@@ -57,10 +57,9 @@ p.init = function (element, content) {
57
57
this . previewWrap = $ . el ( ".preview-wrap" , this . contentTemplate ) ;
58
58
this . preview = $ . el ( ".preview" , this . contentTemplate ) ;
59
59
60
- this . toolWrapReplace = $ . el ( ".tool-wrap-replace" , this . contentTemplate ) ;
61
- this . toolWrapList = $ . el ( ".tool-wrap-list" , this . contentTemplate ) ;
62
- this . toolReplace = $ . el ( ".tool-replace-content" , this . contentTemplate ) ;
63
- this . toolList = $ . el ( ".tool-list-content" , this . contentTemplate ) ;
60
+ this . toolWrap = $ . el ( ".tool-wrap" , this . contentTemplate ) ;
61
+ this . toolContent = $ . el ( ".tool-content" , this . contentTemplate ) ;
62
+ this . toolTitle = $ . el ( ".tool-label" , this . contentTemplate ) ;
64
63
65
64
this . favoriteBtn = $ . el ( ".favorite" , this . contentTemplate ) ;
66
65
this . favoriteBtn . addEventListener ( "mouseover" , $ . bind ( this , this . handleFavoriteOver ) ) ;
@@ -219,17 +218,14 @@ p.handleFavoritesLoad = function (data) {
219
218
p . onLoadClick = function ( evt ) {
220
219
var el = evt . target ;
221
220
var type = '' ;
222
-
223
221
if ( $ . hasClass ( el , ".expr" ) ) {
224
222
type = "expr" ;
225
223
} else if ( $ . hasClass ( el , ".source" ) ) {
226
224
type = "source" ;
227
225
} else if ( $ . hasClass ( el , ".all" ) ) {
228
226
type = "all" ;
229
- } else if ( $ . hasClass ( el , ".tool-list" ) ) {
230
- type = "list" ;
231
- } else if ( $ . hasClass ( el , ".tool-replace" ) ) {
232
- type = "replace" ;
227
+ } else if ( $ . hasClass ( el , ".tool" ) ) {
228
+ type = this . list . selectedItem . state . tool ;
233
229
}
234
230
this . insertContent ( type ) ;
235
231
} ;
@@ -338,20 +334,13 @@ p.onListChange = function (evt) {
338
334
339
335
this . updateFavorite ( data . id ) ;
340
336
341
- if ( data . state && data . state . replace ) {
342
- this . toolReplace . innerHTML = TextUtils . htmlSafe ( data . state [ "replace" ] ) ;
343
-
344
- $ . removeClass ( this . toolWrapReplace , "hidden" ) ;
345
- } else {
346
- $ . addClass ( this . toolWrapReplace , "hidden" ) ;
347
- }
348
-
349
- if ( data . state && data . state . list ) {
350
- this . toolList . innerHTML = TextUtils . htmlSafe ( data . state [ "list" ] ) ;
337
+ if ( data . state && data . state . tool && data . state [ data . state . tool ] ) {
338
+ this . toolContent . innerHTML = TextUtils . htmlSafe ( data . state [ data . state . tool ] ) ;
339
+ this . toolTitle . innerText = data . state . tool . substr ( 0 , 1 ) . toUpperCase ( ) + data . state . tool . substr ( 1 ) ;
351
340
352
- $ . removeClass ( this . toolWrapList , "hidden" ) ;
341
+ $ . removeClass ( this . toolWrap , "hidden" ) ;
353
342
} else {
354
- $ . addClass ( this . toolWrapList , "hidden" ) ;
343
+ $ . addClass ( this . toolWrap , "hidden" ) ;
355
344
}
356
345
357
346
0 commit comments