Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a603e94
https://core.trac.wordpress.org/attachment/ticket/40831/40831.diff
westonruter Jan 15, 2026
a45b863
Fix additional jsdoc
westonruter Jan 15, 2026
9817e3f
Further improve jsdoc
westonruter Jan 15, 2026
a2396e2
Add blank line in jsdoc
westonruter Jan 16, 2026
9a5e1a7
Merge branch 'trunk' into trac-40831
westonruter Aug 28, 2026
c633c29
Improve Customizer JSDoc and replace `arguments` with rest parameters.
westonruter Aug 28, 2026
5221d35
Consume the `wp` argument passed into the Customizer IIFEs.
westonruter Aug 28, 2026
1835ade
Replace the last use of `arguments` in `wp.customize.Class`.
westonruter Aug 28, 2026
162a1f1
Correct the direction described by `wp.customize.Value#link()`.
westonruter Aug 28, 2026
cef3122
Cover the variadic parts of the Customizer base classes.
westonruter Aug 28, 2026
55be81e
Replace the `mixed` JSDoc type with `*` in the Customizer.
westonruter Aug 28, 2026
6ddae5a
Use resolvable names for the Customizer JSDoc types.
westonruter Aug 29, 2026
c7f407f
Correct the types documented for the Customizer IIFE arguments.
westonruter Aug 29, 2026
d512ff3
Fix further JSDoc defects in the Customizer.
westonruter Aug 29, 2026
a5c5d5f
Drop the hyphen before Customizer JSDoc parameter descriptions.
westonruter Aug 29, 2026
3d17619
Document the arguments of three more Customizer functions.
westonruter Aug 29, 2026
d944c5c
Check both directions when unsyncing two values.
westonruter Aug 29, 2026
5ca507b
Describe optional parameters and member types accurately in the Custo…
westonruter Aug 29, 2026
ab9eb85
Mark the remaining optional Customizer parameters as optional.
westonruter Aug 29, 2026
31e8243
Widen the type of the value passed to `wp.customize.Value#set()`.
westonruter Aug 29, 2026
1fa8f87
Mark the callback optional for `wp.customize.control()` and `panel()`.
westonruter Aug 29, 2026
11ffe58
Spell the Customizer's generic object types consistently.
westonruter Aug 29, 2026
182301e
Correct the return documented for `wp.customize.Loader.open()`.
westonruter Aug 29, 2026
9b65262
Describe what `wp.customize.Class` returns, and two Placement details.
westonruter Aug 29, 2026
a19d5df
Correct three Customizer types that misdescribe their values.
westonruter Aug 29, 2026
32e8753
Correct three more Customizer parameters in customize-base.js.
westonruter Aug 29, 2026
bc02b24
Document the arguments of the remaining Customizer functions.
westonruter Aug 31, 2026
de984b7
Name the WordPress global `wp` in customize-base.js.
westonruter Aug 31, 2026
8645a76
Put the `@output` docblock first in customize-widgets.js.
westonruter Aug 31, 2026
ffa1007
Name the Underscore and jQuery promise types in the Customizer.
westonruter Aug 31, 2026
1485310
Use the jQuery namespace as it is actually declared.
westonruter Aug 31, 2026
4f8350c
Say what the Customizer's arrays contain.
westonruter Aug 31, 2026
7106b2a
Merge branch 'trunk' into trac-40831
westonruter Aug 31, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
301 changes: 187 additions & 114 deletions src/js/_enqueues/wp/customize/base.js

Large diffs are not rendered by default.

478 changes: 253 additions & 225 deletions src/js/_enqueues/wp/customize/controls.js

Large diffs are not rendered by default.

34 changes: 32 additions & 2 deletions src/js/_enqueues/wp/customize/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
*/
window.wp = window.wp || {};

