@@ -8,9 +8,11 @@ cls.JsSourceView = function(id, name, container_class)
88 // split out one general class to handle partial view ( yield count of lines )
99
1010 var self = this ;
11- var frame_id = 'js-source' ;
12- var container_id = 'js-source-content' ;
13- var container_line_nr_id = 'js-source-line-numbers' ;
11+ var frame_id = '' ;
12+ var container_class_name = 'js-source-content' ;
13+ var container_selector = "." + container_class_name ;
14+ var container_line_nr_class = 'js-source-line-numbers' ;
15+ var container_line_nr_selector = "container > .js-source-line-numbers" ;
1416 var scroll_id = 'js-source-scroller' ;
1517 var scroll_content_id = 'js-source-scroll-content' ;
1618 var scroll_container_id = 'js-source-scroll-container' ;
@@ -68,7 +70,7 @@ cls.JsSourceView = function(id, name, container_class)
6870 {
6971 ret [ ret . length ] = templates . line_nummer ( ) ;
7072 }
71- return ret . concat ( [ 'id ' , container_line_nr_id ] ) ;
73+ return ret . concat ( [ 'class ' , container_line_nr_class ] ) ;
7274 }
7375
7476 templates . line_nummer = function ( )
@@ -209,11 +211,11 @@ cls.JsSourceView = function(id, name, container_class)
209211 {
210212 style . width = defaults [ 'scrollbar-width' ] + 'px' ;
211213 }
212- if ( style = sheets . getDeclaration ( '# js-source-content div' ) )
214+ if ( style = sheets . getDeclaration ( '. js-source-content div' ) )
213215 {
214216 style . lineHeight = style . height = context [ 'line-height' ] + 'px' ;
215217 }
216- if ( style = sheets . getDeclaration ( '# js-source-line-numbers li' ) )
218+ if ( style = sheets . getDeclaration ( '. js-source-line-numbers li' ) )
217219 {
218220 style . height = context [ 'line-height' ] + 'px' ;
219221 }
@@ -237,8 +239,7 @@ cls.JsSourceView = function(id, name, container_class)
237239 frame_id = container . id ;
238240 container . innerHTML = "" +
239241 "<div id='js-source-scroll-content'>" +
240- "<div id='js-source-content' " +
241- "class='js-source' " +
242+ "<div class='js-source-content' " +
242243 "data-menu='js-source-content' " +
243244 "data-tooltip='" + cls . JSSourceTooltip . tooltip_name + "'></div>" +
244245 "</div>" +
@@ -251,21 +252,21 @@ cls.JsSourceView = function(id, name, container_class)
251252 }
252253 context [ 'container-height' ] = parseInt ( container . style . height ) ;
253254 var set = null , i = 0 ;
254- source_content = document . getElementById ( container_id ) ;
255+ source_content = document . querySelector ( container_selector ) ;
255256 if ( source_content )
256257 {
257258 if ( document . getElementById ( scroll_container_id ) )
258259 {
259260 document . getElementById ( scroll_container_id ) . onscroll = this . scroll ;
260261 }
261262 __max_lines = context [ 'container-height' ] / context [ 'line-height' ] >> 0 ;
262- var lines = document . getElementById ( container_line_nr_id ) ;
263+ var lines = document . querySelector ( container_line_nr_selector ) ;
263264 if ( lines )
264265 {
265266 lines . parentElement . removeChild ( lines ) ;
266267 }
267268 container . render ( templates . line_nummer_container ( __max_lines || 1 ) ) ;
268- line_numbers = document . getElementById ( container_line_nr_id ) ;
269+ line_numbers = document . querySelector ( container_line_nr_selector ) ;
269270
270271 var selected_script_id = runtimes . getSelectedScript ( ) ;
271272 if ( selected_script_id && selected_script_id != __current_script . script_id )
@@ -432,14 +433,14 @@ cls.JsSourceView = function(id, name, container_class)
432433 {
433434 __max_lines = __current_script . line_arr . length ;
434435 }
435- var lines = document . getElementById ( container_line_nr_id ) ;
436+ var lines = document . querySelector ( container_line_nr_selector ) ;
436437
437438 if ( lines )
438439 {
439440 lines . parentElement . removeChild ( lines ) ;
440441 }
441442 document . getElementById ( frame_id ) . render ( templates . line_nummer_container ( __max_lines ) ) ;
442- line_numbers = document . getElementById ( container_line_nr_id ) ;
443+ line_numbers = document . querySelector ( container_line_nr_selector ) ;
443444 source_content . style . height = ( context [ 'line-height' ] * __max_lines ) + 'px' ;
444445 __current_script . scroll_height = __current_script . line_arr . length * context [ 'line-height' ] ;
445446 updateScriptContext ( ) ;
@@ -452,7 +453,7 @@ cls.JsSourceView = function(id, name, container_class)
452453 __max_lines = 1 ;
453454 document . getElementById ( scroll_container_id ) . style . removeProperty ( 'bottom' ) ;
454455 source_content . style . removeProperty ( 'width' ) ;
455- var lines = document . getElementById ( container_line_nr_id ) ;
456+ var lines = document . querySelector ( container_line_nr_selector ) ;
456457 lines . parentElement . removeChild ( lines ) ;
457458 document . getElementById ( frame_id ) . render ( templates . line_nummer_container ( __max_lines ) ) ;
458459 document . getElementById ( scroll_id ) . style . height = 'auto' ;
@@ -481,7 +482,7 @@ cls.JsSourceView = function(id, name, container_class)
481482
482483 this . get_line_element = function ( line_no )
483484 {
484- var source_content = document . getElementById ( container_id ) ;
485+ var source_content = document . querySelector ( container_selector ) ;
485486 var lines = source_content && source_content . getElementsByTagName ( 'div' ) ;
486487 var line = typeof line_no == "number" && lines && lines [ line_no - __top_line ] ;
487488 return line ;
@@ -513,7 +514,7 @@ cls.JsSourceView = function(id, name, container_class)
513514 __timeout_clear_view = clearTimeout ( __timeout_clear_view ) ;
514515 }
515516
516- var is_visible = ( source_content = document . getElementById ( container_id ) ) ? true : false ;
517+ var is_visible = ( source_content = document . querySelector ( container_selector ) ) ? true : false ;
517518 // if the view is visible it shows the first new script
518519 // before any parse error, that means in case of a parse error
519520 // the current script has not set the parse_error property
@@ -781,7 +782,7 @@ cls.JsSourceView = function(id, name, container_class)
781782
782783 this . clear_stop_at_error = function ( )
783784 {
784- var source_content = document . getElementById ( container_id ) ;
785+ var source_content = document . querySelector ( container_selector ) ;
785786 var tooltip = source_content &&
786787 source_content . querySelector ( "." + ERROR_TOOLTIP_CLASS ) ;
787788
@@ -802,7 +803,7 @@ cls.JsSourceView = function(id, name, container_class)
802803
803804 var __clearView = function ( )
804805 {
805- if ( ( source_content = document . getElementById ( container_id ) ) && source_content . parentElement )
806+ if ( ( source_content = document . querySelector ( container_selector ) ) && source_content . parentElement )
806807 {
807808 var
808809 divs = source_content . parentElement . parentElement . getElementsByTagName ( 'div' ) ,
@@ -1250,7 +1251,7 @@ cls.JsSourceView.create_ui_widgets = function()
12501251 eventHandlers . change [ 'set-tab-size' ] = function ( event , target )
12511252 {
12521253 var
1253- style = document . styleSheets . getDeclaration ( "# js-source-content div" ) ,
1254+ style = document . styleSheets . getDeclaration ( ". js-source-content div" ) ,
12541255 tab_size = event . target . value ;
12551256
12561257 if ( style && / [ 0 - 8 ] / . test ( tab_size ) )
0 commit comments