PluginProbe
TablePress – Tables in WordPress made easy / 1.14
TablePress – Tables in WordPress made easy v1.14
3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 2.4.4 All 44 releases
tablepress / admin / js / codemirror.js

codemirror.js in TablePress – Tables in WordPress made easy 1.14, at admin/js/codemirror.js

62 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * JavaScript code for the CodeMirror handling on the "Options" screen
3 *
4 * @package TablePress
5 * @subpackage Views JavaScript
6 * @author Tobias Bäthge
7 * @since 1.9.0
8 */
9
10 /* global wp, tablepress_codemirror_settings */
11
12 jQuery( function( $ ) {
13
14 'use strict';
15
16 /**
17 * Invoke CodeMirror on the "Custom CSS" textarea.
18 *
19 * @since 1.9.0
20 */
21 var CM_custom_css = wp.codeEditor.initialize( document.getElementById( 'option-custom-css' ), tablepress_codemirror_settings );
22
23 /**
24 * Make the CodeMirror textarea vertically resizable.
25 *
26 * @since 1.7.0
27 */
28 $( CM_custom_css.codemirror.getWrapperElement() ).resizable( {
29 handles: 's',
30 resize: function() {
31 var $this = $(this);
32 CM_custom_css.codemirror.setSize( $this.width(), $this.height() );
33 }
34 } );
35
36 /**
37 * Let CodeMirror textarea grow on first focus, if it is not disabled.
38 *
39 * @since 1.0.0
40 */
41 $( '#tablepress-page' ).find( '.CodeMirror' ).on( 'mousedown.codemirror', function() {
42 var $this = $(this);
43 if ( ! $this.hasClass( 'disabled' ) ) {
44 $this.addClass( 'large' );
45 CM_custom_css.codemirror.refresh();
46 $this.off( 'mousedown.codemirror' );
47 }
48 } );
49
50 /**
51 * Enable/disable CodeMirror according to state of "Load Custom CSS" checkbox.
52 *
53 * @since 1.0.0
54 */
55 $( '#option-use-custom-css' ).on( 'change', function() {
56 var use_custom_css = $(this).prop( 'checked' );
57 CM_custom_css.codemirror.setOption( 'readOnly', ! use_custom_css );
58 $( '#tablepress-page' ).find( '.CodeMirror' ).toggleClass( 'disabled', ! use_custom_css );
59 } ).trigger( 'change' );
60
61 } );
62