diff options
Diffstat (limited to 'src/js')
98 files changed, 1597 insertions, 1376 deletions
diff --git a/src/js/_enqueues/admin/comment.js b/src/js/_enqueues/admin/comment.js index f1fd2213a0..fd347d448b 100644 --- a/src/js/_enqueues/admin/comment.js +++ b/src/js/_enqueues/admin/comment.js @@ -70,7 +70,7 @@ jQuery(document).ready( function($) { * @param {Event} event The event object. * @return {void} */ - $timestampdiv.find('.save-timestamp').click( function( event ) { // crazyhorse - multiple ok cancels + $timestampdiv.find('.save-timestamp').click( function( event ) { // Crazyhorse - multiple OK cancels. var aa = $('#aa').val(), mm = $('#mm').val(), jj = $('#jj').val(), hh = $('#hh').val(), mn = $('#mn').val(), newD = new Date( aa, mm - 1, jj, hh, mn ); diff --git a/src/js/_enqueues/admin/common.js b/src/js/_enqueues/admin/common.js index 0541c8d0f2..75c77b3bac 100644 --- a/src/js/_enqueues/admin/common.js +++ b/src/js/_enqueues/admin/common.js @@ -168,7 +168,7 @@ window.validateForm = function( form ) { .length; }; -// stub for doing better warnings +// Stub for doing better warnings. /** * Shows message pop-up notice or confirmation message. * @@ -334,13 +334,13 @@ $('.contextual-help-tabs').delegate('a', 'click', function(e) { if ( link.is('.active a') ) return false; - // Links + // Links. $('.contextual-help-tabs .active').removeClass('active'); link.parent('li').addClass('active'); panel = $( link.attr('href') ); - // Panels + // Panels. $('.help-tab-content').not( panel ).removeClass('active').hide(); panel.addClass('active').show(); }); @@ -517,7 +517,7 @@ $document.ready( function() { $( '#collapse-button' ).on( 'click.collapse-menu', function() { var viewportWidth = getViewportWidth() || 961; - // reset any compensation for submenus near the bottom of the screen + // Reset any compensation for submenus near the bottom of the screen. $('#adminmenu div.wp-submenu').css('margin-top', ''); if ( viewportWidth < 960 ) { @@ -582,12 +582,12 @@ $document.ready( function() { menutop = $menuItem.offset().top; wintop = $window.scrollTop(); - maxtop = menutop - wintop - 30; // max = make the top of the sub almost touch admin bar + maxtop = menutop - wintop - 30; // max = make the top of the sub almost touch admin bar. - bottomOffset = menutop + $submenu.height() + 1; // Bottom offset of the menu - pageHeight = $wpwrap.height(); // Height of the entire page + bottomOffset = menutop + $submenu.height() + 1; // Bottom offset of the menu. + pageHeight = $wpwrap.height(); // Height of the entire page. adjustment = 60 + bottomOffset - pageHeight; - theFold = $window.height() + wintop - 50; // The fold + theFold = $window.height() + wintop - 50; // The fold. if ( theFold < ( bottomOffset - adjustment ) ) { adjustment = bottomOffset - theFold; @@ -604,8 +604,8 @@ $document.ready( function() { } } - if ( 'ontouchstart' in window || /IEMobile\/[1-9]/.test(navigator.userAgent) ) { // touch screen device - // iOS Safari works with touchstart, the rest work with click + if ( 'ontouchstart' in window || /IEMobile\/[1-9]/.test(navigator.userAgent) ) { // Touch screen device. + // iOS Safari works with touchstart, the rest work with click. mobileEvent = isIOS ? 'touchstart' : 'click'; /** @@ -639,9 +639,11 @@ $document.ready( function() { return; } - // Show the sub instead of following the link if: - // - the submenu is not open - // - the submenu is not shown inline or the menu is not folded + /* + * Show the sub instead of following the link if: + * - the submenu is not open. + * - the submenu is not shown inline or the menu is not folded. + */ if ( ! $menuItem.hasClass( 'opensub' ) && ( ! $menuItem.hasClass( 'wp-menu-open' ) || $menuItem.width() < 40 ) ) { event.preventDefault(); adjustSubmenu( $menuItem ); @@ -664,12 +666,12 @@ $document.ready( function() { $submenu = $menuItem.find( '.wp-submenu' ), top = parseInt( $submenu.css( 'top' ), 10 ); - if ( isNaN( top ) || top > -5 ) { // the submenu is visible + if ( isNaN( top ) || top > -5 ) { // The submenu is visible. return; } if ( $adminmenu.data( 'wp-responsive' ) ) { - // The menu is in responsive mode, bail + // The menu is in responsive mode, bail. return; } @@ -685,7 +687,7 @@ $document.ready( function() { */ out: function(){ if ( $adminmenu.data( 'wp-responsive' ) ) { - // The menu is in responsive mode, bail + // The menu is in responsive mode, bail. return; } @@ -705,7 +707,7 @@ $document.ready( function() { */ $adminmenu.on( 'focus.adminmenu', '.wp-submenu a', function( event ) { if ( $adminmenu.data( 'wp-responsive' ) ) { - // The menu is in responsive mode, bail + // The menu is in responsive mode, bail. return; } @@ -759,7 +761,7 @@ $document.ready( function() { $button = $( '<button type="button" class="notice-dismiss"><span class="screen-reader-text"></span></button>' ), btnText = commonL10n.dismiss || ''; - // Ensure plain text + // Ensure plain text. $button.find( '.screen-reader-text' ).text( btnText ); $button.on( 'click.wp-dismiss-notice', function( event ) { event.preventDefault(); @@ -776,7 +778,7 @@ $document.ready( function() { $document.on( 'wp-updates-notice-added wp-plugin-install-error wp-plugin-update-error wp-plugin-delete-error wp-theme-install-error wp-theme-delete-error', makeNoticesDismissible ); - // Init screen meta + // Init screen meta. screenMeta.init(); /** @@ -902,7 +904,7 @@ $document.ready( function() { } }, '.has-row-actions' ); - // Toggle list table rows on small screens + // Toggle list table rows on small screens. $( 'tbody' ).on( 'click', '.toggle-row', function() { $( this ).closest( 'tr' ).toggleClass( 'is-expanded' ); }); @@ -925,7 +927,7 @@ $document.ready( function() { // After pressing escape key (keyCode: 27), the tab key should tab out of the textarea. if ( e.keyCode == 27 ) { - // when pressing Escape: Opera 12 and 27 blur form fields, IE 8 clears them + // When pressing Escape: Opera 12 and 27 blur form fields, IE 8 clears them. e.preventDefault(); $(el).data('tab-out', true); return; @@ -1276,7 +1278,7 @@ $document.ready( function() { this.maybeDisableSortables = this.maybeDisableSortables.bind( this ); - // Modify functionality based on custom activate/deactivate event + // Modify functionality based on custom activate/deactivate event. $document.on( 'wp-responsive-activate.wp-responsive', function() { self.activate(); }).on( 'wp-responsive-deactivate.wp-responsive', function() { @@ -1289,7 +1291,7 @@ $document.ready( function() { $( '#wp-admin-bar-menu-toggle' ).on( 'click.wp-responsive', function( event ) { event.preventDefault(); - // close any open toolbar submenus. + // Close any open toolbar submenus. $adminbar.find( '.hover' ).removeClass( 'hover' ); $wpwrap.toggleClass( 'wp-responsive-open' ); diff --git a/src/js/_enqueues/admin/edit-comments.js b/src/js/_enqueues/admin/edit-comments.js index 4391d50fef..1a64268b6a 100644 --- a/src/js/_enqueues/admin/edit-comments.js +++ b/src/js/_enqueues/admin/edit-comments.js @@ -192,7 +192,7 @@ var getCount, updateCount, updateCountText, updatePending, updateApproved, var newTitle, regExMatch, titleCount, commentFrag; titleRegEx = titleRegEx || new RegExp( adminCommentsL10n.docTitleCommentsCount.replace( '%s', '\\([0-9' + thousandsSeparator + ']+\\)' ) + '?' ); - // count funcs operate on a $'d element + // Count funcs operate on a $'d element. titleDiv = titleDiv || $( '<div />' ); newTitle = adminTitle; @@ -256,7 +256,7 @@ var getCount, updateCount, updateCountText, updatePending, updateApproved, return; } - // cache selectors to not get dupes + // Cache selectors to not get dupes. pending = $( 'span.' + pendingClass, postSelector ); noPending = $( 'span.' + noClass, postSelector ); @@ -444,7 +444,7 @@ window.setCommentsList = function() { a.click(function( e ){ e.preventDefault(); - e.stopPropagation(); // ticket #35904 + e.stopPropagation(); // Ticket #35904. list.wpList.del(this); $('#undo-' + id).css( {backgroundColor:'#ceb'} ).fadeOut(350, function(){ $(this).remove(); @@ -491,17 +491,19 @@ window.setCommentsList = function() { unapproved = commentRow.hasClass( 'unapproved' ), spammed = commentRow.hasClass( 'spam' ), trashed = commentRow.hasClass( 'trash' ), - undoing = false; // ticket #35904 + undoing = false; // Ticket #35904. updateDashboardText( newTotal ); updateInModerationText( newTotal ); - // the order of these checks is important - // .unspam can also have .approve or .unapprove - // .untrash can also have .approve or .unapprove + /* + * The order of these checks is important. + * .unspam can also have .approve or .unapprove. + * .untrash can also have .approve or .unapprove. + */ if ( targetParent.is( 'span.undo' ) ) { - // the comment was spammed + // The comment was spammed. if ( targetParent.hasClass( 'unspam' ) ) { spamDiff = -1; @@ -513,7 +515,7 @@ window.setCommentsList = function() { pendingDiff = 1; } - // the comment was trashed + // The comment was trashed. } else if ( targetParent.hasClass( 'untrash' ) ) { trashDiff = -1; @@ -528,32 +530,32 @@ window.setCommentsList = function() { undoing = true; - // user clicked "Spam" + // User clicked "Spam". } else if ( targetParent.is( 'span.spam' ) ) { - // the comment is currently approved + // The comment is currently approved. if ( approved ) { approvedDiff = -1; - // the comment is currently pending + // The comment is currently pending. } else if ( unapproved ) { pendingDiff = -1; - // the comment was in the trash + // The comment was in the trash. } else if ( trashed ) { trashDiff = -1; } - // you can't spam an item on the spam screen + // You can't spam an item on the Spam screen. spamDiff = 1; - // user clicked "Unspam" + // User clicked "Unspam". } else if ( targetParent.is( 'span.unspam' ) ) { if ( approved ) { pendingDiff = 1; } else if ( unapproved ) { approvedDiff = 1; } else if ( trashed ) { - // the comment was previously approved + // The comment was previously approved. if ( targetParent.hasClass( 'approve' ) ) { approvedDiff = 1; - // the comment was previously pending + // The comment was previously pending. } else if ( targetParent.hasClass( 'unapprove' ) ) { pendingDiff = 1; } @@ -565,23 +567,23 @@ window.setCommentsList = function() { pendingDiff = 1; } } - // you can Unspam an item on the spam screen + // You can unspam an item on the Spam screen. spamDiff = -1; - // user clicked "Trash" + // User clicked "Trash". } else if ( targetParent.is( 'span.trash' ) ) { if ( approved ) { approvedDiff = -1; } else if ( unapproved ) { pendingDiff = -1; - // the comment was in the spam queue + // The comment was in the spam queue. } else if ( spammed ) { spamDiff = -1; } - // you can't trash an item on the trash screen + // You can't trash an item on the Trash screen. trashDiff = 1; - // user clicked "Restore" + // User clicked "Restore". } else if ( targetParent.is( 'span.untrash' ) ) { if ( approved ) { pendingDiff = 1; @@ -594,21 +596,21 @@ window.setCommentsList = function() { pendingDiff = 1; } } - // you can't go from trash to spam - // you can untrash on the trash screen + // You can't go from Trash to Spam. + // You can untrash on the Trash screen. trashDiff = -1; - // User clicked "Approve" + // User clicked "Approve". } else if ( targetParent.is( 'span.approve:not(.unspam):not(.untrash)' ) ) { approvedDiff = 1; pendingDiff = -1; - // User clicked "Unapprove" + // User clicked "Unapprove". } else if ( targetParent.is( 'span.unapprove:not(.unspam):not(.untrash)' ) ) { approvedDiff = -1; pendingDiff = 1; - // User clicked "Delete Permanently" + // User clicked "Delete Permanently". } else if ( targetParent.is( 'span.delete' ) ) { if ( spammed ) { spamDiff = -1; @@ -713,17 +715,17 @@ window.setCommentsList = function() { if (ev) { theExtraList.empty(); - args.number = Math.min(8, per_page); // see WP_Comments_List_Table::prepare_items() @ class-wp-comments-list-table.php + args.number = Math.min(8, per_page); // See WP_Comments_List_Table::prepare_items() in class-wp-comments-list-table.php. } else { args.number = 1; - args.offset = Math.min(8, per_page) - 1; // fetch only the next item on the extra list + args.offset = Math.min(8, per_page) - 1; // Fetch only the next item on the extra list. } args.no_placeholder = true; args.paged ++; - // $.query.get() needs some correction to be sent into an ajax request + // $.query.get() needs some correction to be sent into an Ajax request. if ( true === args.comment_type ) args.comment_type = ''; @@ -781,9 +783,9 @@ window.commentReply = { /** * Initializes the comment reply functionality. * - * @memberof commentReply - * * @since 2.7.0 + * + * @memberof commentReply */ init : function() { var row = $('#replyrow'); @@ -798,7 +800,7 @@ window.commentReply = { } }); - // add events + // Add events. $('#the-comment-list .column-comment > p').dblclick(function(){ commentReply.toggle($(this).parent()); }); @@ -911,7 +913,7 @@ window.commentReply = { .focus(); } - // reset the Quicktags buttons + // Reset the Quicktags buttons. if ( typeof QTags != 'undefined' ) QTags.closeAllTags('replycontent'); @@ -1029,7 +1031,7 @@ window.commentReply = { $('#replycontent').focus().keyup(function(e){ if ( e.which == 27 ) - commentReply.revert(); // close on Escape + commentReply.revert(); // Close on Escape. }); }, 600); @@ -1130,7 +1132,7 @@ window.commentReply = { updateCountText( 'span.all-count', 1 ); } - c = $.trim(r.data); // Trim leading whitespaces + c = $.trim(r.data); // Trim leading whitespaces. $(c).hide(); $('#replyrow').after(c); diff --git a/src/js/_enqueues/admin/inline-edit-post.js b/src/js/_enqueues/admin/inline-edit-post.js index 85cc742844..70a57e1200 100644 --- a/src/js/_enqueues/admin/inline-edit-post.js +++ b/src/js/_enqueues/admin/inline-edit-post.js @@ -29,41 +29,42 @@ window.wp = window.wp || {}; /** * Initializes the inline and bulk post editor. * - * Binds event handlers to the escape key to close the inline 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 * editing. Adds event handler to bulk edit. * - * @memberof inlineEditPost * @since 2.7.0 * + * @memberof inlineEditPost + * * @return {void} */ init : function(){ var t = this, qeRow = $('#inline-edit'), bulkRow = $('#bulk-edit'); t.type = $('table.widefat').hasClass('pages') ? 'page' : 'post'; - // Post id prefix. + // Post ID prefix. t.what = '#post-'; /** - * Binds the escape key to revert the changes and close the quick editor. + * Binds the Escape key to revert the changes and close the quick editor. * * @return {boolean} The result of revert. */ qeRow.keyup(function(e){ - // Revert changes if escape key is pressed. + // Revert changes if Escape key is pressed. if ( e.which === 27 ) { return inlineEditPost.revert(); } }); /** - * Binds the escape key to revert the changes and close the bulk editor. + * Binds the Escape key to revert the changes and close the bulk editor. * * @return {boolean} The result of revert. */ bulkRow.keyup(function(e){ - // Revert changes if escape key is pressed. + // Revert changes if Escape key is pressed. if ( e.which === 27 ) { return inlineEditPost.revert(); } @@ -88,7 +89,7 @@ window.wp = window.wp || {}; }); /** - * 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. * * @return {boolean} The result of save. */ @@ -157,9 +158,10 @@ window.wp = window.wp || {}; * Toggles the quick edit window, hiding it when it's active and showing it when * inactive. * - * @memberof inlineEditPost * @since 2.7.0 * + * @memberof inlineEditPost + * * @param {Object} el Element within a post table row. */ toggle : function(el){ @@ -170,8 +172,9 @@ window.wp = window.wp || {}; /** * Creates the bulk editor row to edit multiple posts at once. * - * @memberof inlineEditPost * @since 2.7.0 + * + * @memberof inlineEditPost */ setBulk : function(){ var te = '', type = this.type, c = true; @@ -242,9 +245,10 @@ window.wp = window.wp || {}; /** * Creates a quick edit window for the post that has been clicked. * - * @memberof inlineEditPost * @since 2.7.0 * + * @memberof inlineEditPost + * * @param {number|Object} id The id of the clicked post or an element within a post * table row. * @return {boolean} Always returns false at the end of execution. @@ -409,7 +413,7 @@ window.wp = window.wp || {}; fields = $('#edit-'+id).find(':input').serialize(); params = fields + '&' + $.param(params); - // Make ajax request. + // Make Ajax request. $.post( ajaxurl, params, function(r) { var $errorNotice = $( '#edit-' + id + ' .inline-edit-save .notice-error' ), @@ -450,9 +454,10 @@ window.wp = window.wp || {}; /** * Hides and empties the Quick Edit and/or Bulk Edit windows. * - * @memberof inlineEditPost * @since 2.7.0 * + * @memberof inlineEditPost + * * @return {boolean} Always returns false. */ revert : function(){ @@ -494,9 +499,10 @@ window.wp = window.wp || {}; * 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 * + * @memberof inlineEditPost + * * @param {Object} o DOM row object to get the id for. * @return {string} The post id extracted from the table row in the object. */ @@ -546,7 +552,7 @@ $( document ).on( 'heartbeat-tick.wp-check-locked-posts', function( e, data ) { } }).ready( function() { - // Set the heartbeat interval to 15 sec. + // Set the heartbeat interval to 15 seconds. if ( typeof wp !== 'undefined' && wp.heartbeat ) { wp.heartbeat.interval( 15 ); } diff --git a/src/js/_enqueues/admin/inline-edit-tax.js b/src/js/_enqueues/admin/inline-edit-tax.js index dcaa8d2bdc..5a3cad885c 100644 --- a/src/js/_enqueues/admin/inline-edit-tax.js +++ b/src/js/_enqueues/admin/inline-edit-tax.js @@ -43,12 +43,12 @@ window.inlineEditTax = { }); /** - * 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. */ row.keyup( function( e ) { - // 27 = [escape] + // 27 = [Escape]. if ( e.which === 27 ) { return inlineEditTax.revert(); } @@ -69,10 +69,10 @@ window.inlineEditTax = { }); /** - * 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] + // 13 = [Enter]. if ( e.which === 13 ) { return inlineEditTax.save( this ); } @@ -184,7 +184,7 @@ window.inlineEditTax = { fields = $('#edit-'+id).find(':input').serialize(); params = fields + '&' + $.param(params); - // Do the ajax request to save the data to the server. + // Do the Ajax request to save the data to the server. $.post( ajaxurl, params, /** * Handles the response from the server diff --git a/src/js/_enqueues/admin/link.js b/src/js/_enqueues/admin/link.js index 076d07c44f..02698e5eea 100644 --- a/src/js/_enqueues/admin/link.js +++ b/src/js/_enqueues/admin/link.js @@ -9,7 +9,7 @@ jQuery(document).ready( function($) { var newCat, noSyncChecks = false, syncChecks, catAddAfter; $('#link_name').focus(); - // postboxes + // Postboxes. postboxes.add_postbox_toggles('link'); /** @@ -33,7 +33,7 @@ jQuery(document).ready( function($) { if ( getUserSetting('cats') ) $('#category-tabs a[href="#categories-pop"]').click(); - // Ajax Cat + // Ajax Cat. newCat = $('#newcat').one( 'focus', function() { $(this).val( '' ).removeClass( 'form-input-tip' ); } ); /** diff --git a/src/js/_enqueues/admin/media-upload.js b/src/js/_enqueues/admin/media-upload.js index 3f45e2ef80..1a28f36d04 100644 --- a/src/js/_enqueues/admin/media-upload.js +++ b/src/js/_enqueues/admin/media-upload.js @@ -43,16 +43,16 @@ window.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 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. + // If neither the TinyMCE editor and the quick tags are available, + // add the HTML to the current active editor. document.getElementById( wpActiveEditor ).value += html; } diff --git a/src/js/_enqueues/admin/plugin-install.js b/src/js/_enqueues/admin/plugin-install.js index b6cd1d74e4..f9c2be395d 100644 --- a/src/js/_enqueues/admin/plugin-install.js +++ b/src/js/_enqueues/admin/plugin-install.js @@ -183,11 +183,12 @@ jQuery( document ).ready( function( $ ) { var tab = $( this ).attr( 'name' ); event.preventDefault(); - // Flip the tab + // Flip the tab. $( '#plugin-information-tabs a.current' ).removeClass( 'current' ); $( this ).addClass( 'current' ); - // Only show the fyi box in the description section, on smaller screen, where it's otherwise always displayed at the top. + // Only show the fyi box in the description section, on smaller screen, + // where it's otherwise always displayed at the top. if ( 'description' !== tab && $( window ).width() < 772 ) { $( '#plugin-information-content' ).find( '.fyi' ).hide(); } else { diff --git a/src/js/_enqueues/admin/post.js b/src/js/_enqueues/admin/post.js index d2e956b4e4..cc7cab1a72 100644 --- a/src/js/_enqueues/admin/post.js +++ b/src/js/_enqueues/admin/post.js @@ -91,9 +91,9 @@ window.wp = window.wp || {}; /** * Load the next batch of comments. * - * @param {int} total Total number of comments to load. - * * @memberof commentsBox + * + * @param {int} total Total number of comments to load. */ load: function(total){ this.st = jQuery('#the-comment-list tr.comment:visible').length; @@ -309,24 +309,24 @@ jQuery(document).ready( function($) { // Post locks: contain focus inside the dialog. If the dialog is shown, focus the first item. $('#post-lock-dialog .notification-dialog').on( 'keydown', function(e) { - // Don't do anything when [tab] is pressed. + // Don't do anything when [Tab] is pressed. if ( e.which != 9 ) return; var target = $(e.target); - // [shift] + [tab] on first tab cycles back to last tab. + // [Shift] + [Tab] on first tab cycles back to last tab. if ( target.hasClass('wp-tab-first') && e.shiftKey ) { $(this).find('.wp-tab-last').focus(); e.preventDefault(); - // [tab] on last tab cycles back to first tab. + // [Tab] on last tab cycles back to first tab. } else if ( target.hasClass('wp-tab-last') && ! e.shiftKey ) { $(this).find('.wp-tab-first').focus(); e.preventDefault(); } }).filter(':visible').find('.wp-tab-first').focus(); - // Set the heartbeat interval to 15 sec. if post lock dialogs are enabled. + // Set the heartbeat interval to 15 seconds if post lock dialogs are enabled. if ( wp.heartbeat && $('#post-lock-dialog').length ) { wp.heartbeat.interval( 15 ); } @@ -385,7 +385,7 @@ jQuery(document).ready( function($) { }); }); - // Submit the form saving a draft or an autosave, and show a preview in a new tab + // Submit the form saving a draft or an autosave, and show a preview in a new tab. $('#post-preview').on( 'click.post-preview', function( event ) { var $this = $(this), $form = $('form#post'), @@ -534,7 +534,7 @@ jQuery(document).ready( function($) { }); }); - // Multiple Taxonomies. + // Multiple taxonomies. if ( $('#tagsdiv-post_tag').length ) { window.tagBox && window.tagBox.init(); } else { @@ -559,7 +559,7 @@ jQuery(document).ready( function($) { settingName = 'cats'; } - // TODO: move to jQuery 1.3+, support for multiple hierarchical taxonomies, see wp-lists.js + // @todo Move to jQuery 1.3+, support for multiple hierarchical taxonomies, see wp-lists.js. $('a', '#' + taxonomy + '-tabs').click( function( e ) { e.preventDefault(); var t = $(this).attr('href'); @@ -581,7 +581,7 @@ jQuery(document).ready( function($) { $( this ).val( '' ).removeClass( 'form-input-tip' ); }); - // On [enter] submit the taxonomy. + // On [Enter] submit the taxonomy. $('#new' + taxonomy).keypress( function(event){ if( 13 === event.keyCode ) { event.preventDefault(); @@ -654,7 +654,7 @@ jQuery(document).ready( function($) { $('#in-' + taxonomy + '-' + id + ', #in-popular-' + taxonomy + '-' + id).prop( 'checked', c ); }); - }); // end cats + }); // End cats. // Custom Fields postbox. if ( $('#postcustom').length ) { @@ -796,7 +796,8 @@ jQuery(document).ready( function($) { // Update "Status:" to currently selected status. $('#post-status-display').text( - wp.sanitize.stripTagsAndEncodeText( $('option:selected', postStatus).text() ) // Remove any potential tags from post status text. + // Remove any potential tags from post status text. + wp.sanitize.stripTagsAndEncodeText( $('option:selected', postStatus).text() ) ); // Show or hide the "Save Draft" button. @@ -838,7 +839,7 @@ jQuery(document).ready( function($) { }); // Set the selected visibility as current. - $postVisibilitySelect.find('.save-post-visibility').click( function( event ) { // crazyhorse - multiple ok cancels + $postVisibilitySelect.find('.save-post-visibility').click( function( event ) { // Crazyhorse - multiple OK cancels. $postVisibilitySelect.slideUp('fast'); $('#visibility .edit-visibility').show().focus(); updateText(); @@ -886,7 +887,7 @@ jQuery(document).ready( function($) { }); // Save the changed timestamp. - $timestampdiv.find('.save-timestamp').click( function( event ) { // crazyhorse - multiple ok cancels + $timestampdiv.find('.save-timestamp').click( function( event ) { // Crazyhorse - multiple OK cancels. if ( updateText() ) { $timestampdiv.slideUp('fast'); $timestampdiv.siblings('a.edit-timestamp').show().focus(); @@ -1023,12 +1024,12 @@ jQuery(document).ready( function($) { $el.html( '<input type="text" id="new-post-slug" value="' + slug_value + '" autocomplete="off" />' ).children( 'input' ).keydown( function( e ) { var key = e.which; - // On [enter], just save the new slug, don't save the post. + // On [Enter], just save the new slug, don't save the post. if ( 13 === key ) { e.preventDefault(); buttons.children( '.save' ).click(); } - // On [esc] cancel the editing. + // On [Esc] cancel the editing. if ( 27 === key ) { buttons.children( '.cancel' ).click(); } @@ -1173,7 +1174,7 @@ jQuery(document).ready( function($) { } }); - // When changing page template, change the editor body class + // When changing page template, change the editor body class. $( '#page_template' ).on( 'change.set-editor-class', function() { var editor, body, pageTemplate = $( this ).val() || ''; @@ -1191,9 +1192,9 @@ jQuery(document).ready( function($) { } - // Save on pressing [ctrl]/[command] + [s] in the Text editor. + // Save on pressing [Ctrl]/[Command] + [S] in the Text editor. $textarea.on( 'keydown.wp-autosave', function( event ) { - // Key [s] has code 83. + // Key [S] has code 83. if ( event.which === 83 ) { if ( event.shiftKey || event.altKey || ( isMac && ( ! event.metaKey || event.ctrlKey ) ) || ( ! isMac && ! event.ctrlKey ) ) { return; diff --git a/src/js/_enqueues/admin/postbox.js b/src/js/_enqueues/admin/postbox.js index 9789518b65..ff144777f9 100644 --- a/src/js/_enqueues/admin/postbox.js +++ b/src/js/_enqueues/admin/postbox.js @@ -32,7 +32,9 @@ * if the postbox has been closed. * * @since 4.4.0 + * * @memberof postboxes + * * @fires postboxes#postbox-toggled * * @return {void} @@ -90,6 +92,7 @@ * Adds event handlers to all postboxes and screen option on the current page. * * @since 2.7.0 + * * @memberof postboxes * * @param {string} page The page we are currently on. @@ -190,6 +193,7 @@ * Initializes all the postboxes, mainly their sortable behaviour. * * @since 2.7.0 + * * @memberof postboxes * * @param {string} page The page we are currently on. @@ -272,6 +276,7 @@ * hidden postboxes. * * @since 2.7.0 + * * @memberof postboxes * * @param {string} page The page we are currently on. @@ -303,6 +308,7 @@ * Sends a list of all postboxes inside a sortable area to the server. * * @since 2.8.0 + * * @memberof postboxes * * @param {string} page The page we are currently on. @@ -333,9 +339,10 @@ * present. * * @since 3.3.0 - * @memberof postboxes * @access private * + * @memberof postboxes + * * @return {void} */ _mark_area : function() { @@ -365,9 +372,11 @@ * Changes the amount of columns on the post edit page. * * @since 3.3.0 + * @access private + * * @memberof postboxes + * * @fires postboxes#postboxes-columnchange - * @access private * * @param {number} n The amount of columns to divide the post edit page in. * @return {void} @@ -395,9 +404,10 @@ * orientation of the browser. * * @since 3.3.0 - * @memberof postboxes * @access private * + * @memberof postboxes + * * @return {void} */ _pb_change : function() { @@ -425,19 +435,20 @@ /** * @since 2.7.0 - * @memberof postboxes * @access public + * * @property {Function|boolean} pbshow A callback that is called when a postbox * is opened. + * @memberof postboxes */ pbshow : false, /** * @since 2.7.0 - * @memberof postboxes * @access public * @property {Function|boolean} pbhide A callback that is called when a postbox * is closed. + * @memberof postboxes */ pbhide : false }; diff --git a/src/js/_enqueues/admin/privacy-tools.js b/src/js/_enqueues/admin/privacy-tools.js index 802ec88f4b..90b3a49233 100644 --- a/src/js/_enqueues/admin/privacy-tools.js +++ b/src/js/_enqueues/admin/privacy-tools.js @@ -4,7 +4,7 @@ * @output wp-admin/js/privacy-tools.js */ -// Privacy request action handling +// Privacy request action handling. jQuery( document ).ready( function( $ ) { var strings = window.privacyToolsL10n || {}; @@ -111,7 +111,7 @@ jQuery( document ).ready( function( $ ) { if ( ! response.success ) { - // e.g. invalid request ID + // e.g. invalid request ID. onExportFailure( response.data ); return; } @@ -127,12 +127,12 @@ jQuery( document ).ready( function( $ ) { } }).fail( function( jqxhr, textStatus, error ) { - // e.g. Nonce failure + // e.g. Nonce failure. onExportFailure( error ); }); } - // And now, let's begin + // And now, let's begin. setActionState( $action, 'export-personal-data-processing' ); doNextExport( 1, 1 ); }); @@ -224,7 +224,7 @@ jQuery( document ).ready( function( $ ) { }); } - // And now, let's begin + // And now, let's begin. setActionState( $action, 'remove-personal-data-processing' ); doNextErasure( 1, 1 ); diff --git a/src/js/_enqueues/admin/site-health.js b/src/js/_enqueues/admin/site-health.js index 015b06c5ec..b0f24c7121 100644 --- a/src/js/_enqueues/admin/site-health.js +++ b/src/js/_enqueues/admin/site-health.js @@ -259,9 +259,11 @@ jQuery( document ).ready( function( $ ) { RecalculateProgression(); if ( delay > 3000 ) { - // We have announced that we're waiting. - // Announce that we're ready after giving at least 3 seconds for the first announcement - // to be read out, or the two may collide. + /* + * We have announced that we're waiting. + * Announce that we're ready after giving at least 3 seconds + * for the first announcement to be read out, or the two may collide. + */ if ( delay > 6000 ) { delay = 0; } else { diff --git a/src/js/_enqueues/admin/tags-box.js b/src/js/_enqueues/admin/tags-box.js index c4676f263e..40105e2d38 100644 --- a/src/js/_enqueues/admin/tags-box.js +++ b/src/js/_enqueues/admin/tags-box.js @@ -52,6 +52,7 @@ * 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. @@ -76,6 +77,7 @@ * Parses tags and makes them editable. * * @since 2.9.0 + * * @memberOf tagBox * * @param {Object} el The tag element to retrieve the ID from. @@ -110,6 +112,7 @@ * Creates clickable links, buttons and fields for adding or editing tags. * * @since 2.9.0 + * * @memberOf tagBox * * @param {Object} el The container HTML element. @@ -134,6 +137,7 @@ * 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. @@ -209,6 +213,7 @@ * Also ensures that the quick links are properly generated. * * @since 2.9.0 + * * @memberOf tagBox * * @param {Object} el The container HTML element. @@ -262,6 +267,7 @@ * tagcloud. Clicking a tag will add it. * * @since 2.9.0 + * * @memberOf tagBox * * @param {string} id The ID to extract the taxonomy from. @@ -350,6 +356,7 @@ * retrieval of tag suggestions. * * @since 2.9.0 + * * @memberOf tagBox * * @return {void} diff --git a/src/js/_enqueues/admin/tags-suggest.js b/src/js/_enqueues/admin/tags-suggest.js index 50075a654b..c5ccf16eaf 100644 --- a/src/js/_enqueues/admin/tags-suggest.js +++ b/src/js/_enqueues/admin/tags-suggest.js @@ -89,8 +89,8 @@ focus: function( event, ui ) { $element.attr( 'aria-activedescendant', 'wp-tags-autocomplete-' + ui.item.id ); - // Don't empty the input field when using the arrow keys to - // highlight items. See api.jqueryui.com/autocomplete/#event-focus + // Don't empty the input field when using the arrow keys + // to highlight items. See api.jqueryui.com/autocomplete/#event-focus event.preventDefault(); }, select: function( event, ui ) { @@ -113,7 +113,7 @@ window.tagBox.flushTags( $( this ).closest( '.tagsdiv' ) ); } - // Do not close Quick Edit / Bulk Edit + // Do not close Quick Edit / Bulk Edit. event.preventDefault(); event.stopPropagation(); } @@ -175,14 +175,16 @@ .attr( 'role', 'listbox' ) .removeAttr( 'tabindex' ) // Remove the `tabindex=0` attribute added by jQuery UI. - // Looks like Safari and VoiceOver need an `aria-selected` attribute. See ticket #33301. - // The `menufocus` and `menublur` events are the same events used to add and remove - // the `ui-state-focus` CSS class on the menu items. See jQuery UI Menu Widget. + /* + * Looks like Safari and VoiceOver need an `aria-selected` attribute. See ticket #33301. + * The `menufocus` and `menublur` events are the same events used to add and remove + * the `ui-state-focus` CSS class on the menu items. See jQuery UI Menu Widget. + */ .on( 'menufocus', function( event, ui ) { ui.item.attr( 'aria-selected', 'true' ); }) .on( 'menublur', function() { - // The `menublur` event returns an object where the item is `null` + // The `menublur` event returns an object where the item is `null`, // so we need to find the active item with other means. $( this ).find( '[aria-selected="true"]' ).removeAttr( 'aria-selected' ); }); diff --git a/src/js/_enqueues/admin/tags.js b/src/js/_enqueues/admin/tags.js index df5b3f7e5d..d87b98174b 100644 --- a/src/js/_enqueues/admin/tags.js +++ b/src/js/_enqueues/admin/tags.js @@ -132,10 +132,14 @@ jQuery(document).ready(function($) { parent = form.find( 'select#parent' ).val(); - if ( parent > 0 && $('#tag-' + parent ).length > 0 ) // If the parent exists on this page, insert it below. Else insert it at the top of the list. - $( '.tags #tag-' + parent ).after( res.responses[0].supplemental.noparents ); // As the parent exists, Insert the version with - - - prefixed - else - $( '.tags' ).prepend( res.responses[0].supplemental.parents ); // As the parent is not visible, Insert the version with Parent - Child - ThisTerm + // If the parent exists on this page, insert it below. Else insert it at the top of the list. + if ( parent > 0 && $('#tag-' + parent ).length > 0 ) { + // As the parent exists, insert the version with - - - prefixed. + $( '.tags #tag-' + parent ).after( res.responses[0].supplemental.noparents ); + } else { + // As the parent is not visible, insert the version with Parent - Child - ThisTerm. + $( '.tags' ).prepend( res.responses[0].supplemental.parents ); + } $('.tags .no-items').remove(); @@ -143,7 +147,7 @@ jQuery(document).ready(function($) { // Parents field exists, Add new term to the list. term = res.responses[1].supplemental; - // Create an indent for the Parent field + // Create an indent for the Parent field. indent = ''; for ( i = 0; i < res.responses[1].position; i++ ) indent += ' '; diff --git a/src/js/_enqueues/admin/user-profile.js b/src/js/_enqueues/admin/user-profile.js index f737dde255..ff4830242c 100644 --- a/src/js/_enqueues/admin/user-profile.js +++ b/src/js/_enqueues/admin/user-profile.js @@ -196,7 +196,7 @@ resetToggle( false ); if ( $pass1Row.closest( 'form' ).is( '#your-profile' ) ) { - // Clear password field to prevent update + // Clear password field to prevent update. $pass1.val( '' ).trigger( 'pwupdate' ); $submitButtons.prop( 'disabled', false ); } @@ -342,7 +342,7 @@ $this.siblings( '.selected' ).removeClass( 'selected' ); $this.addClass( 'selected' ).find( 'input[type="radio"]' ).prop( 'checked', true ); - // Set color scheme + // Set color scheme. if ( user_id === current_user_id ) { // Load the colors stylesheet. // The default color scheme won't have one, so we'll need to create an element. @@ -351,7 +351,7 @@ } $stylesheet.attr( 'href', $this.children( '.css_url' ).val() ); - // repaint icons + // Repaint icons. if ( typeof wp !== 'undefined' && wp.svgPainter ) { try { colors = $.parseJSON( $this.children( '.icon_colors' ).val() ); @@ -363,7 +363,7 @@ } } - // update user option + // Update user option. $.post( ajaxurl, { action: 'save-user-color-scheme', color_scheme: $this.children( 'input[name="admin_color"]' ).val(), diff --git a/src/js/_enqueues/admin/widgets.js b/src/js/_enqueues/admin/widgets.js index 00ae62dbae..3d72db74e2 100644 --- a/src/js/_enqueues/admin/widgets.js +++ b/src/js/_enqueues/admin/widgets.js @@ -222,9 +222,9 @@ window.wpWidgets = { the_id = this.id; if ( chooser.length ) { - // Hide the chooser and move it out of the widget + // Hide the chooser and move it out of the widget. $( '#wpbody-content' ).append( chooser.hide() ); - // Delete the cloned chooser from the drag helper + // Delete the cloned chooser from the drag helper. ui.helper.find('.widgets-chooser').remove(); self.clearWidgetSelection(); } @@ -321,7 +321,7 @@ window.wpWidgets = { wpWidgets.hoveredSidebar = null; if ( $widget.hasClass('deleting') ) { - wpWidgets.save( $widget, 1, 0, 1 ); // delete widget + wpWidgets.save( $widget, 1, 0, 1 ); // Delete widget. $widget.remove(); return; } @@ -363,7 +363,7 @@ window.wpWidgets = { $children = $sidebar.children('.widget'); - // Make sure the dropped widget is at the top + // Make sure the dropped widget is at the top. if ( $children.length > 1 ) { child = $children.get(0); item = $widget.get(0); @@ -386,14 +386,14 @@ window.wpWidgets = { }, deactivate: function() { - // Remove all min-height added on "start" + // Remove all min-height added on "start". $(this).css( 'min-height', '' ).parent().removeClass( 'widget-hover' ); }, receive: function( event, ui ) { var $sender = $( ui.sender ); - // Don't add more widgets to orphaned sidebars + // Don't add more widgets to orphaned sidebars. if ( this.id.indexOf('orphaned_widgets') > -1 ) { $sender.sortable('cancel'); return; @@ -431,7 +431,7 @@ window.wpWidgets = { } }); - // Area Chooser + // Area Chooser. $( '#widgets-right .widgets-holder-wrap' ).each( function( index, element ) { var $element = $( element ), name = $element.find( '.sidebar-name h2' ).text(), @@ -465,7 +465,7 @@ window.wpWidgets = { toggleButton.attr( 'aria-expanded', 'false' ); self.closeChooser(); } else { - // Open the chooser + // Open the chooser. self.clearWidgetSelection(); $( '#widgets-left' ).addClass( 'chooser' ); // Add CSS class and insert the chooser after the widget description. @@ -486,7 +486,7 @@ window.wpWidgets = { } }); - // Add event handlers + // Add event handlers. chooser.on( 'click.widgets-chooser', function( event ) { var $target = $( event.target ); @@ -662,7 +662,7 @@ window.wpWidgets = { add = widget.find( 'input.add_new' ).val(); n = widget.find( 'input.multi_number' ).val(); - // Remove the cloned chooser from the widget + // Remove the cloned chooser from the widget. widget.find('.widgets-chooser').remove(); if ( 'multi' === add ) { @@ -689,7 +689,7 @@ window.wpWidgets = { sidebar.sortable('refresh'); wpWidgets.save( widget, 0, 0, 1 ); - // No longer "new" widget + // No longer "new" widget. widget.find( 'input.add_new' ).val(''); $document.trigger( 'widget-added', [ widget ] ); diff --git a/src/js/_enqueues/lib/accordion.js b/src/js/_enqueues/lib/accordion.js index 0bec1ce514..7eacbec966 100644 --- a/src/js/_enqueues/lib/accordion.js +++ b/src/js/_enqueues/lib/accordion.js @@ -35,11 +35,11 @@ // Expand/Collapse accordion sections on click. $( '.accordion-container' ).on( 'click keydown', '.accordion-section-title', function( e ) { - if ( e.type === 'keydown' && 13 !== e.which ) { // "return" key + if ( e.type === 'keydown' && 13 !== e.which ) { // "Return" key. return; } - e.preventDefault(); // Keep this AFTER the key filter above + e.preventDefault(); // Keep this AFTER the key filter above. accordionSwitch( $( this ) ); }); @@ -80,7 +80,7 @@ section.toggleClass( 'open' ); } - // We have to wait for the animations to finish + // We have to wait for the animations to finish. setTimeout(function(){ container.removeClass( 'opening' ); }, 150); diff --git a/src/js/_enqueues/lib/admin-bar.js b/src/js/_enqueues/lib/admin-bar.js index 3e4292f36a..537df2d98f 100644 --- a/src/js/_enqueues/lib/admin-bar.js +++ b/src/js/_enqueues/lib/admin-bar.js @@ -264,7 +264,7 @@ return; } - // (Old) IE doesn't support preventDefault, and does support returnValue + // (Old) IE doesn't support preventDefault, and does support returnValue. if ( event.preventDefault ) { event.preventDefault(); } @@ -451,7 +451,7 @@ }; } - // Get the closest matching elent + // Get the closest matching elent. for ( ; el && el !== document; el = el.parentNode ) { if ( el.matches( selector ) ) { return el; diff --git a/src/js/_enqueues/lib/ajax-response.js b/src/js/_enqueues/lib/ajax-response.js index fd71ff3702..f2eedf3732 100644 --- a/src/js/_enqueues/lib/ajax-response.js +++ b/src/js/_enqueues/lib/ajax-response.js @@ -17,7 +17,7 @@ window.wpAjax = jQuery.extend( { } return r; }, - parseAjaxResponse: function( x, r, e ) { // 1 = good, 0 = strange (bad data?), -1 = you lack permission + parseAjaxResponse: function( x, r, e ) { // 1 = good, 0 = strange (bad data?), -1 = you lack permission. var parsed = {}, re = jQuery('#' + r).empty(), err = ''; if ( x && typeof x == 'object' && x.getElementsByTagName('wp_ajax') ) { @@ -64,7 +64,7 @@ window.wpAjax = jQuery.extend( { } }, wpAjax || { noPerm: 'Sorry, you are not allowed to do that.', broken: 'Something went wrong.' } ); -// Basic form validation +// Basic form validation. jQuery(document).ready( function($){ $('form.validate').submit( function() { return wpAjax.validateForm( $(this) ); } ); }); diff --git a/src/js/_enqueues/lib/auth-check.js b/src/js/_enqueues/lib/auth-check.js index 158b6e1750..ef6d861de0 100644 --- a/src/js/_enqueues/lib/auth-check.js +++ b/src/js/_enqueues/lib/auth-check.js @@ -51,8 +51,8 @@ else parent.css( 'max-height', height + 40 + 'px' ); } else if ( ! body || ! body.length ) { - // Catch "silent" iframe origin exceptions in WebKit after another page is - // loaded in the iframe. + // Catch "silent" iframe origin exceptions in WebKit + // after another page is loaded in the iframe. wrap.addClass('fallback'); parent.css( 'max-height', '' ); form.remove(); @@ -68,9 +68,11 @@ if ( frame ) { frame.focus(); - // WebKit doesn't throw an error if the iframe fails to load because of - // "X-Frame-Options: DENY" header. - // Wait for 10 sec. and switch to the fallback text. + /* + * WebKit doesn't throw an error if the iframe fails to load + * because of "X-Frame-Options: DENY" header. + * Wait for 10 seconds and switch to the fallback text. + */ setTimeout( function() { if ( ! loaded ) { wrap.addClass('fallback'); @@ -92,8 +94,8 @@ function hide() { $(window).off( 'beforeunload.wp-auth-check' ); - // When on the Edit Post screen, speed up heartbeat after the user logs in to - // quickly refresh nonces. + // When on the Edit Post screen, speed up heartbeat + // after the user logs in to quickly refresh nonces. if ( typeof adminpage !== 'undefined' && ( adminpage === 'post-php' || adminpage === 'post-new-php' ) && typeof wp !== 'undefined' && wp.heartbeat ) { diff --git a/src/js/_enqueues/lib/color-picker.js b/src/js/_enqueues/lib/color-picker.js index 0a99ae00cc..18f2bc26dc 100644 --- a/src/js/_enqueues/lib/color-picker.js +++ b/src/js/_enqueues/lib/color-picker.js @@ -36,7 +36,6 @@ * Creates a color picker that only allows you to adjust the hue. * * @since 3.5.0 - * * @access private * * @return {void} @@ -80,7 +79,6 @@ * Creates the color picker, sets default values, css classes and wraps it all in HTML. * * @since 3.5.0 - * * @access private * * @return {void} @@ -209,7 +207,6 @@ * Binds event listeners to the color picker. * * @since 3.5.0 - * * @access private * * @return {void} diff --git a/src/js/_enqueues/lib/comment-reply.js b/src/js/_enqueues/lib/comment-reply.js index ea973f41e8..1ba9498f11 100644 --- a/src/js/_enqueues/lib/comment-reply.js +++ b/src/js/_enqueues/lib/comment-reply.js @@ -95,7 +95,7 @@ window.addComment = ( function( window ) { cancelElement.addEventListener( 'touchstart', cancelEvent ); cancelElement.addEventListener( 'click', cancelEvent ); - // Submit the comment form when the user types CTRL or CMD + 'Enter'. + // Submit the comment form when the user types [Ctrl] or [Cmd] + [Enter]. var submitFormHandler = function( e ) { if ( ( e.metaKey || e.ctrlKey ) && e.keyCode === 13 ) { commentFormElement.removeEventListener( 'keydown', submitFormHandler ); diff --git a/src/js/_enqueues/lib/cookies.js b/src/js/_enqueues/lib/cookies.js index ac74bdb3a8..66d920affa 100644 --- a/src/js/_enqueues/lib/cookies.js +++ b/src/js/_enqueues/lib/cookies.js @@ -115,7 +115,7 @@ window.wpCookies = { if ( typeof( expires ) === 'object' && expires.toGMTString ) { expires = expires.toGMTString(); } else if ( parseInt( expires, 10 ) ) { - d.setTime( d.getTime() + ( parseInt( expires, 10 ) * 1000 ) ); // time must be in milliseconds + d.setTime( d.getTime() + ( parseInt( expires, 10 ) * 1000 ) ); // Time must be in milliseconds. expires = d.toGMTString(); } else { expires = ''; @@ -153,9 +153,11 @@ window.getUserSetting = function( name, def ) { return ''; }; -// Both name and value must be only ASCII letters, numbers or underscore -// and the shorter, the better (cookies can store maximum 4KB). Not suitable to store text. -// The value is converted and stored as string. +/* + * Both name and value must be only ASCII letters, numbers or underscore + * and the shorter, the better (cookies can store maximum 4KB). Not suitable to store text. + * The value is converted and stored as string. + */ window.setUserSetting = function( name, value, _del ) { if ( 'object' !== typeof userSettings ) { return false; @@ -192,7 +194,7 @@ window.deleteUserSetting = function( name ) { return setUserSetting( name, '', 1 ); }; -// Returns all settings as js object. +// Returns all settings as JS object. window.getAllUserSettings = function() { if ( 'object' !== typeof userSettings ) { return {}; diff --git a/src/js/_enqueues/lib/gallery.js b/src/js/_enqueues/lib/gallery.js index 36cb08636b..dda3e33408 100644 --- a/src/js/_enqueues/lib/gallery.js +++ b/src/js/_enqueues/lib/gallery.js @@ -15,7 +15,7 @@ jQuery(document).ready(function($) { distance: 2, handle: 'div.filename', stop: function() { - // When an update has occurred, adjust the order for each item + // When an update has occurred, adjust the order for each item. var all = $('#media-items').sortable('toArray'), len = all.length; $.each(all, function(i, id) { var order = desc ? (len - i) : (1 + i); @@ -71,7 +71,7 @@ jQuery(document).ready(function($) { $('img.pinkynail').toggle(true); }); - // initialize sortable + // Initialize sortable. gallerySortableInit(); clearAll(); @@ -88,7 +88,7 @@ jQuery(document).ready(function($) { } }); -jQuery(window).unload( function () { window.tinymce = window.tinyMCE = window.wpgallery = null; } ); // Cleanup +jQuery(window).unload( function () { window.tinymce = window.tinyMCE = window.wpgallery = null; } ); // Cleanup. /* gallery settings */ window.tinymce = null; @@ -122,7 +122,7 @@ window.wpgallery = { document.domain = q.mce_rdomain; } - // Find window & API + // Find window & API. window.tinymce = w.tinymce; window.tinyMCE = w.tinyMCE; t.editor = tinymce.EditorManager.activeEditor; diff --git a/src/js/_enqueues/lib/image-edit.js b/src/js/_enqueues/lib/image-edit.js index 756d2e4da1..d2b0139bc1 100644 --- a/src/js/_enqueues/lib/image-edit.js +++ b/src/js/_enqueues/lib/image-edit.js @@ -48,8 +48,9 @@ /** * Converts a value to an integer. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} f The float value that should be converted. * @@ -66,8 +67,9 @@ /** * Adds the disabled attribute and class to a single form element or a field set. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {jQuery} el The element that should be modified. * @param {bool|number} s The state for the element. If set to true @@ -95,8 +97,9 @@ /** * Initializes the image editor. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @@ -121,12 +124,12 @@ $('input[type="text"]', '#imgedit-panel-' + postid).keypress(function(e) { var k = e.keyCode; - // Key codes 37 thru 40 are the arrow keys. + // Key codes 37 through 40 are the arrow keys. if ( 36 < k && k < 41 ) { $(this).blur(); } - // The key code 13 is the enter key. + // The key code 13 is the Enter key. if ( 13 === k ) { e.preventDefault(); e.stopPropagation(); @@ -138,8 +141,9 @@ /** * Toggles the wait/load icon in the editor. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @param {number} toggle Is 0 or 1, fades the icon in then 1 and out when 0. @@ -159,8 +163,9 @@ /** * Shows or hides the image edit help box. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {HTMLElement} el The element to create the help window in. * @@ -181,8 +186,9 @@ * The image edit target contains the image sizes where the (possible) changes * have to be applied to. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @@ -198,8 +204,9 @@ * * If the original image size is exceeded a red exclamation mark is shown. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The current post id. * @param {number} x Is 0 when it applies the y-axis @@ -234,8 +241,9 @@ /** * Gets the selected aspect ratio. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @@ -261,8 +269,9 @@ * Removes the last action from the image edit history. * The history consist of (edit) actions performed on the image. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @param {number} setSize 0 or 1, when 1 the image resets to its original size. @@ -295,13 +304,13 @@ // Restore original 'o'. o = history[history.length - 1]; - // c = 'crop', r = 'rotate', f = 'flip' + // c = 'crop', r = 'rotate', f = 'flip'. o = o.c || o.r || o.f || false; if ( o ) { - // fw = Full image width + // fw = Full image width. this.hold.w = o.fw; - // fh = Full image height + // fh = Full image height. this.hold.h = o.fh; } } @@ -326,8 +335,9 @@ * * When the image source is reloaded the image will be reloaded. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @param {string} nonce The nonce to verify the request. @@ -371,7 +381,7 @@ parent.empty().append(img); - // w, h are the new full size dims + // w, h are the new full size dimensions. max1 = Math.max( t.hold.w, t.hold.h ); max2 = Math.max( $(img).width(), $(img).height() ); t.hold.sizer = max1 > max2 ? max2 / max1 : 1; @@ -399,8 +409,9 @@ /** * Performs an image edit action. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @param {string} nonce The nonce to verify the request. @@ -456,7 +467,7 @@ $.post(ajaxurl, data, function(r) { $('#image-editor-' + postid).empty().append(r); t.toggleEditor(postid, 0); - // refresh the attachment model so that changes propagate + // Refresh the attachment model so that changes propagate. if ( t._view ) { t._view.refresh(); } @@ -466,8 +477,9 @@ /** * Stores the changes that are made to the image. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id to get the image from the database. * @param {string} nonce The nonce to verify the request. @@ -531,8 +543,9 @@ /** * Creates the image edit window. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id for the image. * @param {string} nonce The nonce to verify the request. @@ -588,8 +601,9 @@ /** * Initializes the cropping tool and sets a default cropping selection. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @@ -614,8 +628,9 @@ /** * Initializes the cropping tool. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @param {HTMLElement} image The preview image. @@ -645,8 +660,8 @@ * @param {jQuery} img The preview image. */ onInit: function( img ) { - // Ensure that the imgAreaSelect wrapper elements are position:absolute. - // (even if we're in a position:fixed modal) + // Ensure that the imgAreaSelect wrapper elements are position:absolute + // (even if we're in a position:fixed modal). $img = $( img ); $img.next().css( 'position', 'absolute' ) .nextAll( '.imgareaselect-outer' ).css( 'position', 'absolute' ); @@ -715,8 +730,9 @@ /** * Stores the current crop selection. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @param {object} c The selection. @@ -746,8 +762,9 @@ /** * Closes the image editor. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @param {bool} warn Warning message. @@ -764,13 +781,14 @@ this.iasapi = {}; this.hold = {}; - // If we've loaded the editor in the context of a Media Modal, then switch to the previous view, - // whatever that might have been. + // If we've loaded the editor in the context of a Media Modal, + // then switch to the previous view, whatever that might have been. if ( this._view ){ this._view.back(); } - // In case we are not accessing the image editor in the context of a View, close the editor the old-skool way + // In case we are not accessing the image editor in the context of a View, + // close the editor the old-school way. else { $('#image-editor-' + postid).fadeOut('fast', function() { $( '#media-head-' + postid ).fadeIn( 'fast', function() { @@ -787,8 +805,9 @@ /** * Checks if the image edit history is saved. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @@ -811,8 +830,9 @@ /** * Adds an image edit action to the history. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {object} op The original position. * @param {number} postid The post id. @@ -830,7 +850,7 @@ history.pop(); pop--; } - undone.val(0); // reset + undone.val(0); // Reset. history.push(op); elem.val( JSON.stringify(history) ); @@ -844,8 +864,9 @@ /** * Rotates the image. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {string} angle The angle the image is rotated with. * @param {number} postid The post id. @@ -865,8 +886,9 @@ /** * Flips the image. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} axis The axle the image is flipped on. * @param {number} postid The post id. @@ -886,8 +908,9 @@ /** * Crops the image. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @param {string} nonce The nonce. @@ -915,8 +938,9 @@ /** * Undoes an image edit action. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @param {string} nonce The nonce. @@ -948,8 +972,9 @@ /** * Reverts a undo action. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @param {string} nonce The nonce. @@ -978,8 +1003,9 @@ /** * Sets the selection for the height and width in pixels. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @param {jQuery} el The element containing the values. @@ -1035,8 +1061,9 @@ /** * Rounds a number to a whole. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} num The number. * @@ -1064,8 +1091,9 @@ /** * Sets a locked aspect ratio for the selection. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @param {number} n The ratio to set. @@ -1108,8 +1136,9 @@ /** * Validates if a value in a jQuery.HTMLElement is numeric. * + * @since 4.6.0 + * * @memberof imageEdit - * @since 4.6 * * @param {jQuery} el The html element. * diff --git a/src/js/_enqueues/lib/link.js b/src/js/_enqueues/lib/link.js index 954d211131..1dfc1204e1 100644 --- a/src/js/_enqueues/lib/link.js +++ b/src/js/_enqueues/lib/link.js @@ -36,24 +36,24 @@ inputs.submit = $( '#wp-link-submit' ); inputs.close = $( '#wp-link-close' ); - // Input + // Input. inputs.text = $( '#wp-link-text' ); inputs.url = $( '#wp-link-url' ); inputs.nonce = $( '#_ajax_linking_nonce' ); inputs.openInNewTab = $( '#wp-link-target' ); inputs.search = $( '#wp-link-search' ); - // Build Rivers + // Build rivers. rivers.search = new River( $( '#search-results' ) ); rivers.recent = new River( $( '#most-recent-results' ) ); rivers.elements = inputs.dialog.find( '.query-results' ); - // Get search notice text + // Get search notice text. inputs.queryNotice = $( '#query-notice-message' ); inputs.queryNoticeTextDefault = inputs.queryNotice.find( '.query-notice-default' ); inputs.queryNoticeTextHint = inputs.queryNotice.find( '.query-notice-hint' ); - // Bind event handlers + // Bind event handlers. inputs.dialog.keydown( wpLink.keydown ); inputs.dialog.keyup( wpLink.keyup ); inputs.submit.click( function( event ) { @@ -68,7 +68,7 @@ rivers.elements.on( 'river-select', wpLink.updateFields ); - // Display 'hint' message when search field or 'query-results' box are focused + // Display 'hint' message when search field or 'query-results' box are focused. inputs.search.on( 'focus.wplink', function() { inputs.queryNoticeTextDefault.hide(); inputs.queryNoticeTextHint.removeClass( 'screen-reader-text' ).show(); @@ -91,7 +91,7 @@ inputs.url.on( 'blur', wpLink.correctURL ); }, - // If URL wasn't corrected last time and doesn't start with http:, https:, ? # or /, prepend http:// + // If URL wasn't corrected last time and doesn't start with http:, https:, ? # or /, prepend http://. correctURL: function () { var url = $.trim( inputs.url.val() ); @@ -154,24 +154,24 @@ refresh: function( url, text ) { var linkText = ''; - // Refresh rivers (clear links, check visibility) + // Refresh rivers (clear links, check visibility). rivers.search.refresh(); rivers.recent.refresh(); if ( wpLink.isMCE() ) { wpLink.mceRefresh( url, text ); } else { - // For the Text editor the "Link text" field is always shown + // For the Text editor the "Link text" field is always shown. if ( ! inputs.wrap.hasClass( 'has-text-field' ) ) { inputs.wrap.addClass( 'has-text-field' ); } if ( document.selection ) { - // Old IE + // Old IE. linkText = document.selection.createRange().text || text || ''; } else if ( typeof this.textarea.selectionStart !== 'undefined' && ( this.textarea.selectionStart !== this.textarea.selectionEnd ) ) { - // W3C + // W3C. text = this.textarea.value.substring( this.textarea.selectionStart, this.textarea.selectionEnd ) || text || ''; } @@ -180,12 +180,14 @@ } if ( isTouch ) { - // Close the onscreen keyboard + // Close the onscreen keyboard. inputs.url.focus().blur(); } else { - // Focus the URL field and highlight its contents. - // If this is moved above the selection changes, - // IE will show a flashing cursor over the dialog. + /* + * Focus the URL field and highlight its contents. + * If this is moved above the selection changes, + * IE will show a flashing cursor over the dialog. + */ window.setTimeout( function() { inputs.url[0].select(); inputs.url.focus(); @@ -203,7 +205,7 @@ hasSelectedText: function( linkNode ) { var node, nodes, i, html = editor.selection.getContent(); - // Partial html and not a fully selected anchor element + // Partial html and not a fully selected anchor element. if ( /</.test( html ) && ( ! /^<a [^>]+>[^<]+<\/a>$/.test( html ) || html.indexOf('href=') === -1 ) ) { return false; } @@ -259,7 +261,7 @@ inputs.search.val( '' ); } - // Always reset the search + // Always reset the search. window.setTimeout( function() { wpLink.searchInternalLinks(); } ); @@ -358,11 +360,11 @@ html = wpLink.buildHtml(attrs); - // Insert HTML + // Insert HTML. if ( document.selection && wpLink.range ) { - // IE + // IE. // Note: If no text is selected, IE will not place the cursor - // inside the closing tag. + // inside the closing tag. textarea.focus(); wpLink.range.text = html + ( text || wpLink.range.text ) + '</a>'; wpLink.range.moveToBookmark( wpLink.range.getBookmark() ); @@ -370,7 +372,7 @@ wpLink.range = null; } else if ( typeof textarea.selectionStart !== 'undefined' ) { - // W3C + // W3C. begin = textarea.selectionStart; end = textarea.selectionEnd; selection = text || textarea.value.substring( begin, end ); @@ -388,7 +390,7 @@ textarea.value.substring( end, textarea.value.length ) ); - // Update cursor position + // Update cursor position. textarea.selectionStart = textarea.selectionEnd = cursor; } @@ -484,10 +486,10 @@ selection = $.trim( selection ); if ( selection && emailRegexp.test( selection ) ) { - // Selection is email address + // Selection is email address. return 'mailto:' + selection; } else if ( selection && urlRegexp.test( selection ) ) { - // Selection is URL + // Selection is URL. return selection.replace( /&|�?38;/gi, '&' ); } @@ -553,7 +555,7 @@ id = event.target.id; // wp-link-submit must always be the last focusable element in the dialog. - // following focusable elements will be skipped on keyboard navigation. + // Following focusable elements will be skipped on keyboard navigation. if ( id === 'wp-link-submit' && ! event.shiftKey ) { inputs.close.focus(); event.preventDefault(); @@ -656,18 +658,18 @@ this.deselect(); this.selected = li.addClass( 'selected' ); - // Make sure the element is visible + // Make sure the element is visible. liHeight = li.outerHeight(); elHeight = this.element.height(); liTop = li.position().top; elTop = this.element.scrollTop(); - if ( liTop < 0 ) // Make first visible element + if ( liTop < 0 ) // Make first visible element. this.element.scrollTop( elTop + liTop ); - else if ( liTop + liHeight > elHeight ) // Make last visible element + else if ( liTop + liHeight > elHeight ) // Make last visible element. this.element.scrollTop( elTop + liTop - elHeight + liHeight ); - // Trigger the river-select event + // Trigger the river-select event. this.element.trigger( 'river-select', [ li, event, this ] ); }, deselect: function() { diff --git a/src/js/_enqueues/lib/nav-menu.js b/src/js/_enqueues/lib/nav-menu.js index 95b66c1a42..3a0bd642ef 100644 --- a/src/js/_enqueues/lib/nav-menu.js +++ b/src/js/_enqueues/lib/nav-menu.js @@ -69,7 +69,7 @@ }, jQueryExtensions : function() { - // jQuery extensions + // jQuery extensions. $.fn.extend({ menuItemDepth : function() { var margin = api.isRTL ? this.eq(0).css('margin-right') : this.eq(0).css('margin-left'); @@ -114,7 +114,7 @@ depth = t.menuItemDepth(), newDepth = depth + dir; - // Change .menu-item-depth-n class + // Change .menu-item-depth-n class. t.moveHorizontally( newDepth, depth ); }); }, @@ -125,10 +125,10 @@ diff = newDepth - depth, subItemText = t.find('.is-submenu'); - // Change .menu-item-depth-n class + // Change .menu-item-depth-n class. t.updateDepthClass( newDepth, depth ).updateParentMenuItemDBId(); - // If it has children, move those too + // If it has children, move those too. if ( children ) { children.each(function() { var t = $(this), @@ -138,7 +138,7 @@ }); } - // Show "Sub item" helper text + // Show "Sub item" helper text. if (0 === newDepth) subItemText.hide(); else @@ -153,7 +153,7 @@ parentDepth = depth - 1, parent = item.prevAll( '.menu-item-depth-' + parentDepth ).first(); - if ( 0 === depth ) { // Item is on the top level, has no parent + if ( 0 === depth ) { // Item is on the top level, has no parent. input.val(0); } else { // Find the parent item, and retrieve its object id. input.val( parent.find( '.menu-item-data-db-id' ).val() ); @@ -191,10 +191,10 @@ if ( !checkboxes.length ) return false; - // Show the ajax spinner + // Show the Ajax spinner. t.find( '.button-controls .spinner' ).addClass( 'is-active' ); - // Retrieve menu item data + // Retrieve menu item data. $(checkboxes).each(function(){ var t = $(this), listItemDBIDMatch = re.exec( t.attr('name') ), @@ -205,9 +205,9 @@ menuItems[listItemDBID] = t.closest('li').getItemData( 'add-menu-item', listItemDBID ); }); - // Add the items + // Add the items. api.addItemToMenu(menuItems, processMethod, function(){ - // Deselect the items and hide the ajax spinner + // Deselect the items and hide the Ajax spinner. checkboxes.prop( 'checked', false ); t.find( '.button-controls .select-all' ).prop( 'checked', false ); t.find( '.button-controls .spinner' ).removeClass( 'is-active' ); @@ -312,22 +312,22 @@ case 'up': newItemPosition = thisItemPosition - 1; - // Already at top + // Already at top. if ( 0 === thisItemPosition ) break; - // If a sub item is moved to top, shift it to 0 depth + // If a sub item is moved to top, shift it to 0 depth. if ( 0 === newItemPosition && 0 !== thisItemDepth ) thisItem.moveHorizontally( 0, thisItemDepth ); - // If prev item is sub item, shift to match depth + // If prev item is sub item, shift to match depth. if ( 0 !== prevItemDepth ) thisItem.moveHorizontally( prevItemDepth, thisItemDepth ); // Does this item have sub items? if ( thisItemChildren ) { items = thisItem.add( thisItemChildren ); - // Move the entire block + // Move the entire block. items.detach().insertBefore( menuItems.eq( newItemPosition ) ).updateParentMenuItemDBId(); } else { thisItem.detach().insertBefore( menuItems.eq( newItemPosition ) ).updateParentMenuItemDBId(); @@ -351,40 +351,40 @@ items.detach().insertAfter( menuItems.eq( thisItemPosition + items.length ) ).updateParentMenuItemDBId(); } else { - // If next item has sub items, shift depth + // If next item has sub items, shift depth. if ( 0 !== nextItemChildren.length ) thisItem.moveHorizontally( nextItemDepth, thisItemDepth ); - // Have we reached the bottom + // Have we reached the bottom? if ( menuItemsCount === thisItemPosition + 1 ) break; thisItem.detach().insertAfter( menuItems.eq( thisItemPosition + 1 ) ).updateParentMenuItemDBId(); } break; case 'top': - // Already at top + // Already at top. if ( 0 === thisItemPosition ) break; // Does this item have sub items? if ( thisItemChildren ) { items = thisItem.add( thisItemChildren ); - // Move the entire block + // Move the entire block. items.detach().insertBefore( menuItems.eq( 0 ) ).updateParentMenuItemDBId(); } else { thisItem.detach().insertBefore( menuItems.eq( 0 ) ).updateParentMenuItemDBId(); } break; case 'left': - // As far left as possible + // As far left as possible. if ( 0 === thisItemDepth ) break; thisItem.shiftHorizontally( -1 ); break; case 'right': - // Can't be sub item at top + // Can't be sub item at top. if ( 0 === thisItemPosition ) break; - // Already sub item of prevItem + // Already sub item of prevItem. if ( thisItemData['menu-item-parent-id'] === prevItemId ) break; thisItem.shiftHorizontally( 1 ); @@ -402,7 +402,7 @@ api.refreshKeyboardAccessibility(); api.refreshAdvancedAccessibility(); - // Refresh the accessibility when the user comes close to the item in any way + // Refresh the accessibility when the user comes close to the item in any way. menu.on( 'mouseenter.refreshAccessibility focus.refreshAccessibility touchstart.refreshAccessibility' , '.menu-item' , function(){ api.refreshAdvancedAccessibilityOfItem( $( this ).find( 'a.item-edit' ) ); } ); @@ -412,7 +412,7 @@ api.refreshAdvancedAccessibilityOfItem( $( this ) ); } ); - // Links for moving items + // Links for moving items. menu.on( 'click', '.menus-move', function () { var $this = $( this ), dir = $this.data( 'dir' ); @@ -433,7 +433,7 @@ */ refreshAdvancedAccessibilityOfItem : function( itemToRefresh ) { - // Only refresh accessibility when necessary + // Only refresh accessibility when necessary. if ( true !== $( itemToRefresh ).data( 'needs_accessibility_refresh' ) ) { return; } @@ -494,7 +494,7 @@ itemPosition = primaryItems.index( menuItem ) + 1, totalMenuItems = primaryItems.length, - // String together help text for primary menu items + // String together help text for primary menu items. title = menus.menuFocus.replace( '%1$s', itemName ).replace( '%2$d', itemPosition ).replace( '%3$d', totalMenuItems ); } else { parentItem = menuItem.prevAll( '.menu-item-depth-' + parseInt( depth - 1, 10 ) ).first(), @@ -503,13 +503,13 @@ subItems = $( '.menu-item .menu-item-data-parent-id[value="' + parentItemId + '"]' ), itemPosition = $( subItems.parents('.menu-item').get().reverse() ).index( menuItem ) + 1; - // String together help text for sub menu items + // String together help text for sub menu items. title = menus.subMenuFocus.replace( '%1$s', itemName ).replace( '%2$d', itemPosition ).replace( '%3$s', parentItemName ); } $this.attr( 'aria-label', title ); - // Mark this item's accessibility as refreshed + // Mark this item's accessibility as refreshed. $this.data( 'needs_accessibility_refresh', false ); }, @@ -523,10 +523,10 @@ // Hide all the move buttons by default. $( '.menu-item-settings .field-move .menus-move' ).hide(); - // Mark all menu items as unprocessed + // Mark all menu items as unprocessed. $( 'a.item-edit' ).data( 'needs_accessibility_refresh', true ); - // All open items have to be refreshed or they will show no links + // All open items have to be refreshed or they will show no links. $( '.menu-item-edit-active a.item-edit' ).each( function() { api.refreshAdvancedAccessibilityOfItem( this ); } ); @@ -541,18 +541,18 @@ thisItem = $this.parents( 'li.menu-item' ), thisItemData = thisItem.getItemData(); - // Bail if it's not an arrow key + // Bail if it's not an arrow key. if ( 37 != e.which && 38 != e.which && 39 != e.which && 40 != e.which ) return; - // Avoid multiple keydown events + // Avoid multiple keydown events. $this.off('keydown'); - // Bail if there is only one menu item + // Bail if there is only one menu item. if ( 1 === $('#menu-to-edit li').length ) return; - // If RTL, swap left/right arrows + // If RTL, swap left/right arrows. arrows = { '38': 'up', '40': 'down', '37': 'left', '39': 'right' }; if ( $('body').hasClass('rtl') ) arrows = { '38' : 'up', '40' : 'down', '39' : 'left', '37' : 'right' }; @@ -571,7 +571,7 @@ api.moveMenuItem( $this, 'right' ); break; } - // Put focus back on same menu item + // Put focus back on same menu item. $( '#edit-' + thisItemData['menu-item-db-id'] ).focus(); return false; }); @@ -594,10 +594,10 @@ }, initToggles : function() { - // init postboxes + // Init postboxes. postboxes.add_postbox_toggles('nav-menus'); - // adjust columns functions for menus UI + // Adjust columns functions for menus UI. columns.useCheckboxesForHidden(); columns.checked = function(field) { $('.field-' + field).removeClass('hidden-field'); @@ -605,7 +605,7 @@ columns.unchecked = function(field) { $('.field-' + field).addClass('hidden-field'); }; - // hide fields + // Hide fields. api.menuList.hideAdvancedMenuItemFields(); $('.hide-postbox-tog').click(function () { @@ -639,7 +639,7 @@ start: function(e, ui) { var height, width, parent, children, tempHolder; - // handle placement for rtl orientation + // Handle placement for RTL orientation. if ( api.isRTL ) ui.item[0].style.right = 'auto'; @@ -649,19 +649,19 @@ originalDepth = ui.item.menuItemDepth(); updateCurrentDepth(ui, originalDepth); - // Attach child elements to parent - // Skip the placeholder + // Attach child elements to parent. + // Skip the placeholder. parent = ( ui.item.next()[0] == ui.placeholder[0] ) ? ui.item.next() : ui.item; children = parent.childMenuItems(); transport.append( children ); // Update the height of the placeholder to match the moving item. height = transport.outerHeight(); - // If there are children, account for distance between top of children and parent + // If there are children, account for distance between top of children and parent. height += ( height > 0 ) ? (ui.placeholder.css('margin-top').slice(0, -2) * 1) : 0; height += ui.helper.outerHeight(); helperHeight = height; - height -= 2; // Subtract 2 for borders + height -= 2; // Subtract 2 for borders. ui.placeholder.height(height); // Update the width of the placeholder to match the moving item. @@ -670,18 +670,18 @@ var depth = $(this).menuItemDepth(); maxChildDepth = (depth > maxChildDepth) ? depth : maxChildDepth; }); - width = ui.helper.find('.menu-item-handle').outerWidth(); // Get original width - width += api.depthToPx(maxChildDepth - originalDepth); // Account for children - width -= 2; // Subtract 2 for borders + width = ui.helper.find('.menu-item-handle').outerWidth(); // Get original width. + width += api.depthToPx(maxChildDepth - originalDepth); // Account for children. + width -= 2; // Subtract 2 for borders. ui.placeholder.width(width); // Update the list of menu items. tempHolder = ui.placeholder.next( '.menu-item' ); - tempHolder.css( 'margin-top', helperHeight + 'px' ); // Set the margin to absorb the placeholder - ui.placeholder.detach(); // detach or jQuery UI will think the placeholder is a menu item - $(this).sortable( 'refresh' ); // The children aren't sortable. We should let jQ UI know. - ui.item.after( ui.placeholder ); // reattach the placeholder. - tempHolder.css('margin-top', 0); // reset the margin + tempHolder.css( 'margin-top', helperHeight + 'px' ); // Set the margin to absorb the placeholder. + ui.placeholder.detach(); // Detach or jQuery UI will think the placeholder is a menu item. + $(this).sortable( 'refresh' ); // The children aren't sortable. We should let jQuery UI know. + ui.item.after( ui.placeholder ); // Reattach the placeholder. + tempHolder.css('margin-top', 0); // Reset the margin. // Now that the element is complete, we can update... updateSharedVars(ui); @@ -690,31 +690,31 @@ var children, subMenuTitle, depthChange = currentDepth - originalDepth; - // Return child elements to the list + // Return child elements to the list. children = transport.children().insertAfter(ui.item); - // Add "sub menu" description + // Add "sub menu" description. subMenuTitle = ui.item.find( '.item-title .is-submenu' ); if ( 0 < currentDepth ) subMenuTitle.show(); else subMenuTitle.hide(); - // Update depth classes + // Update depth classes. if ( 0 !== depthChange ) { ui.item.updateDepthClass( currentDepth ); children.shiftDepthClass( depthChange ); updateMenuMaxDepth( depthChange ); } - // Register a change + // Register a change. api.registerChange(); // Update the item data. ui.item.updateParentMenuItemDBId(); - // address sortable's incorrectly-calculated top in opera + // Address sortable's incorrectly-calculated top in Opera. ui.item[0].style.top = 0; - // handle drop placement for rtl orientation + // Handle drop placement for rtl orientation. if ( api.isRTL ) { ui.item[0].style.left = 'auto'; ui.item[0].style.right = 0; @@ -736,9 +736,11 @@ edge = api.isRTL ? offset.left + ui.helper.width() : offset.left, depth = api.negateIfRTL * api.pxToDepth( edge - menuEdge ); - // Check and correct if depth is not within range. - // Also, if the dragged element is dragged upwards over - // an item, shift the placeholder to a child position. + /* + * Check and correct if depth is not within range. + * Also, if the dragged element is dragged upwards over an item, + * shift the placeholder to a child position. + */ if ( depth > maxDepth || offset.top < ( prevBottom - api.options.targetTolerance ) ) { depth = maxDepth; } else if ( depth < minDepth ) { @@ -748,7 +750,7 @@ if( depth != currentDepth ) updateCurrentDepth(ui, depth); - // If we overlap the next element, manually shift downwards + // If we overlap the next element, manually shift downwards. if( nextThreshold && offset.top + helperHeight > nextThreshold ) { next.after( ui.placeholder ); updateSharedVars( ui ); @@ -955,12 +957,12 @@ return false; } - // Show the ajax spinner + // Show the Ajax spinner. $( '.customlinkdiv .spinner' ).addClass( 'is-active' ); this.addLinkToMenu( url, label, processMethod, function() { - // Remove the ajax spinner + // Remove the Ajax spinner. $( '.customlinkdiv .spinner' ).removeClass( 'is-active' ); - // Set custom link form back to defaults + // Set custom link form back to defaults. $('#custom-menu-item-name').val('').blur(); $( '#custom-menu-item-url' ).val( '' ).attr( 'placeholder', 'https://' ); }); @@ -997,10 +999,10 @@ $.post( ajaxurl, params, function(menuMarkup) { var ins = $('#menu-instructions'); - menuMarkup = $.trim( menuMarkup ); // Trim leading whitespaces + menuMarkup = $.trim( menuMarkup ); // Trim leading whitespaces. processMethod(menuMarkup, params); - // Make it stand out a bit more visually, by adding a fadeIn + // Make it stand out a bit more visually, by adding a fadeIn. $( 'li.pending' ).hide().fadeIn('slow'); $( '.drag-instructions' ).show(); if( ! ins.hasClass( 'menu-instructions-inactive' ) && ins.siblings().length ) @@ -1051,7 +1053,7 @@ return navMenuL10n.saveAlert; }; } else { - // Make the post boxes read-only, as they can't be used yet + // Make the post boxes read-only, as they can't be used yet. $( '#menu-settings-column' ).find( 'input,select' ).end().find( 'a' ).attr( 'href', '#' ).unbind( 'click' ); } }, @@ -1071,7 +1073,7 @@ wrapper = target.parents('.accordion-section-content').first(); - // upon changing tabs, we want to uncheck all checkboxes + // Upon changing tabs, we want to uncheck all checkboxes. $( 'input', wrapper ).prop( 'checked', false ); $('.tabs-panel-active', wrapper).removeClass('tabs-panel-active').addClass('tabs-panel-inactive'); @@ -1080,7 +1082,7 @@ $('.tabs', wrapper).removeClass('tabs'); target.parent().addClass('tabs'); - // select the search bar + // Select the search bar. $('.quick-search', wrapper).focus(); // Hide controls in the search tab if no items found. @@ -1193,17 +1195,17 @@ var locs = '', menuName = $('#menu-name'), menuNameVal = menuName.val(); - // Cancel and warn if invalid menu name + // Cancel and warn if invalid menu name. if ( ! menuNameVal || ! menuNameVal.replace( /\s+/, '' ) ) { menuName.parent().addClass( 'form-invalid' ); return false; } - // Copy menu theme locations + // Copy menu theme locations. $('#nav-menu-theme-locations select').each(function() { locs += '<input type="hidden" name="' + this.name + '" value="' + $(this).val() + '" />'; }); $('#update-nav-menu').append( locs ); - // Update menu item position data + // Update menu item position data. api.menuList.find('.menu-item-data-position').val( function(index) { return index + 1; } ); window.onbeforeunload = null; @@ -1211,7 +1213,7 @@ }, eventOnClickMenuDelete : function() { - // Delete warning AYS + // Delete warning AYS. if ( window.confirm( navMenuL10n.warnDeleteMenu ) ) { window.onbeforeunload = null; return true; @@ -1253,7 +1255,7 @@ $items.each(function(){ $item = $(this); - // make a unique DB ID number + // Make a unique DB ID number. matched = pattern.exec($item.html()); if ( matched && matched[1] ) { diff --git a/src/js/_enqueues/lib/pointer.js b/src/js/_enqueues/lib/pointer.js index f841f82308..52524922c1 100644 --- a/src/js/_enqueues/lib/pointer.js +++ b/src/js/_enqueues/lib/pointer.js @@ -90,11 +90,11 @@ var o = this.options, tip = this.pointer; - // Handle document transfer + // Handle document transfer. if ( key === 'document' && value !== o.document ) { tip.detach().appendTo( value.body ); - // Handle class change + // Handle class change. } else if ( key === 'pointerClass' ) { tip.removeClass( o.pointerClass ).addClass( value ); } @@ -102,11 +102,11 @@ // Call super method. $.Widget.prototype._setOption.apply( this, arguments ); - // Reposition automatically + // Reposition automatically. if ( key === 'position' ) { this.reposition(); - // Update content automatically if pointer is open + // Update content automatically if pointer is open. } else if ( key === 'content' && this.active ) { this.update(); } @@ -234,7 +234,7 @@ }).show().position($.extend({ of: this.element, collision: 'fit none' - }, position )); // the object comes before this.options.position so the user can override position.of. + }, position )); // The object comes before this.options.position so the user can override position.of. this.repoint(); }, diff --git a/src/js/_enqueues/lib/quicktags.js b/src/js/_enqueues/lib/quicktags.js index f7bc488691..2224cbed84 100644 --- a/src/js/_enqueues/lib/quicktags.js +++ b/src/js/_enqueues/lib/quicktags.js @@ -20,7 +20,7 @@ * @output wp-includes/js/quicktags.js */ -// new edit toolbar used with permission +// New edit toolbar used with permission // by Alex King // http://www.alexking.org/ @@ -52,7 +52,7 @@ window.edToolbar = function(){}; /* jshint ignore:end */ (function(){ - // private stuff is prefixed with an underscore + // Private stuff is prefixed with an underscore. var _domReady = function(func) { var t, i, DOMContentLoaded, _tryReady; @@ -150,7 +150,7 @@ window.edToolbar = function(){}; t.settings = settings; if ( id === 'content' && typeof(adminpage) === 'string' && ( adminpage === 'post-new-php' || adminpage === 'post-php' ) ) { - // back compat hack :-( + // Back compat hack :-( window.edCanvas = canvas; toolbar_id = 'ed_toolbar'; } else { @@ -168,19 +168,19 @@ window.edToolbar = function(){}; canvas.parentNode.insertBefore(tb, canvas); t.toolbar = tb; - // listen for click events + // Listen for click events. onclick = function(e) { e = e || window.event; var target = e.target || e.srcElement, visible = target.clientWidth || target.offsetWidth, i; - // don't call the callback on pressing the accesskey when the button is not visible + // Don't call the callback on pressing the accesskey when the button is not visible. if ( !visible ) { return; } - // as long as it has the class ed_button, execute the callback + // As long as it has the class ed_button, execute the callback. if ( / ed_button /.test(' ' + target.className + ' ') ) { - // we have to reassign canvas here + // We have to reassign canvas here. t.canvas = canvas = document.getElementById(id); i = target.id.replace(name + '_', ''); @@ -261,7 +261,7 @@ window.edToolbar = function(){}; theButtons = {}; use = ''; - // set buttons + // Set buttons. if ( settings.buttons ) { use = ','+settings.buttons+','; } @@ -361,7 +361,7 @@ window.edToolbar = function(){}; return; } - if ( priority === -1 ) { // back-compat + if ( priority === -1 ) { // Back-compat. return btn; } @@ -376,7 +376,7 @@ window.edToolbar = function(){}; } if ( this.buttonsInitDone ) { - this._buttonsInit(); // add the button HTML to all instances toolbars if addButton() was called too late + this._buttonsInit(); // Add the button HTML to all instances toolbars if addButton() was called too late. } }; @@ -387,12 +387,12 @@ window.edToolbar = function(){}; return false; } - if ( document.selection ) { //IE + if ( document.selection ) { // IE. canvas.focus(); sel = document.selection.createRange(); sel.text = content; canvas.focus(); - } else if ( canvas.selectionStart || canvas.selectionStart === 0 ) { // FF, WebKit, Opera + } else if ( canvas.selectionStart || canvas.selectionStart === 0 ) { // FF, WebKit, Opera. text = canvas.value; startPos = canvas.selectionStart; endPos = canvas.selectionEnd; @@ -420,7 +420,7 @@ window.edToolbar = function(){}; return true; }; - // a plain, dumb button + // A plain, dumb button. qt.Button = function( id, display, access, title, instance, attr ) { this.id = id; this.display = display; @@ -450,7 +450,7 @@ window.edToolbar = function(){}; }; qt.Button.prototype.callback = function(){}; - // a button that inserts HTML tag + // A button that inserts HTML tag. qt.TagButton = function( id, display, tagStart, tagEnd, access, title, instance, attr ) { var t = this; qt.Button.call( t, id, display, access, title, instance, attr ); @@ -485,7 +485,7 @@ window.edToolbar = function(){}; element.setAttribute( 'aria-label', this.attr.ariaLabel ); } }; - // whether a tag is open or not. Returns false if not open, or current open depth of the tag + // Whether a tag is open or not. Returns false if not open, or current open depth of the tag. qt.TagButton.prototype.isOpen = function (ed) { var t = this, i = 0, ret = false; if ( ed.openTags ) { @@ -501,7 +501,7 @@ window.edToolbar = function(){}; qt.TagButton.prototype.callback = function(element, canvas, ed) { var t = this, startPos, endPos, cursorPos, scrollTop, v = canvas.value, l, r, i, sel, endTag = v ? t.tagEnd : '', event; - if ( document.selection ) { // IE + if ( document.selection ) { // IE. canvas.focus(); sel = document.selection.createRange(); if ( sel.text.length > 0 ) { @@ -522,7 +522,7 @@ window.edToolbar = function(){}; } } canvas.focus(); - } else if ( canvas.selectionStart || canvas.selectionStart === 0 ) { // FF, WebKit, Opera + } else if ( canvas.selectionStart || canvas.selectionStart === 0 ) { // FF, WebKit, Opera. startPos = canvas.selectionStart; endPos = canvas.selectionEnd; @@ -532,12 +532,12 @@ window.edToolbar = function(){}; cursorPos = endPos; scrollTop = canvas.scrollTop; - l = v.substring(0, startPos); // left of the selection - r = v.substring(endPos, v.length); // right of the selection - i = v.substring(startPos, endPos); // inside the selection + l = v.substring(0, startPos); // Left of the selection. + r = v.substring(endPos, v.length); // Right of the selection. + i = v.substring(startPos, endPos); // Inside the selection. if ( startPos !== endPos ) { if ( !t.tagEnd ) { - canvas.value = l + i + t.tagStart + r; // insert self closing tags after the selection + canvas.value = l + i + t.tagStart + r; // Insert self-closing tags after the selection. cursorPos += t.tagStart.length; } else { canvas.value = l + t.tagStart + i + endTag + r; @@ -562,7 +562,7 @@ window.edToolbar = function(){}; canvas.selectionEnd = cursorPos; canvas.scrollTop = scrollTop; canvas.focus(); - } else { // other browsers? + } else { // Other browsers? if ( !endTag ) { canvas.value += t.tagStart; } else if ( t.isOpen(ed) !== false ) { @@ -584,10 +584,10 @@ window.edToolbar = function(){}; } }; - // removed + // Removed. qt.SpellButton = function() {}; - // the close tags button + // The close tags button. qt.CloseButton = function() { qt.Button.call( this, 'close', quicktagsL10n.closeTags, '', quicktagsL10n.closeAllOpenTags ); }; @@ -621,7 +621,7 @@ window.edToolbar = function(){}; } }; - // the link button + // The link button. qt.LinkButton = function() { var attr = { ariaLabel: quicktagsL10n.link @@ -653,7 +653,7 @@ window.edToolbar = function(){}; } }; - // the img button + // The img button. qt.ImgButton = function() { var attr = { ariaLabel: quicktagsL10n.image @@ -704,14 +704,14 @@ window.edToolbar = function(){}; c.focus(); }; - // ensure backward compatibility + // Ensure backward compatibility. edButtons[10] = new qt.TagButton( 'strong', 'b', '<strong>', '</strong>', '', '', '', { ariaLabel: quicktagsL10n.strong, ariaLabelClose: quicktagsL10n.strongClose } ); edButtons[20] = new qt.TagButton( 'em', 'i', '<em>', '</em>', '', '', '', { ariaLabel: quicktagsL10n.em, ariaLabelClose: quicktagsL10n.emClose } ); - edButtons[30] = new qt.LinkButton(); // special case + edButtons[30] = new qt.LinkButton(); // Special case. edButtons[40] = new qt.TagButton( 'block', 'b-quote', '\n\n<blockquote>', '</blockquote>\n\n', '', '', '', { ariaLabel: quicktagsL10n.blockquote, ariaLabelClose: quicktagsL10n.blockquoteClose } ); edButtons[50] = new qt.TagButton( 'del', 'del', '<del datetime="' + _datetime + '">', '</del>', '', '', '', { ariaLabel: quicktagsL10n.del, ariaLabelClose: quicktagsL10n.delClose } ); edButtons[60] = new qt.TagButton( 'ins', 'ins', '<ins datetime="' + _datetime + '">', '</ins>', '', '', '', { ariaLabel: quicktagsL10n.ins, ariaLabelClose: quicktagsL10n.insClose } ); - edButtons[70] = new qt.ImgButton(); // special case + edButtons[70] = new qt.ImgButton(); // Special case. edButtons[80] = new qt.TagButton( 'ul', 'ul', '<ul>\n', '</ul>\n\n', '', '', '', { ariaLabel: quicktagsL10n.ul, ariaLabelClose: quicktagsL10n.ulClose } ); edButtons[90] = new qt.TagButton( 'ol', 'ol', '<ol>\n', '</ol>\n\n', '', '', '', { ariaLabel: quicktagsL10n.ol, ariaLabelClose: quicktagsL10n.olClose } ); edButtons[100] = new qt.TagButton( 'li', 'li', '\t<li>', '</li>\n', '', '', '', { ariaLabel: quicktagsL10n.li, ariaLabelClose: quicktagsL10n.liClose } ); diff --git a/src/js/_enqueues/vendor/plupload/handlers.js b/src/js/_enqueues/vendor/plupload/handlers.js index 9116a64eac..9ed2cc687d 100644 --- a/src/js/_enqueues/vendor/plupload/handlers.js +++ b/src/js/_enqueues/vendor/plupload/handlers.js @@ -1,18 +1,18 @@ /* global plupload, pluploadL10n, ajaxurl, post_id, wpUploaderInit, deleteUserSetting, setUserSetting, getUserSetting, shortform */ var topWin = window.dialogArguments || opener || parent || top, uploader, uploader_init; -// progress and success handlers for media multi uploads +// Progress and success handlers for media multi uploads. function fileQueued( fileObj ) { - // Get rid of unused form + // Get rid of unused form. jQuery( '.media-blank' ).remove(); var items = jQuery( '#media-items' ).children(), postid = post_id || 0; - // Collapse a single item + // Collapse a single item. if ( items.length == 1 ) { items.removeClass( 'open' ).find( '.slidetoggle' ).slideUp( 200 ); } - // Create a progress bar containing the filename + // Create a progress bar containing the filename. jQuery( '<div class="media-item">' ) .attr( 'id', 'media-item-' + fileObj.id ) .addClass( 'child-of-' + postid ) @@ -20,7 +20,7 @@ function fileQueued( fileObj ) { jQuery( '<div class="filename original">' ).text( ' ' + fileObj.name ) ) .appendTo( jQuery( '#media-items' ) ); - // Disable submit + // Disable submit. jQuery( '#insert-gallery' ).prop( 'disabled', true ); } @@ -40,27 +40,27 @@ function uploadProgress( up, file ) { jQuery( '.percent', item ).html( file.percent + '%' ); } -// check to see if a large file failed to upload +// Check to see if a large file failed to upload. function fileUploading( up, file ) { var hundredmb = 100 * 1024 * 1024, max = parseInt( up.settings.max_file_size, 10 ); if ( max > hundredmb && file.size > hundredmb ) { setTimeout( function() { - if ( file.status < 3 && file.loaded === 0 ) { // not uploading + if ( file.status < 3 && file.loaded === 0 ) { // Not uploading. wpFileError( file, pluploadL10n.big_upload_failed.replace( '%1$s', '<a class="uploader-html" href="#">' ).replace( '%2$s', '</a>' ) ); - up.stop(); // stops the whole queue + up.stop(); // Stop the whole queue. up.removeFile( file ); - up.start(); // restart the queue + up.start(); // Restart the queue. } - }, 10000 ); // wait for 10 sec. for the file to start uploading + }, 10000 ); // Wait for 10 seconds for the file to start uploading. } } function updateMediaForm() { var items = jQuery( '#media-items' ).children(); - // Just one file, no need for collapsible part + // Just one file, no need for collapsible part. if ( items.length == 1 ) { items.addClass( 'open' ).find( '.slidetoggle' ).show(); jQuery( '.insert-gallery' ).hide(); @@ -80,11 +80,12 @@ function updateMediaForm() { function uploadSuccess( fileObj, serverData ) { var item = jQuery( '#media-item-' + fileObj.id ); - // on success serverData should be numeric, fix bug in html4 runtime returning the serverData wrapped in a <pre> tag + // On success serverData should be numeric, + // fix bug in html4 runtime returning the serverData wrapped in a <pre> tag. if ( typeof serverData === 'string' ) { serverData = serverData.replace( /^<pre>(\d+)<\/pre>$/, '$1' ); - // if async-upload returned an error message, place it in the media item div and return + // If async-upload returned an error message, place it in the media item div and return. if ( /media-upload-error|error-div/.test( serverData ) ) { item.html( serverData ); return; @@ -129,25 +130,27 @@ function prepareMediaItem( fileObj, serverData ) { topWin.jQuery( '#TB_overlay' ).click( topWin.tb_remove ); } catch( e ){} - if ( isNaN( serverData ) || !serverData ) { // Old style: Append the HTML returned by the server -- thumbnail and form inputs + if ( isNaN( serverData ) || !serverData ) { + // Old style: Append the HTML returned by the server -- thumbnail and form inputs. item.append( serverData ); prepareMediaItemInit( fileObj ); - } else { // New style: server data is just the attachment ID, fetch the thumbnail and form html from the server + } else { + // New style: server data is just the attachment ID, fetch the thumbnail and form html from the server. item.load( 'async-upload.php', {attachment_id:serverData, fetch:f}, function(){prepareMediaItemInit( fileObj );updateMediaForm();}); } } function prepareMediaItemInit( fileObj ) { var item = jQuery( '#media-item-' + fileObj.id ); - // Clone the thumbnail as a "pinkynail" -- a tiny image to the left of the filename + // Clone the thumbnail as a "pinkynail" -- a tiny image to the left of the filename. jQuery( '.thumbnail', item ).clone().attr( 'class', 'pinkynail toggle' ).prependTo( item ); - // Replace the original filename with the new (unique) one assigned during upload + // Replace the original filename with the new (unique) one assigned during upload. jQuery( '.filename.original', item ).replaceWith( jQuery( '.filename.new', item ) ); - // Bind AJAX to the new Delete button + // Bind AJAX to the new Delete button. jQuery( 'a.delete', item ).click( function(){ - // Tell the server to delete it. TODO: handle exceptions + // Tell the server to delete it. TODO: Handle exceptions. jQuery.ajax({ url: ajaxurl, type: 'post', @@ -163,9 +166,9 @@ function prepareMediaItemInit( fileObj ) { return false; }); - // Bind AJAX to the new Undo button + // Bind AJAX to the new Undo button. jQuery( 'a.undo', item ).click( function(){ - // Tell the server to untrash it. TODO: handle exceptions + // Tell the server to untrash it. TODO: Handle exceptions. jQuery.ajax({ url: ajaxurl, type: 'post', @@ -195,16 +198,16 @@ function prepareMediaItemInit( fileObj ) { return false; }); - // Open this item if it says to start open (e.g. to display an error) + // Open this item if it says to start open (e.g. to display an error). jQuery( '#media-item-' + fileObj.id + '.startopen' ).removeClass( 'startopen' ).addClass( 'open' ).find( 'slidetoggle' ).fadeIn(); } -// generic error message +// Generic error message. function wpQueueError( message ) { jQuery( '#media-upload-error' ).show().html( '<div class="error"><p>' + message + '</p></div>' ); } -// file-specific error messages +// File-specific error messages. function wpFileError( fileObj, message ) { itemAjaxError( fileObj.id, message ); } @@ -212,7 +215,7 @@ function wpFileError( fileObj, message ) { function itemAjaxError( id, message ) { var item = jQuery( '#media-item-' + id ), filename = item.find( '.filename' ).text(), last_err = item.data( 'last-err' ); - if ( last_err == id ) // prevent firing an error for the same file twice + if ( last_err == id ) // Prevent firing an error for the same file twice. return; item.html( '<div class="error-div">' + @@ -274,7 +277,7 @@ function switchUploader( s ) { if ( typeof( uploader ) == 'object' ) uploader.refresh(); } else { - setUserSetting( 'uploader', '1' ); // 1 == html uploader + setUserSetting( 'uploader', '1' ); // 1 == html uploader. jQuery( '.media-upload-form' ).addClass( 'html-uploader' ); } } @@ -365,7 +368,7 @@ jQuery( document ).ready( function( $ ) { $( '.media-upload-form' ).bind( 'click.uploader', function( e ) { var target = $( e.target ), tr, c; - if ( target.is( 'input[type="radio"]' ) ) { // remember the last used image size and alignment + if ( target.is( 'input[type="radio"]' ) ) { // Remember the last used image size and alignment. tr = target.closest( 'tr' ); if ( tr.hasClass( 'align' ) ) @@ -373,7 +376,7 @@ jQuery( document ).ready( function( $ ) { else if ( tr.hasClass( 'image-size' ) ) setUserSetting( 'imgsize', target.val() ); - } else if ( target.is( 'button.button' ) ) { // remember the last used image link url + } else if ( target.is( 'button.button' ) ) { // Remember the last used image link url. c = e.target.className || ''; c = c.match( /url([^ '"]+)/ ); @@ -385,15 +388,15 @@ jQuery( document ).ready( function( $ ) { target.parents( '.media-item' ).fadeOut( 200, function() { $( this ).remove(); } ); - } else if ( target.is( '.upload-flash-bypass a' ) || target.is( 'a.uploader-html' ) ) { // switch uploader to html4 + } else if ( target.is( '.upload-flash-bypass a' ) || target.is( 'a.uploader-html' ) ) { // Switch uploader to html4. $( '#media-items, p.submit, span.big-file-warning' ).css( 'display', 'none' ); switchUploader( 0 ); e.preventDefault(); - } else if ( target.is( '.upload-html-bypass a' ) ) { // switch uploader to multi-file + } else if ( target.is( '.upload-html-bypass a' ) ) { // Switch uploader to multi-file. $( '#media-items, p.submit, span.big-file-warning' ).css( 'display', '' ); switchUploader( 1 ); e.preventDefault(); - } else if ( target.is( 'a.describe-toggle-on' ) ) { // Show + } else if ( target.is( 'a.describe-toggle-on' ) ) { // Show. target.parent().addClass( 'open' ); target.siblings( '.slidetoggle' ).fadeIn( 250, function() { var S = $( window ).scrollTop(), @@ -417,7 +420,7 @@ jQuery( document ).ready( function( $ ) { } ); e.preventDefault(); - } else if ( target.is( 'a.describe-toggle-off' ) ) { // Hide + } else if ( target.is( 'a.describe-toggle-off' ) ) { // Hide. target.siblings( '.slidetoggle' ).fadeOut( 250, function() { target.parent().removeClass( 'open' ); } ); @@ -450,9 +453,11 @@ jQuery( document ).ready( function( $ ) { times = tryAgainCount[ file.id ]; if ( times && times > 4 ) { - // The file may have been uploaded and attachment post created, - // but post-processing and resizing failed... - // Do a cleanup then tell the user to scale down the image and upload it again. + /* + * The file may have been uploaded and attachment post created, + * but post-processing and resizing failed... + * Do a cleanup then tell the user to scale down the image and upload it again. + */ $.ajax({ type: 'post', url: ajaxurl, @@ -514,7 +519,7 @@ jQuery( document ).ready( function( $ ) { }); } - // init and set the uploader + // Init and set the uploader. uploader_init = function() { uploader = new plupload.Uploader( wpUploaderInit ); diff --git a/src/js/_enqueues/vendor/plupload/wp-plupload.js b/src/js/_enqueues/vendor/plupload/wp-plupload.js index ea32444c7e..e42288fbe4 100644 --- a/src/js/_enqueues/vendor/plupload/wp-plupload.js +++ b/src/js/_enqueues/vendor/plupload/wp-plupload.js @@ -33,7 +33,7 @@ window.wp = window.wp || {}; */ Uploader = function( options ) { var self = this, - isIE, // not used, back-compat + isIE, // Not used, back-compat. elements = { container: 'container', browser: 'browse_button', @@ -60,10 +60,12 @@ window.wp = window.wp || {}; this.plupload = $.extend( true, { multipart_params: {} }, Uploader.defaults ); this.container = document.body; // Set default container. - // Extend the instance with options. - // - // Use deep extend to allow options.plupload to override individual - // default plupload keys. + /* + * Extend the instance with options. + * + * Use deep extend to allow options.plupload to override individual + * default plupload keys. + */ $.extend( true, this, options ); // Proxy all methods so this always refers to the current instance. @@ -138,9 +140,11 @@ window.wp = window.wp || {}; times = tryAgainCount[ file.id ]; if ( times && times > 4 ) { - // The file may have been uploaded and attachment post created, - // but post-processing and resizing failed... - // Do a cleanup then tell the user to scale down the image and upload it again. + /* + * The file may have been uploaded and attachment post created, + * but post-processing and resizing failed... + * Do a cleanup then tell the user to scale down the image and upload it again. + */ $.ajax({ type: 'post', url: ajaxurl, @@ -238,7 +242,7 @@ window.wp = window.wp || {}; fileUploaded = function( up, file, response ) { var complete; - // Remove the "uploading" UI elements + // Remove the "uploading" UI elements. _.each( ['file','loaded','size','percent'], function( key ) { file.attachment.unset( key ); } ); @@ -295,11 +299,13 @@ window.wp = window.wp || {}; }); dropzone.bind('dragleave.wp-uploader, drop.wp-uploader', function() { - // Using an instant timer prevents the drag-over class from - // being quickly removed and re-added when elements inside the - // dropzone are repositioned. - // - // @see https://core.trac.wordpress.org/ticket/21705 + /* + * Using an instant timer prevents the drag-over class + * from being quickly removed and re-added when elements + * inside the dropzone are repositioned. + * + * @see https://core.trac.wordpress.org/ticket/21705 + */ timer = setTimeout( function() { active = false; dropzone.trigger('dropzone:leave').removeClass('drag-over'); @@ -513,9 +519,11 @@ window.wp = window.wp || {}; node = node.parentNode; } - // If the browser node is not attached to the DOM, use a - // temporary container to house it, as the browser button - // shims require the button to exist in the DOM at all times. + /* + * If the browser node is not attached to the DOM, + * use a temporary container to house it, as the browser button shims + * require the button to exist in the DOM at all times. + */ if ( ! attached ) { id = 'wp-uploader-browser-' + this.uploader.id; diff --git a/src/js/_enqueues/vendor/tinymce/plugins/compat3x/plugin.js b/src/js/_enqueues/vendor/tinymce/plugins/compat3x/plugin.js index 92d433edcd..9be24f3e1a 100644 --- a/src/js/_enqueues/vendor/tinymce/plugins/compat3x/plugin.js +++ b/src/js/_enqueues/vendor/tinymce/plugins/compat3x/plugin.js @@ -44,7 +44,7 @@ this.add = function (callback, scope, prepend) { log('<target>.on' + newEventName + ".add(..)"); - // Convert callback({arg1:x, arg2:x}) -> callback(arg1, arg2) + // Convert callback({arg1:x, arg2:x}) -> callback(arg1, arg2). function patchedEventCallback(e) { var callbackArgs = []; diff --git a/src/js/_enqueues/vendor/tinymce/plugins/wordpress/plugin.js b/src/js/_enqueues/vendor/tinymce/plugins/wordpress/plugin.js index b7848cd987..cbb320b146 100644 --- a/src/js/_enqueues/vendor/tinymce/plugins/wordpress/plugin.js +++ b/src/js/_enqueues/vendor/tinymce/plugins/wordpress/plugin.js @@ -1,6 +1,6 @@ /* global getUserSetting, setUserSetting */ ( function( tinymce ) { -// Set the minimum value for the modals z-index higher than #wpadminbar (100000) +// Set the minimum value for the modals z-index higher than #wpadminbar (100000). if ( ! tinymce.ui.FloatPanel.zIndex || tinymce.ui.FloatPanel.zIndex < 100100 ) { tinymce.ui.FloatPanel.zIndex = 100100; } @@ -88,7 +88,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { } }); - // Hide the toolbars after loading + // Hide the toolbars after loading. editor.on( 'PostRender', function() { if ( editor.getParam( 'wordpress_adv_hidden', true ) && getUserSetting( 'hidetb', '0' ) === '0' ) { toggleToolbars( 'hide' ); @@ -191,7 +191,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { } }); - // Display the tag name instead of img in element path + // Display the tag name instead of img in element path. editor.on( 'ResolveName', function( event ) { var attr; @@ -200,7 +200,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { } }); - // Register commands + // Register commands. editor.addCommand( 'WP_More', function( tag ) { var parent, html, title, classname = 'wp-more-tag', @@ -215,13 +215,13 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { html = '<img src="' + tinymce.Env.transparentSrc + '" alt="" title="' + title + '" class="' + classname + '" ' + 'data-wp-more="' + tag + '" data-mce-resize="false" data-mce-placeholder="1" />'; - // Most common case + // Most common case. if ( node === rootNode || ( node.nodeName === 'P' && node.parentNode === rootNode ) ) { editor.insertContent( html ); return; } - // Get the top level parent node + // Get the top level parent node. parent = dom.getParent( node, function( found ) { if ( found.parentNode && found.parentNode === rootNode ) { return true; @@ -328,7 +328,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { html = '<div class="wp-editor-help">'; - // Main section, default and additional shortcuts + // Main section, default and additional shortcuts. html = html + '<h2>' + __( 'Default shortcuts,' ) + ' ' + meta + '</h2>' + '<table class="wp-help-th-center fixed">' + @@ -342,7 +342,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { '</table>'; if ( editor.plugins.wptextpattern && ( ! tinymce.Env.ie || tinymce.Env.ie > 8 ) ) { - // Text pattern section + // Text pattern section. html = html + '<h2>' + __( 'When starting a new paragraph with one of these formatting shortcuts followed by a space, the formatting will be applied automatically. Press Backspace or Escape to undo.' ) + '</h2>' + '<table class="wp-help-th-center fixed">' + @@ -363,7 +363,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { '</table>'; } - // Focus management section + // Focus management section. html = html + '<h2>' + __( 'Focus shortcuts:' ) + '</h2>' + '<table class="wp-help-single">' + @@ -413,7 +413,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { } }); - // Register buttons + // Register buttons. editor.addButton( 'wp_more', { tooltip: 'Insert Read More tag', onclick: function() { @@ -439,7 +439,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { stateSelector: 'code' }); - // Insert->Add Media + // Insert->Add Media. if ( wp && wp.media && wp.media.editor ) { editor.addButton( 'wp_add_media', { tooltip: 'Add Media', @@ -455,7 +455,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { }); } - // Insert "Read More..." + // Insert "Read More...". editor.addMenuItem( 'wp_more', { text: 'Insert Read More tag', icon: 'wp_more', @@ -465,7 +465,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { } }); - // Insert "Next Page" + // Insert "Next Page". editor.addMenuItem( 'wp_page', { text: 'Page break', icon: 'wp_page', @@ -496,7 +496,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { editor.on( 'init', function() { var env = tinymce.Env, - bodyClass = ['mceContentBody'], // back-compat for themes that use this in editor-style.css... + bodyClass = ['mceContentBody'], // Back-compat for themes that use this in editor-style.css... doc = editor.getDoc(), dom = editor.dom; @@ -531,7 +531,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { } }); - // Remove invalid parent paragraphs when inserting HTML + // Remove invalid parent paragraphs when inserting HTML. editor.on( 'BeforeSetContent', function( event ) { if ( event.content ) { event.content = event.content.replace( /<p>\s*<(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre)( [^>]*)?>/gi, '<$1$2>' ) @@ -554,21 +554,21 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { if ( editor.getParam( 'wp_paste_filters', true ) ) { editor.on( 'PastePreProcess', function( event ) { - // Remove trailing <br> added by WebKit browsers to the clipboard + // Remove trailing <br> added by WebKit browsers to the clipboard. event.content = event.content.replace( /<br class="?Apple-interchange-newline"?>/gi, '' ); - // In WebKit this is handled by removeWebKitStyles() + // In WebKit this is handled by removeWebKitStyles(). if ( ! tinymce.Env.webkit ) { - // Remove all inline styles + // Remove all inline styles. event.content = event.content.replace( /(<[^>]+) style="[^"]*"([^>]*>)/gi, '$1$2' ); - // Put back the internal styles + // Put back the internal styles. event.content = event.content.replace(/(<[^>]+) data-mce-style=([^>]+>)/gi, '$1 style=$2' ); } }); editor.on( 'PastePostProcess', function( event ) { - // Remove empty paragraphs + // Remove empty paragraphs. editor.$( 'p', event.node ).each( function( i, node ) { if ( dom.isEmpty( node ) ) { dom.remove( node ); @@ -585,7 +585,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { }); editor.on( 'SaveContent', function( event ) { - // If editor is hidden, we just want the textarea's value to be saved + // If editor is hidden, we just want the textarea's value to be saved. if ( ! editor.inline && editor.isHidden() ) { event.content = event.element.value; return; @@ -700,7 +700,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { wpTooltips = {}; - // For MacOS: ctrl = \u2303, cmd = \u2318, alt = \u2325 + // For MacOS: ctrl = \u2303, cmd = \u2318, alt = \u2325. if ( tinymce.Env.mac ) { access = '\u2303\u2325'; meta = '\u2318'; @@ -761,7 +761,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { } function addShortcutsToListbox() { - // listbox for the "blocks" drop-down + // listbox for the "blocks" drop-down. each( editor.theme.panel.find( 'listbox' ), function( listbox ) { if ( listbox && listbox.settings.text === 'Paragraph' ) { each( listbox.settings.values, function( item ) { @@ -1118,9 +1118,11 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { event.type === 'resize' || event.type === 'scroll' ) && ! activeToolbar.blockHide ) { - // Showing a tooltip may trigger a `resize` event in Chromium browsers. - // That results in a flicketing inline menu; tooltips are shown on hovering over a button, - // which then hides the toolbar on `resize`, then it repeats as soon as the toolbar is shown again. + /* + * Showing a tooltip may trigger a `resize` event in Chromium browsers. + * That results in a flicketing inline menu; tooltips are shown on hovering over a button, + * which then hides the toolbar on `resize`, then it repeats as soon as the toolbar is shown again. + */ if ( event.type === 'resize' || event.type === 'resizewindow' ) { win = editor.getWin(); size = win.innerHeight + win.innerWidth; @@ -1187,7 +1189,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { function noop() {} - // Expose some functions (back-compat) + // Expose some functions (back-compat). return { _showButtons: noop, _hideButtons: noop, diff --git a/src/js/_enqueues/vendor/tinymce/plugins/wpautoresize/plugin.js b/src/js/_enqueues/vendor/tinymce/plugins/wpautoresize/plugin.js index 98905f6478..6e0a1a8d82 100644 --- a/src/js/_enqueues/vendor/tinymce/plugins/wpautoresize/plugin.js +++ b/src/js/_enqueues/vendor/tinymce/plugins/wpautoresize/plugin.js @@ -61,13 +61,13 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) { if ( ! body || ( e && e.type === 'setcontent' && e.initial ) || isFullscreen() ) { if ( body && docElm ) { body.style.overflowY = 'auto'; - docElm.style.overflowY = 'auto'; // Old IE + docElm.style.overflowY = 'auto'; // Old IE. } return; } - // Calculate outer height of the body element using CSS styles + // Calculate outer height of the body element using CSS styles. marginTop = editor.dom.getStyle( body, 'margin-top', true ); marginBottom = editor.dom.getStyle( body, 'margin-bottom', true ); paddingTop = editor.dom.getStyle( body, 'padding-top', true ); @@ -83,36 +83,36 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) { myHeight = docElm.offsetHeight; } - // Make sure we have a valid height + // Make sure we have a valid height. if ( isNaN( myHeight ) || myHeight <= 0 ) { - // Get height differently depending on the browser used + // Get height differently depending on the browser used. myHeight = tinymce.Env.ie ? body.scrollHeight : ( tinymce.Env.webkit && body.clientHeight === 0 ? 0 : body.offsetHeight ); } - // Don't make it smaller than the minimum height + // Don't make it smaller than the minimum height. if ( myHeight > settings.autoresize_min_height ) { resizeHeight = myHeight; } - // If a maximum height has been defined don't exceed this height + // If a maximum height has been defined don't exceed this height. if ( settings.autoresize_max_height && myHeight > settings.autoresize_max_height ) { resizeHeight = settings.autoresize_max_height; body.style.overflowY = 'auto'; - docElm.style.overflowY = 'auto'; // Old IE + docElm.style.overflowY = 'auto'; // Old IE. } else { body.style.overflowY = 'hidden'; - docElm.style.overflowY = 'hidden'; // Old IE + docElm.style.overflowY = 'hidden'; // Old IE. body.scrollTop = 0; } - // Resize content element + // Resize content element. if (resizeHeight !== oldSize) { deltaSize = resizeHeight - oldSize; DOM.setStyle( editor.iframeElement, 'height', resizeHeight + 'px' ); oldSize = resizeHeight; - // WebKit doesn't decrease the size of the body element until the iframe gets resized - // So we need to continue to resize the iframe down until the size gets fixed + // WebKit doesn't decrease the size of the body element until the iframe gets resized. + // So we need to continue to resize the iframe down until the size gets fixed. if ( tinymce.isWebKit && deltaSize < 0 ) { resize( e ); } @@ -137,17 +137,17 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) { }, interval ); } - // Define minimum height + // Define minimum height. settings.autoresize_min_height = parseInt(editor.getParam( 'autoresize_min_height', editor.getElement().offsetHeight), 10 ); - // Define maximum height + // Define maximum height. settings.autoresize_max_height = parseInt(editor.getParam( 'autoresize_max_height', 0), 10 ); function on() { if ( ! editor.dom.hasClass( editor.getBody(), 'wp-autoresize' ) ) { isActive = true; editor.dom.addClass( editor.getBody(), 'wp-autoresize' ); - // Add appropriate listeners for resizing the content area + // Add appropriate listeners for resizing the content area. editor.on( 'nodechange setcontent keyup FullscreenStateChanged', resize ); resize(); } @@ -156,20 +156,20 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) { function off() { var doc; - // Don't turn off if the setting is 'on' + // Don't turn off if the setting is 'on'. if ( ! settings.wp_autoresize_on ) { isActive = false; doc = editor.getDoc(); editor.dom.removeClass( editor.getBody(), 'wp-autoresize' ); editor.off( 'nodechange setcontent keyup FullscreenStateChanged', resize ); doc.body.style.overflowY = 'auto'; - doc.documentElement.style.overflowY = 'auto'; // Old IE + doc.documentElement.style.overflowY = 'auto'; // Old IE. oldSize = 0; } } if ( settings.wp_autoresize_on ) { - // Turn resizing on when the editor loads + // Turn resizing on when the editor loads. isActive = true; editor.on( 'init', function() { @@ -184,24 +184,24 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) { if ( editor.getParam( 'autoresize_on_init', true ) ) { editor.on( 'init', function() { - // Hit it 10 times in 200 ms intervals + // Hit it 10 times in 200 ms intervals. wait( 10, 200, function() { - // Hit it 5 times in 1 sec intervals + // Hit it 5 times in 1 sec intervals. wait( 5, 1000 ); }); }); } } - // Reset the stored size + // Reset the stored size. editor.on( 'show', function() { oldSize = 0; }); - // Register the command + // Register the command. editor.addCommand( 'wpAutoResize', resize ); - // On/off + // On/off. editor.addCommand( 'wpAutoResizeOn', on ); editor.addCommand( 'wpAutoResizeOff', off ); }); diff --git a/src/js/_enqueues/vendor/tinymce/plugins/wpdialogs/plugin.js b/src/js/_enqueues/vendor/tinymce/plugins/wpdialogs/plugin.js index 8b9229fdbc..11c8d5fdc4 100644 --- a/src/js/_enqueues/vendor/tinymce/plugins/wpdialogs/plugin.js +++ b/src/js/_enqueues/vendor/tinymce/plugins/wpdialogs/plugin.js @@ -30,7 +30,7 @@ tinymce.WPWindowManager = tinymce.InlineWindowManager = function( editor ) { } if ( typeof jQuery === 'undefined' || ! jQuery.wp || ! jQuery.wp.wpdialog ) { - // wpdialog.js is not loaded + // wpdialog.js is not loaded. if ( window.console && window.console.error ) { window.console.error('wpdialog.js is not loaded. Please set "wpdialogs" as dependency for your script when calling wp_enqueue_script(). You may also want to enqueue the "wp-jquery-ui-dialog" stylesheet.'); } @@ -54,7 +54,7 @@ tinymce.WPWindowManager = tinymce.InlineWindowManager = function( editor ) { // Store selection. Takes a snapshot in the FocusManager of the selection before focus is moved to the dialog. editor.nodeChanged(); - // Create the dialog if necessary + // Create the dialog if necessary. if ( ! $element.data('wpdialog') ) { $element.wpdialog({ title: args.title, @@ -85,7 +85,7 @@ tinymce.WPWindowManager = tinymce.InlineWindowManager = function( editor ) { }; tinymce.PluginManager.add( 'wpdialogs', function( editor ) { - // Replace window manager + // Replace window manager. editor.on( 'init', function() { editor.windowManager = new tinymce.WPWindowManager( editor ); }); diff --git a/src/js/_enqueues/vendor/tinymce/plugins/wpeditimage/plugin.js b/src/js/_enqueues/vendor/tinymce/plugins/wpeditimage/plugin.js index 9142ed5717..ac6c83b427 100644 --- a/src/js/_enqueues/vendor/tinymce/plugins/wpeditimage/plugin.js +++ b/src/js/_enqueues/vendor/tinymce/plugins/wpeditimage/plugin.js @@ -18,7 +18,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { } ); editor.addButton( 'wp_img_edit', { - tooltip: 'Edit|button', // '|button' is not displayed, only used for context + tooltip: 'Edit|button', // '|button' is not displayed, only used for context. icon: 'dashicon dashicons-edit', onclick: function() { editImage( editor.selection.getNode() ); @@ -146,7 +146,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { caption = trim( img[2] ); img = trim( img[1] ); } else { - // old captions shortcode style + // Old captions shortcode style. caption = trim( b ).replace( /caption=['"]/, '' ).replace( /['"]$/, '' ); img = c; } @@ -214,18 +214,18 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { } caption = caption.replace( /\r\n|\r/g, '\n' ).replace( /<[a-zA-Z0-9]+( [^<>]+)?>/g, function( a ) { - // no line breaks inside HTML tags + // No line breaks inside HTML tags. return a.replace( /[\r\n\t]+/, ' ' ); }); - // convert remaining line breaks to <br> + // Convert remaining line breaks to <br>. caption = caption.replace( /\s*\n\s*/g, '<br />' ); return '[caption id="' + id + '" align="' + align + '" width="' + width + '"' + classes + ']' + c + ' ' + caption + '[/caption]'; }); if ( out.indexOf('[caption') === -1 ) { - // the caption html seems broken, try to find the image that may be wrapped in a link + // The caption html seems broken, try to find the image that may be wrapped in a link // and may be followed by <p> with the caption text. out = dl.replace( /[\s\S]*?((?:<a [^>]+>)?<img [^>]+>(?:<\/a>)?)(<p>[\s\S]*<\/p>)?[\s\S]*/gi, '<p>$1</p>$2' ); } @@ -240,7 +240,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { dom = editor.dom, isIntRegExp = /^\d+$/; - // default attributes + // Default attributes. metadata = { attachment_id: false, size: 'custom', @@ -292,7 +292,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { metadata.extraClasses = extraClasses.join( ' ' ); - // Extract caption + // Extract caption. captionBlock = dom.getParents( imageNode, '.wp-caption' ); if ( captionBlock.length ) { @@ -318,7 +318,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { } } - // Extract linkTo + // Extract linkTo. if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' ) { link = imageNode.parentNode; metadata.linkUrl = dom.getAttrib( link, 'href' ); @@ -334,7 +334,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { return node && !! ( node.textContent || node.innerText ).replace( /\ufeff/g, '' ); } - // Verify HTML in captions + // Verify HTML in captions. function verifyHTML( caption ) { if ( ! caption || ( caption.indexOf( '<' ) === -1 && caption.indexOf( '>' ) === -1 ) ) { return caption; @@ -404,7 +404,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { }; if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' && ! hasTextContent( imageNode.parentNode ) ) { - // Update or remove an existing link wrapped around the image + // Update or remove an existing link wrapped around the image. if ( imageData.linkUrl ) { dom.setAttribs( imageNode.parentNode, linkAttrs ); } else { @@ -413,11 +413,11 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { } else if ( imageData.linkUrl ) { if ( linkNode = dom.getParent( imageNode, 'a' ) ) { // The image is inside a link together with other nodes, - // or is nested in another node, move it out + // or is nested in another node, move it out. dom.insertAfter( imageNode, linkNode ); } - // Add link wrapped around the image + // Add link wrapped around the image. linkNode = dom.create( 'a', linkAttrs ); imageNode.parentNode.insertBefore( linkNode, imageNode ); linkNode.appendChild( imageNode ); @@ -467,7 +467,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { } else { id = id ? 'id="'+ id +'" ' : ''; - // should create a new function for generating the caption markup + // Should create a new function for generating the caption markup. html = '<dl ' + id + 'class="' + className +'" style="width: '+ width +'px">' + '<dt class="wp-caption-dt"></dt><dd class="wp-caption-dd">'+ imageData.caption +'</dd></dl>'; @@ -486,7 +486,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { } } } else if ( captionNode ) { - // Remove the caption wrapper and place the image in new paragraph + // Remove the caption wrapper and place the image in new paragraph. parent = dom.create( 'p' ); captionNode.parentNode.insertBefore( parent, captionNode ); parent.appendChild( node ); @@ -530,7 +530,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { // Mark the image node so we can select it later. editor.$( img ).attr( 'data-wp-editing', 1 ); - // Manipulate the metadata by reference that is fed into the PostImage model used in the media modal + // Manipulate the metadata by reference that is fed into the PostImage model used in the media modal. wp.media.events.trigger( 'editor:image-edit', { editor: editor, metadata: metadata, @@ -558,9 +558,11 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { editor.focus(); frame.detach(); - // `close` fires first... - // To be able to update the image node, we need to find it here, - // and use it in the callback. + /* + * `close` fires first... + * To be able to update the image node, we need to find it here, + * and use it in the callback. + */ imageNode = editor.$( 'img[data-wp-editing]' ) imageNode.removeAttr( 'data-wp-editing' ); }); @@ -600,12 +602,12 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { dom.addClass( editor.getBody(), captionClass ); - // Prevent IE11 from making dl.wp-caption resizable + // Prevent IE11 from making dl.wp-caption resizable. if ( tinymce.Env.ie && tinymce.Env.ie > 10 ) { - // The 'mscontrolselect' event is supported only in IE11+ + // The 'mscontrolselect' event is supported only in IE11+. dom.bind( editor.getBody(), 'mscontrolselect', function( event ) { if ( event.target.nodeName === 'IMG' && dom.getParent( event.target, '.wp-caption' ) ) { - // Hide the thick border with resize handles around dl.wp-caption + // Hide the thick border with resize handles around dl.wp-caption. editor.getBody().focus(); // :( } else if ( event.target.nodeName === 'DL' && dom.hasClass( event.target, 'wp-caption' ) ) { // Trigger the thick border with resize handles... @@ -688,25 +690,31 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { if ( cmd === 'mceInsertContent' ) { if ( pasteInCaption ) { pasteInCaption = false; - // We are in the caption element, and in 'paste' context, - // and the pasted HTML was cleaned up on 'pastePostProcess' above. - // Let it be pasted in the caption. + /* + * We are in the caption element, and in 'paste' context, + * and the pasted HTML was cleaned up on 'pastePostProcess' above. + * Let it be pasted in the caption. + */ return; } - // The paste is somewhere else in the caption DL element. - // Prevent pasting in there as it will break the caption. - // Make new paragraph under the caption DL and move the caret there. + /* + * The paste is somewhere else in the caption DL element. + * Prevent pasting in there as it will break the caption. + * Make new paragraph under the caption DL and move the caret there. + */ p = dom.create( 'p' ); dom.insertAfter( p, captionParent ); editor.selection.setCursorLocation( p, 0 ); - // If the image is selected and the user pastes "over" it, - // replace both the image and the caption elements with the pasted content. - // This matches the behavior when pasting over non-caption images. + /* + * If the image is selected and the user pastes "over" it, + * replace both the image and the caption elements with the pasted content. + * This matches the behavior when pasting over non-caption images. + */ if ( node.nodeName === 'IMG' ) { - editor.$( captionParent ).remove(); - } + editor.$( captionParent ).remove(); + } editor.nodeChanged(); } else { @@ -759,7 +767,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { VK = tinymce.util.VK; if ( keyCode === VK.ENTER ) { - // When pressing Enter inside a caption move the caret to a new parapraph under it + // When pressing Enter inside a caption move the caret to a new parapraph under it. node = selection.getNode(); wrap = dom.getParent( node, 'div.mceTemp' ); @@ -802,9 +810,11 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { } }); - // After undo/redo FF seems to set the image height very slowly when it is set to 'auto' in the CSS. - // This causes image.getBoundingClientRect() to return wrong values and the resize handles are shown in wrong places. - // Collapse the selection to remove the resize handles. + /* + * After undo/redo FF seems to set the image height very slowly when it is set to 'auto' in the CSS. + * This causes image.getBoundingClientRect() to return wrong values and the resize handles are shown in wrong places. + * Collapse the selection to remove the resize handles. + */ if ( tinymce.Env.gecko ) { editor.on( 'undo redo', function() { if ( editor.selection.getNode().nodeName === 'IMG' ) { @@ -878,7 +888,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { } ); } )(); - // Add to editor.wp + // Add to editor.wp. editor.wp = editor.wp || {}; editor.wp.isPlaceholder = isPlaceholder; diff --git a/src/js/_enqueues/vendor/tinymce/plugins/wpemoji/plugin.js b/src/js/_enqueues/vendor/tinymce/plugins/wpemoji/plugin.js index 7d3e4baaef..84de774d70 100644 --- a/src/js/_enqueues/vendor/tinymce/plugins/wpemoji/plugin.js +++ b/src/js/_enqueues/vendor/tinymce/plugins/wpemoji/plugin.js @@ -56,18 +56,22 @@ } if ( isWin8 ) { - // Windows 8+ emoji can be "typed" with the onscreen keyboard. - // That triggers the normal keyboard events, but not the 'input' event. - // Thankfully it sets keyCode 231 when the onscreen keyboard inserts any emoji. + /* + * Windows 8+ emoji can be "typed" with the onscreen keyboard. + * That triggers the normal keyboard events, but not the 'input' event. + * Thankfully it sets keyCode 231 when the onscreen keyboard inserts any emoji. + */ editor.on( 'keyup', function( event ) { if ( event.keyCode === 231 ) { parseNode( editor.selection.getNode() ); } } ); } else if ( ! isWin ) { - // In MacOS inserting emoji doesn't trigger the stanradr keyboard events. - // Thankfully it triggers the 'input' event. - // This works in Android and iOS as well. + /* + * In MacOS inserting emoji doesn't trigger the stanradr keyboard events. + * Thankfully it triggers the 'input' event. + * This works in Android and iOS as well. + */ editor.on( 'keydown keyup', function( event ) { typing = ( event.type === 'keydown' ); } ); diff --git a/src/js/_enqueues/vendor/tinymce/plugins/wpgallery/plugin.js b/src/js/_enqueues/vendor/tinymce/plugins/wpgallery/plugin.js index d9723f2db5..54245efaa5 100644 --- a/src/js/_enqueues/vendor/tinymce/plugins/wpgallery/plugin.js +++ b/src/js/_enqueues/vendor/tinymce/plugins/wpgallery/plugin.js @@ -57,7 +57,7 @@ tinymce.PluginManager.add('wpgallery', function( editor ) { } } - // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('...'); + // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('...'). editor.addCommand( 'WP_Gallery', function() { editMedia( editor.selection.getNode() ); }); @@ -71,7 +71,7 @@ tinymce.PluginManager.add('wpgallery', function( editor ) { } if ( node.nodeName === 'IMG' && dom.getAttrib( node, 'data-wp-media' ) ) { - // Don't trigger on right-click + // Don't trigger on right-click. if ( event.button !== 2 ) { if ( dom.hasClass( node, 'wp-media-selected' ) ) { editMedia( node ); @@ -85,7 +85,7 @@ tinymce.PluginManager.add('wpgallery', function( editor ) { } }); - // Display gallery, audio or video instead of img in the element path + // Display gallery, audio or video instead of img in the element path. editor.on( 'ResolveName', function( event ) { var dom = editor.dom, node = event.target; @@ -98,7 +98,7 @@ tinymce.PluginManager.add('wpgallery', function( editor ) { }); editor.on( 'BeforeSetContent', function( event ) { - // 'wpview' handles the gallery shortcode when present + // 'wpview' handles the gallery shortcode when present. if ( ! editor.plugins.wpview || typeof wp === 'undefined' || ! wp.mce ) { event.content = replaceGalleryShortcodes( event.content ); } diff --git a/src/js/_enqueues/vendor/tinymce/plugins/wplink/plugin.js b/src/js/_enqueues/vendor/tinymce/plugins/wplink/plugin.js index 890ebe86c2..29f98a128f 100644 --- a/src/js/_enqueues/vendor/tinymce/plugins/wplink/plugin.js +++ b/src/js/_enqueues/vendor/tinymce/plugins/wplink/plugin.js @@ -37,9 +37,9 @@ url = this.url; } - // If the URL is longer that 40 chars, concatenate the beginning (after the domain) and ending with ... + // If the URL is longer that 40 chars, concatenate the beginning (after the domain) and ending with '...'. if ( url.length > 40 && ( index = url.indexOf( '/' ) ) !== -1 && ( lastIndex = url.lastIndexOf( '/' ) ) !== -1 && lastIndex !== index ) { - // If the beginning + ending are shorter that 40 chars, show more of the ending + // If the beginning + ending are shorter that 40 chars, show more of the ending. if ( index + url.length - lastIndex < 40 ) { lastIndex = -( 40 - ( index + 1 ) ); } @@ -297,10 +297,10 @@ editor.execCommand( 'wp_link_cancel' ); } ); - // WP default shortcuts + // WP default shortcuts. editor.addShortcut( 'access+a', '', 'WP_Link' ); editor.addShortcut( 'access+s', '', 'wp_unlink' ); - // The "de-facto standard" shortcut, see #27305 + // The "de-facto standard" shortcut, see #27305. editor.addShortcut( 'meta+k', '', 'WP_Link' ); editor.addButton( 'link', { @@ -565,7 +565,7 @@ } ); editor.addButton( 'wp_link_edit', { - tooltip: 'Edit|button', // '|button' is not displayed, only used for context + tooltip: 'Edit|button', // '|button' is not displayed, only used for context. icon: 'dashicon dashicons-edit', cmd: 'WP_Link' } ); diff --git a/src/js/_enqueues/vendor/tinymce/plugins/wptextpattern/plugin.js b/src/js/_enqueues/vendor/tinymce/plugins/wptextpattern/plugin.js index 236775034c..a11515acb1 100644 --- a/src/js/_enqueues/vendor/tinymce/plugins/wptextpattern/plugin.js +++ b/src/js/_enqueues/vendor/tinymce/plugins/wptextpattern/plugin.js @@ -149,9 +149,9 @@ var before = string.charAt( startOffset - 1 ); var after = string.charAt( startOffset + p.delimiter.length ); - // test*test* => format applied - // test *test* => applied - // test* test* => not applied + // test*test* => format applied. + // test *test* => applied. + // test* test* => not applied. if ( startOffset && /\S/.test( before ) ) { if ( /\s/.test( after ) || before === delimiterFirstChar ) { return; diff --git a/src/js/_enqueues/vendor/tinymce/plugins/wpview/plugin.js b/src/js/_enqueues/vendor/tinymce/plugins/wpview/plugin.js index 573ecb4167..1c21854786 100644 --- a/src/js/_enqueues/vendor/tinymce/plugins/wpview/plugin.js +++ b/src/js/_enqueues/vendor/tinymce/plugins/wpview/plugin.js @@ -52,7 +52,7 @@ var className = editor.getBody().className; editor.$( 'iframe[class="wpview-sandbox"]' ).each( function( i, iframe ) { - // Make sure it is a local iframe + // Make sure it is a local iframe. // jshint scripturl: true if ( ! iframe.src || iframe.src === 'javascript:""' ) { try { @@ -79,11 +79,11 @@ node = editor.selection.getNode(); if ( node && node !== editor.getBody() && /^\s*https?:\/\/\S+\s*$/i.test( event.content ) ) { - // When a url is pasted or inserted, only try to embed it when it is in an empty paragrapgh. + // When a url is pasted or inserted, only try to embed it when it is in an empty paragraph. node = editor.dom.getParent( node, 'p' ); if ( node && /^[\s\uFEFF\u00A0]*$/.test( editor.$( node ).text() || '' ) ) { - // Make sure there are no empty inline elements in the <p> + // Make sure there are no empty inline elements in the <p>. node.innerHTML = ''; } else { return; @@ -178,7 +178,7 @@ } ); editor.addButton( 'wp_view_edit', { - tooltip: 'Edit|button', // '|button' is not displayed, only used for context + tooltip: 'Edit|button', // '|button' is not displayed, only used for context. icon: 'dashicon dashicons-edit', onclick: function() { var node = editor.selection.getNode(); diff --git a/src/js/_enqueues/vendor/tinymce/wp-tinymce.php b/src/js/_enqueues/vendor/tinymce/wp-tinymce.php index 3d7b2347f6..213e9327b5 100644 --- a/src/js/_enqueues/vendor/tinymce/wp-tinymce.php +++ b/src/js/_enqueues/vendor/tinymce/wp-tinymce.php @@ -26,10 +26,10 @@ function get_file( $path ) { return @file_get_contents( $path ); } -$expires_offset = 31536000; // 1 year +$expires_offset = 31536000; // 1 year. header( 'Content-Type: application/javascript; charset=UTF-8' ); -header( 'Vary: Accept-Encoding' ); // Handle proxies +header( 'Vary: Accept-Encoding' ); // Handle proxies. header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expires_offset ) . ' GMT' ); header( "Cache-Control: public, max-age=$expires_offset" ); diff --git a/src/js/_enqueues/wp/api-request.js b/src/js/_enqueues/wp/api-request.js index 3ed1c68695..51df7f6f64 100644 --- a/src/js/_enqueues/wp/api-request.js +++ b/src/js/_enqueues/wp/api-request.js @@ -8,7 +8,7 @@ * - Sends the REST API nonce as a request header. * - Allows specifying only an endpoint namespace/path instead of a full URL. * - * @since 4.9.0 + * @since 4.9.0 * @output wp-includes/js/api-request.js */ @@ -42,8 +42,8 @@ apiRoot = wpApiSettings.root; path = path.replace( /^\//, '' ); - // API root may already include query parameter prefix if site is - // configured to use plain permalinks. + // API root may already include query parameter prefix + // if site is configured to use plain permalinks. if ( 'string' === typeof apiRoot && -1 !== apiRoot.indexOf( '?' ) ) { path = path.replace( '?', '&' ); } diff --git a/src/js/_enqueues/wp/api.js b/src/js/_enqueues/wp/api.js index cbd3d4bc6b..8233e4a52c 100644 --- a/src/js/_enqueues/wp/api.js +++ b/src/js/_enqueues/wp/api.js @@ -107,9 +107,11 @@ minutesOffset = 0, numericKeys = [ 1, 4, 5, 6, 7, 10, 11 ]; - // ES5 §15.9.4.2 states that the string should attempt to be parsed as a Date Time String Format string - // before falling back to any implementation-specific date parsing, so that’s what we do, even if native - // implementations could be faster. + /* + * ES5 §15.9.4.2 states that the string should attempt to be parsed as a Date Time String Format string + * before falling back to any implementation-specific date parsing, so that’s what we do, even if native + * implementations could be faster. + */ // 1 YYYY 2 MM 3 DD 4 HH 5 mm 6 ss 7 msec 8 Z 9 ± 10 tzHH 11 tzmm if ( ( struct = /^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/.exec( date ) ) ) { @@ -855,7 +857,7 @@ if ( _.isFunction( model.nonce ) && ! _.isEmpty( model.nonce() ) ) { beforeSend = options.beforeSend; - // @todo enable option for jsonp endpoints + // @todo Enable option for jsonp endpoints. // options.dataType = 'jsonp'; // Include the nonce with requests. @@ -1340,7 +1342,7 @@ } ); } else { - // This is a model without a parent in its route + // This is a model without a parent in its route. modelClassName = wp.api.utils.capitalizeAndCamelCaseDashes( routeName ); modelClassName = mapping.models[ modelClassName ] || modelClassName; loadingObjects.models[ modelClassName ] = wp.api.WPApiBaseModel.extend( { @@ -1514,7 +1516,7 @@ if ( ! initializedDeferreds[ attributes.apiRoot + attributes.versionString ] ) { - // Look for an existing copy of this endpoint + // Look for an existing copy of this endpoint. endpoint = wp.api.endpoints.findWhere( { 'apiRoot': attributes.apiRoot, 'versionString': attributes.versionString } ); if ( ! endpoint ) { endpoint = new Endpoint( attributes ); diff --git a/src/js/_enqueues/wp/autosave.js b/src/js/_enqueues/wp/autosave.js index a96ea97bf9..33c7e2d3b6 100644 --- a/src/js/_enqueues/wp/autosave.js +++ b/src/js/_enqueues/wp/autosave.js @@ -3,7 +3,7 @@ */ /* global tinymce, wpCookies, autosaveL10n, switchEditors */ -// Back-compat +// Back-compat. window.autosave = function() { return true; }; @@ -209,7 +209,7 @@ window.autosave = function() { */ function getStorage() { var stored_obj = false; - // Separate local storage containers for each blog_id + // Separate local storage containers for each blog_id. if ( hasStorage && blog_id ) { stored_obj = sessionStorage.getItem( 'wp-autosave-' + blog_id ); @@ -314,7 +314,7 @@ window.autosave = function() { /** * Saves post data for the current post. * - * Runs on a 15 sec. interval, saves when there are differences in the post title or content. + * Runs on a 15 seconds interval, saves when there are differences in the post title or content. * When the optional data is provided, updates the last saved post data. * * @since 3.9.0 @@ -378,9 +378,11 @@ window.autosave = function() { // Check if the local post data is different than the loaded post data. if ( $( '#wp-content-wrap' ).hasClass( 'tmce-active' ) ) { - // If TinyMCE loads first, check the post 1.5 sec. after it is ready. - // By this time the content has been loaded in the editor and 'saved' to the textarea. - // This prevents false positives. + /* + * If TinyMCE loads first, check the post 1.5 seconds after it is ready. + * By this time the content has been loaded in the editor and 'saved' to the textarea. + * This prevents false positives. + */ $document.on( 'tinymce-editor-init.autosave', function() { window.setTimeout( function() { checkPost(); @@ -390,7 +392,7 @@ window.autosave = function() { checkPost(); } - // Save every 15 sec. + // Save every 15 seconds. intervalTimer = window.setInterval( save, 15000 ); $( 'form#post' ).on( 'submit.autosave-local', function() { @@ -456,7 +458,7 @@ window.autosave = function() { if ( cookie === post_id + '-saved' ) { wpCookies.remove( 'wp-saving-post' ); - // The post was saved properly, remove old data and bail + // The post was saved properly, remove old data and bail. setData( false ); return; } @@ -519,7 +521,7 @@ window.autosave = function() { var editor; if ( postData ) { - // Set the last saved data + // Set the last saved data. lastCompareString = getCompareString( postData ); if ( $( '#title' ).val() !== postData.post_title ) { @@ -534,14 +536,14 @@ window.autosave = function() { postData.content = switchEditors.wpautop( postData.content ); } - // Make sure there's an undo level in the editor + // Make sure there's an undo level in the editor. editor.undoManager.transact( function() { editor.setContent( postData.content || '' ); editor.nodeChanged(); }); } else { - // Make sure the Text editor is selected + // Make sure the Text editor is selected. $( '#content-html' ).click(); $( '#content' ).focus(); @@ -558,9 +560,11 @@ window.autosave = function() { blog_id = typeof window.autosaveL10n !== 'undefined' && window.autosaveL10n.blog_id; - // Check if the browser supports sessionStorage and it's not disabled, - // then initialize and run checkPost(). - // Don't run if the post type supports neither 'editor' (textarea#content) nor 'excerpt'. + /* + * Check if the browser supports sessionStorage and it's not disabled, + * then initialize and run checkPost(). + * Don't run if the post type supports neither 'editor' (textarea#content) nor 'excerpt'. + */ if ( checkStorage() && blog_id && ( $('#content').length || $('#excerpt').length ) ) { $document.ready( run ); } @@ -652,7 +656,7 @@ window.autosave = function() { enableButtons(); if ( data.success ) { - // No longer an auto-draft + // No longer an auto-draft. $( '#auto_draft' ).val(''); } } @@ -698,7 +702,7 @@ window.autosave = function() { function save() { var postData, compareString; - // window.autosave() used for back-compat + // window.autosave() used for back-compat. if ( isSuspended || _blockSave || ! window.autosave() ) { return false; } @@ -710,12 +714,12 @@ window.autosave = function() { postData = getPostData(); compareString = getCompareString( postData ); - // First check + // First check. if ( typeof lastCompareString === 'undefined' ) { lastCompareString = initialCompareString; } - // No change + // No change. if ( compareString === lastCompareString ) { return false; } @@ -836,7 +840,7 @@ window.autosave = function() { } }).ready( function() { - // Set the initial compare string in case TinyMCE is not used or not loaded first + // Set the initial compare string in case TinyMCE is not used or not loaded first. initialCompareString = getCompareString(); }); diff --git a/src/js/_enqueues/wp/code-editor.js b/src/js/_enqueues/wp/code-editor.js index 15906ff55b..dd0feca956 100644 --- a/src/js/_enqueues/wp/code-editor.js +++ b/src/js/_enqueues/wp/code-editor.js @@ -79,7 +79,11 @@ if ( 'undefined' === typeof window.wp.codeEditor ) { options = $.extend( {}, options ); } - // Note that rules must be sent in the "deprecated" lint.options property to prevent linter from complaining about unrecognized options. See <https://github.com/codemirror/CodeMirror/pull/4944>. + /* + * Note that rules must be sent in the "deprecated" lint.options property + * to prevent linter from complaining about unrecognized options. + * See <https://github.com/codemirror/CodeMirror/pull/4944>. + */ if ( ! options.options ) { options.options = {}; } diff --git a/src/js/_enqueues/wp/custom-header.js b/src/js/_enqueues/wp/custom-header.js index 1c405990de..1f2c56f96e 100644 --- a/src/js/_enqueues/wp/custom-header.js +++ b/src/js/_enqueues/wp/custom-header.js @@ -79,7 +79,7 @@ * @return {boolean} */ supportsVideo: function() { - // Don't load video on small screens. @todo: consider bandwidth and other factors. + // Don't load video on small screens. @todo Consider bandwidth and other factors. if ( window.innerWidth < settings.minWidth || window.innerHeight < settings.minHeight ) { return false; } diff --git a/src/js/_enqueues/wp/customize/base.js b/src/js/_enqueues/wp/customize/base.js index 183b731ace..1d38d9b0dc 100644 --- a/src/js/_enqueues/wp/customize/base.js +++ b/src/js/_enqueues/wp/customize/base.js @@ -25,17 +25,21 @@ window.wp = window.wp || {}; inherits = function( parent, protoProps, staticProps ) { var child; - // The constructor function for the new subclass is either defined by you - // (the "constructor" property in your `extend` definition), or defaulted - // by us to simply call `super()`. + /* + * The constructor function for the new subclass is either defined by you + * (the "constructor" property in your `extend` definition), or defaulted + * by us to simply call `super()`. + */ if ( protoProps && protoProps.hasOwnProperty( 'constructor' ) ) { child = protoProps.constructor; } else { child = function() { - // Storing the result `super()` before returning the value - // prevents a bug in Opera where, if the constructor returns - // a function, Opera will reject the return value in favor of - // the original object. This causes all sorts of trouble. + /* + * Storing the result `super()` before returning the value + * prevents a bug in Opera where, if the constructor returns + * a function, Opera will reject the return value in favor of + * the original object. This causes all sorts of trouble. + */ var result = parent.apply( this, arguments ); return result; }; @@ -44,8 +48,8 @@ window.wp = window.wp || {}; // Inherit class (static) properties from parent. $.extend( child, parent ); - // Set the prototype chain to inherit from `parent`, without calling - // `parent`'s constructor function. + // Set the prototype chain to inherit from `parent`, + // without calling `parent`'s constructor function. ctor.prototype = parent.prototype; child.prototype = new ctor(); @@ -187,7 +191,7 @@ window.wp = window.wp || {}; * @param {object} options */ initialize: function( initial, options ) { - this._value = initial; // @todo: potentially change this to a this.set() call. + this._value = initial; // @todo Potentially change this to a this.set() call. this.callbacks = $.Callbacks(); this._dirty = false; @@ -496,7 +500,7 @@ window.wp = window.wp || {}; ids = slice.call( arguments ), dfd = $.Deferred(); - // If the last argument is a callback, bind it to .done() + // If the last argument is a callback, bind it to .done(). if ( $.isFunction( ids[ ids.length - 1 ] ) ) { dfd.done( ids.pop() ); } @@ -699,7 +703,7 @@ window.wp = window.wp || {}; return urlParser.protocol + '//' + urlParser.host.replace( /:(80|443)$/, '' ); }); - // first add with no value + // First add with no value. this.add( 'targetWindow', null ); // This avoids SecurityErrors when setting a window object in x-origin iframe'd scenarios. this.targetWindow.set = function( to ) { @@ -719,15 +723,17 @@ window.wp = window.wp || {}; return this; }; - // now set it + // Now set it. this.targetWindow( params.targetWindow || defaultTarget ); - // Since we want jQuery to treat the receive function as unique - // to this instance, we give the function a new guid. - // - // This will prevent every Messenger's receive function from being - // unbound when calling $.off( 'message', this.receive ); + /* + * Since we want jQuery to treat the receive function as unique + * to this instance, we give the function a new guid. + * + * This will prevent every Messenger's receive function from being + * unbound when calling $.off( 'message', this.receive ); + */ this.receive = $.proxy( this.receive, this ); this.receive.guid = $.guid++; diff --git a/src/js/_enqueues/wp/customize/controls.js b/src/js/_enqueues/wp/customize/controls.js index 6c92362410..8b8c1fd67e 100644 --- a/src/js/_enqueues/wp/customize/controls.js +++ b/src/js/_enqueues/wp/customize/controls.js @@ -578,7 +578,8 @@ return deferred.promise(); } - // A status would cause a revision to be made, and for this wp.customize.previewer.save() should be used. Status is also disallowed for revisions regardless. + // A status would cause a revision to be made, and for this wp.customize.previewer.save() should be used. + // Status is also disallowed for revisions regardless. if ( submittedArgs.status ) { return deferred.reject( { code: 'illegal_status_in_changeset_update' } ).promise(); } @@ -772,13 +773,13 @@ */ api.utils.areElementListsEqual = function ( listA, listB ) { var equal = ( - listA.length === listB.length && // if lists are different lengths, then naturally they are not equal - -1 === _.indexOf( _.map( // are there any false values in the list returned by map? - _.zip( listA, listB ), // pair up each element between the two lists + listA.length === listB.length && // If lists are different lengths, then naturally they are not equal. + -1 === _.indexOf( _.map( // Are there any false values in the list returned by map? + _.zip( listA, listB ), // Pair up each element between the two lists. function ( pair ) { - return $( pair[0] ).is( pair[1] ); // compare to see if each pair are equal + return $( pair[0] ).is( pair[1] ); // Compare to see if each pair is equal. } - ), false ) // check for presence of false in map's return value + ), false ) // Check for presence of false in map's return value. ); return equal; }; @@ -1128,7 +1129,8 @@ } if ( ! $.contains( document, headContainer.get( 0 ) ) ) { - // If the element is not in the DOM, then jQuery.fn.slideUp() does nothing. In this case, a hard toggle is required instead. + // If the element is not in the DOM, then jQuery.fn.slideUp() does nothing. + // In this case, a hard toggle is required instead. headContainer.toggle( active ); if ( args.completeCallback ) { args.completeCallback(); @@ -1479,7 +1481,7 @@ }); } ); } else { - // There is no panel, so embed the section in the root of the customizer + // There is no panel, so embed the section in the root of the customizer. parentContainer = api.ensure( section.containerPaneParent ); if ( ! section.headContainer.parent().is( parentContainer ) ) { parentContainer.append( section.headContainer ); @@ -1511,7 +1513,7 @@ if ( api.utils.isKeydownButNotEnterEvent( event ) ) { return; } - event.preventDefault(); // Keep this AFTER the key filter above + event.preventDefault(); // Keep this AFTER the key filter above. if ( section.expanded() ) { section.collapse(); @@ -1718,12 +1720,12 @@ var inject, section = this; - // Watch for changes to the panel state + // Watch for changes to the panel state. inject = function( panelId ) { var parentContainer; api.panel( panelId, function( panel ) { - // The panel has been registered, wait for it to become ready/initialized + // The panel has been registered, wait for it to become ready/initialized. panel.deferred.embedded.done( function() { parentContainer = panel.contentContainer; if ( ! section.headContainer.parent().is( parentContainer ) ) { @@ -1737,7 +1739,7 @@ } ); }; section.panel.bind( inject ); - inject( section.panel.get() ); // Since a section may never get a panel, assume that it won't ever get one + inject( section.panel.get() ); // Since a section may never get a panel, assume that it won't ever get one. }, /** @@ -1758,17 +1760,17 @@ return; } - // Pressing the right arrow key fires a theme:next event + // Pressing the right arrow key fires a theme:next event. if ( 39 === event.keyCode ) { section.nextTheme(); } - // Pressing the left arrow key fires a theme:previous event + // Pressing the left arrow key fires a theme:previous event. if ( 37 === event.keyCode ) { section.previousTheme(); } - // Pressing the escape key fires a theme:collapse event + // Pressing the escape key fires a theme:collapse event. if ( 27 === event.keyCode ) { if ( section.$body.hasClass( 'modal-open' ) ) { @@ -1818,7 +1820,7 @@ if ( api.utils.isKeydownButNotEnterEvent( event ) ) { return; } - event.preventDefault(); // Keep this AFTER the key filter above + event.preventDefault(); // Keep this AFTER the key filter above. section.collapse(); }); @@ -1957,11 +1959,11 @@ */ onChangeExpanded: function ( expanded, args ) { - // Note: there is a second argument 'args' passed + // Note: there is a second argument 'args' passed. var section = this, container = section.contentContainer.closest( '.customize-themes-full-container' ); - // Immediately call the complete callback if there were no changes + // Immediately call the complete callback if there were no changes. if ( args.unchanged ) { if ( args.completeCallback ) { args.completeCallback(); @@ -1976,7 +1978,7 @@ section.loadThemes(); } - // Collapse any sibling sections/panels + // Collapse any sibling sections/panels. api.section.each( function ( otherSection ) { var searchTerm; @@ -2123,7 +2125,8 @@ _.delay( section.renderScreenshots, 100 ); // Wait for the controls to become visible. - if ( 'local' === section.params.filter_type || 100 > themes.length ) { // If we have less than the requested 100 themes, it's the end of the list. + if ( 'local' === section.params.filter_type || 100 > themes.length ) { + // If we have less than the requested 100 themes, it's the end of the list. section.fullyLoaded = true; } } else { @@ -2202,7 +2205,9 @@ container = section.container.closest( '.customize-themes-full-container' ); bottom = container.scrollTop() + container.height(); - threshold = container.prop( 'scrollHeight' ) - 3000; // Use a fixed distance to the bottom of loaded results to avoid unnecessarily loading results sooner when using a percentage of scroll distance. + // Use a fixed distance to the bottom of loaded results to avoid unnecessarily + // loading results sooner when using a percentage of scroll distance. + threshold = container.prop( 'scrollHeight' ) - 3000; if ( bottom > threshold ) { section.loadThemes(); @@ -2614,15 +2619,15 @@ el.on( 'keydown', function( event ) { // Return if it's not the tab key - // When navigating with prev/next focus is already handled + // When navigating with prev/next focus is already handled. if ( 9 !== event.keyCode ) { return; } - // uses jQuery UI to get the tabbable elements + // Uses jQuery UI to get the tabbable elements. tabbables = $( ':tabbable', el ); - // Keep focus within the overlay + // Keep focus within the overlay. if ( tabbables.last()[0] === event.target && ! event.shiftKey ) { tabbables.first().focus(); return false; @@ -2797,7 +2802,7 @@ embed: function () { var panel = this, container = $( '#customize-theme-controls' ), - parentContainer = $( '.customize-pane-parent' ); // @todo This should be defined elsewhere, and to be configurable + parentContainer = $( '.customize-pane-parent' ); // @todo This should be defined elsewhere, and to be configurable. if ( ! panel.headContainer.parent().is( parentContainer ) ) { parentContainer.append( panel.headContainer ); @@ -2821,7 +2826,7 @@ if ( api.utils.isKeydownButNotEnterEvent( event ) ) { return; } - event.preventDefault(); // Keep this AFTER the key filter above + event.preventDefault(); // Keep this AFTER the key filter above. if ( ! panel.expanded() ) { panel.expand(); @@ -2833,7 +2838,7 @@ if ( api.utils.isKeydownButNotEnterEvent( event ) ) { return; } - event.preventDefault(); // Keep this AFTER the key filter above + event.preventDefault(); // Keep this AFTER the key filter above. if ( panel.expanded() ) { panel.collapse(); @@ -2908,7 +2913,7 @@ */ onChangeExpanded: function ( expanded, args ) { - // Immediately call the complete callback if there were no changes + // Immediately call the complete callback if there were no changes. if ( args.unchanged ) { if ( args.completeCallback ) { args.completeCallback(); @@ -2916,7 +2921,7 @@ return; } - // Note: there is a second argument 'args' passed + // Note: there is a second argument 'args' passed. var panel = this, accordionSection = panel.contentContainer, overlay = accordionSection.closest( '.wp-full-overlay' ), @@ -2927,7 +2932,7 @@ skipTransition; if ( expanded && ! accordionSection.hasClass( 'current-panel' ) ) { - // Collapse any sibling sections/panels + // Collapse any sibling sections/panels. api.section.each( function ( section ) { if ( panel.id !== section.panel() ) { section.collapse( { duration: 0 } ); @@ -3067,7 +3072,7 @@ // Attach regular panel events. api.Panel.prototype.attachEvents.apply( panel ); - // Temporary since supplying SFTP credentials does not work yet. See #42184 + // Temporary since supplying SFTP credentials does not work yet. See #42184. if ( api.settings.theme._canInstall && api.settings.theme._filesystemCredentialsNeeded ) { panel.notifications.add( new api.Notification( 'theme_install_unavailable', { message: api.l10n.themeInstallUnavailable, @@ -3140,7 +3145,7 @@ // Expand/collapse the panel normally. api.Panel.prototype.onChangeExpanded.apply( this, [ expanded, args ] ); - // Immediately call the complete callback if there were no changes + // Immediately call the complete callback if there were no changes. if ( args.unchanged ) { if ( args.completeCallback ) { args.completeCallback(); @@ -3682,15 +3687,15 @@ var control = this, inject; - // Watch for changes to the section state + // Watch for changes to the section state. inject = function ( sectionId ) { var parentContainer; - if ( ! sectionId ) { // @todo allow a control to be embedded without a section, for instance a control embedded in the front end. + if ( ! sectionId ) { // @todo Allow a control to be embedded without a section, for instance a control embedded in the front end. return; } - // Wait for the section to be registered + // Wait for the section to be registered. api.section( sectionId, function ( section ) { - // Wait for the section to be ready/initialized + // Wait for the section to be ready/initialized. section.deferred.embedded.done( function () { parentContainer = ( section.contentContainer.is( 'ul' ) ) ? section.contentContainer : section.contentContainer.find( 'ul:first' ); if ( ! control.container.parent().is( parentContainer ) ) { @@ -3724,7 +3729,7 @@ control.addNewPage(); }); control.container.on( 'keydown', '.create-item-input', function( e ) { - if ( 13 === e.which ) { // Enter + if ( 13 === e.which ) { // Enter. control.addNewPage(); } }); @@ -3909,7 +3914,7 @@ } if ( ! $.contains( document, this.container[0] ) ) { - // jQuery.fn.slideUp is not hiding an element if it is not in the DOM + // jQuery.fn.slideUp is not hiding an element if it is not in the DOM. this.container.toggle( active ); if ( args.completeCallback ) { args.completeCallback(); @@ -3957,7 +3962,7 @@ } }; - // Support the .dropdown class to open/close complex elements + // Support the .dropdown class to open/close complex elements. this.container.on( 'click keydown', '.dropdown', function( event ) { if ( api.utils.isKeydownButNotEnterEvent( event ) ) { return; @@ -3973,7 +3978,7 @@ control.container.parent().parent().find( 'li.library-selected' ).focus(); } - // Don't want to fire focus and click at same time + // Don't want to fire focus and click at same time. toggleFreeze = true; setTimeout(function () { toggleFreeze = false; @@ -4017,7 +4022,8 @@ templateId = control.templateSelector; - // Use default content template when a standard HTML type is used, there isn't a more specific template existing, and the control container is empty. + // Use default content template when a standard HTML type is used, + // there isn't a more specific template existing, and the control container is empty. if ( templateId === 'customize-control-' + control.params.type + '-content' && _.contains( standardTypes, control.params.type ) && ! document.getElementById( 'tmpl-' + templateId ) && @@ -4047,6 +4053,7 @@ * * @since 4.7.0 * @access private + * * @return {void} */ addNewPage: function () { @@ -4070,7 +4077,8 @@ input.removeClass( 'invalid' ); input.attr( 'disabled', 'disabled' ); - // The menus functions add the page, publish when appropriate, and also add the new page to the dropdown-pages controls. + // The menus functions add the page, publish when appropriate, + // and also add the new page to the dropdown-pages controls. promise = api.Menus.insertAutoDraftPost( { post_title: title, post_type: 'page' @@ -4199,7 +4207,7 @@ control.container.on( 'click keydown', '.remove-button', control.removeFile ); control.container.on( 'click keydown', '.remove-button', control.cleanupPlayer ); - // Resize the player controls when it becomes visible (ie when section is expanded) + // Resize the player controls when it becomes visible (ie when section is expanded). api.section( control.section() ).container .on( 'expanded', function() { if ( control.player ) { @@ -5128,7 +5136,7 @@ return; } - event.preventDefault(); // Keep this AFTER the key filter above + event.preventDefault(); // Keep this AFTER the key filter above. section = api.section( control.section() ); section.showDetails( control.params.theme, function() { @@ -5196,7 +5204,7 @@ control.params.priority = 101 - matchCount; // Sort results by match count. return true; } else { - control.deactivate(); // Hide control + control.deactivate(); // Hide control. control.params.priority = 101; return false; } @@ -6498,13 +6506,15 @@ urlParser.href = previewer.origin(); previewer.add( 'scheme', urlParser.protocol.replace( /:$/, '' ) ); - // Limit the URL to internal, front-end links. - // - // If the front end and the admin are served from the same domain, load the - // preview over ssl if the Customizer is being loaded over ssl. This avoids - // insecure content warnings. This is not attempted if the admin and front end - // are on different domains to avoid the case where the front end doesn't have - // ssl certs. + /* + * Limit the URL to internal, front-end links. + * + * If the front end and the admin are served from the same domain, load the + * preview over ssl if the Customizer is being loaded over ssl. This avoids + * insecure content warnings. This is not attempted if the admin and front end + * are on different domains to avoid the case where the front end doesn't have + * ssl certs. + */ previewer.add( 'previewUrl', params.previewUrl ).setter( function( to ) { var result = null, urlParser, queryParams, parsedAllowedUrl, parsedCandidateUrls = []; @@ -6735,12 +6745,13 @@ * * @since 3.4.0 * @access public + * * @return {void} */ refresh: function() { var previewer = this, onSettingChange; - // Display loading indicator + // Display loading indicator. previewer.send( 'loading-initiated' ); previewer.abort(); @@ -7013,7 +7024,7 @@ activeElement = $( document.activeElement ); } - // Sort the sections within each panel + // Sort the sections within each panel. api.panel.each( function ( panel ) { if ( 'themes' === panel.id ) { return; // Don't reflow theme sections, as doing so moves them after the themes container. @@ -7031,7 +7042,7 @@ } } ); - // Sort the controls within each section + // Sort the controls within each section. api.section.each( function ( section ) { var controls = section.controls(), controlContainers = _.pluck( controls, 'container' ); @@ -7047,10 +7058,10 @@ } } ); - // Sort the root panels and sections + // Sort the root panels and sections. rootNodes.sort( api.utils.prioritySort ); rootHeadContainers = _.pluck( rootNodes, 'headContainer' ); - appendContainer = $( '#customize-theme-controls .customize-pane-parent' ); // @todo This should be defined elsewhere, and to be configurable + appendContainer = $( '#customize-theme-controls .customize-pane-parent' ); // @todo This should be defined elsewhere, and to be configurable. if ( ! api.utils.areElementListsEqual( rootHeadContainers, appendContainer.children() ) ) { _( rootNodes ).each( function ( rootNode ) { appendContainer.append( rootNode.headContainer ); @@ -7058,7 +7069,7 @@ wasReflowed = true; } - // Now re-trigger the active Value callbacks to that the panels and sections can decide whether they can be rendered + // Now re-trigger the active Value callbacks so that the panels and sections can decide whether they can be rendered. api.panel.each( function ( panel ) { var value = panel.active(); panel.active.callbacks.fireWith( panel.active, [ value, value ] ); @@ -7068,7 +7079,7 @@ section.active.callbacks.fireWith( section.active, [ value, value ] ); } ); - // Restore focus if there was a reflow and there was an active (focused) element + // Restore focus if there was a reflow and there was an active (focused) element. if ( wasReflowed && activeElement ) { activeElement.focus(); } @@ -7208,9 +7219,11 @@ cancelScheduleButtonReminder = api.utils.highlightButton( btnWrapper, { delay: 1000, - // Only abort the reminder when the save button is focused. - // If the user clicks the settings button to toggle the - // settings closed, we'll still remind them. + /* + * Only abort the reminder when the save button is focused. + * If the user clicks the settings button to toggle the + * settings closed, we'll still remind them. + */ focusTarget: saveBtn } ); } @@ -7579,7 +7592,7 @@ if ( '0' === response ) { response = 'not_logged_in'; } else if ( '-1' === response ) { - // Back-compat in case any other check_ajax_referer() call is dying + // Back-compat in case any other check_ajax_referer() call is dying. response = 'invalid_nonce'; } @@ -7812,7 +7825,7 @@ api.previewer.send( 'nonce-refresh', nonce ); }); - // Create Settings + // Create Settings. $.each( api.settings.settings, function( id, data ) { var Constructor = api.settingConstructor[ data.type ] || api.Setting; api.add( new Constructor( id, data.value, { @@ -7822,28 +7835,31 @@ } ) ); }); - // Create Panels + // Create Panels. $.each( api.settings.panels, function ( id, data ) { var Constructor = api.panelConstructor[ data.type ] || api.Panel, options; - options = _.extend( { params: data }, data ); // Inclusion of params alias is for back-compat for custom panels that expect to augment this property. + // Inclusion of params alias is for back-compat for custom panels that expect to augment this property. + options = _.extend( { params: data }, data ); api.panel.add( new Constructor( id, options ) ); }); - // Create Sections + // Create Sections. $.each( api.settings.sections, function ( id, data ) { var Constructor = api.sectionConstructor[ data.type ] || api.Section, options; - options = _.extend( { params: data }, data ); // Inclusion of params alias is for back-compat for custom sections that expect to augment this property. + // Inclusion of params alias is for back-compat for custom sections that expect to augment this property. + options = _.extend( { params: data }, data ); api.section.add( new Constructor( id, options ) ); }); - // Create Controls + // Create Controls. $.each( api.settings.controls, function( id, data ) { var Constructor = api.controlConstructor[ data.type ] || api.Control, options; - options = _.extend( { params: data }, data ); // Inclusion of params alias is for back-compat for custom controls that expect to augment this property. + // Inclusion of params alias is for back-compat for custom controls that expect to augment this property. + options = _.extend( { params: data }, data ); api.control.add( new Constructor( id, options ) ); }); - // Focus the autofocused element + // Focus the autofocused element. _.each( [ 'panel', 'section', 'control' ], function( type ) { var id = api.settings.autofocus[ type ]; if ( ! id ) { @@ -7896,7 +7912,7 @@ api.notifications.render(); }); - // Save and activated states + // Save and activated states. (function( state ) { var saved = state.instance( 'saved' ), saving = state.instance( 'saving' ), @@ -8690,7 +8706,8 @@ }; }()); - // Previewed device bindings. (The api.previewedDevice property is how this Value was first introduced, but since it has moved to api.state.) + // Previewed device bindings. (The api.previewedDevice property + // is how this Value was first introduced, but since it has moved to api.state.) api.previewedDevice = api.state( 'previewedDevice' ); // Set the default device. @@ -8797,7 +8814,7 @@ api.state( 'selectedChangesetStatus' ).unbind( startPromptingBeforeUnload ); api.state( 'selectedChangesetDate' ).unbind( startPromptingBeforeUnload ); - // Prompt user with AYS dialog if leaving the Customizer with unsaved changes + // Prompt user with AYS dialog if leaving the Customizer with unsaved changes. $( window ).on( 'beforeunload.customize-confirm', function() { if ( ! isCleanState() && ! api.state( 'changesetLocked' ).get() ) { setTimeout( function() { @@ -8882,7 +8899,7 @@ }); } ); - // Pass titles to the parent + // Pass titles to the parent. api.bind( 'title', function( newTitle ) { parent.send( 'title', newTitle ); }); @@ -8894,7 +8911,7 @@ // Initialize the connection with the parent frame. parent.send( 'ready' ); - // Control visibility for default controls + // Control visibility for default controls. $.each({ 'background_image': { controls: [ 'background_preset', 'background_position', 'background_size', 'background_repeat', 'background_attachment' ], @@ -8926,7 +8943,7 @@ api.control( 'background_preset', function( control ) { var visibility, defaultValues, values, toggleVisibility, updateSettings, preset; - visibility = { // position, size, repeat, attachment + visibility = { // position, size, repeat, attachment. 'default': [ false, false, false, false ], 'fill': [ true, false, false, false ], 'fit': [ true, false, true, false ], @@ -8942,14 +8959,15 @@ _wpCustomizeBackground.defaults['default-attachment'] ]; - values = { // position_x, position_y, size, repeat, attachment + values = { // position_x, position_y, size, repeat, attachment. 'default': defaultValues, 'fill': [ 'left', 'top', 'cover', 'no-repeat', 'fixed' ], 'fit': [ 'left', 'top', 'contain', 'no-repeat', 'fixed' ], 'repeat': [ 'left', 'top', 'auto', 'repeat', 'scroll' ] }; - // @todo These should actually toggle the active state, but without the preview overriding the state in data.activeControls. + // @todo These should actually toggle the active state, + // but without the preview overriding the state in data.activeControls. toggleVisibility = function( preset ) { _.each( [ 'background_position', 'background_size', 'background_repeat', 'background_attachment' ], function( controlId, i ) { var control = api.control( controlId ); @@ -9009,7 +9027,7 @@ } ); } ); - // Juggle the two controls that use header_textcolor + // Juggle the two controls that use header_textcolor. api.control( 'display_header_text', function( control ) { var last = ''; diff --git a/src/js/_enqueues/wp/customize/loader.js b/src/js/_enqueues/wp/customize/loader.js index e27f1bc9c5..239d36824f 100644 --- a/src/js/_enqueues/wp/customize/loader.js +++ b/src/js/_enqueues/wp/customize/loader.js @@ -119,7 +119,7 @@ window.wp = window.wp || {}; return window.location = src; } - // Store the document title prior to opening the Live Preview + // Store the document title prior to opening the Live Preview. this.originalDocumentTitle = document.title; this.active = true; @@ -170,7 +170,7 @@ window.wp = window.wp || {}; } }); - // Prompt AYS dialog when navigating away + // Prompt AYS dialog when navigating away. $( window ).on( 'beforeunload', this.beforeunload ); this.messenger.bind( 'saved', function () { @@ -223,13 +223,13 @@ window.wp = window.wp || {}; self.active = false; self.trigger( 'close' ); - // Restore document title prior to opening the Live Preview + // Restore document title prior to opening the Live Preview. if ( self.originalDocumentTitle ) { document.title = self.originalDocumentTitle; } } else { - // Go forward since Customizer is exited by history.back() + // Go forward since Customizer is exited by history.back(). history.forward(); } self.messenger.unbind( 'confirmed-close', onConfirmClose ); @@ -286,6 +286,6 @@ window.wp = window.wp || {}; Loader.initialize(); }); - // Expose the API publicly on window.wp.customize.Loader + // Expose the API publicly on window.wp.customize.Loader. api.Loader = Loader; })( wp, jQuery ); diff --git a/src/js/_enqueues/wp/customize/models.js b/src/js/_enqueues/wp/customize/models.js index f11b3d04b8..0a8bca7f47 100644 --- a/src/js/_enqueues/wp/customize/models.js +++ b/src/js/_enqueues/wp/customize/models.js @@ -53,8 +53,8 @@ var data = this.get('header'), curr = api.HeaderTool.currentHeader.get('header').attachment_id; - // If the image we're removing is also the current header, unset - // the latter + // If the image we're removing is also the current header, + // unset the latter. if (curr && data.attachment_id === curr) { api.HeaderTool.currentHeader.trigger('hide'); } @@ -142,7 +142,7 @@ api.HeaderTool.ChoiceList = Backbone.Collection.extend({ model: api.HeaderTool.ImageModel, - // Ordered from most recently used to least + // Ordered from most recently used to least. comparator: function(model) { return -model.get('header').timestamp; }, @@ -151,18 +151,18 @@ var current = api.HeaderTool.currentHeader.get('choice').replace(/^https?:\/\//, ''), isRandom = this.isRandomChoice(api.get().header_image); - // Overridable by an extending class + // Overridable by an extending class. if (!this.type) { this.type = 'uploaded'; } - // Overridable by an extending class + // Overridable by an extending class. if (typeof this.data === 'undefined') { this.data = _wpCustomizeHeader.uploads; } if (isRandom) { - // So that when adding data we don't hide regular images + // So that when adding data we don't hide regular images. current = api.get().header_image; } diff --git a/src/js/_enqueues/wp/customize/nav-menus.js b/src/js/_enqueues/wp/customize/nav-menus.js index 309785d54c..7ca17acbe1 100644 --- a/src/js/_enqueues/wp/customize/nav-menus.js +++ b/src/js/_enqueues/wp/customize/nav-menus.js @@ -203,9 +203,11 @@ _.bindAll( this, 'close' ); - // If the available menu items panel is open and the customize controls are - // interacted with (other than an item being deleted), then close the - // available menu items panel. Also close on back button click. + /* + * If the available menu items panel is open and the customize controls + * are interacted with (other than an item being deleted), then close + * the available menu items panel. Also close on back button click. + */ $( '#customize-controls, .customize-section-back' ).on( 'click keydown', function( e ) { var isDeleteBtn = $( e.target ).is( '.item-delete, .item-delete *' ), isAddNewBtn = $( e.target ).is( '.add-new-menu-item, .add-new-menu-item *' ); @@ -252,7 +254,7 @@ } }); - // Close the panel if the URL in the preview changes + // Close the panel if the URL in the preview changes. api.previewer.bind( 'url', this.close ); self.delegateEvents(); @@ -496,7 +498,7 @@ // Submit handler for keypress and click on menu item. _submit: function( event ) { - // Only proceed with keypress if it is Enter or Spacebar + // Only proceed with keypress if it is Enter or Spacebar. if ( 'keypress' === event.type && ( 13 !== event.which && 32 !== event.which ) ) { return; } @@ -717,7 +719,7 @@ this.$search.focus(); }, - // Closes the panel + // Closes the panel. close: function( options ) { options = options || {}; @@ -741,7 +743,7 @@ isBackTab = ( 9 === event.which && event.shiftKey ), isSearchFocused = $( event.target ).is( this.$search ); - // If enter pressed but nothing entered, don't do anything + // If enter pressed but nothing entered, don't do anything. if ( isEnter && ! this.$search.val() ) { return; } @@ -781,7 +783,7 @@ } event.preventDefault(); - // Hide description + // Hide description. if ( content.not( ':hidden' ) ) { content.slideUp( 'fast' ); help.attr( 'aria-expanded', 'false' ); @@ -802,7 +804,7 @@ return false; } ); - // Help toggle + // Help toggle. help.on( 'click keydown', function( event ) { if ( api.utils.isKeydownButNotEnterEvent( event ) ) { return; @@ -1062,7 +1064,7 @@ menuAutoAddControl.active.set( true ); } - // Add the control for deleting the menu + // Add the control for deleting the menu. menuDeleteControlId = section.id + '[delete]'; menuDeleteControl = api.control( menuDeleteControlId ); if ( ! menuDeleteControl ) { @@ -1126,7 +1128,7 @@ wpNavMenu.menuList = section.contentContainer; wpNavMenu.targetList = wpNavMenu.menuList; - // Add attributes needed by wpNavMenu + // Add attributes needed by wpNavMenu. $( '#menu-to-edit' ).removeAttr( 'id' ); wpNavMenu.menuList.attr( 'id', 'menu-to-edit' ).addClass( 'menu' ); @@ -1145,7 +1147,8 @@ wpNavMenu.initSortables(); // Depends on menu-to-edit ID being set above. section.deferred.initSortables.resolve( wpNavMenu.menuList ); // Now MenuControl can extend the sortable. - // @todo Note that wp.customize.reflowPaneContents() is debounced, so this immediate change will show a slight flicker while priorities get updated. + // @todo Note that wp.customize.reflowPaneContents() is debounced, + // so this immediate change will show a slight flicker while priorities get updated. api.control( 'nav_menu[' + String( section.params.menu_id ) + ']' ).reflowMenuItems(); } if ( _.isFunction( completeCallback ) ) { @@ -1415,7 +1418,7 @@ navMenuLocationSetting = api( 'nav_menu_locations[' + checkbox.data( 'location-id' ) + ']' ); navMenuLocationSetting.set( menuSection.params.menu_id ); - // Reset state for next new menu + // Reset state for next new menu. checkbox.prop( 'checked', false ); } } ); @@ -1698,7 +1701,8 @@ control.elements.classes = new api.Element( control.container.find( '.edit-menu-item-classes' ) ); control.elements.xfn = new api.Element( control.container.find( '.edit-menu-item-xfn' ) ); control.elements.description = new api.Element( control.container.find( '.edit-menu-item-description' ) ); - // @todo allow other elements, added by plugins, to be automatically picked up here; allow additional values to be added to setting array. + // @todo Allow other elements, added by plugins, to be automatically picked up here; + // allow additional values to be added to setting array. _.each( control.elements, function( element, property ) { element.bind(function( value ) { @@ -1790,7 +1794,7 @@ $removeBtn = control.container.find( '.item-delete' ); $removeBtn.on( 'click', function() { - // Find an adjacent element to add focus to when this menu item goes away + // Find an adjacent element to add focus to when this menu item goes away. var addingItems = true, $adjacentFocusTarget, $next, $prev; if ( ! $( 'body' ).hasClass( 'adding-menu-items' ) ) { @@ -1811,7 +1815,7 @@ control.container.slideUp( function() { control.setting.set( false ); wp.a11y.speak( api.Menus.data.l10n.itemDeleted ); - $adjacentFocusTarget.focus(); // keyboard accessibility + $adjacentFocusTarget.focus(); // Keyboard accessibility. } ); control.setting.set( false ); @@ -2778,13 +2782,13 @@ action = sectionTitle.find( '.customize-action' ), name = displayNavMenuName( menu.name ); - // Update the control title + // Update the control title. controlTitle.text( name ); if ( location.length ) { location.appendTo( controlTitle ); } - // Update the section title + // Update the section title. sectionTitle.text( name ); if ( action.length ) { action.prependTo( sectionTitle ); @@ -2981,7 +2985,7 @@ position: position } ); - delete item.id; // only used by Backbone + delete item.id; // Only used by Backbone. placeholderId = api.Menus.generatePlaceholderAutoIncrementId(); customizeId = 'nav_menu_item[' + String( placeholderId ) + ']'; diff --git a/src/js/_enqueues/wp/customize/preview-widgets.js b/src/js/_enqueues/wp/customize/preview-widgets.js index f46456b28f..e00982d963 100644 --- a/src/js/_enqueues/wp/customize/preview-widgets.js +++ b/src/js/_enqueues/wp/customize/preview-widgets.js @@ -672,7 +672,7 @@ wp.customize.widgetsPreview = wp.customize.WidgetCustomizerPreview = (function( self.preview.send( 'highlight-widget-control', $( this ).prop( 'id' ) ); }); - // Open expand the widget control when shift+clicking the widget element + // Open expand the widget control when shift+clicking the widget element. $( document ).on( 'click', selector, function( e ) { if ( ! e.shiftKey ) { return; diff --git a/src/js/_enqueues/wp/customize/preview.js b/src/js/_enqueues/wp/customize/preview.js index 12c641c080..9e048dd0f6 100644 --- a/src/js/_enqueues/wp/customize/preview.js +++ b/src/js/_enqueues/wp/customize/preview.js @@ -232,8 +232,8 @@ * * @since 4.7.0 * @access protected - * * @access private + * * @return {void} */ api.addLinkPreviewing = function addLinkPreviewing() { @@ -337,7 +337,7 @@ api.prepareLinkPreview = function prepareLinkPreview( element ) { var queryParams, $element = $( element ); - // Skip elements with no href attribute. Check first to avoid more expensive checks down the road + // Skip elements with no href attribute. Check first to avoid more expensive checks down the road. if ( ! element.hasAttribute( 'href' ) ) { return; } @@ -357,7 +357,7 @@ element.protocol = 'https:'; } - // Ignore links with class wp-playlist-caption + // Ignore links with class wp-playlist-caption. if ( $element.hasClass( 'wp-playlist-caption' ) ) { return; } diff --git a/src/js/_enqueues/wp/customize/selective-refresh.js b/src/js/_enqueues/wp/customize/selective-refresh.js index ae9f9ffaf2..9fee9690d0 100644 --- a/src/js/_enqueues/wp/customize/selective-refresh.js +++ b/src/js/_enqueues/wp/customize/selective-refresh.js @@ -442,7 +442,7 @@ wp.customize.selectiveRefresh = ( function( $, api ) { if ( partial.params.containerInclusive ) { - // Note that content may be an empty string, and in this case jQuery will just remove the oldContainer + // Note that content may be an empty string, and in this case jQuery will just remove the oldContainer. newContainerElement = $( content ); // Merge the new context on top of the old context. diff --git a/src/js/_enqueues/wp/customize/widgets.js b/src/js/_enqueues/wp/customize/widgets.js index a2b800db72..8738c13b73 100644 --- a/src/js/_enqueues/wp/customize/widgets.js +++ b/src/js/_enqueues/wp/customize/widgets.js @@ -17,7 +17,7 @@ api.Widgets = api.Widgets || {}; api.Widgets.savedWidgetIds = {}; - // Link settings + // Link settings. api.Widgets.data = _wpCustomizeWidgetsSettings || {}; l10n = api.Widgets.data.l10n; @@ -59,16 +59,16 @@ model: api.Widgets.WidgetModel, // Controls searching on the current widget collection - // and triggers an update event + // and triggers an update event. doSearch: function( value ) { - // Don't do anything if we've already done this search - // Useful because the search handler fires multiple times per keystroke + // Don't do anything if we've already done this search. + // Useful because the search handler fires multiple times per keystroke. if ( this.terms === value ) { return; } - // Updates terms with the value passed + // Updates terms with the value passed. this.terms = value; // If we have terms, run a search... @@ -84,16 +84,16 @@ } }, - // Performs a search within the collection + // Performs a search within the collection. // @uses RegExp search: function( term ) { var match, haystack; - // Escape the term string for RegExp meta characters + // Escape the term string for RegExp meta characters. term = term.replace( /[-\/\\^$*+?.()|[\]{}]/g, '\\$&' ); // Consider spaces as word delimiters and match the whole string - // so matching terms can be combined + // so matching terms can be combined. term = term.replace( / /g, ')(?=.*' ); match = new RegExp( '^(?=.*' + term + ').+', 'i' ); @@ -150,10 +150,10 @@ 'keydown' : 'keyboardAccessible' }, - // Cache current selected widget + // Cache current selected widget. selected: null, - // Cache sidebar control which has opened panel + // Cache sidebar control which has opened panel. currentSidebarControl: null, $search: null, $clearResults: null, @@ -181,9 +181,11 @@ // Set the initial search count to the number of available widgets. this.searchMatchesCount = this.collection.length; - // If the available widgets panel is open and the customize controls are - // interacted with (i.e. available widgets panel is blurred) then close the - // available widgets panel. Also close on back button click. + /* + * If the available widgets panel is open and the customize controls + * are interacted with (i.e. available widgets panel is blurred) then + * close the available widgets panel. Also close on back button click. + */ $( '#customize-controls, #available-widgets .customize-section-title' ).on( 'click keydown', function( e ) { var isAddNewBtn = $( e.target ).is( '.add-new-widget, .add-new-widget *' ); if ( $( 'body' ).hasClass( 'adding-widget' ) && ! isAddNewBtn ) { @@ -197,7 +199,7 @@ self.collection.doSearch( '' ); } ); - // Close the panel if the URL in the preview changes + // Close the panel if the URL in the preview changes. api.previewer.bind( 'url', this.close ); }, @@ -213,19 +215,19 @@ // Announce how many search results. this.announceSearchMatches(); - // Remove a widget from being selected if it is no longer visible + // Remove a widget from being selected if it is no longer visible. if ( this.selected && ! this.selected.is( ':visible' ) ) { this.selected.removeClass( 'selected' ); this.selected = null; } - // If a widget was selected but the filter value has been cleared out, clear selection + // If a widget was selected but the filter value has been cleared out, clear selection. if ( this.selected && ! event.target.value ) { this.selected.removeClass( 'selected' ); this.selected = null; } - // If a filter has been entered and a widget hasn't been selected, select the first one shown + // If a filter has been entered and a widget hasn't been selected, select the first one shown. if ( ! this.selected && event.target.value ) { firstVisible = this.$el.find( '> .widget-tpl:visible:first' ); if ( firstVisible.length ) { @@ -301,7 +303,7 @@ * Handles submit for keypress and click on widget. */ _submit: function( event ) { - // Only proceed with keypress if it is Enter or Spacebar + // Only proceed with keypress if it is Enter or Spacebar. if ( event.type === 'keypress' && ( event.which !== 13 && event.which !== 32 ) ) { return; } @@ -345,7 +347,7 @@ open: function( sidebarControl ) { this.currentSidebarControl = sidebarControl; - // Wide widget controls appear over the preview, and so they need to be collapsed when the panel opens + // Wide widget controls appear over the preview, and so they need to be collapsed when the panel opens. _( this.currentSidebarControl.getWidgetFormControls() ).each( function( control ) { if ( control.params.is_wide ) { control.collapseForm(); @@ -360,7 +362,7 @@ this.$el.find( '.selected' ).removeClass( 'selected' ); - // Reset search + // Reset search. this.collection.doSearch( '' ); if ( ! api.settings.browser.mobile ) { @@ -428,7 +430,7 @@ return; } - // If enter pressed but nothing entered, don't do anything + // If enter pressed but nothing entered, don't do anything. if ( isEnter && ! this.$search.val() ) { return; } @@ -602,7 +604,7 @@ _setupModel: function() { var self = this, rememberSavedWidgetId; - // Remember saved widgets so we know which to trash (move to inactive widgets sidebar) + // Remember saved widgets so we know which to trash (move to inactive widgets sidebar). rememberSavedWidgetId = function() { api.Widgets.savedWidgetIds[self.params.widget_id] = true; }; @@ -613,7 +615,7 @@ this.isWidgetUpdating = false; this.liveUpdateMode = true; - // Update widget whenever model changes + // Update widget whenever model changes. this.setting.bind( function( to, from ) { if ( ! _( from ).isEqual( to ) && ! self.isWidgetUpdating ) { self.updateWidget( { instance: to } ); @@ -658,10 +660,10 @@ top; $widgetInside.css( 'max-height', windowHeight ); top = Math.max( - 0, // prevent top from going off screen + 0, // Prevent top from going off screen. Math.min( - Math.max( offsetTop, 0 ), // distance widget in panel is from top of screen - windowHeight - formHeight // flush up against bottom of screen + Math.max( offsetTop, 0 ), // Distance widget in panel is from top of screen. + windowHeight - formHeight // Flush up against bottom of screen. ) ); $widgetInside.css( 'top', top ); @@ -680,7 +682,7 @@ $themeControlsContainer.off( 'expanded collapsed', positionWidget ); } ); - // Reposition whenever a sidebar's widgets are changed + // Reposition whenever a sidebar's widgets are changed. api.each( function( setting ) { if ( 0 === setting.id.indexOf( 'sidebars_widgets[' ) ) { setting.bind( function() { @@ -711,7 +713,7 @@ $closeBtn = this.container.find( '.widget-control-close' ); $closeBtn.on( 'click', function() { self.collapse(); - self.container.find( '.widget-top .widget-action:first' ).focus(); // keyboard accessibility + self.container.find( '.widget-top .widget-action:first' ).focus(); // Keyboard accessibility. } ); }, @@ -838,7 +840,7 @@ wp.a11y.speak( l10n.widgetMovedDown ); } - $( this ).focus(); // re-focus after the container was moved + $( this ).focus(); // Re-focus after the container was moved. } } ); @@ -886,12 +888,12 @@ _setupHighlightEffects: function() { var self = this; - // Highlight whenever hovering or clicking over the form + // Highlight whenever hovering or clicking over the form. this.container.on( 'mouseenter click', function() { self.setting.previewer.send( 'highlight-widget', self.params.widget_id ); } ); - // Highlight when the setting is updated + // Highlight when the setting is updated. this.setting.bind( function() { self.setting.previewer.send( 'highlight-widget', self.params.widget_id ); } ); @@ -907,7 +909,7 @@ $widgetRoot = this.container.find( '.widget:first' ); $widgetContent = $widgetRoot.find( '.widget-content:first' ); - // Configure update button + // Configure update button. $saveBtn = this.container.find( '.widget-control-save' ); $saveBtn.val( l10n.saveBtnLabel ); $saveBtn.attr( 'title', l10n.saveBtnTooltip ); @@ -921,15 +923,15 @@ self.updateWidget(); }, 250 ); - // Trigger widget form update when hitting Enter within an input + // Trigger widget form update when hitting Enter within an input. $widgetContent.on( 'keydown', 'input', function( e ) { - if ( 13 === e.which ) { // Enter + if ( 13 === e.which ) { // Enter. e.preventDefault(); self.updateWidget( { ignoreActiveElement: true } ); } } ); - // Handle widgets that support live previews + // Handle widgets that support live previews. $widgetContent.on( 'change input propertychange', ':input', function( e ) { if ( ! self.liveUpdateMode ) { return; @@ -939,7 +941,7 @@ } } ); - // Remove loading indicators when the setting is saved and the preview updates + // Remove loading indicators when the setting is saved and the preview updates. this.setting.previewer.channel.bind( 'synced', function() { self.container.removeClass( 'previewer-loading' ); } ); @@ -972,7 +974,7 @@ * @param {function} args.completeCallback */ onChangeActive: function ( active, args ) { - // Note: there is a second 'args' parameter being passed, merged on top of this.defaultActiveArguments + // Note: there is a second 'args' parameter being passed, merged on top of this.defaultActiveArguments. this.container.toggleClass( 'widget-rendered', active ); if ( args.completeCallback ) { args.completeCallback(); @@ -985,10 +987,10 @@ _setupRemoveUI: function() { var self = this, $removeBtn, replaceDeleteWithRemove; - // Configure remove button + // Configure remove button. $removeBtn = this.container.find( '.widget-control-remove' ); $removeBtn.on( 'click', function() { - // Find an adjacent element to add focus to when this widget goes away + // Find an adjacent element to add focus to when this widget goes away. var $adjacentFocusTarget; if ( self.container.next().is( '.customize-control-widget_form' ) ) { $adjacentFocusTarget = self.container.next().find( '.widget-action:first' ); @@ -1015,12 +1017,12 @@ sidebarWidgetIds.splice( i, 1 ); sidebarsWidgetsControl.setting( sidebarWidgetIds ); - $adjacentFocusTarget.focus(); // keyboard accessibility + $adjacentFocusTarget.focus(); // Keyboard accessibility. } ); } ); replaceDeleteWithRemove = function() { - $removeBtn.text( l10n.removeBtnLabel ); // wp_widget_control() outputs the button as "Delete" + $removeBtn.text( l10n.removeBtnLabel ); // wp_widget_control() outputs the button as "Delete". $removeBtn.attr( 'title', l10n.removeBtnTooltip ); }; @@ -1105,7 +1107,7 @@ if ( ! $.isArray( state ) ) { state = []; } else { - // Make sure all state items are strings since the DOM value is a string + // Make sure all state items are strings since the DOM value is a string. state = _.map( state, function ( value ) { return String( value ); } ); @@ -1169,7 +1171,7 @@ $widgetRoot = this.container.find( '.widget:first' ); $widgetContent = $widgetRoot.find( '.widget-content:first' ); - // Remove a previous error message + // Remove a previous error message. $widgetContent.find( '.widget-error' ).remove(); this.container.addClass( 'widget-form-loading' ); @@ -1191,9 +1193,11 @@ data = $.param( params ); $inputs = this._getInputs( $widgetContent ); - // Store the value we're submitting in data so that when the response comes back, - // we know if it got sanitized; if there is no difference in the sanitized value, - // then we do not need to touch the UI and mess up the user's ongoing editing. + /* + * Store the value we're submitting in data so that when the response comes back, + * we know if it got sanitized; if there is no difference in the sanitized value, + * then we do not need to touch the UI and mess up the user's ongoing editing. + */ $inputs.each( function() { $( this ).data( 'state' + updateNumber, self._getInputState( this ) ); } ); @@ -1236,14 +1240,14 @@ $sanitizedInputs = self._getInputs( sanitizedForm ); hasSameInputsInResponse = self._getInputsSignature( $inputs ) === self._getInputsSignature( $sanitizedInputs ); - // Restore live update mode if sanitized fields are now aligned with the existing fields + // Restore live update mode if sanitized fields are now aligned with the existing fields. if ( hasSameInputsInResponse && ! self.liveUpdateMode ) { self.liveUpdateMode = true; self.container.removeClass( 'widget-form-disabled' ); self.container.find( 'input[name="savewidget"]' ).hide(); } - // Sync sanitized field states to existing fields if they are aligned + // Sync sanitized field states to existing fields if they are aligned. if ( hasSameInputsInResponse && self.liveUpdateMode ) { $inputs.each( function( i ) { var $input = $( this ), @@ -1262,13 +1266,13 @@ $( document ).trigger( 'widget-synced', [ $widgetRoot, r.data.form ] ); - // Otherwise, if sanitized fields are not aligned with existing fields, disable live update mode if enabled + // Otherwise, if sanitized fields are not aligned with existing fields, disable live update mode if enabled. } else if ( self.liveUpdateMode ) { self.liveUpdateMode = false; self.container.find( 'input[name="savewidget"]' ).show(); isLiveUpdateAborted = true; - // Otherwise, replace existing form with the sanitized form + // Otherwise, replace existing form with the sanitized form. } else { $widgetContent.html( r.data.form ); @@ -1284,11 +1288,11 @@ */ isChanged = ! isLiveUpdateAborted && ! _( self.setting() ).isEqual( r.data.instance ); if ( isChanged ) { - self.isWidgetUpdating = true; // suppress triggering another updateWidget + self.isWidgetUpdating = true; // Suppress triggering another updateWidget. self.setting( r.data.instance ); self.isWidgetUpdating = false; } else { - // no change was made, so stop the spinner now instead of when the preview would updates + // No change was made, so stop the spinner now instead of when the preview would updates. self.container.removeClass( 'previewer-loading' ); } @@ -1296,7 +1300,7 @@ completeCallback.call( self, null, { noChange: ! isChanged, ajaxFinished: true } ); } } else { - // General error message + // General error message. message = l10n.error; if ( r.data && r.data.message ) { @@ -1406,7 +1410,7 @@ self.embedWidgetContent(); } - // If the expanded state is unchanged only manipulate container expanded states + // If the expanded state is unchanged only manipulate container expanded states. if ( args.unchanged ) { if ( expanded ) { api.Control.prototype.expand.call( self, { @@ -1422,7 +1426,7 @@ expandControl = function() { - // Close all other widget controls before expanding this one + // Close all other widget controls before expanding this one. api.control.each( function( otherControl ) { if ( self.params.type === otherControl.params.type && self !== otherControl ) { otherControl.collapse(); @@ -1535,7 +1539,7 @@ i = this.getWidgetSidebarPosition(); sidebarWidgetsSetting = this.getSidebarWidgetsControl().setting; - sidebarWidgetIds = Array.prototype.slice.call( sidebarWidgetsSetting() ); // clone + sidebarWidgetIds = Array.prototype.slice.call( sidebarWidgetsSetting() ); // Clone. adjacentWidgetId = sidebarWidgetIds[i + offset]; sidebarWidgetIds[i + offset] = this.params.widget_id; sidebarWidgetIds[i] = adjacentWidgetId; @@ -1558,7 +1562,7 @@ } if ( showOrHide ) { - // reset the selected sidebar + // Reset the selected sidebar. $moveWidgetArea.find( '.selected' ).removeClass( 'selected' ); $moveWidgetArea.find( 'li' ).filter( function() { @@ -1781,7 +1785,7 @@ removedWidgetIds = _( oldWidgetIds ).difference( newWidgetIds ); - // Filter out any persistent widget IDs for widgets which have been deactivated + // Filter out any persistent widget IDs for widgets which have been deactivated. newWidgetIds = _( newWidgetIds ).filter( function( newWidgetId ) { var parsedWidgetId = parseWidgetId( newWidgetId ); @@ -1798,7 +1802,7 @@ return widgetFormControl; } ); - // Sort widget controls to their new positions + // Sort widget controls to their new positions. widgetFormControls.sort( function( a, b ) { var aIndex = _.indexOf( newWidgetIds, a.params.widget_id ), bIndex = _.indexOf( newWidgetIds, b.params.widget_id ); @@ -1811,25 +1815,26 @@ control.section( self.section() ); priority += 1; }); - self.priority( priority ); // Make sure sidebar control remains at end + self.priority( priority ); // Make sure sidebar control remains at end. - // Re-sort widget form controls (including widgets form other sidebars newly moved here) + // Re-sort widget form controls (including widgets form other sidebars newly moved here). self._applyCardinalOrderClassNames(); - // If the widget was dragged into the sidebar, make sure the sidebar_id param is updated + // If the widget was dragged into the sidebar, make sure the sidebar_id param is updated. _( widgetFormControls ).each( function( widgetFormControl ) { widgetFormControl.params.sidebar_id = self.params.sidebar_id; } ); - // Cleanup after widget removal + // Cleanup after widget removal. _( removedWidgetIds ).each( function( removedWidgetId ) { - // Using setTimeout so that when moving a widget to another sidebar, the other sidebars_widgets settings get a chance to update + // Using setTimeout so that when moving a widget to another sidebar, + // the other sidebars_widgets settings get a chance to update. setTimeout( function() { var removedControl, wasDraggedToAnotherSidebar, inactiveWidgets, removedIdBase, widget, isPresentInAnotherSidebar = false; - // Check if the widget is in another sidebar + // Check if the widget is in another sidebar. api.each( function( otherSetting ) { if ( otherSetting.id === self.setting.id || 0 !== otherSetting.id.indexOf( 'sidebars_widgets[' ) || otherSetting.id === 'sidebars_widgets[wp_inactive_widgets]' ) { return; @@ -1850,24 +1855,24 @@ removedControl = api.Widgets.getWidgetFormControlForWidget( removedWidgetId ); - // Detect if widget control was dragged to another sidebar + // Detect if widget control was dragged to another sidebar. wasDraggedToAnotherSidebar = removedControl && $.contains( document, removedControl.container[0] ) && ! $.contains( self.$sectionContent[0], removedControl.container[0] ); - // Delete any widget form controls for removed widgets + // Delete any widget form controls for removed widgets. if ( removedControl && ! wasDraggedToAnotherSidebar ) { api.control.remove( removedControl.id ); removedControl.container.remove(); } - // Move widget to inactive widgets sidebar (move it to trash) if has been previously saved - // This prevents the inactive widgets sidebar from overflowing with throwaway widgets + // Move widget to inactive widgets sidebar (move it to trash) if has been previously saved. + // This prevents the inactive widgets sidebar from overflowing with throwaway widgets. if ( api.Widgets.savedWidgetIds[removedWidgetId] ) { inactiveWidgets = api.value( 'sidebars_widgets[wp_inactive_widgets]' )().slice(); inactiveWidgets.push( removedWidgetId ); api.value( 'sidebars_widgets[wp_inactive_widgets]' )( _( inactiveWidgets ).unique() ); } - // Make old single widget available for adding again + // Make old single widget available for adding again. removedIdBase = parseWidgetId( removedWidgetId ).id_base; widget = api.Widgets.availableWidgets.findWhere( { id_base: removedIdBase } ); if ( widget && ! widget.get( 'is_multi' ) ) { @@ -1916,9 +1921,9 @@ over: function() { var section = api.section( self.section.get() ); section.expand({ - allowMultiple: true, // Prevent the section being dragged from to be collapsed + allowMultiple: true, // Prevent the section being dragged from to be collapsed. completeCallback: function () { - // @todo It is not clear when refreshPositions should be called on which sections, or if it is even needed + // @todo It is not clear when refreshPositions should be called on which sections, or if it is even needed. api.section.each( function ( otherSection ) { if ( otherSection.container.find( '.customize-control-sidebar_widgets' ).length ) { otherSection.container.find( '.accordion-section-content:first' ).sortable( 'refreshPositions' ); @@ -2079,7 +2084,7 @@ return false; } - // Set up new multi widget + // Set up new multi widget. if ( widget.get( 'is_multi' ) && ! widgetNumber ) { widget.set( 'multi_number', widget.get( 'multi_number' ) + 1 ); widgetNumber = widget.get( 'multi_number' ); @@ -2091,7 +2096,7 @@ return m.replace( /__i__|%i%/g, widgetNumber ); } ); } else { - widget.set( 'is_disabled', true ); // Prevent single widget from being added again now + widget.set( 'is_disabled', true ); // Prevent single widget from being added again now. } $widget = $( controlHtml ); @@ -2101,7 +2106,7 @@ .addClass( 'customize-control-' + controlType ) .append( $widget ); - // Remove icon which is visible inside the panel + // Remove icon which is visible inside the panel. controlContainer.find( '> .widget-icon' ).remove(); if ( widget.get( 'is_multi' ) ) { @@ -2111,7 +2116,7 @@ widgetId = controlContainer.find( '[name="widget-id"]' ).val(); - controlContainer.hide(); // to be slid-down below + controlContainer.hide(); // To be slid-down below. settingId = 'widget_' + widget.get( 'id_base' ); if ( widget.get( 'is_multi' ) ) { @@ -2119,7 +2124,7 @@ } controlContainer.attr( 'id', 'customize-control-' + settingId.replace( /\]/g, '' ).replace( /\[/g, '-' ) ); - // Only create setting if it doesn't already exist (if we're adding a pre-existing inactive widget) + // Only create setting if it doesn't already exist (if we're adding a pre-existing inactive widget). isExistingWidget = api.has( settingId ); if ( ! isExistingWidget ) { settingArgs = { @@ -2127,7 +2132,7 @@ previewer: this.setting.previewer }; setting = api.create( settingId, settingId, '', settingArgs ); - setting.set( {} ); // mark dirty, changing from '' to {} + setting.set( {} ); // Mark dirty, changing from '' to {}. } controlConstructor = api.controlConstructor[controlType]; @@ -2147,7 +2152,7 @@ } ); api.control.add( widgetFormControl ); - // Make sure widget is removed from the other sidebars + // Make sure widget is removed from the other sidebars. api.each( function( otherSetting ) { if ( otherSetting.id === self.setting.id ) { return; @@ -2166,7 +2171,7 @@ } } ); - // Add widget to this sidebar + // Add widget to this sidebar. sidebarWidgets = this.setting().slice(); if ( -1 === _.indexOf( sidebarWidgets, widgetId ) ) { sidebarWidgets.push( widgetId ); @@ -2185,7 +2190,7 @@ } } ); - // Register models for custom panel, section, and control types + // Register models for custom panel, section, and control types. $.extend( api.panelConstructor, { widgets: api.Widgets.WidgetsPanel }); @@ -2201,15 +2206,15 @@ * Init Customizer for widgets. */ api.bind( 'ready', function() { - // Set up the widgets panel + // Set up the widgets panel. api.Widgets.availableWidgetsPanel = new api.Widgets.AvailableWidgetsPanelView({ collection: api.Widgets.availableWidgets }); - // Highlight widget control + // Highlight widget control. api.previewer.bind( 'highlight-widget-control', api.Widgets.highlightWidgetFormControl ); - // Open and focus widget control + // Open and focus widget control. api.previewer.bind( 'focus-widget-control', api.Widgets.focusWidgetFormControl ); } ); @@ -2247,7 +2252,7 @@ api.Widgets.getSidebarWidgetControlContainingWidget = function( widgetId ) { var foundControl = null; - // @todo this can use widgetIdToSettingId(), then pass into wp.customize.control( x ).getSidebarWidgetsControl() + // @todo This can use widgetIdToSettingId(), then pass into wp.customize.control( x ).getSidebarWidgetsControl(). api.control.each( function( control ) { if ( control.params.type === 'sidebar_widgets' && -1 !== _.indexOf( control.setting(), widgetId ) ) { foundControl = control; @@ -2266,7 +2271,7 @@ api.Widgets.getWidgetFormControlForWidget = function( widgetId ) { var foundControl = null; - // @todo We can just use widgetIdToSettingId() here + // @todo We can just use widgetIdToSettingId() here. api.control.each( function( control ) { if ( control.params.type === 'widget_form' && control.params.widget_id === widgetId ) { foundControl = control; @@ -2343,7 +2348,7 @@ parsed.id_base = matches[1]; parsed.number = parseInt( matches[2], 10 ); } else { - // likely an old single widget + // Likely an old single widget. parsed.id_base = widgetId; } diff --git a/src/js/_enqueues/wp/editor/base.js b/src/js/_enqueues/wp/editor/base.js index 6159467b9c..602fad7355 100644 --- a/src/js/_enqueues/wp/editor/base.js +++ b/src/js/_enqueues/wp/editor/base.js @@ -112,7 +112,7 @@ window.wp = window.wp || {}; } if ( keepSelection ) { - // Save the selection + // Save the selection. addHTMLBookmarkInTextAreaContent( $textarea ); } @@ -131,7 +131,7 @@ window.wp = window.wp || {}; } if ( editor.getParam( 'wp_keep_scroll_position' ) ) { - // Restore the selection + // Restore the selection. focusHTMLBookmarkInVisualEditor( editor ); } } else { @@ -149,7 +149,8 @@ window.wp = window.wp || {}; } if ( editor ) { - // Don't resize the textarea in iOS. The iframe is forced to 100% height there, we shouldn't match it. + // Don't resize the textarea in iOS. + // The iframe is forced to 100% height there, we shouldn't match it. if ( ! tinymce.Env.iOS ) { iframe = editor.iframeElement; editorHeight = iframe ? parseInt( iframe.style.height, 10 ) : 0; @@ -177,7 +178,8 @@ window.wp = window.wp || {}; selectTextInTextArea( editor, selectionRange ); } } else { - // There is probably a JS error on the page. The TinyMCE editor instance doesn't exist. Show the textarea. + // There is probably a JS error on the page. + // The TinyMCE editor instance doesn't exist. Show the textarea. $textarea.css({ 'display': '', 'visibility': '' }); } @@ -209,7 +211,7 @@ window.wp = window.wp || {}; lastGtPos = content.lastIndexOf( '>', cursorPosition ); if ( lastLtPos > lastGtPos || content.substr( cursorPosition, 1 ) === '>' ) { - // find what the tag is + // Find what the tag is. var tagContent = content.substr( lastLtPos ), tagMatch = tagContent.match( /<\s*(\/)?(\w+|\!-{2}.*-{2})/ ); @@ -222,7 +224,7 @@ window.wp = window.wp || {}; return { ltPos: lastLtPos, - gtPos: lastLtPos + closingGt + 1, // offset by one to get the position _after_ the character, + gtPos: lastLtPos + closingGt + 1, // Offset by one to get the position _after_ the character. tagType: tagType, isClosingTag: !! tagMatch[1] }; @@ -248,7 +250,7 @@ window.wp = window.wp || {}; * @param {number} cursorPosition The cursor position to check. * * @return {(undefined|Object)} Undefined if the cursor is not wrapped in a shortcode tag. - * Information about the wrapping shortcode tag if it's wrapped in one. + * Information about the wrapping shortcode tag if it's wrapped in one. */ function getShortcodeWrapperInfo( content, cursorPosition ) { var contentShortcodes = getShortCodePositionsInText( content ); @@ -403,7 +405,7 @@ window.wp = window.wp || {}; var cursorStart = cursorPositions.cursorStart, cursorEnd = cursorPositions.cursorEnd, - // check if the cursor is in a tag and if so, adjust it + // Check if the cursor is in a tag and if so, adjust it. isCursorStartInTag = getContainingTagInfo( content, cursorStart ); if ( isCursorStartInTag ) { @@ -506,11 +508,11 @@ window.wp = window.wp || {}; } textArea.value = [ - textArea.value.slice( 0, htmlModeCursorStartPosition ), // text until the cursor/selection position - cursorMarkerSkeleton.clone() // cursor/selection start marker + textArea.value.slice( 0, htmlModeCursorStartPosition ), // Text until the cursor/selection position. + cursorMarkerSkeleton.clone() // Cursor/selection start marker. .addClass( 'mce_SELRES_start' )[0].outerHTML, - selectedText, // selected text with end cursor/position marker - textArea.value.slice( htmlModeCursorEndPosition ) // text from last cursor/selection position to end + selectedText, // Selected text with end cursor/position marker. + textArea.value.slice( htmlModeCursorEndPosition ) // Text from last cursor/selection position to end. ].join( '' ); } @@ -804,7 +806,7 @@ window.wp = window.wp || {}; endMatchIndex -= endMatch[1].length; } - // We need to adjust the end position to discard the length of the range start marker + // We need to adjust the end position to discard the length of the range start marker. endIndex = endMatchIndex - startMatchLength; } @@ -826,7 +828,7 @@ window.wp = window.wp || {}; * @param {Object} selection Selection data. */ function selectTextInTextArea( editor, selection ) { - // only valid in the text area mode and if we have selection + // Only valid in the text area mode and if we have selection. if ( ! selection ) { return; } @@ -836,11 +838,11 @@ window.wp = window.wp || {}; end = selection.end || selection.start; if ( textArea.focus ) { - // Wait for the Visual editor to be hidden, then focus and scroll to the position + // Wait for the Visual editor to be hidden, then focus and scroll to the position. setTimeout( function() { textArea.setSelectionRange( start, end ); if ( textArea.blur ) { - // defocus before focusing + // Defocus before focusing. textArea.blur(); } textArea.focus(); @@ -1249,7 +1251,7 @@ window.wp = window.wp || {}; defaults = wp.editor.getDefaultSettings(); - // Initialize TinyMCE by default + // Initialize TinyMCE by default. if ( ! settings ) { settings = { tinymce: true diff --git a/src/js/_enqueues/wp/editor/dfw.js b/src/js/_enqueues/wp/editor/dfw.js index 53ec6f594e..2fc580c1fe 100644 --- a/src/js/_enqueues/wp/editor/dfw.js +++ b/src/js/_enqueues/wp/editor/dfw.js @@ -246,10 +246,11 @@ function mceKeyup( event ) { var key = event.keyCode; - // Bail on special keys. Key code 47 is a / + // Bail on special keys. Key code 47 is a '/'. if ( key <= 47 && ! ( key === VK.SPACEBAR || key === VK.ENTER || key === VK.DELETE || key === VK.BACKSPACE || key === VK.UP || key === VK.LEFT || key === VK.DOWN || key === VK.UP ) ) { return; - // OS keys, function keys, num lock, scroll lock. Key code 91-93 are OS keys. Key code 112-123 are F1 to F12. Key code 144 is num lock. Key code 145 is scroll lock. + // OS keys, function keys, num lock, scroll lock. Key code 91-93 are OS keys. + // Key code 112-123 are F1 to F12. Key code 144 is num lock. Key code 145 is scroll lock. } else if ( ( key >= 91 && key <= 93 ) || ( key >= 112 && key <= 123 ) || key === 144 || key === 145 ) { return; } @@ -516,7 +517,7 @@ * If in visual mode, checks if the editorHeight is greater than the autoresizeMinHeight + topHeight. * If not in visual mode, checks if the editorHeight is greater than the autoresizeMinHeight + 20. */ - canPin = visual ? autoresizeMinHeight + topHeight : autoresizeMinHeight + 20; // 20px from textarea padding + canPin = visual ? autoresizeMinHeight + topHeight : autoresizeMinHeight + 20; // 20px from textarea padding. canPin = editorHeight > ( canPin + 5 ); if ( ! canPin ) { @@ -910,7 +911,7 @@ // Adjust when entering or exiting fullscreen mode. fullscreen && fullscreen.pubsub.unsubscribe( 'hidden', fullscreenHide ); - // Reset all css + // Reset all CSS. $.each( [ $visualTop, $textTop, $tools, $menuBar, $bottom, $statusBar, $contentWrap, $visualEditor, $textEditor, $sideSortables ], function( i, element ) { element && element.attr( 'style', '' ); }); @@ -1179,15 +1180,15 @@ // Return if any of the following keys or combinations of keys is pressed. if ( event && ( event.metaKey || ( event.ctrlKey && ! event.altKey ) || ( event.altKey && event.shiftKey ) || ( key && ( - // Special keys ( tab, ctrl, alt, esc, arrow keys... ) + // Special keys ( tab, ctrl, alt, esc, arrow keys... ). ( key <= 47 && key !== 8 && key !== 13 && key !== 32 && key !== 46 ) || - // Windows keys + // Windows keys. ( key >= 91 && key <= 93 ) || - // F keys + // F keys. ( key >= 112 && key <= 135 ) || - // Num Lock, Scroll Lock, OEM + // Num Lock, Scroll Lock, OEM. ( key >= 144 && key <= 150 ) || - // OEM or non-printable + // OEM or non-printable. key >= 224 ) ) ) ) { return; diff --git a/src/js/_enqueues/wp/emoji.js b/src/js/_enqueues/wp/emoji.js index 27882d1e27..c737bb17bf 100644 --- a/src/js/_enqueues/wp/emoji.js +++ b/src/js/_enqueues/wp/emoji.js @@ -9,8 +9,8 @@ /** * Replaces emoji with images when browsers don't support emoji. * - * @since 4.2.0 - * @access private + * @since 4.2.0 + * @access private * * @class * @@ -22,10 +22,10 @@ function wpEmoji() { var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver, - // Compression and maintain local scope + // Compression and maintain local scope. document = window.document, - // Private + // Private. twemoji, timer, loaded = false, count = 0, @@ -69,7 +69,7 @@ // Ensure twemoji is available on the global window before proceeding. if ( typeof window.twemoji === 'undefined' ) { - // Break if waiting for longer than 30 sec. + // Break if waiting for longer than 30 seconds. if ( count > 600 ) { return; } @@ -245,8 +245,8 @@ } if ( settings.supports.everythingExceptFlag && - ! /^1f1(?:e[6-9a-f]|f[0-9a-f])-1f1(?:e[6-9a-f]|f[0-9a-f])$/.test( icon ) && // Country flags - ! /^(1f3f3-fe0f-200d-1f308|1f3f4-200d-2620-fe0f)$/.test( icon ) // Rainbow and pirate flags + ! /^1f1(?:e[6-9a-f]|f[0-9a-f])-1f1(?:e[6-9a-f]|f[0-9a-f])$/.test( icon ) && // Country flags. + ! /^(1f3f3-fe0f-200d-1f308|1f3f4-200d-2620-fe0f)$/.test( icon ) // Rainbow and pirate flags. ) { return false; } diff --git a/src/js/_enqueues/wp/heartbeat.js b/src/js/_enqueues/wp/heartbeat.js index 98cba71c54..f55d2f87ca 100644 --- a/src/js/_enqueues/wp/heartbeat.js +++ b/src/js/_enqueues/wp/heartbeat.js @@ -62,7 +62,7 @@ // Connect interval (in seconds). mainInterval: 60, - // Used when the interval is set to 5 sec. temporarily. + // Used when the interval is set to 5 seconds temporarily. tempInterval: 0, // Used when the interval is reset. @@ -89,7 +89,7 @@ // Whether the current browser window is in focus and the user is active. hasFocus: true, - // Timestamp, last time the user was active. Checked every 30 sec. + // Timestamp, last time the user was active. Checked every 30 seconds. userActivity: 0, // Flag whether events tracking user activity were set. @@ -106,9 +106,8 @@ /** * Sets local variables and events, then starts the heartbeat. * - * @access private - * * @since 3.8.0 + * @access private * * @return {void} */ @@ -133,9 +132,8 @@ } /* - * The interval can be from 15 to 120 sec. and can be set temporarily to 5 sec. - * It can be set in the initial options or changed later through JS and/or - * through PHP. + * The interval can be from 15 to 120 seconds and can be set temporarily to 5 seconds. + * It can be set in the initial options or changed later through JS and/or through PHP. */ if ( options.interval ) { settings.mainInterval = options.interval; @@ -148,12 +146,12 @@ } /* - * Used to limit the number of AJAX requests. Overrides all other intervals if - * they are shorter. Needed for some hosts that cannot handle frequent requests - * and the user may exceed the allocated server CPU time, etc. The minimal - * interval can be up to 600 sec. however setting it to longer than 120 sec. - * will limit or disable some of the functionality (like post locks). Once set - * at initialization, minimalInterval cannot be changed/overridden. + * Used to limit the number of AJAX requests. Overrides all other intervals + * if they are shorter. Needed for some hosts that cannot handle frequent requests + * and the user may exceed the allocated server CPU time, etc. The minimal interval + * can be up to 600 seconds, however setting it to longer than 120 seconds + * will limit or disable some of the functionality (like post locks). + * Once set at initialization, minimalInterval cannot be changed/overridden. */ if ( options.minimalInterval ) { options.minimalInterval = parseInt( options.minimalInterval, 10 ); @@ -189,11 +187,11 @@ hidden = 'hidden'; visibilitychange = 'visibilitychange'; visibilityState = 'visibilityState'; - } else if ( typeof document.msHidden !== 'undefined' ) { // IE10 + } else if ( typeof document.msHidden !== 'undefined' ) { // IE10. hidden = 'msHidden'; visibilitychange = 'msvisibilitychange'; visibilityState = 'msVisibilityState'; - } else if ( typeof document.webkitHidden !== 'undefined' ) { // Android + } else if ( typeof document.webkitHidden !== 'undefined' ) { // Android. hidden = 'webkitHidden'; visibilitychange = 'webkitvisibilitychange'; visibilityState = 'webkitVisibilityState'; @@ -245,9 +243,8 @@ /** * Returns the current time according to the browser. * - * @access private - * * @since 3.6.0 + * @access private * * @return {number} Returns the current time. */ @@ -258,9 +255,8 @@ /** * Checks if the iframe is from the same origin. * - * @access private - * * @since 3.6.0 + * @access private * * @return {boolean} Returns whether or not the iframe is from the same origin. */ @@ -291,9 +287,8 @@ /** * Checks if the document's focus has changed. * - * @access private - * * @since 4.1.0 + * @access private * * @return {void} */ @@ -308,9 +303,8 @@ /** * Sets error state and fires an event on XHR errors or timeout. * - * @access private - * * @since 3.8.0 + * @access private * * @param {string} error The error type passed from the XHR. * @param {number} status The HTTP status code passed from jqXHR @@ -327,7 +321,7 @@ // Do nothing. break; case 'timeout': - // No response for 30 sec. + // No response for 30 seconds. trigger = true; break; case 'error': @@ -359,9 +353,8 @@ /** * Clears the error state and fires an event if there is a connection error. * - * @access private - * * @since 3.8.0 + * @access private * * @return {void} */ @@ -380,9 +373,8 @@ /** * Gathers the data and connects to the server. * - * @access private - * * @since 3.6.0 + * @access private * * @return {void} */ @@ -421,7 +413,7 @@ settings.xhr = $.ajax({ url: settings.url, type: 'post', - timeout: 30000, // throw an error if not completed after 30 sec. + timeout: 30000, // Throw an error if not completed after 30 seconds. data: ajaxData, dataType: 'json' }).always( function() { @@ -442,7 +434,7 @@ wp.hooks.doAction( 'heartbeat.nonces-expired' ); } - // Change the interval from PHP + // Change the interval from PHP. if ( response.heartbeat_interval ) { newInterval = response.heartbeat_interval; delete response.heartbeat_interval; @@ -464,7 +456,7 @@ $document.trigger( 'heartbeat-tick', [response, textStatus, jqXHR] ); wp.hooks.doAction( 'heartbeat.tick', response, textStatus, jqXHR ); - // Do this last. Can trigger the next XHR if connection time > 5 sec. and newInterval == 'fast'. + // Do this last. Can trigger the next XHR if connection time > 5 seconds and newInterval == 'fast'. if ( newInterval ) { interval( newInterval ); } @@ -480,9 +472,8 @@ * * Fires immediately if the connection time is longer than the interval. * - * @access private - * * @since 3.8.0 + * @access private * * @return {void} */ @@ -495,7 +486,7 @@ } if ( ! settings.hasFocus ) { - interval = 120000; // 120 sec. Post locks expire after 150 sec. + interval = 120000; // 120 seconds. Post locks expire after 150 seconds. } else if ( settings.countdown > 0 && settings.tempInterval ) { interval = settings.tempInterval; settings.countdown--; @@ -526,9 +517,8 @@ /** * Sets the internal state when the browser window becomes hidden or loses focus. * - * @access private - * * @since 3.6.0 + * @access private * * @return {void} */ @@ -539,16 +529,15 @@ /** * Sets the internal state when the browser window becomes visible or is in focus. * - * @access private - * * @since 3.6.0 + * @access private * * @return {void} */ function focused() { settings.userActivity = time(); - // Resume if suspended + // Resume if suspended. settings.suspend = false; if ( ! settings.hasFocus ) { @@ -560,9 +549,8 @@ /** * Runs when the user becomes active after a period of inactivity. * - * @access private - * * @since 3.6.0 + * @access private * * @return {void} */ @@ -582,26 +570,25 @@ /** * Checks for user activity. * - * Runs every 30 sec. Sets 'hasFocus = true' if user is active and the window is - * in the background. Sets 'hasFocus = false' if the user has been inactive - * (no mouse or keyboard activity) for 5 min. even when the window has focus. - * - * @access private + * Runs every 30 seconds. Sets 'hasFocus = true' if user is active and the window + * is in the background. Sets 'hasFocus = false' if the user has been inactive + * (no mouse or keyboard activity) for 5 minutes even when the window has focus. * * @since 3.8.0 + * @access private * * @return {void} */ function checkUserActivity() { var lastActive = settings.userActivity ? time() - settings.userActivity : 0; - // Throttle down when no mouse or keyboard activity for 5 min. + // Throttle down when no mouse or keyboard activity for 5 minutes. if ( lastActive > 300000 && settings.hasFocus ) { blurred(); } - // Suspend after 10 min. of inactivity when suspending is enabled. - // Always suspend after 60 min. of inactivity. This will release the post lock, etc. + // Suspend after 10 minutes of inactivity when suspending is enabled. + // Always suspend after 60 minutes of inactivity. This will release the post lock, etc. if ( ( settings.suspendEnabled && lastActive > 600000 ) || lastActive > 3600000 ) { settings.suspend = true; } @@ -672,9 +659,9 @@ * Disables suspending. * * Should be used only when Heartbeat is performing critical tasks like - * autosave, post-locking, etc. Using this on many screens may overload the - * user's hosting account if several browser windows/tabs are left open for a - * long time. + * autosave, post-locking, etc. Using this on many screens may overload + * the user's hosting account if several browser windows/tabs are left open + * for a long time. * * @since 3.8.0 * @@ -691,15 +678,15 @@ * * When setting to 'fast' or 5, the interval is 5 seconds for the next 30 ticks * (for 2 minutes and 30 seconds) by default. In this case the number of 'ticks' - * can be passed as second argument. If the window doesn't have focus, the - * interval slows down to 2 min. + * can be passed as second argument. If the window doesn't have focus, + * the interval slows down to 2 minutes. * * @since 3.6.0 * * @memberOf wp.heartbeat.prototype * - * @param {string|number} speed Interval: 'fast' or 5, 15, 30, 60, 120. Fast - * equals 5. + * @param {string|number} speed Interval: 'fast' or 5, 15, 30, 60, 120. + * Fast equals 5. * @param {string} ticks Tells how many ticks before the interval reverts * back. Used with speed = 'fast' or 5. * @@ -728,7 +715,7 @@ newInterval = 120000; break; case 'long-polling': - // Allow long polling, (experimental) + // Allow long polling (experimental). settings.mainInterval = 0; return 0; default: @@ -751,9 +738,11 @@ settings.mainInterval = newInterval; } - // Change the next connection time if new interval has been set. - // Will connect immediately if the time since the last connection - // is greater than the new interval. + /* + * Change the next connection time if new interval has been set. + * Will connect immediately if the time since the last connection + * is greater than the new interval. + */ if ( newInterval !== oldInterval ) { scheduleNextTick(); } diff --git a/src/js/_enqueues/wp/mce-view.js b/src/js/_enqueues/wp/mce-view.js index e0439c41c7..1fca3d6d35 100644 --- a/src/js/_enqueues/wp/mce-view.js +++ b/src/js/_enqueues/wp/mce-view.js @@ -565,10 +565,12 @@ dom.add( node, 'span', { 'class': 'wpview-end' } ); } ); - // Bail if the iframe node is not attached to the DOM. - // Happens when the view is dragged in the editor. - // There is a browser restriction when iframes are moved in the DOM. They get emptied. - // The iframe will be rerendered after dropping the view node at the new location. + /* + * Bail if the iframe node is not attached to the DOM. + * Happens when the view is dragged in the editor. + * There is a browser restriction when iframes are moved in the DOM. They get emptied. + * The iframe will be rerendered after dropping the view node at the new location. + */ if ( ! iframe.contentWindow ) { return; } diff --git a/src/js/_enqueues/wp/media/audiovideo.js b/src/js/_enqueues/wp/media/audiovideo.js index 75eee00d52..f0127cc507 100644 --- a/src/js/_enqueues/wp/media/audiovideo.js +++ b/src/js/_enqueues/wp/media/audiovideo.js @@ -53,7 +53,7 @@ wp.media.mixin = { return; } - // invoke features cleanup + // Invoke features cleanup. for ( featureIndex in t.options.features ) { feature = t.options.features[featureIndex]; if ( t['clean' + feature] ) { diff --git a/src/js/_enqueues/wp/media/editor.js b/src/js/_enqueues/wp/media/editor.js index 380dbe2ce2..a02ecf9376 100644 --- a/src/js/_enqueues/wp/media/editor.js +++ b/src/js/_enqueues/wp/media/editor.js @@ -430,9 +430,11 @@ _.extend( attrs, attachments[this.tag].toJSON() ); } - // Convert all gallery shortcodes to use the `ids` property. - // Ignore `post__in` and `post__not_in`; the attachments in - // the collection will already reflect those properties. + /* + * Convert all gallery shortcodes to use the `ids` property. + * Ignore `post__in` and `post__not_in`; the attachments in + * the collection will already reflect those properties. + */ attrs.ids = attachments.pluck('id'); // Copy the `uploadedTo` post ID. @@ -670,7 +672,7 @@ this.content.set( view ); - // after bringing in the frame, load the actual editor via an ajax call + // After bringing in the frame, load the actual editor via an Ajax call. view.loadEditor(); }, this._frame ); @@ -733,9 +735,11 @@ wpActiveEditor = window.wpActiveEditor; } - // Delegate to the global `send_to_editor` if it exists. - // This attempts to play nice with any themes/plugins that have - // overridden the insert functionality. + /* + * Delegate to the global `send_to_editor` if it exists. + * This attempts to play nice with any themes/plugins + * that have overridden the insert functionality. + */ if ( window.send_to_editor ) { return window.send_to_editor.apply( this, arguments ); } @@ -780,7 +784,7 @@ add: function( id, options ) { var workflow = this.get( id ); - // only add once: if exists return existing + // Only add once: if exists return existing. if ( workflow ) { return workflow; } @@ -1016,7 +1020,7 @@ workflow = this.get( id ); - // Redo workflow if state has changed + // Redo workflow if state has changed. if ( ! workflow || ( workflow.options && options.state !== workflow.options.state ) ) { workflow = this.add( id, options ); } diff --git a/src/js/_enqueues/wp/media/models.js b/src/js/_enqueues/wp/media/models.js index 308aea41c0..205616c36c 100644 --- a/src/js/_enqueues/wp/media/models.js +++ b/src/js/_enqueues/wp/media/models.js @@ -147,9 +147,11 @@ _.extend( media, /** @lends wp.media */{ maxHeight = dimensions.maxHeight, constraint; - // Compare ratios between the two values to determine which - // max to constrain by. If a max value doesn't exist, then the - // opposite side is the constraint. + /* + * Compare ratios between the two values to determine + * which max to constrain by. If a max value doesn't exist, + * then the opposite side is the constraint. + */ if ( ! _.isUndefined( maxWidth ) && ! _.isUndefined( maxHeight ) ) { constraint = ( width / height > maxWidth / maxHeight ) ? 'width' : 'height'; } else if ( _.isUndefined( maxHeight ) ) { @@ -236,7 +238,7 @@ media.query = function( props ) { }); }; -// Clean up. Prevents mobile browsers caching +// Clean up. Prevents mobile browsers caching. $(window).on('unload', function(){ window.wp = null; }); diff --git a/src/js/_enqueues/wp/media/views.js b/src/js/_enqueues/wp/media/views.js index d2c35078e6..2f98e029f5 100644 --- a/src/js/_enqueues/wp/media/views.js +++ b/src/js/_enqueues/wp/media/views.js @@ -18,7 +18,7 @@ delete l10n.settings; // Copy the `post` setting over to the model settings. media.model.settings.post = media.view.settings.post; -// Check if the browser supports CSS 3.0 transitions +// Check if the browser supports CSS 3.0 transitions. $.support.transition = (function(){ var style = document.documentElement.style, transitions = { diff --git a/src/js/_enqueues/wp/shortcode.js b/src/js/_enqueues/wp/shortcode.js index bf3e1e21a0..1818d20c51 100644 --- a/src/js/_enqueues/wp/shortcode.js +++ b/src/js/_enqueues/wp/shortcode.js @@ -13,13 +13,15 @@ window.wp = window.wp || {}; (function(){ wp.shortcode = { - // ### Find the next matching shortcode - // - // Given a shortcode `tag`, a block of `text`, and an optional starting - // `index`, returns the next matching shortcode or `undefined`. - // - // Shortcodes are formatted as an object that contains the match - // `content`, the matching `index`, and the parsed `shortcode` object. + /* + * ### Find the next matching shortcode. + * + * Given a shortcode `tag`, a block of `text`, and an optional starting + * `index`, returns the next matching shortcode or `undefined`. + * + * Shortcodes are formatted as an object that contains the match + * `content`, the matching `index`, and the parsed `shortcode` object. + */ next: function( tag, text, index ) { var re = wp.shortcode.regexp( tag ), match, result; @@ -57,15 +59,17 @@ window.wp = window.wp || {}; return result; }, - // ### Replace matching shortcodes in a block of text - // - // Accepts a shortcode `tag`, content `text` to scan, and a `callback` - // to process the shortcode matches and return a replacement string. - // Returns the `text` with all shortcodes replaced. - // - // Shortcode matches are objects that contain the shortcode `tag`, - // a shortcode `attrs` object, the `content` between shortcode tags, - // and a boolean flag to indicate if the match was a `single` tag. + /* + * ### Replace matching shortcodes in a block of text. + * + * Accepts a shortcode `tag`, content `text` to scan, and a `callback` + * to process the shortcode matches and return a replacement string. + * Returns the `text` with all shortcodes replaced. + * + * Shortcode matches are objects that contain the shortcode `tag`, + * a shortcode `attrs` object, the `content` between shortcode tags, + * and a boolean flag to indicate if the match was a `single` tag. + */ replace: function( tag, text, callback ) { return text.replace( wp.shortcode.regexp( tag ), function( match, left, tag, attrs, slash, content, closing, right ) { // If both extra brackets exist, the shortcode has been @@ -83,67 +87,75 @@ window.wp = window.wp || {}; }); }, - // ### Generate a string from shortcode parameters - // - // Creates a `wp.shortcode` instance and returns a string. - // - // Accepts the same `options` as the `wp.shortcode()` constructor, - // containing a `tag` string, a string or object of `attrs`, a boolean - // indicating whether to format the shortcode using a `single` tag, and a - // `content` string. + /* + * ### Generate a string from shortcode parameters. + * + * Creates a `wp.shortcode` instance and returns a string. + * + * Accepts the same `options` as the `wp.shortcode()` constructor, + * containing a `tag` string, a string or object of `attrs`, a boolean + * indicating whether to format the shortcode using a `single` tag, and a + * `content` string. + */ string: function( options ) { return new wp.shortcode( options ).string(); }, - // ### Generate a RegExp to identify a shortcode - // - // The base regex is functionally equivalent to the one found in - // `get_shortcode_regex()` in `wp-includes/shortcodes.php`. - // - // Capture groups: - // - // 1. An extra `[` to allow for escaping shortcodes with double `[[]]` - // 2. The shortcode name - // 3. The shortcode argument list - // 4. The self closing `/` - // 5. The content of a shortcode when it wraps some content. - // 6. The closing tag. - // 7. An extra `]` to allow for escaping shortcodes with double `[[]]` + /* + * ### Generate a RegExp to identify a shortcode. + * + * The base regex is functionally equivalent to the one found in + * `get_shortcode_regex()` in `wp-includes/shortcodes.php`. + * + * Capture groups: + * + * 1. An extra `[` to allow for escaping shortcodes with double `[[]]`. + * 2. The shortcode name. + * 3. The shortcode argument list. + * 4. The self closing `/`. + * 5. The content of a shortcode when it wraps some content. + * 6. The closing tag. + * 7. An extra `]` to allow for escaping shortcodes with double `[[]]`. + */ regexp: _.memoize( function( tag ) { return new RegExp( '\\[(\\[?)(' + tag + ')(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*(?:\\[(?!\\/\\2\\])[^\\[]*)*)(\\[\\/\\2\\]))?)(\\]?)', 'g' ); }), - // ### Parse shortcode attributes - // - // Shortcodes accept many types of attributes. These can chiefly be - // divided into named and numeric attributes: - // - // Named attributes are assigned on a key/value basis, while numeric - // attributes are treated as an array. - // - // Named attributes can be formatted as either `name="value"`, - // `name='value'`, or `name=value`. Numeric attributes can be formatted - // as `"value"` or just `value`. + /* + * ### Parse shortcode attributes. + * + * Shortcodes accept many types of attributes. These can chiefly be + * divided into named and numeric attributes: + * + * Named attributes are assigned on a key/value basis, while numeric + * attributes are treated as an array. + * + * Named attributes can be formatted as either `name="value"`, + * `name='value'`, or `name=value`. Numeric attributes can be formatted + * as `"value"` or just `value`. + */ attrs: _.memoize( function( text ) { var named = {}, numeric = [], pattern, match; - // This regular expression is reused from `shortcode_parse_atts()` - // in `wp-includes/shortcodes.php`. - // - // Capture groups: - // - // 1. An attribute name, that corresponds to... - // 2. a value in double quotes. - // 3. An attribute name, that corresponds to... - // 4. a value in single quotes. - // 5. An attribute name, that corresponds to... - // 6. an unquoted value. - // 7. A numeric attribute in double quotes. - // 8. A numeric attribute in single quotes. - // 9. An unquoted numeric attribute. + /* + * This regular expression is reused from `shortcode_parse_atts()` + * in `wp-includes/shortcodes.php`. + * + * Capture groups: + * + * 1. An attribute name, that corresponds to... + * 2. a value in double quotes. + * 3. An attribute name, that corresponds to... + * 4. a value in single quotes. + * 5. An attribute name, that corresponds to... + * 6. an unquoted value. + * 7. A numeric attribute in double quotes. + * 8. A numeric attribute in single quotes. + * 9. An unquoted numeric attribute. + */ pattern = /([\w-]+)\s*=\s*"([^"]*)"(?:\s|$)|([\w-]+)\s*=\s*'([^']*)'(?:\s|$)|([\w-]+)\s*=\s*([^\s'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|'([^']*)'(?:\s|$)|(\S+)(?:\s|$)/g; // Map zero-width spaces to actual spaces. @@ -172,10 +184,13 @@ window.wp = window.wp || {}; }; }), - // ### Generate a Shortcode Object from a RegExp match - // Accepts a `match` object from calling `regexp.exec()` on a `RegExp` - // generated by `wp.shortcode.regexp()`. `match` can also be set to the - // `arguments` from a callback passed to `regexp.replace()`. + /* + * ### Generate a Shortcode Object from a RegExp match. + * + * Accepts a `match` object from calling `regexp.exec()` on a `RegExp` + * generated by `wp.shortcode.regexp()`. `match` can also be set + * to the `arguments` from a callback passed to `regexp.replace()`. + */ fromMatch: function( match ) { var type; @@ -197,16 +212,18 @@ window.wp = window.wp || {}; }; - // Shortcode Objects - // ----------------- - // - // Shortcode objects are generated automatically when using the main - // `wp.shortcode` methods: `next()`, `replace()`, and `string()`. - // - // To access a raw representation of a shortcode, pass an `options` object, - // containing a `tag` string, a string or object of `attrs`, a string - // indicating the `type` of the shortcode ('single', 'self-closing', or - // 'closed'), and a `content` string. + /* + * Shortcode Objects + * ----------------- + * + * Shortcode objects are generated automatically when using the main + * `wp.shortcode` methods: `next()`, `replace()`, and `string()`. + * + * To access a raw representation of a shortcode, pass an `options` object, + * containing a `tag` string, a string or object of `attrs`, a string + * indicating the `type` of the shortcode ('single', 'self-closing', + * or 'closed'), and a `content` string. + */ wp.shortcode = _.extend( function( options ) { _.extend( this, _.pick( options || {}, 'tag', 'attrs', 'type', 'content' ) ); @@ -239,24 +256,28 @@ window.wp = window.wp || {}; }, wp.shortcode ); _.extend( wp.shortcode.prototype, { - // ### Get a shortcode attribute - // - // Automatically detects whether `attr` is named or numeric and routes - // it accordingly. + /* + * ### Get a shortcode attribute. + * + * Automatically detects whether `attr` is named or numeric and routes + * it accordingly. + */ get: function( attr ) { return this.attrs[ _.isNumber( attr ) ? 'numeric' : 'named' ][ attr ]; }, - // ### Set a shortcode attribute - // - // Automatically detects whether `attr` is named or numeric and routes - // it accordingly. + /* + * ### Set a shortcode attribute. + * + * Automatically detects whether `attr` is named or numeric and routes + * it accordingly. + */ set: function( attr, value ) { this.attrs[ _.isNumber( attr ) ? 'numeric' : 'named' ][ attr ] = value; return this; }, - // ### Transform the shortcode match into a string + // ### Transform the shortcode match into a string. string: function() { var text = '[' + this.tag; @@ -293,20 +314,24 @@ window.wp = window.wp || {}; }); }()); -// HTML utility functions -// ---------------------- -// -// Experimental. These functions may change or be removed in the future. +/* + * HTML utility functions + * ---------------------- + * + * Experimental. These functions may change or be removed in the future. + */ (function(){ wp.html = _.extend( wp.html || {}, { - // ### Parse HTML attributes. - // - // Converts `content` to a set of parsed HTML attributes. - // Utilizes `wp.shortcode.attrs( content )`, which is a valid superset of - // the HTML attribute specification. Reformats the attributes into an - // object that contains the `attrs` with `key:value` mapping, and a record - // of the attributes that were entered using `empty` attribute syntax (i.e. - // with no value). + /* + * ### Parse HTML attributes. + * + * Converts `content` to a set of parsed HTML attributes. + * Utilizes `wp.shortcode.attrs( content )`, which is a valid superset of + * the HTML attribute specification. Reformats the attributes into an + * object that contains the `attrs` with `key:value` mapping, and a record + * of the attributes that were entered using `empty` attribute syntax (i.e. + * with no value). + */ attrs: function( content ) { var result, attrs; diff --git a/src/js/_enqueues/wp/svg-painter.js b/src/js/_enqueues/wp/svg-painter.js index e0277f13f2..e697a0df28 100644 --- a/src/js/_enqueues/wp/svg-painter.js +++ b/src/js/_enqueues/wp/svg-painter.js @@ -13,7 +13,7 @@ wp.svgPainter = ( function( $, window, document, undefined ) { elements = []; $(document).ready( function() { - // detection for browser SVG capability + // Detection for browser SVG capability. if ( document.implementation.hasFeature( 'http://www.w3.org/TR/SVG11/feature#Image', '1.1' ) ) { $( document.body ).removeClass( 'no-svg' ).addClass( 'svg' ); wp.svgPainter.init(); @@ -148,24 +148,24 @@ wp.svgPainter = ( function( $, window, document, undefined ) { }, paint: function() { - // loop through all elements + // Loop through all elements. $.each( elements, function( index, $element ) { var $menuitem = $element.parent().parent(); if ( $menuitem.hasClass( 'current' ) || $menuitem.hasClass( 'wp-has-current-submenu' ) ) { - // paint icon in 'current' color + // Paint icon in 'current' color. painter.paintElement( $element, 'current' ); } else { - // paint icon in base color + // Paint icon in base color. painter.paintElement( $element, 'base' ); - // set hover callbacks + // Set hover callbacks. $menuitem.hover( function() { painter.paintElement( $element, 'focus' ); }, function() { - // Match the delay from hoverIntent + // Match the delay from hoverIntent. window.setTimeout( function() { painter.paintElement( $element, 'base' ); }, 100 ); @@ -184,7 +184,7 @@ wp.svgPainter = ( function( $, window, document, undefined ) { color = colorscheme[ colorType ]; - // only accept hex colors: #101 or #101010 + // Only accept hex colors: #101 or #101010. if ( ! color.match( /^(#[0-9a-f]{3}|#[0-9a-f]{6})$/i ) ) { return; } @@ -212,13 +212,13 @@ wp.svgPainter = ( function( $, window, document, undefined ) { } catch ( error ) {} if ( xml ) { - // replace `fill` attributes + // Replace `fill` attributes. xml = xml.replace( /fill="(.+?)"/g, 'fill="' + color + '"'); - // replace `style` attributes + // Replace `style` attributes. xml = xml.replace( /style="(.+?)"/g, 'style="fill:' + color + '"'); - // replace `fill` properties in `<style>` tags + // Replace `fill` properties in `<style>` tags. xml = xml.replace( /fill:.*?;/g, 'fill: ' + color + ';'); if ( 'btoa' in window ) { diff --git a/src/js/_enqueues/wp/theme-plugin-editor.js b/src/js/_enqueues/wp/theme-plugin-editor.js index 6ddb9dff47..84695dfefa 100644 --- a/src/js/_enqueues/wp/theme-plugin-editor.js +++ b/src/js/_enqueues/wp/theme-plugin-editor.js @@ -491,7 +491,7 @@ wp.themePluginEditor = (function( $ ) { var TreeitemLink = function (node, treeObj, group) { - // Check whether node is a DOM element + // Check whether node is a DOM element. if (typeof node !== 'object') { return; } @@ -696,7 +696,7 @@ wp.themePluginEditor = (function( $ ) { TreeitemLink.prototype.handleClick = function (event) { - // only process click events that directly happened on this treeitem + // Only process click events that directly happened on this treeitem. if (event.target !== this.domNode && event.target !== this.domNode.firstElementChild) { return; } @@ -773,7 +773,7 @@ wp.themePluginEditor = (function( $ ) { */ var TreeLinks = function (node) { - // Check whether node is a DOM element + // Check whether node is a DOM element. if (typeof node !== 'object') { return; } @@ -812,7 +812,7 @@ wp.themePluginEditor = (function( $ ) { } } - // initialize pop up menus + // Initialize pop up menus. if (!this.domNode.getAttribute('role')) { this.domNode.setAttribute('role', 'tree'); } @@ -964,16 +964,16 @@ wp.themePluginEditor = (function( $ ) { var start, index; _char = _char.toLowerCase(); - // Get start index for search based on position of currentItem + // Get start index for search based on position of currentItem. start = this.treeitems.indexOf(currentItem) + 1; if (start === this.treeitems.length) { start = 0; } - // Check remaining slots in the menu + // Check remaining slots in the menu. index = this.getIndexFirstChars(start, _char); - // If not found in remaining slots, check from beginning + // If not found in remaining slots, check from beginning. if (index === -1) { index = this.getIndexFirstChars(0, _char); } diff --git a/src/js/_enqueues/wp/theme.js b/src/js/_enqueues/wp/theme.js index 0d29fe8876..7f7f0ce1fb 100644 --- a/src/js/_enqueues/wp/theme.js +++ b/src/js/_enqueues/wp/theme.js @@ -11,20 +11,20 @@ window.wp = window.wp || {}; var themes, l10n; themes = wp.themes = wp.themes || {}; -// Store the theme data and settings for organized and quick access -// themes.data.settings, themes.data.themes, themes.data.l10n +// Store the theme data and settings for organized and quick access. +// themes.data.settings, themes.data.themes, themes.data.l10n. themes.data = _wpThemeSettings; l10n = themes.data.l10n; -// Shortcut for isInstall check +// Shortcut for isInstall check. themes.isInstall = !! themes.data.settings.isInstall; -// Setup app structure +// Setup app structure. _.extend( themes, { model: {}, view: {}, routes: {}, router: {}, template: wp.template }); themes.Model = Backbone.Model.extend({ - // Adds attributes to the default data coming through the .org themes api - // Map `id` to `slug` for shared code + // Adds attributes to the default data coming through the .org themes api. + // Map `id` to `slug` for shared code. initialize: function() { var description; @@ -33,14 +33,14 @@ themes.Model = Backbone.Model.extend({ this.set({ installed: true }); } - // Set the attributes + // Set the attributes. this.set({ - // slug is for installation, id is for existing. + // `slug` is for installation, `id` is for existing. id: this.get( 'slug' ) || this.get( 'id' ) }); // Map `section.description` to `description` - // as the API sometimes returns it differently + // as the API sometimes returns it differently. if ( this.has( 'sections' ) ) { description = this.get( 'sections' ).description; this.set({ description: description }); @@ -48,31 +48,31 @@ themes.Model = Backbone.Model.extend({ } }); -// Main view controller for themes.php -// Unifies and renders all available views +// Main view controller for themes.php. +// Unifies and renders all available views. themes.view.Appearance = wp.Backbone.View.extend({ el: '#wpbody-content .wrap .theme-browser', window: $( window ), - // Pagination instance + // Pagination instance. page: 0, - // Sets up a throttler for binding to 'scroll' + // Sets up a throttler for binding to 'scroll'. initialize: function( options ) { - // Scroller checks how far the scroll position is + // Scroller checks how far the scroll position is. _.bindAll( this, 'scroller' ); this.SearchView = options.SearchView ? options.SearchView : themes.view.Search; // Bind to the scroll event and throttle - // the results from this.scroller + // the results from this.scroller. this.window.bind( 'scroll', _.throttle( this.scroller, 300 ) ); }, - // Main render control + // Main render control. render: function() { // Setup the main theme view - // with the current theme collection + // with the current theme collection. this.view = new themes.view.Themes({ collection: this.collection, parent: this @@ -83,21 +83,21 @@ themes.view.Appearance = wp.Backbone.View.extend({ this.$el.removeClass( 'search-loading' ); - // Render and append + // Render and append. this.view.render(); this.$el.empty().append( this.view.el ).addClass( 'rendered' ); }, - // Defines search element container + // Defines search element container. searchContainer: $( '.search-form' ), // Search input and view - // for current theme collection + // for current theme collection. search: function() { var view, self = this; - // Don't render the search if there is only one theme + // Don't render the search if there is only one theme. if ( themes.data.themes.length === 1 ) { return; } @@ -108,7 +108,7 @@ themes.view.Appearance = wp.Backbone.View.extend({ }); self.SearchView = view; - // Render and append after screen title + // Render and append after screen title. view.render(); this.searchContainer .append( $.parseHTML( '<label class="screen-reader-text" for="wp-filter-search-input">' + l10n.search + '</label>' ) ) @@ -119,7 +119,7 @@ themes.view.Appearance = wp.Backbone.View.extend({ }, // Checks when the user gets close to the bottom - // of the mage and triggers a theme:scroll event + // of the mage and triggers a theme:scroll event. scroller: function() { var self = this, bottom, threshold; @@ -134,26 +134,26 @@ themes.view.Appearance = wp.Backbone.View.extend({ } }); -// Set up the Collection for our theme data +// Set up the Collection for our theme data. // @has 'id' 'name' 'screenshot' 'author' 'authorURI' 'version' 'active' ... themes.Collection = Backbone.Collection.extend({ model: themes.Model, - // Search terms + // Search terms. terms: '', // Controls searching on the current theme collection - // and triggers an update event + // and triggers an update event. doSearch: function( value ) { - // Don't do anything if we've already done this search - // Useful because the Search handler fires multiple times per keystroke + // Don't do anything if we've already done this search. + // Useful because the Search handler fires multiple times per keystroke. if ( this.terms === value ) { return; } - // Updates terms with the value passed + // Updates terms with the value passed. this.terms = value; // If we have terms, run a search... @@ -161,38 +161,41 @@ themes.Collection = Backbone.Collection.extend({ this.search( this.terms ); } - // If search is blank, show all themes - // Useful for resetting the views when you clean the input + // If search is blank, show all themes. + // Useful for resetting the views when you clean the input. if ( this.terms === '' ) { this.reset( themes.data.themes ); $( 'body' ).removeClass( 'no-results' ); } - // Trigger a 'themes:update' event + // Trigger a 'themes:update' event. this.trigger( 'themes:update' ); }, - // Performs a search within the collection - // @uses RegExp + /** + * Performs a search within the collection. + * + * @uses RegExp + */ search: function( term ) { var match, results, haystack, name, description, author; - // Start with a full collection + // Start with a full collection. this.reset( themes.data.themes, { silent: true } ); - // Trim the term + // Trim the term. term = term.trim(); - // Escape the term string for RegExp meta characters + // Escape the term string for RegExp meta characters. term = term.replace( /[-\/\\^$*+?.()|[\]{}]/g, '\\$&' ); // Consider spaces as word delimiters and match the whole string - // so matching terms can be combined + // so matching terms can be combined. term = term.replace( / /g, ')(?=.*' ); match = new RegExp( '^(?=.*' + term + ').+', 'i' ); - // Find results - // _.filter and .test + // Find results. + // _.filter() and .test(). results = this.filter( function( data ) { name = data.get( 'name' ).replace( /(<([^>]+)>)/ig, '' ); description = data.get( 'description' ).replace( /(<([^>]+)>)/ig, '' ); @@ -217,12 +220,12 @@ themes.Collection = Backbone.Collection.extend({ }, // Paginates the collection with a helper method - // that slices the collection + // that slices the collection. paginate: function( instance ) { var collection = this; instance = instance || 0; - // Themes per instance are set at 20 + // Themes per instance are set at 20. collection = _( collection.rest( 20 * instance ) ); collection = _( collection.first( 20 ) ); @@ -231,11 +234,13 @@ themes.Collection = Backbone.Collection.extend({ count: false, - // Handles requests for more themes - // and caches results - // - // When we are missing a cache object we fire an apiCall() - // which triggers events of `query:success` or `query:fail` + /* + * Handles requests for more themes and caches results. + * + * + * When we are missing a cache object we fire an apiCall() + * which triggers events of `query:success` or `query:fail`. + */ query: function( request ) { /** * @static @@ -246,7 +251,7 @@ themes.Collection = Backbone.Collection.extend({ query, isPaginated, count; // Store current query request args - // for later use with the event `theme:end` + // for later use with the event `theme:end`. this.currentQuery.request = request; // Search the query cache for matches. @@ -271,7 +276,7 @@ themes.Collection = Backbone.Collection.extend({ if ( data.themes ) { self.reset( data.themes ); count = data.info.results; - // Store the results and the query request + // Store the results and the query request. queries.push( { themes: data.themes, request: request, total: count } ); } @@ -291,8 +296,8 @@ themes.Collection = Backbone.Collection.extend({ // If it's a paginated request we need to fetch more themes... if ( isPaginated ) { return this.apiCall( request, isPaginated ).done( function( data ) { - // Add the new themes to the current collection - // @todo update counter + // Add the new themes to the current collection. + // @todo Update counter. self.add( data.themes ); self.trigger( 'query:success' ); @@ -311,7 +316,7 @@ themes.Collection = Backbone.Collection.extend({ } // Only trigger an update event since we already have the themes - // on our cached object + // on our cached object. if ( _.isNumber( query.total ) ) { this.count = query.total; } @@ -326,20 +331,20 @@ themes.Collection = Backbone.Collection.extend({ } }, - // Local cache array for API queries + // Local cache array for API queries. queries: [], - // Keep track of current query so we can handle pagination + // Keep track of current query so we can handle pagination. currentQuery: { page: 1, request: {} }, - // Send request to api.wordpress.org/themes + // Send request to api.wordpress.org/themes. apiCall: function( request, paginated ) { return wp.ajax.send( 'query-themes', { data: { - // Request data + // Request data. request: _.extend({ per_page: 100 }, request) @@ -347,7 +352,7 @@ themes.Collection = Backbone.Collection.extend({ beforeSend: function() { if ( ! paginated ) { - // Spin it + // Spin it. $( 'body' ).addClass( 'loading-content' ).removeClass( 'no-results' ); } } @@ -359,17 +364,17 @@ themes.Collection = Backbone.Collection.extend({ }); // This is the view that controls each theme item -// that will be displayed on the screen +// that will be displayed on the screen. themes.view.Theme = wp.Backbone.View.extend({ - // Wrap theme data on a div.theme element + // Wrap theme data on a div.theme element. className: 'theme', - // Reflects which theme view we have - // 'grid' (default) or 'detail' + // Reflects which theme view we have. + // 'grid' (default) or 'detail'. state: 'grid', - // The HTML template for each element to be rendered + // The HTML template for each element to be rendered. html: themes.template( 'theme' ), events: { @@ -391,14 +396,14 @@ themes.view.Theme = wp.Backbone.View.extend({ render: function() { var data = this.model.toJSON(); - // Render themes using the html template + // Render themes using the html template. this.$el.html( this.html( data ) ).attr({ tabindex: 0, 'aria-describedby' : data.id + '-action ' + data.id + '-name', 'data-slug': data.id }); - // Renders active theme styles + // Renders active theme styles. this.activeTheme(); if ( this.model.get( 'displayAuthor' ) ) { @@ -407,7 +412,7 @@ themes.view.Theme = wp.Backbone.View.extend({ }, // Adds a class to the currently active theme - // and to the overlay in detailed view mode + // and to the overlay in detailed view mode. activeTheme: function() { if ( this.model.get( 'active' ) ) { this.$el.addClass( 'active' ); @@ -422,25 +427,25 @@ themes.view.Theme = wp.Backbone.View.extend({ $themeToFocus.addClass('focus'); }, - // Single theme overlay screen - // It's shown when clicking a theme + // Single theme overlay screen. + // It's shown when clicking a theme. expand: function( event ) { var self = this; event = event || window.event; - // 'enter' and 'space' keys expand the details view when a theme is :focused + // 'Enter' and 'Space' keys expand the details view when a theme is :focused. if ( event.type === 'keydown' && ( event.which !== 13 && event.which !== 32 ) ) { return; } - // Bail if the user scrolled on a touch device + // Bail if the user scrolled on a touch device. if ( this.touchDrag === true ) { return this.touchDrag = false; } // Prevent the modal from showing when the user clicks - // one of the direct action buttons + // one of the direct action buttons. if ( $( event.target ).is( '.theme-actions a' ) ) { return; } @@ -450,7 +455,7 @@ themes.view.Theme = wp.Backbone.View.extend({ return; } - // Set focused theme to current element + // Set focused theme to current element. themes.focusedTheme = this.$el; this.trigger( 'theme:expand', self.model.cid ); @@ -466,7 +471,7 @@ themes.view.Theme = wp.Backbone.View.extend({ event = event || window.event; - // Bail if the user scrolled on a touch device + // Bail if the user scrolled on a touch device. if ( this.touchDrag === true ) { return this.touchDrag = false; } @@ -476,12 +481,12 @@ themes.view.Theme = wp.Backbone.View.extend({ return; } - // 'enter' and 'space' keys expand the details view when a theme is :focused + // 'Enter' and 'Space' keys expand the details view when a theme is :focused. if ( event.type === 'keydown' && ( event.which !== 13 && event.which !== 32 ) ) { return; } - // pressing enter while focused on the buttons shouldn't open the preview + // Pressing Enter while focused on the buttons shouldn't open the preview. if ( event.type === 'keydown' && event.which !== 13 && $( ':focus' ).hasClass( 'button' ) ) { return; } @@ -502,14 +507,14 @@ themes.view.Theme = wp.Backbone.View.extend({ preview.render(); this.setNavButtonsState(); - // Hide previous/next navigation if there is only one theme + // Hide previous/next navigation if there is only one theme. if ( this.model.collection.length === 1 ) { preview.$el.addClass( 'no-navigation' ); } else { preview.$el.removeClass( 'no-navigation' ); } - // Append preview + // Append preview. $( 'div.wrap' ).append( preview.el ); // Listen to our preview object @@ -545,7 +550,7 @@ themes.view.Theme = wp.Backbone.View.extend({ // Keep track of current theme model. current = self.model; - // Bail early if we are at the beginning of the collection + // Bail early if we are at the beginning of the collection. if ( self.model.collection.indexOf( self.current ) === 0 ) { return; } @@ -577,14 +582,14 @@ themes.view.Theme = wp.Backbone.View.extend({ }, - // Handles .disabled classes for previous/next buttons in theme installer preview + // 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, previousThemeButton = $themeInstaller.find( '.previous-theme' ), nextThemeButton = $themeInstaller.find( '.next-theme' ); - // Disable previous at the zero position + // Disable previous at the zero position. if ( 0 === this.model.collection.indexOf( current ) ) { previousThemeButton .addClass( 'disabled' ) @@ -593,7 +598,7 @@ themes.view.Theme = wp.Backbone.View.extend({ nextThemeButton.focus(); } - // Disable next if the next model is undefined + // Disable next if the next model is undefined. if ( _.isUndefined( this.model.collection.at( this.model.collection.indexOf( current ) + 1 ) ) ) { nextThemeButton .addClass( 'disabled' ) @@ -649,11 +654,11 @@ themes.view.Theme = wp.Backbone.View.extend({ } }); -// Theme Details view -// Set ups a modal overlay with the expanded theme data +// Theme Details view. +// Sets up a modal overlay with the expanded theme data. themes.view.Details = wp.Backbone.View.extend({ - // Wrap theme data on a div.theme element + // Wrap theme data on a div.theme element. className: 'theme-overlay', events: { @@ -664,26 +669,26 @@ themes.view.Details = wp.Backbone.View.extend({ 'click #update-theme': 'updateTheme' }, - // The HTML template for the theme overlay + // The HTML template for the theme overlay. html: themes.template( 'theme-single' ), render: function() { var data = this.model.toJSON(); this.$el.html( this.html( data ) ); - // Renders active theme styles + // Renders active theme styles. this.activeTheme(); - // Set up navigation events + // Set up navigation events. this.navigation(); - // Checks screenshot size + // Checks screenshot size. this.screenshotCheck( this.$el ); - // Contain "tabbing" inside the overlay + // Contain "tabbing" inside the overlay. this.containFocus( this.$el ); }, // Adds a class to the currently active theme - // and to the overlay in detailed view mode + // and to the overlay in detailed view mode. activeTheme: function() { - // Check the model has the active property + // Check the model has the active property. this.$el.toggleClass( 'active', this.model.get( 'active' ) ); }, @@ -713,44 +718,43 @@ themes.view.Details = wp.Backbone.View.extend({ }); }, - // Single theme overlay screen - // It's shown when clicking a theme + // Single theme overlay screen. + // It's shown when clicking a theme. collapse: function( event ) { var self = this, scroll; event = event || window.event; - // Prevent collapsing detailed view when there is only one theme available + // Prevent collapsing detailed view when there is only one theme available. if ( themes.data.themes.length === 1 ) { return; } - // Detect if the click is inside the overlay - // and don't close it unless the target was - // the div.back button + // Detect if the click is inside the overlay and don't close it + // unless the target was the div.back button. if ( $( event.target ).is( '.theme-backdrop' ) || $( event.target ).is( '.close' ) || event.keyCode === 27 ) { - // Add a temporary closing class while overlay fades out + // Add a temporary closing class while overlay fades out. $( 'body' ).addClass( 'closing-overlay' ); - // With a quick fade out animation + // With a quick fade out animation. this.$el.fadeOut( 130, function() { - // Clicking outside the modal box closes the overlay + // Clicking outside the modal box closes the overlay. $( 'body' ).removeClass( 'closing-overlay' ); - // Handle event cleanup + // Handle event cleanup. self.closeOverlay(); - // Get scroll position to avoid jumping to the top + // Get scroll position to avoid jumping to the top. scroll = document.body.scrollTop; - // Clean the url structure + // Clean the URL structure. themes.router.navigate( themes.router.baseUrl( '' ) ); - // Restore scroll position + // Restore scroll position. document.body.scrollTop = scroll; - // Return focus to the theme div + // Return focus to the theme div. if ( themes.focusedTheme ) { themes.focusedTheme.focus(); } @@ -758,10 +762,10 @@ themes.view.Details = wp.Backbone.View.extend({ } }, - // Handles .disabled classes for next/previous buttons + // Handles .disabled classes for next/previous buttons. navigation: function() { - // Disable Left/Right when at the start or end of the collection + // Disable Left/Right when at the start or end of the collection. if ( this.model.cid === this.model.collection.at(0).cid ) { this.$el.find( '.left' ) .addClass( 'disabled' ) @@ -775,7 +779,7 @@ themes.view.Details = wp.Backbone.View.extend({ }, // Performs the actions to effectively close - // the theme details overlay + // the theme details overlay. closeOverlay: function() { $( 'body' ).removeClass( 'modal-open' ); this.remove(); @@ -848,7 +852,7 @@ themes.view.Details = wp.Backbone.View.extend({ }, // Checks if the theme screenshot is the old 300px width version - // and adds a corresponding class if it's true + // and adds a corresponding class if it's true. screenshotCheck: function( el ) { var screenshot, image; @@ -856,15 +860,15 @@ themes.view.Details = wp.Backbone.View.extend({ image = new Image(); image.src = screenshot.attr( 'src' ); - // Width check + // Width check. if ( image.width && image.width <= 300 ) { el.addClass( 'small-screenshot' ); } } }); -// Theme Preview view -// Set ups a modal overlay with the expanded theme data +// Theme Preview view. +// Sets up a modal overlay with the expanded theme data. themes.view.Preview = themes.view.Details.extend({ className: 'wp-full-overlay expanded', @@ -880,7 +884,7 @@ themes.view.Preview = themes.view.Details.extend({ 'click .theme-install': 'installTheme' }, - // The HTML template for the theme preview + // The HTML template for the theme preview. html: themes.template( 'theme-preview' ), render: function() { @@ -918,7 +922,7 @@ themes.view.Preview = themes.view.Details.extend({ this.$el.fadeOut( 200, function() { $( 'body' ).removeClass( 'theme-installer-active full-overlay-active' ); - // Return focus to the theme div + // Return focus to the theme div. if ( themes.focusedTheme ) { themes.focusedTheme.focus(); } @@ -973,17 +977,17 @@ themes.view.Preview = themes.view.Details.extend({ }, keyEvent: function( event ) { - // The escape key closes the preview + // The escape key closes the preview. if ( event.keyCode === 27 ) { this.undelegateEvents(); this.close(); } - // The right arrow key, next theme + // The right arrow key, next theme. if ( event.keyCode === 39 ) { _.once( this.nextTheme() ); } - // The left arrow key, previous theme + // The left arrow key, previous theme. if ( event.keyCode === 37 ) { this.previousTheme(); } @@ -1011,32 +1015,32 @@ themes.view.Preview = themes.view.Details.extend({ }); // Controls the rendering of div.themes, -// a wrapper that will hold all the theme elements +// a wrapper that will hold all the theme elements. themes.view.Themes = wp.Backbone.View.extend({ className: 'themes wp-clearfix', $overlay: $( 'div.theme-overlay' ), // Number to keep track of scroll position - // while in theme-overlay mode + // while in theme-overlay mode. index: 0, - // The theme count element + // The theme count element. count: $( '.wrap .theme-count' ), - // The live themes count + // The live themes count. liveThemeCount: 0, initialize: function( options ) { var self = this; - // Set up parent + // Set up parent. this.parent = options.parent; - // Set current view to [grid] + // Set current view to [grid]. this.setView( 'grid' ); - // Move the active theme to the beginning of the collection + // Move the active theme to the beginning of the collection. self.currentTheme(); // When the collection is updated by user input... @@ -1082,17 +1086,17 @@ themes.view.Themes = wp.Backbone.View.extend({ return; } - // Pressing the right arrow key fires a theme:next event + // Pressing the right arrow key fires a theme:next event. if ( event.keyCode === 39 ) { self.overlay.nextTheme(); } - // Pressing the left arrow key fires a theme:previous event + // Pressing the left arrow key fires a theme:previous event. if ( event.keyCode === 37 ) { self.overlay.previousTheme(); } - // Pressing the escape key fires a theme:collapse event + // Pressing the escape key fires a theme:collapse event. if ( event.keyCode === 27 ) { self.overlay.collapse( event ); } @@ -1100,35 +1104,33 @@ themes.view.Themes = wp.Backbone.View.extend({ }, // Manages rendering of theme pages - // and keeping theme count in sync + // and keeping theme count in sync. render: function() { - // Clear the DOM, please + // Clear the DOM, please. this.$el.empty(); - // If the user doesn't have switch capabilities - // or there is only one theme in the collection - // render the detailed view of the active theme + // If the user doesn't have switch capabilities or there is only one theme + // in the collection, render the detailed view of the active theme. if ( themes.data.themes.length === 1 ) { - // Constructs the view + // Constructs the view. this.singleTheme = new themes.view.Details({ model: this.collection.models[0] }); - // Render and apply a 'single-theme' class to our container + // Render and apply a 'single-theme' class to our container. this.singleTheme.render(); this.$el.addClass( 'single-theme' ); this.$el.append( this.singleTheme.el ); } - // Generate the themes - // Using page instance - // While checking the collection has items + // Generate the themes using page instance + // while checking the collection has items. if ( this.options.collection.size() > 0 ) { this.renderThemes( this.parent.page ); } - // Display a live theme count for the collection + // Display a live theme count for the collection. this.liveThemeCount = this.collection.count ? this.collection.count : this.collection.length; this.count.text( this.liveThemeCount ); @@ -1142,25 +1144,25 @@ themes.view.Themes = wp.Backbone.View.extend({ }, // Iterates through each instance of the collection - // and renders each theme module + // and renders each theme module. renderThemes: function( page ) { var self = this; self.instance = self.collection.paginate( page ); - // If we have no more themes bail + // If we have no more themes, bail. if ( self.instance.size() === 0 ) { // Fire a no-more-themes event. this.parent.trigger( 'theme:end' ); return; } - // Make sure the add-new stays at the end + // Make sure the add-new stays at the end. if ( ! themes.isInstall && page >= 1 ) { $( '.add-new-theme' ).remove(); } - // Loop through the themes and setup each theme view + // Loop through the themes and setup each theme view. self.instance.each( function( theme ) { self.theme = new themes.view.Theme({ model: theme, @@ -1169,15 +1171,15 @@ themes.view.Themes = wp.Backbone.View.extend({ // Render the views... self.theme.render(); - // and append them to div.themes + // ...and append them to div.themes. self.$el.append( self.theme.el ); // Binds to theme:expand to show the modal box - // with the theme details + // with the theme details. self.listenTo( self.theme, 'theme:expand', self.expand, self ); }); - // 'Add new theme' element shown at the end of the grid + // 'Add new theme' element shown at the end of the grid. if ( ! themes.isInstall && themes.data.settings.canInstall ) { this.$el.append( '<div class="theme add-new-theme"><a href="' + themes.data.settings.installURI + '"><div class="theme-screenshot"><span></span></div><h2 class="theme-name">' + l10n.addNew + '</h2></a></div>' ); } @@ -1185,41 +1187,41 @@ themes.view.Themes = wp.Backbone.View.extend({ this.parent.page++; }, - // Grabs current theme and puts it at the beginning of the collection + // Grabs current theme and puts it at the beginning of the collection. currentTheme: function() { var self = this, current; current = self.collection.findWhere({ active: true }); - // Move the active theme to the beginning of the collection + // Move the active theme to the beginning of the collection. if ( current ) { self.collection.remove( current ); self.collection.add( current, { at:0 } ); } }, - // Sets current view + // Sets current view. setView: function( view ) { return view; }, - // Renders the overlay with the ThemeDetails view - // Uses the current model data + // Renders the overlay with the ThemeDetails view. + // Uses the current model data. expand: function( id ) { var self = this, $card, $modal; - // Set the current theme model + // Set the current theme model. this.model = self.collection.get( id ); - // Trigger a route update for the current model + // Trigger a route update for the current model. themes.router.navigate( themes.router.baseUrl( themes.router.themePath + this.model.id ) ); - // Sets this.view to 'detail' + // Sets this.view to 'detail'. this.setView( 'detail' ); $( 'body' ).addClass( 'modal-open' ); - // Set up the theme details view + // Set up the theme details view. this.overlay = new themes.view.Details({ model: self.model }); @@ -1243,72 +1245,75 @@ themes.view.Themes = wp.Backbone.View.extend({ this.$overlay.html( this.overlay.el ); - // Bind to theme:next and theme:previous - // triggered by the arrow keys - // - // Keep track of the current model so we - // can infer an index position + // Bind to theme:next and theme:previous triggered by the arrow keys. + // Keep track of the current model so we can infer an index position. this.listenTo( this.overlay, 'theme:next', function() { - // Renders the next theme on the overlay + // Renders the next theme on the overlay. self.next( [ self.model.cid ] ); }) .listenTo( this.overlay, 'theme:previous', function() { - // Renders the previous theme on the overlay + // Renders the previous theme on the overlay. self.previous( [ self.model.cid ] ); }); }, - // This method renders the next theme on the overlay modal - // based on the current position in the collection - // @params [model cid] + /* + * This method renders the next theme on the overlay modal + * based on the current position in the collection. + * + * @params [model cid] + */ next: function( args ) { var self = this, model, nextModel; - // Get the current theme + // Get the current theme. model = self.collection.get( args[0] ); - // Find the next model within the collection + // Find the next model within the collection. nextModel = self.collection.at( self.collection.indexOf( model ) + 1 ); - // Sanity check which also serves as a boundary test + // Sanity check which also serves as a boundary test. if ( nextModel !== undefined ) { // We have a new theme... - // Close the overlay + // Close the overlay. this.overlay.closeOverlay(); - // Trigger a route update for the current model + // Trigger a route update for the current model. self.theme.trigger( 'theme:expand', nextModel.cid ); } }, - // This method renders the previous theme on the overlay modal - // based on the current position in the collection - // @params [model cid] + /* + * This method renders the previous theme on the overlay modal + * based on the current position in the collection. + * + * @params [model cid] + */ previous: function( args ) { var self = this, model, previousModel; - // Get the current theme + // Get the current theme. model = self.collection.get( args[0] ); - // Find the previous model within the collection + // Find the previous model within the collection. previousModel = self.collection.at( self.collection.indexOf( model ) - 1 ); if ( previousModel !== undefined ) { // We have a new theme... - // Close the overlay + // Close the overlay. this.overlay.closeOverlay(); - // Trigger a route update for the current model + // Trigger a route update for the current model. self.theme.trigger( 'theme:expand', previousModel.cid ); } }, - // Dispatch audible search results feedback message + // Dispatch audible search results feedback message. announceSearchResults: function( count ) { if ( 0 === count ) { wp.a11y.speak( l10n.noThemesFound ); @@ -1364,14 +1369,14 @@ themes.view.Search = wp.Backbone.View.extend({ this.collection.doSearch( event.target.value.replace( /\+/g, ' ' ) ); - // if search is initiated and key is not return + // if search is initiated and key is not return. if ( this.searching && event.which !== 13 ) { options.replace = true; } else { this.searching = true; } - // Update the URL hash + // Update the URL hash. if ( event.target.value ) { themes.router.navigate( themes.router.baseUrl( themes.router.searchPath + event.target.value ), options ); } else { @@ -1408,8 +1413,8 @@ function navigateRouter( url, state ) { } } -// Sets up the routes events for relevant url queries -// Listens to [theme] and [search] params +// Sets up the routes events for relevant url queries. +// Listens to [theme] and [search] params. themes.Router = Backbone.Router.extend({ routes: { @@ -1439,14 +1444,14 @@ themes.Router = Backbone.Router.extend({ }); -// Execute and setup the application +// Execute and setup the application. themes.Run = { init: function() { - // Initializes the blog's theme library view - // Create a new collection with data + // Initializes the blog's theme library view. + // Create a new collection with data. this.themes = new themes.Collection( themes.data.themes ); - // Set up the view + // Set up the view. this.view = new themes.view.Appearance({ collection: this.themes }); @@ -1459,7 +1464,7 @@ themes.Run = { render: function() { - // Render results + // Render results. this.view.render(); this.routes(); @@ -1476,10 +1481,10 @@ themes.Run = { routes: function() { var self = this; // Bind to our global thx object - // so that the object is available to sub-views + // so that the object is available to sub-views. themes.router = new themes.Router(); - // Handles theme details route event + // Handles theme details route event. themes.router.on( 'route:theme', function( slug ) { self.view.view.expand( slug ); }); @@ -1489,7 +1494,7 @@ themes.Run = { self.view.trigger( 'theme:close' ); }); - // Handles search route event + // Handles search route event. themes.router.on( 'route:search', function() { $( '.wp-filter-search' ).trigger( 'keyup' ); }); @@ -1502,7 +1507,7 @@ themes.Run = { } }; -// Extend the main Search view +// Extend the main Search view. themes.view.InstallerSearch = themes.view.Search.extend({ events: { @@ -1512,10 +1517,10 @@ themes.view.InstallerSearch = themes.view.Search.extend({ terms: '', - // Handles Ajax request for searching through themes in public repo + // Handles Ajax request for searching through themes in public repo. search: function( event ) { - // Tabbing or reverse tabbing into the search input shouldn't trigger a search + // Tabbing or reverse tabbing into the search input shouldn't trigger a search. if ( event.type === 'keyup' && ( event.which === 9 || event.which === 16 ) ) { return; } @@ -1543,19 +1548,23 @@ themes.view.InstallerSearch = themes.view.Search.extend({ request.search = value; - // Intercept an [author] search. - // - // If input value starts with `author:` send a request - // for `author` instead of a regular `search` + /* + * Intercept an [author] search. + * + * If input value starts with `author:` send a request + * for `author` instead of a regular `search`. + */ if ( value.substring( 0, 7 ) === 'author:' ) { request.search = ''; request.author = value.slice( 7 ); } - // Intercept a [tag] search. - // - // If input value starts with `tag:` send a request - // for `tag` instead of a regular `search` + /* + * Intercept a [tag] search. + * + * If input value starts with `tag:` send a request + * for `tag` instead of a regular `search`. + */ if ( value.substring( 0, 4 ) === 'tag:' ) { request.search = ''; request.tag = [ value.slice( 4 ) ]; @@ -1569,10 +1578,10 @@ themes.view.InstallerSearch = themes.view.Search.extend({ $( '.drawer-toggle' ).attr( 'aria-expanded', 'false' ); // Get the themes by sending Ajax POST request to api.wordpress.org/themes - // or searching the local cache + // or searching the local cache. this.collection.query( request ); - // Set route + // Set route. themes.router.navigate( themes.router.baseUrl( themes.router.searchPath + encodeURIComponent( value ) ), { replace: true } ); } }); @@ -1581,7 +1590,7 @@ themes.view.Installer = themes.view.Appearance.extend({ el: '#wpbody-content .wrap', - // Register events for sorting and filters in theme-navigation + // Register events for sorting and filters in theme-navigation. events: { 'click .filter-links li > a': 'onSort', 'click .theme-filter': 'onFilter', @@ -1594,7 +1603,7 @@ themes.view.Installer = themes.view.Appearance.extend({ 'keyup #wporg-username-input': 'saveUsername' }, - // Initial render method + // Initial render method. render: function() { var self = this; @@ -1606,7 +1615,7 @@ themes.view.Installer = themes.view.Appearance.extend({ // Bump `collection.currentQuery.page` and request more themes if we hit the end of the page. this.listenTo( this, 'theme:end', function() { - // Make sure we are not already loading + // Make sure we are not already loading. if ( self.collection.loadingThemes ) { return; } @@ -1639,29 +1648,29 @@ themes.view.Installer = themes.view.Appearance.extend({ this.view.remove(); } - // Set ups the view and passes the section argument + // Sets up the view and passes the section argument. this.view = new themes.view.Themes({ collection: this.collection, parent: this }); - // Reset pagination every time the install view handler is run + // Reset pagination every time the install view handler is run. this.page = 0; - // Render and append + // Render and append. this.$el.find( '.themes' ).remove(); this.view.render(); this.$el.find( '.theme-browser' ).append( this.view.el ).addClass( 'rendered' ); }, - // Handles all the rendering of the public theme directory + // Handles all the rendering of the public theme directory. browse: function( section ) { // Create a new collection with the proper theme data - // for each section + // for each section. this.collection.query( { browse: section } ); }, - // Sorting navigation + // Sorting navigation. onSort: function( event ) { var $el = $( event.target ), sort = $el.data( 'sort' ); @@ -1671,14 +1680,14 @@ themes.view.Installer = themes.view.Appearance.extend({ $( 'body' ).removeClass( 'filters-applied show-filters' ); $( '.drawer-toggle' ).attr( 'aria-expanded', 'false' ); - // Bail if this is already active + // Bail if this is already active. if ( $el.hasClass( this.activeClass ) ) { return; } this.sort( sort ); - // Trigger a router.naviagte update + // Trigger a router.navigate update. themes.router.navigate( themes.router.baseUrl( themes.router.browsePath + sort ) ); }, @@ -1705,13 +1714,13 @@ themes.view.Installer = themes.view.Appearance.extend({ this.browse( sort ); }, - // Filters and Tags + // Filters and Tags. onFilter: function( event ) { var request, $el = $( event.target ), filter = $el.data( 'filter' ); - // Bail if this is already active + // Bail if this is already active. if ( $el.hasClass( this.activeClass ) ) { return; } @@ -1728,21 +1737,21 @@ themes.view.Installer = themes.view.Appearance.extend({ } // Construct the filter request - // using the default values + // using the default values. filter = _.union( [ filter, this.filtersChecked() ] ); request = { tag: [ filter ] }; // Get the themes by sending Ajax POST request to api.wordpress.org/themes - // or searching the local cache + // or searching the local cache. this.collection.query( request ); }, - // Clicking on a checkbox to add another filter to the request + // Clicking on a checkbox to add another filter to the request. addFilter: function() { this.filtersChecked(); }, - // Applying filters triggers a tag request + // Applying filters triggers a tag request. applyFilters: function( event ) { var name, tags = this.filtersChecked(), @@ -1771,7 +1780,7 @@ themes.view.Installer = themes.view.Appearance.extend({ }); // Get the themes by sending Ajax POST request to api.wordpress.org/themes - // or searching the local cache + // or searching the local cache. this.collection.query( request ); }, @@ -1786,7 +1795,7 @@ themes.view.Installer = themes.view.Appearance.extend({ event.preventDefault(); } - // save username on enter + // Save username on enter. if ( event.type === 'keyup' && event.which !== 13 ) { return; } @@ -1798,14 +1807,17 @@ themes.view.Installer = themes.view.Appearance.extend({ }, success: function () { // Get the themes by sending Ajax POST request to api.wordpress.org/themes - // or searching the local cache + // or searching the local cache. that.collection.query( request ); } } ); }, - // Get the checked filters - // @return {array} of tags or false + /** + * Get the checked filters. + * + * @return {array} of tags or false + */ filtersChecked: function() { var items = $( '.filter-group' ).find( ':checkbox' ), tags = []; @@ -1814,7 +1826,7 @@ themes.view.Installer = themes.view.Appearance.extend({ tags.push( $( item ).prop( 'value' ) ); }); - // When no filters are checked, restore initial state and return + // When no filters are checked, restore initial state and return. if ( tags.length === 0 ) { $( '.filter-drawer .apply-filters' ).find( 'span' ).text( '' ); $( '.filter-drawer .clear-filters' ).hide(); @@ -1830,7 +1842,7 @@ themes.view.Installer = themes.view.Appearance.extend({ activeClass: 'current', - /* + /** * When users press the "Upload Theme" button, show the upload form in place. */ uploader: function() { @@ -1845,7 +1857,7 @@ themes.view.Installer = themes.view.Appearance.extend({ }); }, - // Toggle the full filters navigation + // Toggle the full filters navigation. moreFilters: function( event ) { var $body = $( 'body' ), $toggleButton = $( '.drawer-toggle' ); @@ -1865,8 +1877,11 @@ themes.view.Installer = themes.view.Appearance.extend({ $toggleButton.attr( 'aria-expanded', $body.hasClass( 'show-filters' ) ); }, - // Clears all the checked filters - // @uses filtersChecked() + /** + * Clears all the checked filters. + * + * @uses filtersChecked() + */ clearFilters: function( event ) { var items = $( '.filter-group' ).find( ':checkbox' ), self = this; @@ -1919,14 +1934,14 @@ themes.InstallerRouter = Backbone.Router.extend({ themes.RunInstaller = { init: function() { - // Set up the view - // Passes the default 'section' as an option + // Set up the view. + // Passes the default 'section' as an option. this.view = new themes.view.Installer({ section: 'featured', SearchView: themes.view.InstallerSearch }); - // Render results + // Render results. this.render(); // Start debouncing user searches after Backbone.history.start(). @@ -1935,7 +1950,7 @@ themes.RunInstaller = { render: function() { - // Render results + // Render results. this.view.render(); this.routes(); @@ -1954,11 +1969,11 @@ themes.RunInstaller = { request = {}; // Bind to our global `wp.themes` object - // so that the router is available to sub-views + // so that the router is available to sub-views. themes.router = new themes.InstallerRouter(); - // Handles `theme` route event - // Queries the API for the passed theme slug + // Handles `theme` route event. + // Queries the API for the passed theme slug. themes.router.on( 'route:preview', function( slug ) { // Remove existing handlers. @@ -1986,9 +2001,11 @@ themes.RunInstaller = { } }); - // Handles sorting / browsing routes - // Also handles the root URL triggering a sort request - // for `featured`, the default view + /* + * Handles sorting / browsing routes. + * Also handles the root URL triggering a sort request + * for `featured`, the default view. + */ themes.router.on( 'route:sort', function( sort ) { if ( ! sort ) { sort = 'featured'; @@ -2043,7 +2060,7 @@ $( document ).ready(function() { })( jQuery ); -// Align theme browser thickbox +// Align theme browser thickbox. jQuery(document).ready( function($) { window.tb_position = function() { var tbWindow = $('#TB_window'), diff --git a/src/js/_enqueues/wp/util.js b/src/js/_enqueues/wp/util.js index 836d0016f2..5bb0a6b3ae 100644 --- a/src/js/_enqueues/wp/util.js +++ b/src/js/_enqueues/wp/util.js @@ -41,11 +41,13 @@ window.wp = window.wp || {}; }; }); - // wp.ajax - // ------ - // - // Tools for sending ajax requests with JSON responses and built in error handling. - // Mirrors and wraps jQuery's ajax APIs. + /* + * wp.ajax + * ------ + * + * Tools for sending ajax requests with JSON responses and built in error handling. + * Mirrors and wraps jQuery's ajax APIs. + */ wp.ajax = { settings: settings.ajax || {}, @@ -105,7 +107,7 @@ window.wp = window.wp || {}; delete options.success; delete options.error; - // Use with PHP's wp_send_json_success() and wp_send_json_error() + // Use with PHP's wp_send_json_success() and wp_send_json_error(). deferred.jqXHR = $.ajax( options ).done( function( response ) { // Treat a response of 1 as successful for backward compatibility with existing handlers. if ( response === '1' || response === 1 ) { diff --git a/src/js/_enqueues/wp/utils/word-count.js b/src/js/_enqueues/wp/utils/word-count.js index 41a052b572..a0454512bd 100644 --- a/src/js/_enqueues/wp/utils/word-count.js +++ b/src/js/_enqueues/wp/utils/word-count.js @@ -3,7 +3,8 @@ * provided text string. * * @namespace wp.utils - * @since 2.6.0 + * + * @since 2.6.0 * @output wp-admin/js/word-count.js */ @@ -73,17 +74,17 @@ spaceRegExp: / | /gi, HTMLEntityRegExp: /&\S+?;/g, - // \u2014 = em-dash + // \u2014 = em-dash. connectorRegExp: /--|\u2014/g, // Characters to be removed from input text. removeRegExp: new RegExp( [ '[', - // Basic Latin (extract) + // Basic Latin (extract). '\u0021-\u0040\u005B-\u0060\u007B-\u007E', - // Latin-1 Supplement (extract) + // Latin-1 Supplement (extract). '\u0080-\u00BF\u00D7\u00F7', /* @@ -115,7 +116,7 @@ */ '\u2000-\u2BFF', - // Supplemental Punctuation + // Supplemental Punctuation. '\u2E00-\u2E7F', ']' ].join( '' ), 'g' ), @@ -143,7 +144,8 @@ /** * Counts the number of words (or other specified type) in the specified text. * - * @since 2.6.0 + * @since 2.6.0 + * * @memberof wp.utils.wordcounter * * @param {String} text Text to count elements in. diff --git a/src/js/media/controllers/collection-add.js b/src/js/media/controllers/collection-add.js index fedcb308b7..aab6bb03e3 100644 --- a/src/js/media/controllers/collection-add.js +++ b/src/js/media/controllers/collection-add.js @@ -15,8 +15,8 @@ var Selection = wp.media.model.Selection, * @augments Backbone.Model * * @param {object} [attributes] The attributes hash passed to the state. - * @param {string} [attributes.id=library] Unique identifier. - * @param {string} attributes.title Title for the state. Displays in the frame's title region. + * @param {string} [attributes.id=library] Unique identifier. + * @param {string} attributes.title Title for the state. Displays in the frame's title region. * @param {boolean} [attributes.multiple=add] Whether multi-select is enabled. @todo 'add' doesn't seem do anything special, and gets used as a boolean. * @param {wp.media.model.Attachments} [attributes.library] The attachments collection to browse. * If one is not supplied, a collection of attachments of the specified type will be created. @@ -34,8 +34,8 @@ var Selection = wp.media.model.Selection, * @param {int} [attributes.priority=100] The priority for the state link in the media menu. * @param {boolean} [attributes.syncSelection=false] Whether the Attachments selection should be persisted from the last state. * Defaults to false because for this state, because the library of the Edit Gallery state is the selection. - * @param {string} attributes.type The collection's media type. (e.g. 'video'). - * @param {string} attributes.collectionType The collection type. (e.g. 'playlist'). + * @param {string} attributes.type The collection's media type. (e.g. 'video'). + * @param {string} attributes.collectionType The collection type. (e.g. 'playlist'). */ CollectionAdd = Library.extend(/** @lends wp.media.controller.CollectionAdd.prototype */{ defaults: _.defaults( { @@ -87,9 +87,11 @@ CollectionAdd = Library.extend(/** @lends wp.media.controller.CollectionAdd.prot return !! this.mirroring.get( attachment.cid ) && ! edit.get( attachment.cid ) && Selection.prototype.validator.apply( this, arguments ); }; - // Reset the library to ensure that all attachments are re-added - // to the collection. Do so silently, as calling `observe` will - // trigger the `reset` event. + /* + * Reset the library to ensure that all attachments are re-added + * to the collection. Do so silently, as calling `observe` will + * trigger the `reset` event. + */ library.reset( library.mirroring.models, { silent: true }); library.observe( edit ); this.set('editLibrary', edit); diff --git a/src/js/media/controllers/embed.js b/src/js/media/controllers/embed.js index 2b271dcd0a..d6614ed24d 100644 --- a/src/js/media/controllers/embed.js +++ b/src/js/media/controllers/embed.js @@ -63,9 +63,11 @@ Embed = wp.media.controller.State.extend(/** @lends wp.media.controller.Embed.pr scanners: [] }; - // Scan is triggered with the list of `attributes` to set on the - // state, useful for the 'type' attribute and 'scanners' attribute, - // an array of promise objects for asynchronous scan operations. + /* + * Scan is triggered with the list of `attributes` to set on the + * state, useful for the 'type' attribute and 'scanners' attribute, + * an array of promise objects for asynchronous scan operations. + */ if ( this.props.get('url') ) { this.trigger( 'scan', attributes ); } diff --git a/src/js/media/controllers/state.js b/src/js/media/controllers/state.js index 666efe58f4..62e8c545ef 100644 --- a/src/js/media/controllers/state.js +++ b/src/js/media/controllers/state.js @@ -71,24 +71,24 @@ var State = Backbone.Model.extend(/** @lends wp.media.controller.State.prototype reset: function() {}, /** - * @access private * @since 3.5.0 + * @access private */ _ready: function() { this._updateMenu(); }, /** - * @access private * @since 3.5.0 + * @access private */ _preActivate: function() { this.active = true; }, /** - * @access private * @since 3.5.0 + * @access private */ _postActivate: function() { this.on( 'change:menu', this._menu, this ); @@ -106,8 +106,8 @@ var State = Backbone.Model.extend(/** @lends wp.media.controller.State.prototype }, /** - * @access private * @since 3.5.0 + * @access private */ _deactivate: function() { this.active = false; @@ -121,24 +121,24 @@ var State = Backbone.Model.extend(/** @lends wp.media.controller.State.prototype }, /** - * @access private * @since 3.5.0 + * @access private */ _title: function() { this.frame.title.render( this.get('titleMode') || 'default' ); }, /** - * @access private * @since 3.5.0 + * @access private */ _renderTitle: function( view ) { view.$el.text( this.get('title') || '' ); }, /** - * @access private * @since 3.5.0 + * @access private */ _router: function() { var router = this.frame.router, @@ -159,8 +159,8 @@ var State = Backbone.Model.extend(/** @lends wp.media.controller.State.prototype }, /** - * @access private * @since 3.5.0 + * @access private */ _menu: function() { var menu = this.frame.menu, @@ -181,8 +181,8 @@ var State = Backbone.Model.extend(/** @lends wp.media.controller.State.prototype }, /** - * @access private * @since 3.5.0 + * @access private */ _updateMenu: function() { var previous = this.previous('menu'), @@ -200,8 +200,8 @@ var State = Backbone.Model.extend(/** @lends wp.media.controller.State.prototype /** * Create a view in the media menu for the state. * - * @access private * @since 3.5.0 + * @access private * * @param {media.view.Menu} view The menu view. */ diff --git a/src/js/media/models/attachments.js b/src/js/media/models/attachments.js index ed46588189..ac967bda56 100644 --- a/src/js/media/models/attachments.js +++ b/src/js/media/models/attachments.js @@ -133,9 +133,8 @@ var Attachments = Backbone.Collection.extend(/** @lends wp.media.model.Attachmen return; } - // If no `Attachments` model is provided to source the searches - // from, then automatically generate a source from the existing - // models. + // If no `Attachments` model is provided to source the searches from, + // then automatically generate a source from the existing models. if ( ! this._source ) { this._source = new Attachments( this.models ); } @@ -326,10 +325,12 @@ var Attachments = Backbone.Collection.extend(/** @lends wp.media.model.Attachmen if ( ! mirroring || ! mirroring.more ) { return deferred.resolveWith( this ).promise(); } - // If we're mirroring another collection, forward `more` to - // the mirrored collection. Account for a race condition by - // checking if we're still mirroring that collection when - // the request resolves. + /* + * If we're mirroring another collection, forward `more` to + * the mirrored collection. Account for a race condition by + * checking if we're still mirroring that collection when + * the request resolves. + */ mirroring.more( options ).done( function() { if ( this === attachments.mirroring ) { deferred.resolveWith( this ); @@ -412,9 +413,11 @@ var Attachments = Backbone.Collection.extend(/** @lends wp.media.model.Attachmen return; } - // Removes any uploading attachments, updates each attachment's - // menu order, and returns an object with an { id: menuOrder } - // mapping to pass to the request. + /* + * Removes any uploading attachments, updates each attachment's + * menu order, and returns an object with an { id: menuOrder } + * mapping to pass to the request. + */ var attachments = this.chain().filter( function( attachment ) { return ! _.isUndefined( attachment.id ); }).map( function( attachment, index ) { diff --git a/src/js/media/models/post-image.js b/src/js/media/models/post-image.js index f1ff867e48..1642f42e2a 100644 --- a/src/js/media/models/post-image.js +++ b/src/js/media/models/post-image.js @@ -30,7 +30,7 @@ var PostImage = Backbone.Model.extend(/** @lends wp.media.model.PostImage.protot this.bindAttachmentListeners(); } - // keep url in sync with changes to the type of link + // Keep URL in sync with changes to the type of link. this.on( 'change:link', this.updateLinkUrl, this ); this.on( 'change:size', this.updateSize, this ); @@ -70,7 +70,7 @@ var PostImage = Backbone.Model.extend(/** @lends wp.media.model.PostImage.protot return; } - // default to custom if there is a linkUrl + // Default to custom if there is a linkUrl. type = 'custom'; if ( this.attachment ) { diff --git a/src/js/media/models/query.js b/src/js/media/models/query.js index 90e36e6cc7..a9d01c43a4 100644 --- a/src/js/media/models/query.js +++ b/src/js/media/models/query.js @@ -43,15 +43,19 @@ Query = Attachments.extend(/** @lends wp.media.model.Query.prototype */{ return true; } - // We want any items that can be placed before the last - // item in the set. If we add any items after the last - // item, then we can't guarantee the set is complete. + /* + * We want any items that can be placed before the last + * item in the set. If we add any items after the last + * item, then we can't guarantee the set is complete. + */ if ( this.length ) { return 1 !== this.comparator( attachment, this.last(), { ties: true }); - // Handle the case where there are no items yet and - // we're sorting for recent items. In that case, we want - // changes that occurred after we created the query. + /* + * Handle the case where there are no items yet and + * we're sorting for recent items. In that case, we want + * changes that occurred after we created the query. + */ } else if ( 'DESC' === order && ( 'date' === orderby || 'modified' === orderby ) ) { return attachment.get( orderby ) >= this.created; @@ -65,12 +69,14 @@ Query = Attachments.extend(/** @lends wp.media.model.Query.prototype */{ return false; }; - // Observe the central `wp.Uploader.queue` collection to watch for - // new matches for the query. - // - // Only observe when a limited number of query args are set. There - // are no filters for other properties, so observing will result in - // false positives in those queries. + /* + * Observe the central `wp.Uploader.queue` collection to watch for + * new matches for the query. + * + * Only observe when a limited number of query args are set. There + * are no filters for other properties, so observing will result in + * false positives in those queries. + */ allowed = [ 's', 'order', 'orderby', 'posts_per_page', 'post_mime_type', 'post_parent', 'author' ]; if ( wp.Uploader && _( this.args ).chain().keys().difference( allowed ).isEmpty().value() ) { this.observe( wp.Uploader.queue ); @@ -144,7 +150,7 @@ Query = Attachments.extend(/** @lends wp.media.model.Query.prototype */{ options.data.query = args; return wp.media.ajax( options ); - // Otherwise, fall back to Backbone.sync() + // Otherwise, fall back to `Backbone.sync()`. } else { /** * Call wp.media.model.Attachments.sync or Backbone.sync diff --git a/src/js/media/routers/manage.js b/src/js/media/routers/manage.js index d058078773..5e0cb21b3d 100644 --- a/src/js/media/routers/manage.js +++ b/src/js/media/routers/manage.js @@ -16,7 +16,7 @@ var Router = Backbone.Router.extend(/** @lends wp.media.view.MediaFrame.Manage.R 'upload.php': 'reset' }, - // Map routes against the page URL + // Map routes against the page URL. baseUrl: function( url ) { return 'upload.php' + url; }, @@ -29,19 +29,19 @@ var Router = Backbone.Router.extend(/** @lends wp.media.view.MediaFrame.Manage.R } }, - // Respond to the search route by filling the search field and trigggering the input event + // Respond to the search route by filling the search field and trigggering the input event. search: function( query ) { jQuery( '#media-search-input' ).val( query ).trigger( 'input' ); }, - // Show the modal with a specific item + // Show the modal with a specific item. showItem: function( query ) { var media = wp.media, frame = media.frames.browse, library = frame.state().get('library'), item; - // Trigger the media frame to open the correct item + // Trigger the media frame to open the correct item. item = library.findWhere( { id: parseInt( query, 10 ) } ); item.set( 'skipHistory', true ); diff --git a/src/js/media/utils/selection-sync.js b/src/js/media/utils/selection-sync.js index fd2a872e1d..73cbed002a 100644 --- a/src/js/media/utils/selection-sync.js +++ b/src/js/media/utils/selection-sync.js @@ -22,10 +22,12 @@ var selectionSync = { return; } - // If the selection supports multiple items, validate the stored - // attachments based on the new selection's conditions. Record - // the attachments that are not included; we'll maintain a - // reference to those. Other attachments are considered in flux. + /* + * If the selection supports multiple items, validate the stored + * attachments based on the new selection's conditions. Record + * the attachments that are not included; we'll maintain a + * reference to those. Other attachments are considered in flux. + */ if ( selection.multiple ) { selection.reset( [], { silent: true }); selection.validateAll( manager.attachments ); diff --git a/src/js/media/views/attachment.js b/src/js/media/views/attachment.js index 36ea814fe1..543c75adee 100644 --- a/src/js/media/views/attachment.js +++ b/src/js/media/views/attachment.js @@ -167,13 +167,13 @@ Attachment = View.extend(/** @lends wp.media.view.Attachment.prototype */{ return; } - // Catch arrow events + // Catch arrow events. if ( 37 === event.keyCode || 38 === event.keyCode || 39 === event.keyCode || 40 === event.keyCode ) { this.controller.trigger( 'attachment:keydown:arrow', event ); return; } - // Catch enter and space events + // Catch enter and space events. if ( 'keydown' === event.type && 13 !== event.keyCode && 32 !== event.keyCode ) { return; } @@ -183,7 +183,7 @@ Attachment = View.extend(/** @lends wp.media.view.Attachment.prototype */{ // In the grid view, bubble up an edit:attachment event to the controller. if ( this.controller.isModeActive( 'grid' ) ) { if ( this.controller.isModeActive( 'edit' ) ) { - // Pass the current target to restore focus when closing + // Pass the current target to restore focus when closing. this.controller.trigger( 'edit:attachment', this.model, event.currentTarget ); return; } @@ -255,7 +255,7 @@ Attachment = View.extend(/** @lends wp.media.view.Attachment.prototype */{ return; } - // Fixes bug that loses focus when selecting a featured image + // Fixes bug that loses focus when selecting a featured image. if ( ! method ) { method = 'add'; } @@ -265,14 +265,18 @@ Attachment = View.extend(/** @lends wp.media.view.Attachment.prototype */{ } if ( this.selected() ) { - // If the model is the single model, remove it. - // If it is not the same as the single model, - // it now becomes the single model. + /* + * If the model is the single model, remove it. + * If it is not the same as the single model, + * it now becomes the single model. + */ selection[ single === model ? 'remove' : 'single' ]( model ); } else { - // If the model is not selected, run the `method` on the - // selection. By default, we `reset` the selection, but the - // `method` can be set to `add` the model to the selection. + /* + * If the model is not selected, run the `method` on the + * selection. By default, we `reset` the selection, but the + * `method` can be set to `add` the model to the selection. + */ selection[ method ]( model ); selection.single( model ); } @@ -298,9 +302,11 @@ Attachment = View.extend(/** @lends wp.media.view.Attachment.prototype */{ var selection = this.options.selection, controller = this.controller; - // Check if a selection exists and if it's the collection provided. - // If they're not the same collection, bail; we're in another - // selection's event loop. + /* + * Check if a selection exists and if it's the collection provided. + * If they're not the same collection, bail; we're in another + * selection's event loop. + */ if ( ! selection || ( collection && collection !== selection ) ) { return; } @@ -324,9 +330,11 @@ Attachment = View.extend(/** @lends wp.media.view.Attachment.prototype */{ deselect: function( model, collection ) { var selection = this.options.selection; - // Check if a selection exists and if it's the collection provided. - // If they're not the same collection, bail; we're in another - // selection's event loop. + /* + * Check if a selection exists and if it's the collection provided. + * If they're not the same collection, bail; we're in another + * selection's event loop. + */ if ( ! selection || ( collection && collection !== selection ) ) { return; } @@ -478,7 +486,7 @@ Attachment = View.extend(/** @lends wp.media.view.Attachment.prototype */{ * @param {Object} event */ removeFromLibrary: function( event ) { - // Catch enter and space events + // Catch enter and space events. if ( 'keydown' === event.type && 13 !== event.keyCode && 32 !== event.keyCode ) { return; } @@ -565,10 +573,12 @@ _.each({ return this; } - // If the updated value is in sync with the value in the DOM, there - // is no need to re-render. If we're currently editing the value, - // it will automatically be in sync, suppressing the re-render for - // the view we're editing, while updating any others. + /* + * If the updated value is in sync with the value in the DOM, there + * is no need to re-render. If we're currently editing the value, + * it will automatically be in sync, suppressing the re-render for + * the view we're editing, while updating any others. + */ if ( value === $setting.find('input, textarea, select, [value]').val() ) { return this; } diff --git a/src/js/media/views/attachment/details.js b/src/js/media/views/attachment/details.js index 5f80220088..b406818683 100644 --- a/src/js/media/views/attachment/details.js +++ b/src/js/media/views/attachment/details.js @@ -146,10 +146,10 @@ Details = Attachment.extend(/** @lends wp.media.view.Attachment.Details.prototyp this.model.save().done( function() { library._requery( true ); /* - * @todo: We need to move focus back to the previous, next, or first - * attachment but the library gets re-queried and refreshed. Thus, - * the references to the previous attachments are lost. We need an - * alternate method. + * @todo We need to move focus back to the previous, next, or first + * attachment but the library gets re-queried and refreshed. + * Thus, the references to the previous attachments are lost. + * We need an alternate method. */ self.moveFocusToLastFallback(); } ); diff --git a/src/js/media/views/attachments.js b/src/js/media/views/attachments.js index c36f7f681b..cb81ea3072 100644 --- a/src/js/media/views/attachments.js +++ b/src/js/media/views/attachments.js @@ -131,11 +131,11 @@ Attachments = View.extend(/** @lends wp.media.view.Attachments.prototype */{ */ attachmentFocus: function() { /* - * @todo: when uploading new attachments, this tries to move focus to the - * attachmentz grid. Actually, a progress bar gets initially displayed + * @todo When uploading new attachments, this tries to move focus to + * the attachments grid. Actually, a progress bar gets initially displayed * and then updated when uploading completes, so focus is lost. - * Additionally: this view is used for both the attachments list and the - * list of selected attachments in the bottom media toolbar. Thus, when + * Additionally: this view is used for both the attachments list and + * the list of selected attachments in the bottom media toolbar. Thus, when * uploading attachments, it is called twice and returns two different `this`. * `this.columns` is truthy within the modal. */ @@ -257,8 +257,8 @@ Attachments = View.extend(/** @lends wp.media.view.Attachments.prototype */{ /** * Initializes jQuery sortable on the attachment list. * - * Fails gracefully if jQuery sortable doesn't exist or isn't passed in the - * options. + * Fails gracefully if jQuery sortable doesn't exist or isn't passed + * in the options. * * @since 3.5.0 * @@ -278,8 +278,8 @@ Attachments = View.extend(/** @lends wp.media.view.Attachments.prototype */{ disabled: !! collection.comparator, /* - * Change the position of the attachment as soon as the mouse pointer overlaps a - * thumbnail. + * Change the position of the attachment as soon as the mouse pointer + * overlaps a thumbnail. */ tolerance: 'pointer', @@ -321,8 +321,8 @@ Attachments = View.extend(/** @lends wp.media.view.Attachments.prototype */{ }, this.options.sortable ) ); /* - * If the `orderby` property is changed on the `collection`, check to see if we - * have a `comparator`. If so, disable sorting. + * If the `orderby` property is changed on the `collection`, + * check to see if we have a `comparator`. If so, disable sorting. */ collection.props.on( 'change:orderby', function() { this.$el.sortable( 'option', 'disabled', !! collection.comparator ); diff --git a/src/js/media/views/attachments/browser.js b/src/js/media/views/attachments/browser.js index a4a880f842..4a4289149d 100644 --- a/src/js/media/views/attachments/browser.js +++ b/src/js/media/views/attachments/browser.js @@ -194,9 +194,11 @@ AttachmentsBrowser = View.extend(/** @lends wp.media.view.AttachmentsBrowser.pro } } - // Feels odd to bring the global media library switcher into the Attachment - // browser view. Is this a use case for doAction( 'add:toolbar-items:attachments-browser', this.toolbar ); - // which the controller can tap into and add this view? + /* + * Feels odd to bring the global media library switcher into the Attachment browser view. + * Is this a use case for doAction( 'add:toolbar-items:attachments-browser', this.toolbar ); + * which the controller can tap into and add this view? + */ if ( this.controller.isModeActive( 'grid' ) ) { LibraryViewSwitcher = View.extend({ className: 'view-switch media-grid-view-switch', @@ -222,7 +224,7 @@ AttachmentsBrowser = View.extend(/** @lends wp.media.view.AttachmentsBrowser.pro priority: -75 }).render() ); - // BulkSelection is a <div> with subviews, including screen reader text + // BulkSelection is a <div> with subviews, including screen reader text. this.toolbar.set( 'selectModeToggleButton', new wp.media.view.SelectModeToggleButton({ text: l10n.bulkSelect, controller: this.controller, @@ -437,7 +439,7 @@ AttachmentsBrowser = View.extend(/** @lends wp.media.view.AttachmentsBrowser.pro AttachmentView: this.options.AttachmentView }); - // Add keydown listener to the instance of the Attachments view + // Add keydown listener to the instance of the Attachments view. this.controller.on( 'attachment:keydown:arrow', _.bind( this.attachments.arrowEvent, this.attachments ) ); this.controller.on( 'attachment:details:shift-tab', _.bind( this.attachments.restoreFocus, this.attachments ) ); @@ -516,7 +518,7 @@ AttachmentsBrowser = View.extend(/** @lends wp.media.view.AttachmentsBrowser.pro }) ); } - // Show the sidebar on mobile + // Show the sidebar on mobile. if ( this.model.id === 'insert' ) { sidebar.$el.addClass( 'visible' ); } @@ -527,7 +529,7 @@ AttachmentsBrowser = View.extend(/** @lends wp.media.view.AttachmentsBrowser.pro sidebar.unset('details'); sidebar.unset('compat'); sidebar.unset('display'); - // Hide the sidebar on mobile + // Hide the sidebar on mobile. sidebar.$el.removeClass( 'visible' ); } }); diff --git a/src/js/media/views/button/select-mode-toggle.js b/src/js/media/views/button/select-mode-toggle.js index dbe662653e..2c2335bcd5 100644 --- a/src/js/media/views/button/select-mode-toggle.js +++ b/src/js/media/views/button/select-mode-toggle.js @@ -49,7 +49,7 @@ SelectModeToggle = Button.extend(/** @lends wp.media.view.SelectModeToggle.proto children = toolbar.$( '.media-toolbar-secondary > *, .media-toolbar-primary > *' ); - // TODO: the Frame should be doing all of this. + // @todo The Frame should be doing all of this. if ( this.controller.isModeActive( 'select' ) ) { this.model.set( { size: 'large', diff --git a/src/js/media/views/embed/link.js b/src/js/media/views/embed/link.js index ade3ae8ce5..f42d494558 100644 --- a/src/js/media/views/embed/link.js +++ b/src/js/media/views/embed/link.js @@ -23,11 +23,11 @@ EmbedLink = wp.media.view.Settings.extend(/** @lends wp.media.view.EmbedLink.pro updateoEmbed: _.debounce( function() { var url = this.model.get( 'url' ); - // clear out previous results + // Clear out previous results. this.$('.embed-container').hide().find('.embed-preview').empty(); this.$( '.setting' ).hide(); - // only proceed with embed if the field contains more than 11 characters + // Only proceed with embed if the field contains more than 11 characters. // Example: http://a.io is 11 chars if ( url && ( url.length < 11 || ! url.match(/^http(s)?:\/\//) ) ) { return; @@ -39,7 +39,7 @@ EmbedLink = wp.media.view.Settings.extend(/** @lends wp.media.view.EmbedLink.pro fetch: function() { var url = this.model.get( 'url' ), re, youTubeEmbedMatch; - // check if they haven't typed in 500 ms + // Check if they haven't typed in 500 ms. if ( $('#embed-url-field').val() !== url ) { return; } diff --git a/src/js/media/views/focus-manager.js b/src/js/media/views/focus-manager.js index ba2db72511..414b7a5418 100644 --- a/src/js/media/views/focus-manager.js +++ b/src/js/media/views/focus-manager.js @@ -91,7 +91,7 @@ var FocusManager = wp.media.View.extend(/** @lends wp.media.view.FocusManager.pr tabbables = this.getTabbables(); - // Keep tab focus within media modal while it's open + // Keep tab focus within media modal while it's open. if ( tabbables.last()[0] === event.target && ! event.shiftKey ) { tabbables.first().focus(); return false; diff --git a/src/js/media/views/frame/edit-attachments.js b/src/js/media/views/frame/edit-attachments.js index 249329f396..a2e1749dc1 100644 --- a/src/js/media/views/frame/edit-attachments.js +++ b/src/js/media/views/frame/edit-attachments.js @@ -255,11 +255,11 @@ EditAttachments = MediaFrame.extend(/** @lends wp.media.view.MediaFrame.EditAtta return; } - // The right arrow key + // The right arrow key. if ( 39 === event.keyCode ) { this.nextMediaItem(); } - // The left arrow key + // The left arrow key. if ( 37 === event.keyCode ) { this.previousMediaItem(); } diff --git a/src/js/media/views/frame/image-details.js b/src/js/media/views/frame/image-details.js index a270df8875..7ad1ecbe30 100644 --- a/src/js/media/views/frame/image-details.js +++ b/src/js/media/views/frame/image-details.js @@ -43,7 +43,7 @@ ImageDetails = Select.extend(/** @lends wp.media.view.MediaFrame.ImageDetails.pr this.on( 'content:create:image-details', this.imageDetailsContent, this ); this.on( 'content:render:edit-image', this.editImageContent, this ); this.on( 'toolbar:render:image-details', this.renderImageDetailsToolbar, this ); - // override the select toolbar + // Override the select toolbar. this.on( 'toolbar:render:replace', this.renderReplaceImageToolbar, this ); }, @@ -91,7 +91,7 @@ ImageDetails = Select.extend(/** @lends wp.media.view.MediaFrame.ImageDetails.pr this.content.set( view ); - // after bringing in the frame, load the actual editor via an ajax call + // After bringing in the frame, load the actual editor via an Ajax call. view.loadEditor(); }, @@ -111,8 +111,8 @@ ImageDetails = Select.extend(/** @lends wp.media.view.MediaFrame.ImageDetails.pr controller.close(); - // not sure if we want to use wp.media.string.image which will create a shortcode or - // perhaps wp.html.string to at least to build the <img /> + // Not sure if we want to use wp.media.string.image which will create a shortcode or + // perhaps wp.html.string to at least to build the <img />. state.trigger( 'update', controller.image.toJSON() ); // Restore and reset the default state. @@ -160,8 +160,8 @@ ImageDetails = Select.extend(/** @lends wp.media.view.MediaFrame.ImageDetails.pr controller.image.changeAttachment( attachment, state.display( attachment ) ); - // not sure if we want to use wp.media.string.image which will create a shortcode or - // perhaps wp.html.string to at least to build the <img /> + // Not sure if we want to use wp.media.string.image which will create a shortcode or + // perhaps wp.html.string to at least to build the <img />. state.trigger( 'replace', controller.image.toJSON() ); // Restore and reset the default state. diff --git a/src/js/media/views/frame/manage.js b/src/js/media/views/frame/manage.js index 4c244120a2..bed774a2e2 100644 --- a/src/js/media/views/frame/manage.js +++ b/src/js/media/views/frame/manage.js @@ -102,7 +102,7 @@ Manage = MediaFrame.extend(/** @lends wp.media.view.MediaFrame.Manage.prototype } }, 1000 ); - // Update the URL when entering search string (at most once per second) + // Update the URL when entering search string (at most once per second). search.on( 'input', _.bind( input, this ) ); this.gridRouter @@ -183,7 +183,7 @@ Manage = MediaFrame.extend(/** @lends wp.media.view.MediaFrame.Manage.prototype $browser = this.$('.attachments-browser'); $toolbar = $browser.find('.media-toolbar'); - // Offset doesn't appear to take top margin into account, hence +16 + // Offset doesn't appear to take top margin into account, hence +16. if ( ( $browser.offset().top + 16 ) < this.$window.scrollTop() + this.$adminBar.height() ) { $browser.addClass( 'fixed' ); $toolbar.css('width', $browser.width() + 'px'); @@ -271,7 +271,7 @@ Manage = MediaFrame.extend(/** @lends wp.media.view.MediaFrame.Manage.prototype }, startHistory: function() { - // Verify pushState support and activate + // Verify pushState support and activate. if ( window.history && window.history.pushState ) { if ( Backbone.History.started ) { Backbone.history.stop(); diff --git a/src/js/media/views/frame/post.js b/src/js/media/views/frame/post.js index dbf550d0ec..064c024cf4 100644 --- a/src/js/media/views/frame/post.js +++ b/src/js/media/views/frame/post.js @@ -180,7 +180,7 @@ Post = Select.extend(/** @lends wp.media.view.MediaFrame.Post.prototype */{ this.on( 'activate', this.activate, this ); - // Only bother checking media type counts if one of the counts is zero + // Only bother checking media type counts if one of the counts is zero. checkCounts = _.find( this.counts, function( type ) { return type.count === 0; } ); @@ -235,7 +235,7 @@ Post = Select.extend(/** @lends wp.media.view.MediaFrame.Post.prototype */{ }, activate: function() { - // Hide menu items for states tied to particular media types if there are no items + // Hide menu items for states tied to particular media types if there are no items. _.each( this.counts, function( type ) { if ( type.count < 1 ) { this.menuItemVisibility( type.state, 'hide' ); @@ -250,7 +250,7 @@ Post = Select.extend(/** @lends wp.media.view.MediaFrame.Post.prototype */{ } }, - // Menus + // Menus. /** * @param {wp.Backbone.View} view */ @@ -358,7 +358,7 @@ Post = Select.extend(/** @lends wp.media.view.MediaFrame.Post.prototype */{ }); }, - // Content + // Content. embedContent: function() { var view = new wp.media.view.Embed({ controller: this, @@ -400,7 +400,7 @@ Post = Select.extend(/** @lends wp.media.view.MediaFrame.Post.prototype */{ // Browse our library of attachments. this.content.set( view ); - // Trigger the controller to set focus + // Trigger the controller to set focus. this.trigger( 'edit:selection', this ); }, @@ -410,12 +410,12 @@ Post = Select.extend(/** @lends wp.media.view.MediaFrame.Post.prototype */{ this.content.set( view ); - // after creating the wrapper view, load the actual editor via an ajax call + // After creating the wrapper view, load the actual editor via an Ajax call. view.loadEditor(); }, - // Toolbars + // Toolbars. /** * @param {wp.Backbone.View} view diff --git a/src/js/media/views/frame/select.js b/src/js/media/views/frame/select.js index acb58906c9..3f3c0642ee 100644 --- a/src/js/media/views/frame/select.js +++ b/src/js/media/views/frame/select.js @@ -64,7 +64,7 @@ Select = MediaFrame.extend(/** @lends wp.media.view.MediaFrame.Select.prototype this.content.set( view ); - // after creating the wrapper view, load the actual editor via an ajax call + // After creating the wrapper view, load the actual editor via an Ajax call. view.loadEditor(); }, diff --git a/src/js/media/views/image-details.js b/src/js/media/views/image-details.js index cbd62e306d..db3597a4f9 100644 --- a/src/js/media/views/image-details.js +++ b/src/js/media/views/image-details.js @@ -27,7 +27,7 @@ ImageDetails = AttachmentDisplay.extend(/** @lends wp.media.view.ImageDetails.pr 'keyup [data-setting="customHeight"]': 'onCustomSize' } ), initialize: function() { - // used in AttachmentDisplay.prototype.updateLinkTo + // Used in AttachmentDisplay.prototype.updateLinkTo. this.options.attachment = this.model.attachment; this.listenTo( this.model, 'change:url', this.updateUrl ); this.listenTo( this.model, 'change:link', this.toggleLinkSettings ); @@ -109,7 +109,7 @@ ImageDetails = AttachmentDisplay.extend(/** @lends wp.media.view.ImageDetails.pr num = $( event.target ).val(), value; - // Ignore bogus input + // Ignore bogus input. if ( ! /^\d+/.test( num ) || parseInt( num, 10 ) < 1 ) { event.preventDefault(); return; diff --git a/src/js/media/views/menu-item.js b/src/js/media/views/menu-item.js index b492b4eae3..6acb5c361b 100644 --- a/src/js/media/views/menu-item.js +++ b/src/js/media/views/menu-item.js @@ -42,7 +42,7 @@ MenuItem = wp.media.View.extend(/** @lends wp.media.view.MenuItem.prototype */{ if ( state ) { this.controller.setState( state ); // Toggle the menu visibility in the responsive view. - this.views.parent.$el.removeClass( 'visible' ); // TODO: or hide on any click, see below + this.views.parent.$el.removeClass( 'visible' ); // @todo Or hide on any click, see below. } }, diff --git a/src/js/media/views/modal.js b/src/js/media/views/modal.js index 7927c0777b..d06bf9b599 100644 --- a/src/js/media/views/modal.js +++ b/src/js/media/views/modal.js @@ -102,7 +102,7 @@ Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ $el.show(); - // Try to close the onscreen keyboard + // Try to close the onscreen keyboard. if ( 'ontouchend' in document ) { if ( ( mceEditor = window.tinymce && window.tinymce.activeEditor ) && ! mceEditor.isHidden() && mceEditor.iframeElement ) { mceEditor.iframeElement.focus(); @@ -135,7 +135,7 @@ Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ // Enable page scrolling. $( 'body' ).removeClass( 'modal-open' ); - // Hide modal and remove restricted media modal tab focus once it's closed + // Hide modal and remove restricted media modal tab focus once it's closed. this.$el.hide().undelegate( 'keydown' ); /* diff --git a/src/js/media/views/toolbar.js b/src/js/media/views/toolbar.js index 4cd6ee2d8f..1beb428fe6 100644 --- a/src/js/media/views/toolbar.js +++ b/src/js/media/views/toolbar.js @@ -142,7 +142,7 @@ Toolbar = View.extend(/** @lends wp.media.view.Toolbar.prototype */{ var requires = button.options.requires, disabled = false; - // Prevent insertion of attachments if any of them are still uploading + // Prevent insertion of attachments if any of them are still uploading. if ( selection && selection.models ) { disabled = _.some( selection.models, function( attachment ) { return attachment.get('uploading') === true; diff --git a/src/js/media/views/uploader/inline.js b/src/js/media/views/uploader/inline.js index 4cb80e1e0e..bd2cff0dcc 100644 --- a/src/js/media/views/uploader/inline.js +++ b/src/js/media/views/uploader/inline.js @@ -70,9 +70,11 @@ UploaderInline = View.extend(/** @lends wp.media.view.UploaderInline.prototype * return View.prototype.dispose.apply( this, arguments ); } - // Run remove on `dispose`, so we can be sure to refresh the - // uploader with a view-less DOM. Track whether we're disposing - // so we don't trigger an infinite loop. + /* + * Run remove on `dispose`, so we can be sure to refresh the + * uploader with a view-less DOM. Track whether we're disposing + * so we don't trigger an infinite loop. + */ this.disposing = true; return this.remove(); }, diff --git a/src/js/media/views/view.js b/src/js/media/views/view.js index 19b16e5c8f..e8a4b3621a 100644 --- a/src/js/media/views/view.js +++ b/src/js/media/views/view.js @@ -31,9 +31,11 @@ var View = wp.Backbone.View.extend(/** @lends wp.media.View.prototype */{ * @return {wp.media.View} Returns itself to allow chaining. */ dispose: function() { - // Undelegating events, removing events from the model, and - // removing events from the controller mirror the code for - // `Backbone.View.dispose` in Backbone 0.9.8 development. + /* + * Undelegating events, removing events from the model, and + * removing events from the controller mirror the code for + * `Backbone.View.dispose` in Backbone 0.9.8 development. + */ this.undelegateEvents(); if ( this.model && this.model.off ) { |