Skip to content

Commit

Permalink
save current tab for each part
Browse files Browse the repository at this point in the history
  • Loading branch information
christianp committed Mar 28, 2017
1 parent bee0725 commit a87754f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions editor/static/js/question/edit.js
Expand Up @@ -295,6 +295,22 @@ $(document).ready(function() {
} else {
return undefined;
}
},this));
if('currentPartTabs' in state) {
Object.keys(state.currentPartTabs).forEach(function(path) {
var tab = state.currentPartTabs[path];
var part = q.getPart(path);
if(part) {
part.setTab(tab)();
}
});
}
Editor.computedReplaceState('currentPartTabs',ko.computed(function() {
var d = {};
q.allParts().forEach(function(p) {
d[p.path()] = p.currentTab().id;
});
return d;
},this));
}

Expand Down Expand Up @@ -1636,6 +1652,18 @@ $(document).ready(function() {
write: this.realCurrentTab
},this);

this.getTab = function(id) {
return p.tabs().find(function(t){return t.id==id});
}

this.setTab = function(id) {
return function() {
var tab = p.getTab(id);
p.currentTab(tab);
}
}


this.marks = ko.observable(1);
this.realMarks = ko.computed(function() {
switch(this.type().name) {
Expand Down

0 comments on commit a87754f

Please sign in to comment.