53 |
53 |
54 /** |
54 /** |
55 * Deprecate all properties on an object. |
55 * Deprecate all properties on an object. |
56 * |
56 * |
57 * @since 5.5.1 |
57 * @since 5.5.1 |
|
58 * @since 5.6.0 Added the `version` parameter. |
58 * |
59 * |
59 * @param {string} name The name of the object, i.e. commonL10n. |
60 * @param {string} name The name of the object, i.e. commonL10n. |
60 * @param {object} l10nObject The object to deprecate the properties on. |
61 * @param {object} l10nObject The object to deprecate the properties on. |
|
62 * @param {string} version The version of WordPress that deprecated the property. |
61 * |
63 * |
62 * @return {object} The object with all its properties deprecated. |
64 * @return {object} The object with all its properties deprecated. |
63 */ |
65 */ |
64 function deprecateL10nObject( name, l10nObject ) { |
66 function deprecateL10nObject( name, l10nObject, version ) { |
65 var deprecatedObject = {}; |
67 var deprecatedObject = {}; |
66 |
68 |
67 Object.keys( l10nObject ).forEach( function( key ) { |
69 Object.keys( l10nObject ).forEach( function( key ) { |
68 var prop = l10nObject[ key ]; |
70 var prop = l10nObject[ key ]; |
69 var propName = name + '.' + key; |
71 var propName = name + '.' + key; |
70 |
72 |
71 if ( 'object' === typeof prop ) { |
73 if ( 'object' === typeof prop ) { |
72 Object.defineProperty( deprecatedObject, key, { get: function() { |
74 Object.defineProperty( deprecatedObject, key, { get: function() { |
73 deprecatedProperty( propName, '5.5.0', prop.alternative ); |
75 deprecatedProperty( propName, version, prop.alternative ); |
74 return prop.func(); |
76 return prop.func(); |
75 } } ); |
77 } } ); |
76 } else { |
78 } else { |
77 Object.defineProperty( deprecatedObject, key, { get: function() { |
79 Object.defineProperty( deprecatedObject, key, { get: function() { |
78 deprecatedProperty( propName, '5.5.0', 'wp.i18n' ); |
80 deprecatedProperty( propName, version, 'wp.i18n' ); |
79 return prop; |
81 return prop; |
80 } } ); |
82 } } ); |
81 } |
83 } |
82 } ); |
84 } ); |
83 |
85 |
196 warnCommentChanges: '', |
198 warnCommentChanges: '', |
197 docTitleComments: '', |
199 docTitleComments: '', |
198 docTitleCommentsCount: '' |
200 docTitleCommentsCount: '' |
199 }; |
201 }; |
200 |
202 |
201 window.adminCommentsL10n = deprecateL10nObject( 'adminCommentsL10n', window.adminCommentsL10n ); |
203 window.adminCommentsL10n = deprecateL10nObject( 'adminCommentsL10n', window.adminCommentsL10n, '5.5.0' ); |
202 |
204 |
203 /** |
205 /** |
204 * Removed in 5.5.0, needed for back-compatibility. |
206 * Removed in 5.5.0, needed for back-compatibility. |
205 * |
207 * |
206 * @since 2.5.0 |
208 * @since 2.5.0 |
304 plugin_information: '', |
306 plugin_information: '', |
305 plugin_modal_label: '', |
307 plugin_modal_label: '', |
306 ays: '' |
308 ays: '' |
307 }; |
309 }; |
308 |
310 |
309 window.plugininstallL10n = deprecateL10nObject( 'plugininstallL10n', window.plugininstallL10n ); |
311 window.plugininstallL10n = deprecateL10nObject( 'plugininstallL10n', window.plugininstallL10n, '5.5.0' ); |
310 |
312 |
311 /** |
313 /** |
312 * Removed in 5.5.0, needed for back-compatibility. |
314 * Removed in 5.5.0, needed for back-compatibility. |
313 * |
315 * |
314 * @since 3.0.0 |
316 * @since 3.0.0 |
378 * |
380 * |
379 * @return {void} |
381 * @return {void} |
380 */ |
382 */ |
381 init : function() { |
383 init : function() { |
382 var that = this; |
384 var that = this; |
383 $('.hide-column-tog', '#adv-settings').click( function() { |
385 $('.hide-column-tog', '#adv-settings').on( 'click', function() { |
384 var $t = $(this), column = $t.val(); |
386 var $t = $(this), column = $t.val(); |
385 if ( $t.prop('checked') ) |
387 if ( $t.prop('checked') ) |
386 that.checked(column); |
388 that.checked(column); |
387 else |
389 else |
388 that.unchecked(column); |
390 that.unchecked(column); |
479 n = parseInt( $t.attr('colspan'), 10 ) + diff; |
481 n = parseInt( $t.attr('colspan'), 10 ) + diff; |
480 $t.attr('colspan', n.toString()); |
482 $t.attr('colspan', n.toString()); |
481 } |
483 } |
482 }; |
484 }; |
483 |
485 |
484 $document.ready(function(){columns.init();}); |
486 $( function() { columns.init(); } ); |
485 |
487 |
486 /** |
488 /** |
487 * Validates that the required form fields are not empty. |
489 * Validates that the required form fields are not empty. |
488 * |
490 * |
489 * @since 2.9.0 |
491 * @since 2.9.0 |
496 return !$( form ) |
498 return !$( form ) |
497 .find( '.form-required' ) |
499 .find( '.form-required' ) |
498 .filter( function() { return $( ':input:visible', this ).val() === ''; } ) |
500 .filter( function() { return $( ':input:visible', this ).val() === ''; } ) |
499 .addClass( 'form-invalid' ) |
501 .addClass( 'form-invalid' ) |
500 .find( ':input:visible' ) |
502 .find( ':input:visible' ) |
501 .change( function() { $( this ).closest( '.form-invalid' ).removeClass( 'form-invalid' ); } ) |
503 .on( 'change', function() { $( this ).closest( '.form-invalid' ).removeClass( 'form-invalid' ); } ) |
502 .length; |
504 .length; |
503 }; |
505 }; |
504 |
506 |
505 // Stub for doing better warnings. |
507 // Stub for doing better warnings. |
506 /** |
508 /** |
567 init: function() { |
569 init: function() { |
568 this.element = $('#screen-meta'); |
570 this.element = $('#screen-meta'); |
569 this.toggles = $( '#screen-meta-links' ).find( '.show-settings' ); |
571 this.toggles = $( '#screen-meta-links' ).find( '.show-settings' ); |
570 this.page = $('#wpcontent'); |
572 this.page = $('#wpcontent'); |
571 |
573 |
572 this.toggles.click( this.toggleEvent ); |
574 this.toggles.on( 'click', this.toggleEvent ); |
573 }, |
575 }, |
574 |
576 |
575 /** |
577 /** |
576 * Toggles the screen meta options panel. |
578 * Toggles the screen meta options panel. |
577 * |
579 * |
794 |
796 |
795 // If input had focus give it back with cursor right after appended text. |
797 // If input had focus give it back with cursor right after appended text. |
796 if ( permalinkStructureFocused && $permalinkStructure[0].setSelectionRange ) { |
798 if ( permalinkStructureFocused && $permalinkStructure[0].setSelectionRange ) { |
797 newSelectionStart = ( permalinkStructureValue.substr( 0, selectionStart ) + textToAppend ).length; |
799 newSelectionStart = ( permalinkStructureValue.substr( 0, selectionStart ) + textToAppend ).length; |
798 $permalinkStructure[0].setSelectionRange( newSelectionStart, newSelectionStart ); |
800 $permalinkStructure[0].setSelectionRange( newSelectionStart, newSelectionStart ); |
799 $permalinkStructure.focus(); |
801 $permalinkStructure.trigger( 'focus' ); |
800 } |
802 } |
801 } ); |
803 } ); |
802 |
804 |
803 $document.ready( function() { |
805 $( function() { |
804 var checks, first, last, checked, sliced, mobileEvent, transitionTimeout, focusedRowActions, |
806 var checks, first, last, checked, sliced, mobileEvent, transitionTimeout, focusedRowActions, |
805 lastClicked = false, |
807 lastClicked = false, |
806 pageInput = $('input.current-page'), |
808 pageInput = $('input.current-page'), |
807 currentPage = pageInput.val(), |
809 currentPage = pageInput.val(), |
808 isIOS = /iPhone|iPad|iPod/.test( navigator.userAgent ), |
810 isIOS = /iPhone|iPad|iPod/.test( navigator.userAgent ), |
1090 function makeNoticesDismissible() { |
1092 function makeNoticesDismissible() { |
1091 $( '.notice.is-dismissible' ).each( function() { |
1093 $( '.notice.is-dismissible' ).each( function() { |
1092 var $el = $( this ), |
1094 var $el = $( this ), |
1093 $button = $( '<button type="button" class="notice-dismiss"><span class="screen-reader-text"></span></button>' ); |
1095 $button = $( '<button type="button" class="notice-dismiss"><span class="screen-reader-text"></span></button>' ); |
1094 |
1096 |
|
1097 if ( $el.find( '.notice-dismiss' ).length ) { |
|
1098 return; |
|
1099 } |
|
1100 |
1095 // Ensure plain text. |
1101 // Ensure plain text. |
1096 $button.find( '.screen-reader-text' ).text( __( 'Dismiss this notice.' ) ); |
1102 $button.find( '.screen-reader-text' ).text( __( 'Dismiss this notice.' ) ); |
1097 $button.on( 'click.wp-dismiss-notice', function( event ) { |
1103 $button.on( 'click.wp-dismiss-notice', function( event ) { |
1098 event.preventDefault(); |
1104 event.preventDefault(); |
1099 $el.fadeTo( 100, 0, function() { |
1105 $el.fadeTo( 100, 0, function() { |
1212 return false; |
1218 return false; |
1213 }); |
1219 }); |
1214 }); |
1220 }); |
1215 |
1221 |
1216 /** |
1222 /** |
|
1223 * Marries a secondary control to its primary control. |
|
1224 * |
|
1225 * @param {jQuery} topSelector The top selector element. |
|
1226 * @param {jQuery} topSubmit The top submit element. |
|
1227 * @param {jQuery} bottomSelector The bottom selector element. |
|
1228 * @param {jQuery} bottomSubmit The bottom submit element. |
|
1229 * @return {void} |
|
1230 */ |
|
1231 function marryControls( topSelector, topSubmit, bottomSelector, bottomSubmit ) { |
|
1232 /** |
|
1233 * Updates the primary selector when the secondary selector is changed. |
|
1234 * |
|
1235 * @since 5.7.0 |
|
1236 * |
|
1237 * @return {void} |
|
1238 */ |
|
1239 function updateTopSelector() { |
|
1240 topSelector.val($(this).val()); |
|
1241 } |
|
1242 bottomSelector.on('change', updateTopSelector); |
|
1243 |
|
1244 /** |
|
1245 * Updates the secondary selector when the primary selector is changed. |
|
1246 * |
|
1247 * @since 5.7.0 |
|
1248 * |
|
1249 * @return {void} |
|
1250 */ |
|
1251 function updateBottomSelector() { |
|
1252 bottomSelector.val($(this).val()); |
|
1253 } |
|
1254 topSelector.on('change', updateBottomSelector); |
|
1255 |
|
1256 /** |
|
1257 * Triggers the primary submit when then secondary submit is clicked. |
|
1258 * |
|
1259 * @since 5.7.0 |
|
1260 * |
|
1261 * @return {void} |
|
1262 */ |
|
1263 function triggerSubmitClick(e) { |
|
1264 e.preventDefault(); |
|
1265 e.stopPropagation(); |
|
1266 |
|
1267 topSubmit.trigger('click'); |
|
1268 } |
|
1269 bottomSubmit.on('click', triggerSubmitClick); |
|
1270 } |
|
1271 |
|
1272 // Marry the secondary "Bulk actions" controls to the primary controls: |
|
1273 marryControls( $('#bulk-action-selector-top'), $('#doaction'), $('#bulk-action-selector-bottom'), $('#doaction2') ); |
|
1274 |
|
1275 // Marry the secondary "Change role to" controls to the primary controls: |
|
1276 marryControls( $('#new_role'), $('#changeit'), $('#new_role2'), $('#changeit2') ); |
|
1277 |
|
1278 /** |
1217 * Shows row actions on focus of its parent container element or any other elements contained within. |
1279 * Shows row actions on focus of its parent container element or any other elements contained within. |
1218 * |
1280 * |
1219 * @return {void} |
1281 * @return {void} |
1220 */ |
1282 */ |
1221 $( '#wpbody-content' ).on({ |
1283 $( '#wpbody-content' ).on({ |
1231 // the .row-actions div gets hidden in transit in some browsers (ahem, Firefox). |
1293 // the .row-actions div gets hidden in transit in some browsers (ahem, Firefox). |
1232 transitionTimeout = setTimeout( function() { |
1294 transitionTimeout = setTimeout( function() { |
1233 focusedRowActions.removeClass( 'visible' ); |
1295 focusedRowActions.removeClass( 'visible' ); |
1234 }, 30 ); |
1296 }, 30 ); |
1235 } |
1297 } |
1236 }, '.has-row-actions' ); |
1298 }, '.table-view-list .has-row-actions' ); |
1237 |
1299 |
1238 // Toggle list table rows on small screens. |
1300 // Toggle list table rows on small screens. |
1239 $( 'tbody' ).on( 'click', '.toggle-row', function() { |
1301 $( 'tbody' ).on( 'click', '.toggle-row', function() { |
1240 $( this ).closest( 'tr' ).toggleClass( 'is-expanded' ); |
1302 $( this ).closest( 'tr' ).toggleClass( 'is-expanded' ); |
1241 }); |
1303 }); |
1242 |
1304 |
1243 $('#default-password-nag-no').click( function() { |
1305 $('#default-password-nag-no').on( 'click', function() { |
1244 setUserSetting('default_password_nag', 'hide'); |
1306 setUserSetting('default_password_nag', 'hide'); |
1245 $('div.default-password-nag').hide(); |
1307 $('div.default-password-nag').hide(); |
1246 return false; |
1308 return false; |
1247 }); |
1309 }); |
1248 |
1310 |
1251 * |
1313 * |
1252 * @param {Event} e The event object. |
1314 * @param {Event} e The event object. |
1253 * |
1315 * |
1254 * @return {void} |
1316 * @return {void} |
1255 */ |
1317 */ |
1256 $('#newcontent').bind('keydown.wpevent_InsertTab', function(e) { |
1318 $('#newcontent').on('keydown.wpevent_InsertTab', function(e) { |
1257 var el = e.target, selStart, selEnd, val, scroll, sel; |
1319 var el = e.target, selStart, selEnd, val, scroll, sel; |
1258 |
1320 |
1259 // After pressing escape key (keyCode: 27), the tab key should tab out of the textarea. |
1321 // After pressing escape key (keyCode: 27), the tab key should tab out of the textarea. |
1260 if ( e.keyCode == 27 ) { |
1322 if ( e.keyCode == 27 ) { |
1261 // When pressing Escape: Opera 12 and 27 blur form fields, IE 8 clears them. |
1323 // When pressing Escape: Opera 12 and 27 blur form fields, IE 8 clears them. |
1310 * |
1372 * |
1311 * The form closest to the pageInput is the post-filter form. |
1373 * The form closest to the pageInput is the post-filter form. |
1312 * |
1374 * |
1313 * @return {void} |
1375 * @return {void} |
1314 */ |
1376 */ |
1315 pageInput.closest('form').submit( function() { |
1377 pageInput.closest('form').on( 'submit', function() { |
1316 /* |
1378 /* |
1317 * action = bulk action dropdown at the top of the table |
1379 * action = bulk action dropdown at the top of the table |
1318 * action2 = bulk action dropdow at the bottom of the table |
|
1319 */ |
1380 */ |
1320 if ( $('select[name="action"]').val() == -1 && $('select[name="action2"]').val() == -1 && pageInput.val() == currentPage ) |
1381 if ( $('select[name="action"]').val() == -1 && pageInput.val() == currentPage ) |
1321 pageInput.val('1'); |
1382 pageInput.val('1'); |
1322 }); |
1383 }); |
1323 } |
1384 } |
1324 |
1385 |
1325 /** |
1386 /** |
1326 * Resets the bulk actions when the search button is clicked. |
1387 * Resets the bulk actions when the search button is clicked. |
1327 * |
1388 * |
1328 * @return {void} |
1389 * @return {void} |
1329 */ |
1390 */ |
1330 $('.search-box input[type="search"], .search-box input[type="submit"]').mousedown(function () { |
1391 $('.search-box input[type="search"], .search-box input[type="submit"]').on( 'mousedown', function () { |
1331 $('select[name^="action"]').val('-1'); |
1392 $('select[name^="action"]').val('-1'); |
1332 }); |
1393 }); |
1333 |
1394 |
1334 /** |
1395 /** |
1335 * Scrolls into view when focus.scroll-into-view is triggered. |
1396 * Scrolls into view when focus.scroll-into-view is triggered. |
1626 $adminbar.find( '.hover' ).removeClass( 'hover' ); |
1687 $adminbar.find( '.hover' ).removeClass( 'hover' ); |
1627 |
1688 |
1628 $wpwrap.toggleClass( 'wp-responsive-open' ); |
1689 $wpwrap.toggleClass( 'wp-responsive-open' ); |
1629 if ( $wpwrap.hasClass( 'wp-responsive-open' ) ) { |
1690 if ( $wpwrap.hasClass( 'wp-responsive-open' ) ) { |
1630 $(this).find('a').attr( 'aria-expanded', 'true' ); |
1691 $(this).find('a').attr( 'aria-expanded', 'true' ); |
1631 $( '#adminmenu a:first' ).focus(); |
1692 $( '#adminmenu a:first' ).trigger( 'focus' ); |
1632 } else { |
1693 } else { |
1633 $(this).find('a').attr( 'aria-expanded', 'false' ); |
1694 $(this).find('a').attr( 'aria-expanded', 'false' ); |
1634 } |
1695 } |
1635 } ); |
1696 } ); |
1636 |
1697 |
1643 $( this ).parent( 'li' ).toggleClass( 'selected' ); |
1704 $( this ).parent( 'li' ).toggleClass( 'selected' ); |
1644 event.preventDefault(); |
1705 event.preventDefault(); |
1645 }); |
1706 }); |
1646 |
1707 |
1647 self.trigger(); |
1708 self.trigger(); |
1648 $document.on( 'wp-window-resized.wp-responsive', $.proxy( this.trigger, this ) ); |
1709 $document.on( 'wp-window-resized.wp-responsive', this.trigger.bind( this ) ); |
1649 |
1710 |
1650 // This needs to run later as UI Sortable may be initialized later on $(document).ready(). |
1711 // This needs to run later as UI Sortable may be initialized later on $(document).ready(). |
1651 $window.on( 'load.wp-responsive', this.maybeDisableSortables ); |
1712 $window.on( 'load.wp-responsive', this.maybeDisableSortables ); |
1652 $document.on( 'postbox-toggled', this.maybeDisableSortables ); |
1713 $document.on( 'postbox-toggled', this.maybeDisableSortables ); |
1653 |
1714 |
1826 */ |
1887 */ |
1827 function aria_button_if_js() { |
1888 function aria_button_if_js() { |
1828 $( '.aria-button-if-js' ).attr( 'role', 'button' ); |
1889 $( '.aria-button-if-js' ).attr( 'role', 'button' ); |
1829 } |
1890 } |
1830 |
1891 |
1831 $( document ).ajaxComplete( function() { |
1892 $( document ).on( 'ajaxComplete', function() { |
1832 aria_button_if_js(); |
1893 aria_button_if_js(); |
1833 }); |
1894 }); |
1834 |
1895 |
1835 /** |
1896 /** |
1836 * Get the viewport width. |
1897 * Get the viewport width. |
1915 aria_button_if_js(); |
1976 aria_button_if_js(); |
1916 |
1977 |
1917 $document.on( 'wp-pin-menu wp-window-resized.pin-menu postboxes-columnchange.pin-menu postbox-toggled.pin-menu wp-collapse-menu.pin-menu wp-scroll-start.pin-menu', setPinMenu ); |
1978 $document.on( 'wp-pin-menu wp-window-resized.pin-menu postboxes-columnchange.pin-menu postbox-toggled.pin-menu wp-collapse-menu.pin-menu wp-scroll-start.pin-menu', setPinMenu ); |
1918 |
1979 |
1919 // Set initial focus on a specific element. |
1980 // Set initial focus on a specific element. |
1920 $( '.wp-initial-focus' ).focus(); |
1981 $( '.wp-initial-focus' ).trigger( 'focus' ); |
1921 |
1982 |
1922 // Toggle update details on update-core.php. |
1983 // Toggle update details on update-core.php. |
1923 $body.on( 'click', '.js-update-details-toggle', function() { |
1984 $body.on( 'click', '.js-update-details-toggle', function() { |
1924 var $updateNotice = $( this ).closest( '.js-update-details' ), |
1985 var $updateNotice = $( this ).closest( '.js-update-details' ), |
1925 $progressDiv = $( '#' + $updateNotice.data( 'update-details' ) ); |
1986 $progressDiv = $( '#' + $updateNotice.data( 'update-details' ) ); |
1945 * On the "Update plugin/theme from uploaded zip" screen, once the upload has expired, |
2006 * On the "Update plugin/theme from uploaded zip" screen, once the upload has expired, |
1946 * hides the "Replace current with uploaded" button and displays a warning. |
2007 * hides the "Replace current with uploaded" button and displays a warning. |
1947 * |
2008 * |
1948 * @since 5.5.0 |
2009 * @since 5.5.0 |
1949 */ |
2010 */ |
1950 $document.ready( function( $ ) { |
2011 $( function( $ ) { |
1951 var $overwrite, $warning; |
2012 var $overwrite, $warning; |
1952 |
2013 |
1953 if ( ! $body.hasClass( 'update-php' ) ) { |
2014 if ( ! $body.hasClass( 'update-php' ) ) { |
1954 return; |
2015 return; |
1955 } |
2016 } |