Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 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
63bb030
Tidy the Customizer docblocks after code review.
westonruter Sep 1, 2026
54c5826
Require the nav menu arguments the partial constructor insists on.
westonruter Sep 1, 2026
5ceb336
Align the docblock lines that continue a description.
westonruter Sep 1, 2026
a95cec6
Correct two parameter descriptions that describe the wrong thing.
westonruter Sep 1, 2026
49ddca4
Finish the parameter descriptions that were left incomplete.
westonruter Sep 1, 2026
d1c9b66
Merge branch 'trunk' of https://github.com/WordPress/wordpress-develo…
westonruter Sep 1, 2026
cda7c0e
Name the jQuery collection type so it resolves to a collection.
westonruter Sep 1, 2026
384799f
Type the partial refresh promises as the jQuery promises they are.
westonruter Sep 1, 2026
e49b63e
Say what `this` actually is in the field toggle handler.
westonruter Sep 1, 2026
51b1a2d
Fix three structural tags that name or classify the wrong thing.
westonruter Sep 1, 2026
8279851
Name the selective refresh classes instead of inferring them.
westonruter Sep 1, 2026
bb77c4b
Finish the tag descriptions that trailed off mid-phrase.
westonruter Sep 2, 2026
d9f3663
Return the header image model, not a set of cropper options.
westonruter Sep 2, 2026
9576a7a
Describe the parameters that were named but never explained.
westonruter Sep 3, 2026
1287025
Correct three things the parameter tags got wrong.
westonruter Sep 3, 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
306 changes: 190 additions & 116 deletions src/js/_enqueues/wp/customize/base.js

Large diffs are not rendered by default.

557 changes: 293 additions & 264 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 */{
/**
* Returns the default attributes for a header image.
*
* @return {Object} Default attributes.
*/
defaults: function() {
return {
header: {
Expand All @@ -39,16 +49,25 @@
};
},

/**
* Initializes the model, hiding the header when asked to.
*/
initialize: function() {
this.on('hide', this.hide, this);
},

/**
* Hides the header image, removing it from the site.
*/
hide: function() {
this.set('choice', '');
api('header_image').set('remove-header');
api('header_image_data').set('remove-header');
},

/**
* Removes the image, hiding the header first if it is the current one.
*/
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);
},

/**
* Makes this image the current header image.
*/
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);
},

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

/**
* Returns whether the image needs cropping for this theme.
*
* @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.
/**
* 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;
},

/**
* Initializes the collection from the uploaded header images.
*/
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 @@
}
},

/**
* Removes an image's previous crop once it has been replaced.
*
* @param {Backbone.Model} model Model.
*/
maybeRemoveOldCrop: function( model ) {
var newID = model.get( 'header' ).attachment_id || false,
oldCrop;
Expand All @@ -211,12 +254,20 @@
}
},

/**
* Adds the random choice once a single image is left.
*/
maybeAddRandomChoice: function() {
if (this.size() === 1) {
this.addRandomChoice();
}
},

/**
* Adds the random image choice to the collection.
*
* @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 @@
});
},

/**
* Returns whether a choice is one of the random image choices.
*
* @param {string} choice Choice.
* @return {boolean} Whether the choice is random.
*/
isRandomChoice: function(choice) {
return (/^random-(uploaded|default)-image$/).test(choice);
},

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

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

/**
* Clears the selection.
*/
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({
/**
* Initializes the collection from the theme's default header images.
*/
initialize: function() {
this.type = 'default';
this.data = _wpCustomizeHeader.defaults;
Expand Down
Loading
Loading