From 8347d7e22f98520228309392757ea75fd7bca4db Mon Sep 17 00:00:00 2001 From: Omar Reiss Date: Sun, 19 Aug 2018 13:32:27 +0000 Subject: [PATCH] General: Explicitly assigns all JS globals to the window. Many variables in the JavaScript were defined in the global scope without being explicitly assigned to the window. When built with Webpack, the code gets encapsulated in anonymous functions and those implicit globals get assigned to the wrong scope. This patch prevents that from happening. Fixes #44371. See #43731. git-svn-id: https://develop.svn.wordpress.org/trunk@43577 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/_enqueues/admin/common.js | 12 ++--- src/js/_enqueues/admin/edit-comments.js | 10 ++--- src/js/_enqueues/admin/inline-edit-post.js | 5 +-- src/js/_enqueues/admin/inline-edit-tax.js | 6 +-- src/js/_enqueues/admin/media-upload.js | 11 ++--- src/js/_enqueues/admin/media.js | 6 +-- src/js/_enqueues/admin/plugin-install.js | 6 +-- src/js/_enqueues/admin/post.js | 16 +++---- src/js/_enqueues/admin/postbox.js | 26 +++++------ src/js/_enqueues/admin/set-post-thumbnail.js | 4 +- src/js/_enqueues/admin/tags-box.js | 8 ++-- src/js/_enqueues/admin/widgets.js | 6 +-- src/js/_enqueues/lib/ajax-response.js | 4 +- src/js/_enqueues/lib/comment-reply.js | 3 +- src/js/_enqueues/lib/cookies.js | 20 ++++----- src/js/_enqueues/lib/gallery.js | 12 ++--- src/js/_enqueues/lib/link.js | 4 +- src/js/_enqueues/lib/nav-menu.js | 16 +++---- src/js/_enqueues/lib/quicktags.js | 44 +++++++++---------- src/js/_enqueues/wp/dashboard.js | 12 ++--- .../_enqueues/wp/password-strength-meter.js | 3 +- src/js/_enqueues/wp/theme.js | 5 +-- 22 files changed, 111 insertions(+), 128 deletions(-) diff --git a/src/js/_enqueues/admin/common.js b/src/js/_enqueues/admin/common.js index 26abce8c95..00efd8573a 100644 --- a/src/js/_enqueues/admin/common.js +++ b/src/js/_enqueues/admin/common.js @@ -3,7 +3,7 @@ */ /* global setUserSetting, ajaxurl, commonL10n, alert, confirm, pagenow */ -var showNotice, adminMenu, columns, validateForm, screenMeta; +/* global columns, screenMeta */ /** * Adds common WordPress functionality to the window. @@ -23,7 +23,7 @@ var showNotice, adminMenu, columns, validateForm, screenMeta; * @since 2.7.0 * @deprecated 3.3.0 */ -adminMenu = { +window.adminMenu = { init : function() {}, fold : function() {}, restoreMenuState : function() {}, @@ -32,7 +32,7 @@ adminMenu = { }; // Show/hide/save table columns. -columns = { +window.columns = { /** * Initializes the column toggles in the screen options. @@ -158,7 +158,7 @@ $document.ready(function(){columns.init();}); * * @returns {boolean} Returns true if all required fields are not an empty string. */ -validateForm = function( form ) { +window.validateForm = function( form ) { return !$( form ) .find( '.form-required' ) .filter( function() { return $( ':input:visible', this ).val() === ''; } ) @@ -178,7 +178,7 @@ validateForm = function( form ) { * * @returns {void} */ -showNotice = { +window.showNotice = { /** * Shows a delete confirmation pop-up message. @@ -219,7 +219,7 @@ showNotice = { * * @returns {void} */ -screenMeta = { +window.screenMeta = { element: null, // #screen-meta toggles: null, // .screen-meta-toggle page: null, // #wpcontent diff --git a/src/js/_enqueues/admin/edit-comments.js b/src/js/_enqueues/admin/edit-comments.js index c928ceb880..626a6b6e35 100644 --- a/src/js/_enqueues/admin/edit-comments.js +++ b/src/js/_enqueues/admin/edit-comments.js @@ -3,7 +3,7 @@ */ /* global adminCommentsL10n, thousandsSeparator, list_args, QTags, ajaxurl, wpAjax */ -var setCommentsList, theList, theExtraList, commentReply; +/* global commentReply, theExtraList, theList, setCommentsList */ (function($) { var getCount, updateCount, updateCountText, updatePending, updateApproved, @@ -188,7 +188,7 @@ var getCount, updateCount, updateCountText, updatePending, updateApproved, }); }; -setCommentsList = function() { +window.setCommentsList = function() { var totalInput, perPageInput, pageInput, dimAfter, delBefore, updateTotalCount, delAfter, refillTheExtraList, diff, lastConfidentTime = 0; @@ -564,8 +564,8 @@ setCommentsList = function() { }); }; - theExtraList = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } ); - theList = $('#the-comment-list').wpList( { alt: '', delBefore: delBefore, dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } ) + window.theExtraList = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } ); + window.theList = $('#the-comment-list').wpList( { alt: '', delBefore: delBefore, dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } ) .bind('wpListDelEnd', function(e, s){ var wpListsData = $(s.target).attr('data-wp-lists'), id = s.element.replace(/[^0-9]+/g, ''); @@ -574,7 +574,7 @@ setCommentsList = function() { }); }; -commentReply = { +window.commentReply = { cid : '', act : '', originalContent : '', diff --git a/src/js/_enqueues/admin/inline-edit-post.js b/src/js/_enqueues/admin/inline-edit-post.js index 8bc7d37d7e..cdca55dd89 100644 --- a/src/js/_enqueues/admin/inline-edit-post.js +++ b/src/js/_enqueues/admin/inline-edit-post.js @@ -5,7 +5,7 @@ * @output wp-admin/js/inline-edit-post.js */ -/* global inlineEditL10n, ajaxurl, typenow */ +/* global inlineEditL10n, ajaxurl, typenow, inlineEditPost */ window.wp = window.wp || {}; @@ -22,10 +22,9 @@ window.wp = window.wp || {}; * @property {string} what The prefix before the post id. * */ -var inlineEditPost; ( function( $, wp ) { - inlineEditPost = { + window.inlineEditPost = { /** * Initializes the inline and bulk post editor. diff --git a/src/js/_enqueues/admin/inline-edit-tax.js b/src/js/_enqueues/admin/inline-edit-tax.js index d589135578..bea01963bb 100644 --- a/src/js/_enqueues/admin/inline-edit-tax.js +++ b/src/js/_enqueues/admin/inline-edit-tax.js @@ -4,7 +4,7 @@ * @output wp-admin/js/inline-edit-tax.js */ -/* global inlineEditL10n, ajaxurl */ +/* global inlineEditL10n, ajaxurl, inlineEditTax */ window.wp = window.wp || {}; @@ -17,11 +17,9 @@ window.wp = window.wp || {}; * @property {string} what The type property with a hash prefixed and a dash * suffixed. */ -var inlineEditTax; - ( function( $, wp ) { -inlineEditTax = { +window.inlineEditTax = { /** * Initializes the inline taxonomy editor by adding event handlers to be able to diff --git a/src/js/_enqueues/admin/media-upload.js b/src/js/_enqueues/admin/media-upload.js index 136b0e4b22..9055cf9ca4 100644 --- a/src/js/_enqueues/admin/media-upload.js +++ b/src/js/_enqueues/admin/media-upload.js @@ -12,9 +12,7 @@ * @requires jQuery */ -/* global tinymce, QTags */ - -var wpActiveEditor, send_to_editor; +/* global tinymce, QTags, wpActiveEditor, tb_position */ /** * Sends the HTML passed in the parameters to TinyMCE. @@ -28,7 +26,7 @@ var wpActiveEditor, send_to_editor; * are unavailable. This means that the HTML was not * sent to the editor. */ -send_to_editor = function( html ) { +window.send_to_editor = function( html ) { var editor, hasTinymce = typeof tinymce !== 'undefined', hasQuicktags = typeof QTags !== 'undefined'; @@ -37,7 +35,7 @@ send_to_editor = function( html ) { if ( ! wpActiveEditor ) { if ( hasTinymce && tinymce.activeEditor ) { editor = tinymce.activeEditor; - wpActiveEditor = editor.id; + window.wpActiveEditor = editor.id; } else if ( ! hasQuicktags ) { return false; } @@ -64,7 +62,6 @@ send_to_editor = function( html ) { } }; -var tb_position; (function($) { /** * Recalculates and applies the new ThickBox position based on the current @@ -77,7 +74,7 @@ var tb_position; * @returns {Object[]} Array containing jQuery objects for all the found * ThickBox anchors. */ - tb_position = function() { + window.tb_position = function() { var tbWindow = $('#TB_window'), width = $(window).width(), H = $(window).height(), diff --git a/src/js/_enqueues/admin/media.js b/src/js/_enqueues/admin/media.js index 68a9b75c48..4d9a5ec46b 100644 --- a/src/js/_enqueues/admin/media.js +++ b/src/js/_enqueues/admin/media.js @@ -10,12 +10,10 @@ * @requires jQuery */ -/* global ajaxurl, attachMediaBoxL10n, _wpMediaGridSettings, showNotice */ - -var findPosts; +/* global ajaxurl, attachMediaBoxL10n, _wpMediaGridSettings, showNotice, findPosts */ ( function( $ ){ - findPosts = { + window.findPosts = { /** * Opens a dialog to attach media to a post. * diff --git a/src/js/_enqueues/admin/plugin-install.js b/src/js/_enqueues/admin/plugin-install.js index 1a2cf17623..b6cd1d74e4 100644 --- a/src/js/_enqueues/admin/plugin-install.js +++ b/src/js/_enqueues/admin/plugin-install.js @@ -4,8 +4,8 @@ * @output wp-admin/js/plugin-install.js */ -/* global plugininstallL10n, tb_click, tb_remove */ -var tb_position; +/* global plugininstallL10n, tb_click, tb_remove, tb_position */ + jQuery( document ).ready( function( $ ) { var tbWindow, @@ -18,7 +18,7 @@ jQuery( document ).ready( function( $ ) { $wrap = $ ( '.wrap' ), $body = $( document.body ); - tb_position = function() { + window.tb_position = function() { var width = $( window ).width(), H = $( window ).height() - ( ( 792 < width ) ? 60 : 20 ), W = ( 792 < width ) ? 772 : width - 20; diff --git a/src/js/_enqueues/admin/post.js b/src/js/_enqueues/admin/post.js index 18f69079a7..534915dadd 100644 --- a/src/js/_enqueues/admin/post.js +++ b/src/js/_enqueues/admin/post.js @@ -5,11 +5,11 @@ */ /* global postL10n, ajaxurl, wpAjax, setPostThumbnailL10n, postboxes, pagenow, tinymce, alert, deleteUserSetting */ - /* global theList:true, theExtraList:true, getUserSetting, setUserSetting, commentReply */ + /* global theList:true, theExtraList:true, getUserSetting, setUserSetting, commentReply, commentsBox */ + /* global WPSetThumbnailHTML, wptitlehint */ -var commentsBox, WPSetThumbnailHTML, WPSetThumbnailID, WPRemoveThumbnail, wptitlehint, makeSlugeditClickable, editPermalink; // Backwards compatibility: prevent fatal errors. -makeSlugeditClickable = editPermalink = function(){}; +window.makeSlugeditClickable = window.editPermalink = function(){}; // Make sure the wp object exists. window.wp = window.wp || {}; @@ -24,7 +24,7 @@ window.wp = window.wp || {}; * * @namespace commentsBox */ - commentsBox = { + window.commentsBox = { // Comment offset to use when fetching new comments. st : 0, @@ -108,7 +108,7 @@ window.wp = window.wp || {}; * * @global */ - WPSetThumbnailHTML = function(html){ + window.WPSetThumbnailHTML = function(html){ $('.inside', '#postimagediv').html(html); }; @@ -119,7 +119,7 @@ window.wp = window.wp || {}; * * @global */ - WPSetThumbnailID = function(id){ + window.WPSetThumbnailID = function(id){ var field = $('input[value="_thumbnail_id"]', '#list-table'); if ( field.length > 0 ) { $('#meta\\[' + field.attr('id').match(/[0-9]+/) + '\\]\\[value\\]').text(id); @@ -133,7 +133,7 @@ window.wp = window.wp || {}; * * @global */ - WPRemoveThumbnail = function(nonce){ + window.WPRemoveThumbnail = function(nonce){ $.post(ajaxurl, { action: 'set-post-thumbnail', post_id: $( '#post_ID' ).val(), thumbnail_id: -1, _ajax_nonce: nonce, cookie: encodeURIComponent( document.cookie ) }, @@ -1048,7 +1048,7 @@ jQuery(document).ready( function($) { * * @returns void */ - wptitlehint = function(id) { + window.wptitlehint = function(id) { id = id || 'title'; var title = $('#' + id), titleprompt = $('#' + id + '-prompt-text'); diff --git a/src/js/_enqueues/admin/postbox.js b/src/js/_enqueues/admin/postbox.js index 265da9fd80..88facb1aee 100644 --- a/src/js/_enqueues/admin/postbox.js +++ b/src/js/_enqueues/admin/postbox.js @@ -7,24 +7,22 @@ * @output wp-admin/js/postbox.js */ -/* global ajaxurl, postBoxL10n */ - -/** - * This object contains all function to handle the behaviour of the post boxes. The post boxes are the boxes you see - * around the content on the edit page. - * - * @since 2.7.0 - * - * @namespace postboxes - * - * @type {Object} - */ -var postboxes; +/* global ajaxurl, postBoxL10n, postboxes */ (function($) { var $document = $( document ); - postboxes = { + /** + * This object contains all function to handle the behaviour of the post boxes. The post boxes are the boxes you see + * around the content on the edit page. + * + * @since 2.7.0 + * + * @namespace postboxes + * + * @type {Object} + */ + window.postboxes = { /** * Handles a click on either the postbox heading or the postbox open/close icon. diff --git a/src/js/_enqueues/admin/set-post-thumbnail.js b/src/js/_enqueues/admin/set-post-thumbnail.js index 9df25db92f..0f3849af34 100644 --- a/src/js/_enqueues/admin/set-post-thumbnail.js +++ b/src/js/_enqueues/admin/set-post-thumbnail.js @@ -5,7 +5,7 @@ /* global setPostThumbnailL10n, ajaxurl, post_id, alert */ /* exported WPSetAsThumbnail */ -function WPSetAsThumbnail( id, nonce ) { +window.WPSetAsThumbnail = function( id, nonce ) { var $link = jQuery('a#wp-post-thumbnail-' + id); $link.text( setPostThumbnailL10n.saving ); @@ -25,4 +25,4 @@ function WPSetAsThumbnail( id, nonce ) { } } ); -} +}; diff --git a/src/js/_enqueues/admin/tags-box.js b/src/js/_enqueues/admin/tags-box.js index 49c82fb7f9..d47cbed8a5 100644 --- a/src/js/_enqueues/admin/tags-box.js +++ b/src/js/_enqueues/admin/tags-box.js @@ -3,9 +3,7 @@ */ /* jshint curly: false, eqeqeq: false */ -/* global ajaxurl */ - -var tagBox, array_unique_noempty; +/* global ajaxurl, tagBox, array_unique_noempty */ ( function( $ ) { var tagDelimiter = ( window.tagsSuggestL10n && window.tagsSuggestL10n.tagDelimiter ) || ','; @@ -24,7 +22,7 @@ var tagBox, array_unique_noempty; * * @return {Array} A new array containing only the unique items. */ - array_unique_noempty = function( array ) { + window.array_unique_noempty = function( array ) { var out = []; // Trim the values and ensure they are unique. @@ -49,7 +47,7 @@ var tagBox, array_unique_noempty; * * @global */ - tagBox = { + window.tagBox = { /** * Cleans up tags by removing redundant characters. * diff --git a/src/js/_enqueues/admin/widgets.js b/src/js/_enqueues/admin/widgets.js index 227890f90a..00ae62dbae 100644 --- a/src/js/_enqueues/admin/widgets.js +++ b/src/js/_enqueues/admin/widgets.js @@ -2,12 +2,12 @@ * @output wp-admin/js/widgets.js */ -/* global ajaxurl, isRtl */ -var wpWidgets; +/* global ajaxurl, isRtl, wpWidgets */ + (function($) { var $document = $( document ); -wpWidgets = { +window.wpWidgets = { /** * A closed Sidebar that gets a Widget dragged over it. * diff --git a/src/js/_enqueues/lib/ajax-response.js b/src/js/_enqueues/lib/ajax-response.js index 717c1b3014..fd71ff3702 100644 --- a/src/js/_enqueues/lib/ajax-response.js +++ b/src/js/_enqueues/lib/ajax-response.js @@ -2,7 +2,9 @@ * @output wp-includes/js/wp-ajax-response.js */ -var wpAjax = jQuery.extend( { + /* global wpAjax */ + +window.wpAjax = jQuery.extend( { unserialize: function( s ) { var r = {}, q, pp, i, p; if ( !s ) { return r; } diff --git a/src/js/_enqueues/lib/comment-reply.js b/src/js/_enqueues/lib/comment-reply.js index fde5f51b96..0c09560f0d 100644 --- a/src/js/_enqueues/lib/comment-reply.js +++ b/src/js/_enqueues/lib/comment-reply.js @@ -8,8 +8,7 @@ * * @type {Object} */ -var addComment; -addComment = ( function( window ) { +window.addComment = ( function( window ) { // Avoid scope lookups on commonly used variables. var document = window.document; diff --git a/src/js/_enqueues/lib/cookies.js b/src/js/_enqueues/lib/cookies.js index eda46b78cb..ac74bdb3a8 100644 --- a/src/js/_enqueues/lib/cookies.js +++ b/src/js/_enqueues/lib/cookies.js @@ -4,10 +4,10 @@ * @output wp-includes/js/utils.js */ -/* global userSettings */ +/* global userSettings, getAllUserSettings, wpCookies, setUserSetting */ /* exported getUserSetting, setUserSetting, deleteUserSetting */ -var wpCookies = { +window.wpCookies = { // The following functions are from Cookie.js class in TinyMCE 3, Moxiecode, used under LGPL. each: function( obj, cb, scope ) { @@ -139,7 +139,7 @@ var wpCookies = { }; // Returns the value as string. Second arg or empty string is returned when value is not set. -function getUserSetting( name, def ) { +window.getUserSetting = function( name, def ) { var settings = getAllUserSettings(); if ( settings.hasOwnProperty( name ) ) { @@ -151,12 +151,12 @@ function getUserSetting( 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. -function setUserSetting( name, value, _del ) { +window.setUserSetting = function( name, value, _del ) { if ( 'object' !== typeof userSettings ) { return false; } @@ -186,17 +186,17 @@ function setUserSetting( name, value, _del ) { wpCookies.set( 'wp-settings-time-' + uid, userSettings.time, 31536000, path, '', secure ); return name; -} +}; -function deleteUserSetting( name ) { +window.deleteUserSetting = function( name ) { return setUserSetting( name, '', 1 ); -} +}; // Returns all settings as js object. -function getAllUserSettings() { +window.getAllUserSettings = function() { if ( 'object' !== typeof userSettings ) { return {}; } return wpCookies.getHash( 'wp-settings-' + userSettings.uid ) || {}; -} +}; diff --git a/src/js/_enqueues/lib/gallery.js b/src/js/_enqueues/lib/gallery.js index c0ba0937c7..36cb08636b 100644 --- a/src/js/_enqueues/lib/gallery.js +++ b/src/js/_enqueues/lib/gallery.js @@ -2,7 +2,7 @@ * @output wp-admin/js/gallery.js */ -/* global unescape, getUserSetting, setUserSetting */ +/* global unescape, getUserSetting, setUserSetting, wpgallery, tinymce */ jQuery(document).ready(function($) { var gallerySortable, gallerySortableInit, sortIt, clearAll, w, desc = false; @@ -88,12 +88,12 @@ jQuery(document).ready(function($) { } }); -jQuery(window).unload( function () { tinymce = tinyMCE = wpgallery = null; } ); // Cleanup +jQuery(window).unload( function () { window.tinymce = window.tinyMCE = window.wpgallery = null; } ); // Cleanup /* gallery settings */ -var tinymce = null, tinyMCE, wpgallery; +window.tinymce = null; -wpgallery = { +window.wpgallery = { mcemode : false, editor : {}, dom : {}, @@ -123,8 +123,8 @@ wpgallery = { } // Find window & API - tinymce = w.tinymce; - tinyMCE = w.tinyMCE; + window.tinymce = w.tinymce; + window.tinyMCE = w.tinyMCE; t.editor = tinymce.EditorManager.activeEditor; t.setup(); diff --git a/src/js/_enqueues/lib/link.js b/src/js/_enqueues/lib/link.js index a89bd577e0..ff9b3c441d 100644 --- a/src/js/_enqueues/lib/link.js +++ b/src/js/_enqueues/lib/link.js @@ -2,7 +2,7 @@ * @output wp-includes/js/wplink.js */ -var wpLink; + /* global wpLink */ ( function( $, wpLinkL10n, wp ) { var editor, searchTimer, River, Query, correctedURL, linkNode, @@ -16,7 +16,7 @@ var wpLink; return linkNode || editor.dom.getParent( editor.selection.getNode(), 'a[href]' ); } - wpLink = { + window.wpLink = { timeToTriggerRiver: 150, minRiverAJAXDuration: 200, riverBottomThreshold: 5, diff --git a/src/js/_enqueues/lib/nav-menu.js b/src/js/_enqueues/lib/nav-menu.js index bccddc8359..40f6787c76 100644 --- a/src/js/_enqueues/lib/nav-menu.js +++ b/src/js/_enqueues/lib/nav-menu.js @@ -9,20 +9,18 @@ * @output wp-admin/js/nav-menu.js */ -/* global menus, postboxes, columns, isRtl, navMenuL10n, ajaxurl */ - -/** - * Contains all the functions to handle WordPress navigation menus administration. - * - * @namespace - */ -var wpNavMenu; +/* global menus, postboxes, columns, isRtl, navMenuL10n, ajaxurl, wpNavMenu */ (function($) { var api; - api = wpNavMenu = { + /** + * Contains all the functions to handle WordPress navigation menus administration. + * + * @namespace wpNavMenu + */ + api = window.wpNavMenu = { options : { menuItemDepthPerLevel : 30, // Do not use directly. Use depthToPx and pxToDepth instead. diff --git a/src/js/_enqueues/lib/quicktags.js b/src/js/_enqueues/lib/quicktags.js index 8906af1869..5bfd6aa031 100644 --- a/src/js/_enqueues/lib/quicktags.js +++ b/src/js/_enqueues/lib/quicktags.js @@ -24,10 +24,9 @@ // by Alex King // http://www.alexking.org/ -/* global adminpage, wpActiveEditor, quicktagsL10n, wpLink, prompt */ +/* global adminpage, wpActiveEditor, quicktagsL10n, wpLink, prompt, edButtons */ -var QTags, edCanvas, - edButtons = []; +window.edButtons = []; /* jshint ignore:start */ @@ -36,24 +35,24 @@ var QTags, edCanvas, * * Define all former global functions so plugins that hack quicktags.js directly don't cause fatal errors. */ -var edAddTag = function(){}, -edCheckOpenTags = function(){}, -edCloseAllTags = function(){}, -edInsertImage = function(){}, -edInsertLink = function(){}, -edInsertTag = function(){}, -edLink = function(){}, -edQuickLink = function(){}, -edRemoveTag = function(){}, -edShowButton = function(){}, -edShowLinks = function(){}, -edSpell = function(){}, -edToolbar = function(){}; +window.edAddTag = function(){}, +window.edCheckOpenTags = function(){}, +window.edCloseAllTags = function(){}, +window.edInsertImage = function(){}, +window.edInsertLink = function(){}, +window.edInsertTag = function(){}, +window.edLink = function(){}, +window.edQuickLink = function(){}, +window.edRemoveTag = function(){}, +window.edShowButton = function(){}, +window.edShowLinks = function(){}, +window.edSpell = function(){}, +window.edToolbar = function(){}; /** * Initialize new instance of the Quicktags editor */ -function quicktags(settings) { +window.quicktags = function(settings) { return new QTags(settings); } @@ -63,7 +62,7 @@ function quicktags(settings) { * Added for back compatibility * @see QTags.insertContent() */ -function edInsertContent(bah, txt) { +window.edInsertContent = function(bah, txt) { return QTags.insertContent(txt); } @@ -73,7 +72,7 @@ function edInsertContent(bah, txt) { * Added for back compatibility, use QTags.addButton() as it gives more flexibility like type of button, button placement, etc. * @see QTags.addButton() */ -function edButton(id, display, tagStart, tagEnd, access) { +window.edButton = function(id, display, tagStart, tagEnd, access) { return QTags.addButton( id, display, tagStart, tagEnd, access, '', -1 ); } @@ -153,10 +152,9 @@ function edButton(id, display, tagStart, tagEnd, access) { zeroise( now.getUTCMinutes() ) + ':' + zeroise( now.getUTCSeconds() ) + '+00:00'; - })(), - qt; + })(); - qt = QTags = function(settings) { + var qt = window.QTags = function(settings) { if ( typeof(settings) === 'string' ) { settings = {id: settings}; } else if ( typeof(settings) !== 'object' ) { @@ -180,7 +178,7 @@ function edButton(id, display, tagStart, tagEnd, access) { if ( id === 'content' && typeof(adminpage) === 'string' && ( adminpage === 'post-new-php' || adminpage === 'post-php' ) ) { // back compat hack :-( - edCanvas = canvas; + window.edCanvas = canvas; toolbar_id = 'ed_toolbar'; } else { toolbar_id = name + '_toolbar'; diff --git a/src/js/_enqueues/wp/dashboard.js b/src/js/_enqueues/wp/dashboard.js index 0719c875eb..67118fe97e 100644 --- a/src/js/_enqueues/wp/dashboard.js +++ b/src/js/_enqueues/wp/dashboard.js @@ -2,8 +2,8 @@ * @output wp-admin/js/dashboard.js */ -/* global pagenow, ajaxurl, postboxes, wpActiveEditor:true */ -var ajaxWidgets, ajaxPopulateWidgets, quickPressLoad; +/* global pagenow, ajaxurl, postboxes, wpActiveEditor:true, ajaxWidgets */ +/* global ajaxPopulateWidgets, quickPressLoad, */ window.wp = window.wp || {}; /** @@ -61,7 +61,7 @@ jQuery(document).ready( function($) { * * @global */ - ajaxWidgets = ['dashboard_primary']; + window.ajaxWidgets = ['dashboard_primary']; /** * Triggers widget updates via AJAX. @@ -74,7 +74,7 @@ jQuery(document).ready( function($) { * * @returns {void} */ - ajaxPopulateWidgets = function(el) { + window.ajaxPopulateWidgets = function(el) { /** * Fetch the latest representation of the widget via Ajax and show it. * @@ -129,7 +129,7 @@ jQuery(document).ready( function($) { * * @returns {void} */ - quickPressLoad = function() { + window.quickPressLoad = function() { var act = $('#quickpost-action'), t; // Enable the submit buttons. @@ -210,7 +210,7 @@ jQuery(document).ready( function($) { autoResizeTextarea(); }; - quickPressLoad(); + window.quickPressLoad(); // Enable the dragging functionality of the widgets. $( '.meta-box-sortables' ).sortable( 'option', 'containment', '#wpwrap' ); diff --git a/src/js/_enqueues/wp/password-strength-meter.js b/src/js/_enqueues/wp/password-strength-meter.js index 14ef40798e..753f697ce4 100644 --- a/src/js/_enqueues/wp/password-strength-meter.js +++ b/src/js/_enqueues/wp/password-strength-meter.js @@ -5,7 +5,6 @@ /* global zxcvbn */ window.wp = window.wp || {}; -var passwordStrength; (function($){ /** @@ -118,5 +117,5 @@ var passwordStrength; * * @type {wp.passwordStrength.meter} */ - passwordStrength = wp.passwordStrength.meter; + window.passwordStrength = wp.passwordStrength.meter; })(jQuery); diff --git a/src/js/_enqueues/wp/theme.js b/src/js/_enqueues/wp/theme.js index 9eefeb4caa..596b097f59 100644 --- a/src/js/_enqueues/wp/theme.js +++ b/src/js/_enqueues/wp/theme.js @@ -2,7 +2,7 @@ * @output wp-admin/js/theme.js */ -/* global _wpThemeSettings, confirm */ +/* global _wpThemeSettings, confirm, tb_position */ window.wp = window.wp || {}; ( function($) { @@ -2041,9 +2041,8 @@ $( document ).ready(function() { })( jQuery ); // Align theme browser thickbox -var tb_position; jQuery(document).ready( function($) { - tb_position = function() { + window.tb_position = function() { var tbWindow = $('#TB_window'), width = $(window).width(), H = $(window).height(),