mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-29 15:47:38 +02:00
Customize: Add codemirror
deferred object to CodeEditorControl
which is resolved when CodeMirror is initialized.
CodeMirror gets initialized once the control's containing section is expanded. The deferred will be rejected if user preference for syntax highlighting is disabled. Also move jsdoc from `wp.customize.Control` to intended `wp.customize.Control#initialize()`. See #41897, #12423. Built from https://develop.svn.wordpress.org/trunk@41958 git-svn-id: http://core.svn.wordpress.org/trunk@41792 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
81c87e7d5e
commit
47c555f8ed
@ -3341,6 +3341,19 @@
|
|||||||
*
|
*
|
||||||
* @class
|
* @class
|
||||||
* @augments wp.customize.Class
|
* @augments wp.customize.Class
|
||||||
|
*/
|
||||||
|
api.Control = api.Class.extend({
|
||||||
|
defaultActiveArguments: { duration: 'fast', completeCallback: $.noop },
|
||||||
|
|
||||||
|
defaults: {
|
||||||
|
label: '',
|
||||||
|
description: '',
|
||||||
|
active: true,
|
||||||
|
priority: 10
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize.
|
||||||
*
|
*
|
||||||
* @param {string} id - Unique identifier for the control instance.
|
* @param {string} id - Unique identifier for the control instance.
|
||||||
* @param {object} options - Options hash for the control instance.
|
* @param {object} options - Options hash for the control instance.
|
||||||
@ -3358,17 +3371,8 @@
|
|||||||
* @param {string} options.description - Description.
|
* @param {string} options.description - Description.
|
||||||
* @param {number} [options.instanceNumber] - Order in which this instance was created in relation to other instances.
|
* @param {number} [options.instanceNumber] - Order in which this instance was created in relation to other instances.
|
||||||
* @param {object} [options.params] - Deprecated wrapper for the above properties.
|
* @param {object} [options.params] - Deprecated wrapper for the above properties.
|
||||||
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
api.Control = api.Class.extend({
|
|
||||||
defaultActiveArguments: { duration: 'fast', completeCallback: $.noop },
|
|
||||||
|
|
||||||
defaults: {
|
|
||||||
label: '',
|
|
||||||
description: '',
|
|
||||||
active: true,
|
|
||||||
priority: 10
|
|
||||||
},
|
|
||||||
|
|
||||||
initialize: function( id, options ) {
|
initialize: function( id, options ) {
|
||||||
var control = this, deferredSettingIds = [], settings, gatherSettings;
|
var control = this, deferredSettingIds = [], settings, gatherSettings;
|
||||||
|
|
||||||
@ -5113,6 +5117,20 @@
|
|||||||
*/
|
*/
|
||||||
api.CodeEditorControl = api.Control.extend({
|
api.CodeEditorControl = api.Control.extend({
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize.
|
||||||
|
*
|
||||||
|
* @since 4.9.0
|
||||||
|
* @param {string} id - Unique identifier for the control instance.
|
||||||
|
* @param {object} options - Options hash for the control instance.
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
initialize: function( id, options ) {
|
||||||
|
var control = this;
|
||||||
|
api.Control.prototype.initialize.call( this, id, options );
|
||||||
|
control.deferred.codemirror = $.Deferred();
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the editor when the containing section is ready and expanded.
|
* Initialize the editor when the containing section is ready and expanded.
|
||||||
*
|
*
|
||||||
@ -5272,6 +5290,8 @@
|
|||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
control.deferred.codemirror.resolveWith( control, [ control.editor.codemirror ] );
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -5380,6 +5400,8 @@
|
|||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
control.deferred.codemirror.rejectWith( control );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
6
wp-admin/js/customize-controls.min.js
vendored
6
wp-admin/js/customize-controls.min.js
vendored
File diff suppressed because one or more lines are too long
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.9-beta3-41957';
|
$wp_version = '4.9-beta3-41958';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user