| 1 |
function bws_show_settings_notice() { |
| 2 |
(function($) { |
| 3 |
$( '.updated.fade, .error' ).css( 'display', 'none' ); |
| 4 |
$( '#bws_save_settings_notice' ).css( 'display', 'block' ); |
| 5 |
})(jQuery); |
| 6 |
} |
| 7 |
|
| 8 |
(function($) { |
| 9 |
$( document ).ready( function() { |
| 10 |
/** |
| 11 |
* add notice about changing on the settings page |
| 12 |
*/ |
| 13 |
$( '.bws_form input, .bws_form textarea, .bws_form select' ).bind( "change paste select", function() { |
| 14 |
if ( $( this ).attr( 'type' ) != 'submit' && ! $( this ).hasClass( 'bws_no_bind_notice' ) ) { |
| 15 |
bws_show_settings_notice(); |
| 16 |
}; |
| 17 |
}); |
| 18 |
$( '.bws_save_anchor' ).on( "click", function( event ) { |
| 19 |
event.preventDefault(); |
| 20 |
$( '.bws_form #bws-submit-button' ).click(); |
| 21 |
}); |
| 22 |
|
| 23 |
/* custom code */ |
| 24 |
if ( typeof CodeMirror == 'function' ) { |
| 25 |
if ( $( '#bws_newcontent_css' ).length > 0 ) { |
| 26 |
var editor = CodeMirror.fromTextArea( document.getElementById( 'bws_newcontent_css' ), { |
| 27 |
mode: "css", |
| 28 |
theme: "default", |
| 29 |
styleActiveLine: true, |
| 30 |
matchBrackets: true, |
| 31 |
lineNumbers: true, |
| 32 |
}); |
| 33 |
} |
| 34 |
|
| 35 |
if ( $( '#bws_newcontent_php' ).length > 0 ) { |
| 36 |
var editor = CodeMirror.fromTextArea( document.getElementById( "bws_newcontent_php" ), { |
| 37 |
mode: 'text/x-php', |
| 38 |
styleActiveLine: true, |
| 39 |
matchBrackets: true, |
| 40 |
lineNumbers: true, |
| 41 |
}); |
| 42 |
/* disable lines */ |
| 43 |
editor.markText( {ch:0,line:0}, {ch:0,line:5}, { readOnly: true, className: 'bws-readonly' } ); |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
/* banner to settings */ |
| 48 |
$( '.bws_banner_to_settings_joint .bws-details' ).addClass( 'hidden' ).removeClass( 'hide-if-js' ); |
| 49 |
$( '.bws_banner_to_settings_joint .bws-more-links' ).on( "click", function( event ) { |
| 50 |
event.preventDefault(); |
| 51 |
if ( $( '.bws_banner_to_settings_joint .bws-less' ).hasClass( 'hidden' ) ) { |
| 52 |
$( '.bws_banner_to_settings_joint .bws-less, .bws_banner_to_settings_joint .bws-details' ).removeClass( 'hidden' ); |
| 53 |
$( '.bws_banner_to_settings_joint .bws-more' ).addClass( 'hidden' ); |
| 54 |
} else { |
| 55 |
$( '.bws_banner_to_settings_joint .bws-less, .bws_banner_to_settings_joint .bws-details' ).addClass( 'hidden' ); |
| 56 |
$( '.bws_banner_to_settings_joint .bws-more' ).removeClass( 'hidden' ); |
| 57 |
} |
| 58 |
}); |
| 59 |
}); |
| 60 |
})(jQuery); |