@@ -1148,88 +1148,86 @@ var ICEcoder = {
11481148 }
11491149 } ,
11501150
1151- setMinimap : function ( ) {
1152- var cM ;
1153-
1154- cM = ICEcoder . getcMInstance ( ) ;
1155- top . ICEcoder . functionClassList = [ ] ;
1156-
1157- if ( cM ) {
1158- top . ICEcoder . content . contentWindow . CodeMirror . runMode ( cM . getValue ( ) , "application/x-httpd-php" , get ( 'miniMapContent' ) ) ;
1159- // white-space: pre; vs pre-wrap
1160- get ( 'miniMapContent' ) . innerHTML = '<div class="cm-s-' + top . ICEcoder . theme + '" style="font-family: monospace; white-space: pre-wrap; font-size: 2px; line-height: 2px">' + get ( 'miniMapContent' ) . innerHTML + '</div>' ;
1161- get ( 'miniMapContent' ) . innerHTML = get ( 'miniMapContent' ) . innerHTML . replace ( / \< s p a n / g, '<span style="font-size: 2px; font-family: monospace" ' ) ;
1162-
1163- get ( 'miniMapContainer' ) . innerHTML = '<div style="position: absolute; display: inline-block; top: ' +
1164- top . ICEcoder . miniMapBoxTop +
1165- 'px; left: 0; width: 200px; height: ' +
1166- top . ICEcoder . miniMapBoxHeight + 'px; background: rgba(0,198,255,0.3); z-index: 100; cursor: pointer" id="miniMapBox"></div>' ;
1167-
1168- if ( ! top . ICEcoder . minimapNav ) {
1169-
1170- var elem = get ( 'miniMapBox' ) ;
1171- var draggie = new Draggabilly ( elem , {
1172- axis : 'y' ,
1173- containment : true
1174- } ) ;
1175-
1176- draggie . on ( 'dragMove' , function ( event , pointer , moveVector ) {
1177- yPos = this . position . y ;
1178- maxHeight = parseInt ( get ( 'docExplorer' ) . style . height , 10 ) <= parseInt ( get ( 'miniMapContent' ) . getBoundingClientRect ( ) . height , 10 )
1179- ? parseInt ( get ( 'docExplorer' ) . style . height , 10 )
1180- : parseInt ( get ( 'miniMapContent' ) . getBoundingClientRect ( ) . height , 10 ) ;
1181- newPerc = ( this . position . y / ( maxHeight - top . ICEcoder . miniMapBoxHeight ) ) ;
1182- yPos = ( cM . getScrollInfo ( ) . height - cM . getScrollInfo ( ) . clientHeight ) * newPerc ;
1183- cM . scrollTo ( 0 , yPos ) ; // this.position.y
1184- } ) ;
1185- draggie . on ( 'pointerDown' , function ( event , pointer ) {
1186- top . ICEcoder . mouseDownMinimap = true ;
1187- } ) ;
1188- draggie . on ( 'pointerUp' , function ( event , pointer ) {
1189- top . ICEcoder . mouseDownMinimap = false ;
1190- } ) ;
1191- top . ICEcoder . minimapNav = true ;
1192- }
1193- }
1194- } ,
1195-
1196- updateFunctionClassListItems : function ( x ) {
1197- var cM ;
1151+ // Update function/class list items
1152+ updateFunctionClassListItems : function ( handle ) {
1153+ var cM , functionClassText ;
11981154
11991155 cM = ICEcoder . getcMInstance ( ) ;
12001156 functionClassText = "" ;
1201- if ( x . text . indexOf ( "function " ) > - 1 && x . text . replace ( / \$ f u n c t i o n / g, "" ) . indexOf ( "function " ) > - 1 ) {
1202- functionClassText = x . text . substring ( x . text . indexOf ( "function " ) + 9 ) ;
1157+ // Get function declaration lines
1158+ if ( handle . text . indexOf ( "function " ) > - 1 && handle . text . replace ( / \$ f u n c t i o n / g, "" ) . indexOf ( "function " ) > - 1 ) {
1159+ functionClassText = handle . text . substring ( handle . text . indexOf ( "function " ) + 9 ) ;
12031160 }
1204- if ( x . text . indexOf ( "class " ) > - 1 && x . text . replace ( / \$ c l a s s / g, "" ) . indexOf ( "class " ) > - 1 ) {
1205- functionClassText = x . text . substring ( x . text . indexOf ( "class " ) + 6 ) ;
1161+ // Get class declaration lines
1162+ if ( handle . text . indexOf ( "class " ) > - 1 && handle . text . replace ( / \$ c l a s s / g, "" ) . indexOf ( "class " ) > - 1 ) {
1163+ functionClassText = handle . text . substring ( handle . text . indexOf ( "class " ) + 6 ) ;
12061164 }
1165+ // Get just the name of the function/class
12071166 functionClassText = functionClassText . trim ( ) . split ( "{" ) [ 0 ] . split ( "(" ) ;
12081167
1168+ // Push items into array
12091169 if ( functionClassText [ 0 ] != "" ) {
12101170 top . ICEcoder . functionClassList . push ( {
1211- line : cM . getLineNumber ( x ) ,
1171+ line : cM . getLineNumber ( handle ) ,
12121172 name : functionClassText [ 0 ] ,
12131173 params : "(" + functionClassText [ 1 ] ,
12141174 verified : false
12151175 } ) ;
1176+ // After a 0ms tickover, verify the item
12161177 setTimeout ( function ( ) {
1217- if ( ! x . styles || ( x . styles && x . styles . indexOf ( 'def' ) > - 1 && cM . getLineNumber ( x ) ) ) {
1218- //if (x.styles && x.styles.indexOf('def') > -1 && cM.getLineNumber(x)) {
1178+ // If we're defining a function/class
1179+ if ( ! handle . styles || ( handle . styles && handle . styles . indexOf ( 'def' ) > - 1 && cM . getLineNumber ( handle ) ) ) {
1180+ // Find our item in the array and mark it as verified
12191181 for ( var i = 0 ; i < top . ICEcoder . functionClassList . length ; i ++ ) {
1220- if ( top . ICEcoder . functionClassList [ i ] [ 'line' ] == cM . getLineNumber ( x ) ) {
1182+ if ( top . ICEcoder . functionClassList [ i ] [ 'line' ] == cM . getLineNumber ( handle ) ) {
12211183 top . ICEcoder . functionClassList [ i ] [ 'verified' ] = true ;
12221184 }
12231185 } ;
12241186 }
1225-
1226-
12271187 } , 0 ) ;
12281188 }
1189+ } ,
12291190
1191+ // Set the Minimap
1192+ setMinimap : function ( ) {
1193+ var cM ;
12301194
1195+ cM = ICEcoder . getcMInstance ( ) ;
12311196
1197+ if ( cM ) {
1198+ // Get syntax formatted content and output to miniMapContent
1199+ top . ICEcoder . content . contentWindow . CodeMirror . runMode ( cM . getValue ( ) , cM . getOption ( 'mode' ) , get ( 'miniMapContent' ) ) ;
1200+ // white-space: pre; vs pre-wrap
1201+ get ( 'miniMapContent' ) . innerHTML = '<div class="cm-s-' + top . ICEcoder . theme + '" style="font-family: monospace; white-space: pre-wrap; font-size: 2px; line-height: 2px">' + get ( 'miniMapContent' ) . innerHTML + '</div>' ;
1202+ get ( 'miniMapContent' ) . innerHTML = get ( 'miniMapContent' ) . innerHTML . replace ( / \< s p a n / g, '<span style="font-size: 2px; font-family: monospace" ' ) ;
12321203
1204+ get ( 'miniMapContainer' ) . innerHTML = '<div style="position: absolute; display: inline-block; top: ' +
1205+ top . ICEcoder . miniMapBoxTop +
1206+ 'px; left: 0; width: 200px; height: ' +
1207+ top . ICEcoder . miniMapBoxHeight + 'px; background: rgba(0,198,255,0.3); z-index: 100; cursor: pointer" id="miniMapBox"></div>' ;
1208+
1209+ var elem = get ( 'miniMapBox' ) ;
1210+ var draggie = new Draggabilly ( elem , {
1211+ axis : 'y' ,
1212+ containment : true
1213+ } ) ;
1214+
1215+ draggie . on ( 'dragMove' , function ( event , pointer , moveVector ) {
1216+ yPos = this . position . y ;
1217+ maxHeight = parseInt ( get ( 'docExplorer' ) . style . height , 10 ) <= parseInt ( get ( 'miniMapContent' ) . getBoundingClientRect ( ) . height , 10 )
1218+ ? parseInt ( get ( 'docExplorer' ) . style . height , 10 )
1219+ : parseInt ( get ( 'miniMapContent' ) . getBoundingClientRect ( ) . height , 10 ) ;
1220+ newPerc = ( this . position . y / ( maxHeight - top . ICEcoder . miniMapBoxHeight ) ) ;
1221+ yPos = ( cM . getScrollInfo ( ) . height - cM . getScrollInfo ( ) . clientHeight ) * newPerc ;
1222+ cM . scrollTo ( 0 , yPos ) ; // this.position.y
1223+ } ) ;
1224+ draggie . on ( 'pointerDown' , function ( event , pointer ) {
1225+ top . ICEcoder . mouseDownMinimap = true ;
1226+ } ) ;
1227+ draggie . on ( 'pointerUp' , function ( event , pointer ) {
1228+ top . ICEcoder . mouseDownMinimap = false ;
1229+ } ) ;
1230+ }
12331231 } ,
12341232
12351233 // Autocomplete
@@ -3126,14 +3124,15 @@ var ICEcoder = {
31263124 var newTheme = cleanThemeUrl . slice ( cleanThemeUrl . lastIndexOf ( "/" ) + 1 , cleanThemeUrl . lastIndexOf ( "." ) ) ;
31273125 // if theme was not changed - no need to do all these tricks
31283126 if ( top . ICEcoder . theme !== newTheme ) {
3129- // Add new stylesheet for selected theme
3127+ // Add new stylesheet for selected theme to editor
31303128 top . ICEcoder . theme = newTheme ;
31313129 if ( top . ICEcoder . theme == "editor" ) { top . ICEcoder . theme = "icecoder" } ;
31323130 styleNode = document . createElement ( 'link' ) ;
31333131 styleNode . setAttribute ( 'rel' , 'stylesheet' ) ;
31343132 styleNode . setAttribute ( 'type' , 'text/css' ) ;
31353133 styleNode . setAttribute ( 'href' , themeURL ) ;
31363134 top . ICEcoder . content . contentWindow . document . getElementsByTagName ( 'head' ) [ 0 ] . appendChild ( styleNode ) ;
3135+ // Add new stylesheet for selected theme to top level (used by Minimap)
31373136 styleNode = document . createElement ( 'link' ) ;
31383137 styleNode . setAttribute ( 'rel' , 'stylesheet' ) ;
31393138 styleNode . setAttribute ( 'type' , 'text/css' ) ;
0 commit comments