(function( exports, $ ){
/**
* @param {Object} wp The WordPress global object.
* @param {JQueryStatic} $ The jQuery object.
*/
(function( wp, $ ){
Comment thread
westonruter marked this conversation as resolved.
var api = wp.customize,
Loader;

Expand Down Expand Up @@ -76,6 +80,12 @@ window.wp = window.wp || {};
}
},

/**
* Handle popstate event.
*
* @param {JQuery.Event} e The popstate event.
* @return {void}
*/
popstate: function( e ) {
var state = e.originalEvent.state;
if ( state && state.customize ) {
Expand All @@ -85,6 +95,9 @@ window.wp = window.wp || {};
}
},

/**
* Handle hashchange event.
*/
hashchange: function() {
var hash = window.location.toString().split('#')[1];

Expand All @@ -97,6 +110,11 @@ window.wp = window.wp || {};
}
},

/**
* Handle beforeunload event.
*
* @return {string|void} Confirmation message if there are unsaved changes.
*/
beforeunload: function () {
if ( ! Loader.saved() ) {
return Loader.settings.l10n.saveAlert;
Expand All @@ -106,7 +124,8 @@ window.wp = window.wp || {};
/**
* Open the Customizer overlay for a specific URL.
*
* @param string src URL to load in the Customizer.
* @param {string} src URL to load in the Customizer.
* @return {string|void} The URL, when navigating to it directly on mobile.
*/
open: function( src ) {

Expand Down Expand Up @@ -189,6 +208,11 @@ window.wp = window.wp || {};
this.trigger( 'open' );
},

/**
* Push the state of the Customizer onto the history stack.
*
* @param {string} src URL to push.
*/
pushState: function ( src ) {
var hash = src.split( '?' )[1];

Expand Down Expand Up @@ -270,10 +294,16 @@ window.wp = window.wp || {};
* Overlay hide/show utility methods.
*/
overlay: {
/**
* Show the overlay.
*/
show: function() {
this.element.fadeIn( 200, Loader.opened );
},

/**
* Hide the overlay.
*/
hide: function() {
this.element.fadeOut( 200, Loader.closed );
}
Expand Down
81 changes: 77 additions & 4 deletions src/js/_enqueues/wp/customize/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
*/

/* global _wpCustomizeHeader */

/**
* @param {JQueryStatic} $ The jQuery object.
* @param {Object} wp The WordPress global object.
*/
(function( $, wp ) {
var api = wp.customize;
/** @namespace wp.customize.HeaderTool */
Expand All @@ -21,10 +26,15 @@
* @memberOf wp.customize.HeaderTool
* @alias wp.customize.HeaderTool.ImageModel
*
* @constructor
* @class
* @augments Backbone.Model
*/
api.HeaderTool.ImageModel = Backbone.Model.extend(/** @lends wp.customize.HeaderTool.ImageModel.prototype */{
/**
* Default attributes.
*
* @return {Object} Default attributes.
*/
defaults: function() {
return {
header: {
Expand All @@ -39,16 +49,25 @@
};
},

/**
* Initialize.
*/
initialize: function() {
this.on('hide', this.hide, this);
},

/**
* Hide.
*/
hide: function() {
this.set('choice', '');
api('header_image').set('remove-header');
api('header_image_data').set('remove-header');
},

/**
* Destroy.
*/
destroy: function() {
var data = this.get('header'),
curr = api.HeaderTool.currentHeader.get('header').attachment_id;
Expand All @@ -69,6 +88,9 @@
this.trigger('destroy', this, this.collection);
},

/**
* Save.
*/
save: function() {
if (this.get('random')) {
api('header_image').set(this.get('header').random);
Expand All @@ -86,6 +108,9 @@
api.HeaderTool.combinedList.trigger('control:setImage', this);
},

/**
* Import image.
*/
importImage: function() {
var data = this.get('header');
if (data.attachment_id === undefined) {
Expand All @@ -100,6 +125,11 @@
} );
},

/**
* Should be cropped.
*
* @return {boolean} Whether the image should be cropped.
*/
shouldBeCropped: function() {
if (this.get('themeFlexWidth') === true &&
this.get('themeFlexHeight') === true) {
Expand Down Expand Up @@ -136,17 +166,25 @@
* @memberOf wp.customize.HeaderTool
* @alias wp.customize.HeaderTool.ChoiceList
*
* @constructor
* @class
* @augments Backbone.Collection
*/
api.HeaderTool.ChoiceList = Backbone.Collection.extend({
model: api.HeaderTool.ImageModel,

// Ordered from most recently used to least.
/**
* Comparator which orders the collection from most recently used to least.
*
* @param {Backbone.Model} model The model to sort.
* @return {number} The sort order.
*/
comparator: function(model) {
return -model.get('header').timestamp;
},

/**
* Initialize.
*/
initialize: function() {
var current = api.HeaderTool.currentHeader.get('choice').replace(/^https?:\/\//, ''),
isRandom = this.isRandomChoice(api.get().header_image);
Expand Down Expand Up @@ -192,6 +230,11 @@
}
},

/**
* Maybe remove old crop.
*
* @param {Backbone.Model} model Model.
*/
maybeRemoveOldCrop: function( model ) {
var newID = model.get( 'header' ).attachment_id || false,
oldCrop;
Expand All @@ -211,12 +254,20 @@
}
},

/**
* Maybe add random choice.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love the determinism of this!!! 🤪

*/
maybeAddRandomChoice: function() {
if (this.size() === 1) {
this.addRandomChoice();
}
},

/**
* Add random choice.
*
* @param {string} initialChoice Initial choice.
*/
addRandomChoice: function(initialChoice) {
var isRandomSameType = RegExp(this.type).test(initialChoice),
randomChoice = 'random-' + this.type + '-image';
Expand All @@ -234,14 +285,30 @@
});
},

/**
* Is random choice?
*
* @param {string} choice Choice.
* @return {boolean} Whether the choice is random.
*/
isRandomChoice: function(choice) {
return (/^random-(uploaded|default)-image$/).test(choice);
},

/**
* Should hide title?
*
* @return {boolean} Whether the title should be hidden.
*/
shouldHideTitle: function() {
return this.size() < 2;
},

/**
* Set image.
*
* @param {Backbone.Model} model Model.
*/
setImage: function(model) {
this.each(function(m) {
m.set('selected', false);
Expand All @@ -252,6 +319,9 @@
}
},

/**
* Remove image.
*/
removeImage: function() {
this.each(function(m) {
m.set('selected', false);
Expand All @@ -266,11 +336,14 @@
* @memberOf wp.customize.HeaderTool
* @alias wp.customize.HeaderTool.DefaultsList
*
* @constructor
* @class
* @augments wp.customize.HeaderTool.ChoiceList
* @augments Backbone.Collection
*/
api.HeaderTool.DefaultsList = api.HeaderTool.ChoiceList.extend({
/**
* Initialize.
*/
initialize: function() {
this.type = 'default';
this.data = _wpCustomizeHeader.defaults;
Expand Down
Loading
Loading