Update WP and plugins

This commit is contained in:
Oliver Davies 2019-04-16 20:56:22 +01:00
parent 10a4713229
commit 1fb77fc4ff
864 changed files with 101724 additions and 78262 deletions

View file

@ -25,7 +25,8 @@
*
* Note that any appropriate tags may be used, as long as the above classes are present.
*
* @since 3.6.0.
* @since 3.6.0
* @output wp-admin/js/accordion.js
*/
( function( $ ){

View file

@ -1,7 +1,17 @@
/**
* @output wp-admin/js/code-editor.js
*/
if ( 'undefined' === typeof window.wp ) {
/**
* @namespace wp
*/
window.wp = {};
}
if ( 'undefined' === typeof window.wp.codeEditor ) {
/**
* @namespace wp.codeEditor
*/
window.wp.codeEditor = {};
}
@ -33,6 +43,7 @@ if ( 'undefined' === typeof window.wp.codeEditor ) {
* @param {object} settings.codeMirror - Settings for CodeMirror.
* @param {Function} settings.onChangeLintingErrors - Callback for when there are changes to linting errors.
* @param {Function} settings.onUpdateErrorNotice - Callback to update error notice.
*
* @returns {void}
*/
function configureLinting( editor, settings ) { // eslint-disable-line complexity
@ -202,6 +213,7 @@ if ( 'undefined' === typeof window.wp.codeEditor ) {
* @param {object} settings.codeMirror - Settings for CodeMirror.
* @param {Function} settings.onTabNext - Callback to handle tabbing to the next tabbable element.
* @param {Function} settings.onTabPrevious - Callback to handle tabbing to the previous tabbable element.
*
* @returns {void}
*/
function configureTabbing( codemirror, settings ) {
@ -240,7 +252,7 @@ if ( 'undefined' === typeof window.wp.codeEditor ) {
}
/**
* @typedef {object} CodeEditorInstance
* @typedef {object} wp.codeEditor~CodeEditorInstance
* @property {object} settings - The code editor settings.
* @property {CodeMirror} codemirror - The CodeMirror instance.
*/
@ -260,6 +272,7 @@ if ( 'undefined' === typeof window.wp.codeEditor ) {
* @param {object} [settings.csslint] - Rules for CSSLint.
* @param {object} [settings.htmlhint] - Rules for HTMLHint.
* @param {object} [settings.jshint] - Rules for JSHint.
*
* @returns {CodeEditorInstance} Instance.
*/
wp.codeEditor.initialize = function initialize( textarea, settings ) {

View file

@ -1,3 +1,7 @@
/**
* @output wp-admin/js/color-picker.js
*/
/* global wpColorPickerL10n */
( function( $, undef ) {
@ -10,13 +14,13 @@
_wrappingLabelText = '<span class="screen-reader-text"></span>';
/**
* @summary Creates a jQuery UI color picker.
*
* Creates a jQuery UI color picker that is used in the theme customizer.
*
* @class $.widget.wp.wpColorPicker
*
* @since 3.5.0
*/
ColorPicker = {
ColorPicker = /** @lends $.widget.wp.wpColorPicker.prototype */{
options: {
defaultColor: false,
change: false,
@ -29,7 +33,7 @@
slider: 'horizontal'
},
/**
* @summary Creates a color picker that only allows you to adjust the hue.
* Creates a color picker that only allows you to adjust the hue.
*
* @since 3.5.0
*
@ -54,7 +58,9 @@
hide: false,
color: color,
/**
* @summary Handles the onChange event if one has been defined in the options.
* Handles the onChange event if one has been defined in the options.
*
* @ignore
*
* @param {Event} event The event that's being called.
* @param {HTMLElement} ui The HTMLElement containing the color picker.
@ -71,8 +77,6 @@
} );
},
/**
* @summary Creates the color picker.
*
* Creates the color picker, sets default values, css classes and wraps it all in HTML.
*
* @since 3.5.0
@ -172,13 +176,13 @@
mode: self.options.mode,
palettes: self.options.palettes,
/**
* @summary Handles the onChange event if one has been defined in the options.
*
* Handles the onChange event if one has been defined in the options and additionally
* sets the background color for the toggler element.
*
* @since 3.5.0
*
* @ignore
*
* @param {Event} event The event that's being called.
* @param {HTMLElement} ui The HTMLElement containing the color picker.
*
@ -202,7 +206,7 @@
}
},
/**
* @summary Binds event listeners to the color picker.
* Binds event listeners to the color picker.
*
* @since 3.5.0
*
@ -214,7 +218,7 @@
var self = this;
/**
* @summary Prevent any clicks inside this widget from leaking to the top and closing it.
* Prevent any clicks inside this widget from leaking to the top and closing it.
*
* @since 3.5.0
*
@ -227,7 +231,7 @@
});
/**
* @summary Open or close the color picker depending on the class.
* Open or close the color picker depending on the class.
*
* @since 3.5
*/
@ -240,8 +244,6 @@
});
/**
* @summary Checks if value is empty when changing the color in the color picker.
*
* Checks if value is empty when changing the color in the color picker.
* If so, the background color is cleared.
*
@ -265,8 +267,6 @@
});
/**
* @summary Enables the user to clear or revert the color in the color picker.
*
* Enables the user to either clear the color in the color picker or revert back to the default color.
*
* @since 3.5.0
@ -289,7 +289,7 @@
});
},
/**
* @summary Opens the color picker dialog.
* Opens the color picker dialog.
*
* @since 3.5.0
*
@ -305,7 +305,7 @@
$( 'body' ).trigger( 'click.wpcolorpicker' ).on( 'click.wpcolorpicker', this.close );
},
/**
* @summary Closes the color picker dialog.
* Closes the color picker dialog.
*
* @since 3.5.0
*
@ -321,8 +321,6 @@
$( 'body' ).off( 'click.wpcolorpicker', this.close );
},
/**
* @summary Returns iris object or sets new color.
*
* Returns the iris object if no new color is provided. If a new color is provided, it sets the new color.
*
* @param newColor {string|*} The new color to use. Can be undefined.
@ -338,8 +336,6 @@
this.element.iris( 'option', 'color', newColor );
},
/**
* @summary Returns iris object or sets new default color.
*
* Returns the iris object if no new default color is provided.
* If a new default color is provided, it sets the new default color.
*

View file

@ -1,7 +1,11 @@
/**
* @output wp-admin/js/comment.js
*/
/* global postboxes, commentL10n */
/**
* @summary Binds to the document ready event.
* Binds to the document ready event.
*
* @since 2.5.0
*
@ -18,7 +22,7 @@ jQuery(document).ready( function($) {
$edittimestamp = $timestampdiv.siblings( 'a.edit-timestamp' );
/**
* @summary Adds event that opens the time stamp form if the form is hidden.
* Adds event that opens the time stamp form if the form is hidden.
*
* @listens $edittimestamp:click
*
@ -37,7 +41,7 @@ jQuery(document).ready( function($) {
});
/**
* @summary Resets the time stamp values when the cancel button is clicked.
* Resets the time stamp values when the cancel button is clicked.
*
* @listens .cancel-timestamp:click
*
@ -59,7 +63,7 @@ jQuery(document).ready( function($) {
});
/**
* @summary Sets the time stamp values when the ok button is clicked.
* Sets the time stamp values when the ok button is clicked.
*
* @listens .save-timestamp:click
*

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -1,7 +1,11 @@
/**
* @output wp-admin/js/custom-background.js
*/
/* global ajaxurl */
/**
* @summary Registers all events for customizing the background.
* Registers all events for customizing the background.
*
* @since 3.0.0
*
@ -13,7 +17,7 @@
bgImage = $( '#custom-background-image' );
/**
* @summary Instantiates the WordPress color picker and binds the change and clear events.
* Instantiates the WordPress color picker and binds the change and clear events.
*
* @since 3.5.0
*
@ -29,7 +33,7 @@
});
/**
* @summary Alters the background size CSS property whenever the background size input has changed.
* Alters the background size CSS property whenever the background size input has changed.
*
* @since 4.7.0
*
@ -40,7 +44,7 @@
});
/**
* @summary Alters the background position CSS property whenever the background position input has changed.
* Alters the background position CSS property whenever the background position input has changed.
*
* @since 4.7.0
*
@ -51,7 +55,7 @@
});
/**
* @summary Alters the background repeat CSS property whenever the background repeat input has changed.
* Alters the background repeat CSS property whenever the background repeat input has changed.
*
* @since 3.0.0
*
@ -62,7 +66,7 @@
});
/**
* @summary Alters the background attachment CSS property whenever the background attachment input has changed.
* Alters the background attachment CSS property whenever the background attachment input has changed.
*
* @since 4.7.0
*
@ -73,7 +77,7 @@
});
/**
* @summary Binds the event for opening the WP Media dialog.
* Binds the event for opening the WP Media dialog.
*
* @since 3.5.0
*
@ -113,7 +117,7 @@
});
/**
* @summary When an image is selected, run a callback.
* When an image is selected, run a callback.
*
* @since 3.5.0
*

View file

@ -1,12 +1,25 @@
/**
* @output wp-admin/js/custom-header.js
*/
/* global isRtl */
/**
* Initializes the custom header selection page.
*
* @since 3.5.0
*
* @deprecated 4.1.0 The page this is used on is never linked to from the UI.
* Setting a custom header is completely handled by the Customizer.
*/
(function($) {
var frame;
$( function() {
// Fetch available headers and apply jQuery.masonry
// once the images have loaded.
// Fetch available headers.
var $headers = $('.available-headers');
// Apply jQuery.masonry once the images have loaded.
$headers.imagesLoaded( function() {
$headers.masonry({
itemSelector: '.default-header',
@ -14,7 +27,14 @@
});
});
// Build the choose from library frame.
/**
* Opens the 'choose from library' frame and creates it if it doesn't exist.
*
* @since 3.5.0
* @deprecated 4.1.0
*
* @returns {void}
*/
$('#choose-from-library-link').click( function( event ) {
var $el = $(this);
event.preventDefault();
@ -45,7 +65,14 @@
}
});
// When an image is selected, run a callback.
/**
* Updates the window location to include the selected attachment.
*
* @since 3.5.0
* @deprecated 4.1.0
*
* @returns {void}
*/
frame.on( 'select', function() {
// Grab the selected attachment.
var attachment = frame.state().get('selection').first(),

View file

@ -1,15 +1,12 @@
/**
* @output wp-admin/js/customize-controls.js
*/
/* global _wpCustomizeHeader, _wpCustomizeBackground, _wpMediaViewsL10n, MediaElementPlayer, console, confirm */
(function( exports, $ ){
var Container, focus, normalizedTransitionendEventName, api = wp.customize;
/**
* A notification that is displayed in a full-screen overlay.
*
* @since 4.9.0
* @class
* @augments wp.customize.Notification
*/
api.OverlayNotification = api.Notification.extend({
api.OverlayNotification = api.Notification.extend(/** @lends wp.customize.OverlayNotification.prototype */{
/**
* Whether the notification should show a loading spinner.
@ -20,7 +17,10 @@
loading: false,
/**
* Initialize.
* A notification that is displayed in a full-screen overlay.
*
* @constructs wp.customize.OverlayNotification
* @augments wp.customize.Notification
*
* @since 4.9.0
*
@ -68,14 +68,7 @@
}
});
/**
* A collection of observable notifications.
*
* @since 4.9.0
* @class
* @augments wp.customize.Values
*/
api.Notifications = api.Values.extend({
api.Notifications = api.Values.extend(/** @lends wp.customize.Notifications.prototype */{
/**
* Whether the alternative style should be used.
@ -94,15 +87,18 @@
defaultConstructor: api.Notification,
/**
* Initialize notifications area.
* A collection of observable notifications.
*
* @since 4.9.0
* @constructor
*
* @constructs wp.customize.Notifications
* @augments wp.customize.Values
*
* @param {object} options - Options.
* @param {jQuery} [options.container] - Container element for notifications. This can be injected later.
* @param {boolean} [options.alt] - Whether alternative style should be used when rendering notifications.
*
* @returns {void}
* @this {wp.customize.Notifications}
*/
initialize: function( options ) {
var collection = this;
@ -181,7 +177,6 @@
* @param {object} args - Args.
* @param {boolean} [args.sort=false] - Whether to return the notifications sorted.
* @return {Array.<wp.customize.Notification>} Notifications.
* @this {wp.customize.Notifications}
*/
get: function( args ) {
var collection = this, notifications, errorTypePriorities, params;
@ -217,7 +212,6 @@
*
* @since 4.9.0
* @returns {void}
* @this {wp.customize.Notifications}
*/
render: function() {
var collection = this,
@ -340,20 +334,7 @@
}
});
/**
* A Customizer Setting.
*
* A setting is WordPress data (theme mod, option, menu, etc.) that the user can
* draft changes to in the Customizer.
*
* @see PHP class WP_Customize_Setting.
*
* @since 3.4.0
* @class
* @augments wp.customize.Value
* @augments wp.customize.Class
*/
api.Setting = api.Value.extend({
api.Setting = api.Value.extend(/** @lends wp.customize.Setting.prototype */{
/**
* Default params.
@ -367,7 +348,15 @@
},
/**
* Initialize.
* A Customizer Setting.
*
* A setting is WordPress data (theme mod, option, menu, etc.) that the user can
* draft changes to in the Customizer.
*
* @see PHP class WP_Customize_Setting.
*
* @constructs wp.customize.Setting
* @augments wp.customize.Value
*
* @since 3.4.0
*
@ -448,6 +437,8 @@
/**
* Current change count.
*
* @alias wp.customize._latestRevision
*
* @since 4.7.0
* @type {number}
* @protected
@ -457,6 +448,8 @@
/**
* Last revision that was saved.
*
* @alias wp.customize._lastSavedRevision
*
* @since 4.7.0
* @type {number}
* @protected
@ -466,6 +459,8 @@
/**
* Latest revisions associated with the updated setting.
*
* @alias wp.customize._latestSettingRevisions
*
* @since 4.7.0
* @type {object}
* @protected
@ -495,6 +490,8 @@
/**
* Get the dirty setting values.
*
* @alias wp.customize.dirtyValues
*
* @since 4.7.0
* @access public
*
@ -526,6 +523,8 @@
/**
* Request updates to the changeset.
*
* @alias wp.customize.requestChangesetUpdate
*
* @since 4.7.0
* @access public
*
@ -661,6 +660,8 @@
/**
* Watch all changes to Value properties, and bubble changes to parent Values instance
*
* @alias wp.customize.utils.bubbleChildValueChanges
*
* @since 4.1.0
*
* @param {wp.customize.Class} instance
@ -679,6 +680,8 @@
/**
* Expand a panel, section, or control and focus on the first focusable element.
*
* @alias wp.customize~focus
*
* @since 4.1.0
*
* @param {Object} [params]
@ -726,6 +729,8 @@
*
* If a.priority() === b.priority(), then sort by their respective params.instanceNumber.
*
* @alias wp.customize.utils.prioritySort
*
* @since 4.1.0
*
* @param {(wp.customize.Panel|wp.customize.Section|wp.customize.Control)} a
@ -743,6 +748,8 @@
/**
* Return whether the supplied Event object is for a keydown event but not the Enter key.
*
* @alias wp.customize.utils.isKeydownButNotEnterEvent
*
* @since 4.1.0
*
* @param {jQuery.Event} event
@ -755,6 +762,8 @@
/**
* Return whether the two lists of elements are the same and are in the same order.
*
* @alias wp.customize.utils.areElementListsEqual
*
* @since 4.1.0
*
* @param {Array|jQuery} listA
@ -781,6 +790,8 @@
* UI element, after an optional delay. If the user focuses the element
* before the delay passes, the reminder is canceled.
*
* @alias wp.customize.utils.highlightButton
*
* @since 4.9.0
*
* @param {jQuery} button - The element to highlight.
@ -834,6 +845,8 @@
*
* Same functionality as the `current_time( 'mysql', false )` function in PHP.
*
* @alias wp.customize.utils.getCurrentTimestamp
*
* @since 4.9.0
*
* @returns {int} Current timestamp.
@ -851,6 +864,8 @@
/**
* Get remaining time of when the date is set.
*
* @alias wp.customize.utils.getRemainingTime
*
* @since 4.9.0
*
* @param {string|int|Date} datetime - Date time or timestamp of the future date.
@ -876,6 +891,8 @@
*
* @since 4.7.0
*
* @ignore
*
* @returns {string|null} Normalized `transitionend` event name or null if CSS transitions are not supported.
*/
normalizedTransitionendEventName = (function () {
@ -897,15 +914,7 @@
}
})();
/**
* Base class for Panel and Section.
*
* @since 4.1.0
*
* @class
* @augments wp.customize.Class
*/
Container = api.Class.extend({
Container = api.Class.extend(/** @lends wp.customize~Container.prototype */{
defaultActiveArguments: { duration: 'fast', completeCallback: $.noop },
defaultExpandedArguments: { duration: 'fast', completeCallback: $.noop },
containerType: 'container',
@ -920,18 +929,25 @@
},
/**
* Base class for Panel and Section.
*
* @constructs wp.customize~Container
* @augments wp.customize.Class
*
* @since 4.1.0
*
* @param {string} id - The ID for the container.
* @param {object} options - Object containing one property: params.
* @param {string} options.title - Title shown when panel is collapsed and expanded.
* @param {string=} [options.description] - Description shown at the top of the panel.
* @param {number=100} [options.priority] - The sort priority for the panel.
* @param {string} [options.templateId] - Template selector for container.
* @param {string=default} [options.type] - The type of the panel. See wp.customize.panelConstructor.
* @param {string=} [options.content] - The markup to be used for the panel container. If empty, a JS template is used.
* @param {boolean=true} [options.active] - Whether the panel is active or not.
* @param {object} [options.params] - Deprecated wrapper for the above properties.
* @borrows wp.customize~focus as focus
*
* @param {string} id - The ID for the container.
* @param {object} options - Object containing one property: params.
* @param {string} options.title - Title shown when panel is collapsed and expanded.
* @param {string} [options.description] - Description shown at the top of the panel.
* @param {number} [options.priority=100] - The sort priority for the panel.
* @param {string} [options.templateId] - Template selector for container.
* @param {string} [options.type=default] - The type of the panel. See wp.customize.panelConstructor.
* @param {string} [options.content] - The markup to be used for the panel container. If empty, a JS template is used.
* @param {boolean} [options.active=true] - Whether the panel is active or not.
* @param {object} [options.params] - Deprecated wrapper for the above properties.
*/
initialize: function ( id, options ) {
var container = this;
@ -999,7 +1015,6 @@
*
* @since 4.9.0
* @returns {jQuery} Notification container element.
* @this {wp.customize.Control}
*/
getNotificationsContainerElement: function() {
var container = this;
@ -1305,9 +1320,8 @@
} );
},
/**
* Bring the container into view and then expand this and bring it into view
* @param {Object} [params]
/*
* is documented using @borrows in the constructor.
*/
focus: focus,
@ -1370,13 +1384,7 @@
}
});
/**
* @since 4.1.0
*
* @class
* @augments wp.customize.Class
*/
api.Section = Container.extend({
api.Section = Container.extend(/** @lends wp.customize.Section.prototype */{
containerType: 'section',
containerParent: '#customize-theme-controls',
containerPaneParent: '.customize-pane-parent',
@ -1393,19 +1401,22 @@
},
/**
* @constructs wp.customize.Section
* @augments wp.customize~Container
*
* @since 4.1.0
*
* @param {string} id - The ID for the section.
* @param {object} options - Options.
* @param {string} options.title - Title shown when section is collapsed and expanded.
* @param {string=} [options.description] - Description shown at the top of the section.
* @param {number=100} [options.priority] - The sort priority for the section.
* @param {string=default} [options.type] - The type of the section. See wp.customize.sectionConstructor.
* @param {string=} [options.content] - The markup to be used for the section container. If empty, a JS template is used.
* @param {boolean=true} [options.active] - Whether the section is active or not.
* @param {string} options.panel - The ID for the panel this section is associated with.
* @param {string=} [options.customizeAction] - Additional context information shown before the section title when expanded.
* @param {object} [options.params] - Deprecated wrapper for the above properties.
* @param {string} id - The ID for the section.
* @param {object} options - Options.
* @param {string} options.title - Title shown when section is collapsed and expanded.
* @param {string} [options.description] - Description shown at the top of the section.
* @param {number} [options.priority=100] - The sort priority for the section.
* @param {string} [options.type=default] - The type of the section. See wp.customize.sectionConstructor.
* @param {string} [options.content] - The markup to be used for the section container. If empty, a JS template is used.
* @param {boolean} [options.active=true] - Whether the section is active or not.
* @param {string} options.panel - The ID for the panel this section is associated with.
* @param {string} [options.customizeAction] - Additional context information shown before the section title when expanded.
* @param {object} [options.params] - Deprecated wrapper for the above properties.
*/
initialize: function ( id, options ) {
var section = this, params;
@ -1654,17 +1665,7 @@
}
});
/**
* wp.customize.ThemesSection
*
* Custom section for themes that loads themes by category, and also
* handles the theme-details view rendering and navigation.
*
* @constructor
* @augments wp.customize.Section
* @augments wp.customize.Container
*/
api.ThemesSection = api.Section.extend({
api.ThemesSection = api.Section.extend(/** @lends wp.customize.ThemesSection.prototype */{
currentTheme: '',
overlay: '',
template: '',
@ -1683,7 +1684,13 @@
updateCountDebounced: null,
/**
* Initialize.
* wp.customize.ThemesSection
*
* Custom section for themes that loads themes by category, and also
* handles the theme-details view rendering and navigation.
*
* @constructs wp.customize.ThemesSection
* @augments wp.customize.Section
*
* @since 4.9.0
*
@ -2627,22 +2634,16 @@
}
});
/**
* Class wp.customize.OuterSection.
*
* Creates section outside of the sidebar, there is no ui to trigger collapse/expand so
* it would require custom handling.
*
* @since 4.9
*
* @constructor
* @augments wp.customize.Section
* @augments wp.customize.Container
*/
api.OuterSection = api.Section.extend({
api.OuterSection = api.Section.extend(/** @lends wp.customize.OuterSection.prototype */{
/**
* Initialize.
* Class wp.customize.OuterSection.
*
* Creates section outside of the sidebar, there is no ui to trigger collapse/expand so
* it would require custom handling.
*
* @constructs wp.customize.OuterSection
* @augments wp.customize.Section
*
* @since 4.9.0
*
@ -2746,27 +2747,24 @@
}
});
/**
* @since 4.1.0
*
* @class
* @augments wp.customize.Class
*/
api.Panel = Container.extend({
api.Panel = Container.extend(/** @lends wp.customize.Panel.prototype */{
containerType: 'panel',
/**
* @constructs wp.customize.Panel
* @augments wp.customize~Container
*
* @since 4.1.0
*
* @param {string} id - The ID for the panel.
* @param {object} options - Object containing one property: params.
* @param {string} options.title - Title shown when panel is collapsed and expanded.
* @param {string=} [options.description] - Description shown at the top of the panel.
* @param {number=100} [options.priority] - The sort priority for the panel.
* @param {string=default} [options.type] - The type of the panel. See wp.customize.panelConstructor.
* @param {string=} [options.content] - The markup to be used for the panel container. If empty, a JS template is used.
* @param {boolean=true} [options.active] - Whether the panel is active or not.
* @param {object} [options.params] - Deprecated wrapper for the above properties.
* @param {string} id - The ID for the panel.
* @param {object} options - Object containing one property: params.
* @param {string} options.title - Title shown when panel is collapsed and expanded.
* @param {string} [options.description] - Description shown at the top of the panel.
* @param {number} [options.priority=100] - The sort priority for the panel.
* @param {string} [options.type=default] - The type of the panel. See wp.customize.panelConstructor.
* @param {string} [options.content] - The markup to be used for the panel container. If empty, a JS template is used.
* @param {boolean} [options.active=true] - Whether the panel is active or not.
* @param {object} [options.params] - Deprecated wrapper for the above properties.
*/
initialize: function ( id, options ) {
var panel = this, params;
@ -3020,19 +3018,15 @@
}
});
/**
* Class wp.customize.ThemesPanel.
*
* Custom section for themes that displays without the customize preview.
*
* @constructor
* @augments wp.customize.Panel
* @augments wp.customize.Container
*/
api.ThemesPanel = api.Panel.extend({
api.ThemesPanel = api.Panel.extend(/** @lends wp.customize.ThemsPanel.prototype */{
/**
* Initialize.
* Class wp.customize.ThemesPanel.
*
* Custom section for themes that displays without the customize preview.
*
* @constructs wp.customize.ThemesPanel
* @augments wp.customize.Panel
*
* @since 4.9.0
*
@ -3451,17 +3445,7 @@
}
});
/**
* A Customizer Control.
*
* A control provides a UI element that allows a user to modify a Customizer Setting.
*
* @see PHP class WP_Customize_Control.
*
* @class
* @augments wp.customize.Class
*/
api.Control = api.Class.extend({
api.Control = api.Class.extend(/** @lends wp.customize.Control.prototype */{
defaultActiveArguments: { duration: 'fast', completeCallback: $.noop },
/**
@ -3478,7 +3462,19 @@
},
/**
* Initialize.
* A Customizer Control.
*
* A control provides a UI element that allows a user to modify a Customizer Setting.
*
* @see PHP class WP_Customize_Control.
*
* @constructs wp.customize.Control
* @augments wp.customize.Class
*
* @borrows wp.customize~focus as this#focus
* @borrows wp.customize~Container#activate as this#activate
* @borrows wp.customize~Container#deactivate as this#deactivate
* @borrows wp.customize~Container#_toggleActive as this#_toggleActive
*
* @param {string} id - Unique identifier for the control instance.
* @param {object} options - Options hash for the control instance.
@ -3744,7 +3740,6 @@
*
* @since 4.6.0
* @returns {jQuery} Setting validation message element.
* @this {wp.customize.Control}
*/
getNotificationsContainerElement: function() {
var control = this, controlTitle, notificationsContainer;
@ -3888,9 +3883,8 @@
api.section( this.section() ).expand( params );
},
/**
* Bring the containing section and panel into view and then
* this control into view, focusing on the first input.
/*
* Documented using @borrows in the constructor.
*/
focus: focus,
@ -3934,30 +3928,18 @@
return this.onChangeActive( active, this.defaultActiveArguments );
},
/**
* Shorthand way to enable the active state.
*
* @since 4.1.0
*
* @param {Object} [params]
* @returns {Boolean} false if already active
/*
* Documented using @borrows in the constructor
*/
activate: Container.prototype.activate,
/**
* Shorthand way to disable the active state.
*
* @since 4.1.0
*
* @param {Object} [params]
* @returns {Boolean} false if already inactive
/*
* Documented using @borrows in the constructor
*/
deactivate: Container.prototype.deactivate,
/**
* Re-use _toggleActive from Container class.
*
* @access private
/*
* Documented using @borrows in the constructor
*/
_toggleActive: Container.prototype._toggleActive,
@ -4131,11 +4113,10 @@
/**
* A colorpicker control.
*
* @class
* @class wp.customize.ColorControl
* @augments wp.customize.Control
* @augments wp.customize.Class
*/
api.ColorControl = api.Control.extend({
api.ColorControl = api.Control.extend(/** @lends wp.customize.ColorControl.prototype */{
ready: function() {
var control = this,
isHueSlider = this.params.mode === 'hue',
@ -4195,11 +4176,10 @@
/**
* A control that implements the media modal.
*
* @class
* @class wp.customize.MediaControl
* @augments wp.customize.Control
* @augments wp.customize.Class
*/
api.MediaControl = api.Control.extend({
api.MediaControl = api.Control.extend(/** @lends wp.customize.MediaControl.prototype */{
/**
* When the control's DOM structure is ready,
@ -4384,12 +4364,10 @@
/**
* An upload control, which utilizes the media modal.
*
* @class
* @class wp.customize.UploadControl
* @augments wp.customize.MediaControl
* @augments wp.customize.Control
* @augments wp.customize.Class
*/
api.UploadControl = api.MediaControl.extend({
api.UploadControl = api.MediaControl.extend(/** @lends wp.customize.UploadControl.prototype */{
/**
* Callback handler for when an attachment is selected in the media modal.
@ -4428,13 +4406,10 @@
* This control no longer needs to do anything more
* than what the upload control does in JS.
*
* @class
* @class wp.customize.ImageControl
* @augments wp.customize.UploadControl
* @augments wp.customize.MediaControl
* @augments wp.customize.Control
* @augments wp.customize.Class
*/
api.ImageControl = api.UploadControl.extend({
api.ImageControl = api.UploadControl.extend(/** @lends wp.customize.ImageControl.prototype */{
// @deprecated
thumbnailSrc: function() {}
});
@ -4442,13 +4417,10 @@
/**
* A control for uploading background images.
*
* @class
* @class wp.customize.BackgroundControl
* @augments wp.customize.UploadControl
* @augments wp.customize.MediaControl
* @augments wp.customize.Control
* @augments wp.customize.Class
*/
api.BackgroundControl = api.UploadControl.extend({
api.BackgroundControl = api.UploadControl.extend(/** @lends wp.customize.BackgroundControl.prototype */{
/**
* When the control's DOM structure is ready,
@ -4479,11 +4451,10 @@
*
* @since 4.7.0
*
* @class
* @class wp.customize.BackgroundPositionControl
* @augments wp.customize.Control
* @augments wp.customize.Class
*/
api.BackgroundPositionControl = api.Control.extend( {
api.BackgroundPositionControl = api.Control.extend(/** @lends wp.customize.BackgroundPositionControl.prototype */{
/**
* Set up control UI once embedded in DOM and settings are created.
@ -4518,12 +4489,10 @@
/**
* A control for selecting and cropping an image.
*
* @class
* @class wp.customize.CroppedImageControl
* @augments wp.customize.MediaControl
* @augments wp.customize.Control
* @augments wp.customize.Class
*/
api.CroppedImageControl = api.MediaControl.extend({
api.CroppedImageControl = api.MediaControl.extend(/** @lends wp.customize.CroppedImageControl.prototype */{
/**
* Open the media modal to the library state.
@ -4720,13 +4689,10 @@
/**
* A control for selecting and cropping Site Icons.
*
* @class
* @class wp.customize.SiteIconControl
* @augments wp.customize.CroppedImageControl
* @augments wp.customize.MediaControl
* @augments wp.customize.Control
* @augments wp.customize.Class
*/
api.SiteIconControl = api.CroppedImageControl.extend({
api.SiteIconControl = api.CroppedImageControl.extend(/** @lends wp.customize.SiteIconControl.prototype */{
/**
* Create a media modal select frame, and store it so the instance can be reused when needed.
@ -4841,11 +4807,10 @@
});
/**
* @class
* @class wp.customize.HeaderControl
* @augments wp.customize.Control
* @augments wp.customize.Class
*/
api.HeaderControl = api.Control.extend({
api.HeaderControl = api.Control.extend(/** @lends wp.customize.HeaderControl.prototype */{
ready: function() {
this.btnRemove = $('#customize-control-header_image .actions .remove');
this.btnNew = $('#customize-control-header_image .actions .new');
@ -5111,11 +5076,10 @@
/**
* wp.customize.ThemeControl
*
* @constructor
* @class wp.customize.ThemeControl
* @augments wp.customize.Control
* @augments wp.customize.Class
*/
api.ThemeControl = api.Control.extend({
api.ThemeControl = api.Control.extend(/** @lends wp.customize.ThemeControl.prototype */{
touchDrag: false,
screenshotRendered: false,
@ -5263,11 +5227,10 @@
*
* @since 4.9.0
*
* @constructor
* @class wp.customize.CodeEditorControl
* @augments wp.customize.Control
* @augments wp.customize.Class
*/
api.CodeEditorControl = api.Control.extend({
api.CodeEditorControl = api.Control.extend(/** @lends wp.customize.CodeEditorControl.prototype */{
/**
* Initialize.
@ -5584,11 +5547,10 @@
* Class wp.customize.DateTimeControl.
*
* @since 4.9.0
* @constructor
* @class wp.customize.DateTimeControl
* @augments wp.customize.Control
* @augments wp.customize.Class
*/
api.DateTimeControl = api.Control.extend({
api.DateTimeControl = api.Control.extend(/** @lends wp.customize.DateTimeControl.prototype */{
/**
* Initialize behaviors.
@ -5939,11 +5901,10 @@
* Class PreviewLinkControl.
*
* @since 4.9.0
* @constructor
* @class wp.customize.PreviewLinkControl
* @augments wp.customize.Control
* @augments wp.customize.Class
*/
api.PreviewLinkControl = api.Control.extend({
api.PreviewLinkControl = api.Control.extend(/** @lends wp.customize.PreviewLinkControl.prototype */{
defaults: _.extend( {}, api.Control.prototype.defaults, {
templateId: 'customize-preview-link-control'
@ -6057,19 +6018,25 @@
}
});
// Change objects contained within the main customize object to Settings.
/**
* Change objects contained within the main customize object to Settings.
*
* @alias wp.customize.defaultConstructor
*/
api.defaultConstructor = api.Setting;
/**
* Callback for resolved controls.
*
* @callback deferredControlsCallback
* @param {wp.customize.Control[]} Resolved controls.
* @callback wp.customize.deferredControlsCallback
* @param {wp.customize.Control[]} controls Resolved controls.
*/
/**
* Collection of all registered controls.
*
* @alias wp.customize.control
*
* @since 3.4.0
*
* @type {Function}
@ -6122,13 +6089,15 @@
/**
* Callback for resolved sections.
*
* @callback deferredSectionsCallback
* @param {wp.customize.Section[]} Resolved sections.
* @callback wp.customize.deferredSectionsCallback
* @param {wp.customize.Section[]} sections Resolved sections.
*/
/**
* Collection of all registered sections.
*
* @alias wp.customize.section
*
* @since 3.4.0
*
* @type {Function}
@ -6154,13 +6123,15 @@
/**
* Callback for resolved panels.
*
* @callback deferredPanelsCallback
* @param {wp.customize.Panel[]} Resolved panels.
* @callback wp.customize.deferredPanelsCallback
* @param {wp.customize.Panel[]} panels Resolved panels.
*/
/**
* Collection of all registered panels.
*
* @alias wp.customize.panel
*
* @since 4.0.0
*
* @type {Function}
@ -6186,13 +6157,15 @@
/**
* Callback for resolved notifications.
*
* @callback deferredNotificationsCallback
* @param {wp.customize.Notification[]} Resolved notifications.
* @callback wp.customize.deferredNotificationsCallback
* @param {wp.customize.Notification[]} notifications Resolved notifications.
*/
/**
* Collection of all global notifications.
*
* @alias wp.customize.notifications
*
* @since 4.9.0
*
* @type {Function}
@ -6223,20 +6196,15 @@
*/
api.notifications = new api.Notifications();
/**
* An object that fetches a preview in the background of the document, which
* allows for seamless replacement of an existing preview.
*
* @class
* @augments wp.customize.Messenger
* @augments wp.customize.Class
* @mixes wp.customize.Events
*/
api.PreviewFrame = api.Messenger.extend({
api.PreviewFrame = api.Messenger.extend(/** @lends wp.customize.PreviewFrame.prototype */{
sensitivity: null, // Will get set to api.settings.timeouts.previewFrameSensitivity.
/**
* Initialize the PreviewFrame.
* An object that fetches a preview in the background of the document, which
* allows for seamless replacement of an existing preview.
*
* @constructs wp.customize.PreviewFrame
* @augments wp.customize.Messenger
*
* @param {object} params.container
* @param {object} params.previewUrl
@ -6321,6 +6289,7 @@
name: 'customize-' + previewFrame.channel()
} );
previewFrame.iframe.attr( 'onmousewheel', '' ); // Workaround for Safari bug. See WP Trac #38149.
previewFrame.iframe.attr( 'sandbox', 'allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts' );
if ( ! hasPendingChangesetUpdate ) {
previewFrame.iframe.attr( 'src', urlParser.href );
@ -6454,6 +6423,8 @@
/**
* Set the document title of the customizer.
*
* @alias wp.customize.setDocumentTitle
*
* @since 4.1.0
*
* @param {string} documentTitle
@ -6466,16 +6437,13 @@
api.trigger( 'title', title );
};
/**
* @class
* @augments wp.customize.Messenger
* @augments wp.customize.Class
* @mixes wp.customize.Events
*/
api.Previewer = api.Messenger.extend({
api.Previewer = api.Messenger.extend(/** @lends wp.customize.Previewer.prototype */{
refreshBuffer: null, // Will get set to api.settings.timeouts.windowRefresh.
/**
* @constructs wp.customize.Previewer
* @augments wp.customize.Messenger
*
* @param {array} params.allowedUrls
* @param {string} params.container A selector or jQuery element for the preview
* frame to be placed.
@ -6929,6 +6897,8 @@
*
* Add notifications to the settings and focus on the first control that has an invalid setting.
*
* @alias wp.customize._handleSettingValidities
*
* @since 4.6.0
* @private
*
@ -7004,6 +6974,8 @@
/**
* Find all controls associated with the given settings.
*
* @alias wp.customize.findControlsForSettings
*
* @since 4.6.0
* @param {string[]} settingIds Setting IDs.
* @returns {object<string, wp.customize.Control>} Mapping setting ids to arrays of controls.
@ -7025,6 +6997,8 @@
/**
* Sort panels, sections, controls by priorities. Hide empty sections and panels.
*
* @alias wp.customize.reflowPaneContents
*
* @since 4.1.0
*/
api.reflowPaneContents = _.bind( function () {
@ -7389,13 +7363,17 @@
}
});
// Initialize Previewer
/**
* Initialize Previewer
*
* @alias wp.customize.previewer
*/
api.previewer = new api.Previewer({
container: '#customize-preview',
form: '#customize-controls',
previewUrl: api.settings.url.preview,
allowedUrls: api.settings.url.allowed
}, {
},/** @lends wp.customize.previewer */{
nonce: api.settings.nonce,
@ -8098,15 +8076,7 @@
*/
( function checkAndDisplayLockNotice() {
/**
* A notification that is displayed in a full-screen overlay with information about the locked changeset.
*
* @since 4.9.0
* @class
* @augments wp.customize.Notification
* @augments wp.customize.OverlayNotification
*/
var LockedNotification = api.OverlayNotification.extend({
var LockedNotification = api.OverlayNotification.extend(/** @lends wp.customize~LockedNotification.prototype */{
/**
* Template ID.
@ -8123,7 +8093,10 @@
lockUser: null,
/**
* Initialize.
* A notification that is displayed in a full-screen overlay with information about the locked changeset.
*
* @constructs wp.customize~LockedNotification
* @augments wp.customize.OverlayNotification
*
* @since 4.9.0
*

File diff suppressed because one or more lines are too long

View file

@ -1,3 +1,7 @@
/**
* @output wp-admin/js/customize-nav-menus.js
*/
/* global _wpCustomizeNavMenusSettings, wpNavMenu, console */
( function( api, wp, $ ) {
'use strict';
@ -13,6 +17,9 @@
this.jQueryExtensions();
};
/**
* @namespace wp.customize.Menus
*/
api.Menus = api.Menus || {};
// Link settings.
@ -35,6 +42,8 @@
* Newly-created Nav Menus and Nav Menu Items have negative integer IDs which
* serve as placeholders until Save & Publish happens.
*
* @alias wp.customize.Menus.generatePlaceholderAutoIncrementId
*
* @return {number}
*/
api.Menus.generatePlaceholderAutoIncrementId = function() {
@ -46,7 +55,7 @@
*
* A single available menu item model. See PHP's WP_Customize_Nav_Menu_Item_Setting class.
*
* @constructor
* @class wp.customize.Menus.AvailableItemModel
* @augments Backbone.Model
*/
api.Menus.AvailableItemModel = Backbone.Model.extend( $.extend(
@ -61,10 +70,10 @@
*
* Collection for available menu item models.
*
* @constructor
* @augments Backbone.Model
* @class wp.customize.Menus.AvailableItemCollection
* @augments Backbone.Collection
*/
api.Menus.AvailableItemCollection = Backbone.Collection.extend({
api.Menus.AvailableItemCollection = Backbone.Collection.extend(/** @lends wp.customize.Menus.AvailableItemCollection.prototype */{
model: api.Menus.AvailableItemModel,
sort_key: 'order',
@ -84,7 +93,7 @@
* Insert a new `auto-draft` post.
*
* @since 4.7.0
* @access public
* @alias wp.customize.Menus.insertAutoDraftPost
*
* @param {object} params - Parameters for the draft post to create.
* @param {string} params.post_type - Post type to add.
@ -141,22 +150,12 @@
return deferred.promise();
};
/**
* wp.customize.Menus.AvailableMenuItemsPanelView
*
* View class for the available menu items panel.
*
* @constructor
* @augments wp.Backbone.View
* @augments Backbone.View
*/
api.Menus.AvailableMenuItemsPanelView = wp.Backbone.View.extend({
api.Menus.AvailableMenuItemsPanelView = wp.Backbone.View.extend(/** @lends wp.customize.Menus.AvailableMenuItemsPanelView.prototype */{
el: '#available-menu-items',
events: {
'input #menu-items-search': 'debounceSearch',
'keyup #menu-items-search': 'debounceSearch',
'focus .menu-item-tpl': 'focus',
'click .menu-item-tpl': '_submit',
'click #custom-menu-item-submit': '_submitLink',
@ -181,6 +180,14 @@
loading: false,
addingNew: false,
/**
* wp.customize.Menus.AvailableMenuItemsPanelView
*
* View class for the available menu items panel.
*
* @constructs wp.customize.Menus.AvailableMenuItemsPanelView
* @augments wp.Backbone.View
*/
initialize: function() {
var self = this;
@ -753,10 +760,10 @@
* Customizer panel for menus. This is used only for screen options management.
* Note that 'menus' must match the WP_Customize_Menu_Panel::$type.
*
* @constructor
* @class wp.customize.Menus.MenusPanel
* @augments wp.customize.Panel
*/
api.Menus.MenusPanel = api.Panel.extend({
api.Menus.MenusPanel = api.Panel.extend(/** @lends wp.customize.Menus.MenusPanel.prototype */{
attachEvents: function() {
api.Panel.prototype.attachEvents.call( this );
@ -885,10 +892,10 @@
* Customizer section for menus. This is used only for lazy-loading child controls.
* Note that 'nav_menu' must match the WP_Customize_Menu_Section::$type.
*
* @constructor
* @class wp.customize.Menus.MenuSection
* @augments wp.customize.Section
*/
api.Menus.MenuSection = api.Section.extend({
api.Menus.MenuSection = api.Section.extend(/** @lends wp.customize.Menus.MenuSection.prototype */{
/**
* Initialize.
@ -1212,10 +1219,10 @@
*
* Customizer section for new menus.
*
* @constructor
* @class wp.customize.Menus.NewMenuSection
* @augments wp.customize.Section
*/
api.Menus.NewMenuSection = api.Section.extend({
api.Menus.NewMenuSection = api.Section.extend(/** @lends wp.customize.Menus.NewMenuSection.prototype */{
/**
* Add behaviors for the accordion section.
@ -1451,10 +1458,10 @@
* Customizer control for menu locations (rendered as a <select>).
* Note that 'nav_menu_location' must match the WP_Customize_Nav_Menu_Location_Control::$type.
*
* @constructor
* @class wp.customize.Menus.MenuLocationControl
* @augments wp.customize.Control
*/
api.Menus.MenuLocationControl = api.Control.extend({
api.Menus.MenuLocationControl = api.Control.extend(/** @lends wp.customize.Menus.MenuLocationControl.prototype */{
initialize: function( id, options ) {
var control = this,
matches = id.match( /^nav_menu_locations\[(.+?)]/ );
@ -1529,19 +1536,18 @@
}
});
/**
* wp.customize.Menus.MenuItemControl
*
* Customizer control for menu items.
* Note that 'menu_item' must match the WP_Customize_Menu_Item_Control::$type.
*
* @constructor
* @augments wp.customize.Control
*/
api.Menus.MenuItemControl = api.Control.extend({
api.Menus.MenuItemControl = api.Control.extend(/** @lends wp.customize.Menus.MenuItemControl.prototype */{
/**
* @inheritdoc
* wp.customize.Menus.MenuItemControl
*
* Customizer control for menu items.
* Note that 'menu_item' must match the WP_Customize_Menu_Item_Control::$type.
*
* @constructs wp.customize.Menus.MenuItemControl
* @augments wp.customize.Control
*
* @inheritDoc
*/
initialize: function( id, options ) {
var control = this;
@ -2324,10 +2330,10 @@
*
* Customizer control for a nav menu's name.
*
* @constructor
* @class wp.customize.Menus.MenuNameControl
* @augments wp.customize.Control
*/
api.Menus.MenuNameControl = api.Control.extend({
api.Menus.MenuNameControl = api.Control.extend(/** @lends wp.customize.Menus.MenuNameControl.prototype */{
ready: function() {
var control = this;
@ -2364,10 +2370,10 @@
* Customizer control for a nav menu's locations.
*
* @since 4.9.0
* @constructor
* @class wp.customize.Menus.MenuLocationsControl
* @augments wp.customize.Control
*/
api.Menus.MenuLocationsControl = api.Control.extend({
api.Menus.MenuLocationsControl = api.Control.extend(/** @lends wp.customize.Menus.MenuLocationsControl.prototype */{
/**
* Set up the control.
@ -2437,10 +2443,10 @@
*
* Customizer control for a nav menu's auto add.
*
* @constructor
* @class wp.customize.Menus.MenuAutoAddControl
* @augments wp.customize.Control
*/
api.Menus.MenuAutoAddControl = api.Control.extend({
api.Menus.MenuAutoAddControl = api.Control.extend(/** @lends wp.customize.Menus.MenuAutoAddControl.prototype */{
ready: function() {
var control = this,
@ -2490,10 +2496,10 @@
* Customizer control for menus.
* Note that 'nav_menu' must match the WP_Menu_Customize_Control::$type
*
* @constructor
* @class wp.customize.Menus.MenuControl
* @augments wp.customize.Control
*/
api.Menus.MenuControl = api.Control.extend({
api.Menus.MenuControl = api.Control.extend(/** @lends wp.customize.Menus.MenuControl.prototype */{
/**
* Set up the control.
*/
@ -3021,22 +3027,18 @@
}
} );
/**
* wp.customize.Menus.NewMenuControl
*
* Customizer control for creating new menus and handling deletion of existing menus.
* Note that 'new_menu' must match the WP_Customize_New_Menu_Control::$type.
*
* @constructor
* @augments wp.customize.Control
* @deprecated 4.9.0 This class is no longer used due to new menu creation UX.
*/
api.Menus.NewMenuControl = api.Control.extend({
api.Menus.NewMenuControl = api.Control.extend(/** @lends wp.customize.Menus.NewMenuControl.prototype */{
/**
* Initialize.
* wp.customize.Menus.NewMenuControl
*
* @deprecated 4.9.0
* Customizer control for creating new menus and handling deletion of existing menus.
* Note that 'new_menu' must match the WP_Customize_New_Menu_Control::$type.
*
* @constructs wp.customize.Menus.NewMenuControl
* @augments wp.customize.Control
*
* @deprecated 4.9.0 This class is no longer used due to new menu creation UX.
*/
initialize: function() {
if ( 'undefined' !== typeof console && console.warn ) {
@ -3166,6 +3168,8 @@
* When customize_save comes back with a success, make sure any inserted
* nav menus and items are properly re-added with their newly-assigned IDs.
*
* @alias wp.customize.Menus.applySavedData
*
* @param {object} data
* @param {array} data.nav_menu_updates
* @param {array} data.nav_menu_item_updates
@ -3396,6 +3400,8 @@
/**
* Focus a menu item control.
*
* @alias wp.customize.Menus.focusMenuItemControl
*
* @param {string} menuItemId
*/
api.Menus.focusMenuItemControl = function( menuItemId ) {
@ -3408,6 +3414,8 @@
/**
* Get the control for a given menu.
*
* @alias wp.customize.Menus.getMenuControl
*
* @param menuId
* @return {wp.customize.controlConstructor.menus[]}
*/
@ -3418,6 +3426,8 @@
/**
* Given a menu item ID, get the control associated with it.
*
* @alias wp.customize.Menus.getMenuItemControl
*
* @param {string} menuItemId
* @return {object|null}
*/
@ -3426,6 +3436,8 @@
};
/**
* @alias wp.customize.Menus~menuItemIdToSettingId
*
* @param {String} menuItemId
*/
function menuItemIdToSettingId( menuItemId ) {
@ -3436,6 +3448,8 @@
* Apply sanitize_text_field()-like logic to the supplied name, returning a
* "unnammed" fallback string if the name is then empty.
*
* @alias wp.customize.Menus~displayNavMenuName
*
* @param {string} name
* @returns {string}
*/

File diff suppressed because one or more lines are too long

View file

@ -1,3 +1,7 @@
/**
* @output wp-admin/js/customize-widgets.js
*/
/* global _wpCustomizeWidgetsSettings */
(function( wp, $ ){
@ -7,6 +11,9 @@
var api = wp.customize,
l10n;
/**
* @namespace wp.customize.Widgets
*/
api.Widgets = api.Widgets || {};
api.Widgets.savedWidgetIds = {};
@ -19,10 +26,10 @@
*
* A single widget model.
*
* @constructor
* @class wp.customize.Widgets.WidgetModel
* @augments Backbone.Model
*/
api.Widgets.WidgetModel = Backbone.Model.extend({
api.Widgets.WidgetModel = Backbone.Model.extend(/** @lends wp.customize.Widgets.WidgetModel.prototype */{
id: null,
temp_id: null,
classname: null,
@ -45,10 +52,10 @@
*
* Collection for widget models.
*
* @constructor
* @augments Backbone.Model
* @class wp.customize.Widgets.WidgetCollection
* @augments Backbone.Collection
*/
api.Widgets.WidgetCollection = Backbone.Collection.extend({
api.Widgets.WidgetCollection = Backbone.Collection.extend(/** @lends wp.customize.Widgets.WidgetCollection.prototype */{
model: api.Widgets.WidgetModel,
// Controls searching on the current widget collection
@ -103,10 +110,10 @@
*
* A single sidebar model.
*
* @constructor
* @class wp.customize.Widgets.SidebarModel
* @augments Backbone.Model
*/
api.Widgets.SidebarModel = Backbone.Model.extend({
api.Widgets.SidebarModel = Backbone.Model.extend(/** @lends wp.customize.Widgets.SidebarModel.prototype */{
after_title: null,
after_widget: null,
before_title: null,
@ -123,30 +130,20 @@
*
* Collection for sidebar models.
*
* @constructor
* @class wp.customize.Widgets.SidebarCollection
* @augments Backbone.Collection
*/
api.Widgets.SidebarCollection = Backbone.Collection.extend({
api.Widgets.SidebarCollection = Backbone.Collection.extend(/** @lends wp.customize.Widgets.SidebarCollection.prototype */{
model: api.Widgets.SidebarModel
});
api.Widgets.registeredSidebars = new api.Widgets.SidebarCollection( api.Widgets.data.registeredSidebars );
/**
* wp.customize.Widgets.AvailableWidgetsPanelView
*
* View class for the available widgets panel.
*
* @constructor
* @augments wp.Backbone.View
* @augments Backbone.View
*/
api.Widgets.AvailableWidgetsPanelView = wp.Backbone.View.extend({
api.Widgets.AvailableWidgetsPanelView = wp.Backbone.View.extend(/** @lends wp.customize.Widgets.AvailableWidgetsPanelView.prototype */{
el: '#available-widgets',
events: {
'input #widgets-search': 'search',
'keyup #widgets-search': 'search',
'focus .widget-tpl' : 'focus',
'click .widget-tpl' : '_submit',
'keypress .widget-tpl' : '_submit',
@ -162,6 +159,12 @@
$clearResults: null,
searchMatchesCount: null,
/**
* View class for the available widgets panel.
*
* @constructs wp.customize.Widgets.AvailableWidgetsPanelView
* @augments wp.Backbone.View
*/
initialize: function() {
var self = this;
@ -197,7 +200,9 @@
api.previewer.bind( 'url', this.close );
},
// Performs a search and handles selected widget
/**
* Performs a search and handles selected widget.
*/
search: function( event ) {
var firstVisible;
@ -242,12 +247,16 @@
}
},
// Update the count of the available widgets that have the `search_matched` attribute.
/**
* Updates the count of the available widgets that have the `search_matched` attribute.
*/
updateSearchMatchesCount: function() {
this.searchMatchesCount = this.collection.where({ search_matched: true }).length;
},
// Send a message to the aria-live region to announce how many search results.
/**
* Sends a message to the aria-live region to announce how many search results.
*/
announceSearchMatches: _.debounce( function() {
var message = l10n.widgetsFound.replace( '%d', this.searchMatchesCount ) ;
@ -258,7 +267,9 @@
wp.a11y.speak( message );
}, 500 ),
// Changes visibility of available widgets
/**
* Changes visibility of available widgets.
*/
updateList: function() {
this.collection.each( function( widget ) {
var widgetTpl = $( '#widget-tpl-' + widget.id );
@ -269,19 +280,25 @@
} );
},
// Highlights a widget
/**
* Highlights a widget.
*/
select: function( widgetTpl ) {
this.selected = $( widgetTpl );
this.selected.siblings( '.widget-tpl' ).removeClass( 'selected' );
this.selected.addClass( 'selected' );
},
// Highlights a widget on focus
/**
* Highlights a widget on focus.
*/
focus: function( event ) {
this.select( $( event.currentTarget ) );
},
// Submit handler for keypress and click on widget
/**
* Handles submit for keypress and click on widget.
*/
_submit: function( event ) {
// Only proceed with keypress if it is Enter or Spacebar
if ( event.type === 'keypress' && ( event.which !== 13 && event.which !== 32 ) ) {
@ -291,7 +308,9 @@
this.submit( $( event.currentTarget ) );
},
// Adds a selected widget to the sidebar
/**
* Adds a selected widget to the sidebar.
*/
submit: function( widgetTpl ) {
var widgetId, widget, widgetFormControl;
@ -319,7 +338,9 @@
this.close();
},
// Opens the panel
/**
* Opens the panel.
*/
open: function( sidebarControl ) {
this.currentSidebarControl = sidebarControl;
@ -346,7 +367,9 @@
}
},
// Closes the panel
/**
* Closes the panel.
*/
close: function( options ) {
options = options || {};
@ -362,7 +385,9 @@
this.$search.val( '' );
},
// Add keyboard accessiblity to the panel
/**
* Adds keyboard accessiblity to the panel.
*/
keyboardAccessible: function( event ) {
var isEnter = ( event.which === 13 ),
isEsc = ( event.which === 27 ),
@ -424,6 +449,8 @@
* Handlers for the widget-synced event, organized by widget ID base.
* Other widgets may provide their own update handlers by adding
* listeners for the widget-synced event.
*
* @alias wp.customize.Widgets.formSyncHandlers
*/
api.Widgets.formSyncHandlers = {
@ -446,23 +473,22 @@
}
};
/**
* wp.customize.Widgets.WidgetControl
*
* Customizer control for widgets.
* Note that 'widget_form' must match the WP_Widget_Form_Customize_Control::$type
*
* @constructor
* @augments wp.customize.Control
*/
api.Widgets.WidgetControl = api.Control.extend({
api.Widgets.WidgetControl = api.Control.extend(/** @lends wp.customize.Widgets.WidgetControl.prototype */{
defaultExpandedArguments: {
duration: 'fast',
completeCallback: $.noop
},
/**
* wp.customize.Widgets.WidgetControl
*
* Customizer control for widgets.
* Note that 'widget_form' must match the WP_Widget_Form_Customize_Control::$type
*
* @since 4.1.0
*
* @constructs wp.customize.Widgets.WidgetControl
* @augments wp.customize.Control
*/
initialize: function( id, options ) {
var control = this;
@ -943,7 +969,7 @@
*
* @param {Boolean} active
* @param {Object} args
* @param {Callback} args.completeCallback
* @param {function} args.completeCallback
*/
onChangeActive: function ( active, args ) {
// Note: there is a second 'args' parameter being passed, merged on top of this.defaultActiveArguments
@ -1574,8 +1600,11 @@
* Customizer panel containing the widget area sections.
*
* @since 4.4.0
*
* @class wp.customize.Widgets.WidgetsPanel
* @augments wp.customize.Panel
*/
api.Widgets.WidgetsPanel = api.Panel.extend({
api.Widgets.WidgetsPanel = api.Panel.extend(/** @lends wp.customize.Widgets.WigetsPanel.prototype */{
/**
* Add and manage the display of the no-rendered-areas notice.
@ -1604,7 +1633,7 @@
*/
getActiveSectionCount = function() {
return _.filter( panel.sections(), function( section ) {
return section.active();
return 'sidebar' === section.params.type && section.active();
} ).length;
};
@ -1695,8 +1724,11 @@
* Customizer section representing a widget area widget
*
* @since 4.1.0
*
* @class wp.customize.Widgets.SidebarSection
* @augments wp.customize.Section
*/
api.Widgets.SidebarSection = api.Section.extend({
api.Widgets.SidebarSection = api.Section.extend(/** @lends wp.customize.Widgets.SidebarSection.prototype */{
/**
* Sync the section's active state back to the Backbone model's is_rendered attribute
@ -1722,10 +1754,10 @@
*
* @since 3.9.0
*
* @constructor
* @class wp.customize.Widgets.SidebarControl
* @augments wp.customize.Control
*/
api.Widgets.SidebarControl = api.Control.extend({
api.Widgets.SidebarControl = api.Control.extend(/** @lends wp.customize.Widgets.SidebarControl.prototype */{
/**
* Set up the control

File diff suppressed because one or more lines are too long

View file

@ -1,12 +1,30 @@
/* global pagenow, ajaxurl, postboxes, wpActiveEditor:true */
var ajaxWidgets, ajaxPopulateWidgets, quickPressLoad;
/**
* @output wp-admin/js/dashboard.js
*/
/* global pagenow, ajaxurl, postboxes, wpActiveEditor:true, ajaxWidgets */
/* global ajaxPopulateWidgets, quickPressLoad, */
window.wp = window.wp || {};
/**
* Initializes the dashboard widget functionality.
*
* @since 2.7.0
*/
jQuery(document).ready( function($) {
var welcomePanel = $( '#welcome-panel' ),
welcomePanelHide = $('#wp_welcome_panel-hide'),
updateWelcomePanel;
/**
* Saves the visibility of the welcome panel.
*
* @since 3.3.0
*
* @param {boolean} visible Should it be visible or not.
*
* @returns {void}
*/
updateWelcomePanel = function( visible ) {
$.post( ajaxurl, {
action: 'update-welcome-panel',
@ -15,10 +33,12 @@ jQuery(document).ready( function($) {
});
};
// Unhide the welcome panel if the Welcome Option checkbox is checked.
if ( welcomePanel.hasClass('hidden') && welcomePanelHide.prop('checked') ) {
welcomePanel.removeClass('hidden');
}
// Hide the welcome panel when the dismiss button or close button is clicked.
$('.welcome-panel-close, .welcome-panel-dismiss a', welcomePanel).click( function(e) {
e.preventDefault();
welcomePanel.addClass('hidden');
@ -26,21 +46,52 @@ jQuery(document).ready( function($) {
$('#wp_welcome_panel-hide').prop('checked', false);
});
// Set welcome panel visibility based on Welcome Option checkbox value.
welcomePanelHide.click( function() {
welcomePanel.toggleClass('hidden', ! this.checked );
updateWelcomePanel( this.checked ? 1 : 0 );
});
// These widgets are sometimes populated via ajax
ajaxWidgets = ['dashboard_primary'];
/**
* These widgets can be populated via ajax.
*
* @since 2.7.0
*
* @type {string[]}
*
* @global
*/
window.ajaxWidgets = ['dashboard_primary'];
ajaxPopulateWidgets = function(el) {
/**
* Triggers widget updates via AJAX.
*
* @since 2.7.0
*
* @global
*
* @param {string} el Optional. Widget to fetch or none to update all.
*
* @returns {void}
*/
window.ajaxPopulateWidgets = function(el) {
/**
* Fetch the latest representation of the widget via Ajax and show it.
*
* @param {number} i Number of half-seconds to use as the timeout.
* @param {string} id ID of the element which is going to be checked for changes.
*
* @returns {void}
*/
function show(i, id) {
var p, e = $('#' + id + ' div.inside:visible').find('.widget-loading');
// If the element is found in the dom, queue to load latest representation.
if ( e.length ) {
p = e.parent();
setTimeout( function(){
// Request the widget content.
p.load( ajaxurl + '?action=dashboard-widgets&widget=' + id + '&pagenow=' + pagenow, '', function() {
// Hide the parent and slide it out for visual fancyness.
p.hide().slideDown('normal', function(){
$(this).css('display', '');
});
@ -49,39 +100,67 @@ jQuery(document).ready( function($) {
}
}
// If we have received a specific element to fetch, check if it is valid.
if ( el ) {
el = el.toString();
// If the element is available as AJAX widget, show it.
if ( $.inArray(el, ajaxWidgets) !== -1 ) {
// Show element without any delay.
show(0, el);
}
} else {
// Walk through all ajaxWidgets, loading them after each other.
$.each( ajaxWidgets, show );
}
};
// Initially populate ajax widgets.
ajaxPopulateWidgets();
// Register ajax widgets as postbox toggles.
postboxes.add_postbox_toggles(pagenow, { pbshow: ajaxPopulateWidgets } );
/* QuickPress */
quickPressLoad = function() {
/**
* Control the Quick Press (Quick Draft) widget.
*
* @since 2.7.0
*
* @global
*
* @returns {void}
*/
window.quickPressLoad = function() {
var act = $('#quickpost-action'), t;
// Enable the submit buttons.
$( '#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]' ).prop( 'disabled' , false );
t = $('#quick-press').submit( function( e ) {
e.preventDefault();
// Show a spinner.
$('#dashboard_quick_press #publishing-action .spinner').show();
// Disable the submit button to prevent duplicate submissions.
$('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop('disabled', true);
// Post the entered data to save it.
$.post( t.attr( 'action' ), t.serializeArray(), function( data ) {
// Replace the form, and prepend the published post.
$('#dashboard_quick_press .inside').html( data );
$('#quick-press').removeClass('initial-form');
quickPressLoad();
highlightLatestPost();
// Focus the title to allow for quickly drafting another post.
$('#title').focus();
});
/**
* Highlights the latest post for one second.
*
* @returns {void}
*/
function highlightLatestPost () {
var latestPost = $('.drafts ul li').first();
latestPost.css('background', '#fffbe5');
@ -91,8 +170,17 @@ jQuery(document).ready( function($) {
}
} );
// Change the QuickPost action to the publish value.
$('#publish').click( function() { act.val( 'post-quickpress-publish' ); } );
/**
* Adds accessibility context to inputs.
*
* Use the 'screen-reader-text' class to hide the label when entering a value.
* Apply it when the input is not empty or the input has focus.
*
* @returns {void}
*/
$('#title, #tags-input, #content').each( function() {
var input = $(this), prompt = $('#' + this.id + '-prompt-text');
@ -122,11 +210,20 @@ jQuery(document).ready( function($) {
autoResizeTextarea();
};
quickPressLoad();
window.quickPressLoad();
// Enable the dragging functionality of the widgets.
$( '.meta-box-sortables' ).sortable( 'option', 'containment', '#wpwrap' );
/**
* Adjust the height of the textarea based on the content.
*
* @since 3.6.0
*
* @returns {void}
*/
function autoResizeTextarea() {
// When IE8 or older is used to render this document, exit.
if ( document.documentMode && document.documentMode < 9 ) {
return;
}
@ -137,12 +234,16 @@ jQuery(document).ready( function($) {
var clone = $('.quick-draft-textarea-clone'),
editor = $('#content'),
editorHeight = editor.height(),
// 100px roughly accounts for browser chrome and allows the
// save draft button to show on-screen at the same time.
/*
* 100px roughly accounts for browser chrome and allows the
* save draft button to show on-screen at the same time.
*/
editorMaxHeight = $(window).height() - 100;
// Match up textarea and clone div as much as possible.
// Padding cannot be reliably retrieved using shorthand in all browsers.
/*
* Match up textarea and clone div as much as possible.
* Padding cannot be reliably retrieved using shorthand in all browsers.
*/
clone.css({
'font-family': editor.css('font-family'),
'font-size': editor.css('font-size'),
@ -156,31 +257,34 @@ jQuery(document).ready( function($) {
'display': 'none'
});
// propertychange is for IE < 9
// The 'propertychange' is used in IE < 9.
editor.on('focus input propertychange', function() {
var $this = $(this),
// &nbsp; is to ensure that the height of a final trailing newline is included.
// Add a non-breaking space to ensure that the height of a trailing newline is
// included.
textareaContent = $this.val() + '&nbsp;',
// 2px is for border-top & border-bottom
// Add 2px to compensate for border-top & border-bottom.
cloneHeight = clone.css('width', $this.css('width')).text(textareaContent).outerHeight() + 2;
// Default to having scrollbars
// Default to show a vertical scrollbar, if needed.
editor.css('overflow-y', 'auto');
// Only change the height if it has indeed changed and both heights are below the max.
// Only change the height if it has changed and both heights are below the max.
if ( cloneHeight === editorHeight || ( cloneHeight >= editorMaxHeight && editorHeight >= editorMaxHeight ) ) {
return;
}
// Don't allow editor to exceed height of window.
// This is also bound in CSS to a max-height of 1300px to be extra safe.
/*
* Don't allow editor to exceed the height of the window.
* This is also bound in CSS to a max-height of 1300px to be extra safe.
*/
if ( cloneHeight > editorMaxHeight ) {
editorHeight = editorMaxHeight;
} else {
editorHeight = cloneHeight;
}
// No scrollbars as we change height, not for IE < 9
// Disable scrollbars because we adjust the height to the content.
editor.css('overflow', 'hidden');
$this.css('height', editorHeight + 'px');
@ -195,7 +299,15 @@ jQuery( function( $ ) {
var communityEventsData = window.communityEventsData || {},
app;
app = window.wp.communityEvents = {
/**
* Global Community Events namespace.
*
* @since 4.8.0
*
* @memberOf wp
* @namespace wp.communityEvents
*/
app = window.wp.communityEvents = /** @lends wp.communityEvents */{
initialized: false,
model: null,
@ -203,6 +315,8 @@ jQuery( function( $ ) {
* Initializes the wp.communityEvents object.
*
* @since 4.8.0
*
* @returns {void}
*/
init: function() {
if ( app.initialized ) {
@ -233,6 +347,11 @@ jQuery( function( $ ) {
$container.on( 'click', '.community-events-toggle-location, .community-events-cancel', app.toggleLocationForm );
/**
* Filters events based on entered location.
*
* @returns {void}
*/
$container.on( 'submit', '.community-events-form', function( event ) {
var location = $.trim( $( '#community-events-location' ).val() );
@ -267,6 +386,8 @@ jQuery( function( $ ) {
*
* @param {event|string} action 'show' or 'hide' to specify a state;
* or an event object to flip between states.
*
* @returns {void}
*/
toggleLocationForm: function( action ) {
var $toggleButton = $( '.community-events-toggle-location' ),
@ -309,7 +430,9 @@ jQuery( function( $ ) {
*
* @since 4.8.0
*
* @param {object} requestParams
* @param {Object} requestParams REST API Request parameters object.
*
* @returns {void}
*/
getEvents: function( requestParams ) {
var initiatedBy,
@ -362,6 +485,8 @@ jQuery( function( $ ) {
* @param {Object} templateParams The various parameters that will get passed to wp.template.
* @param {string} initiatedBy 'user' to indicate that this was triggered manually by the user;
* 'app' to indicate it was triggered automatically by the app itself.
*
* @returns {void}
*/
renderEventsTemplate: function( templateParams, initiatedBy ) {
var template,

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,9 @@
/**
* @output wp-admin/js/edit-comments.js
*/
/* global adminCommentsL10n, thousandsSeparator, list_args, QTags, ajaxurl, wpAjax */
var setCommentsList, theList, theExtraList, commentReply;
/* global commentReply, theExtraList, theList, setCommentsList */
(function($) {
var getCount, updateCount, updateCountText, updatePending, updateApproved,
@ -184,7 +188,7 @@ var getCount, updateCount, updateCountText, updatePending, updateApproved,
});
};
setCommentsList = function() {
window.setCommentsList = function() {
var totalInput, perPageInput, pageInput, dimAfter, delBefore, updateTotalCount, delAfter, refillTheExtraList, diff,
lastConfidentTime = 0;
@ -560,8 +564,8 @@ setCommentsList = function() {
});
};
theExtraList = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } );
theList = $('#the-comment-list').wpList( { alt: '', delBefore: delBefore, dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } )
window.theExtraList = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } );
window.theList = $('#the-comment-list').wpList( { alt: '', delBefore: delBefore, dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } )
.bind('wpListDelEnd', function(e, s){
var wpListsData = $(s.target).attr('data-wp-lists'), id = s.element.replace(/[^0-9]+/g, '');
@ -570,7 +574,7 @@ setCommentsList = function() {
});
};
commentReply = {
window.commentReply = {
cid : '',
act : '',
originalContent : '',
@ -632,15 +636,37 @@ commentReply = {
},
close : function() {
var c, replyrow = $('#replyrow');
var commentRow = $(),
replyRow = $( '#replyrow' );
// replyrow is not showing?
if ( replyrow.parent().is('#com-reply') )
if ( replyRow.parent().is( '#com-reply' ) ) {
return;
}
if ( this.cid && this.act == 'edit-comment' ) {
c = $('#comment-' + this.cid);
c.fadeIn(300, function(){ c.show(); }).css('backgroundColor', '');
if ( this.cid ) {
commentRow = $( '#comment-' + this.cid );
}
/*
* When closing the Quick Edit form, show the comment row and move focus
* back to the Quick Edit button.
*/
if ( 'edit-comment' === this.act ) {
commentRow.fadeIn( 300, function() {
commentRow
.show()
.find( '.vim-q' )
.attr( 'aria-expanded', 'false' )
.focus();
} ).css( 'backgroundColor', '' );
}
// When closing the Reply form, move focus back to the Reply button.
if ( 'replyto-comment' === this.act ) {
commentRow.find( '.vim-r' )
.attr( 'aria-expanded', 'false' )
.focus();
}
// reset the Quicktags buttons
@ -649,14 +675,14 @@ commentReply = {
$('#add-new-comment').css('display', '');
replyrow.hide();
$('#com-reply').append( replyrow );
replyRow.hide();
$( '#com-reply' ).append( replyRow );
$('#replycontent').css('height', '').val('');
$('#edithead input').val('');
$( '.notice-error', replyrow )
$( '.notice-error', replyRow )
.addClass( 'hidden' )
.find( '.error' ).empty();
$( '.spinner', replyrow ).removeClass( 'is-active' );
$( '.spinner', replyRow ).removeClass( 'is-active' );
this.cid = '';
this.originalContent = '';
@ -960,8 +986,7 @@ $(document).ready(function(){
}
// Quick Edit and Reply have an inline comment editor.
$( '#the-comment-list' ).on( 'click', '.comment-inline', function (e) {
e.preventDefault();
$( '#the-comment-list' ).on( 'click', '.comment-inline', function() {
var $el = $( this ),
action = 'replyto';
@ -969,6 +994,7 @@ $(document).ready(function(){
action = $el.data( 'action' );
}
$( this ).attr( 'aria-expanded', 'true' );
commentReply.open( $el.data( 'commentId' ), $el.data( 'postId' ), action );
} );
});

File diff suppressed because one or more lines are too long

View file

@ -1,3 +1,7 @@
/**
* @output wp-admin/js/editor-expand.js
*/
( function( window, $, undefined ) {
'use strict';
@ -7,7 +11,7 @@
$footer = $( '#wpfooter' );
/**
* @summary Handles the resizing of the editor.
* Handles the resizing of the editor.
*
* @since 4.0.0
*
@ -60,10 +64,9 @@
};
/**
* @summary Resizes textarea based on scroll height and width.
* Resizes textarea based on scroll height and width.
*
* Resizes textarea based on scroll height and width. Doesn't shrink the
* editor size below the 300px auto resize minimum height.
* Doesn't shrink the editor size below the 300px auto resize minimum height.
*
* @since 4.6.1
*
@ -90,7 +93,7 @@
}, 300 );
/**
* @summary Resizes the text editor depending on the old text length.
* Resizes the text editor depending on the old text length.
*
* If there is an mceEditor and it is hidden, it resizes the editor depending
* on the old text length. If the current length of the text is smaller than
@ -123,7 +126,7 @@
}
/**
* @summary Gets the height and widths of elements.
* Gets the height and widths of elements.
*
* Gets the heights of the window, the adminbar, the tools, the menu,
* the visualTop, the textTop, the bottom, the statusbar and sideSortables
@ -158,8 +161,8 @@
// We need to wait for TinyMCE to initialize.
/**
* @summary Binds all necessary functions for editor expand to the editor
* when the editor is initialized.
* Binds all necessary functions for editor expand to the editor when the editor
* is initialized.
*
* @since 4.0.0
*
@ -172,7 +175,7 @@
// VK contains the type of key pressed. VK = virtual keyboard.
var VK = window.tinymce.util.VK,
/**
* @summary Hides any float panel with a hover state. Additionally hides tooltips.
* Hides any float panel with a hover state. Additionally hides tooltips.
*
* @returns {void}
*/
@ -199,7 +202,7 @@
$menuBar = $contentWrap.find( '.mce-menubar' );
/**
* @summary Gets the offset of the editor.
* Gets the offset of the editor.
*
* @returns {Number|Boolean} Returns the offset of the editor
* or false if there is no offset height.
@ -232,7 +235,7 @@
}
/**
* @summary Filters the special keys that should not be used for scrolling.
* Filters the special keys that should not be used for scrolling.
*
* @since 4.0.0
*
@ -255,7 +258,7 @@
}
/**
* @summary Makes sure the cursor is always visible in the editor.
* Makes sure the cursor is always visible in the editor.
*
* Makes sure the cursor is kept between the toolbars of the editor and scrolls
* the window when the cursor moves out of the viewport to a wpview.
@ -322,7 +325,7 @@
}
/**
* @summary If the editor is fullscreen, calls adjust.
* If the editor is fullscreen, calls adjust.
*
* @since 4.1.0
*
@ -338,7 +341,7 @@
}
/**
* @summary Shows the editor when scrolled.
* Shows the editor when scrolled.
*
* Binds the hideFloatPanels function on the window scroll.mce-float-panels event.
* Executes the wpAutoResize on the active editor.
@ -357,7 +360,7 @@
}
/**
* @summary Resizes the editor.
* Resizes the editor.
*
* Removes all functions from the window scroll.mce-float-panels event.
* Resizes the text editor and scrolls to a position based on the pageXOffset and adminBarHeight.
@ -384,7 +387,7 @@
}
/**
* @summary Toggles advanced states.
* Toggles advanced states.
*
* @since 4.1.0
*
@ -395,7 +398,7 @@
}
/**
* @summary Binds events of the editor and window.
* Binds events of the editor and window.
*
* @since 4.0.0
*
@ -420,7 +423,7 @@
};
/**
* @summary Unbinds the events of the editor and window.
* Unbinds the events of the editor and window.
*
* @since 4.0.0
*
@ -447,10 +450,11 @@
} );
/**
* @summary Adjusts the toolbars heights and positions.
* Adjusts the toolbars heights and positions.
*
* Adjusts the toolbar heights and positions based on the scroll position on the page,
* the active editor mode and the heights of the editor, admin bar and side bar.
* Adjusts the toolbars heights and positions based on the scroll position on
* the page, the active editor mode and the heights of the editor, admin bar and
* side bar.
*
* @since 4.0.0
*
@ -764,7 +768,7 @@
}
/**
* @summary Resizes the editor and adjusts the toolbars.
* Resizes the editor and adjusts the toolbars.
*
* @since 4.0.0
*
@ -776,7 +780,7 @@
}
/**
* @summary Runs the passed function with 500ms intervals.
* Runs the passed function with 500ms intervals.
*
* @since 4.0.0
*
@ -791,7 +795,7 @@
}
/**
* @summary Runs adjust after 100ms.
* Runs adjust after 100ms.
*
* @since 4.0.0
*
@ -803,7 +807,7 @@
}
/**
* @summary Binds editor expand events on elements.
* Binds editor expand events on elements.
*
* @since 4.0.0
*
@ -873,7 +877,7 @@
}
/**
* @summary Unbinds editor expand events.
* Unbinds editor expand events.
*
* @since 4.0.0
*
@ -967,7 +971,7 @@
} );
/**
* @summary Handles the distraction free writing of TinyMCE.
* Handles the distraction free writing of TinyMCE.
*
* @since 4.1.0
*
@ -1017,7 +1021,7 @@
} );
/**
* @summary Recalculates the bottom and right position of the editor in the DOM.
* Recalculates the bottom and right position of the editor in the DOM.
*
* @since 4.1.0
*
@ -1030,7 +1034,7 @@
}
/**
* @summary Activates the distraction free writing mode.
* Activates the distraction free writing mode.
*
* @since 4.1.0
*
@ -1046,7 +1050,7 @@
}
/**
* @summary Deactivates the distraction free writing mode.
* Deactivates the distraction free writing mode.
*
* @since 4.1.0
*
@ -1064,7 +1068,7 @@
}
/**
* @summary Returns _isActive.
* Returns _isActive.
*
* @since 4.1.0
*
@ -1075,7 +1079,7 @@
}
/**
* @summary Binds events on the editor for distraction free writing.
* Binds events on the editor for distraction free writing.
*
* @since 4.1.0
*
@ -1098,7 +1102,7 @@
}
/**
* @summary Unbinds events on the editor for distraction free writing.
* Unbinds events on the editor for distraction free writing.
*
* @since 4.1.0
*
@ -1121,7 +1125,7 @@
}
/**
* @summary Binds or unbinds the editor expand events.
* Binds or unbinds the editor expand events.
*
* @since 4.1.0
*
@ -1136,7 +1140,7 @@
}
/**
* @summary Returns the value of _isOn.
* Returns the value of _isOn.
*
* @since 4.1.0
*
@ -1147,7 +1151,7 @@
}
/**
* @summary Fades out all elements except for the editor.
* Fades out all elements except for the editor.
*
* The fading is done based on key presses and mouse movements.
* Also calls the fadeIn on certain key presses
@ -1290,7 +1294,7 @@
}
/**
* @summary Fades all elements back in.
* Fades all elements back in.
*
* @since 4.1.0
*
@ -1338,7 +1342,7 @@
}
/**
* @summary Fades in if the focused element based on it position.
* Fades in if the focused element based on it position.
*
* @since 4.1.0
*
@ -1360,7 +1364,7 @@
}
/**
* @summary Fades out the admin bar based on focus on the admin bar.
* Fades out the admin bar based on focus on the admin bar.
*
* @since 4.1.0
*
@ -1381,7 +1385,7 @@
}
/**
* @summary Fades in the admin bar.
* Fades in the admin bar.
*
* @since 4.1.0
*
@ -1396,7 +1400,7 @@
}
/**
* @summary Fades out the edit slug box.
* Fades out the edit slug box.
*
* @since 4.1.0
*
@ -1413,7 +1417,7 @@
}
/**
* @summary Fades in the edit slug box.
* Fades in the edit slug box.
*
* @since 4.1.0
*
@ -1430,7 +1434,7 @@
}
/**
* @summary Triggers the toggle on Alt + Shift + W.
* Triggers the toggle on Alt + Shift + W.
*
* Keycode 87 = w.
*
@ -1451,7 +1455,7 @@
}
/**
* @summary Adds the distraction free writing button when setting up TinyMCE.
* Adds the distraction free writing button when setting up TinyMCE.
*
* @since 4.1.0
*
@ -1492,7 +1496,7 @@
} );
/**
* @summary Binds and unbinds events on the editor.
* Binds and unbinds events on the editor.
*
* @since 4.1.0
*
@ -1549,7 +1553,7 @@
} );
/**
* @summary Binds events on quicktags init.
* Binds events on quicktags init.
*
* @since 4.1.0
*

View file

@ -1,10 +1,14 @@
/**
* @output wp-admin/js/editor.js
*/
window.wp = window.wp || {};
( function( $, wp ) {
wp.editor = wp.editor || {};
/**
* @summary Utility functions for the editor.
* Utility functions for the editor.
*
* @since 2.5.0
*/
@ -18,7 +22,7 @@ window.wp = window.wp || {};
$$ = tinymce.$;
/**
* @summary Handles onclick events for the Visual/Text tabs.
* Handles onclick events for the Visual/Text tabs.
*
* @since 4.3.0
*
@ -38,7 +42,7 @@ window.wp = window.wp || {};
}
/**
* @summary Returns the height of the editor toolbar(s) in px.
* Returns the height of the editor toolbar(s) in px.
*
* @since 3.9.0
*
@ -58,7 +62,7 @@ window.wp = window.wp || {};
}
/**
* @summary Switches the editor between Visual and Text mode.
* Switches the editor between Visual and Text mode.
*
* @since 2.5.0
*
@ -184,7 +188,7 @@ window.wp = window.wp || {};
}
/**
* @summary Checks if a cursor is inside an HTML tag.
* Checks if a cursor is inside an HTML tag or comment.
*
* In order to prevent breaking HTML tags when selecting text, the cursor
* must be moved to either the start or end of the tag.
@ -207,7 +211,7 @@ window.wp = window.wp || {};
if ( lastLtPos > lastGtPos || content.substr( cursorPosition, 1 ) === '>' ) {
// find what the tag is
var tagContent = content.substr( lastLtPos ),
tagMatch = tagContent.match( /<\s*(\/)?(\w+)/ );
tagMatch = tagContent.match( /<\s*(\/)?(\w+|\!-{2}.*-{2})/ );
if ( ! tagMatch ) {
return null;
@ -227,7 +231,7 @@ window.wp = window.wp || {};
}
/**
* @summary Check if the cursor is inside a shortcode
* Checks if the cursor is inside a shortcode
*
* If the cursor is inside a shortcode wrapping tag, e.g. `[caption]` it's better to
* move the selection marker to before or after the shortcode.
@ -281,7 +285,7 @@ window.wp = window.wp || {};
}
/**
* @summary Get all shortcodes and their positions in the content
* Gets all shortcodes and their positions in the content
*
* This function returns all the shortcodes that could be found in the textarea content
* along with their character positions and boundaries.
@ -378,7 +382,7 @@ window.wp = window.wp || {};
}
/**
* @summary Get adjusted selection cursor positions according to HTML tags/shortcodes
* Gets adjusted selection cursor positions according to HTML tags, comments, and shortcodes.
*
* Shortcodes and HTML codes are a bit of a special case when selecting, since they may render
* content in Visual mode. If we insert selection markers somewhere inside them, it's really possible
@ -461,7 +465,7 @@ window.wp = window.wp || {};
}
/**
* @summary Adds text selection markers in the editor textarea.
* Adds text selection markers in the editor textarea.
*
* Adds selection markers in the content of the editor `textarea`.
* The method directly manipulates the `textarea` content, to allow TinyMCE plugins
@ -511,7 +515,7 @@ window.wp = window.wp || {};
}
/**
* @summary Focus the selection markers in Visual mode.
* Focuses the selection markers in Visual mode.
*
* The method checks for existing selection markers inside the editor DOM (Visual mode)
* and create a selection between the two nodes using the DOM `createRange` selection API
@ -550,7 +554,7 @@ window.wp = window.wp || {};
}
/**
* @summary Remove selection marker and the parent node if it is an empty paragraph.
* Removes selection marker and the parent node if it is an empty paragraph.
*
* By default TinyMCE wraps loose inline tags in a `<p>`.
* When removing selection markers an empty `<p>` may be left behind, remove it.
@ -569,7 +573,7 @@ window.wp = window.wp || {};
}
/**
* @summary Scrolls the content to place the selected element in the center of the screen.
* Scrolls the content to place the selected element in the center of the screen.
*
* Takes an element, that is usually the selection start element, selected in
* `focusHTMLBookmarkInVisualEditor()` and scrolls the screen so the element appears roughly
@ -644,7 +648,7 @@ window.wp = window.wp || {};
}
/**
* @summary Finds the current selection position in the Visual editor.
* Finds the current selection position in the Visual editor.
*
* Find the current selection in the Visual editor by inserting marker elements at the start
* and end of the selection.
@ -811,7 +815,7 @@ window.wp = window.wp || {};
}
/**
* @summary Selects text in the TinyMCE `textarea`.
* Selects text in the TinyMCE `textarea`.
*
* Selects the text in TinyMCE's textarea that's between `selection.start` and `selection.end`.
*
@ -852,7 +856,7 @@ window.wp = window.wp || {};
} );
/**
* @summary Replaces <p> tags with two line breaks. "Opposite" of wpautop().
* Replaces <p> tags with two line breaks. "Opposite" of wpautop().
*
* Replaces <p> tags with two line breaks except where the <p> has attributes.
* Unifies whitespace.
@ -991,7 +995,7 @@ window.wp = window.wp || {};
}
/**
* @summary Replaces two line breaks with a paragraph tag and one line break with a <br>.
* Replaces two line breaks with a paragraph tag and one line break with a <br>.
*
* Similar to `wpautop()` in formatting.php.
*
@ -1120,7 +1124,7 @@ window.wp = window.wp || {};
}
/**
* @summary Fires custom jQuery events `beforePreWpautop` and `afterPreWpautop` when jQuery is available.
* Fires custom jQuery events `beforePreWpautop` and `afterPreWpautop` when jQuery is available.
*
* @since 2.9.0
*
@ -1146,7 +1150,7 @@ window.wp = window.wp || {};
}
/**
* @summary Fires custom jQuery events `beforeWpautop` and `afterWpautop` when jQuery is available.
* Fires custom jQuery events `beforeWpautop` and `afterWpautop` when jQuery is available.
*
* @since 2.9.0
*
@ -1200,8 +1204,9 @@ window.wp = window.wp || {};
}
/**
* @namespace {SwitchEditors} switchEditors
* Expose the switch editors to be used globally.
*
* @namespace switchEditors
*/
window.switchEditors = new SwitchEditors();

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,8 @@
/* global unescape, getUserSetting, setUserSetting */
/**
* @output wp-admin/js/gallery.js
*/
/* global unescape, getUserSetting, setUserSetting, wpgallery, tinymce */
jQuery(document).ready(function($) {
var gallerySortable, gallerySortableInit, sortIt, clearAll, w, desc = false;
@ -84,12 +88,12 @@ jQuery(document).ready(function($) {
}
});
jQuery(window).unload( function () { tinymce = tinyMCE = wpgallery = null; } ); // Cleanup
jQuery(window).unload( function () { window.tinymce = window.tinyMCE = window.wpgallery = null; } ); // Cleanup
/* gallery settings */
var tinymce = null, tinyMCE, wpgallery;
window.tinymce = null;
wpgallery = {
window.wpgallery = {
mcemode : false,
editor : {},
dom : {},
@ -119,8 +123,8 @@ wpgallery = {
}
// Find window & API
tinymce = w.tinymce;
tinyMCE = w.tinyMCE;
window.tinymce = w.tinymce;
window.tinyMCE = w.tinyMCE;
t.editor = tinymce.EditorManager.activeEditor;
t.setup();

View file

@ -1 +1 @@
jQuery(document).ready(function(a){var b,c,d,e,f,g=!1;c=function(){b=a("#media-items").sortable({items:"div.media-item",placeholder:"sorthelper",axis:"y",distance:2,handle:"div.filename",stop:function(){var b=a("#media-items").sortable("toArray"),c=b.length;a.each(b,function(b,d){var e=g?c-b:1+b;a("#"+d+" .menu_order input").val(e)})}})},d=function(){var b=a(".menu_order_input"),c=b.length;b.each(function(b){var d=g?c-b:1+b;a(this).val(d)})},e=function(b){b=b||0,a(".menu_order_input").each(function(){("0"===this.value||b)&&(this.value="")})},a("#asc").click(function(a){a.preventDefault(),g=!1,d()}),a("#desc").click(function(a){a.preventDefault(),g=!0,d()}),a("#clear").click(function(a){a.preventDefault(),e(1)}),a("#showall").click(function(b){b.preventDefault(),a("#sort-buttons span a").toggle(),a("a.describe-toggle-on").hide(),a("a.describe-toggle-off, table.slidetoggle").show(),a("img.pinkynail").toggle(!1)}),a("#hideall").click(function(b){b.preventDefault(),a("#sort-buttons span a").toggle(),a("a.describe-toggle-on").show(),a("a.describe-toggle-off, table.slidetoggle").hide(),a("img.pinkynail").toggle(!0)}),c(),e(),a("#media-items>*").length>1&&(f=wpgallery.getWin(),a("#save-all, #gallery-settings").show(),"undefined"!=typeof f.tinyMCE&&f.tinyMCE.activeEditor&&!f.tinyMCE.activeEditor.isHidden()?(wpgallery.mcemode=!0,wpgallery.init()):a("#insert-gallery").show())}),jQuery(window).unload(function(){tinymce=tinyMCE=wpgallery=null});var tinymce=null,tinyMCE,wpgallery;wpgallery={mcemode:!1,editor:{},dom:{},is_update:!1,el:{},I:function(a){return document.getElementById(a)},init:function(){var a,b,c,d,e=this,f=e.getWin();if(e.mcemode){for(a=(""+document.location.search).replace(/^\?/,"").split("&"),b={},c=0;c<a.length;c++)d=a[c].split("="),b[unescape(d[0])]=unescape(d[1]);b.mce_rdomain&&(document.domain=b.mce_rdomain),tinymce=f.tinymce,tinyMCE=f.tinyMCE,e.editor=tinymce.EditorManager.activeEditor,e.setup()}},getWin:function(){return window.dialogArguments||opener||parent||top},setup:function(){var a,b,c,d,e,f,g=this,h=g.editor;if(g.mcemode){if(g.el=h.selection.getNode(),"IMG"!==g.el.nodeName||!h.dom.hasClass(g.el,"wpGallery")){if(!(b=h.dom.select("img.wpGallery"))||!b[0])return"1"===getUserSetting("galfile")&&(g.I("linkto-file").checked="checked"),"1"===getUserSetting("galdesc")&&(g.I("order-desc").checked="checked"),getUserSetting("galcols")&&(g.I("columns").value=getUserSetting("galcols")),getUserSetting("galord")&&(g.I("orderby").value=getUserSetting("galord")),void jQuery("#insert-gallery").show();g.el=b[0]}a=h.dom.getAttrib(g.el,"title"),a=h.dom.decode(a),a?(jQuery("#update-gallery").show(),g.is_update=!0,c=a.match(/columns=['"]([0-9]+)['"]/),d=a.match(/link=['"]([^'"]+)['"]/i),e=a.match(/order=['"]([^'"]+)['"]/i),f=a.match(/orderby=['"]([^'"]+)['"]/i),d&&d[1]&&(g.I("linkto-file").checked="checked"),e&&e[1]&&(g.I("order-desc").checked="checked"),c&&c[1]&&(g.I("columns").value=""+c[1]),f&&f[1]&&(g.I("orderby").value=f[1])):jQuery("#insert-gallery").show()}},update:function(){var a,b=this,c=b.editor,d="";return b.mcemode&&b.is_update?void("IMG"===b.el.nodeName&&(d=c.dom.decode(c.dom.getAttrib(b.el,"title")),d=d.replace(/\s*(order|link|columns|orderby)=['"]([^'"]+)['"]/gi,""),d+=b.getSettings(),c.dom.setAttrib(b.el,"title",d),b.getWin().tb_remove())):(a="[gallery"+b.getSettings()+"]",void b.getWin().send_to_editor(a))},getSettings:function(){var a=this.I,b="";return a("linkto-file").checked&&(b+=' link="file"',setUserSetting("galfile","1")),a("order-desc").checked&&(b+=' order="DESC"',setUserSetting("galdesc","1")),3!==a("columns").value&&(b+=' columns="'+a("columns").value+'"',setUserSetting("galcols",a("columns").value)),"menu_order"!==a("orderby").value&&(b+=' orderby="'+a("orderby").value+'"',setUserSetting("galord",a("orderby").value)),b}};
jQuery(document).ready(function(a){var b,c,d,e,f,g=!1;c=function(){b=a("#media-items").sortable({items:"div.media-item",placeholder:"sorthelper",axis:"y",distance:2,handle:"div.filename",stop:function(){var b=a("#media-items").sortable("toArray"),c=b.length;a.each(b,function(b,d){var e=g?c-b:1+b;a("#"+d+" .menu_order input").val(e)})}})},d=function(){var b=a(".menu_order_input"),c=b.length;b.each(function(b){var d=g?c-b:1+b;a(this).val(d)})},e=function(b){b=b||0,a(".menu_order_input").each(function(){("0"===this.value||b)&&(this.value="")})},a("#asc").click(function(a){a.preventDefault(),g=!1,d()}),a("#desc").click(function(a){a.preventDefault(),g=!0,d()}),a("#clear").click(function(a){a.preventDefault(),e(1)}),a("#showall").click(function(b){b.preventDefault(),a("#sort-buttons span a").toggle(),a("a.describe-toggle-on").hide(),a("a.describe-toggle-off, table.slidetoggle").show(),a("img.pinkynail").toggle(!1)}),a("#hideall").click(function(b){b.preventDefault(),a("#sort-buttons span a").toggle(),a("a.describe-toggle-on").show(),a("a.describe-toggle-off, table.slidetoggle").hide(),a("img.pinkynail").toggle(!0)}),c(),e(),a("#media-items>*").length>1&&(f=wpgallery.getWin(),a("#save-all, #gallery-settings").show(),"undefined"!=typeof f.tinyMCE&&f.tinyMCE.activeEditor&&!f.tinyMCE.activeEditor.isHidden()?(wpgallery.mcemode=!0,wpgallery.init()):a("#insert-gallery").show())}),jQuery(window).unload(function(){window.tinymce=window.tinyMCE=window.wpgallery=null}),window.tinymce=null,window.wpgallery={mcemode:!1,editor:{},dom:{},is_update:!1,el:{},I:function(a){return document.getElementById(a)},init:function(){var a,b,c,d,e=this,f=e.getWin();if(e.mcemode){for(a=(""+document.location.search).replace(/^\?/,"").split("&"),b={},c=0;c<a.length;c++)d=a[c].split("="),b[unescape(d[0])]=unescape(d[1]);b.mce_rdomain&&(document.domain=b.mce_rdomain),window.tinymce=f.tinymce,window.tinyMCE=f.tinyMCE,e.editor=tinymce.EditorManager.activeEditor,e.setup()}},getWin:function(){return window.dialogArguments||opener||parent||top},setup:function(){var a,b,c,d,e,f,g=this,h=g.editor;if(g.mcemode){if(g.el=h.selection.getNode(),"IMG"!==g.el.nodeName||!h.dom.hasClass(g.el,"wpGallery")){if(!(b=h.dom.select("img.wpGallery"))||!b[0])return"1"===getUserSetting("galfile")&&(g.I("linkto-file").checked="checked"),"1"===getUserSetting("galdesc")&&(g.I("order-desc").checked="checked"),getUserSetting("galcols")&&(g.I("columns").value=getUserSetting("galcols")),getUserSetting("galord")&&(g.I("orderby").value=getUserSetting("galord")),void jQuery("#insert-gallery").show();g.el=b[0]}a=h.dom.getAttrib(g.el,"title"),a=h.dom.decode(a),a?(jQuery("#update-gallery").show(),g.is_update=!0,c=a.match(/columns=['"]([0-9]+)['"]/),d=a.match(/link=['"]([^'"]+)['"]/i),e=a.match(/order=['"]([^'"]+)['"]/i),f=a.match(/orderby=['"]([^'"]+)['"]/i),d&&d[1]&&(g.I("linkto-file").checked="checked"),e&&e[1]&&(g.I("order-desc").checked="checked"),c&&c[1]&&(g.I("columns").value=""+c[1]),f&&f[1]&&(g.I("orderby").value=f[1])):jQuery("#insert-gallery").show()}},update:function(){var a,b=this,c=b.editor,d="";return b.mcemode&&b.is_update?void("IMG"===b.el.nodeName&&(d=c.dom.decode(c.dom.getAttrib(b.el,"title")),d=d.replace(/\s*(order|link|columns|orderby)=['"]([^'"]+)['"]/gi,""),d+=b.getSettings(),c.dom.setAttrib(b.el,"title",d),b.getWin().tb_remove())):(a="[gallery"+b.getSettings()+"]",void b.getWin().send_to_editor(a))},getSettings:function(){var a=this.I,b="";return a("linkto-file").checked&&(b+=' link="file"',setUserSetting("galfile","1")),a("order-desc").checked&&(b+=' order="DESC"',setUserSetting("galdesc","1")),3!==a("columns").value&&(b+=' columns="'+a("columns").value+'"',setUserSetting("galcols",a("columns").value)),"menu_order"!==a("orderby").value&&(b+=' orderby="'+a("orderby").value+'"',setUserSetting("galord",a("orderby").value)),b}};

View file

@ -1,10 +1,12 @@
/* global imageEditL10n, ajaxurl, confirm */
/**
* @summary The functions necessary for editing images.
* The functions necessary for editing images.
*
* @since 2.9.0
* @since 2.9.0
* @output wp-admin/js/image-edit.js
*/
/* global imageEditL10n, ajaxurl, confirm */
(function($) {
/**
@ -19,7 +21,32 @@
_view : false,
/**
* @summary Converts a value to an integer.
* Handle crop tool clicks.
*/
handleCropToolClick: function( postid, nonce, cropButton ) {
var img = $( '#image-preview-' + postid ),
selection = this.iasapi.getSelection();
// Ensure selection is available, otherwise reset to full image.
if ( isNaN( selection.x1 ) ) {
this.setCropSelection( postid, { 'x1': 0, 'y1': 0, 'x2': img.innerWidth(), 'y2': img.innerHeight(), 'width': img.innerWidth(), 'height': img.innerHeight() } );
selection = this.iasapi.getSelection();
}
// If we don't already have a selection, select the entire image.
if ( 0 === selection.x1 && 0 === selection.y1 && 0 === selection.x2 && 0 === selection.y2 ) {
this.iasapi.setSelection( 0, 0, img.innerWidth(), img.innerHeight(), true );
this.iasapi.setOptions( { show: true } );
this.iasapi.update();
} else {
// Otherwise, perform the crop.
imageEdit.crop( postid, nonce , cropButton );
}
},
/**
* Converts a value to an integer.
*
* @memberof imageEdit
* @since 2.9.0
@ -37,8 +64,7 @@
},
/**
* @summary Adds the disabled attribute and class to a single form element
* or a field set.
* Adds the disabled attribute and class to a single form element or a field set.
*
* @memberof imageEdit
* @since 2.9.0
@ -67,7 +93,7 @@
},
/**
* @summary Initializes the image editor.
* Initializes the image editor.
*
* @memberof imageEdit
* @since 2.9.0
@ -110,7 +136,7 @@
},
/**
* @summary Toggles the wait/load icon in the editor.
* Toggles the wait/load icon in the editor.
*
* @memberof imageEdit
* @since 2.9.0
@ -131,7 +157,7 @@
},
/**
* @summary Shows or hides the image edit help box.
* Shows or hides the image edit help box.
*
* @memberof imageEdit
* @since 2.9.0
@ -150,7 +176,7 @@
},
/**
* @summary Gets the value from the image edit target.
* Gets the value from the image edit target.
*
* The image edit target contains the image sizes where the (possible) changes
* have to be applied to.
@ -168,7 +194,7 @@
},
/**
* @summary Recalculates the height or width and keeps the original aspect ratio.
* Recalculates the height or width and keeps the original aspect ratio.
*
* If the original image size is exceeded a red exclamation mark is shown.
*
@ -206,7 +232,7 @@
},
/**
* @summary Gets the selected aspect ratio.
* Gets the selected aspect ratio.
*
* @memberof imageEdit
* @since 2.9.0
@ -232,7 +258,7 @@
},
/**
* @summary Removes the last action from the image edit history
* Removes the last action from the image edit history.
* The history consist of (edit) actions performed on the image.
*
* @memberof imageEdit
@ -296,7 +322,7 @@
return '';
},
/**
* @summary Binds the necessary events to the image.
* Binds the necessary events to the image.
*
* When the image source is reloaded the image will be reloaded.
*
@ -351,7 +377,6 @@
t.hold.sizer = max1 > max2 ? max2 / max1 : 1;
t.initCrop(postid, img, parent);
t.setCropSelection(postid, 0);
if ( (typeof callback !== 'undefined') && callback !== null ) {
callback();
@ -372,7 +397,7 @@
.attr('src', ajaxurl + '?' + $.param(data));
},
/**
* @summary Performs an image edit action.
* Performs an image edit action.
*
* @memberof imageEdit
* @since 2.9.0
@ -439,7 +464,7 @@
},
/**
* @summary Stores the changes that are made to the image.
* Stores the changes that are made to the image.
*
* @memberof imageEdit
* @since 2.9.0
@ -504,7 +529,7 @@
},
/**
* @summary Creates the image edit window.
* Creates the image edit window.
*
* @memberof imageEdit
* @since 2.9.0
@ -561,7 +586,7 @@
},
/**
* @summary Initializes the cropping tool and sets a default cropping selection.
* Initializes the cropping tool and sets a default cropping selection.
*
* @memberof imageEdit
* @since 2.9.0
@ -579,14 +604,15 @@
}
this.initCrop(postid, img, parent);
this.setCropSelection(postid, 0);
this.setCropSelection( postid, { 'x1': 0, 'y1': 0, 'x2': 0, 'y2': 0, 'width': img.innerWidth(), 'height': img.innerHeight() } );
this.toggleEditor(postid, 0);
// Editor is ready, move focus to the first focusable element.
$( '.imgedit-wrap .imgedit-help-toggle' ).eq( 0 ).focus();
},
/**
* @summary Initializes the cropping tool.
* Initializes the cropping tool.
*
* @memberof imageEdit
* @since 2.9.0
@ -612,7 +638,9 @@
minHeight: 3,
/**
* @summary Sets the CSS styles and binds events for locking the aspect ratio.
* Sets the CSS styles and binds events for locking the aspect ratio.
*
* @ignore
*
* @param {jQuery} img The preview image.
*/
@ -623,7 +651,7 @@
$img.next().css( 'position', 'absolute' )
.nextAll( '.imgareaselect-outer' ).css( 'position', 'absolute' );
/**
* @summary Binds mouse down event to the cropping container.
* Binds mouse down event to the cropping container.
*
* @returns {void}
*/
@ -643,7 +671,9 @@
},
/**
* @summary Event triggered when starting a selection.
* Event triggered when starting a selection.
*
* @ignore
*
* @returns {void}
*/
@ -651,7 +681,9 @@
imageEdit.setDisabled($('#imgedit-crop-sel-' + postid), 1);
},
/**
* @summary Event triggered when the selection is ended.
* Event triggered when the selection is ended.
*
* @ignore
*
* @param {object} img jQuery object representing the image.
* @param {object} c The selection.
@ -663,7 +695,9 @@
},
/**
* @summary Event triggered when the selection changes.
* Event triggered when the selection changes.
*
* @ignore
*
* @param {object} img jQuery object representing the image.
* @param {object} c The selection.
@ -679,7 +713,7 @@
},
/**
* @summary Stores the current crop selection.
* Stores the current crop selection.
*
* @memberof imageEdit
* @since 2.9.0
@ -695,8 +729,8 @@
c = c || 0;
if ( !c || ( c.width < 3 && c.height < 3 ) ) {
this.setDisabled($('.imgedit-crop', '#imgedit-panel-' + postid), 0);
this.setDisabled($('#imgedit-crop-sel-' + postid), 0);
this.setDisabled( $( '.imgedit-crop', '#imgedit-panel-' + postid ), 1 );
this.setDisabled( $( '#imgedit-crop-sel-' + postid ), 1 );
$('#imgedit-sel-width-' + postid).val('');
$('#imgedit-sel-height-' + postid).val('');
$('#imgedit-selection-' + postid).val('');
@ -710,7 +744,7 @@
/**
* @summary Closes the image editor.
* Closes the image editor.
*
* @memberof imageEdit
* @since 2.9.0
@ -751,7 +785,7 @@
},
/**
* @summary Checks if the image edit history is saved.
* Checks if the image edit history is saved.
*
* @memberof imageEdit
* @since 2.9.0
@ -775,7 +809,7 @@
},
/**
* @summary Adds an image edit action to the history.
* Adds an image edit action to the history.
*
* @memberof imageEdit
* @since 2.9.0
@ -808,7 +842,7 @@
},
/**
* @summary Rotates the image.
* Rotates the image.
*
* @memberof imageEdit
* @since 2.9.0
@ -829,7 +863,7 @@
},
/**
* @summary Flips the image.
* Flips the image.
*
* @memberof imageEdit
* @since 2.9.0
@ -850,7 +884,7 @@
},
/**
* @summary Crops the image.
* Crops the image.
*
* @memberof imageEdit
* @since 2.9.0
@ -879,7 +913,7 @@
},
/**
* @summary Undoes an image edit action.
* Undoes an image edit action.
*
* @memberof imageEdit
* @since 2.9.0
@ -942,7 +976,7 @@
},
/**
* @summary Sets the selection for the height and width in pixels.
* Sets the selection for the height and width in pixels.
*
* @memberof imageEdit
* @since 2.9.0

File diff suppressed because one or more lines are too long

View file

@ -1,19 +1,20 @@
/* global inlineEditL10n, ajaxurl, typenow */
/**
* This file contains the functions needed for the inline editing of posts.
*
* @since 2.7.0
* @output wp-admin/js/inline-edit-post.js
*/
/* global inlineEditL10n, ajaxurl, typenow, inlineEditPost */
window.wp = window.wp || {};
/**
* Manages the quick edit and bulk edit windows for editing posts or pages.
*
* @namespace
* @namespace inlineEditPost
*
* @since 2.7.0
* @access public
*
* @type {Object}
*
@ -21,13 +22,12 @@ window.wp = window.wp || {};
* @property {string} what The prefix before the post id.
*
*/
var inlineEditPost;
( function( $, wp ) {
inlineEditPost = {
window.inlineEditPost = {
/**
* @summary Initializes the inline and bulk post editor.
* Initializes the inline and bulk post editor.
*
* Binds event handlers to the escape key to close the inline editor
* and to the save and close buttons. Changes DOM to be ready for inline
@ -46,7 +46,7 @@ var inlineEditPost;
t.what = '#post-';
/**
* @summary Bind escape key to revert the changes and close the quick editor.
* Binds the escape key to revert the changes and close the quick editor.
*
* @returns {boolean} The result of revert.
*/
@ -58,7 +58,7 @@ var inlineEditPost;
});
/**
* @summary Bind escape key to revert the changes and close the bulk editor.
* Binds the escape key to revert the changes and close the bulk editor.
*
* @returns {boolean} The result of revert.
*/
@ -70,7 +70,7 @@ var inlineEditPost;
});
/**
* @summary Revert changes and close the quick editor if the cancel button is clicked.
* Reverts changes and close the quick editor if the cancel button is clicked.
*
* @returns {boolean} The result of revert.
*/
@ -79,7 +79,7 @@ var inlineEditPost;
});
/**
* @summary Save changes in the quick editor if the save(named: update) button is clicked.
* Saves changes in the quick editor if the save(named: update) button is clicked.
*
* @returns {boolean} The result of save.
*/
@ -88,7 +88,7 @@ var inlineEditPost;
});
/**
* @summary If enter is pressed, and the target is not the cancel button, save the post.
* If enter is pressed, and the target is not the cancel button, save the post.
*
* @returns {boolean} The result of save.
*/
@ -99,7 +99,7 @@ var inlineEditPost;
});
/**
* @summary Revert changes and close the bulk editor if the cancel button is clicked.
* Reverts changes and close the bulk editor if the cancel button is clicked.
*
* @returns {boolean} The result of revert.
*/
@ -108,7 +108,7 @@ var inlineEditPost;
});
/**
* @summary Disables the password input field when the private post checkbox is checked.
* Disables the password input field when the private post checkbox is checked.
*/
$('#inline-edit .inline-edit-private input[value="private"]').click( function(){
var pw = $('input.inline-edit-password-input');
@ -120,11 +120,11 @@ var inlineEditPost;
});
/**
* @summary Bind click event to the .editinline link which opens the quick editor.
* Binds click event to the .editinline button which opens the quick editor.
*/
$('#the-list').on( 'click', 'a.editinline', function( e ) {
e.preventDefault();
inlineEditPost.edit(this);
$( '#the-list' ).on( 'click', '.editinline', function() {
$( this ).attr( 'aria-expanded', 'true' );
inlineEditPost.edit( this );
});
$('#bulk-edit').find('fieldset:first').after(
@ -136,7 +136,7 @@ var inlineEditPost;
$('select[name="_status"] option[value="future"]', bulkRow).remove();
/**
* @summary Adds onclick events to the apply buttons.
* Adds onclick events to the apply buttons.
*/
$('#doaction, #doaction2').click(function(e){
var n;
@ -154,9 +154,8 @@ var inlineEditPost;
},
/**
* @summary Toggles the quick edit window.
*
* Hides the window when it's active and shows the window when inactive.
* Toggles the quick edit window, hiding it when it's active and showing it when
* inactive.
*
* @memberof inlineEditPost
* @since 2.7.0
@ -169,7 +168,7 @@ var inlineEditPost;
},
/**
* @summary Creates the bulk editor row to edit multiple posts at once.
* Creates the bulk editor row to edit multiple posts at once.
*
* @memberof inlineEditPost
* @since 2.7.0
@ -185,10 +184,10 @@ var inlineEditPost;
$('#bulk-edit').addClass('inline-editor').show();
/**
* @summary Create a HTML div with the title and a delete link(cross-icon) for each selected post.
* Create a HTML div with the title and a link(delete-icon) for each selected
* post.
*
* Get the selected posts based on the checked checkboxes in the post table.
* Create a HTML div with the title and a link(delete-icon) for each selected post.
*/
$( 'tbody th.check-column input[type="checkbox"]' ).each( function() {
@ -209,7 +208,7 @@ var inlineEditPost;
// Add onclick events to the delete-icons in the bulk editors the post title list.
$('#bulk-titles').html(te);
/**
* @summary Binds on click events to the checkboxes before the posts in the table.
* Binds on click events to the checkboxes before the posts in the table.
*
* @listens click
*/
@ -241,7 +240,7 @@ var inlineEditPost;
},
/**
* @summary Creates a quick edit window for the post that has been clicked.
* Creates a quick edit window for the post that has been clicked.
*
* @memberof inlineEditPost
* @since 2.7.0
@ -284,7 +283,7 @@ var inlineEditPost;
val = $('.'+fields[f], rowData);
/**
* @summary Replaces the image for a Twemoji(Twitter emoji) with it's alternate text.
* Replaces the image for a Twemoji(Twitter emoji) with it's alternate text.
*
* @returns Alternate text from the image.
*/
@ -304,7 +303,7 @@ var inlineEditPost;
}
/**
* @summary Creates the select boxes for the categories.
* Creates the select boxes for the categories.
*/
$('.post_category', rowData).each(function(){
var taxname,
@ -317,8 +316,8 @@ var inlineEditPost;
});
/**
* @summary Gets all the taxonomies for live auto-fill suggestions.
* When typing the name of a tag.
* Gets all the taxonomies for live auto-fill suggestions when typing the name
* of a tag.
*/
$('.tags_input', rowData).each(function(){
var terms = $(this),
@ -381,7 +380,7 @@ var inlineEditPost;
},
/**
* @summary Saves the changes made in the quick edit window to the post.
* Saves the changes made in the quick edit window to the post.
* AJAX saving is only for Quick Edit and not for bulk edit.
*
* @since 2.7.0
@ -424,8 +423,10 @@ var inlineEditPost;
$(inlineEditPost.what+id).siblings('tr.hidden').addBack().remove();
$('#edit-'+id).before(r).remove();
$( inlineEditPost.what + id ).hide().fadeIn( 400, function() {
// Move focus back to the Quick Edit link. $( this ) is the row being animated.
$( this ).find( '.editinline' ).focus();
// Move focus back to the Quick Edit button. $( this ) is the row being animated.
$( this ).find( '.editinline' )
.attr( 'aria-expanded', 'false' )
.focus();
wp.a11y.speak( inlineEditL10n.saved );
});
} else {
@ -447,7 +448,7 @@ var inlineEditPost;
},
/**
* @summary Hides and empties the Quick Edit and/or Bulk Edit windows.
* Hides and empties the Quick Edit and/or Bulk Edit windows.
*
* @memberof inlineEditPost
* @since 2.7.0
@ -479,8 +480,10 @@ var inlineEditPost;
$('#'+id).siblings('tr.hidden').addBack().remove();
id = id.substr( id.lastIndexOf('-') + 1 );
// Show the post row and move focus back to the Quick Edit link.
$( this.what + id ).show().find( '.editinline' ).focus();
// Show the post row and move focus back to the Quick Edit button.
$( this.what + id ).show().find( '.editinline' )
.attr( 'aria-expanded', 'false' )
.focus();
}
}
@ -488,8 +491,8 @@ var inlineEditPost;
},
/**
* @summary Gets the id for a the post that you want to quick edit from the row
* in the quick edit table.
* Gets the id for a the post that you want to quick edit from the row in the quick
* edit table.
*
* @memberof inlineEditPost
* @since 2.7.0

File diff suppressed because one or more lines are too long

View file

@ -1,8 +1,11 @@
/* global inlineEditL10n, ajaxurl */
/**
* This file is used on the term overview page to power quick-editing terms.
*
* @output wp-admin/js/inline-edit-tax.js
*/
/* global inlineEditL10n, ajaxurl, inlineEditTax */
window.wp = window.wp || {};
/**
@ -14,16 +17,13 @@ window.wp = window.wp || {};
* @property {string} what The type property with a hash prefixed and a dash
* suffixed.
*/
var inlineEditTax;
( function( $, wp ) {
inlineEditTax = {
window.inlineEditTax = {
/**
* @summary Initializes the inline taxonomy editor.
*
* Adds event handlers to be able to quick edit.
* Initializes the inline taxonomy editor by adding event handlers to be able to
* quick edit.
*
* @since 2.7.0
*
@ -37,13 +37,13 @@ inlineEditTax = {
t.type = $('#the-list').attr('data-wp-lists').substr(5);
t.what = '#'+t.type+'-';
$('#the-list').on('click', 'a.editinline', function(){
inlineEditTax.edit(this);
return false;
$( '#the-list' ).on( 'click', '.editinline', function() {
$( this ).attr( 'aria-expanded', 'true' );
inlineEditTax.edit( this );
});
/*
* @summary Cancels inline editing when pressing escape inside the inline editor.
/**
* Cancels inline editing when pressing escape inside the inline editor.
*
* @param {Object} e The keyup event that has been triggered.
*/
@ -55,21 +55,21 @@ inlineEditTax = {
});
/**
* @summary Cancels inline editing when clicking the cancel button.
* Cancels inline editing when clicking the cancel button.
*/
$( '.cancel', row ).click( function() {
return inlineEditTax.revert();
});
/**
* @summary Saves the inline edits when clicking the save button.
* Saves the inline edits when clicking the save button.
*/
$( '.save', row ).click( function() {
return inlineEditTax.save(this);
});
/**
* @summary Saves the inline edits when pressing enter inside the inline editor.
* Saves the inline edits when pressing enter inside the inline editor.
*/
$( 'input, select', row ).keydown( function( e ) {
// 13 = [enter]
@ -79,7 +79,7 @@ inlineEditTax = {
});
/**
* @summary Saves the inline edits on submitting the inline edit form.
* Saves the inline edits on submitting the inline edit form.
*/
$( '#posts-filter input[type="submit"]' ).mousedown( function() {
t.revert();
@ -149,7 +149,7 @@ inlineEditTax = {
},
/**
* @summary Saves the quick edit data.
* Saves the quick edit data.
*
* Saves the quick edit data to the server and replaces the table row with the
* HTML retrieved from the server.
@ -187,7 +187,7 @@ inlineEditTax = {
// Do the ajax request to save the data to the server.
$.post( ajaxurl, params,
/**
* @summary Handles the response from the server.
* Handles the response from the server
*
* Handles the response from the server, replaces the table row with the response
* from the server.
@ -220,8 +220,10 @@ inlineEditTax = {
$( '#parent' ).find( 'option[value=' + option_value + ']' ).text( row.find( '.row-title' ).text() );
row.hide().fadeIn( 400, function() {
// Move focus back to the Quick Edit link.
row.find( '.editinline' ).focus();
// Move focus back to the Quick Edit button.
row.find( '.editinline' )
.attr( 'aria-expanded', 'false' )
.focus();
wp.a11y.speak( inlineEditL10n.saved );
});
@ -263,8 +265,10 @@ inlineEditTax = {
$('#'+id).siblings('tr.hidden').addBack().remove();
id = id.substr( id.lastIndexOf('-') + 1 );
// Show the taxonomy row and move focus back to the Quick Edit link.
$( this.what + id ).show().find( '.editinline' ).focus();
// Show the taxonomy row and move focus back to the Quick Edit button.
$( this.what + id ).show().find( '.editinline' )
.attr( 'aria-expanded', 'false' )
.focus();
}
},

View file

@ -1 +1 @@
window.wp=window.wp||{};var inlineEditTax;!function(a,b){inlineEditTax={init:function(){var b=this,c=a("#inline-edit");b.type=a("#the-list").attr("data-wp-lists").substr(5),b.what="#"+b.type+"-",a("#the-list").on("click","a.editinline",function(){return inlineEditTax.edit(this),!1}),c.keyup(function(a){if(27===a.which)return inlineEditTax.revert()}),a(".cancel",c).click(function(){return inlineEditTax.revert()}),a(".save",c).click(function(){return inlineEditTax.save(this)}),a("input, select",c).keydown(function(a){if(13===a.which)return inlineEditTax.save(this)}),a('#posts-filter input[type="submit"]').mousedown(function(){b.revert()})},toggle:function(b){var c=this;"none"===a(c.what+c.getId(b)).css("display")?c.revert():c.edit(b)},edit:function(b){var c,d,e,f=this;return f.revert(),"object"==typeof b&&(b=f.getId(b)),c=a("#inline-edit").clone(!0),d=a("#inline_"+b),a("td",c).attr("colspan",a("th:visible, td:visible",".wp-list-table.widefat:first thead").length),a(f.what+b).hide().after(c).after('<tr class="hidden"></tr>'),e=a(".name",d),e.find("img").replaceWith(function(){return this.alt}),e=e.text(),a(':input[name="name"]',c).val(e),e=a(".slug",d),e.find("img").replaceWith(function(){return this.alt}),e=e.text(),a(':input[name="slug"]',c).val(e),a(c).attr("id","edit-"+b).addClass("inline-editor").show(),a(".ptitle",c).eq(0).focus(),!1},save:function(c){var d,e,f=a('input[name="taxonomy"]').val()||"";return"object"==typeof c&&(c=this.getId(c)),a("table.widefat .spinner").addClass("is-active"),d={action:"inline-save-tax",tax_type:this.type,tax_ID:c,taxonomy:f},e=a("#edit-"+c).find(":input").serialize(),d=e+"&"+a.param(d),a.post(ajaxurl,d,function(d){var e,f,g,h=a("#edit-"+c+" .inline-edit-save .notice-error"),i=h.find(".error");a("table.widefat .spinner").removeClass("is-active"),d?-1!==d.indexOf("<tr")?(a(inlineEditTax.what+c).siblings("tr.hidden").addBack().remove(),f=a(d).attr("id"),a("#edit-"+c).before(d).remove(),f?(g=f.replace(inlineEditTax.type+"-",""),e=a("#"+f)):(g=c,e=a(inlineEditTax.what+c)),a("#parent").find("option[value="+g+"]").text(e.find(".row-title").text()),e.hide().fadeIn(400,function(){e.find(".editinline").focus(),b.a11y.speak(inlineEditL10n.saved)})):(h.removeClass("hidden"),i.html(d),b.a11y.speak(i.text())):(h.removeClass("hidden"),i.html(inlineEditL10n.error),b.a11y.speak(inlineEditL10n.error))}),!1},revert:function(){var b=a("table.widefat tr.inline-editor").attr("id");b&&(a("table.widefat .spinner").removeClass("is-active"),a("#"+b).siblings("tr.hidden").addBack().remove(),b=b.substr(b.lastIndexOf("-")+1),a(this.what+b).show().find(".editinline").focus())},getId:function(b){var c="TR"===b.tagName?b.id:a(b).parents("tr").attr("id"),d=c.split("-");return d[d.length-1]}},a(document).ready(function(){inlineEditTax.init()})}(jQuery,window.wp);
window.wp=window.wp||{},function(a,b){window.inlineEditTax={init:function(){var b=this,c=a("#inline-edit");b.type=a("#the-list").attr("data-wp-lists").substr(5),b.what="#"+b.type+"-",a("#the-list").on("click",".editinline",function(){a(this).attr("aria-expanded","true"),inlineEditTax.edit(this)}),c.keyup(function(a){if(27===a.which)return inlineEditTax.revert()}),a(".cancel",c).click(function(){return inlineEditTax.revert()}),a(".save",c).click(function(){return inlineEditTax.save(this)}),a("input, select",c).keydown(function(a){if(13===a.which)return inlineEditTax.save(this)}),a('#posts-filter input[type="submit"]').mousedown(function(){b.revert()})},toggle:function(b){var c=this;"none"===a(c.what+c.getId(b)).css("display")?c.revert():c.edit(b)},edit:function(b){var c,d,e,f=this;return f.revert(),"object"==typeof b&&(b=f.getId(b)),c=a("#inline-edit").clone(!0),d=a("#inline_"+b),a("td",c).attr("colspan",a("th:visible, td:visible",".wp-list-table.widefat:first thead").length),a(f.what+b).hide().after(c).after('<tr class="hidden"></tr>'),e=a(".name",d),e.find("img").replaceWith(function(){return this.alt}),e=e.text(),a(':input[name="name"]',c).val(e),e=a(".slug",d),e.find("img").replaceWith(function(){return this.alt}),e=e.text(),a(':input[name="slug"]',c).val(e),a(c).attr("id","edit-"+b).addClass("inline-editor").show(),a(".ptitle",c).eq(0).focus(),!1},save:function(c){var d,e,f=a('input[name="taxonomy"]').val()||"";return"object"==typeof c&&(c=this.getId(c)),a("table.widefat .spinner").addClass("is-active"),d={action:"inline-save-tax",tax_type:this.type,tax_ID:c,taxonomy:f},e=a("#edit-"+c).find(":input").serialize(),d=e+"&"+a.param(d),a.post(ajaxurl,d,function(d){var e,f,g,h=a("#edit-"+c+" .inline-edit-save .notice-error"),i=h.find(".error");a("table.widefat .spinner").removeClass("is-active"),d?-1!==d.indexOf("<tr")?(a(inlineEditTax.what+c).siblings("tr.hidden").addBack().remove(),f=a(d).attr("id"),a("#edit-"+c).before(d).remove(),f?(g=f.replace(inlineEditTax.type+"-",""),e=a("#"+f)):(g=c,e=a(inlineEditTax.what+c)),a("#parent").find("option[value="+g+"]").text(e.find(".row-title").text()),e.hide().fadeIn(400,function(){e.find(".editinline").attr("aria-expanded","false").focus(),b.a11y.speak(inlineEditL10n.saved)})):(h.removeClass("hidden"),i.html(d),b.a11y.speak(i.text())):(h.removeClass("hidden"),i.html(inlineEditL10n.error),b.a11y.speak(inlineEditL10n.error))}),!1},revert:function(){var b=a("table.widefat tr.inline-editor").attr("id");b&&(a("table.widefat .spinner").removeClass("is-active"),a("#"+b).siblings("tr.hidden").addBack().remove(),b=b.substr(b.lastIndexOf("-")+1),a(this.what+b).show().find(".editinline").attr("aria-expanded","false").focus())},getId:function(b){var c="TR"===b.tagName?b.id:a(b).parents("tr").attr("id"),d=c.split("-");return d[d.length-1]}},a(document).ready(function(){inlineEditTax.init()})}(jQuery,window.wp);

View file

@ -1,5 +1,12 @@
jQuery( function($) {
/**
* @output wp-admin/js/language-chooser.js
*/
jQuery( function($) {
/*
* Set the correct translation to the continue button and show a spinner
* when downloading a language.
*/
var select = $( '#language' ),
submit = $( '#language-continue' );
@ -8,6 +15,10 @@ if ( ! $( 'body' ).hasClass( 'language-chooser' ) ) {
}
select.focus().on( 'change', function() {
/*
* When a language is selected, set matching translation to continue button
* and attach the language attribute.
*/
var option = select.children( 'option:selected' );
submit.attr({
value: option.data( 'continue' ),
@ -16,8 +27,7 @@ select.focus().on( 'change', function() {
});
$( 'form' ).submit( function() {
// Don't show a spinner for English and installed languages,
// as there is nothing to download.
// Show spinner for languages that need to be downloaded.
if ( ! select.children( 'option:selected' ).data( 'installed' ) ) {
$( this ).find( '.step .spinner' ).css( 'visibility', 'visible' );
}

View file

@ -1,3 +1,7 @@
/**
* @output wp-admin/js/link.js
*/
/* global postboxes, deleteUserSetting, setUserSetting, getUserSetting */
jQuery(document).ready( function($) {
@ -8,7 +12,13 @@ jQuery(document).ready( function($) {
// postboxes
postboxes.add_postbox_toggles('link');
// category tabs
/**
* Adds event that opens a particular category tab.
*
* @ignore
*
* @return {boolean} Always returns false to prevent the default behavior.
*/
$('#category-tabs a').click(function(){
var t = $(this).attr('href');
$(this).parent().addClass('tabs').siblings('li').removeClass('tabs');
@ -25,7 +35,24 @@ jQuery(document).ready( function($) {
// Ajax Cat
newCat = $('#newcat').one( 'focus', function() { $(this).val( '' ).removeClass( 'form-input-tip' ); } );
/**
* After adding a new category, focus on the category add input field.
*
* @return {void}
*/
$('#link-category-add-submit').click( function() { newCat.focus(); } );
/**
* Synchronize category checkboxes.
*
* This function makes sure that the checkboxes are synced between the all
* categories tab and the most used categories tab.
*
* @since 2.5.0
*
* @return {void}
*/
syncChecks = function() {
if ( noSyncChecks )
return;
@ -35,6 +62,21 @@ jQuery(document).ready( function($) {
noSyncChecks = false;
};
/**
* Adds event listeners to an added category.
*
* This is run on the addAfter event to make sure the correct event listeners
* are bound to the DOM elements.
*
* @since 2.5.0
*
* @param {string} r Raw XML response returned from the server after adding a
* category.
* @param {Object} s List manager configuration object; settings for the Ajax
* request.
*
* @return {void}
*/
catAddAfter = function( r, s ) {
$(s.what + ' response_data', r).each( function() {
var t = $($(this).text());
@ -46,18 +88,43 @@ jQuery(document).ready( function($) {
} );
};
/*
* Instantiates the list manager.
*
* @see js/_enqueues/lib/lists.js
*/
$('#categorychecklist').wpList( {
// CSS class name for alternate styling.
alt: '',
// The type of list.
what: 'link-category',
// ID of the element the parsed Ajax response will be stored in.
response: 'category-ajax-response',
// Callback that's run after an item got added to the list.
addAfter: catAddAfter
} );
// All categories is the default tab, so we delete the user setting.
$('a[href="#categories-all"]').click(function(){deleteUserSetting('cats');});
// Set a preference for the popular categories to cookies.
$('a[href="#categories-pop"]').click(function(){setUserSetting('cats','pop');});
if ( 'pop' == getUserSetting('cats') )
$('a[href="#categories-pop"]').click();
/**
* Adds event handler that shows the interface controls to add a new category.
*
* @ignore
*
* @param {Event} event The event object.
* @returns {boolean} Always returns false to prevent regular link
* functionality.
*/
$('#category-add-toggle').click( function() {
$(this).parents('div:first').toggleClass( 'wp-hidden-children' );
$('#category-tabs a[href="#categories-all"]').click();

View file

@ -1,9 +1,11 @@
/* global ajaxurl */
/**
* This file is used on media-upload.php which has been replaced by media-new.php and upload.php
* Deprecated since 3.5.0
*
* @deprecated 3.5.0
* @output wp-admin/js/media-gallery.js
*/
/* global ajaxurl */
jQuery(function($) {
/**
* Adds a click event handler to the element with a 'wp-gallery' class.

View file

@ -1,17 +1,41 @@
/* global tinymce, QTags */
// send html to the post editor
/**
* Contains global functions for the media upload within the post edit screen.
*
* Updates the ThickBox anchor href and the ThickBox's own properties in order
* to set the size and position on every resize event. Also adds a function to
* send HTML or text to the currently active editor.
*
* @file
* @since 2.5.0
* @output wp-admin/js/media-upload.js
*
* @requires jQuery
*/
var wpActiveEditor, send_to_editor;
/* global tinymce, QTags, wpActiveEditor, tb_position */
send_to_editor = function( html ) {
/**
* Sends the HTML passed in the parameters to TinyMCE.
*
* @since 2.5.0
*
* @global
*
* @param {string} html The HTML to be sent to the editor.
* @returns {void|boolean} Returns false when both TinyMCE and QTags instances
* are unavailable. This means that the HTML was not
* sent to the editor.
*/
window.send_to_editor = function( html ) {
var editor,
hasTinymce = typeof tinymce !== 'undefined',
hasQuicktags = typeof QTags !== 'undefined';
// If no active editor is set, try to set it.
if ( ! wpActiveEditor ) {
if ( hasTinymce && tinymce.activeEditor ) {
editor = tinymce.activeEditor;
wpActiveEditor = editor.id;
window.wpActiveEditor = editor.id;
} else if ( ! hasQuicktags ) {
return false;
}
@ -19,24 +43,38 @@ send_to_editor = function( html ) {
editor = tinymce.get( wpActiveEditor );
}
// If the editor is set and not hidden, insert the HTML into the content of the
// editor.
if ( editor && ! editor.isHidden() ) {
editor.execCommand( 'mceInsertContent', false, html );
} else if ( hasQuicktags ) {
// If quick tags are available, insert the HTML into its content.
QTags.insertContent( html );
} else {
// If neither the TinyMCE editor and the quick tags are available, add the HTML
// to the current active editor.
document.getElementById( wpActiveEditor ).value += html;
}
// If the old thickbox remove function exists, call it
// If the old thickbox remove function exists, call it.
if ( window.tb_remove ) {
try { window.tb_remove(); } catch( e ) {}
}
};
// thickbox settings
var tb_position;
(function($) {
tb_position = function() {
/**
* Recalculates and applies the new ThickBox position based on the current
* window size.
*
* @since 2.6.0
*
* @global
*
* @returns {Object[]} Array containing jQuery objects for all the found
* ThickBox anchors.
*/
window.tb_position = function() {
var tbWindow = $('#TB_window'),
width = $(window).width(),
H = $(window).height(),
@ -55,6 +93,11 @@ var tb_position;
tbWindow.css({'top': 20 + adminbar_height + 'px', 'margin-top': '0'});
}
/**
* Recalculates the new height and width for all links with a ThickBox class.
*
* @since 2.6.0
*/
return $('a.thickbox').each( function() {
var href = $(this).attr('href');
if ( ! href ) return;
@ -64,6 +107,7 @@ var tb_position;
});
};
// Add handler to recalculates the ThickBox position when the window is resized.
$(window).resize(function(){ tb_position(); });
})(jQuery);

View file

@ -1 +1 @@
var wpActiveEditor,send_to_editor;send_to_editor=function(a){var b,c="undefined"!=typeof tinymce,d="undefined"!=typeof QTags;if(wpActiveEditor)c&&(b=tinymce.get(wpActiveEditor));else if(c&&tinymce.activeEditor)b=tinymce.activeEditor,wpActiveEditor=b.id;else if(!d)return!1;if(b&&!b.isHidden()?b.execCommand("mceInsertContent",!1,a):d?QTags.insertContent(a):document.getElementById(wpActiveEditor).value+=a,window.tb_remove)try{window.tb_remove()}catch(e){}};var tb_position;!function(a){tb_position=function(){var b=a("#TB_window"),c=a(window).width(),d=a(window).height(),e=833<c?833:c,f=0;return a("#wpadminbar").length&&(f=parseInt(a("#wpadminbar").css("height"),10)),b.length&&(b.width(e-50).height(d-45-f),a("#TB_iframeContent").width(e-50).height(d-75-f),b.css({"margin-left":"-"+parseInt((e-50)/2,10)+"px"}),"undefined"!=typeof document.body.style.maxWidth&&b.css({top:20+f+"px","margin-top":"0"})),a("a.thickbox").each(function(){var b=a(this).attr("href");b&&(b=b.replace(/&width=[0-9]+/g,""),b=b.replace(/&height=[0-9]+/g,""),a(this).attr("href",b+"&width="+(e-80)+"&height="+(d-85-f)))})},a(window).resize(function(){tb_position()})}(jQuery);
window.send_to_editor=function(a){var b,c="undefined"!=typeof tinymce,d="undefined"!=typeof QTags;if(wpActiveEditor)c&&(b=tinymce.get(wpActiveEditor));else if(c&&tinymce.activeEditor)b=tinymce.activeEditor,window.wpActiveEditor=b.id;else if(!d)return!1;if(b&&!b.isHidden()?b.execCommand("mceInsertContent",!1,a):d?QTags.insertContent(a):document.getElementById(wpActiveEditor).value+=a,window.tb_remove)try{window.tb_remove()}catch(e){}},function(a){window.tb_position=function(){var b=a("#TB_window"),c=a(window).width(),d=a(window).height(),e=833<c?833:c,f=0;return a("#wpadminbar").length&&(f=parseInt(a("#wpadminbar").css("height"),10)),b.length&&(b.width(e-50).height(d-45-f),a("#TB_iframeContent").width(e-50).height(d-75-f),b.css({"margin-left":"-"+parseInt((e-50)/2,10)+"px"}),"undefined"!=typeof document.body.style.maxWidth&&b.css({top:20+f+"px","margin-top":"0"})),a("a.thickbox").each(function(){var b=a(this).attr("href");b&&(b=b.replace(/&width=[0-9]+/g,""),b=b.replace(/&height=[0-9]+/g,""),a(this).attr("href",b+"&width="+(e-80)+"&height="+(d-85-f)))})},a(window).resize(function(){tb_position()})}(jQuery);

View file

@ -1,21 +1,21 @@
/* global ajaxurl, attachMediaBoxL10n, _wpMediaGridSettings, showNotice */
/**
* @summary Creates a dialog containing posts that can have a particular media attached to it.
* Creates a dialog containing posts that can have a particular media attached
* to it.
*
* @since 2.7.0
* @output wp-admin/js/media.js
*
* @global
* @namespace
* @namespace findPosts
*
* @requires jQuery
*/
var findPosts;
/* global ajaxurl, attachMediaBoxL10n, _wpMediaGridSettings, showNotice, findPosts */
( function( $ ){
findPosts = {
window.findPosts = {
/**
* @summary Opens a dialog to attach media to a post.
* Opens a dialog to attach media to a post.
*
* Adds an overlay prior to retrieving a list of posts to attach the media to.
*
@ -59,7 +59,7 @@ var findPosts;
},
/**
* @summary Clears the found posts lists before hiding the attach media dialog.
* Clears the found posts lists before hiding the attach media dialog.
*
* @since 2.7.0
*
@ -74,7 +74,8 @@ var findPosts;
},
/**
* @summary Binds a click event listener to the overlay which closes the attach media dialog.
* Binds a click event listener to the overlay which closes the attach media
* dialog.
*
* @since 3.5.0
*
@ -89,10 +90,11 @@ var findPosts;
},
/**
* @summary Retrieves and displays posts based on the search term.
* Retrieves and displays posts based on the search term.
*
* Sends a post request to the admin_ajax.php, requesting posts based on the search term provided by the user.
* Defaults to all posts if no search term is provided.
* Sends a post request to the admin_ajax.php, requesting posts based on the
* search term provided by the user. Defaults to all posts if no search term is
* provided.
*
* @since 2.7.0
*
@ -111,8 +113,8 @@ var findPosts;
spinner.addClass( 'is-active' );
/**
* Send a POST request to admin_ajax.php, hide the spinner and replace the list of posts with the response data.
* If an error occurs, display it.
* Send a POST request to admin_ajax.php, hide the spinner and replace the list
* of posts with the response data. If an error occurs, display it.
*/
$.ajax( ajaxurl, {
type: 'POST',
@ -133,7 +135,8 @@ var findPosts;
};
/**
* @summary Initializes the file once the DOM is fully loaded and attaches events to the various form elements.
* Initializes the file once the DOM is fully loaded and attaches events to the
* various form elements.
*
* @returns {void}
*/
@ -193,7 +196,7 @@ var findPosts;
});
/**
* @summary Enables clicking on the entire table row.
* Enables clicking on the entire table row.
*
* @returns {void}
*/

View file

@ -1 +1 @@
var findPosts;!function(a){findPosts={open:function(b,c){var d=a(".ui-find-overlay");return 0===d.length&&(a("body").append('<div class="ui-find-overlay"></div>'),findPosts.overlay()),d.show(),b&&c&&a("#affected").attr("name",b).val(c),a("#find-posts").show(),a("#find-posts-input").focus().keyup(function(a){27==a.which&&findPosts.close()}),findPosts.send(),!1},close:function(){a("#find-posts-response").empty(),a("#find-posts").hide(),a(".ui-find-overlay").hide()},overlay:function(){a(".ui-find-overlay").on("click",function(){findPosts.close()})},send:function(){var b={ps:a("#find-posts-input").val(),action:"find_posts",_ajax_nonce:a("#_ajax_nonce").val()},c=a(".find-box-search .spinner");c.addClass("is-active"),a.ajax(ajaxurl,{type:"POST",data:b,dataType:"json"}).always(function(){c.removeClass("is-active")}).done(function(b){b.success||a("#find-posts-response").text(attachMediaBoxL10n.error),a("#find-posts-response").html(b.data)}).fail(function(){a("#find-posts-response").text(attachMediaBoxL10n.error)})}},a(document).ready(function(){var b,c=a("#wp-media-grid");c.length&&window.wp&&window.wp.media&&(b=_wpMediaGridSettings,window.wp.media({frame:"manage",container:c,library:b.queryVars}).open()),a("#find-posts-submit").click(function(b){a('#find-posts-response input[type="radio"]:checked').length||b.preventDefault()}),a("#find-posts .find-box-search :input").keypress(function(a){if(13==a.which)return findPosts.send(),!1}),a("#find-posts-search").click(findPosts.send),a("#find-posts-close").click(findPosts.close),a("#doaction, #doaction2").click(function(b){a('select[name^="action"]').each(function(){var c=a(this).val();"attach"===c?(b.preventDefault(),findPosts.open()):"delete"===c&&(showNotice.warn()||b.preventDefault())})}),a(".find-box-inside").on("click","tr",function(){a(this).find(".found-radio input").prop("checked",!0)})})}(jQuery);
!function(a){window.findPosts={open:function(b,c){var d=a(".ui-find-overlay");return 0===d.length&&(a("body").append('<div class="ui-find-overlay"></div>'),findPosts.overlay()),d.show(),b&&c&&a("#affected").attr("name",b).val(c),a("#find-posts").show(),a("#find-posts-input").focus().keyup(function(a){27==a.which&&findPosts.close()}),findPosts.send(),!1},close:function(){a("#find-posts-response").empty(),a("#find-posts").hide(),a(".ui-find-overlay").hide()},overlay:function(){a(".ui-find-overlay").on("click",function(){findPosts.close()})},send:function(){var b={ps:a("#find-posts-input").val(),action:"find_posts",_ajax_nonce:a("#_ajax_nonce").val()},c=a(".find-box-search .spinner");c.addClass("is-active"),a.ajax(ajaxurl,{type:"POST",data:b,dataType:"json"}).always(function(){c.removeClass("is-active")}).done(function(b){b.success||a("#find-posts-response").text(attachMediaBoxL10n.error),a("#find-posts-response").html(b.data)}).fail(function(){a("#find-posts-response").text(attachMediaBoxL10n.error)})}},a(document).ready(function(){var b,c=a("#wp-media-grid");c.length&&window.wp&&window.wp.media&&(b=_wpMediaGridSettings,window.wp.media({frame:"manage",container:c,library:b.queryVars}).open()),a("#find-posts-submit").click(function(b){a('#find-posts-response input[type="radio"]:checked').length||b.preventDefault()}),a("#find-posts .find-box-search :input").keypress(function(a){if(13==a.which)return findPosts.send(),!1}),a("#find-posts-search").click(findPosts.send),a("#find-posts-close").click(findPosts.close),a("#doaction, #doaction2").click(function(b){a('select[name^="action"]').each(function(){var c=a(this).val();"attach"===c?(b.preventDefault(),findPosts.open()):"delete"===c&&(showNotice.warn()||b.preventDefault())})}),a(".find-box-inside").on("click","tr",function(){a(this).find(".found-radio input").prop("checked",!0)})})}(jQuery);

View file

@ -6,17 +6,21 @@
*
* @package WordPress
* @subpackage Administration
* @output wp-admin/js/nav-menu.js
*/
/* global menus, postboxes, columns, isRtl, navMenuL10n, ajaxurl */
var wpNavMenu;
/* global menus, postboxes, columns, isRtl, navMenuL10n, ajaxurl, wpNavMenu */
(function($) {
var api;
api = wpNavMenu = {
/**
* Contains all the functions to handle WordPress navigation menus administration.
*
* @namespace wpNavMenu
*/
api = window.wpNavMenu = {
options : {
menuItemDepthPerLevel : 30, // Do not use directly. Use depthToPx and pxToDepth instead.
@ -167,6 +171,8 @@ var wpNavMenu;
/**
* Adds selected menu items to the menu.
*
* @ignore
*
* @param jQuery metabox The metabox jQuery object.
*/
addSelectedToMenu : function(processMethod) {
@ -829,6 +835,20 @@ var wpNavMenu;
}
}
});
$( '#menu-name' ).on( 'input', _.debounce( function () {
var menuName = $( document.getElementById( 'menu-name' ) ),
menuNameVal = menuName.val();
if ( ! menuNameVal || ! menuNameVal.replace( /\s+/, '' ) ) {
// Add warning for invalid menu name.
menuName.parent().addClass( 'form-invalid' );
} else {
// Remove warning for valid menu name.
menuName.parent().removeClass( 'form-invalid' );
}
}, 500 ) );
$('#add-custom-links input[type="text"]').keypress(function(e){
$('#customlinkdiv').removeClass('form-invalid');
@ -867,26 +887,14 @@ var wpNavMenu;
},
attachQuickSearchListeners : function() {
var searchTimer,
inputEvent;
var searchTimer;
// Prevent form submission.
$( '#nav-menu-meta' ).on( 'submit', function( event ) {
event.preventDefault();
});
/*
* Use feature detection to determine whether inputs should use
* the `keyup` or `input` event. Input is preferred but lacks support
* in legacy browsers. See changeset 34078, see also ticket #26600#comment:59
*/
if ( 'oninput' in document.createElement( 'input' ) ) {
inputEvent = 'input';
} else {
inputEvent = 'keyup';
}
$( '#nav-menu-meta' ).on( inputEvent, '.quick-search', function() {
$( '#nav-menu-meta' ).on( 'input', '.quick-search', function() {
var $this = $( this );
$this.attr( 'autocomplete', 'off' );
@ -1172,8 +1180,8 @@ var wpNavMenu;
menuName = $('#menu-name'),
menuNameVal = menuName.val();
// Cancel and warn if invalid menu name
if( !menuNameVal || menuNameVal == menuName.attr('title') || !menuNameVal.replace(/\s+/, '') ) {
menuName.parent().addClass('form-invalid');
if ( ! menuNameVal || ! menuNameVal.replace( /\s+/, '' ) ) {
menuName.parent().addClass( 'form-invalid' );
return false;
}
// Copy menu theme locations

File diff suppressed because one or more lines are too long

View file

@ -1,15 +1,33 @@
/**
* @output wp-admin/js/password-strength-meter.js
*/
/* global zxcvbn */
window.wp = window.wp || {};
var passwordStrength;
(function($){
/**
* Contains functions to determine the password strength.
*
* @since 3.7.0
*
* @namespace
*/
wp.passwordStrength = {
/**
* Determine the strength of a given password
* Determines the strength of a given password.
*
* @param string password1 The password
* @param array blacklist An array of words that will lower the entropy of the password
* @param string password2 The confirmed password
* Compares first password to the password confirmation.
*
* @since 3.7.0
*
* @param {string} password1 The subject password.
* @param {Array} blacklist An array of words that will lower the entropy of
* the password.
* @param {string} password2 The password confirmation.
*
* @returns {number} The password strength score.
*/
meter : function( password1, blacklist, password2 ) {
if ( ! $.isArray( blacklist ) )
@ -28,9 +46,15 @@ var passwordStrength;
},
/**
* Builds an array of data that should be penalized, because it would lower the entropy of a password if it were used
* Builds an array of words that should be penalized.
*
* @return array The array of data to be blacklisted
* Certain words need to be penalized because it would lower the entropy of a
* password if they were used. The blacklist is based on user input fields such
* as username, first name, email etc.
*
* @since 3.7.0
*
* @returns {string[]} The array of words to be blacklisted.
*/
userInputBlacklist : function() {
var i, userInputFieldsLength, rawValuesLength, currentField,
@ -38,7 +62,7 @@ var passwordStrength;
blacklist = [],
userInputFields = [ 'user_login', 'first_name', 'last_name', 'nickname', 'display_name', 'email', 'url', 'description', 'weblog_title', 'admin_email' ];
// Collect all the strings we want to blacklist
// Collect all the strings we want to blacklist.
rawValues.push( document.title );
rawValues.push( document.URL );
@ -54,7 +78,10 @@ var passwordStrength;
rawValues.push( currentField.val() );
}
// Strip out non-alphanumeric characters and convert each word to an individual entry
/*
* Strip out non-alphanumeric characters and convert each word to an
* individual entry.
*/
rawValuesLength = rawValues.length;
for ( i = 0; i < rawValuesLength; i++ ) {
if ( rawValues[ i ] ) {
@ -62,7 +89,10 @@ var passwordStrength;
}
}
// Remove empty values, short words, and duplicates. Short words are likely to cause many false positives.
/*
* Remove empty values, short words and duplicates. Short words are likely to
* cause many false positives.
*/
blacklist = $.grep( blacklist, function( value, key ) {
if ( '' === value || 4 > value.length ) {
return false;
@ -75,6 +105,17 @@ var passwordStrength;
}
};
// Back-compat.
passwordStrength = wp.passwordStrength.meter;
// Backward compatibility.
/**
* Password strength meter function.
*
* @since 2.5.0
* @deprecated 3.7.0 Use wp.passwordStrength.meter instead.
*
* @global
*
* @type {wp.passwordStrength.meter}
*/
window.passwordStrength = wp.passwordStrength.meter;
})(jQuery);

View file

@ -1 +1 @@
window.wp=window.wp||{};var passwordStrength;!function(a){wp.passwordStrength={meter:function(b,c,d){if(a.isArray(c)||(c=[c.toString()]),b!=d&&d&&d.length>0)return 5;if("undefined"==typeof window.zxcvbn)return-1;var e=zxcvbn(b,c);return e.score},userInputBlacklist:function(){var b,c,d,e,f=[],g=[],h=["user_login","first_name","last_name","nickname","display_name","email","url","description","weblog_title","admin_email"];for(f.push(document.title),f.push(document.URL),c=h.length,b=0;b<c;b++)e=a("#"+h[b]),0!==e.length&&(f.push(e[0].defaultValue),f.push(e.val()));for(d=f.length,b=0;b<d;b++)f[b]&&(g=g.concat(f[b].replace(/\W/g," ").split(" ")));return g=a.grep(g,function(b,c){return!(""===b||4>b.length)&&a.inArray(b,g)===c})}},passwordStrength=wp.passwordStrength.meter}(jQuery);
window.wp=window.wp||{},function(a){wp.passwordStrength={meter:function(b,c,d){if(a.isArray(c)||(c=[c.toString()]),b!=d&&d&&d.length>0)return 5;if("undefined"==typeof window.zxcvbn)return-1;var e=zxcvbn(b,c);return e.score},userInputBlacklist:function(){var b,c,d,e,f=[],g=[],h=["user_login","first_name","last_name","nickname","display_name","email","url","description","weblog_title","admin_email"];for(f.push(document.title),f.push(document.URL),c=h.length,b=0;b<c;b++)e=a("#"+h[b]),0!==e.length&&(f.push(e[0].defaultValue),f.push(e.val()));for(d=f.length,b=0;b<d;b++)f[b]&&(g=g.concat(f[b].replace(/\W/g," ").split(" ")));return g=a.grep(g,function(b,c){return!(""===b||4>b.length)&&a.inArray(b,g)===c})}},window.passwordStrength=wp.passwordStrength.meter}(jQuery);

View file

@ -1,9 +1,11 @@
/* global plugininstallL10n, tb_click, tb_remove */
/**
* Functionality for the plugin install screens.
* @file Functionality for the plugin install screens.
*
* @output wp-admin/js/plugin-install.js
*/
var tb_position;
/* global plugininstallL10n, tb_click, tb_remove, tb_position */
jQuery( document ).ready( function( $ ) {
var tbWindow,
@ -16,7 +18,7 @@ jQuery( document ).ready( function( $ ) {
$wrap = $ ( '.wrap' ),
$body = $( document.body );
tb_position = function() {
window.tb_position = function() {
var width = $( window ).width(),
H = $( window ).height() - ( ( 792 < width ) ? 60 : 20 ),
W = ( 792 < width ) ? 772 : width - 20;

View file

@ -1 +1 @@
var tb_position;jQuery(document).ready(function(a){function b(){var b=e.find("#TB_iframeContent");f=b.contents().find("body"),c(),h.focus(),a("#plugin-information-tabs a",f).on("click",function(){c()}),f.on("keydown",function(a){27===a.which&&tb_remove()})}function c(){var b;g=a(":tabbable",f),h=e.find("#TB_closeWindowButton"),i=g.last(),b=h.add(i),b.off("keydown.wp-plugin-details"),b.on("keydown.wp-plugin-details",function(a){d(a)})}function d(a){9===a.which&&(i[0]!==a.target||a.shiftKey?h[0]===a.target&&a.shiftKey&&(a.preventDefault(),i.focus()):(a.preventDefault(),h.focus()))}var e,f,g,h,i,j=a(),k=a(".upload-view-toggle"),l=a(".wrap"),m=a(document.body);tb_position=function(){var b=a(window).width(),c=a(window).height()-(792<b?60:20),d=792<b?772:b-20;return e=a("#TB_window"),e.length&&(e.width(d).height(c),a("#TB_iframeContent").width(d).height(c),e.css({"margin-left":"-"+parseInt(d/2,10)+"px"}),"undefined"!=typeof document.body.style.maxWidth&&e.css({top:"30px","margin-top":"0"})),a("a.thickbox").each(function(){var b=a(this).attr("href");b&&(b=b.replace(/&width=[0-9]+/g,""),b=b.replace(/&height=[0-9]+/g,""),a(this).attr("href",b+"&width="+d+"&height="+c))})},a(window).resize(function(){tb_position()}),m.on("thickbox:iframe:loaded",e,function(){e.hasClass("plugin-details-modal")&&b()}).on("thickbox:removed",function(){j.focus()}),a(".wrap").on("click",".thickbox.open-plugin-details-modal",function(b){var c=a(this).data("title")?plugininstallL10n.plugin_information+" "+a(this).data("title"):plugininstallL10n.plugin_modal_label;b.preventDefault(),b.stopPropagation(),j=a(this),tb_click.call(this),e.attr({role:"dialog","aria-label":plugininstallL10n.plugin_modal_label}).addClass("plugin-details-modal"),e.find("#TB_iframeContent").attr("title",c)}),a("#plugin-information-tabs a").click(function(b){var c=a(this).attr("name");b.preventDefault(),a("#plugin-information-tabs a.current").removeClass("current"),a(this).addClass("current"),"description"!==c&&a(window).width()<772?a("#plugin-information-content").find(".fyi").hide():a("#plugin-information-content").find(".fyi").show(),a("#section-holder div.section").hide(),a("#section-"+c).show()}),l.hasClass("plugin-install-tab-upload")||k.attr({role:"button","aria-expanded":"false"}).on("click",function(a){a.preventDefault(),m.toggleClass("show-upload-view"),k.attr("aria-expanded",m.hasClass("show-upload-view"))})});
jQuery(document).ready(function(a){function b(){var b=e.find("#TB_iframeContent");f=b.contents().find("body"),c(),h.focus(),a("#plugin-information-tabs a",f).on("click",function(){c()}),f.on("keydown",function(a){27===a.which&&tb_remove()})}function c(){var b;g=a(":tabbable",f),h=e.find("#TB_closeWindowButton"),i=g.last(),b=h.add(i),b.off("keydown.wp-plugin-details"),b.on("keydown.wp-plugin-details",function(a){d(a)})}function d(a){9===a.which&&(i[0]!==a.target||a.shiftKey?h[0]===a.target&&a.shiftKey&&(a.preventDefault(),i.focus()):(a.preventDefault(),h.focus()))}var e,f,g,h,i,j=a(),k=a(".upload-view-toggle"),l=a(".wrap"),m=a(document.body);window.tb_position=function(){var b=a(window).width(),c=a(window).height()-(792<b?60:20),d=792<b?772:b-20;return e=a("#TB_window"),e.length&&(e.width(d).height(c),a("#TB_iframeContent").width(d).height(c),e.css({"margin-left":"-"+parseInt(d/2,10)+"px"}),"undefined"!=typeof document.body.style.maxWidth&&e.css({top:"30px","margin-top":"0"})),a("a.thickbox").each(function(){var b=a(this).attr("href");b&&(b=b.replace(/&width=[0-9]+/g,""),b=b.replace(/&height=[0-9]+/g,""),a(this).attr("href",b+"&width="+d+"&height="+c))})},a(window).resize(function(){tb_position()}),m.on("thickbox:iframe:loaded",e,function(){e.hasClass("plugin-details-modal")&&b()}).on("thickbox:removed",function(){j.focus()}),a(".wrap").on("click",".thickbox.open-plugin-details-modal",function(b){var c=a(this).data("title")?plugininstallL10n.plugin_information+" "+a(this).data("title"):plugininstallL10n.plugin_modal_label;b.preventDefault(),b.stopPropagation(),j=a(this),tb_click.call(this),e.attr({role:"dialog","aria-label":plugininstallL10n.plugin_modal_label}).addClass("plugin-details-modal"),e.find("#TB_iframeContent").attr("title",c)}),a("#plugin-information-tabs a").click(function(b){var c=a(this).attr("name");b.preventDefault(),a("#plugin-information-tabs a.current").removeClass("current"),a(this).addClass("current"),"description"!==c&&a(window).width()<772?a("#plugin-information-content").find(".fyi").hide():a("#plugin-information-content").find(".fyi").show(),a("#section-holder div.section").hide(),a("#section-"+c).show()}),l.hasClass("plugin-install-tab-upload")||k.attr({role:"button","aria-expanded":"false"}).on("click",function(a){a.preventDefault(),m.toggleClass("show-upload-view"),k.attr("aria-expanded",m.hasClass("show-upload-view"))})});

View file

@ -1,15 +1,15 @@
/* global postL10n, ajaxurl, wpAjax, setPostThumbnailL10n, postboxes, pagenow, tinymce, alert, deleteUserSetting */
/* global theList:true, theExtraList:true, getUserSetting, setUserSetting, commentReply */
/**
* Contains all dynamic functionality needed on post and term pages.
* @file Contains all dynamic functionality needed on post and term pages.
*
* @summary Control page and term functionality.
* @output wp-admin/js/post.js
*/
var commentsBox, WPSetThumbnailHTML, WPSetThumbnailID, WPRemoveThumbnail, wptitlehint, makeSlugeditClickable, editPermalink;
/* global postL10n, ajaxurl, wpAjax, setPostThumbnailL10n, postboxes, pagenow, tinymce, alert, deleteUserSetting */
/* global theList:true, theExtraList:true, getUserSetting, setUserSetting, commentReply, commentsBox */
/* global WPSetThumbnailHTML, wptitlehint */
// Backwards compatibility: prevent fatal errors.
makeSlugeditClickable = editPermalink = function(){};
window.makeSlugeditClickable = window.editPermalink = function(){};
// Make sure the wp object exists.
window.wp = window.wp || {};
@ -24,18 +24,18 @@ window.wp = window.wp || {};
*
* @namespace commentsBox
*/
commentsBox = {
window.commentsBox = {
// Comment offset to use when fetching new comments.
st : 0,
/**
* Fetch comments using AJAX and display them in the box.
*
* @memberof commentsBox
*
* @param {int} total Total number of comments for this post.
* @param {int} num Optional. Number of comments to fetch, defaults to 20.
* @returns {boolean} Always returns false.
*
* @memberof commentsBox
*/
get : function(total, num) {
var st = this.st, data;
@ -108,7 +108,7 @@ window.wp = window.wp || {};
*
* @global
*/
WPSetThumbnailHTML = function(html){
window.WPSetThumbnailHTML = function(html){
$('.inside', '#postimagediv').html(html);
};
@ -119,7 +119,7 @@ window.wp = window.wp || {};
*
* @global
*/
WPSetThumbnailID = function(id){
window.WPSetThumbnailID = function(id){
var field = $('input[value="_thumbnail_id"]', '#list-table');
if ( field.length > 0 ) {
$('#meta\\[' + field.attr('id').match(/[0-9]+/) + '\\]\\[value\\]').text(id);
@ -133,7 +133,7 @@ window.wp = window.wp || {};
*
* @global
*/
WPRemoveThumbnail = function(nonce){
window.WPRemoveThumbnail = function(nonce){
$.post(ajaxurl, {
action: 'set-post-thumbnail', post_id: $( '#post_ID' ).val(), thumbnail_id: -1, _ajax_nonce: nonce, cookie: encodeURIComponent( document.cookie )
},
@ -662,6 +662,8 @@ jQuery(document).ready( function($) {
/**
* Add current post_ID to request to fetch custom fields
*
* @ignore
*
* @param {Object} s Request object.
*
* @returns {Object} Data modified with post_ID attached.
@ -672,6 +674,8 @@ jQuery(document).ready( function($) {
},
/**
* Show the listing of custom fields after fetching.
*
* @ignore
*/
addAfter: function() {
$('table#list-table').show();
@ -689,6 +693,8 @@ jQuery(document).ready( function($) {
/**
* When the visibility of a post changes sub-options should be shown or hidden.
*
* @ignore
*
* @returns void
*/
updateVisibility = function() {
@ -711,6 +717,8 @@ jQuery(document).ready( function($) {
/**
* Make sure all labels represent the current settings.
*
* @ignore
*
* @returns {boolean} False when an invalid timestamp has been selected, otherwise True.
*/
updateText = function() {
@ -926,9 +934,8 @@ jQuery(document).ready( function($) {
}
/**
* Handle the editing of the post_name. Create the required HTML elements and update the changes via AJAX.
*
* @summary Permalink aka slug aka post_name editing
* Handle the editing of the post_name. Create the required HTML elements and
* update the changes via AJAX.
*
* @global
*
@ -1033,9 +1040,7 @@ jQuery(document).ready( function($) {
});
/**
* Add screen reader text to the title prompt when needed.
*
* @summary Title screen reader text handler.
* Adds screen reader text to the title prompt when needed.
*
* @param {string} id Optional. HTML ID to add the screen reader helper text to.
*
@ -1043,7 +1048,7 @@ jQuery(document).ready( function($) {
*
* @returns void
*/
wptitlehint = function(id) {
window.wptitlehint = function(id) {
id = id || 'title';
var title = $('#' + id), titleprompt = $('#' + id + '-prompt-text');

File diff suppressed because one or more lines are too long

View file

@ -2,33 +2,30 @@
* Contains the postboxes logic, opening and closing postboxes, reordering and saving
* the state and ordering to the database.
*
* @summary Contains postboxes logic
*
* @since 2.5.0
* @requires jQuery
* @output wp-admin/js/postbox.js
*/
/* global ajaxurl, postBoxL10n */
/**
* This object contains all function to handle the behaviour of the post boxes. The post boxes are the boxes you see
* around the content on the edit page.
*
* @since 2.7.0
*
* @namespace postboxes
*
* @type {Object}
*/
var postboxes;
/* global ajaxurl, postBoxL10n, postboxes */
(function($) {
var $document = $( document );
postboxes = {
/**
* This object contains all function to handle the behaviour of the post boxes. The post boxes are the boxes you see
* around the content on the edit page.
*
* @since 2.7.0
*
* @namespace postboxes
*
* @type {Object}
*/
window.postboxes = {
/**
* @summary Handles a click on either the postbox heading or the postbox open/close icon.
* Handles a click on either the postbox heading or the postbox open/close icon.
*
* Opens or closes the postbox. Expects `this` to equal the clicked element.
* Calls postboxes.pbshow if the postbox has been opened, calls postboxes.pbhide
@ -76,11 +73,13 @@ var postboxes;
}
/**
* @summary Fires when a postbox has been opened or closed.
* Fires when a postbox has been opened or closed.
*
* Contains a jQuery object with the relevant postbox element.
*
* @since 4.0.0
* @ignore
*
* @event postboxes#postbox-toggled
* @type {Object}
*/
@ -115,7 +114,7 @@ var postboxes;
});
/**
* @summary Hides a postbox.
* Hides a postbox.
*
* Event handler for the postbox dismiss button. After clicking the button
* the postbox will be hidden.
@ -131,12 +130,14 @@ var postboxes;
});
/**
* @summary Hides the postbox element
* Hides the postbox element
*
* Event handler for the screen options checkboxes. When a checkbox is
* clicked this function will hide or show the relevant postboxes.
*
* @since 2.7.0
* @ignore
*
* @fires postboxes#postbox-toggled
*
* @returns {void}
@ -169,7 +170,7 @@ var postboxes;
});
/**
* @summary Changes the amount of columns based on the layout preferences.
* Changes the amount of columns based on the layout preferences.
*
* @since 2.8.0
*
@ -186,7 +187,7 @@ var postboxes;
},
/**
* @summary Initializes all the postboxes, mainly their sortable behaviour.
* Initializes all the postboxes, mainly their sortable behaviour.
*
* @since 2.7.0
* @memberof postboxes
@ -265,10 +266,10 @@ var postboxes;
},
/**
* @summary Saves the state of the postboxes to the server.
* Saves the state of the postboxes to the server.
*
* Saves the state of the postboxes to the server. It sends two lists, one with
* all the closed postboxes, one with all the hidden postboxes.
* It sends two lists, one with all the closed postboxes, one with all the
* hidden postboxes.
*
* @since 2.7.0
* @memberof postboxes
@ -297,10 +298,9 @@ var postboxes;
},
/**
* @summary Saves the order of the postboxes to the server.
* Saves the order of the postboxes to the server.
*
* Saves the order of the postboxes to the server. Sends a list of all postboxes
* inside a sortable area to the server.
* Sends a list of all postboxes inside a sortable area to the server.
*
* @since 2.8.0
* @memberof postboxes
@ -326,7 +326,7 @@ var postboxes;
},
/**
* @summary Marks empty postbox areas.
* Marks empty postbox areas.
*
* Adds a message to empty sortable areas on the dashboard page. Also adds a
* border around the side area on the post edit screen if there are no postboxes
@ -362,7 +362,7 @@ var postboxes;
},
/**
* @summary Changes the amount of columns on the post edit page.
* Changes the amount of columns on the post edit page.
*
* @since 3.3.0
* @memberof postboxes
@ -383,14 +383,16 @@ var postboxes;
* Fires when the amount of columns on the post edit page has been changed.
*
* @since 4.0.0
* @ignore
*
* @event postboxes#postboxes-columnchange
*/
$( document ).trigger( 'postboxes-columnchange' );
},
/**
* @summary Changes the amount of columns the postboxes are in based on the
* current orientation of the browser.
* Changes the amount of columns the postboxes are in based on the current
* orientation of the browser.
*
* @since 3.3.0
* @memberof postboxes

View file

@ -1 +1 @@
var postboxes;!function(a){var b=a(document);postboxes={handle_click:function(){var c,d=a(this),e=d.parent(".postbox"),f=e.attr("id");"dashboard_browser_nag"!==f&&(e.toggleClass("closed"),c=!e.hasClass("closed"),d.hasClass("handlediv")?d.attr("aria-expanded",c):d.closest(".postbox").find("button.handlediv").attr("aria-expanded",c),"press-this"!==postboxes.page&&postboxes.save_state(postboxes.page),f&&(!e.hasClass("closed")&&a.isFunction(postboxes.pbshow)?postboxes.pbshow(f):e.hasClass("closed")&&a.isFunction(postboxes.pbhide)&&postboxes.pbhide(f)),b.trigger("postbox-toggled",e))},add_postbox_toggles:function(c,d){var e=a(".postbox .hndle, .postbox .handlediv");this.page=c,this.init(c,d),e.on("click.postboxes",this.handle_click),a(".postbox .hndle a").click(function(a){a.stopPropagation()}),a(".postbox a.dismiss").on("click.postboxes",function(b){var c=a(this).parents(".postbox").attr("id")+"-hide";b.preventDefault(),a("#"+c).prop("checked",!1).triggerHandler("click")}),a(".hide-postbox-tog").bind("click.postboxes",function(){var d=a(this),e=d.val(),f=a("#"+e);d.prop("checked")?(f.show(),a.isFunction(postboxes.pbshow)&&postboxes.pbshow(e)):(f.hide(),a.isFunction(postboxes.pbhide)&&postboxes.pbhide(e)),postboxes.save_state(c),postboxes._mark_area(),b.trigger("postbox-toggled",f)}),a('.columns-prefs input[type="radio"]').bind("click.postboxes",function(){var b=parseInt(a(this).val(),10);b&&(postboxes._pb_edit(b),postboxes.save_order(c))})},init:function(c,d){var e=a(document.body).hasClass("mobile"),f=a(".postbox .handlediv");a.extend(this,d||{}),a("#wpbody-content").css("overflow","hidden"),a(".meta-box-sortables").sortable({placeholder:"sortable-placeholder",connectWith:".meta-box-sortables",items:".postbox",handle:".hndle",cursor:"move",delay:e?200:0,distance:2,tolerance:"pointer",forcePlaceholderSize:!0,helper:function(a,b){return b.clone().find(":input").attr("name",function(a,b){return"sort_"+parseInt(1e5*Math.random(),10).toString()+"_"+b}).end()},opacity:.65,stop:function(){var b=a(this);return b.find("#dashboard_browser_nag").is(":visible")&&"dashboard_browser_nag"!=this.firstChild.id?void b.sortable("cancel"):void postboxes.save_order(c)},receive:function(c,d){"dashboard_browser_nag"==d.item[0].id&&a(d.sender).sortable("cancel"),postboxes._mark_area(),b.trigger("postbox-moved",d.item)}}),e&&(a(document.body).bind("orientationchange.postboxes",function(){postboxes._pb_change()}),this._pb_change()),this._mark_area(),f.each(function(){var b=a(this);b.attr("aria-expanded",!b.parent(".postbox").hasClass("closed"))})},save_state:function(b){var c,d;"nav-menus"!==b&&(c=a(".postbox").filter(".closed").map(function(){return this.id}).get().join(","),d=a(".postbox").filter(":hidden").map(function(){return this.id}).get().join(","),a.post(ajaxurl,{action:"closed-postboxes",closed:c,hidden:d,closedpostboxesnonce:jQuery("#closedpostboxesnonce").val(),page:b}))},save_order:function(b){var c,d=a(".columns-prefs input:checked").val()||0;c={action:"meta-box-order",_ajax_nonce:a("#meta-box-order-nonce").val(),page_columns:d,page:b},a(".meta-box-sortables").each(function(){c["order["+this.id.split("-")[0]+"]"]=a(this).sortable("toArray").join(",")}),a.post(ajaxurl,c)},_mark_area:function(){var b=a("div.postbox:visible").length,c=a("#post-body #side-sortables");a("#dashboard-widgets .meta-box-sortables:visible").each(function(){var c=a(this);1==b||c.children(".postbox:visible").length?c.removeClass("empty-container"):(c.addClass("empty-container"),c.attr("data-emptyString",postBoxL10n.postBoxEmptyString))}),c.length&&(c.children(".postbox:visible").length?c.removeClass("empty-container"):"280px"==a("#postbox-container-1").css("width")&&c.addClass("empty-container"))},_pb_edit:function(b){var c=a(".metabox-holder").get(0);c&&(c.className=c.className.replace(/columns-\d+/,"columns-"+b)),a(document).trigger("postboxes-columnchange")},_pb_change:function(){var b=a('label.columns-prefs-1 input[type="radio"]');switch(window.orientation){case 90:case-90:b.length&&b.is(":checked")||this._pb_edit(2);break;case 0:case 180:a("#poststuff").length?this._pb_edit(1):b.length&&b.is(":checked")||this._pb_edit(2)}},pbshow:!1,pbhide:!1}}(jQuery);
!function(a){var b=a(document);window.postboxes={handle_click:function(){var c,d=a(this),e=d.parent(".postbox"),f=e.attr("id");"dashboard_browser_nag"!==f&&(e.toggleClass("closed"),c=!e.hasClass("closed"),d.hasClass("handlediv")?d.attr("aria-expanded",c):d.closest(".postbox").find("button.handlediv").attr("aria-expanded",c),"press-this"!==postboxes.page&&postboxes.save_state(postboxes.page),f&&(!e.hasClass("closed")&&a.isFunction(postboxes.pbshow)?postboxes.pbshow(f):e.hasClass("closed")&&a.isFunction(postboxes.pbhide)&&postboxes.pbhide(f)),b.trigger("postbox-toggled",e))},add_postbox_toggles:function(c,d){var e=a(".postbox .hndle, .postbox .handlediv");this.page=c,this.init(c,d),e.on("click.postboxes",this.handle_click),a(".postbox .hndle a").click(function(a){a.stopPropagation()}),a(".postbox a.dismiss").on("click.postboxes",function(b){var c=a(this).parents(".postbox").attr("id")+"-hide";b.preventDefault(),a("#"+c).prop("checked",!1).triggerHandler("click")}),a(".hide-postbox-tog").bind("click.postboxes",function(){var d=a(this),e=d.val(),f=a("#"+e);d.prop("checked")?(f.show(),a.isFunction(postboxes.pbshow)&&postboxes.pbshow(e)):(f.hide(),a.isFunction(postboxes.pbhide)&&postboxes.pbhide(e)),postboxes.save_state(c),postboxes._mark_area(),b.trigger("postbox-toggled",f)}),a('.columns-prefs input[type="radio"]').bind("click.postboxes",function(){var b=parseInt(a(this).val(),10);b&&(postboxes._pb_edit(b),postboxes.save_order(c))})},init:function(c,d){var e=a(document.body).hasClass("mobile"),f=a(".postbox .handlediv");a.extend(this,d||{}),a("#wpbody-content").css("overflow","hidden"),a(".meta-box-sortables").sortable({placeholder:"sortable-placeholder",connectWith:".meta-box-sortables",items:".postbox",handle:".hndle",cursor:"move",delay:e?200:0,distance:2,tolerance:"pointer",forcePlaceholderSize:!0,helper:function(a,b){return b.clone().find(":input").attr("name",function(a,b){return"sort_"+parseInt(1e5*Math.random(),10).toString()+"_"+b}).end()},opacity:.65,stop:function(){var b=a(this);return b.find("#dashboard_browser_nag").is(":visible")&&"dashboard_browser_nag"!=this.firstChild.id?void b.sortable("cancel"):void postboxes.save_order(c)},receive:function(c,d){"dashboard_browser_nag"==d.item[0].id&&a(d.sender).sortable("cancel"),postboxes._mark_area(),b.trigger("postbox-moved",d.item)}}),e&&(a(document.body).bind("orientationchange.postboxes",function(){postboxes._pb_change()}),this._pb_change()),this._mark_area(),f.each(function(){var b=a(this);b.attr("aria-expanded",!b.parent(".postbox").hasClass("closed"))})},save_state:function(b){var c,d;"nav-menus"!==b&&(c=a(".postbox").filter(".closed").map(function(){return this.id}).get().join(","),d=a(".postbox").filter(":hidden").map(function(){return this.id}).get().join(","),a.post(ajaxurl,{action:"closed-postboxes",closed:c,hidden:d,closedpostboxesnonce:jQuery("#closedpostboxesnonce").val(),page:b}))},save_order:function(b){var c,d=a(".columns-prefs input:checked").val()||0;c={action:"meta-box-order",_ajax_nonce:a("#meta-box-order-nonce").val(),page_columns:d,page:b},a(".meta-box-sortables").each(function(){c["order["+this.id.split("-")[0]+"]"]=a(this).sortable("toArray").join(",")}),a.post(ajaxurl,c)},_mark_area:function(){var b=a("div.postbox:visible").length,c=a("#post-body #side-sortables");a("#dashboard-widgets .meta-box-sortables:visible").each(function(){var c=a(this);1==b||c.children(".postbox:visible").length?c.removeClass("empty-container"):(c.addClass("empty-container"),c.attr("data-emptyString",postBoxL10n.postBoxEmptyString))}),c.length&&(c.children(".postbox:visible").length?c.removeClass("empty-container"):"280px"==a("#postbox-container-1").css("width")&&c.addClass("empty-container"))},_pb_edit:function(b){var c=a(".metabox-holder").get(0);c&&(c.className=c.className.replace(/columns-\d+/,"columns-"+b)),a(document).trigger("postboxes-columnchange")},_pb_change:function(){var b=a('label.columns-prefs-1 input[type="radio"]');switch(window.orientation){case 90:case-90:b.length&&b.is(":checked")||this._pb_edit(2);break;case 0:case 180:a("#poststuff").length?this._pb_edit(1):b.length&&b.is(":checked")||this._pb_edit(2)}},pbshow:!1,pbhide:!1}}(jQuery);

View file

@ -1,10 +1,12 @@
/* global isRtl */
/**
* @file Revisions interface functions, Backbone classes and
* the revisions.php document.ready bootstrap.
*
* @output wp-admin/js/revisions.js
*/
/* global isRtl */
window.wp = window.wp || {};
(function($) {

View file

@ -1,7 +1,11 @@
/**
* @output wp-admin/js/set-post-thumbnail.js
*/
/* global setPostThumbnailL10n, ajaxurl, post_id, alert */
/* exported WPSetAsThumbnail */
function WPSetAsThumbnail( id, nonce ) {
window.WPSetAsThumbnail = function( id, nonce ) {
var $link = jQuery('a#wp-post-thumbnail-' + id);
$link.text( setPostThumbnailL10n.saving );
@ -21,4 +25,4 @@ function WPSetAsThumbnail( id, nonce ) {
}
}
);
}
};

View file

@ -1 +1 @@
function WPSetAsThumbnail(a,b){var c=jQuery("a#wp-post-thumbnail-"+a);c.text(setPostThumbnailL10n.saving),jQuery.post(ajaxurl,{action:"set-post-thumbnail",post_id:post_id,thumbnail_id:a,_ajax_nonce:b,cookie:encodeURIComponent(document.cookie)},function(b){var d=window.dialogArguments||opener||parent||top;c.text(setPostThumbnailL10n.setThumbnail),"0"==b?alert(setPostThumbnailL10n.error):(jQuery("a.wp-post-thumbnail").show(),c.text(setPostThumbnailL10n.done),c.fadeOut(2e3),d.WPSetThumbnailID(a),d.WPSetThumbnailHTML(b))})}
window.WPSetAsThumbnail=function(a,b){var c=jQuery("a#wp-post-thumbnail-"+a);c.text(setPostThumbnailL10n.saving),jQuery.post(ajaxurl,{action:"set-post-thumbnail",post_id:post_id,thumbnail_id:a,_ajax_nonce:b,cookie:encodeURIComponent(document.cookie)},function(b){var d=window.dialogArguments||opener||parent||top;c.text(setPostThumbnailL10n.setThumbnail),"0"==b?alert(setPostThumbnailL10n.error):(jQuery("a.wp-post-thumbnail").show(),c.text(setPostThumbnailL10n.done),c.fadeOut(2e3),d.WPSetThumbnailID(a),d.WPSetThumbnailHTML(b))})};

View file

@ -1,6 +1,7 @@
/**
* Attempt to re-color SVG icons used in the admin menu or the toolbar
*
* @output wp-admin/js/svg-painter.js
*/
window.wp = window.wp || {};

View file

@ -1,15 +1,31 @@
/* jshint curly: false, eqeqeq: false */
/* global ajaxurl */
/**
* @output wp-admin/js/tags-box.js
*/
var tagBox, array_unique_noempty;
/* jshint curly: false, eqeqeq: false */
/* global ajaxurl, tagBox, array_unique_noempty */
( function( $ ) {
var tagDelimiter = ( window.tagsSuggestL10n && window.tagsSuggestL10n.tagDelimiter ) || ',';
// Return an array with any duplicate, whitespace or empty values removed
array_unique_noempty = function( array ) {
/**
* Filters unique items and returns a new array.
*
* Filters all items from an array into a new array containing only the unique
* items. This also excludes whitespace or empty values.
*
* @since 2.8.0
*
* @global
*
* @param {Array} array The array to filter through.
*
* @return {Array} A new array containing only the unique items.
*/
window.array_unique_noempty = function( array ) {
var out = [];
// Trim the values and ensure they are unique.
$.each( array, function( key, val ) {
val = $.trim( val );
@ -21,7 +37,27 @@ var tagBox, array_unique_noempty;
return out;
};
tagBox = {
/**
* The TagBox object.
*
* Contains functions to create and manage tags that can be associated with a
* post.
*
* @since 2.9.0
*
* @global
*/
window.tagBox = {
/**
* Cleans up tags by removing redundant characters.
*
* @since 2.9.0
* @memberOf tagBox
*
* @param {string} tags Comma separated tags that need to be cleaned up.
*
* @return {string} The cleaned up tags.
*/
clean : function( tags ) {
if ( ',' !== tagDelimiter ) {
tags = tags.replace( new RegExp( tagDelimiter, 'g' ), ',' );
@ -36,6 +72,16 @@ var tagBox, array_unique_noempty;
return tags;
},
/**
* Parses tags and makes them editable.
*
* @since 2.9.0
* @memberOf tagBox
*
* @param {Object} el The tag element to retrieve the ID from.
*
* @return {boolean} Always returns false.
*/
parseTags : function(el) {
var id = el.id,
num = id.split('-check-num-')[1],
@ -46,6 +92,7 @@ var tagBox, array_unique_noempty;
delete current_tags[num];
// Sanitize the current tags and push them as if they're new tags.
$.each( current_tags, function( key, val ) {
val = $.trim( val );
if ( val ) {
@ -59,6 +106,16 @@ var tagBox, array_unique_noempty;
return false;
},
/**
* Creates clickable links, buttons and fields for adding or editing tags.
*
* @since 2.9.0
* @memberOf tagBox
*
* @param {Object} el The container HTML element.
*
* @return {void}
*/
quickClicks : function( el ) {
var thetags = $('.the-tags', el),
tagchecklist = $('.tagchecklist', el),
@ -73,6 +130,17 @@ var tagBox, array_unique_noempty;
current_tags = thetags.val().split( tagDelimiter );
tagchecklist.empty();
/**
* Creates a delete button if tag editing is enabled, before adding it to the tag list.
*
* @since 2.5.0
* @memberOf tagBox
*
* @param {string} key The index of the current tag.
* @param {string} val The value of the current tag.
*
* @return {void}
*/
$.each( current_tags, function( key, val ) {
var listItem, xbutton;
@ -95,6 +163,18 @@ var tagBox, array_unique_noempty;
'<span class="screen-reader-text">' + window.tagsSuggestL10n.removeTerm + ' ' + listItem.html() + '</span>' +
'</button>' );
/**
* Handles the click and keypress event of the tag remove button.
*
* Makes sure the focus ends up in the tag input field when using
* the keyboard to delete the tag.
*
* @since 4.2.0
*
* @param {Event} e The click or keypress event to handle.
*
* @return {void}
*/
xbutton.on( 'click keypress', function( e ) {
// On click or when using the Enter/Spacebar keys.
if ( 'click' === e.type || 13 === e.keyCode || 32 === e.keyCode ) {
@ -118,10 +198,27 @@ var tagBox, array_unique_noempty;
// Append the list item to the tag list.
tagchecklist.append( listItem );
});
// The buttons list is built now, give feedback to screen reader users.
tagBox.screenReadersMessage();
},
/**
* Adds a new tag.
*
* Also ensures that the quick links are properly generated.
*
* @since 2.9.0
* @memberOf tagBox
*
* @param {Object} el The container HTML element.
* @param {Object|boolean} a When this is an HTML element the text of that
* element will be used for the new tag.
* @param {number|boolean} f If this value is not passed then the tag input
* field is focused.
*
* @return {boolean} Always returns false.
*/
flushTags : function( el, a, f ) {
var tagsval, newtags, text,
tags = $( '.the-tags', el ),
@ -158,9 +255,34 @@ var tagBox, array_unique_noempty;
return false;
},
/**
* Retrieves the available tags and creates a tagcloud.
*
* Retrieves the available tags from the database and creates an interactive
* tagcloud. Clicking a tag will add it.
*
* @since 2.9.0
* @memberOf tagBox
*
* @param {string} id The ID to extract the taxonomy from.
*
* @return {void}
*/
get : function( id ) {
var tax = id.substr( id.indexOf('-') + 1 );
/**
* Puts a received tag cloud into a DOM element.
*
* The tag cloud HTML is generated on the server.
*
* @since 2.9.0
*
* @param {number|string} r The response message from the AJAX call.
* @param {string} stat The status of the AJAX request.
*
* @return {void}
*/
$.post( ajaxurl, { 'action': 'get-tagcloud', 'tax': tax }, function( r, stat ) {
if ( 0 === r || 'success' != stat ) {
return;
@ -168,6 +290,13 @@ var tagBox, array_unique_noempty;
r = $( '<div id="tagcloud-' + tax + '" class="the-tagcloud">' + r + '</div>' );
/**
* Adds a new tag when a tag in the tagcloud is clicked.
*
* @since 2.9.0
*
* @return {boolean} Returns false to prevent the default action.
*/
$( 'a', r ).click( function() {
tagBox.userAction = 'add';
tagBox.flushTags( $( '#' + tax ), this );
@ -186,9 +315,13 @@ var tagBox, array_unique_noempty;
userAction: '',
/**
* Dispatch an audible message to screen readers.
* Dispatches an audible message to screen readers.
*
* This will inform the user when a tag has been added or removed.
*
* @since 4.7.0
*
* @return {void}
*/
screenReadersMessage: function() {
var message;
@ -209,6 +342,18 @@ var tagBox, array_unique_noempty;
window.wp.a11y.speak( message, 'assertive' );
},
/**
* Initializes the tags box by setting up the links, buttons. Sets up event
* handling.
*
* This includes handling of pressing the enter key in the input field and the
* retrieval of tag suggestions.
*
* @since 2.9.0
* @memberOf tagBox
*
* @return {void}
*/
init : function() {
var ajaxtag = $('div.ajaxtag');
@ -221,6 +366,17 @@ var tagBox, array_unique_noempty;
tagBox.flushTags( $( this ).closest( '.tagsdiv' ) );
});
/**
* Handles pressing enter on the new tag input field.
*
* Prevents submitting the post edit form.
*
* @since 2.9.0
*
* @param {Event} event The keypress event that occurred.
*
* @return {void}
*/
$( 'input.newtag', ajaxtag ).keypress( function( event ) {
if ( 13 == event.which ) {
tagBox.userAction = 'add';
@ -237,14 +393,29 @@ var tagBox, array_unique_noempty;
$( element ).wpTagsSuggest();
});
// save tags on post save/publish
/**
* Before a post is saved the value currently in the new tag input field will be
* added as a tag.
*
* @since 2.9.0
*
* @return {void}
*/
$('#post').submit(function(){
$('div.tagsdiv').each( function() {
tagBox.flushTags(this, false, 1);
});
});
// Fetch and toggle the Tag cloud.
/**
* Handles clicking on the tag cloud link.
*
* Makes sure the ARIA attributes are set correctly.
*
* @since 2.9.0
*
* @return {void}
*/
$('.tagcloud-link').click(function(){
// On the first click, fetch the tag cloud and insert it in the DOM.
tagBox.get( $( this ).attr( 'id' ) );

View file

@ -1 +1 @@
var tagBox,array_unique_noempty;!function(a){var b=window.tagsSuggestL10n&&window.tagsSuggestL10n.tagDelimiter||",";array_unique_noempty=function(b){var c=[];return a.each(b,function(b,d){d=a.trim(d),d&&a.inArray(d,c)===-1&&c.push(d)}),c},tagBox={clean:function(a){return","!==b&&(a=a.replace(new RegExp(b,"g"),",")),a=a.replace(/\s*,\s*/g,",").replace(/,+/g,",").replace(/[,\s]+$/,"").replace(/^[,\s]+/,""),","!==b&&(a=a.replace(/,/g,b)),a},parseTags:function(c){var d=c.id,e=d.split("-check-num-")[1],f=a(c).closest(".tagsdiv"),g=f.find(".the-tags"),h=g.val().split(b),i=[];return delete h[e],a.each(h,function(b,c){c=a.trim(c),c&&i.push(c)}),g.val(this.clean(i.join(b))),this.quickClicks(f),!1},quickClicks:function(c){var d,e,f=a(".the-tags",c),g=a(".tagchecklist",c),h=a(c).attr("id");f.length&&(e=f.prop("disabled"),d=f.val().split(b),g.empty(),a.each(d,function(b,c){var d,f;c=a.trim(c),c&&(d=a("<li />").text(c),e||(f=a('<button type="button" id="'+h+"-check-num-"+b+'" class="ntdelbutton"><span class="remove-tag-icon" aria-hidden="true"></span><span class="screen-reader-text">'+window.tagsSuggestL10n.removeTerm+" "+d.html()+"</span></button>"),f.on("click keypress",function(b){"click"!==b.type&&13!==b.keyCode&&32!==b.keyCode||(13!==b.keyCode&&32!==b.keyCode||a(this).closest(".tagsdiv").find("input.newtag").focus(),tagBox.userAction="remove",tagBox.parseTags(this))}),d.prepend("&nbsp;").prepend(f)),g.append(d))}),tagBox.screenReadersMessage())},flushTags:function(c,d,e){var f,g,h,i=a(".the-tags",c),j=a("input.newtag",c);return d=d||!1,h=d?a(d).text():j.val(),"undefined"!=typeof h&&""!==h&&(f=i.val(),g=f?f+b+h:h,g=this.clean(g),g=array_unique_noempty(g.split(b)).join(b),i.val(g),this.quickClicks(c),d||j.val(""),"undefined"==typeof e&&j.focus(),!1)},get:function(b){var c=b.substr(b.indexOf("-")+1);a.post(ajaxurl,{action:"get-tagcloud",tax:c},function(d,e){0!==d&&"success"==e&&(d=a('<div id="tagcloud-'+c+'" class="the-tagcloud">'+d+"</div>"),a("a",d).click(function(){return tagBox.userAction="add",tagBox.flushTags(a("#"+c),this),!1}),a("#"+b).after(d))})},userAction:"",screenReadersMessage:function(){var a;switch(this.userAction){case"remove":a=window.tagsSuggestL10n.termRemoved;break;case"add":a=window.tagsSuggestL10n.termAdded;break;default:return}window.wp.a11y.speak(a,"assertive")},init:function(){var b=a("div.ajaxtag");a(".tagsdiv").each(function(){tagBox.quickClicks(this)}),a(".tagadd",b).click(function(){tagBox.userAction="add",tagBox.flushTags(a(this).closest(".tagsdiv"))}),a("input.newtag",b).keypress(function(b){13==b.which&&(tagBox.userAction="add",tagBox.flushTags(a(this).closest(".tagsdiv")),b.preventDefault(),b.stopPropagation())}).keypress(function(a){13==a.which&&(a.preventDefault(),a.stopPropagation())}).each(function(b,c){a(c).wpTagsSuggest()}),a("#post").submit(function(){a("div.tagsdiv").each(function(){tagBox.flushTags(this,!1,1)})}),a(".tagcloud-link").click(function(){tagBox.get(a(this).attr("id")),a(this).attr("aria-expanded","true").unbind().click(function(){a(this).attr("aria-expanded","false"===a(this).attr("aria-expanded")?"true":"false").siblings(".the-tagcloud").toggle()})})}}}(jQuery);
!function(a){var b=window.tagsSuggestL10n&&window.tagsSuggestL10n.tagDelimiter||",";window.array_unique_noempty=function(b){var c=[];return a.each(b,function(b,d){d=a.trim(d),d&&a.inArray(d,c)===-1&&c.push(d)}),c},window.tagBox={clean:function(a){return","!==b&&(a=a.replace(new RegExp(b,"g"),",")),a=a.replace(/\s*,\s*/g,",").replace(/,+/g,",").replace(/[,\s]+$/,"").replace(/^[,\s]+/,""),","!==b&&(a=a.replace(/,/g,b)),a},parseTags:function(c){var d=c.id,e=d.split("-check-num-")[1],f=a(c).closest(".tagsdiv"),g=f.find(".the-tags"),h=g.val().split(b),i=[];return delete h[e],a.each(h,function(b,c){c=a.trim(c),c&&i.push(c)}),g.val(this.clean(i.join(b))),this.quickClicks(f),!1},quickClicks:function(c){var d,e,f=a(".the-tags",c),g=a(".tagchecklist",c),h=a(c).attr("id");f.length&&(e=f.prop("disabled"),d=f.val().split(b),g.empty(),a.each(d,function(b,c){var d,f;c=a.trim(c),c&&(d=a("<li />").text(c),e||(f=a('<button type="button" id="'+h+"-check-num-"+b+'" class="ntdelbutton"><span class="remove-tag-icon" aria-hidden="true"></span><span class="screen-reader-text">'+window.tagsSuggestL10n.removeTerm+" "+d.html()+"</span></button>"),f.on("click keypress",function(b){"click"!==b.type&&13!==b.keyCode&&32!==b.keyCode||(13!==b.keyCode&&32!==b.keyCode||a(this).closest(".tagsdiv").find("input.newtag").focus(),tagBox.userAction="remove",tagBox.parseTags(this))}),d.prepend("&nbsp;").prepend(f)),g.append(d))}),tagBox.screenReadersMessage())},flushTags:function(c,d,e){var f,g,h,i=a(".the-tags",c),j=a("input.newtag",c);return d=d||!1,h=d?a(d).text():j.val(),"undefined"!=typeof h&&""!==h&&(f=i.val(),g=f?f+b+h:h,g=this.clean(g),g=array_unique_noempty(g.split(b)).join(b),i.val(g),this.quickClicks(c),d||j.val(""),"undefined"==typeof e&&j.focus(),!1)},get:function(b){var c=b.substr(b.indexOf("-")+1);a.post(ajaxurl,{action:"get-tagcloud",tax:c},function(d,e){0!==d&&"success"==e&&(d=a('<div id="tagcloud-'+c+'" class="the-tagcloud">'+d+"</div>"),a("a",d).click(function(){return tagBox.userAction="add",tagBox.flushTags(a("#"+c),this),!1}),a("#"+b).after(d))})},userAction:"",screenReadersMessage:function(){var a;switch(this.userAction){case"remove":a=window.tagsSuggestL10n.termRemoved;break;case"add":a=window.tagsSuggestL10n.termAdded;break;default:return}window.wp.a11y.speak(a,"assertive")},init:function(){var b=a("div.ajaxtag");a(".tagsdiv").each(function(){tagBox.quickClicks(this)}),a(".tagadd",b).click(function(){tagBox.userAction="add",tagBox.flushTags(a(this).closest(".tagsdiv"))}),a("input.newtag",b).keypress(function(b){13==b.which&&(tagBox.userAction="add",tagBox.flushTags(a(this).closest(".tagsdiv")),b.preventDefault(),b.stopPropagation())}).keypress(function(a){13==a.which&&(a.preventDefault(),a.stopPropagation())}).each(function(b,c){a(c).wpTagsSuggest()}),a("#post").submit(function(){a("div.tagsdiv").each(function(){tagBox.flushTags(this,!1,1)})}),a(".tagcloud-link").click(function(){tagBox.get(a(this).attr("id")),a(this).attr("aria-expanded","true").unbind().click(function(){a(this).attr("aria-expanded","false"===a(this).attr("aria-expanded")?"true":"false").siblings(".the-tagcloud").toggle()})})}}}(jQuery);

View file

@ -1,5 +1,7 @@
/**
* Default settings for jQuery UI Autocomplete for use with non-hierarchical taxonomies.
*
* @output wp-admin/js/tags-suggest.js
*/
( function( $ ) {
if ( typeof window.tagsSuggestL10n === 'undefined' || typeof window.uiAutocompleteL10n === 'undefined' ) {

View file

@ -1,18 +1,19 @@
/* global ajaxurl, wpAjax, tagsl10n, showNotice, validateForm */
/**
* Contains logic for both adding and deleting tags. For deleting tags it makes a request
* to the server to delete the tag. For adding tags it makes a request to the server to
* add the tag.
* Contains logic for deleting and adding tags.
*
* @summary Contains logic for deleting and adding tags
* For deleting tags it makes a request to the server to delete the tag.
* For adding tags it makes a request to the server to add the tag.
*
* @output wp-admin/js/tags.js
*/
/* global ajaxurl, wpAjax, tagsl10n, showNotice, validateForm */
jQuery(document).ready(function($) {
/**
* @summary Adds an event handler to the delete term link on the term overview page.
*
* Adds an event handler to the delete term link on the term overview page.
*
* Cancels default event handling and event bubbling.
*
* @since 2.8.0
@ -29,8 +30,8 @@ jQuery(document).ready(function($) {
data = t.attr('href').replace(/[^?]*\?/, '').replace(/action=delete/, 'action=delete-tag');
/**
* @summary Makes a request to the server to delete the term that
* corresponds to the delete term button.
* Makes a request to the server to delete the term that corresponds to the
* delete term button.
*
* @param {string} r The response from the server.
*
@ -42,7 +43,7 @@ jQuery(document).ready(function($) {
tr.fadeOut('normal', function(){ tr.remove(); });
/**
* @summary Remove the term from the parent box and the tag cloud
* Removes the term from the parent box and the tag cloud.
*
* `data.match(/tag_ID=(\d+)/)[1]` matches the term id from the data variable.
* This term id is then used to select the relevant HTML elements:
@ -87,7 +88,7 @@ jQuery(document).ready(function($) {
});
/**
* @summary Adds an event handler tot he form submit on the term overview page.
* Adds an event handler to the form submit on the term overview page.
*
* Cancels default event handling and event bubbling.
*

View file

@ -1,3 +1,7 @@
/**
* @output wp-admin/js/theme-plugin-editor.js
*/
/* eslint no-magic-numbers: ["error", { "ignore": [-1, 0, 1] }] */
if ( ! window.wp ) {
@ -49,6 +53,8 @@ wp.themePluginEditor = (function( $ ) {
component.textarea = component.form.find( '#newcontent' );
component.textarea.on( 'change', component.onChange );
component.warning = $( '.file-editor-warning' );
component.docsLookUpButton = component.form.find( '#docs-lookup' );
component.docsLookUpList = component.form.find( '#docs-list' );
if ( component.warning.length > 0 ) {
component.showWarning();
@ -73,6 +79,15 @@ wp.themePluginEditor = (function( $ ) {
}
return undefined;
} );
component.docsLookUpList.on( 'change', function() {
var option = $( this ).val();
if ( '' === option ) {
component.docsLookUpButton.prop( 'disabled', true );
} else {
component.docsLookUpButton.prop( 'disabled', false );
}
} );
};
/**

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,8 @@
/* global _wpThemeSettings, confirm */
/**
* @output wp-admin/js/theme.js
*/
/* global _wpThemeSettings, confirm, tb_position */
window.wp = window.wp || {};
( function($) {
@ -334,18 +338,7 @@ themes.Collection = Backbone.Collection.extend({
data: {
// Request data
request: _.extend({
per_page: 100,
fields: {
description: true,
tested: true,
requires: true,
rating: true,
downloaded: true,
downloadLink: true,
last_updated: true,
homepage: true,
num_ratings: true
}
per_page: 100
}, request)
},
@ -584,16 +577,26 @@ themes.view.Theme = wp.Backbone.View.extend({
// Handles .disabled classes for previous/next buttons in theme installer preview
setNavButtonsState: function() {
var $themeInstaller = $( '.theme-install-overlay' ),
current = _.isUndefined( this.current ) ? this.model : this.current;
current = _.isUndefined( this.current ) ? this.model : this.current,
previousThemeButton = $themeInstaller.find( '.previous-theme' ),
nextThemeButton = $themeInstaller.find( '.next-theme' );
// Disable previous at the zero position
if ( 0 === this.model.collection.indexOf( current ) ) {
$themeInstaller.find( '.previous-theme' ).addClass( 'disabled' );
previousThemeButton
.addClass( 'disabled' )
.prop( 'disabled', true );
nextThemeButton.focus();
}
// Disable next if the next model is undefined
if ( _.isUndefined( this.model.collection.at( this.model.collection.indexOf( current ) + 1 ) ) ) {
$themeInstaller.find( '.next-theme' ).addClass( 'disabled' );
nextThemeButton
.addClass( 'disabled' )
.prop( 'disabled', true );
previousThemeButton.focus();
}
},
@ -2038,9 +2041,8 @@ $( document ).ready(function() {
})( jQuery );
// Align theme browser thickbox
var tb_position;
jQuery(document).ready( function($) {
tb_position = function() {
window.tb_position = function() {
var tbWindow = $('#TB_window'),
width = $(window).width(),
H = $(window).height(),

File diff suppressed because one or more lines are too long

View file

@ -2,9 +2,7 @@
* Functions for ajaxified updates, deletions and installs inside the WordPress admin.
*
* @version 4.2.0
*
* @package WordPress
* @subpackage Administration
* @output wp-admin/js/updates.js
*/
/* global pagenow */
@ -38,7 +36,7 @@
*
* @since 4.2.0
*
* @type {object}
* @namespace wp.updates
*/
wp.updates = {};
@ -84,19 +82,19 @@
* @since 4.2.0
* @since 4.6.0 Added `available` property to indicate whether credentials have been provided.
*
* @type {object} filesystemCredentials Holds filesystem credentials.
* @type {object} filesystemCredentials.ftp Holds FTP credentials.
* @type {string} filesystemCredentials.ftp.host FTP host. Default empty string.
* @type {string} filesystemCredentials.ftp.username FTP user name. Default empty string.
* @type {string} filesystemCredentials.ftp.password FTP password. Default empty string.
* @type {string} filesystemCredentials.ftp.connectionType Type of FTP connection. 'ssh', 'ftp', or 'ftps'.
* Default empty string.
* @type {object} filesystemCredentials.ssh Holds SSH credentials.
* @type {string} filesystemCredentials.ssh.publicKey The public key. Default empty string.
* @type {string} filesystemCredentials.ssh.privateKey The private key. Default empty string.
* @type {string} filesystemCredentials.fsNonce Filesystem credentials form nonce.
* @type {bool} filesystemCredentials.available Whether filesystem credentials have been provided.
* Default 'false'.
* @type {Object}
* @property {Object} filesystemCredentials.ftp Holds FTP credentials.
* @property {string} filesystemCredentials.ftp.host FTP host. Default empty string.
* @property {string} filesystemCredentials.ftp.username FTP user name. Default empty string.
* @property {string} filesystemCredentials.ftp.password FTP password. Default empty string.
* @property {string} filesystemCredentials.ftp.connectionType Type of FTP connection. 'ssh', 'ftp', or 'ftps'.
* Default empty string.
* @property {Object} filesystemCredentials.ssh Holds SSH credentials.
* @property {string} filesystemCredentials.ssh.publicKey The public key. Default empty string.
* @property {string} filesystemCredentials.ssh.privateKey The private key. Default empty string.
* @property {string} filesystemCredentials.fsNonce Filesystem credentials form nonce.
* @property {bool} filesystemCredentials.available Whether filesystem credentials have been provided.
* Default 'false'.
*/
wp.updates.filesystemCredentials = {
ftp: {
@ -128,7 +126,7 @@
*
* @since 4.6.0
*
* @type {function} A function that lazily-compiles the template requested.
* @type {function}
*/
wp.updates.adminNotice = wp.template( 'wp-updates-admin-notice' );
@ -170,7 +168,9 @@
*
*/
wp.updates.addAdminNotice = function( data ) {
var $notice = $( data.selector ), $adminNotice;
var $notice = $( data.selector ),
$headerEnd = $( '.wp-header-end' ),
$adminNotice;
delete data.selector;
$adminNotice = wp.updates.adminNotice( data );
@ -182,6 +182,8 @@
if ( $notice.length ) {
$notice.replaceWith( $adminNotice );
} else if ( $headerEnd.length ) {
$headerEnd.after( $adminNotice );
} else {
if ( 'customize' === pagenow ) {
$( '.customize-themes-notifications' ).append( $adminNotice );
@ -407,7 +409,6 @@
* @since 4.2.0
* @since 4.6.0 More accurately named `updatePluginSuccess`.
*
* @typedef {object} updatePluginSuccess
* @param {object} response Response from the server.
* @param {string} response.slug Slug of the plugin to be updated.
* @param {string} response.plugin Basename of the plugin to be updated.
@ -452,7 +453,6 @@
* @since 4.2.0
* @since 4.6.0 More accurately named `updatePluginError`.
*
* @typedef {object} updatePluginError
* @param {object} response Response from the server.
* @param {string} response.slug Slug of the plugin to be updated.
* @param {string} response.plugin Basename of the plugin to be updated.
@ -574,7 +574,6 @@
*
* @since 4.6.0
*
* @typedef {object} installPluginSuccess
* @param {object} response Response from the server.
* @param {string} response.slug Slug of the installed plugin.
* @param {string} response.pluginName Name of the installed plugin.
@ -585,16 +584,10 @@
$message
.removeClass( 'updating-message' )
.addClass( 'updated-message installed' )
.addClass( 'updated-message installed button-disabled' )
.attr( 'aria-label', wp.updates.l10n.pluginInstalledLabel.replace( '%s', response.pluginName ) )
.text( wp.updates.l10n.pluginInstalled );
if ( $message.hasClass( 'button-primary' ) ) {
$message.addClass( 'button-primary-disabled' );
} else {
$message.addClass( 'button-disabled' );
}
wp.a11y.speak( wp.updates.l10n.installedMsg, 'polite' );
$document.trigger( 'wp-plugin-install-success', response );
@ -603,11 +596,10 @@
setTimeout( function() {
// Transform the 'Install' button into an 'Activate' button.
$message.removeClass( 'install-now installed button-primary-disabled button-secondary-disabled button-disabled updated-message' )
.addClass( 'activate-now' )
$message.removeClass( 'install-now installed button-disabled updated-message' ).addClass( 'activate-now button-primary' )
.attr( 'href', response.activateUrl )
.attr( 'aria-label', wp.updates.l10n.activatePluginLabel.replace( '%s', response.pluginName ) )
.text( response.activateLabel || wp.updates.l10n.activatePlugin );
.text( wp.updates.l10n.activatePlugin );
}, 1000 );
}
};
@ -617,7 +609,6 @@
*
* @since 4.6.0
*
* @typedef {object} installPluginError
* @param {object} response Response from the server.
* @param {string} response.slug Slug of the plugin to be installed.
* @param {string=} response.pluginName Optional. Name of the plugin to be installed.
@ -668,7 +659,6 @@
*
* @since 4.6.0
*
* @typedef {object} installImporterSuccess
* @param {object} response Response from the server.
* @param {string} response.slug Slug of the installed plugin.
* @param {string} response.pluginName Name of the installed plugin.
@ -700,7 +690,6 @@
*
* @since 4.6.0
*
* @typedef {object} installImporterError
* @param {object} response Response from the server.
* @param {string} response.slug Slug of the plugin to be installed.
* @param {string=} response.pluginName Optional. Name of the plugin to be installed.
@ -729,7 +718,7 @@
$installLink
.removeClass( 'updating-message' )
.text( wp.updates.l10n.installNow )
.attr( 'aria-label', wp.updates.l10n.installNowLabel.replace( '%s', pluginName ) );
.attr( 'aria-label', wp.updates.l10n.pluginInstallNowLabel.replace( '%s', pluginName ) );
wp.a11y.speak( errorMessage, 'assertive' );
@ -775,8 +764,7 @@
*
* @since 4.6.0
*
* @typedef {object} deletePluginSuccess
* @param {object} response Response from the server.
* @param {Object} response Response from the server.
* @param {string} response.slug Slug of the plugin that was deleted.
* @param {string} response.plugin Base name of the plugin that was deleted.
* @param {string} response.pluginName Name of the plugin that was deleted.
@ -790,7 +778,11 @@
$pluginRow = $( this ),
columnCount = $form.find( 'thead th:not(.hidden), thead td' ).length,
pluginDeletedRow = wp.template( 'item-deleted-row' ),
/** @type {object} plugins Base names of plugins in their different states. */
/**
* Plugins Base names of plugins in their different states.
*
* @type {Object}
*/
plugins = settings.plugins;
// Add a success message after deleting a plugin.
@ -865,7 +857,6 @@
*
* @since 4.6.0
*
* @typedef {object} deletePluginError
* @param {object} response Response from the server.
* @param {string} response.slug Slug of the plugin to be deleted.
* @param {string} response.plugin Base name of the plugin to be deleted
@ -978,7 +969,6 @@
*
* @since 4.6.0
*
* @typedef {object} updateThemeSuccess
* @param {object} response
* @param {string} response.slug Slug of the theme to be updated.
* @param {object} response.theme Updated theme.
@ -1040,7 +1030,6 @@
*
* @since 4.6.0
*
* @typedef {object} updateThemeError
* @param {object} response Response from the server.
* @param {string} response.slug Slug of the theme to be updated.
* @param {string} response.errorCode Error code for the error that occurred.
@ -1126,7 +1115,6 @@
*
* @since 4.6.0
*
* @typedef {object} installThemeSuccess
* @param {object} response Response from the server.
* @param {string} response.slug Slug of the theme to be installed.
* @param {string} response.customizeUrl URL to the Customizer for the just installed theme.
@ -1177,7 +1165,6 @@
*
* @since 4.6.0
*
* @typedef {object} installThemeError
* @param {object} response Response from the server.
* @param {string} response.slug Slug of the theme to be installed.
* @param {string} response.errorCode Error code for the error that occurred.
@ -1275,7 +1262,6 @@
*
* @since 4.6.0
*
* @typedef {object} deleteThemeSuccess
* @param {object} response Response from the server.
* @param {string} response.slug Slug of the theme that was deleted.
*/
@ -1334,7 +1320,6 @@
*
* @since 4.6.0
*
* @typedef {object} deleteThemeError
* @param {object} response Response from the server.
* @param {string} response.slug Slug of the theme to be deleted.
* @param {string} response.errorCode Error code for the error that occurred.
@ -1608,7 +1593,6 @@
*
* @since 4.6.0
*
* @typedef {object} maybeHandleCredentialError
* @param {object} response Response from the server.
* @param {string} response.errorCode Error code for the error that occurred.
* @param {string} response.errorMessage The error that occurred.
@ -1947,7 +1931,7 @@
$button
.removeClass( 'updating-message' )
.text( wp.updates.l10n.installNow )
.attr( 'aria-label', wp.updates.l10n.installNowLabel.replace( '%s', pluginName ) );
.attr( 'aria-label', wp.updates.l10n.pluginInstallNowLabel.replace( '%s', pluginName ) );
wp.a11y.speak( wp.updates.l10n.updateCancel, 'polite' );
} );
@ -2339,14 +2323,14 @@
$( 'input.wp-filter-search' ).trigger( 'input' );
} );
/**
* Trigger a search event when the "Try Again" button is clicked.
*
/**
* Trigger a search event when the "Try Again" button is clicked.
*
* @since 4.9.0
*/
$document.on( 'click', '.try-again', function( event ) {
event.preventDefault();
$pluginInstallSearch.trigger( 'input' );
*/
$document.on( 'click', '.try-again', function( event ) {
event.preventDefault();
$pluginInstallSearch.trigger( 'input' );
} );
/**

File diff suppressed because one or more lines are too long

View file

@ -1,3 +1,7 @@
/**
* @output wp-admin/js/user-profile.js
*/
/* global ajaxurl, pwsL10n, userProfileL10n */
(function($) {
var updateLock = false,
@ -13,19 +17,7 @@
$toggleButton,
$submitButtons,
$submitButton,
currentPass,
inputEvent;
/*
* Use feature detection to determine whether password inputs should use
* the `keyup` or `input` event. Input is preferred but lacks support
* in legacy browsers.
*/
if ( 'oninput' in document.createElement( 'input' ) ) {
inputEvent = 'input';
} else {
inputEvent = 'keyup';
}
currentPass;
function generatePassword() {
if ( typeof zxcvbn !== 'function' ) {
@ -67,7 +59,7 @@
.addClass( $pass1[0].className )
.data( 'pw', $pass1.data( 'pw' ) )
.val( $pass1.val() )
.on( inputEvent, function () {
.on( 'input', function () {
if ( $pass1Text.val() === currentPass ) {
return;
}
@ -82,7 +74,7 @@
generatePassword();
}
$pass1.on( inputEvent + ' pwupdate', function () {
$pass1.on( 'input' + ' pwupdate', function () {
if ( $pass1.val() === currentPass ) {
return;
}
@ -184,7 +176,7 @@
* This fixes the issue by copying any changes from the hidden
* pass2 field to the pass1 field, then running check_pass_strength.
*/
$pass2 = $('#pass2').on( inputEvent, function () {
$pass2 = $( '#pass2' ).on( 'input', function () {
if ( $pass2.val().length > 0 ) {
$pass1.val( $pass2.val() );
$pass2.val('');
@ -332,7 +324,7 @@
current_name = select.val(),
greeting = $( '#wp-admin-bar-my-account' ).find( '.display-name' );
$('#pass1').val('').on( inputEvent + ' pwupdate', check_pass_strength );
$( '#pass1' ).val( '' ).on( 'input' + ' pwupdate', check_pass_strength );
$('#pass-strength-result').show();
$('.color-palette').click( function() {
$(this).siblings('input[name="admin_color"]').prop('checked', true);

File diff suppressed because one or more lines are too long

View file

@ -1,3 +1,15 @@
/**
* Suggests users in a multisite environment.
*
* For input fields where the admin can select a user based on email or
* username, this script shows an autocompletion menu for these inputs. Should
* only be used in a multisite environment. Only users in the currently active
* site are shown.
*
* @since 3.4.0
* @output wp-admin/js/user-suggest.js
*/
/* global ajaxurl, current_site_id, isRtl */
(function( $ ) {
@ -8,6 +20,28 @@
position.my = 'right top';
position.at = 'right bottom';
}
/**
* Adds an autocomplete function to input fields marked with the class
* 'wp-suggest-user'.
*
* A minimum of two characters is required to trigger the suggestions. The
* autocompletion menu is shown at the left bottom of the input field. On
* RTL installations, it is shown at the right top. Adds the class 'open' to
* the input field when the autocompletion menu is shown.
*
* Does a backend call to retrieve the users.
*
* Optional data-attributes:
* - data-autocomplete-type (add, search)
* The action that is going to be performed: search for existing users
* or add a new one. Default: add
* - data-autocomplete-field (user_login, user_email)
* The field that is returned as the value for the suggestion.
* Default: user_login
*
* @see wp-admin/includes/admin-actions.php:wp_ajax_autocomplete_user()
*/
$( '.wp-suggest-user' ).each( function(){
var $this = $( this ),
autocompleteType = ( typeof $this.data( 'autocompleteType' ) !== 'undefined' ) ? $this.data( 'autocompleteType' ) : 'add',

View file

@ -1,9 +1,13 @@
/*global ajaxurl, isRtl */
var wpWidgets;
/**
* @output wp-admin/js/widgets.js
*/
/* global ajaxurl, isRtl, wpWidgets */
(function($) {
var $document = $( document );
wpWidgets = {
window.wpWidgets = {
/**
* A closed Sidebar that gets a Widget dragged over it.
*
@ -21,7 +25,8 @@ wpWidgets = {
l10n: {
save: '{save}',
saved: '{saved}',
saveAlert: '{saveAlert}'
saveAlert: '{saveAlert}',
widgetAdded: '{widgetAdded}'
},
/**
@ -176,19 +181,16 @@ wpWidgets = {
widget.removeClass( 'open' );
});
}
e.preventDefault();
} else if ( target.hasClass('widget-control-save') ) {
wpWidgets.save( target.closest('div.widget'), 0, 1, 0 );
e.preventDefault();
} else if ( target.hasClass('widget-control-remove') ) {
wpWidgets.save( target.closest('div.widget'), 1, 1, 0 );
e.preventDefault();
} else if ( target.hasClass('widget-control-close') ) {
widget = target.closest('div.widget');
widget.removeClass( 'open' );
toggleBtn.attr( 'aria-expanded', 'false' );
wpWidgets.close( widget );
e.preventDefault();
} else if ( target.attr( 'id' ) === 'inactive-widgets-control-remove' ) {
wpWidgets.removeInactiveWidgets();
e.preventDefault();
@ -245,6 +247,8 @@ wpWidgets = {
/**
* Open Sidebar when a Widget gets dragged over it.
*
* @ignore
*
* @param {object} event jQuery event object.
*/
over: function( event ) {
@ -268,6 +272,8 @@ wpWidgets = {
/**
* Close Sidebar when the Widget gets dragged out of it.
*
* @ignore
*
* @param {object} event jQuery event object.
*/
out: function( event ) {
@ -429,35 +435,53 @@ wpWidgets = {
$( '#widgets-right .widgets-holder-wrap' ).each( function( index, element ) {
var $element = $( element ),
name = $element.find( '.sidebar-name h2' ).text(),
ariaLabel = $element.find( '.sidebar-name' ).data( 'add-to' ),
id = $element.find( '.widgets-sortables' ).attr( 'id' ),
li = $('<li tabindex="0">').text( $.trim( name ) );
li = $( '<li>' ),
button = $( '<button>', {
type: 'button',
'aria-pressed': 'false',
'class': 'widgets-chooser-button',
'aria-label': ariaLabel
} ).text( $.trim( name ) );
li.append( button );
if ( index === 0 ) {
li.addClass( 'widgets-chooser-selected' );
button.attr( 'aria-pressed', 'true' );
}
selectSidebar.append( li );
li.data( 'sidebarId', id );
});
$( '#available-widgets .widget .widget-title' ).on( 'click.widgets-chooser', function() {
var $widget = $(this).closest( '.widget' );
$( '#available-widgets .widget .widget-top' ).on( 'click.widgets-chooser', function() {
var $widget = $( this ).closest( '.widget' ),
toggleButton = $( this ).find( '.widget-action' ),
chooserButtons = selectSidebar.find( '.widgets-chooser-button' );
if ( $widget.hasClass( 'widget-in-question' ) || $( '#widgets-left' ).hasClass( 'chooser' ) ) {
toggleButton.attr( 'aria-expanded', 'false' );
self.closeChooser();
} else {
// Open the chooser
self.clearWidgetSelection();
$( '#widgets-left' ).addClass( 'chooser' );
// Add CSS class and insert the chooser after the widget description.
$widget.addClass( 'widget-in-question' ).children( '.widget-description' ).after( chooser );
// Open the chooser with a slide down animation.
chooser.slideDown( 300, function() {
selectSidebar.find('.widgets-chooser-selected').focus();
// Update the toggle button aria-expanded attribute after previous DOM manipulations.
toggleButton.attr( 'aria-expanded', 'true' );
});
selectSidebar.find( 'li' ).on( 'focusin.widgets-chooser', function() {
selectSidebar.find('.widgets-chooser-selected').removeClass( 'widgets-chooser-selected' );
$(this).addClass( 'widgets-chooser-selected' );
chooserButtons.on( 'click.widgets-chooser', function() {
selectSidebar.find( '.widgets-chooser-selected' ).removeClass( 'widgets-chooser-selected' );
chooserButtons.attr( 'aria-pressed', 'false' );
$( this )
.attr( 'aria-pressed', 'true' )
.closest( 'li' ).addClass( 'widgets-chooser-selected' );
} );
}
});
@ -473,15 +497,7 @@ wpWidgets = {
self.closeChooser();
}
}).on( 'keyup.widgets-chooser', function( event ) {
if ( event.which === $.ui.keyCode.ENTER ) {
if ( $( event.target ).hasClass( 'widgets-chooser-cancel' ) ) {
// Close instead of adding when pressing Enter on the Cancel button
self.closeChooser();
} else {
self.addWidget( chooser );
self.closeChooser();
}
} else if ( event.which === $.ui.keyCode.ESCAPE ) {
if ( event.which === $.ui.keyCode.ESCAPE ) {
self.closeChooser();
}
});
@ -701,15 +717,20 @@ wpWidgets = {
// Cannot use a callback in the animation above as it fires twice,
// have to queue this "by hand".
widget.find( '.widget-title' ).trigger('click');
// At the end of the animation, announce the widget has been added.
window.wp.a11y.speak( wpWidgets.l10n.widgetAdded, 'assertive' );
}, 250 );
},
closeChooser: function() {
var self = this;
var self = this,
widgetInQuestion = $( '#available-widgets .widget-in-question' );
$( '.widgets-chooser' ).slideUp( 200, function() {
$( '#wpbody-content' ).append( this );
self.clearWidgetSelection();
// Move focus back to the toggle button.
widgetInQuestion.find( '.widget-action' ).attr( 'aria-expanded', 'false' ).focus();
});
},

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,15 @@
/**
* @output wp-admin/js/widgets/custom-html-widgets.js
*/
/* global wp */
/* eslint consistent-this: [ "error", "control" ] */
/* eslint no-magic-numbers: ["error", { "ignore": [0,1,-1] }] */
/**
* @namespace wp.customHtmlWidget
* @memberOf wp
*/
wp.customHtmlWidgets = ( function( $ ) {
'use strict';
@ -15,14 +24,7 @@ wp.customHtmlWidgets = ( function( $ ) {
}
};
/**
* Text widget control.
*
* @class CustomHtmlWidgetControl
* @constructor
* @abstract
*/
component.CustomHtmlWidgetControl = Backbone.View.extend({
component.CustomHtmlWidgetControl = Backbone.View.extend(/** @lends wp.customHtmlWidgets.CustomHtmlWidgetControl.prototype */{
/**
* View events.
@ -32,11 +34,16 @@ wp.customHtmlWidgets = ( function( $ ) {
events: {},
/**
* Initialize.
* Text widget control.
*
* @constructs wp.customHtmlWidgets.CustomHtmlWidgetControl
* @augments Backbone.View
* @abstract
*
* @param {Object} options - Options.
* @param {jQuery} options.el - Control field container element.
* @param {jQuery} options.syncContainer - Container element where fields are synced for the server.
*
* @returns {void}
*/
initialize: function initialize( options ) {
@ -105,10 +112,10 @@ wp.customHtmlWidgets = ( function( $ ) {
* to prevent the editor's contents from getting sanitized as soon as a user removes focus from
* the editor. This is particularly important for users who cannot unfiltered_html.
*/
control.contentUpdateBypassed = control.fields.content.is( document.activeElement ) || control.editor && control.editor.codemirror.state.focused || 0 !== control.currentErrorAnnotations;
control.contentUpdateBypassed = control.fields.content.is( document.activeElement ) || control.editor && control.editor.codemirror.state.focused || 0 !== control.currentErrorAnnotations.length;
if ( ! control.contentUpdateBypassed ) {
syncInput = control.syncContainer.find( '.sync-input.content' );
control.fields.content.val( syncInput.val() ).trigger( 'change' );
control.fields.content.val( syncInput.val() );
}
},
@ -171,6 +178,8 @@ wp.customHtmlWidgets = ( function( $ ) {
/**
* Handle tabbing to the field before the editor.
*
* @ignore
*
* @returns {void}
*/
onTabPrevious: function onTabPrevious() {
@ -180,6 +189,8 @@ wp.customHtmlWidgets = ( function( $ ) {
/**
* Handle tabbing to the field after the editor.
*
* @ignore
*
* @returns {void}
*/
onTabNext: function onTabNext() {
@ -190,6 +201,8 @@ wp.customHtmlWidgets = ( function( $ ) {
/**
* Disable save button and store linting errors for use in updateFields.
*
* @ignore
*
* @param {Array} errorAnnotations - Error notifications.
* @returns {void}
*/
@ -200,6 +213,8 @@ wp.customHtmlWidgets = ( function( $ ) {
/**
* Update error notice.
*
* @ignore
*
* @param {Array} errorAnnotations - Error annotations.
* @returns {void}
*/
@ -259,6 +274,8 @@ wp.customHtmlWidgets = ( function( $ ) {
/**
* Mapping of widget ID to instances of CustomHtmlWidgetControl subclasses.
*
* @alias wp.customHtmlWidgets.widgetControls
*
* @type {Object.<string, wp.textWidgets.CustomHtmlWidgetControl>}
*/
component.widgetControls = {};
@ -266,8 +283,11 @@ wp.customHtmlWidgets = ( function( $ ) {
/**
* Handle widget being added or initialized for the first time at the widget-added event.
*
* @alias wp.customHtmlWidgets.handleWidgetAdded
*
* @param {jQuery.Event} event - Event.
* @param {jQuery} widgetContainer - Widget container element.
*
* @returns {void}
*/
component.handleWidgetAdded = function handleWidgetAdded( event, widgetContainer ) {
@ -325,6 +345,8 @@ wp.customHtmlWidgets = ( function( $ ) {
/**
* Setup widget in accessibility mode.
*
* @alias wp.customHtmlWidgets.setupAccessibleMode
*
* @returns {void}
*/
component.setupAccessibleMode = function setupAccessibleMode() {
@ -358,6 +380,8 @@ wp.customHtmlWidgets = ( function( $ ) {
* the widgets admin screen and also via the 'widget-synced' event when making
* a change to a widget in the customizer.
*
* @alias wp.customHtmlWidgets.handleWidgetUpdated
*
* @param {jQuery.Event} event - Event.
* @param {jQuery} widgetContainer - Widget container element.
* @returns {void}
@ -387,7 +411,10 @@ wp.customHtmlWidgets = ( function( $ ) {
* When WordPress enqueues this script, it should have an inline script
* attached which calls wp.textWidgets.init().
*
* @alias wp.customHtmlWidgets.init
*
* @param {object} settings - Options for code editor, exported from PHP.
*
* @returns {void}
*/
component.init = function init( settings ) {

File diff suppressed because one or more lines are too long

View file

@ -1,3 +1,7 @@
/**
* @output wp-admin/js/widgets/media-audio-widget.js
*/
/* eslint consistent-this: [ "error", "control" ] */
(function( component ) {
'use strict';
@ -7,10 +11,10 @@
/**
* Custom audio details frame that removes the replace-audio state.
*
* @class AudioDetailsMediaFrame
* @constructor
* @class wp.mediaWidgets.controlConstructors~AudioDetailsMediaFrame
* @augments wp.media.view.MediaFrame.AudioDetails
*/
AudioDetailsMediaFrame = wp.media.view.MediaFrame.AudioDetails.extend({
AudioDetailsMediaFrame = wp.media.view.MediaFrame.AudioDetails.extend(/** @lends wp.mediaWidgets.controlConstructors~AudioDetailsMediaFrame.prototype */{
/**
* Create the default states.
@ -40,8 +44,8 @@
*
* See WP_Widget_Audio::enqueue_admin_scripts() for amending prototype from PHP exports.
*
* @class AudioWidgetModel
* @constructor
* @class wp.mediaWidgets.modelConstructors.media_audio
* @augments wp.mediaWidgets.MediaWidgetModel
*/
AudioWidgetModel = component.MediaWidgetModel.extend({});
@ -50,10 +54,10 @@
*
* See WP_Widget_Audio::enqueue_admin_scripts() for amending prototype from PHP exports.
*
* @class AudioWidgetModel
* @constructor
* @class wp.mediaWidgets.controlConstructors.media_audio
* @augments wp.mediaWidgets.MediaWidgetControl
*/
AudioWidgetControl = component.MediaWidgetControl.extend({
AudioWidgetControl = component.MediaWidgetControl.extend(/** @lends wp.mediaWidgets.controlConstructors.media_audio.prototype */{
/**
* Show display settings.

View file

@ -1,3 +1,7 @@
/**
* @output wp-admin/js/widgets/media-gallery-widget.js
*/
/* eslint consistent-this: [ "error", "control" ] */
(function( component ) {
'use strict';
@ -8,10 +12,10 @@
* Custom gallery details frame.
*
* @since 4.9.0
* @class GalleryDetailsMediaFrame
* @constructor
* @class wp.mediaWidgets~GalleryDetailsMediaFrame
* @augments wp.media.view.MediaFrame.Post
*/
GalleryDetailsMediaFrame = wp.media.view.MediaFrame.Post.extend( {
GalleryDetailsMediaFrame = wp.media.view.MediaFrame.Post.extend(/** @lends wp.mediaWidgets~GalleryDetailsMediaFrame.prototype */{
/**
* Create the default states.
@ -53,21 +57,13 @@
* See WP_Widget_Gallery::enqueue_admin_scripts() for amending prototype from PHP exports.
*
* @since 4.9.0
* @class GalleryWidgetModel
* @constructor
*
* @class wp.mediaWidgets.modelConstructors.media_gallery
* @augments wp.mediaWidgets.MediaWidgetModel
*/
GalleryWidgetModel = component.MediaWidgetModel.extend( {} );
GalleryWidgetModel = component.MediaWidgetModel.extend(/** @lends wp.mediaWidgets.modelConstructors.media_gallery.prototype */{} );
/**
* Gallery widget control.
*
* See WP_Widget_Gallery::enqueue_admin_scripts() for amending prototype from PHP exports.
*
* @since 4.9.0
* @class GalleryWidgetControl
* @constructor
*/
GalleryWidgetControl = component.MediaWidgetControl.extend( {
GalleryWidgetControl = component.MediaWidgetControl.extend(/** @lends wp.mediaWidgets.controlConstructors.media_gallery.prototype */{
/**
* View events.
@ -80,7 +76,12 @@
} ),
/**
* Initialize.
* Gallery widget control.
*
* See WP_Widget_Gallery::enqueue_admin_scripts() for amending prototype from PHP exports.
*
* @constructs wp.mediaWidgets.controlConstructors.media_gallery
* @augments wp.mediaWidgets.MediaWidgetControl
*
* @since 4.9.0
* @param {Object} options - Options.

View file

@ -1,3 +1,7 @@
/**
* @output wp-admin/js/widgets/media-image-widget.js
*/
/* eslint consistent-this: [ "error", "control" ] */
(function( component, $ ) {
'use strict';
@ -9,8 +13,8 @@
*
* See WP_Widget_Media_Image::enqueue_admin_scripts() for amending prototype from PHP exports.
*
* @class ImageWidgetModel
* @constructor
* @class wp.mediaWidgets.modelConstructors.media_image
* @augments wp.mediaWidgets.MediaWidgetModel
*/
ImageWidgetModel = component.MediaWidgetModel.extend({});
@ -19,10 +23,10 @@
*
* See WP_Widget_Media_Image::enqueue_admin_scripts() for amending prototype from PHP exports.
*
* @class ImageWidgetModel
* @constructor
* @class wp.mediaWidgets.controlConstructors.media_audio
* @augments wp.mediaWidgets.MediaWidgetControl
*/
ImageWidgetControl = component.MediaWidgetControl.extend({
ImageWidgetControl = component.MediaWidgetControl.extend(/** @lends wp.mediaWidgets.controlConstructors.media_image.prototype */{
/**
* View events.

View file

@ -1,3 +1,7 @@
/**
* @output wp-admin/js/widgets/media-video-widget.js
*/
/* eslint consistent-this: [ "error", "control" ] */
(function( component ) {
'use strict';
@ -7,10 +11,12 @@
/**
* Custom video details frame that removes the replace-video state.
*
* @class VideoDetailsMediaFrame
* @constructor
* @class wp.mediaWidgets.controlConstructors~VideoDetailsMediaFrame
* @augments wp.media.view.MediaFrame.VideoDetails
*
* @private
*/
VideoDetailsMediaFrame = wp.media.view.MediaFrame.VideoDetails.extend({
VideoDetailsMediaFrame = wp.media.view.MediaFrame.VideoDetails.extend(/** @lends wp.mediaWidgets.controlConstructors~VideoDetailsMediaFrame.prototype */{
/**
* Create the default states.
@ -49,8 +55,8 @@
*
* See WP_Widget_Video::enqueue_admin_scripts() for amending prototype from PHP exports.
*
* @class VideoWidgetModel
* @constructor
* @class wp.mediaWidgets.modelConstructors.media_video
* @augments wp.mediaWidgets.MediaWidgetModel
*/
VideoWidgetModel = component.MediaWidgetModel.extend({});
@ -59,10 +65,10 @@
*
* See WP_Widget_Video::enqueue_admin_scripts() for amending prototype from PHP exports.
*
* @class VideoWidgetControl
* @constructor
* @class wp.mediaWidgets.controlConstructors.media_video
* @augments wp.mediaWidgets.MediaWidgetControl
*/
VideoWidgetControl = component.MediaWidgetControl.extend({
VideoWidgetControl = component.MediaWidgetControl.extend(/** @lends wp.mediaWidgets.controlConstructors.media_video.prototype */{
/**
* Show display settings.

View file

@ -1,4 +1,13 @@
/**
* @output wp-admin/js/widgets/media-widgets.js
*/
/* eslint consistent-this: [ "error", "control" ] */
/**
* @namespace wp.mediaWidgets
* @memberOf wp
*/
wp.mediaWidgets = ( function( $ ) {
'use strict';
@ -9,6 +18,8 @@ wp.mediaWidgets = ( function( $ ) {
*
* Media widgets register themselves by assigning subclasses of MediaWidgetControl onto this object by widget ID base.
*
* @memberOf wp.mediaWidgets
*
* @type {Object.<string, wp.mediaWidgets.MediaWidgetModel>}
*/
component.controlConstructors = {};
@ -18,22 +29,22 @@ wp.mediaWidgets = ( function( $ ) {
*
* Media widgets register themselves by assigning subclasses of MediaWidgetControl onto this object by widget ID base.
*
* @memberOf wp.mediaWidgets
*
* @type {Object.<string, wp.mediaWidgets.MediaWidgetModel>}
*/
component.modelConstructors = {};
/**
* Library which persists the customized display settings across selections.
*
* @class PersistentDisplaySettingsLibrary
* @constructor
*/
component.PersistentDisplaySettingsLibrary = wp.media.controller.Library.extend({
component.PersistentDisplaySettingsLibrary = wp.media.controller.Library.extend(/** @lends wp.mediaWidgets.PersistentDisplaySettingsLibrary.prototype */{
/**
* Initialize.
* Library which persists the customized display settings across selections.
*
* @constructs wp.mediaWidgets.PersistentDisplaySettingsLibrary
* @augments wp.media.controller.Library
*
* @param {Object} options - Options.
*
* @returns {void}
*/
initialize: function initialize( options ) {
@ -79,10 +90,10 @@ wp.mediaWidgets = ( function( $ ) {
/**
* Extended view for managing the embed UI.
*
* @class MediaEmbedView
* @constructor
* @class wp.mediaWidgets.MediaEmbedView
* @augments wp.media.view.Embed
*/
component.MediaEmbedView = wp.media.view.Embed.extend({
component.MediaEmbedView = wp.media.view.Embed.extend(/** @lends wp.mediaWidgets.MediaEmbedView.prototype */{
/**
* Initialize.
@ -109,6 +120,9 @@ wp.mediaWidgets = ( function( $ ) {
* @returns {void}
*/
refresh: function refresh() {
/**
* @class wp.mediaWidgets~Constructor
*/
var Constructor;
if ( 'image' === this.controller.options.mimeType ) {
@ -116,7 +130,7 @@ wp.mediaWidgets = ( function( $ ) {
} else {
// This should be eliminated once #40450 lands of when this is merged into core.
Constructor = wp.media.view.EmbedLink.extend({
Constructor = wp.media.view.EmbedLink.extend(/** @lends wp.mediaWidgets~Constructor.prototype */{
/**
* Set the disabled state on the Add to Widget button.
@ -284,10 +298,10 @@ wp.mediaWidgets = ( function( $ ) {
/**
* Custom media frame for selecting uploaded media or providing media by URL.
*
* @class MediaFrameSelect
* @constructor
* @class wp.mediaWidgets.MediaFrameSelect
* @augments wp.media.view.MediaFrame.Post
*/
component.MediaFrameSelect = wp.media.view.MediaFrame.Post.extend({
component.MediaFrameSelect = wp.media.view.MediaFrame.Post.extend(/** @lends wp.mediaWidgets.MediaFrameSelect.prototype */{
/**
* Create the default states.
@ -357,6 +371,8 @@ wp.mediaWidgets = ( function( $ ) {
/**
* Handle click.
*
* @ignore
*
* @fires wp.media.controller.State#insert()
* @returns {void}
*/
@ -408,14 +424,7 @@ wp.mediaWidgets = ( function( $ ) {
}
});
/**
* Media widget control.
*
* @class MediaWidgetControl
* @constructor
* @abstract
*/
component.MediaWidgetControl = Backbone.View.extend({
component.MediaWidgetControl = Backbone.View.extend(/** @lends wp.mediaWidgets.MediaWidgetControl.prototype */{
/**
* Translation strings.
@ -473,12 +482,17 @@ wp.mediaWidgets = ( function( $ ) {
showDisplaySettings: true,
/**
* Initialize.
* Media Widget Control.
*
* @constructs wp.mediaWidgets.MediaWidgetControl
* @augments Backbone.View
* @abstract
*
* @param {Object} options - Options.
* @param {Backbone.Model} options.model - Model.
* @param {jQuery} options.el - Control field container element.
* @param {jQuery} options.syncContainer - Container element where fields are synced for the server.
*
* @returns {void}
*/
initialize: function initialize( options ) {
@ -961,10 +975,10 @@ wp.mediaWidgets = ( function( $ ) {
/**
* Media widget model.
*
* @class MediaWidgetModel
* @constructor
* @class wp.mediaWidgets.MediaWidgetModel
* @augments Backbone.Model
*/
component.MediaWidgetModel = Backbone.Model.extend({
component.MediaWidgetModel = Backbone.Model.extend(/** @lends wp.mediaWidgets.MediaWidgetModel.prototype */{
/**
* Id attribute.
@ -1085,15 +1099,19 @@ wp.mediaWidgets = ( function( $ ) {
/**
* Collection of all widget model instances.
*
* @memberOf wp.mediaWidgets
*
* @type {Backbone.Collection}
*/
component.modelCollection = new ( Backbone.Collection.extend({
component.modelCollection = new ( Backbone.Collection.extend( {
model: component.MediaWidgetModel
}) )();
/**
* Mapping of widget ID to instances of MediaWidgetControl subclasses.
*
* @memberOf wp.mediaWidgets
*
* @type {Object.<string, wp.mediaWidgets.MediaWidgetControl>}
*/
component.widgetControls = {};
@ -1101,8 +1119,11 @@ wp.mediaWidgets = ( function( $ ) {
/**
* Handle widget being added or initialized for the first time at the widget-added event.
*
* @memberOf wp.mediaWidgets
*
* @param {jQuery.Event} event - Event.
* @param {jQuery} widgetContainer - Widget container element.
*
* @returns {void}
*/
component.handleWidgetAdded = function handleWidgetAdded( event, widgetContainer ) {
@ -1184,6 +1205,8 @@ wp.mediaWidgets = ( function( $ ) {
/**
* Setup widget in accessibility mode.
*
* @memberOf wp.mediaWidgets
*
* @returns {void}
*/
component.setupAccessibleMode = function setupAccessibleMode() {
@ -1233,8 +1256,11 @@ wp.mediaWidgets = ( function( $ ) {
* the widgets admin screen and also via the 'widget-synced' event when making
* a change to a widget in the customizer.
*
* @memberOf wp.mediaWidgets
*
* @param {jQuery.Event} event - Event.
* @param {jQuery} widgetContainer - Widget container element.
*
* @returns {void}
*/
component.handleWidgetUpdated = function handleWidgetUpdated( event, widgetContainer ) {
@ -1267,6 +1293,8 @@ wp.mediaWidgets = ( function( $ ) {
* When WordPress enqueues this script, it should have an inline script
* attached which calls wp.mediaWidgets.init().
*
* @memberOf wp.mediaWidgets
*
* @returns {void}
*/
component.init = function init() {

View file

@ -1,5 +1,13 @@
/**
* @output wp-admin/js/widgets/text-widgets.js
*/
/* global tinymce, switchEditors */
/* eslint consistent-this: [ "error", "control" ] */
/**
* @namespace wp.textWidgets
*/
wp.textWidgets = ( function( $ ) {
'use strict';
@ -8,14 +16,7 @@ wp.textWidgets = ( function( $ ) {
idBases: [ 'text' ]
};
/**
* Text widget control.
*
* @class TextWidgetControl
* @constructor
* @abstract
*/
component.TextWidgetControl = Backbone.View.extend({
component.TextWidgetControl = Backbone.View.extend(/** @lends wp.textWidgets.TextWidgetControl.prototype */{
/**
* View events.
@ -25,11 +26,16 @@ wp.textWidgets = ( function( $ ) {
events: {},
/**
* Initialize.
* Text widget control.
*
* @constructs wp.textWidgets.TextWidgetControl
* @augments Backbone.View
* @abstract
*
* @param {Object} options - Options.
* @param {jQuery} options.el - Control field container element.
* @param {jQuery} options.syncContainer - Container element where fields are synced for the server.
*
* @returns {void}
*/
initialize: function initialize( options ) {
@ -357,6 +363,8 @@ wp.textWidgets = ( function( $ ) {
/**
* Mapping of widget ID to instances of TextWidgetControl subclasses.
*
* @memberOf wp.textWidgets
*
* @type {Object.<string, wp.textWidgets.TextWidgetControl>}
*/
component.widgetControls = {};
@ -364,8 +372,11 @@ wp.textWidgets = ( function( $ ) {
/**
* Handle widget being added or initialized for the first time at the widget-added event.
*
* @memberOf wp.textWidgets
*
* @param {jQuery.Event} event - Event.
* @param {jQuery} widgetContainer - Widget container element.
*
* @returns {void}
*/
component.handleWidgetAdded = function handleWidgetAdded( event, widgetContainer ) {
@ -429,6 +440,8 @@ wp.textWidgets = ( function( $ ) {
/**
* Setup widget in accessibility mode.
*
* @memberOf wp.textWidgets
*
* @returns {void}
*/
component.setupAccessibleMode = function setupAccessibleMode() {
@ -467,6 +480,8 @@ wp.textWidgets = ( function( $ ) {
* the widgets admin screen and also via the 'widget-synced' event when making
* a change to a widget in the customizer.
*
* @memberOf wp.textWidgets
*
* @param {jQuery.Event} event - Event.
* @param {jQuery} widgetContainer - Widget container element.
* @returns {void}
@ -496,6 +511,8 @@ wp.textWidgets = ( function( $ ) {
* When WordPress enqueues this script, it should have an inline script
* attached which calls wp.textWidgets.init().
*
* @memberOf wp.textWidgets
*
* @returns {void}
*/
component.init = function init() {

View file

@ -1,10 +1,10 @@
/**
* Word or character counting functionality. Count words or characters in a provided text string.
*
* @summary Count words or characters in a text.
* Word or character counting functionality. Count words or characters in a
* provided text string.
*
* @namespace wp.utils
* @since 2.6.0
* @output wp-admin/js/word-count.js
*/
( function() {
@ -143,8 +143,6 @@
/**
* Counts the number of words (or other specified type) in the specified text.
*
* @summary Count the number of elements in a text.
*
* @since 2.6.0
* @memberof wp.utils.wordcounter
*

View file

@ -1,8 +1,9 @@
/**
* Distraction-Free Writing (wp-fullscreen) backward compatibility stub.
* Todo: remove at the end of 2016.
*
* Original was deprecated in 4.1, removed in 4.3.
* @deprecated 4.1
* @removed 4.3.
* @output wp-admin/js/wp-fullscreen-stub.js
*/
( function() {
var noop = function(){};

View file

@ -1,3 +1,9 @@
/**
* Generates the XHTML Friends Network 'rel' string from the inputs.
*
* @deprecated 3.5.0
* @output wp-admin/js/xfn.js
*/
jQuery( document ).ready(function( $ ) {
$( '#link_rel' ).prop( 'readonly', true );
$( '#linkxfndiv input' ).bind( 'click keyup', function() {