PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.4 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 All 45 releases
← All changes | admin/js/codemirror.js +38 -31 2.0.4 → 3.4 View file →
@@ -6,42 +6,49 @@
6 6 * @author Tobias Bäthge
7 7 * @since 1.9.0
8 8 */
9 9
10 -/* globals wp */
10 +/* globals tp, wp */
11 11
12 12 /* jshint strict: global */
13 13 'use strict'; // Necessary as this file does not use "import".
14 14
15 -/**
16 - * Invoke CodeMirror on the "Custom CSS" textarea.
17 - *
18 - * @since 1.9.0
19 - */
20 -const CM_custom_css = wp.codeEditor.initialize( 'option-custom-css', {} ).codemirror;
21 -const $CM_wrapper = CM_custom_css.getWrapperElement();
15 +// Ensure the global `tp` object exists.
16 +window.tp = window.tp || {};
22 17
23 -/**
24 - * Let CodeMirror textarea grow on first focus (with mouse click), if it is not disabled.
25 - *
26 - * @since 1.0.0
27 - */
28 -const CM_wrapper_mousedown_handler = function () {
29 - if ( ! this.classList.contains( 'disabled' ) ) {
30 - this.classList.add( 'large' );
31 - CM_custom_css.refresh();
32 - this.removeEventListener( 'mousedown', CM_wrapper_mousedown_handler ); // No need to keep checking for clicks after the textarea height was increased.
33 - }
34 -};
35 -$CM_wrapper.addEventListener( 'mousedown', CM_wrapper_mousedown_handler );
18 +document.addEventListener( 'DOMContentLoaded', () => {
36 19
37 -/**
38 - * Enable/disable CodeMirror according to state of "Load Custom CSS" checkbox.
39 - *
40 - * @since 1.0.0
41 - */
42 -const $cb_use_custom_css = document.getElementById( 'option-use-custom-css' );
43 -$cb_use_custom_css.addEventListener( 'change', function () {
44 - CM_custom_css.setOption( 'readOnly', ! this.checked );
45 - $CM_wrapper.classList.toggle( 'disabled', ! this.checked );
20 + /**
21 + * Invoke CodeMirror on the "Custom CSS" textarea.
22 + *
23 + * @since 1.9.0
24 + */
25 + tp.CM_custom_css = wp.codeEditor.initialize( 'option-custom-css', {} ).codemirror;
26 + const $CM_wrapper = tp.CM_custom_css.getWrapperElement();
27 +
28 + /**
29 + * Let CodeMirror textarea grow on first focus (with mouse click), if it is not disabled.
30 + *
31 + * @since 1.0.0
32 + */
33 + const CM_wrapper_mousedown_handler = function () {
34 + if ( ! this.classList.contains( 'disabled' ) ) {
35 + this.classList.add( 'large' );
36 + tp.CM_custom_css.refresh();
37 + this.removeEventListener( 'mousedown', CM_wrapper_mousedown_handler ); // No need to keep checking for clicks after the textarea height was increased.
38 + }
39 + };
40 + $CM_wrapper.addEventListener( 'mousedown', CM_wrapper_mousedown_handler );
41 +
42 + /**
43 + * Enable/disable CodeMirror according to state of "Load Custom CSS" checkbox.
44 + *
45 + * @since 1.0.0
46 + */
47 + const $cb_use_custom_css = document.getElementById( 'option-use-custom-css' );
48 + $cb_use_custom_css.addEventListener( 'change', function () {
49 + tp.CM_custom_css.setOption( 'readOnly', ! this.checked );
50 + $CM_wrapper.classList.toggle( 'disabled', ! this.checked );
51 + } );
52 + $cb_use_custom_css.dispatchEvent( new Event( 'change' ) );
53 +
46 54 } );
47 -$cb_use_custom_css.dispatchEvent( new Event( 'change' ) );