-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Improve Customizer JSDoc #10743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
westonruter
wants to merge
33
commits into
WordPress:trunk
Choose a base branch
from
westonruter:trac-40831
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Improve Customizer JSDoc #10743
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 a45b863
Fix additional jsdoc
westonruter 9817e3f
Further improve jsdoc
westonruter a2396e2
Add blank line in jsdoc
westonruter 9a5e1a7
Merge branch 'trunk' into trac-40831
westonruter c633c29
Improve Customizer JSDoc and replace `arguments` with rest parameters.
westonruter 5221d35
Consume the `wp` argument passed into the Customizer IIFEs.
westonruter 1835ade
Replace the last use of `arguments` in `wp.customize.Class`.
westonruter 162a1f1
Correct the direction described by `wp.customize.Value#link()`.
westonruter cef3122
Cover the variadic parts of the Customizer base classes.
westonruter 55be81e
Replace the `mixed` JSDoc type with `*` in the Customizer.
westonruter 6ddae5a
Use resolvable names for the Customizer JSDoc types.
westonruter c7f407f
Correct the types documented for the Customizer IIFE arguments.
westonruter d512ff3
Fix further JSDoc defects in the Customizer.
westonruter a5c5d5f
Drop the hyphen before Customizer JSDoc parameter descriptions.
westonruter 3d17619
Document the arguments of three more Customizer functions.
westonruter d944c5c
Check both directions when unsyncing two values.
westonruter 5ca507b
Describe optional parameters and member types accurately in the Custo…
westonruter ab9eb85
Mark the remaining optional Customizer parameters as optional.
westonruter 31e8243
Widen the type of the value passed to `wp.customize.Value#set()`.
westonruter 1fa8f87
Mark the callback optional for `wp.customize.control()` and `panel()`.
westonruter 11ffe58
Spell the Customizer's generic object types consistently.
westonruter 182301e
Correct the return documented for `wp.customize.Loader.open()`.
westonruter 9b65262
Describe what `wp.customize.Class` returns, and two Placement details.
westonruter a19d5df
Correct three Customizer types that misdescribe their values.
westonruter 32e8753
Correct three more Customizer parameters in customize-base.js.
westonruter bc02b24
Document the arguments of the remaining Customizer functions.
westonruter de984b7
Name the WordPress global `wp` in customize-base.js.
westonruter 8645a76
Put the `@output` docblock first in customize-widgets.js.
westonruter ffa1007
Name the Underscore and jQuery promise types in the Customizer.
westonruter 1485310
Use the jQuery namespace as it is actually declared.
westonruter 4f8350c
Say what the Customizer's arrays contain.
westonruter 7106b2a
Merge branch 'trunk' into trac-40831
westonruter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 */ | ||
|
|
@@ -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: { | ||
|
|
@@ -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; | ||
|
|
@@ -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); | ||
|
|
@@ -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) { | ||
|
|
@@ -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) { | ||
|
|
@@ -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); | ||
|
|
@@ -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; | ||
|
|
@@ -211,12 +254,20 @@ | |
| } | ||
| }, | ||
|
|
||
| /** | ||
| * Maybe add random choice. | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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'; | ||
|
|
@@ -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); | ||
|
|
@@ -252,6 +319,9 @@ | |
| } | ||
| }, | ||
|
|
||
| /** | ||
| * Remove image. | ||
| */ | ||
| removeImage: function() { | ||
| this.each(function(m) { | ||
| m.set('selected', false); | ||
|
|
@@ -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; | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.