@@ -30,13 +30,6 @@ var codeViewer = {
30
30
31
31
e . preventDefault ( ) ;
32
32
33
- // make sure the annotations overlay is off before showing code view
34
- $ ( '#sg-t-annotations' ) . removeClass ( 'active' ) ;
35
- annotationsViewer . commentsActive = false ;
36
- var obj = JSON . stringify ( { "commentToggle" : "off" } ) ;
37
- document . getElementById ( 'sg-viewport' ) . contentWindow . postMessage ( obj , codeViewer . targetOrigin ) ;
38
- annotationsViewer . slideComment ( 999 ) ;
39
-
40
33
// remove the class from the "eye" nav item
41
34
$ ( '#sg-t-toggle' ) . removeClass ( 'active' ) ;
42
35
@@ -71,10 +64,22 @@ var codeViewer = {
71
64
* after clicking the code view link open the panel
72
65
*/
73
66
openCode : function ( ) {
67
+
68
+ // make sure the annotations overlay is off before showing code view
69
+ $ ( '#sg-t-annotations' ) . removeClass ( 'active' ) ;
70
+ annotationsViewer . commentsActive = false ;
71
+ var obj = JSON . stringify ( { "commentToggle" : "off" } ) ;
72
+ document . getElementById ( 'sg-viewport' ) . contentWindow . postMessage ( obj , codeViewer . targetOrigin ) ;
73
+ annotationsViewer . slideComment ( 999 ) ;
74
+
75
+ // tell the iframe code view has been turned on
74
76
var obj = JSON . stringify ( { "codeToggle" : "on" } ) ;
75
77
document . getElementById ( 'sg-viewport' ) . contentWindow . postMessage ( obj , codeViewer . targetOrigin ) ;
78
+
79
+ // note it's turned on in the viewer
76
80
codeViewer . codeActive = true ;
77
81
$ ( '#sg-t-code' ) . addClass ( 'active' ) ;
82
+
78
83
} ,
79
84
80
85
/**
@@ -238,35 +243,30 @@ var codeViewer = {
238
243
$ ( "#sg-code-lineage" ) . css ( "display" , "none" ) ;
239
244
}
240
245
241
-
242
- // when clicking on a lineage item change the iframe source
243
- $ ( '#sg-code-lineage-fill a' ) . on ( "click" , function ( e ) {
244
- e . preventDefault ( ) ;
245
- var obj = JSON . stringify ( { "path" : urlHandler . getFileName ( $ ( this ) . attr ( "data-patternpartial" ) ) } ) ;
246
- document . getElementById ( "sg-viewport" ) . contentWindow . postMessage ( obj , codeViewer . targetOrigin ) ;
247
- } ) ;
248
-
249
246
// draw reverse lineage
250
247
if ( lineageR . length !== 0 ) {
251
248
var lineageRList = "" ;
252
249
$ ( "#sg-code-lineager" ) . css ( "display" , "block" ) ;
253
250
for ( var i = 0 ; i < lineageR . length ; i ++ ) {
254
251
lineageRList += ( i === 0 ) ? "" : ", " ;
255
- var cssClass = ( lineageR [ i ] . lineageState != undefined ) ? lineageR [ i ] . lineageState : "" ;
252
+ var cssClass = ( lineageR [ i ] . lineageState != undefined ) ? "sg-pattern-state " + lineageR [ i ] . lineageState : "" ;
256
253
lineageRList += "<a href='" + lineageR [ i ] . lineagePath + "' class='" + cssClass + "' data-patternPartial='" + lineageR [ i ] . lineagePattern + "'>" + lineageR [ i ] . lineagePattern + "</a>" ;
257
254
}
258
255
$ ( "#sg-code-lineager-fill" ) . html ( lineageRList ) ;
259
256
} else {
260
257
$ ( "#sg-code-lineager" ) . css ( "display" , "none" ) ;
261
258
}
262
259
263
- // when clicking on a reverse lineage item change the iframe source
264
- $ ( '#sg-code-lineager-fill a' ) . on ( "click" , function ( e ) {
260
+ // when clicking on a lineage item change the iframe source
261
+ $ ( '#sg-code-lineage-fill a, #sg-code- lineager-fill a' ) . on ( "click" , function ( e ) {
265
262
e . preventDefault ( ) ;
266
- var obj = JSON . stringify ( { "path" : urlHandler . getFileName ( $ ( this ) . attr ( "data-patternpartial" ) ) } ) ;
263
+ $ ( "#sg-code-loader" ) . css ( "display" , "block" ) ;
264
+ var obj = JSON . stringify ( { "path" : urlHandler . getFileName ( $ ( this ) . attr ( "data-patternpartial" ) ) } ) ;
267
265
document . getElementById ( "sg-viewport" ) . contentWindow . postMessage ( obj , codeViewer . targetOrigin ) ;
268
266
} ) ;
269
267
268
+ $ ( '#sg-code-lineage-patternname, #sg-code-lineager-patternname' ) . html ( patternPartial ) ;
269
+
270
270
// get the file name of the pattern so we can get the various editions of the code that can show in code view
271
271
var fileName = urlHandler . getFileName ( patternPartial ) ;
272
272
@@ -292,7 +292,9 @@ var codeViewer = {
292
292
293
293
// move the code into view
294
294
codeViewer . slideCode ( 0 ) ;
295
-
295
+
296
+ $ ( "#sg-code-loader" ) . css ( "display" , "none" ) ;
297
+
296
298
} ,
297
299
298
300
/**
0 commit comments