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. git-svn-id: https://develop.svn.wordpress.org/trunk@41958 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f5534ec8d5
commit
c8c16b9f70
@ -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 );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user