Skip to content

Commit d1fae45

Browse files
committed
Save now includes full tool state.
Signed-off-by: Grant Skinner <[email protected]>
1 parent 4bcfdcd commit d1fae45

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

js/views/DocView.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -340,14 +340,14 @@ p.showTools = function (value) {
340340
};
341341

342342
p.setTool = function(tool) {
343-
if (tool == this.tool) { return; }
343+
if (tool == this.tool || !tool) { return; }
344344
var el;
345345
if (this.tool) {
346346
el = $.el(".tools.title .button."+this.tool);
347347
$.removeClass(el,"active");
348348
}
349349
this.tool = tool;
350-
el = $.el(".tools.title .button."+this.tool);
350+
el = $.el(".tools.title .button."+tool);
351351
$.addClass(el,"active");
352352

353353
$.removeClass(this.element, /tool-/);
@@ -356,33 +356,34 @@ p.setTool = function(tool) {
356356
this.updateTool();
357357
};
358358

359-
p.showTool = function(tool, value) {
360-
if (!tool) {
361-
this.showTools(false);
362-
return;
363-
}
359+
p.showTool = function(tool) {
360+
this.showTools(!!tool);
364361
this.setTool(tool);
365-
if (value != null) { this.setToolValue(value); }
366-
this.showTools(true);
367362
};
368363

369-
p.setState = function (value) {
370-
this.showTool(value&&value.tool, value&&value.toolValue);
364+
p.setState = function (state) {
365+
if (!state) { return; }
366+
this.replaceCM.setValue(state.replace);
367+
this.listCM.setValue(state.list);
368+
this.showTool(state.tool);
371369
};
372370

371+
/** Unused
373372
p.setToolValue = function(value) {
374373
var toolCM = this.getToolCM();
375374
if (toolCM) { toolCM.setValue(value); }
376375
};
376+
*/
377377

378378
p.getToolCM = function() {
379379
return this.tool === "replace" ? this.replaceCM : this.tool === "list" ? this.listCM : null;
380380
};
381381

382382
p.getState = function () {
383-
var state = {}, cm = this.getToolCM();
383+
var state = {};
384384
if (this.toolsEnabled) { state.tool = this.tool; }
385-
if (cm) { state.toolValue = cm.getValue(); }
385+
state.replace = this.replaceCM.getValue();
386+
state.list = this.listCM.getValue();
386387
return state;
387388
};
388389

0 commit comments

Comments
 (0)