@@ -57,9 +57,10 @@ 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 . toolWrap = $ . el ( ".tool-wrap" , this . contentTemplate ) ;
61
- this . toolTitle = $ . el ( ".tool-title" , this . contentTemplate ) ;
62
- this . tool = $ . el ( ".tool" , this . contentTemplate ) ;
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 ) ;
63
64
64
65
this . favoriteBtn = $ . el ( ".favorite" , this . contentTemplate ) ;
65
66
this . favoriteBtn . addEventListener ( "mouseover" , $ . bind ( this , this . handleFavoriteOver ) ) ;
@@ -225,8 +226,10 @@ p.onLoadClick = function (evt) {
225
226
type = "source" ;
226
227
} else if ( $ . hasClass ( el , ".all" ) ) {
227
228
type = "all" ;
228
- } else if ( $ . hasClass ( el , ".subst" ) ) {
229
- type = "subst" ;
229
+ } else if ( $ . hasClass ( el , ".tool-list" ) ) {
230
+ type = "list" ;
231
+ } else if ( $ . hasClass ( el , ".tool-replace" ) ) {
232
+ type = "replace" ;
230
233
}
231
234
this . insertContent ( type ) ;
232
235
} ;
@@ -265,8 +268,12 @@ p.insertContent = function (type) {
265
268
this . docView . setFlags ( flags ) ;
266
269
} else if ( type == "source" ) {
267
270
this . docView . setText ( data . content ) ;
268
- } else if ( type == "subst" ) {
269
- this . docView . showTool ( data . state . tool , data . state . toolValue ) ;
271
+ } else if ( type == "list" ) {
272
+ this . docView . setState ( data . state ) ;
273
+ this . docView . showTool ( "list" ) ;
274
+ } else if ( type == "replace" ) {
275
+ this . docView . setState ( data . state ) ;
276
+ this . docView . showTool ( "replace" ) ;
270
277
} else if ( type == "all" ) {
271
278
if ( ExpressionModel . id != data . id ) {
272
279
ExpressionModel . setID ( data . id ) ;
@@ -331,27 +338,23 @@ p.onListChange = function (evt) {
331
338
332
339
this . updateFavorite ( data . id ) ;
333
340
334
- if ( data . state ) {
335
- // TODO: Pull into a strings file.
336
- // Also update index.html
337
- var toolText = "" ;
338
- switch ( data . state . tool ) {
339
- case "replace" :
340
- toolText = "Replace" ; break ;
341
- case "list" :
342
- toolText = "List" ; break ;
343
- case "details" :
344
- toolText = "Details" ; break ;
345
- case "graph" :
346
- toolText = "Graph" ; break ;
347
- }
348
- this . toolTitle . innerText = toolText ;
349
- this . tool . innerHTML = TextUtils . htmlSafe ( data . state . toolValue ) ;
350
- $ . removeClass ( this . toolWrap , "hidden" ) ;
341
+ if ( data . state && data . state . replace ) {
342
+ this . toolReplace . innerHTML = TextUtils . htmlSafe ( data . state [ "replace" ] ) ;
343
+
344
+ $ . removeClass ( this . toolWrapReplace , "hidden" ) ;
351
345
} else {
352
- $ . addClass ( this . toolWrap , "hidden" ) ;
346
+ $ . addClass ( this . toolWrapReplace , "hidden" ) ;
353
347
}
354
348
349
+ if ( data . state && data . state . list ) {
350
+ this . toolList . innerHTML = TextUtils . htmlSafe ( data . state [ "list" ] ) ;
351
+
352
+ $ . removeClass ( this . toolWrapList , "hidden" ) ;
353
+ } else {
354
+ $ . addClass ( this . toolWrapList , "hidden" ) ;
355
+ }
356
+
357
+
355
358
if ( this . _visible ) {
356
359
$ . removeClass ( this . element , "hidden" ) ;
357
360
this . showLoading ( false ) ;
0 commit comments