changeset 16 | a86126ab1dd4 |
parent 9 | 177826044cd9 |
child 18 | be944660c56a |
15:3d4e9c994f10 | 16:a86126ab1dd4 |
---|---|
1 /** |
1 /** |
2 * @output wp-admin/js/common.js |
2 * @output wp-admin/js/common.js |
3 */ |
3 */ |
4 |
4 |
5 /* global setUserSetting, ajaxurl, commonL10n, alert, confirm, pagenow */ |
5 /* global setUserSetting, ajaxurl, alert, confirm, pagenow */ |
6 /* global columns, screenMeta */ |
6 /* global columns, screenMeta */ |
7 |
7 |
8 /** |
8 /** |
9 * Adds common WordPress functionality to the window. |
9 * Adds common WordPress functionality to the window. |
10 * |
10 * |
13 * @param {mixed} undefined Unused. |
13 * @param {mixed} undefined Unused. |
14 */ |
14 */ |
15 ( function( $, window, undefined ) { |
15 ( function( $, window, undefined ) { |
16 var $document = $( document ), |
16 var $document = $( document ), |
17 $window = $( window ), |
17 $window = $( window ), |
18 $body = $( document.body ); |
18 $body = $( document.body ), |
19 __ = wp.i18n.__, |
|
20 sprintf = wp.i18n.sprintf; |
|
21 |
|
22 /** |
|
23 * Throws an error for a deprecated property. |
|
24 * |
|
25 * @since 5.5.1 |
|
26 * |
|
27 * @param {string} propName The property that was used. |
|
28 * @param {string} version The version of WordPress that deprecated the property. |
|
29 * @param {string} replacement The property that should have been used. |
|
30 */ |
|
31 function deprecatedProperty( propName, version, replacement ) { |
|
32 var message; |
|
33 |
|
34 if ( 'undefined' !== typeof replacement ) { |
|
35 message = sprintf( |
|
36 /* translators: 1: Deprecated property name, 2: Version number, 3: Alternative property name. */ |
|
37 __( '%1$s is deprecated since version %2$s! Use %3$s instead.' ), |
|
38 propName, |
|
39 version, |
|
40 replacement |
|
41 ); |
|
42 } else { |
|
43 message = sprintf( |
|
44 /* translators: 1: Deprecated property name, 2: Version number. */ |
|
45 __( '%1$s is deprecated since version %2$s with no alternative available.' ), |
|
46 propName, |
|
47 version |
|
48 ); |
|
49 } |
|
50 |
|
51 window.console.warn( message ); |
|
52 } |
|
53 |
|
54 /** |
|
55 * Deprecate all properties on an object. |
|
56 * |
|
57 * @since 5.5.1 |
|
58 * |
|
59 * @param {string} name The name of the object, i.e. commonL10n. |
|
60 * @param {object} l10nObject The object to deprecate the properties on. |
|
61 * |
|
62 * @return {object} The object with all its properties deprecated. |
|
63 */ |
|
64 function deprecateL10nObject( name, l10nObject ) { |
|
65 var deprecatedObject = {}; |
|
66 |
|
67 Object.keys( l10nObject ).forEach( function( key ) { |
|
68 var prop = l10nObject[ key ]; |
|
69 var propName = name + '.' + key; |
|
70 |
|
71 if ( 'object' === typeof prop ) { |
|
72 Object.defineProperty( deprecatedObject, key, { get: function() { |
|
73 deprecatedProperty( propName, '5.5.0', prop.alternative ); |
|
74 return prop.func(); |
|
75 } } ); |
|
76 } else { |
|
77 Object.defineProperty( deprecatedObject, key, { get: function() { |
|
78 deprecatedProperty( propName, '5.5.0', 'wp.i18n' ); |
|
79 return prop; |
|
80 } } ); |
|
81 } |
|
82 } ); |
|
83 |
|
84 return deprecatedObject; |
|
85 } |
|
86 |
|
87 window.wp.deprecateL10nObject = deprecateL10nObject; |
|
88 |
|
89 /** |
|
90 * Removed in 5.5.0, needed for back-compatibility. |
|
91 * |
|
92 * @since 2.6.0 |
|
93 * @deprecated 5.5.0 |
|
94 */ |
|
95 window.commonL10n = window.commonL10n || { |
|
96 warnDelete: '', |
|
97 dismiss: '', |
|
98 collapseMenu: '', |
|
99 expandMenu: '' |
|
100 }; |
|
101 |
|
102 window.commonL10n = deprecateL10nObject( 'commonL10n', window.commonL10n ); |
|
103 |
|
104 /** |
|
105 * Removed in 5.5.0, needed for back-compatibility. |
|
106 * |
|
107 * @since 3.3.0 |
|
108 * @deprecated 5.5.0 |
|
109 */ |
|
110 window.wpPointerL10n = window.wpPointerL10n || { |
|
111 dismiss: '' |
|
112 }; |
|
113 |
|
114 window.wpPointerL10n = deprecateL10nObject( 'wpPointerL10n', window.wpPointerL10n ); |
|
115 |
|
116 /** |
|
117 * Removed in 5.5.0, needed for back-compatibility. |
|
118 * |
|
119 * @since 4.3.0 |
|
120 * @deprecated 5.5.0 |
|
121 */ |
|
122 window.userProfileL10n = window.userProfileL10n || { |
|
123 warn: '', |
|
124 warnWeak: '', |
|
125 show: '', |
|
126 hide: '', |
|
127 cancel: '', |
|
128 ariaShow: '', |
|
129 ariaHide: '' |
|
130 }; |
|
131 |
|
132 window.userProfileL10n = deprecateL10nObject( 'userProfileL10n', window.userProfileL10n ); |
|
133 |
|
134 /** |
|
135 * Removed in 5.5.0, needed for back-compatibility. |
|
136 * |
|
137 * @since 4.9.6 |
|
138 * @deprecated 5.5.0 |
|
139 */ |
|
140 window.privacyToolsL10n = window.privacyToolsL10n || { |
|
141 noDataFound: '', |
|
142 foundAndRemoved: '', |
|
143 noneRemoved: '', |
|
144 someNotRemoved: '', |
|
145 removalError: '', |
|
146 emailSent: '', |
|
147 noExportFile: '', |
|
148 exportError: '' |
|
149 }; |
|
150 |
|
151 window.privacyToolsL10n = deprecateL10nObject( 'privacyToolsL10n', window.privacyToolsL10n ); |
|
152 |
|
153 /** |
|
154 * Removed in 5.5.0, needed for back-compatibility. |
|
155 * |
|
156 * @since 3.6.0 |
|
157 * @deprecated 5.5.0 |
|
158 */ |
|
159 window.authcheckL10n = { |
|
160 beforeunload: '' |
|
161 }; |
|
162 |
|
163 window.authcheckL10n = window.authcheckL10n || deprecateL10nObject( 'authcheckL10n', window.authcheckL10n ); |
|
164 |
|
165 /** |
|
166 * Removed in 5.5.0, needed for back-compatibility. |
|
167 * |
|
168 * @since 2.8.0 |
|
169 * @deprecated 5.5.0 |
|
170 */ |
|
171 window.tagsl10n = { |
|
172 noPerm: '', |
|
173 broken: '' |
|
174 }; |
|
175 |
|
176 window.tagsl10n = window.tagsl10n || deprecateL10nObject( 'tagsl10n', window.tagsl10n ); |
|
177 |
|
178 /** |
|
179 * Removed in 5.5.0, needed for back-compatibility. |
|
180 * |
|
181 * @since 2.5.0 |
|
182 * @deprecated 5.5.0 |
|
183 */ |
|
184 window.adminCommentsL10n = window.adminCommentsL10n || { |
|
185 hotkeys_highlight_first: { |
|
186 alternative: 'window.adminCommentsSettings.hotkeys_highlight_first', |
|
187 func: function() { return window.adminCommentsSettings.hotkeys_highlight_first; } |
|
188 }, |
|
189 hotkeys_highlight_last: { |
|
190 alternative: 'window.adminCommentsSettings.hotkeys_highlight_last', |
|
191 func: function() { return window.adminCommentsSettings.hotkeys_highlight_last; } |
|
192 }, |
|
193 replyApprove: '', |
|
194 reply: '', |
|
195 warnQuickEdit: '', |
|
196 warnCommentChanges: '', |
|
197 docTitleComments: '', |
|
198 docTitleCommentsCount: '' |
|
199 }; |
|
200 |
|
201 window.adminCommentsL10n = deprecateL10nObject( 'adminCommentsL10n', window.adminCommentsL10n ); |
|
202 |
|
203 /** |
|
204 * Removed in 5.5.0, needed for back-compatibility. |
|
205 * |
|
206 * @since 2.5.0 |
|
207 * @deprecated 5.5.0 |
|
208 */ |
|
209 window.tagsSuggestL10n = window.tagsSuggestL10n || { |
|
210 tagDelimiter: '', |
|
211 removeTerm: '', |
|
212 termSelected: '', |
|
213 termAdded: '', |
|
214 termRemoved: '' |
|
215 }; |
|
216 |
|
217 window.tagsSuggestL10n = deprecateL10nObject( 'tagsSuggestL10n', window.tagsSuggestL10n ); |
|
218 |
|
219 /** |
|
220 * Removed in 5.5.0, needed for back-compatibility. |
|
221 * |
|
222 * @since 3.5.0 |
|
223 * @deprecated 5.5.0 |
|
224 */ |
|
225 window.wpColorPickerL10n = window.wpColorPickerL10n || { |
|
226 clear: '', |
|
227 clearAriaLabel: '', |
|
228 defaultString: '', |
|
229 defaultAriaLabel: '', |
|
230 pick: '', |
|
231 defaultLabel: '' |
|
232 }; |
|
233 |
|
234 window.wpColorPickerL10n = deprecateL10nObject( 'wpColorPickerL10n', window.wpColorPickerL10n ); |
|
235 |
|
236 /** |
|
237 * Removed in 5.5.0, needed for back-compatibility. |
|
238 * |
|
239 * @since 2.7.0 |
|
240 * @deprecated 5.5.0 |
|
241 */ |
|
242 window.attachMediaBoxL10n = window.attachMediaBoxL10n || { |
|
243 error: '' |
|
244 }; |
|
245 |
|
246 window.attachMediaBoxL10n = deprecateL10nObject( 'attachMediaBoxL10n', window.attachMediaBoxL10n ); |
|
247 |
|
248 /** |
|
249 * Removed in 5.5.0, needed for back-compatibility. |
|
250 * |
|
251 * @since 2.5.0 |
|
252 * @deprecated 5.5.0 |
|
253 */ |
|
254 window.postL10n = window.postL10n || { |
|
255 ok: '', |
|
256 cancel: '', |
|
257 publishOn: '', |
|
258 publishOnFuture: '', |
|
259 publishOnPast: '', |
|
260 dateFormat: '', |
|
261 showcomm: '', |
|
262 endcomm: '', |
|
263 publish: '', |
|
264 schedule: '', |
|
265 update: '', |
|
266 savePending: '', |
|
267 saveDraft: '', |
|
268 'private': '', |
|
269 'public': '', |
|
270 publicSticky: '', |
|
271 password: '', |
|
272 privatelyPublished: '', |
|
273 published: '', |
|
274 saveAlert: '', |
|
275 savingText: '', |
|
276 permalinkSaved: '' |
|
277 }; |
|
278 |
|
279 window.postL10n = deprecateL10nObject( 'postL10n', window.postL10n ); |
|
280 |
|
281 /** |
|
282 * Removed in 5.5.0, needed for back-compatibility. |
|
283 * |
|
284 * @since 2.7.0 |
|
285 * @deprecated 5.5.0 |
|
286 */ |
|
287 window.inlineEditL10n = window.inlineEditL10n || { |
|
288 error: '', |
|
289 ntdeltitle: '', |
|
290 notitle: '', |
|
291 comma: '', |
|
292 saved: '' |
|
293 }; |
|
294 |
|
295 window.inlineEditL10n = deprecateL10nObject( 'inlineEditL10n', window.inlineEditL10n ); |
|
296 |
|
297 /** |
|
298 * Removed in 5.5.0, needed for back-compatibility. |
|
299 * |
|
300 * @since 2.7.0 |
|
301 * @deprecated 5.5.0 |
|
302 */ |
|
303 window.plugininstallL10n = window.plugininstallL10n || { |
|
304 plugin_information: '', |
|
305 plugin_modal_label: '', |
|
306 ays: '' |
|
307 }; |
|
308 |
|
309 window.plugininstallL10n = deprecateL10nObject( 'plugininstallL10n', window.plugininstallL10n ); |
|
310 |
|
311 /** |
|
312 * Removed in 5.5.0, needed for back-compatibility. |
|
313 * |
|
314 * @since 3.0.0 |
|
315 * @deprecated 5.5.0 |
|
316 */ |
|
317 window.navMenuL10n = window.navMenuL10n || { |
|
318 noResultsFound: '', |
|
319 warnDeleteMenu: '', |
|
320 saveAlert: '', |
|
321 untitled: '' |
|
322 }; |
|
323 |
|
324 window.navMenuL10n = deprecateL10nObject( 'navMenuL10n', window.navMenuL10n ); |
|
325 |
|
326 /** |
|
327 * Removed in 5.5.0, needed for back-compatibility. |
|
328 * |
|
329 * @since 2.5.0 |
|
330 * @deprecated 5.5.0 |
|
331 */ |
|
332 window.commentL10n = window.commentL10n || { |
|
333 submittedOn: '', |
|
334 dateFormat: '' |
|
335 }; |
|
336 |
|
337 window.commentL10n = deprecateL10nObject( 'commentL10n', window.commentL10n ); |
|
338 |
|
339 /** |
|
340 * Removed in 5.5.0, needed for back-compatibility. |
|
341 * |
|
342 * @since 2.9.0 |
|
343 * @deprecated 5.5.0 |
|
344 */ |
|
345 window.setPostThumbnailL10n = window.setPostThumbnailL10n || { |
|
346 setThumbnail: '', |
|
347 saving: '', |
|
348 error: '', |
|
349 done: '' |
|
350 }; |
|
351 |
|
352 window.setPostThumbnailL10n = deprecateL10nObject( 'setPostThumbnailL10n', window.setPostThumbnailL10n ); |
|
19 |
353 |
20 /** |
354 /** |
21 * Removed in 3.3.0, needed for back-compatibility. |
355 * Removed in 3.3.0, needed for back-compatibility. |
22 * |
356 * |
23 * @since 2.7.0 |
357 * @since 2.7.0 |
40 * Binds an onClick event to the checkboxes to show or hide the table columns |
374 * Binds an onClick event to the checkboxes to show or hide the table columns |
41 * based on their toggled state. And persists the toggled state. |
375 * based on their toggled state. And persists the toggled state. |
42 * |
376 * |
43 * @since 2.7.0 |
377 * @since 2.7.0 |
44 * |
378 * |
45 * @returns {void} |
379 * @return {void} |
46 */ |
380 */ |
47 init : function() { |
381 init : function() { |
48 var that = this; |
382 var that = this; |
49 $('.hide-column-tog', '#adv-settings').click( function() { |
383 $('.hide-column-tog', '#adv-settings').click( function() { |
50 var $t = $(this), column = $t.val(); |
384 var $t = $(this), column = $t.val(); |
62 * |
396 * |
63 * Saves whether the columns should be shown or hidden on a page. |
397 * Saves whether the columns should be shown or hidden on a page. |
64 * |
398 * |
65 * @since 3.0.0 |
399 * @since 3.0.0 |
66 * |
400 * |
67 * @returns {void} |
401 * @return {void} |
68 */ |
402 */ |
69 saveManageColumnsState : function() { |
403 saveManageColumnsState : function() { |
70 var hidden = this.hidden(); |
404 var hidden = this.hidden(); |
71 $.post(ajaxurl, { |
405 $.post(ajaxurl, { |
72 action: 'hidden-columns', |
406 action: 'hidden-columns', |
80 * Makes a column visible and adjusts the column span for the table. |
414 * Makes a column visible and adjusts the column span for the table. |
81 * |
415 * |
82 * @since 3.0.0 |
416 * @since 3.0.0 |
83 * @param {string} column The column name. |
417 * @param {string} column The column name. |
84 * |
418 * |
85 * @returns {void} |
419 * @return {void} |
86 */ |
420 */ |
87 checked : function(column) { |
421 checked : function(column) { |
88 $('.column-' + column).removeClass( 'hidden' ); |
422 $('.column-' + column).removeClass( 'hidden' ); |
89 this.colSpanChange(+1); |
423 this.colSpanChange(+1); |
90 }, |
424 }, |
93 * Hides a column and adjusts the column span for the table. |
427 * Hides a column and adjusts the column span for the table. |
94 * |
428 * |
95 * @since 3.0.0 |
429 * @since 3.0.0 |
96 * @param {string} column The column name. |
430 * @param {string} column The column name. |
97 * |
431 * |
98 * @returns {void} |
432 * @return {void} |
99 */ |
433 */ |
100 unchecked : function(column) { |
434 unchecked : function(column) { |
101 $('.column-' + column).addClass( 'hidden' ); |
435 $('.column-' + column).addClass( 'hidden' ); |
102 this.colSpanChange(-1); |
436 this.colSpanChange(-1); |
103 }, |
437 }, |
105 /** |
439 /** |
106 * Gets all hidden columns. |
440 * Gets all hidden columns. |
107 * |
441 * |
108 * @since 3.0.0 |
442 * @since 3.0.0 |
109 * |
443 * |
110 * @returns {string} The hidden column names separated by a comma. |
444 * @return {string} The hidden column names separated by a comma. |
111 */ |
445 */ |
112 hidden : function() { |
446 hidden : function() { |
113 return $( '.manage-column[id]' ).filter( '.hidden' ).map(function() { |
447 return $( '.manage-column[id]' ).filter( '.hidden' ).map(function() { |
114 return this.id; |
448 return this.id; |
115 }).get().join( ',' ); |
449 }).get().join( ',' ); |
118 /** |
452 /** |
119 * Gets the checked column toggles from the screen options. |
453 * Gets the checked column toggles from the screen options. |
120 * |
454 * |
121 * @since 3.0.0 |
455 * @since 3.0.0 |
122 * |
456 * |
123 * @returns {string} String containing the checked column names. |
457 * @return {string} String containing the checked column names. |
124 */ |
458 */ |
125 useCheckboxesForHidden : function() { |
459 useCheckboxesForHidden : function() { |
126 this.hidden = function(){ |
460 this.hidden = function(){ |
127 return $('.hide-column-tog').not(':checked').map(function() { |
461 return $('.hide-column-tog').not(':checked').map(function() { |
128 var id = this.id; |
462 var id = this.id; |
134 /** |
468 /** |
135 * Adjusts the column span for the table. |
469 * Adjusts the column span for the table. |
136 * |
470 * |
137 * @since 3.1.0 |
471 * @since 3.1.0 |
138 * |
472 * |
139 * @param {int} diff The modifier for the column span. |
473 * @param {number} diff The modifier for the column span. |
140 */ |
474 */ |
141 colSpanChange : function(diff) { |
475 colSpanChange : function(diff) { |
142 var $t = $('table').find('.colspanchange'), n; |
476 var $t = $('table').find('.colspanchange'), n; |
143 if ( !$t.length ) |
477 if ( !$t.length ) |
144 return; |
478 return; |
154 * |
488 * |
155 * @since 2.9.0 |
489 * @since 2.9.0 |
156 * |
490 * |
157 * @param {jQuery} form The form to validate. |
491 * @param {jQuery} form The form to validate. |
158 * |
492 * |
159 * @returns {boolean} Returns true if all required fields are not an empty string. |
493 * @return {boolean} Returns true if all required fields are not an empty string. |
160 */ |
494 */ |
161 window.validateForm = function( form ) { |
495 window.validateForm = function( form ) { |
162 return !$( form ) |
496 return !$( form ) |
163 .find( '.form-required' ) |
497 .find( '.form-required' ) |
164 .filter( function() { return $( ':input:visible', this ).val() === ''; } ) |
498 .filter( function() { return $( ':input:visible', this ).val() === ''; } ) |
166 .find( ':input:visible' ) |
500 .find( ':input:visible' ) |
167 .change( function() { $( this ).closest( '.form-invalid' ).removeClass( 'form-invalid' ); } ) |
501 .change( function() { $( this ).closest( '.form-invalid' ).removeClass( 'form-invalid' ); } ) |
168 .length; |
502 .length; |
169 }; |
503 }; |
170 |
504 |
171 // stub for doing better warnings |
505 // Stub for doing better warnings. |
172 /** |
506 /** |
173 * Shows message pop-up notice or confirmation message. |
507 * Shows message pop-up notice or confirmation message. |
174 * |
508 * |
175 * @since 2.7.0 |
509 * @since 2.7.0 |
176 * |
510 * |
177 * @type {{warn: showNotice.warn, note: showNotice.note}} |
511 * @type {{warn: showNotice.warn, note: showNotice.note}} |
178 * |
512 * |
179 * @returns {void} |
513 * @return {void} |
180 */ |
514 */ |
181 window.showNotice = { |
515 window.showNotice = { |
182 |
516 |
183 /** |
517 /** |
184 * Shows a delete confirmation pop-up message. |
518 * Shows a delete confirmation pop-up message. |
185 * |
519 * |
186 * @since 2.7.0 |
520 * @since 2.7.0 |
187 * |
521 * |
188 * @returns {boolean} Returns true if the message is confirmed. |
522 * @return {boolean} Returns true if the message is confirmed. |
189 */ |
523 */ |
190 warn : function() { |
524 warn : function() { |
191 var msg = commonL10n.warnDelete || ''; |
525 if ( confirm( __( 'You are about to permanently delete these items from your site.\nThis action cannot be undone.\n\'Cancel\' to stop, \'OK\' to delete.' ) ) ) { |
192 if ( confirm(msg) ) { |
|
193 return true; |
526 return true; |
194 } |
527 } |
195 |
528 |
196 return false; |
529 return false; |
197 }, |
530 }, |
215 * |
548 * |
216 * @type {{element: null, toggles: null, page: null, init: screenMeta.init, |
549 * @type {{element: null, toggles: null, page: null, init: screenMeta.init, |
217 * toggleEvent: screenMeta.toggleEvent, open: screenMeta.open, |
550 * toggleEvent: screenMeta.toggleEvent, open: screenMeta.open, |
218 * close: screenMeta.close}} |
551 * close: screenMeta.close}} |
219 * |
552 * |
220 * @returns {void} |
553 * @return {void} |
221 */ |
554 */ |
222 window.screenMeta = { |
555 window.screenMeta = { |
223 element: null, // #screen-meta |
556 element: null, // #screen-meta |
224 toggles: null, // .screen-meta-toggle |
557 toggles: null, // .screen-meta-toggle |
225 page: null, // #wpcontent |
558 page: null, // #wpcontent |
227 /** |
560 /** |
228 * Initializes the screen meta options panel. |
561 * Initializes the screen meta options panel. |
229 * |
562 * |
230 * @since 3.2.0 |
563 * @since 3.2.0 |
231 * |
564 * |
232 * @returns {void} |
565 * @return {void} |
233 */ |
566 */ |
234 init: function() { |
567 init: function() { |
235 this.element = $('#screen-meta'); |
568 this.element = $('#screen-meta'); |
236 this.toggles = $( '#screen-meta-links' ).find( '.show-settings' ); |
569 this.toggles = $( '#screen-meta-links' ).find( '.show-settings' ); |
237 this.page = $('#wpcontent'); |
570 this.page = $('#wpcontent'); |
242 /** |
575 /** |
243 * Toggles the screen meta options panel. |
576 * Toggles the screen meta options panel. |
244 * |
577 * |
245 * @since 3.2.0 |
578 * @since 3.2.0 |
246 * |
579 * |
247 * @returns {void} |
580 * @return {void} |
248 */ |
581 */ |
249 toggleEvent: function() { |
582 toggleEvent: function() { |
250 var panel = $( '#' + $( this ).attr( 'aria-controls' ) ); |
583 var panel = $( '#' + $( this ).attr( 'aria-controls' ) ); |
251 |
584 |
252 if ( !panel.length ) |
585 if ( !panel.length ) |
264 * @since 3.2.0 |
597 * @since 3.2.0 |
265 * |
598 * |
266 * @param {jQuery} panel The screen meta options panel div. |
599 * @param {jQuery} panel The screen meta options panel div. |
267 * @param {jQuery} button The toggle button. |
600 * @param {jQuery} button The toggle button. |
268 * |
601 * |
269 * @returns {void} |
602 * @return {void} |
270 */ |
603 */ |
271 open: function( panel, button ) { |
604 open: function( panel, button ) { |
272 |
605 |
273 $( '#screen-meta-links' ).find( '.screen-meta-toggle' ).not( button.parent() ).css( 'visibility', 'hidden' ); |
606 $( '#screen-meta-links' ).find( '.screen-meta-toggle' ).not( button.parent() ).css( 'visibility', 'hidden' ); |
274 |
607 |
277 /** |
610 /** |
278 * Sets the focus to the meta options panel and adds the necessary CSS classes. |
611 * Sets the focus to the meta options panel and adds the necessary CSS classes. |
279 * |
612 * |
280 * @since 3.2.0 |
613 * @since 3.2.0 |
281 * |
614 * |
282 * @returns {void} |
615 * @return {void} |
283 */ |
616 */ |
284 panel.slideDown( 'fast', function() { |
617 panel.slideDown( 'fast', function() { |
285 panel.focus(); |
618 panel.focus(); |
286 button.addClass( 'screen-meta-active' ).attr( 'aria-expanded', true ); |
619 button.addClass( 'screen-meta-active' ).attr( 'aria-expanded', true ); |
287 }); |
620 }); |
295 * @since 3.2.0 |
628 * @since 3.2.0 |
296 * |
629 * |
297 * @param {jQuery} panel The screen meta options panel div. |
630 * @param {jQuery} panel The screen meta options panel div. |
298 * @param {jQuery} button The toggle button. |
631 * @param {jQuery} button The toggle button. |
299 * |
632 * |
300 * @returns {void} |
633 * @return {void} |
301 */ |
634 */ |
302 close: function( panel, button ) { |
635 close: function( panel, button ) { |
303 /** |
636 /** |
304 * Hides the screen meta options panel. |
637 * Hides the screen meta options panel. |
305 * |
638 * |
306 * @since 3.2.0 |
639 * @since 3.2.0 |
307 * |
640 * |
308 * @returns {void} |
641 * @return {void} |
309 */ |
642 */ |
310 panel.slideUp( 'fast', function() { |
643 panel.slideUp( 'fast', function() { |
311 button.removeClass( 'screen-meta-active' ).attr( 'aria-expanded', false ); |
644 button.removeClass( 'screen-meta-active' ).attr( 'aria-expanded', false ); |
312 $('.screen-meta-toggle').css('visibility', ''); |
645 $('.screen-meta-toggle').css('visibility', ''); |
313 panel.parent().hide(); |
646 panel.parent().hide(); |
320 /** |
653 /** |
321 * Initializes the help tabs in the help panel. |
654 * Initializes the help tabs in the help panel. |
322 * |
655 * |
323 * @param {Event} e The event object. |
656 * @param {Event} e The event object. |
324 * |
657 * |
325 * @returns {void} |
658 * @return {void} |
326 */ |
659 */ |
327 $('.contextual-help-tabs').delegate('a', 'click', function(e) { |
660 $('.contextual-help-tabs').delegate('a', 'click', function(e) { |
328 var link = $(this), |
661 var link = $(this), |
329 panel; |
662 panel; |
330 |
663 |
332 |
665 |
333 // Don't do anything if the click is for the tab already showing. |
666 // Don't do anything if the click is for the tab already showing. |
334 if ( link.is('.active a') ) |
667 if ( link.is('.active a') ) |
335 return false; |
668 return false; |
336 |
669 |
337 // Links |
670 // Links. |
338 $('.contextual-help-tabs .active').removeClass('active'); |
671 $('.contextual-help-tabs .active').removeClass('active'); |
339 link.parent('li').addClass('active'); |
672 link.parent('li').addClass('active'); |
340 |
673 |
341 panel = $( link.attr('href') ); |
674 panel = $( link.attr('href') ); |
342 |
675 |
343 // Panels |
676 // Panels. |
344 $('.help-tab-content').not( panel ).removeClass('active').hide(); |
677 $('.help-tab-content').not( panel ).removeClass('active').hide(); |
345 panel.addClass('active').show(); |
678 panel.addClass('active').show(); |
346 }); |
679 }); |
347 |
680 |
348 /** |
681 /** |
382 * Enables or disables a structure tag button depending on its usage. |
715 * Enables or disables a structure tag button depending on its usage. |
383 * |
716 * |
384 * If the structure is already used in the custom permalink structure, |
717 * If the structure is already used in the custom permalink structure, |
385 * it will be disabled. |
718 * it will be disabled. |
386 * |
719 * |
387 * @param {object} button Button jQuery object. |
720 * @param {Object} button Button jQuery object. |
388 */ |
721 */ |
389 function changeStructureTagButtonState( button ) { |
722 function changeStructureTagButtonState( button ) { |
390 if ( -1 !== $permalinkStructure.val().indexOf( button.text().trim() ) ) { |
723 if ( -1 !== $permalinkStructure.val().indexOf( button.text().trim() ) ) { |
391 button.attr( 'data-label', button.attr( 'aria-label' ) ); |
724 button.attr( 'data-label', button.attr( 'aria-label' ) ); |
392 button.attr( 'aria-label', button.attr( 'data-used' ) ); |
725 button.attr( 'aria-label', button.attr( 'data-used' ) ); |
472 lastClicked = false, |
805 lastClicked = false, |
473 pageInput = $('input.current-page'), |
806 pageInput = $('input.current-page'), |
474 currentPage = pageInput.val(), |
807 currentPage = pageInput.val(), |
475 isIOS = /iPhone|iPad|iPod/.test( navigator.userAgent ), |
808 isIOS = /iPhone|iPad|iPod/.test( navigator.userAgent ), |
476 isAndroid = navigator.userAgent.indexOf( 'Android' ) !== -1, |
809 isAndroid = navigator.userAgent.indexOf( 'Android' ) !== -1, |
477 isIE8 = $( document.documentElement ).hasClass( 'ie8' ), |
|
478 $adminMenuWrap = $( '#adminmenuwrap' ), |
810 $adminMenuWrap = $( '#adminmenuwrap' ), |
479 $wpwrap = $( '#wpwrap' ), |
811 $wpwrap = $( '#wpwrap' ), |
480 $adminmenu = $( '#adminmenu' ), |
812 $adminmenu = $( '#adminmenu' ), |
481 $overlay = $( '#wp-responsive-overlay' ), |
813 $overlay = $( '#wp-responsive-overlay' ), |
482 $toolbar = $( '#wp-toolbar' ), |
814 $toolbar = $( '#wp-toolbar' ), |
501 /** |
833 /** |
502 * Makes the fly-out submenu header clickable, when the menu is folded. |
834 * Makes the fly-out submenu header clickable, when the menu is folded. |
503 * |
835 * |
504 * @param {Event} e The event object. |
836 * @param {Event} e The event object. |
505 * |
837 * |
506 * @returns {void} |
838 * @return {void} |
507 */ |
839 */ |
508 $adminmenu.on('click.wp-submenu-head', '.wp-submenu-head', function(e){ |
840 $adminmenu.on('click.wp-submenu-head', '.wp-submenu-head', function(e){ |
509 $(e.target).parent().siblings('a').get(0).click(); |
841 $(e.target).parent().siblings('a').get(0).click(); |
510 }); |
842 }); |
511 |
843 |
512 /** |
844 /** |
513 * Collapses the admin menu. |
845 * Collapses the admin menu. |
514 * |
846 * |
515 * @returns {void} |
847 * @return {void} |
516 */ |
848 */ |
517 $( '#collapse-button' ).on( 'click.collapse-menu', function() { |
849 $( '#collapse-button' ).on( 'click.collapse-menu', function() { |
518 var viewportWidth = getViewportWidth() || 961; |
850 var viewportWidth = getViewportWidth() || 961; |
519 |
851 |
520 // reset any compensation for submenus near the bottom of the screen |
852 // Reset any compensation for submenus near the bottom of the screen. |
521 $('#adminmenu div.wp-submenu').css('margin-top', ''); |
853 $('#adminmenu div.wp-submenu').css('margin-top', ''); |
522 |
854 |
523 if ( viewportWidth < 960 ) { |
855 if ( viewportWidth < 960 ) { |
524 if ( $body.hasClass('auto-fold') ) { |
856 if ( $body.hasClass('auto-fold') ) { |
525 $body.removeClass('auto-fold').removeClass('folded'); |
857 $body.removeClass('auto-fold').removeClass('folded'); |
549 /** |
881 /** |
550 * Handles the `aria-haspopup` attribute on the current menu item when it has a submenu. |
882 * Handles the `aria-haspopup` attribute on the current menu item when it has a submenu. |
551 * |
883 * |
552 * @since 4.4.0 |
884 * @since 4.4.0 |
553 * |
885 * |
554 * @returns {void} |
886 * @return {void} |
555 */ |
887 */ |
556 function currentMenuItemHasPopup() { |
888 function currentMenuItemHasPopup() { |
557 var $current = $( 'a.wp-has-current-submenu' ); |
889 var $current = $( 'a.wp-has-current-submenu' ); |
558 |
890 |
559 if ( 'folded' === menuState ) { |
891 if ( 'folded' === menuState ) { |
572 * |
904 * |
573 * @since 4.1.0 |
905 * @since 4.1.0 |
574 * |
906 * |
575 * @param {jQuery} $menuItem The parent menu item containing the submenu. |
907 * @param {jQuery} $menuItem The parent menu item containing the submenu. |
576 * |
908 * |
577 * @returns {void} |
909 * @return {void} |
578 */ |
910 */ |
579 function adjustSubmenu( $menuItem ) { |
911 function adjustSubmenu( $menuItem ) { |
580 var bottomOffset, pageHeight, adjustment, theFold, menutop, wintop, maxtop, |
912 var bottomOffset, pageHeight, adjustment, theFold, menutop, wintop, maxtop, |
581 $submenu = $menuItem.find( '.wp-submenu' ); |
913 $submenu = $menuItem.find( '.wp-submenu' ); |
582 |
914 |
583 menutop = $menuItem.offset().top; |
915 menutop = $menuItem.offset().top; |
584 wintop = $window.scrollTop(); |
916 wintop = $window.scrollTop(); |
585 maxtop = menutop - wintop - 30; // max = make the top of the sub almost touch admin bar |
917 maxtop = menutop - wintop - 30; // max = make the top of the sub almost touch admin bar. |
586 |
918 |
587 bottomOffset = menutop + $submenu.height() + 1; // Bottom offset of the menu |
919 bottomOffset = menutop + $submenu.height() + 1; // Bottom offset of the menu. |
588 pageHeight = $wpwrap.height(); // Height of the entire page |
920 pageHeight = $wpwrap.height(); // Height of the entire page. |
589 adjustment = 60 + bottomOffset - pageHeight; |
921 adjustment = 60 + bottomOffset - pageHeight; |
590 theFold = $window.height() + wintop - 50; // The fold |
922 theFold = $window.height() + wintop - 50; // The fold. |
591 |
923 |
592 if ( theFold < ( bottomOffset - adjustment ) ) { |
924 if ( theFold < ( bottomOffset - adjustment ) ) { |
593 adjustment = bottomOffset - theFold; |
925 adjustment = bottomOffset - theFold; |
594 } |
926 } |
595 |
927 |
602 } else { |
934 } else { |
603 $submenu.css( 'margin-top', '' ); |
935 $submenu.css( 'margin-top', '' ); |
604 } |
936 } |
605 } |
937 } |
606 |
938 |
607 if ( 'ontouchstart' in window || /IEMobile\/[1-9]/.test(navigator.userAgent) ) { // touch screen device |
939 if ( 'ontouchstart' in window || /IEMobile\/[1-9]/.test(navigator.userAgent) ) { // Touch screen device. |
608 // iOS Safari works with touchstart, the rest work with click |
940 // iOS Safari works with touchstart, the rest work with click. |
609 mobileEvent = isIOS ? 'touchstart' : 'click'; |
941 mobileEvent = isIOS ? 'touchstart' : 'click'; |
610 |
942 |
611 /** |
943 /** |
612 * Closes any open submenus when touch/click is not on the menu. |
944 * Closes any open submenus when touch/click is not on the menu. |
613 * |
945 * |
614 * @param {Event} e The event object. |
946 * @param {Event} e The event object. |
615 * |
947 * |
616 * @returns {void} |
948 * @return {void} |
617 */ |
949 */ |
618 $body.on( mobileEvent+'.wp-mobile-hover', function(e) { |
950 $body.on( mobileEvent+'.wp-mobile-hover', function(e) { |
619 if ( $adminmenu.data('wp-responsive') ) { |
951 if ( $adminmenu.data('wp-responsive') ) { |
620 return; |
952 return; |
621 } |
953 } |
628 /** |
960 /** |
629 * Handles the opening or closing the submenu based on the mobile click|touch event. |
961 * Handles the opening or closing the submenu based on the mobile click|touch event. |
630 * |
962 * |
631 * @param {Event} event The event object. |
963 * @param {Event} event The event object. |
632 * |
964 * |
633 * @returns {void} |
965 * @return {void} |
634 */ |
966 */ |
635 $adminmenu.find( 'a.wp-has-submenu' ).on( mobileEvent + '.wp-mobile-hover', function( event ) { |
967 $adminmenu.find( 'a.wp-has-submenu' ).on( mobileEvent + '.wp-mobile-hover', function( event ) { |
636 var $menuItem = $(this).parent(); |
968 var $menuItem = $(this).parent(); |
637 |
969 |
638 if ( $adminmenu.data( 'wp-responsive' ) ) { |
970 if ( $adminmenu.data( 'wp-responsive' ) ) { |
639 return; |
971 return; |
640 } |
972 } |
641 |
973 |
642 // Show the sub instead of following the link if: |
974 /* |
643 // - the submenu is not open |
975 * Show the sub instead of following the link if: |
644 // - the submenu is not shown inline or the menu is not folded |
976 * - the submenu is not open. |
977 * - the submenu is not shown inline or the menu is not folded. |
|
978 */ |
|
645 if ( ! $menuItem.hasClass( 'opensub' ) && ( ! $menuItem.hasClass( 'wp-menu-open' ) || $menuItem.width() < 40 ) ) { |
979 if ( ! $menuItem.hasClass( 'opensub' ) && ( ! $menuItem.hasClass( 'wp-menu-open' ) || $menuItem.width() < 40 ) ) { |
646 event.preventDefault(); |
980 event.preventDefault(); |
647 adjustSubmenu( $menuItem ); |
981 adjustSubmenu( $menuItem ); |
648 $adminmenu.find( 'li.opensub' ).removeClass( 'opensub' ); |
982 $adminmenu.find( 'li.opensub' ).removeClass( 'opensub' ); |
649 $menuItem.addClass('opensub'); |
983 $menuItem.addClass('opensub'); |
655 $adminmenu.find( 'li.wp-has-submenu' ).hoverIntent({ |
989 $adminmenu.find( 'li.wp-has-submenu' ).hoverIntent({ |
656 |
990 |
657 /** |
991 /** |
658 * Opens the submenu when hovered over the menu item for desktops. |
992 * Opens the submenu when hovered over the menu item for desktops. |
659 * |
993 * |
660 * @returns {void} |
994 * @return {void} |
661 */ |
995 */ |
662 over: function() { |
996 over: function() { |
663 var $menuItem = $( this ), |
997 var $menuItem = $( this ), |
664 $submenu = $menuItem.find( '.wp-submenu' ), |
998 $submenu = $menuItem.find( '.wp-submenu' ), |
665 top = parseInt( $submenu.css( 'top' ), 10 ); |
999 top = parseInt( $submenu.css( 'top' ), 10 ); |
666 |
1000 |
667 if ( isNaN( top ) || top > -5 ) { // the submenu is visible |
1001 if ( isNaN( top ) || top > -5 ) { // The submenu is visible. |
668 return; |
1002 return; |
669 } |
1003 } |
670 |
1004 |
671 if ( $adminmenu.data( 'wp-responsive' ) ) { |
1005 if ( $adminmenu.data( 'wp-responsive' ) ) { |
672 // The menu is in responsive mode, bail |
1006 // The menu is in responsive mode, bail. |
673 return; |
1007 return; |
674 } |
1008 } |
675 |
1009 |
676 adjustSubmenu( $menuItem ); |
1010 adjustSubmenu( $menuItem ); |
677 $adminmenu.find( 'li.opensub' ).removeClass( 'opensub' ); |
1011 $adminmenu.find( 'li.opensub' ).removeClass( 'opensub' ); |
679 }, |
1013 }, |
680 |
1014 |
681 /** |
1015 /** |
682 * Closes the submenu when no longer hovering the menu item. |
1016 * Closes the submenu when no longer hovering the menu item. |
683 * |
1017 * |
684 * @returns {void} |
1018 * @return {void} |
685 */ |
1019 */ |
686 out: function(){ |
1020 out: function(){ |
687 if ( $adminmenu.data( 'wp-responsive' ) ) { |
1021 if ( $adminmenu.data( 'wp-responsive' ) ) { |
688 // The menu is in responsive mode, bail |
1022 // The menu is in responsive mode, bail. |
689 return; |
1023 return; |
690 } |
1024 } |
691 |
1025 |
692 $( this ).removeClass( 'opensub' ).find( '.wp-submenu' ).css( 'margin-top', '' ); |
1026 $( this ).removeClass( 'opensub' ).find( '.wp-submenu' ).css( 'margin-top', '' ); |
693 }, |
1027 }, |
699 /** |
1033 /** |
700 * Opens the submenu on when focused on the menu item. |
1034 * Opens the submenu on when focused on the menu item. |
701 * |
1035 * |
702 * @param {Event} event The event object. |
1036 * @param {Event} event The event object. |
703 * |
1037 * |
704 * @returns {void} |
1038 * @return {void} |
705 */ |
1039 */ |
706 $adminmenu.on( 'focus.adminmenu', '.wp-submenu a', function( event ) { |
1040 $adminmenu.on( 'focus.adminmenu', '.wp-submenu a', function( event ) { |
707 if ( $adminmenu.data( 'wp-responsive' ) ) { |
1041 if ( $adminmenu.data( 'wp-responsive' ) ) { |
708 // The menu is in responsive mode, bail |
1042 // The menu is in responsive mode, bail. |
709 return; |
1043 return; |
710 } |
1044 } |
711 |
1045 |
712 $( event.target ).closest( 'li.menu-top' ).addClass( 'opensub' ); |
1046 $( event.target ).closest( 'li.menu-top' ).addClass( 'opensub' ); |
713 |
1047 |
714 /** |
1048 /** |
715 * Closes the submenu on blur from the menu item. |
1049 * Closes the submenu on blur from the menu item. |
716 * |
1050 * |
717 * @param {Event} event The event object. |
1051 * @param {Event} event The event object. |
718 * |
1052 * |
719 * @returns {void} |
1053 * @return {void} |
720 */ |
1054 */ |
721 }).on( 'blur.adminmenu', '.wp-submenu a', function( event ) { |
1055 }).on( 'blur.adminmenu', '.wp-submenu a', function( event ) { |
722 if ( $adminmenu.data( 'wp-responsive' ) ) { |
1056 if ( $adminmenu.data( 'wp-responsive' ) ) { |
723 return; |
1057 return; |
724 } |
1058 } |
726 $( event.target ).closest( 'li.menu-top' ).removeClass( 'opensub' ); |
1060 $( event.target ).closest( 'li.menu-top' ).removeClass( 'opensub' ); |
727 |
1061 |
728 /** |
1062 /** |
729 * Adjusts the size for the submenu. |
1063 * Adjusts the size for the submenu. |
730 * |
1064 * |
731 * @returns {void} |
1065 * @return {void} |
732 */ |
1066 */ |
733 }).find( 'li.wp-has-submenu.wp-not-current-submenu' ).on( 'focusin.adminmenu', function() { |
1067 }).find( 'li.wp-has-submenu.wp-not-current-submenu' ).on( 'focusin.adminmenu', function() { |
734 adjustSubmenu( $( this ) ); |
1068 adjustSubmenu( $( this ) ); |
735 }); |
1069 }); |
736 } |
1070 } |
749 /** |
1083 /** |
750 * Makes notices dismissible. |
1084 * Makes notices dismissible. |
751 * |
1085 * |
752 * @since 4.4.0 |
1086 * @since 4.4.0 |
753 * |
1087 * |
754 * @returns {void} |
1088 * @return {void} |
755 */ |
1089 */ |
756 function makeNoticesDismissible() { |
1090 function makeNoticesDismissible() { |
757 $( '.notice.is-dismissible' ).each( function() { |
1091 $( '.notice.is-dismissible' ).each( function() { |
758 var $el = $( this ), |
1092 var $el = $( this ), |
759 $button = $( '<button type="button" class="notice-dismiss"><span class="screen-reader-text"></span></button>' ), |
1093 $button = $( '<button type="button" class="notice-dismiss"><span class="screen-reader-text"></span></button>' ); |
760 btnText = commonL10n.dismiss || ''; |
1094 |
761 |
1095 // Ensure plain text. |
762 // Ensure plain text |
1096 $button.find( '.screen-reader-text' ).text( __( 'Dismiss this notice.' ) ); |
763 $button.find( '.screen-reader-text' ).text( btnText ); |
|
764 $button.on( 'click.wp-dismiss-notice', function( event ) { |
1097 $button.on( 'click.wp-dismiss-notice', function( event ) { |
765 event.preventDefault(); |
1098 event.preventDefault(); |
766 $el.fadeTo( 100, 0, function() { |
1099 $el.fadeTo( 100, 0, function() { |
767 $el.slideUp( 100, function() { |
1100 $el.slideUp( 100, function() { |
768 $el.remove(); |
1101 $el.remove(); |
774 }); |
1107 }); |
775 } |
1108 } |
776 |
1109 |
777 $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 ); |
1110 $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 ); |
778 |
1111 |
779 // Init screen meta |
1112 // Init screen meta. |
780 screenMeta.init(); |
1113 screenMeta.init(); |
781 |
1114 |
782 /** |
1115 /** |
783 * Checks a checkbox. |
1116 * Checks a checkbox. |
784 * |
1117 * |
785 * This event needs to be delegated. Ticket #37973. |
1118 * This event needs to be delegated. Ticket #37973. |
786 * |
1119 * |
787 * @returns {boolean} Returns whether a checkbox is checked or not. |
1120 * @return {boolean} Returns whether a checkbox is checked or not. |
788 */ |
1121 */ |
789 $body.on( 'click', 'tbody > tr > .check-column :checkbox', function( event ) { |
1122 $body.on( 'click', 'tbody > tr > .check-column :checkbox', function( event ) { |
790 // Shift click to select a range of checkboxes. |
1123 // Shift click to select a range of checkboxes. |
791 if ( 'undefined' == event.shiftKey ) { return true; } |
1124 if ( 'undefined' == event.shiftKey ) { return true; } |
792 if ( event.shiftKey ) { |
1125 if ( event.shiftKey ) { |
811 var unchecked = $(this).closest('tbody').find(':checkbox').filter(':visible:enabled').not(':checked'); |
1144 var unchecked = $(this).closest('tbody').find(':checkbox').filter(':visible:enabled').not(':checked'); |
812 |
1145 |
813 /** |
1146 /** |
814 * Determines if all checkboxes are checked. |
1147 * Determines if all checkboxes are checked. |
815 * |
1148 * |
816 * @returns {boolean} Returns true if there are no unchecked checkboxes. |
1149 * @return {boolean} Returns true if there are no unchecked checkboxes. |
817 */ |
1150 */ |
818 $(this).closest('table').children('thead, tfoot').find(':checkbox').prop('checked', function() { |
1151 $(this).closest('table').children('thead, tfoot').find(':checkbox').prop('checked', function() { |
819 return ( 0 === unchecked.length ); |
1152 return ( 0 === unchecked.length ); |
820 }); |
1153 }); |
821 |
1154 |
830 * |
1163 * |
831 * This event needs to be delegated. Ticket #37973. |
1164 * This event needs to be delegated. Ticket #37973. |
832 * |
1165 * |
833 * @param {Event} event The event object. |
1166 * @param {Event} event The event object. |
834 * |
1167 * |
835 * @returns {boolean} |
1168 * @return {boolean} |
836 */ |
1169 */ |
837 $body.on( 'click.wp-toggle-checkboxes', 'thead .check-column :checkbox, tfoot .check-column :checkbox', function( event ) { |
1170 $body.on( 'click.wp-toggle-checkboxes', 'thead .check-column :checkbox, tfoot .check-column :checkbox', function( event ) { |
838 var $this = $(this), |
1171 var $this = $(this), |
839 $table = $this.closest( 'table' ), |
1172 $table = $this.closest( 'table' ), |
840 controlChecked = $this.prop('checked'), |
1173 controlChecked = $this.prop('checked'), |
843 $table.children( 'tbody' ).filter(':visible') |
1176 $table.children( 'tbody' ).filter(':visible') |
844 .children().children('.check-column').find(':checkbox') |
1177 .children().children('.check-column').find(':checkbox') |
845 /** |
1178 /** |
846 * Updates the checked state on the checkbox in the table. |
1179 * Updates the checked state on the checkbox in the table. |
847 * |
1180 * |
848 * @returns {boolean} True checks the checkbox, False unchecks the checkbox. |
1181 * @return {boolean} True checks the checkbox, False unchecks the checkbox. |
849 */ |
1182 */ |
850 .prop('checked', function() { |
1183 .prop('checked', function() { |
851 if ( $(this).is(':hidden,:disabled') ) { |
1184 if ( $(this).is(':hidden,:disabled') ) { |
852 return false; |
1185 return false; |
853 } |
1186 } |
865 .children().children('.check-column').find(':checkbox') |
1198 .children().children('.check-column').find(':checkbox') |
866 |
1199 |
867 /** |
1200 /** |
868 * Syncs the bulk checkboxes on the top and bottom of the table. |
1201 * Syncs the bulk checkboxes on the top and bottom of the table. |
869 * |
1202 * |
870 * @returns {boolean} True checks the checkbox, False unchecks the checkbox. |
1203 * @return {boolean} True checks the checkbox, False unchecks the checkbox. |
871 */ |
1204 */ |
872 .prop('checked', function() { |
1205 .prop('checked', function() { |
873 if ( toggle ) { |
1206 if ( toggle ) { |
874 return false; |
1207 return false; |
875 } else if ( controlChecked ) { |
1208 } else if ( controlChecked ) { |
881 }); |
1214 }); |
882 |
1215 |
883 /** |
1216 /** |
884 * Shows row actions on focus of its parent container element or any other elements contained within. |
1217 * Shows row actions on focus of its parent container element or any other elements contained within. |
885 * |
1218 * |
886 * @returns {void} |
1219 * @return {void} |
887 */ |
1220 */ |
888 $( '#wpbody-content' ).on({ |
1221 $( '#wpbody-content' ).on({ |
889 focusin: function() { |
1222 focusin: function() { |
890 clearTimeout( transitionTimeout ); |
1223 clearTimeout( transitionTimeout ); |
891 focusedRowActions = $( this ).find( '.row-actions' ); |
1224 focusedRowActions = $( this ).find( '.row-actions' ); |
900 focusedRowActions.removeClass( 'visible' ); |
1233 focusedRowActions.removeClass( 'visible' ); |
901 }, 30 ); |
1234 }, 30 ); |
902 } |
1235 } |
903 }, '.has-row-actions' ); |
1236 }, '.has-row-actions' ); |
904 |
1237 |
905 // Toggle list table rows on small screens |
1238 // Toggle list table rows on small screens. |
906 $( 'tbody' ).on( 'click', '.toggle-row', function() { |
1239 $( 'tbody' ).on( 'click', '.toggle-row', function() { |
907 $( this ).closest( 'tr' ).toggleClass( 'is-expanded' ); |
1240 $( this ).closest( 'tr' ).toggleClass( 'is-expanded' ); |
908 }); |
1241 }); |
909 |
1242 |
910 $('#default-password-nag-no').click( function() { |
1243 $('#default-password-nag-no').click( function() { |
916 /** |
1249 /** |
917 * Handles tab keypresses in theme and plugin editor textareas. |
1250 * Handles tab keypresses in theme and plugin editor textareas. |
918 * |
1251 * |
919 * @param {Event} e The event object. |
1252 * @param {Event} e The event object. |
920 * |
1253 * |
921 * @returns {void} |
1254 * @return {void} |
922 */ |
1255 */ |
923 $('#newcontent').bind('keydown.wpevent_InsertTab', function(e) { |
1256 $('#newcontent').bind('keydown.wpevent_InsertTab', function(e) { |
924 var el = e.target, selStart, selEnd, val, scroll, sel; |
1257 var el = e.target, selStart, selEnd, val, scroll, sel; |
925 |
1258 |
926 // After pressing escape key (keyCode: 27), the tab key should tab out of the textarea. |
1259 // After pressing escape key (keyCode: 27), the tab key should tab out of the textarea. |
927 if ( e.keyCode == 27 ) { |
1260 if ( e.keyCode == 27 ) { |
928 // when pressing Escape: Opera 12 and 27 blur form fields, IE 8 clears them |
1261 // When pressing Escape: Opera 12 and 27 blur form fields, IE 8 clears them. |
929 e.preventDefault(); |
1262 e.preventDefault(); |
930 $(el).data('tab-out', true); |
1263 $(el).data('tab-out', true); |
931 return; |
1264 return; |
932 } |
1265 } |
933 |
1266 |
975 * |
1308 * |
976 * The pagination argument should not be touched when the bulk action dropdowns are set to do anything. |
1309 * The pagination argument should not be touched when the bulk action dropdowns are set to do anything. |
977 * |
1310 * |
978 * The form closest to the pageInput is the post-filter form. |
1311 * The form closest to the pageInput is the post-filter form. |
979 * |
1312 * |
980 * @returns {void} |
1313 * @return {void} |
981 */ |
1314 */ |
982 pageInput.closest('form').submit( function() { |
1315 pageInput.closest('form').submit( function() { |
983 /* |
1316 /* |
984 * action = bulk action dropdown at the top of the table |
1317 * action = bulk action dropdown at the top of the table |
985 * action2 = bulk action dropdow at the bottom of the table |
1318 * action2 = bulk action dropdow at the bottom of the table |
990 } |
1323 } |
991 |
1324 |
992 /** |
1325 /** |
993 * Resets the bulk actions when the search button is clicked. |
1326 * Resets the bulk actions when the search button is clicked. |
994 * |
1327 * |
995 * @returns {void} |
1328 * @return {void} |
996 */ |
1329 */ |
997 $('.search-box input[type="search"], .search-box input[type="submit"]').mousedown(function () { |
1330 $('.search-box input[type="search"], .search-box input[type="submit"]').mousedown(function () { |
998 $('select[name^="action"]').val('-1'); |
1331 $('select[name^="action"]').val('-1'); |
999 }); |
1332 }); |
1000 |
1333 |
1001 /** |
1334 /** |
1002 * Scrolls into view when focus.scroll-into-view is triggered. |
1335 * Scrolls into view when focus.scroll-into-view is triggered. |
1003 * |
1336 * |
1004 * @param {Event} e The event object. |
1337 * @param {Event} e The event object. |
1005 * |
1338 * |
1006 * @returns {void} |
1339 * @return {void} |
1007 */ |
1340 */ |
1008 $('#contextual-help-link, #show-settings-link').on( 'focus.scroll-into-view', function(e){ |
1341 $('#contextual-help-link, #show-settings-link').on( 'focus.scroll-into-view', function(e){ |
1009 if ( e.target.scrollIntoView ) |
1342 if ( e.target.scrollIntoView ) |
1010 e.target.scrollIntoView(false); |
1343 e.target.scrollIntoView(false); |
1011 }); |
1344 }); |
1012 |
1345 |
1013 /** |
1346 /** |
1014 * Disables the submit upload buttons when no data is entered. |
1347 * Disables the submit upload buttons when no data is entered. |
1015 * |
1348 * |
1016 * @returns {void} |
1349 * @return {void} |
1017 */ |
1350 */ |
1018 (function(){ |
1351 (function(){ |
1019 var button, input, form = $('form.wp-upload-form'); |
1352 var button, input, form = $('form.wp-upload-form'); |
1020 |
1353 |
1021 // Exit when no upload form is found. |
1354 // Exit when no upload form is found. |
1028 /** |
1361 /** |
1029 * Determines if any data is entered in any file upload input. |
1362 * Determines if any data is entered in any file upload input. |
1030 * |
1363 * |
1031 * @since 3.5.0 |
1364 * @since 3.5.0 |
1032 * |
1365 * |
1033 * @returns {void} |
1366 * @return {void} |
1034 */ |
1367 */ |
1035 function toggleUploadButton() { |
1368 function toggleUploadButton() { |
1036 // When no inputs have a value, disable the upload buttons. |
1369 // When no inputs have a value, disable the upload buttons. |
1037 button.prop('disabled', '' === input.map( function() { |
1370 button.prop('disabled', '' === input.map( function() { |
1038 return $(this).val(); |
1371 return $(this).val(); |
1050 * |
1383 * |
1051 * @param {Event} event Event data. |
1384 * @param {Event} event Event data. |
1052 * |
1385 * |
1053 * @since 4.1.0 |
1386 * @since 4.1.0 |
1054 * |
1387 * |
1055 * @returns {void} |
1388 * @return {void} |
1056 */ |
1389 */ |
1057 function pinMenu( event ) { |
1390 function pinMenu( event ) { |
1058 var windowPos = $window.scrollTop(), |
1391 var windowPos = $window.scrollTop(), |
1059 resizing = ! event || event.type !== 'scroll'; |
1392 resizing = ! event || event.type !== 'scroll'; |
1060 |
1393 |
1061 if ( isIOS || isIE8 || $adminmenu.data( 'wp-responsive' ) ) { |
1394 if ( isIOS || $adminmenu.data( 'wp-responsive' ) ) { |
1062 return; |
1395 return; |
1063 } |
1396 } |
1064 |
1397 |
1065 /* |
1398 /* |
1066 * When the menu is higher than the window and smaller than the entire page. |
1399 * When the menu is higher than the window and smaller than the entire page. |
1193 /** |
1526 /** |
1194 * Determines the height of certain elements. |
1527 * Determines the height of certain elements. |
1195 * |
1528 * |
1196 * @since 4.1.0 |
1529 * @since 4.1.0 |
1197 * |
1530 * |
1198 * @returns {void} |
1531 * @return {void} |
1199 */ |
1532 */ |
1200 function resetHeights() { |
1533 function resetHeights() { |
1201 height = { |
1534 height = { |
1202 window: $window.height(), |
1535 window: $window.height(), |
1203 wpwrap: $wpwrap.height(), |
1536 wpwrap: $wpwrap.height(), |
1209 /** |
1542 /** |
1210 * Unpins the menu. |
1543 * Unpins the menu. |
1211 * |
1544 * |
1212 * @since 4.1.0 |
1545 * @since 4.1.0 |
1213 * |
1546 * |
1214 * @returns {void} |
1547 * @return {void} |
1215 */ |
1548 */ |
1216 function unpinMenu() { |
1549 function unpinMenu() { |
1217 if ( isIOS || ! menuIsPinned ) { |
1550 if ( isIOS || ! menuIsPinned ) { |
1218 return; |
1551 return; |
1219 } |
1552 } |
1229 /** |
1562 /** |
1230 * Pins and unpins the menu when applicable. |
1563 * Pins and unpins the menu when applicable. |
1231 * |
1564 * |
1232 * @since 4.1.0 |
1565 * @since 4.1.0 |
1233 * |
1566 * |
1234 * @returns {void} |
1567 * @return {void} |
1235 */ |
1568 */ |
1236 function setPinMenu() { |
1569 function setPinMenu() { |
1237 resetHeights(); |
1570 resetHeights(); |
1238 |
1571 |
1239 if ( $adminmenu.data('wp-responsive') ) { |
1572 if ( $adminmenu.data('wp-responsive') ) { |
1258 /** |
1591 /** |
1259 * Changes the sortables and responsiveness of metaboxes. |
1592 * Changes the sortables and responsiveness of metaboxes. |
1260 * |
1593 * |
1261 * @since 3.8.0 |
1594 * @since 3.8.0 |
1262 * |
1595 * |
1263 *@returns {void} |
1596 * @return {void} |
1264 */ |
1597 */ |
1265 window.wpResponsive = { |
1598 window.wpResponsive = { |
1266 |
1599 |
1267 /** |
1600 /** |
1268 * Initializes the wpResponsive object. |
1601 * Initializes the wpResponsive object. |
1269 * |
1602 * |
1270 * @since 3.8.0 |
1603 * @since 3.8.0 |
1271 * |
1604 * |
1272 * @returns {void} |
1605 * @return {void} |
1273 */ |
1606 */ |
1274 init: function() { |
1607 init: function() { |
1275 var self = this; |
1608 var self = this; |
1276 |
1609 |
1277 // Modify functionality based on custom activate/deactivate event |
1610 this.maybeDisableSortables = this.maybeDisableSortables.bind( this ); |
1611 |
|
1612 // Modify functionality based on custom activate/deactivate event. |
|
1278 $document.on( 'wp-responsive-activate.wp-responsive', function() { |
1613 $document.on( 'wp-responsive-activate.wp-responsive', function() { |
1279 self.activate(); |
1614 self.activate(); |
1280 }).on( 'wp-responsive-deactivate.wp-responsive', function() { |
1615 }).on( 'wp-responsive-deactivate.wp-responsive', function() { |
1281 self.deactivate(); |
1616 self.deactivate(); |
1282 }); |
1617 }); |
1285 |
1620 |
1286 // Toggle sidebar when toggle is clicked. |
1621 // Toggle sidebar when toggle is clicked. |
1287 $( '#wp-admin-bar-menu-toggle' ).on( 'click.wp-responsive', function( event ) { |
1622 $( '#wp-admin-bar-menu-toggle' ).on( 'click.wp-responsive', function( event ) { |
1288 event.preventDefault(); |
1623 event.preventDefault(); |
1289 |
1624 |
1290 // close any open toolbar submenus. |
1625 // Close any open toolbar submenus. |
1291 $adminbar.find( '.hover' ).removeClass( 'hover' ); |
1626 $adminbar.find( '.hover' ).removeClass( 'hover' ); |
1292 |
1627 |
1293 $wpwrap.toggleClass( 'wp-responsive-open' ); |
1628 $wpwrap.toggleClass( 'wp-responsive-open' ); |
1294 if ( $wpwrap.hasClass( 'wp-responsive-open' ) ) { |
1629 if ( $wpwrap.hasClass( 'wp-responsive-open' ) ) { |
1295 $(this).find('a').attr( 'aria-expanded', 'true' ); |
1630 $(this).find('a').attr( 'aria-expanded', 'true' ); |
1311 |
1646 |
1312 self.trigger(); |
1647 self.trigger(); |
1313 $document.on( 'wp-window-resized.wp-responsive', $.proxy( this.trigger, this ) ); |
1648 $document.on( 'wp-window-resized.wp-responsive', $.proxy( this.trigger, this ) ); |
1314 |
1649 |
1315 // This needs to run later as UI Sortable may be initialized later on $(document).ready(). |
1650 // This needs to run later as UI Sortable may be initialized later on $(document).ready(). |
1316 $window.on( 'load.wp-responsive', function() { |
1651 $window.on( 'load.wp-responsive', this.maybeDisableSortables ); |
1317 var width = navigator.userAgent.indexOf('AppleWebKit/') > -1 ? $window.width() : window.innerWidth; |
1652 $document.on( 'postbox-toggled', this.maybeDisableSortables ); |
1318 |
1653 |
1319 if ( width <= 782 ) { |
1654 // When the screen columns are changed, potentially disable sortables. |
1320 self.disableSortables(); |
1655 $( '#screen-options-wrap input' ).on( 'click', this.maybeDisableSortables ); |
1321 } |
1656 }, |
1322 }); |
1657 |
1658 /** |
|
1659 * Disable sortables if there is only one metabox, or the screen is in one column mode. Otherwise, enable sortables. |
|
1660 * |
|
1661 * @since 5.3.0 |
|
1662 * |
|
1663 * @return {void} |
|
1664 */ |
|
1665 maybeDisableSortables: function() { |
|
1666 var width = navigator.userAgent.indexOf('AppleWebKit/') > -1 ? $window.width() : window.innerWidth; |
|
1667 |
|
1668 if ( |
|
1669 ( width <= 782 ) || |
|
1670 ( 1 >= $sortables.find( '.ui-sortable-handle:visible' ).length && jQuery( '.columns-prefs-1 input' ).prop( 'checked' ) ) |
|
1671 ) { |
|
1672 this.disableSortables(); |
|
1673 } else { |
|
1674 this.enableSortables(); |
|
1675 } |
|
1323 }, |
1676 }, |
1324 |
1677 |
1325 /** |
1678 /** |
1326 * Changes properties of body and admin menu. |
1679 * Changes properties of body and admin menu. |
1327 * |
1680 * |
1328 * Pins and unpins the menu and adds the auto-fold class to the body. |
1681 * Pins and unpins the menu and adds the auto-fold class to the body. |
1329 * Makes the admin menu responsive and disables the metabox sortables. |
1682 * Makes the admin menu responsive and disables the metabox sortables. |
1330 * |
1683 * |
1331 * @since 3.8.0 |
1684 * @since 3.8.0 |
1332 * |
1685 * |
1333 * @returns {void} |
1686 * @return {void} |
1334 */ |
1687 */ |
1335 activate: function() { |
1688 activate: function() { |
1336 setPinMenu(); |
1689 setPinMenu(); |
1337 |
1690 |
1338 if ( ! $body.hasClass( 'auto-fold' ) ) { |
1691 if ( ! $body.hasClass( 'auto-fold' ) ) { |
1349 * Pin and unpin the menu. |
1702 * Pin and unpin the menu. |
1350 * Removes the responsiveness of the admin menu and enables the metabox sortables. |
1703 * Removes the responsiveness of the admin menu and enables the metabox sortables. |
1351 * |
1704 * |
1352 * @since 3.8.0 |
1705 * @since 3.8.0 |
1353 * |
1706 * |
1354 * @returns {void} |
1707 * @return {void} |
1355 */ |
1708 */ |
1356 deactivate: function() { |
1709 deactivate: function() { |
1357 setPinMenu(); |
1710 setPinMenu(); |
1358 $adminmenu.removeData('wp-responsive'); |
1711 $adminmenu.removeData('wp-responsive'); |
1359 this.enableSortables(); |
1712 |
1713 this.maybeDisableSortables(); |
|
1360 }, |
1714 }, |
1361 |
1715 |
1362 /** |
1716 /** |
1363 * Sets the responsiveness and enables the overlay based on the viewport width. |
1717 * Sets the responsiveness and enables the overlay based on the viewport width. |
1364 * |
1718 * |
1365 * @since 3.8.0 |
1719 * @since 3.8.0 |
1366 * |
1720 * |
1367 * @returns {void} |
1721 * @return {void} |
1368 */ |
1722 */ |
1369 trigger: function() { |
1723 trigger: function() { |
1370 var viewportWidth = getViewportWidth(); |
1724 var viewportWidth = getViewportWidth(); |
1371 |
1725 |
1372 // Exclude IE < 9, it doesn't support @media CSS rules. |
1726 // Exclude IE < 9, it doesn't support @media CSS rules. |
1389 if ( viewportWidth <= 480 ) { |
1743 if ( viewportWidth <= 480 ) { |
1390 this.enableOverlay(); |
1744 this.enableOverlay(); |
1391 } else { |
1745 } else { |
1392 this.disableOverlay(); |
1746 this.disableOverlay(); |
1393 } |
1747 } |
1748 |
|
1749 this.maybeDisableSortables(); |
|
1394 }, |
1750 }, |
1395 |
1751 |
1396 /** |
1752 /** |
1397 * Inserts a responsive overlay and toggles the window. |
1753 * Inserts a responsive overlay and toggles the window. |
1398 * |
1754 * |
1399 * @since 3.8.0 |
1755 * @since 3.8.0 |
1400 * |
1756 * |
1401 * @returns {void} |
1757 * @return {void} |
1402 */ |
1758 */ |
1403 enableOverlay: function() { |
1759 enableOverlay: function() { |
1404 if ( $overlay.length === 0 ) { |
1760 if ( $overlay.length === 0 ) { |
1405 $overlay = $( '<div id="wp-responsive-overlay"></div>' ) |
1761 $overlay = $( '<div id="wp-responsive-overlay"></div>' ) |
1406 .insertAfter( '#wpcontent' ) |
1762 .insertAfter( '#wpcontent' ) |
1419 /** |
1775 /** |
1420 * Disables the responsive overlay and removes the overlay. |
1776 * Disables the responsive overlay and removes the overlay. |
1421 * |
1777 * |
1422 * @since 3.8.0 |
1778 * @since 3.8.0 |
1423 * |
1779 * |
1424 * @returns {void} |
1780 * @return {void} |
1425 */ |
1781 */ |
1426 disableOverlay: function() { |
1782 disableOverlay: function() { |
1427 $toolbarPopups.off( 'click.wp-responsive' ); |
1783 $toolbarPopups.off( 'click.wp-responsive' ); |
1428 $overlay.hide(); |
1784 $overlay.hide(); |
1429 }, |
1785 }, |
1431 /** |
1787 /** |
1432 * Disables sortables. |
1788 * Disables sortables. |
1433 * |
1789 * |
1434 * @since 3.8.0 |
1790 * @since 3.8.0 |
1435 * |
1791 * |
1436 * @returns {void} |
1792 * @return {void} |
1437 */ |
1793 */ |
1438 disableSortables: function() { |
1794 disableSortables: function() { |
1439 if ( $sortables.length ) { |
1795 if ( $sortables.length ) { |
1440 try { |
1796 try { |
1441 $sortables.sortable( 'disable' ); |
1797 $sortables.sortable( 'disable' ); |
1798 $sortables.find( '.ui-sortable-handle' ).addClass( 'is-non-sortable' ); |
|
1442 } catch ( e ) {} |
1799 } catch ( e ) {} |
1443 } |
1800 } |
1444 }, |
1801 }, |
1445 |
1802 |
1446 /** |
1803 /** |
1447 * Enables sortables. |
1804 * Enables sortables. |
1448 * |
1805 * |
1449 * @since 3.8.0 |
1806 * @since 3.8.0 |
1450 * |
1807 * |
1451 * @returns {void} |
1808 * @return {void} |
1452 */ |
1809 */ |
1453 enableSortables: function() { |
1810 enableSortables: function() { |
1454 if ( $sortables.length ) { |
1811 if ( $sortables.length ) { |
1455 try { |
1812 try { |
1456 $sortables.sortable( 'enable' ); |
1813 $sortables.sortable( 'enable' ); |
1814 $sortables.find( '.ui-sortable-handle' ).removeClass( 'is-non-sortable' ); |
|
1457 } catch ( e ) {} |
1815 } catch ( e ) {} |
1458 } |
1816 } |
1459 } |
1817 } |
1460 }; |
1818 }; |
1461 |
1819 |
1462 /** |
1820 /** |
1463 * Add an ARIA role `button` to elements that behave like UI controls when JavaScript is on. |
1821 * Add an ARIA role `button` to elements that behave like UI controls when JavaScript is on. |
1464 * |
1822 * |
1465 * @since 4.5.0 |
1823 * @since 4.5.0 |
1466 * |
1824 * |
1467 * @returns {void} |
1825 * @return {void} |
1468 */ |
1826 */ |
1469 function aria_button_if_js() { |
1827 function aria_button_if_js() { |
1470 $( '.aria-button-if-js' ).attr( 'role', 'button' ); |
1828 $( '.aria-button-if-js' ).attr( 'role', 'button' ); |
1471 } |
1829 } |
1472 |
1830 |
1477 /** |
1835 /** |
1478 * Get the viewport width. |
1836 * Get the viewport width. |
1479 * |
1837 * |
1480 * @since 4.7.0 |
1838 * @since 4.7.0 |
1481 * |
1839 * |
1482 * @returns {number|boolean} The current viewport width or false if the |
1840 * @return {number|boolean} The current viewport width or false if the |
1483 * browser doesn't support innerWidth (IE < 9). |
1841 * browser doesn't support innerWidth (IE < 9). |
1484 */ |
1842 */ |
1485 function getViewportWidth() { |
1843 function getViewportWidth() { |
1486 var viewportWidth = false; |
1844 var viewportWidth = false; |
1487 |
1845 |
1488 if ( window.innerWidth ) { |
1846 if ( window.innerWidth ) { |
1499 * Sets the global variable `menuState` and triggers a custom event passing |
1857 * Sets the global variable `menuState` and triggers a custom event passing |
1500 * the current menu state. |
1858 * the current menu state. |
1501 * |
1859 * |
1502 * @since 4.7.0 |
1860 * @since 4.7.0 |
1503 * |
1861 * |
1504 * @returns {void} |
1862 * @return {void} |
1505 */ |
1863 */ |
1506 function setMenuState() { |
1864 function setMenuState() { |
1507 var viewportWidth = getViewportWidth() || 961; |
1865 var viewportWidth = getViewportWidth() || 961; |
1508 |
1866 |
1509 if ( viewportWidth <= 782 ) { |
1867 if ( viewportWidth <= 782 ) { |
1527 * `aria-label` attributes of the button to give feedback to assistive |
1885 * `aria-label` attributes of the button to give feedback to assistive |
1528 * technologies. In the responsive view, the button is always hidden. |
1886 * technologies. In the responsive view, the button is always hidden. |
1529 * |
1887 * |
1530 * @since 4.7.0 |
1888 * @since 4.7.0 |
1531 * |
1889 * |
1532 * @returns {void} |
1890 * @return {void} |
1533 */ |
1891 */ |
1534 $document.on( 'wp-menu-state-set wp-collapse-menu', function( event, eventData ) { |
1892 $document.on( 'wp-menu-state-set wp-collapse-menu', function( event, eventData ) { |
1535 var $collapseButton = $( '#collapse-button' ), |
1893 var $collapseButton = $( '#collapse-button' ), |
1536 ariaExpanded = 'true', |
1894 ariaExpanded, ariaLabelText; |
1537 ariaLabelText = commonL10n.collapseMenu; |
|
1538 |
1895 |
1539 if ( 'folded' === eventData.state ) { |
1896 if ( 'folded' === eventData.state ) { |
1540 ariaExpanded = 'false'; |
1897 ariaExpanded = 'false'; |
1541 ariaLabelText = commonL10n.expandMenu; |
1898 ariaLabelText = __( 'Expand Main menu' ); |
1899 } else { |
|
1900 ariaExpanded = 'true'; |
|
1901 ariaLabelText = __( 'Collapse Main menu' ); |
|
1542 } |
1902 } |
1543 |
1903 |
1544 $collapseButton.attr({ |
1904 $collapseButton.attr({ |
1545 'aria-expanded': ariaExpanded, |
1905 'aria-expanded': ariaExpanded, |
1546 'aria-label': ariaLabelText |
1906 'aria-label': ariaLabelText |
1577 // Toggle the Show Details button expanded state. |
1937 // Toggle the Show Details button expanded state. |
1578 $( this ).attr( 'aria-expanded', $progressDiv.is( ':visible' ) ); |
1938 $( this ).attr( 'aria-expanded', $progressDiv.is( ':visible' ) ); |
1579 }); |
1939 }); |
1580 }); |
1940 }); |
1581 |
1941 |
1942 /** |
|
1943 * Hides the update button for expired plugin or theme uploads. |
|
1944 * |
|
1945 * 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. |
|
1947 * |
|
1948 * @since 5.5.0 |
|
1949 */ |
|
1950 $document.ready( function( $ ) { |
|
1951 var $overwrite, $warning; |
|
1952 |
|
1953 if ( ! $body.hasClass( 'update-php' ) ) { |
|
1954 return; |
|
1955 } |
|
1956 |
|
1957 $overwrite = $( 'a.update-from-upload-overwrite' ); |
|
1958 $warning = $( '.update-from-upload-expired' ); |
|
1959 |
|
1960 if ( ! $overwrite.length || ! $warning.length ) { |
|
1961 return; |
|
1962 } |
|
1963 |
|
1964 window.setTimeout( |
|
1965 function() { |
|
1966 $overwrite.hide(); |
|
1967 $warning.removeClass( 'hidden' ); |
|
1968 |
|
1969 if ( window.wp && window.wp.a11y ) { |
|
1970 window.wp.a11y.speak( $warning.text() ); |
|
1971 } |
|
1972 }, |
|
1973 7140000 // 119 minutes. The uploaded file is deleted after 2 hours. |
|
1974 ); |
|
1975 } ); |
|
1976 |
|
1582 // Fire a custom jQuery event at the end of window resize. |
1977 // Fire a custom jQuery event at the end of window resize. |
1583 ( function() { |
1978 ( function() { |
1584 var timeout; |
1979 var timeout; |
1585 |
1980 |
1586 /** |
1981 /** |
1587 * Triggers the WP window-resize event. |
1982 * Triggers the WP window-resize event. |
1588 * |
1983 * |
1589 * @since 3.8.0 |
1984 * @since 3.8.0 |
1590 * |
1985 * |
1591 * @returns {void} |
1986 * @return {void} |
1592 */ |
1987 */ |
1593 function triggerEvent() { |
1988 function triggerEvent() { |
1594 $document.trigger( 'wp-window-resized' ); |
1989 $document.trigger( 'wp-window-resized' ); |
1595 } |
1990 } |
1596 |
1991 |
1597 /** |
1992 /** |
1598 * Fires the trigger event again after 200 ms. |
1993 * Fires the trigger event again after 200 ms. |
1599 * |
1994 * |
1600 * @since 3.8.0 |
1995 * @since 3.8.0 |
1601 * |
1996 * |
1602 * @returns {void} |
1997 * @return {void} |
1603 */ |
1998 */ |
1604 function fireOnce() { |
1999 function fireOnce() { |
1605 window.clearTimeout( timeout ); |
2000 window.clearTimeout( timeout ); |
1606 timeout = window.setTimeout( triggerEvent, 200 ); |
2001 timeout = window.setTimeout( triggerEvent, 200 ); |
1607 } |
2002 } |