@@ -277,7 +277,7 @@ Functions.handleRedirectAndReload = function (data) {
277277 */
278278Functions . getSqlEditor = function ( $textarea , options , resize , lintOptions ) {
279279 var resizeType = resize ;
280- if ( $textarea . length > 0 && typeof CodeMirror !== 'undefined' ) {
280+ if ( $textarea . length > 0 && typeof window . CodeMirror !== 'undefined' ) {
281281 // merge options for CodeMirror
282282 var defaults = {
283283 lineNumbers : true ,
@@ -289,11 +289,11 @@ Functions.getSqlEditor = function ($textarea, options, resize, lintOptions) {
289289 lineWrapping : true
290290 } ;
291291
292- if ( CodeMirror . sqlLint ) {
292+ if ( window . CodeMirror . sqlLint ) {
293293 $ . extend ( defaults , {
294294 gutters : [ 'CodeMirror-lint-markers' ] ,
295295 lint : {
296- 'getAnnotations' : CodeMirror . sqlLint ,
296+ 'getAnnotations' : window . CodeMirror . sqlLint ,
297297 'async' : true ,
298298 'lintOptions' : lintOptions
299299 }
@@ -303,7 +303,7 @@ Functions.getSqlEditor = function ($textarea, options, resize, lintOptions) {
303303 $ . extend ( true , defaults , options ) ;
304304
305305 // create CodeMirror editor
306- var codemirrorEditor = CodeMirror . fromTextArea ( $textarea [ 0 ] , defaults ) ;
306+ var codemirrorEditor = window . CodeMirror . fromTextArea ( $textarea [ 0 ] , defaults ) ;
307307 // allow resizing
308308 if ( ! resizeType ) {
309309 resizeType = 'vertical' ;
@@ -1374,7 +1374,7 @@ Functions.codeMirrorAutoCompleteOnInputRead = function (instance) {
13741374 string = token . string ;
13751375 }
13761376 if ( string . length > 0 ) {
1377- CodeMirror . commands . autocomplete ( instance ) ;
1377+ window . CodeMirror . commands . autocomplete ( instance ) ;
13781378 }
13791379} ;
13801380
@@ -1389,7 +1389,7 @@ Functions.removeAutocompleteInfo = () => {
13891389Functions . bindCodeMirrorToInlineEditor = function ( ) {
13901390 var $inlineEditor = $ ( '#sql_query_edit' ) ;
13911391 if ( $inlineEditor . length > 0 ) {
1392- if ( typeof CodeMirror !== 'undefined' ) {
1392+ if ( typeof window . CodeMirror !== 'undefined' ) {
13931393 var height = $inlineEditor . css ( 'height' ) ;
13941394 codeMirrorInlineEditor = Functions . getSqlEditor ( $inlineEditor ) ;
13951395 codeMirrorInlineEditor . getWrapperElement ( ) . style . height = height ;
@@ -1504,8 +1504,8 @@ Functions.highlightSql = function ($base) {
15041504 if ( $pre . is ( ':visible' ) ) {
15051505 var $highlight = $ ( '<div class="sql-highlight cm-s-default"></div>' ) ;
15061506 $sql . append ( $highlight ) ;
1507- if ( typeof CodeMirror !== 'undefined' ) {
1508- CodeMirror . runMode ( $sql . text ( ) , 'text/x-mysql' , $highlight [ 0 ] ) ;
1507+ if ( typeof window . CodeMirror !== 'undefined' ) {
1508+ window . CodeMirror . runMode ( $sql . text ( ) , 'text/x-mysql' , $highlight [ 0 ] ) ;
15091509 $pre . hide ( ) ;
15101510 $highlight . find ( '.cm-keyword' ) . each ( Functions . documentationKeyword ) ;
15111511 $highlight . find ( '.cm-builtin' ) . each ( Functions . documentationBuiltin ) ;
@@ -1553,9 +1553,9 @@ Functions.updateCode = function ($base, htmlValue, rawValue) {
15531553 var $notHighlighted = $ ( '<pre>' + htmlValue + '</pre>' ) ;
15541554
15551555 // Tries to highlight code using CodeMirror.
1556- if ( typeof CodeMirror !== 'undefined' ) {
1556+ if ( typeof window . CodeMirror !== 'undefined' ) {
15571557 var $highlighted = $ ( '<div class="' + type + '-highlight cm-s-default"></div>' ) ;
1558- CodeMirror . runMode ( rawValue , mode , $highlighted [ 0 ] ) ;
1558+ window . CodeMirror . runMode ( rawValue , mode , $highlighted [ 0 ] ) ;
15591559 $notHighlighted . hide ( ) ;
15601560 $code . html ( '' ) . append ( $notHighlighted , $highlighted [ 0 ] ) ;
15611561 } else {
@@ -2025,12 +2025,12 @@ Functions.prettyProfilingNum = function (number, accuracy) {
20252025 * @return {string } The formatted query
20262026 */
20272027Functions . sqlPrettyPrint = function ( string ) {
2028- if ( typeof CodeMirror === 'undefined' ) {
2028+ if ( typeof window . CodeMirror === 'undefined' ) {
20292029 return string ;
20302030 }
20312031
2032- var mode = CodeMirror . getMode ( { } , 'text/x-mysql' ) ;
2033- var stream = new CodeMirror . StringStream ( string ) ;
2032+ var mode = window . CodeMirror . getMode ( { } , 'text/x-mysql' ) ;
2033+ var stream = new window . CodeMirror . StringStream ( string ) ;
20342034 var state = mode . startState ( ) ;
20352035 var token ;
20362036 var tokens = [ ] ;
@@ -3631,7 +3631,7 @@ Functions.onloadCodeMirrorEditor = () => {
36313631 return ;
36323632 }
36333633 if ( $elm . length > 0 ) {
3634- if ( typeof CodeMirror !== 'undefined' ) {
3634+ if ( typeof window . CodeMirror !== 'undefined' ) {
36353635 window . codeMirrorEditor = Functions . getSqlEditor ( $elm ) ;
36363636 window . codeMirrorEditor . focus ( ) ;
36373637 window . codeMirrorEditor . on ( 'blur' , Functions . updateQueryParameters ) ;
@@ -3788,7 +3788,7 @@ Functions.createViewModal = function ($this) {
37883788 if ( typeof data !== 'undefined' && data . success === true ) {
37893789 Functions . ajaxRemoveMessage ( $msg ) ;
37903790 $ ( '#createViewModalGoButton' ) . on ( 'click' , function ( ) {
3791- if ( typeof CodeMirror !== 'undefined' ) {
3791+ if ( typeof window . CodeMirror !== 'undefined' ) {
37923792 window . codeMirrorEditor . save ( ) ;
37933793 }
37943794 $msg = Functions . ajaxShowMessage ( ) ;
0 commit comments