19 event.preventDefault(); |
19 event.preventDefault(); |
20 $( '.bws_form #bws-submit-button' ).click(); |
20 $( '.bws_form #bws-submit-button' ).click(); |
21 }); |
21 }); |
22 |
22 |
23 /* custom code */ |
23 /* custom code */ |
24 if ( typeof CodeMirror == 'function' ) { |
24 |
|
25 if ( 'function' == typeof wp.CodeMirror || 'function' == typeof CodeMirror ) { |
|
26 var CodeMirrorFunc = ( typeof wp.CodeMirror != 'undefined' ) ? wp.CodeMirror : CodeMirror; |
25 if ( $( '#bws_newcontent_css' ).length > 0 ) { |
27 if ( $( '#bws_newcontent_css' ).length > 0 ) { |
26 var editor = CodeMirror.fromTextArea( document.getElementById( 'bws_newcontent_css' ), { |
28 var editor = CodeMirrorFunc.fromTextArea( document.getElementById( 'bws_newcontent_css' ), { |
27 mode: "css", |
29 mode: "css", |
28 theme: "default", |
30 theme: "default", |
29 styleActiveLine: true, |
31 styleActiveLine: true, |
30 matchBrackets: true, |
32 matchBrackets: true, |
31 lineNumbers: true, |
33 lineNumbers: true, |
32 addModeClass: 'bws_newcontent_css' |
34 addModeClass: 'bws_newcontent_css' |
33 }); |
35 }); |
34 } |
36 } |
35 |
37 |
36 if ( $( '#bws_newcontent_php' ).length > 0 ) { |
38 if ( $( '#bws_newcontent_php' ).length > 0 ) { |
37 var editor = CodeMirror.fromTextArea( document.getElementById( "bws_newcontent_php" ), { |
39 var editor = CodeMirrorFunc.fromTextArea( document.getElementById( "bws_newcontent_php" ), { |
38 mode: 'text/x-php', |
40 mode: 'text/x-php', |
39 styleActiveLine: true, |
41 styleActiveLine: true, |
40 matchBrackets: true, |
42 matchBrackets: true, |
41 lineNumbers: true, |
43 lineNumbers: true, |
42 }); |
44 }); |
43 /* disable lines */ |
45 /* disable lines */ |
44 editor.markText( {ch:0,line:0}, {ch:0,line:5}, { readOnly: true, className: 'bws-readonly' } ); |
46 editor.markText( {ch:0,line:0}, {ch:0,line:5}, { readOnly: true, className: 'bws-readonly' } ); |
45 } |
47 } |
46 |
48 |
47 if ( $( '#bws_newcontent_js' ).length > 0 ) { |
49 if ( $( '#bws_newcontent_js' ).length > 0 ) { |
48 var editor = CodeMirror.fromTextArea( document.getElementById( "bws_newcontent_js" ), { |
50 var editor = CodeMirrorFunc.fromTextArea( document.getElementById( "bws_newcontent_js" ), { |
49 mode: 'javascript', |
51 mode: 'javascript', |
50 styleActiveLine: true, |
52 styleActiveLine: true, |
51 matchBrackets: true, |
53 matchBrackets: true, |
52 lineNumbers: true, |
54 lineNumbers: true, |
53 }); |
55 }); |