@@ -340,14 +340,14 @@ p.showTools = function (value) {
340
340
} ;
341
341
342
342
p . setTool = function ( tool ) {
343
- if ( tool == this . tool ) { return ; }
343
+ if ( tool == this . tool || ! tool ) { return ; }
344
344
var el ;
345
345
if ( this . tool ) {
346
346
el = $ . el ( ".tools.title .button." + this . tool ) ;
347
347
$ . removeClass ( el , "active" ) ;
348
348
}
349
349
this . tool = tool ;
350
- el = $ . el ( ".tools.title .button." + this . tool ) ;
350
+ el = $ . el ( ".tools.title .button." + tool ) ;
351
351
$ . addClass ( el , "active" ) ;
352
352
353
353
$ . removeClass ( this . element , / t o o l - / ) ;
@@ -356,33 +356,34 @@ p.setTool = function(tool) {
356
356
this . updateTool ( ) ;
357
357
} ;
358
358
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 ) ;
364
361
this . setTool ( tool ) ;
365
- if ( value != null ) { this . setToolValue ( value ) ; }
366
- this . showTools ( true ) ;
367
362
} ;
368
363
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 ) ;
371
369
} ;
372
370
371
+ /** Unused
373
372
p.setToolValue = function(value) {
374
373
var toolCM = this.getToolCM();
375
374
if (toolCM) { toolCM.setValue(value); }
376
375
};
376
+ */
377
377
378
378
p . getToolCM = function ( ) {
379
379
return this . tool === "replace" ? this . replaceCM : this . tool === "list" ? this . listCM : null ;
380
380
} ;
381
381
382
382
p . getState = function ( ) {
383
- var state = { } , cm = this . getToolCM ( ) ;
383
+ var state = { } ;
384
384
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 ( ) ;
386
387
return state ;
387
388
} ;
388
389
0 commit comments