author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:40:08 +0200 | |
changeset 21 | 48c4eec2b7e6 |
parent 19 | 3d72ae0968f4 |
child 22 | 8c2e4d02f4ef |
permissions | -rw-r--r-- |
9 | 1 |
/** |
2 |
* @output wp-admin/js/common.js |
|
3 |
*/ |
|
4 |
||
16 | 5 |
/* global setUserSetting, ajaxurl, alert, confirm, pagenow */ |
9 | 6 |
/* global columns, screenMeta */ |
7 |
||
8 |
/** |
|
9 |
* Adds common WordPress functionality to the window. |
|
10 |
* |
|
11 |
* @param {jQuery} $ jQuery object. |
|
12 |
* @param {Object} window The window object. |
|
13 |
* @param {mixed} undefined Unused. |
|
14 |
*/ |
|
5 | 15 |
( function( $, window, undefined ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
16 |
var $document = $( document ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
17 |
$window = $( window ), |
16 | 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 |
|
18 | 58 |
* @since 5.6.0 Added the `version` parameter. |
16 | 59 |
* |
60 |
* @param {string} name The name of the object, i.e. commonL10n. |
|
61 |
* @param {object} l10nObject The object to deprecate the properties on. |
|
18 | 62 |
* @param {string} version The version of WordPress that deprecated the property. |
16 | 63 |
* |
64 |
* @return {object} The object with all its properties deprecated. |
|
65 |
*/ |
|
18 | 66 |
function deprecateL10nObject( name, l10nObject, version ) { |
16 | 67 |
var deprecatedObject = {}; |
68 |
||
69 |
Object.keys( l10nObject ).forEach( function( key ) { |
|
70 |
var prop = l10nObject[ key ]; |
|
71 |
var propName = name + '.' + key; |
|
72 |
||
73 |
if ( 'object' === typeof prop ) { |
|
74 |
Object.defineProperty( deprecatedObject, key, { get: function() { |
|
18 | 75 |
deprecatedProperty( propName, version, prop.alternative ); |
16 | 76 |
return prop.func(); |
77 |
} } ); |
|
78 |
} else { |
|
79 |
Object.defineProperty( deprecatedObject, key, { get: function() { |
|
18 | 80 |
deprecatedProperty( propName, version, 'wp.i18n' ); |
16 | 81 |
return prop; |
82 |
} } ); |
|
83 |
} |
|
84 |
} ); |
|
85 |
||
86 |
return deprecatedObject; |
|
87 |
} |
|
88 |
||
89 |
window.wp.deprecateL10nObject = deprecateL10nObject; |
|
90 |
||
91 |
/** |
|
92 |
* Removed in 5.5.0, needed for back-compatibility. |
|
93 |
* |
|
94 |
* @since 2.6.0 |
|
95 |
* @deprecated 5.5.0 |
|
96 |
*/ |
|
97 |
window.commonL10n = window.commonL10n || { |
|
98 |
warnDelete: '', |
|
99 |
dismiss: '', |
|
100 |
collapseMenu: '', |
|
101 |
expandMenu: '' |
|
102 |
}; |
|
103 |
||
18 | 104 |
window.commonL10n = deprecateL10nObject( 'commonL10n', window.commonL10n, '5.5.0' ); |
16 | 105 |
|
106 |
/** |
|
107 |
* Removed in 5.5.0, needed for back-compatibility. |
|
108 |
* |
|
109 |
* @since 3.3.0 |
|
110 |
* @deprecated 5.5.0 |
|
111 |
*/ |
|
112 |
window.wpPointerL10n = window.wpPointerL10n || { |
|
113 |
dismiss: '' |
|
114 |
}; |
|
115 |
||
18 | 116 |
window.wpPointerL10n = deprecateL10nObject( 'wpPointerL10n', window.wpPointerL10n, '5.5.0' ); |
16 | 117 |
|
118 |
/** |
|
119 |
* Removed in 5.5.0, needed for back-compatibility. |
|
120 |
* |
|
121 |
* @since 4.3.0 |
|
122 |
* @deprecated 5.5.0 |
|
123 |
*/ |
|
124 |
window.userProfileL10n = window.userProfileL10n || { |
|
125 |
warn: '', |
|
126 |
warnWeak: '', |
|
127 |
show: '', |
|
128 |
hide: '', |
|
129 |
cancel: '', |
|
130 |
ariaShow: '', |
|
131 |
ariaHide: '' |
|
132 |
}; |
|
133 |
||
18 | 134 |
window.userProfileL10n = deprecateL10nObject( 'userProfileL10n', window.userProfileL10n, '5.5.0' ); |
16 | 135 |
|
136 |
/** |
|
137 |
* Removed in 5.5.0, needed for back-compatibility. |
|
138 |
* |
|
139 |
* @since 4.9.6 |
|
140 |
* @deprecated 5.5.0 |
|
141 |
*/ |
|
142 |
window.privacyToolsL10n = window.privacyToolsL10n || { |
|
143 |
noDataFound: '', |
|
144 |
foundAndRemoved: '', |
|
145 |
noneRemoved: '', |
|
146 |
someNotRemoved: '', |
|
147 |
removalError: '', |
|
148 |
emailSent: '', |
|
149 |
noExportFile: '', |
|
150 |
exportError: '' |
|
151 |
}; |
|
152 |
||
18 | 153 |
window.privacyToolsL10n = deprecateL10nObject( 'privacyToolsL10n', window.privacyToolsL10n, '5.5.0' ); |
16 | 154 |
|
155 |
/** |
|
156 |
* Removed in 5.5.0, needed for back-compatibility. |
|
157 |
* |
|
158 |
* @since 3.6.0 |
|
159 |
* @deprecated 5.5.0 |
|
160 |
*/ |
|
161 |
window.authcheckL10n = { |
|
162 |
beforeunload: '' |
|
163 |
}; |
|
164 |
||
18 | 165 |
window.authcheckL10n = window.authcheckL10n || deprecateL10nObject( 'authcheckL10n', window.authcheckL10n, '5.5.0' ); |
16 | 166 |
|
167 |
/** |
|
168 |
* Removed in 5.5.0, needed for back-compatibility. |
|
169 |
* |
|
170 |
* @since 2.8.0 |
|
171 |
* @deprecated 5.5.0 |
|
172 |
*/ |
|
173 |
window.tagsl10n = { |
|
174 |
noPerm: '', |
|
175 |
broken: '' |
|
176 |
}; |
|
177 |
||
18 | 178 |
window.tagsl10n = window.tagsl10n || deprecateL10nObject( 'tagsl10n', window.tagsl10n, '5.5.0' ); |
16 | 179 |
|
180 |
/** |
|
181 |
* Removed in 5.5.0, needed for back-compatibility. |
|
182 |
* |
|
183 |
* @since 2.5.0 |
|
184 |
* @deprecated 5.5.0 |
|
185 |
*/ |
|
186 |
window.adminCommentsL10n = window.adminCommentsL10n || { |
|
187 |
hotkeys_highlight_first: { |
|
188 |
alternative: 'window.adminCommentsSettings.hotkeys_highlight_first', |
|
189 |
func: function() { return window.adminCommentsSettings.hotkeys_highlight_first; } |
|
190 |
}, |
|
191 |
hotkeys_highlight_last: { |
|
192 |
alternative: 'window.adminCommentsSettings.hotkeys_highlight_last', |
|
193 |
func: function() { return window.adminCommentsSettings.hotkeys_highlight_last; } |
|
194 |
}, |
|
195 |
replyApprove: '', |
|
196 |
reply: '', |
|
197 |
warnQuickEdit: '', |
|
198 |
warnCommentChanges: '', |
|
199 |
docTitleComments: '', |
|
200 |
docTitleCommentsCount: '' |
|
201 |
}; |
|
202 |
||
18 | 203 |
window.adminCommentsL10n = deprecateL10nObject( 'adminCommentsL10n', window.adminCommentsL10n, '5.5.0' ); |
16 | 204 |
|
205 |
/** |
|
206 |
* Removed in 5.5.0, needed for back-compatibility. |
|
207 |
* |
|
208 |
* @since 2.5.0 |
|
209 |
* @deprecated 5.5.0 |
|
210 |
*/ |
|
211 |
window.tagsSuggestL10n = window.tagsSuggestL10n || { |
|
212 |
tagDelimiter: '', |
|
213 |
removeTerm: '', |
|
214 |
termSelected: '', |
|
215 |
termAdded: '', |
|
216 |
termRemoved: '' |
|
217 |
}; |
|
218 |
||
18 | 219 |
window.tagsSuggestL10n = deprecateL10nObject( 'tagsSuggestL10n', window.tagsSuggestL10n, '5.5.0' ); |
16 | 220 |
|
221 |
/** |
|
222 |
* Removed in 5.5.0, needed for back-compatibility. |
|
223 |
* |
|
224 |
* @since 3.5.0 |
|
225 |
* @deprecated 5.5.0 |
|
226 |
*/ |
|
227 |
window.wpColorPickerL10n = window.wpColorPickerL10n || { |
|
228 |
clear: '', |
|
229 |
clearAriaLabel: '', |
|
230 |
defaultString: '', |
|
231 |
defaultAriaLabel: '', |
|
232 |
pick: '', |
|
233 |
defaultLabel: '' |
|
234 |
}; |
|
235 |
||
18 | 236 |
window.wpColorPickerL10n = deprecateL10nObject( 'wpColorPickerL10n', window.wpColorPickerL10n, '5.5.0' ); |
16 | 237 |
|
238 |
/** |
|
239 |
* Removed in 5.5.0, needed for back-compatibility. |
|
240 |
* |
|
241 |
* @since 2.7.0 |
|
242 |
* @deprecated 5.5.0 |
|
243 |
*/ |
|
244 |
window.attachMediaBoxL10n = window.attachMediaBoxL10n || { |
|
245 |
error: '' |
|
246 |
}; |
|
247 |
||
18 | 248 |
window.attachMediaBoxL10n = deprecateL10nObject( 'attachMediaBoxL10n', window.attachMediaBoxL10n, '5.5.0' ); |
16 | 249 |
|
250 |
/** |
|
251 |
* Removed in 5.5.0, needed for back-compatibility. |
|
252 |
* |
|
253 |
* @since 2.5.0 |
|
254 |
* @deprecated 5.5.0 |
|
255 |
*/ |
|
256 |
window.postL10n = window.postL10n || { |
|
257 |
ok: '', |
|
258 |
cancel: '', |
|
259 |
publishOn: '', |
|
260 |
publishOnFuture: '', |
|
261 |
publishOnPast: '', |
|
262 |
dateFormat: '', |
|
263 |
showcomm: '', |
|
264 |
endcomm: '', |
|
265 |
publish: '', |
|
266 |
schedule: '', |
|
267 |
update: '', |
|
268 |
savePending: '', |
|
269 |
saveDraft: '', |
|
270 |
'private': '', |
|
271 |
'public': '', |
|
272 |
publicSticky: '', |
|
273 |
password: '', |
|
274 |
privatelyPublished: '', |
|
275 |
published: '', |
|
276 |
saveAlert: '', |
|
277 |
savingText: '', |
|
278 |
permalinkSaved: '' |
|
279 |
}; |
|
280 |
||
18 | 281 |
window.postL10n = deprecateL10nObject( 'postL10n', window.postL10n, '5.5.0' ); |
16 | 282 |
|
283 |
/** |
|
284 |
* Removed in 5.5.0, needed for back-compatibility. |
|
285 |
* |
|
286 |
* @since 2.7.0 |
|
287 |
* @deprecated 5.5.0 |
|
288 |
*/ |
|
289 |
window.inlineEditL10n = window.inlineEditL10n || { |
|
290 |
error: '', |
|
291 |
ntdeltitle: '', |
|
292 |
notitle: '', |
|
293 |
comma: '', |
|
294 |
saved: '' |
|
295 |
}; |
|
296 |
||
18 | 297 |
window.inlineEditL10n = deprecateL10nObject( 'inlineEditL10n', window.inlineEditL10n, '5.5.0' ); |
16 | 298 |
|
299 |
/** |
|
300 |
* Removed in 5.5.0, needed for back-compatibility. |
|
301 |
* |
|
302 |
* @since 2.7.0 |
|
303 |
* @deprecated 5.5.0 |
|
304 |
*/ |
|
305 |
window.plugininstallL10n = window.plugininstallL10n || { |
|
306 |
plugin_information: '', |
|
307 |
plugin_modal_label: '', |
|
308 |
ays: '' |
|
309 |
}; |
|
310 |
||
18 | 311 |
window.plugininstallL10n = deprecateL10nObject( 'plugininstallL10n', window.plugininstallL10n, '5.5.0' ); |
16 | 312 |
|
313 |
/** |
|
314 |
* Removed in 5.5.0, needed for back-compatibility. |
|
315 |
* |
|
316 |
* @since 3.0.0 |
|
317 |
* @deprecated 5.5.0 |
|
318 |
*/ |
|
319 |
window.navMenuL10n = window.navMenuL10n || { |
|
320 |
noResultsFound: '', |
|
321 |
warnDeleteMenu: '', |
|
322 |
saveAlert: '', |
|
323 |
untitled: '' |
|
324 |
}; |
|
325 |
||
18 | 326 |
window.navMenuL10n = deprecateL10nObject( 'navMenuL10n', window.navMenuL10n, '5.5.0' ); |
16 | 327 |
|
328 |
/** |
|
329 |
* Removed in 5.5.0, needed for back-compatibility. |
|
330 |
* |
|
331 |
* @since 2.5.0 |
|
332 |
* @deprecated 5.5.0 |
|
333 |
*/ |
|
334 |
window.commentL10n = window.commentL10n || { |
|
335 |
submittedOn: '', |
|
336 |
dateFormat: '' |
|
337 |
}; |
|
338 |
||
18 | 339 |
window.commentL10n = deprecateL10nObject( 'commentL10n', window.commentL10n, '5.5.0' ); |
16 | 340 |
|
341 |
/** |
|
342 |
* Removed in 5.5.0, needed for back-compatibility. |
|
343 |
* |
|
344 |
* @since 2.9.0 |
|
345 |
* @deprecated 5.5.0 |
|
346 |
*/ |
|
347 |
window.setPostThumbnailL10n = window.setPostThumbnailL10n || { |
|
348 |
setThumbnail: '', |
|
349 |
saving: '', |
|
350 |
error: '', |
|
351 |
done: '' |
|
352 |
}; |
|
353 |
||
18 | 354 |
window.setPostThumbnailL10n = deprecateL10nObject( 'setPostThumbnailL10n', window.setPostThumbnailL10n, '5.5.0' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
355 |
|
9 | 356 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
357 |
* Removed in 6.5.0, needed for back-compatibility. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
358 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
359 |
* @since 4.5.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
360 |
* @deprecated 6.5.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
361 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
362 |
window.uiAutocompleteL10n = window.uiAutocompleteL10n || { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
363 |
noResults: '', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
364 |
oneResult: '', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
365 |
manyResults: '', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
366 |
itemSelected: '' |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
367 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
368 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
369 |
window.uiAutocompleteL10n = deprecateL10nObject( 'uiAutocompleteL10n', window.uiAutocompleteL10n, '6.5.0' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
370 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
371 |
/** |
9 | 372 |
* Removed in 3.3.0, needed for back-compatibility. |
373 |
* |
|
374 |
* @since 2.7.0 |
|
375 |
* @deprecated 3.3.0 |
|
376 |
*/ |
|
377 |
window.adminMenu = { |
|
0 | 378 |
init : function() {}, |
379 |
fold : function() {}, |
|
380 |
restoreMenuState : function() {}, |
|
381 |
toggle : function() {}, |
|
382 |
favorites : function() {} |
|
383 |
}; |
|
384 |
||
9 | 385 |
// Show/hide/save table columns. |
386 |
window.columns = { |
|
387 |
||
388 |
/** |
|
389 |
* Initializes the column toggles in the screen options. |
|
390 |
* |
|
391 |
* Binds an onClick event to the checkboxes to show or hide the table columns |
|
392 |
* based on their toggled state. And persists the toggled state. |
|
393 |
* |
|
394 |
* @since 2.7.0 |
|
395 |
* |
|
16 | 396 |
* @return {void} |
9 | 397 |
*/ |
0 | 398 |
init : function() { |
399 |
var that = this; |
|
18 | 400 |
$('.hide-column-tog', '#adv-settings').on( 'click', function() { |
0 | 401 |
var $t = $(this), column = $t.val(); |
402 |
if ( $t.prop('checked') ) |
|
403 |
that.checked(column); |
|
404 |
else |
|
405 |
that.unchecked(column); |
|
406 |
||
407 |
columns.saveManageColumnsState(); |
|
408 |
}); |
|
409 |
}, |
|
410 |
||
9 | 411 |
/** |
412 |
* Saves the toggled state for the columns. |
|
413 |
* |
|
414 |
* Saves whether the columns should be shown or hidden on a page. |
|
415 |
* |
|
416 |
* @since 3.0.0 |
|
417 |
* |
|
16 | 418 |
* @return {void} |
9 | 419 |
*/ |
0 | 420 |
saveManageColumnsState : function() { |
421 |
var hidden = this.hidden(); |
|
422 |
$.post(ajaxurl, { |
|
423 |
action: 'hidden-columns', |
|
424 |
hidden: hidden, |
|
425 |
screenoptionnonce: $('#screenoptionnonce').val(), |
|
426 |
page: pagenow |
|
427 |
}); |
|
428 |
}, |
|
429 |
||
9 | 430 |
/** |
431 |
* Makes a column visible and adjusts the column span for the table. |
|
432 |
* |
|
433 |
* @since 3.0.0 |
|
434 |
* @param {string} column The column name. |
|
435 |
* |
|
16 | 436 |
* @return {void} |
9 | 437 |
*/ |
0 | 438 |
checked : function(column) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
439 |
$('.column-' + column).removeClass( 'hidden' ); |
0 | 440 |
this.colSpanChange(+1); |
441 |
}, |
|
442 |
||
9 | 443 |
/** |
444 |
* Hides a column and adjusts the column span for the table. |
|
445 |
* |
|
446 |
* @since 3.0.0 |
|
447 |
* @param {string} column The column name. |
|
448 |
* |
|
16 | 449 |
* @return {void} |
9 | 450 |
*/ |
0 | 451 |
unchecked : function(column) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
452 |
$('.column-' + column).addClass( 'hidden' ); |
0 | 453 |
this.colSpanChange(-1); |
454 |
}, |
|
455 |
||
9 | 456 |
/** |
457 |
* Gets all hidden columns. |
|
458 |
* |
|
459 |
* @since 3.0.0 |
|
460 |
* |
|
16 | 461 |
* @return {string} The hidden column names separated by a comma. |
9 | 462 |
*/ |
0 | 463 |
hidden : function() { |
9 | 464 |
return $( '.manage-column[id]' ).filter( '.hidden' ).map(function() { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
465 |
return this.id; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
466 |
}).get().join( ',' ); |
0 | 467 |
}, |
468 |
||
9 | 469 |
/** |
470 |
* Gets the checked column toggles from the screen options. |
|
471 |
* |
|
472 |
* @since 3.0.0 |
|
473 |
* |
|
16 | 474 |
* @return {string} String containing the checked column names. |
9 | 475 |
*/ |
0 | 476 |
useCheckboxesForHidden : function() { |
477 |
this.hidden = function(){ |
|
478 |
return $('.hide-column-tog').not(':checked').map(function() { |
|
479 |
var id = this.id; |
|
480 |
return id.substring( id, id.length - 5 ); |
|
481 |
}).get().join(','); |
|
482 |
}; |
|
483 |
}, |
|
484 |
||
9 | 485 |
/** |
486 |
* Adjusts the column span for the table. |
|
487 |
* |
|
488 |
* @since 3.1.0 |
|
489 |
* |
|
16 | 490 |
* @param {number} diff The modifier for the column span. |
9 | 491 |
*/ |
0 | 492 |
colSpanChange : function(diff) { |
493 |
var $t = $('table').find('.colspanchange'), n; |
|
494 |
if ( !$t.length ) |
|
495 |
return; |
|
496 |
n = parseInt( $t.attr('colspan'), 10 ) + diff; |
|
497 |
$t.attr('colspan', n.toString()); |
|
498 |
} |
|
5 | 499 |
}; |
0 | 500 |
|
18 | 501 |
$( function() { columns.init(); } ); |
0 | 502 |
|
9 | 503 |
/** |
504 |
* Validates that the required form fields are not empty. |
|
505 |
* |
|
506 |
* @since 2.9.0 |
|
507 |
* |
|
508 |
* @param {jQuery} form The form to validate. |
|
509 |
* |
|
16 | 510 |
* @return {boolean} Returns true if all required fields are not an empty string. |
9 | 511 |
*/ |
512 |
window.validateForm = function( form ) { |
|
5 | 513 |
return !$( form ) |
514 |
.find( '.form-required' ) |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
515 |
.filter( function() { return $( ':input:visible', this ).val() === ''; } ) |
5 | 516 |
.addClass( 'form-invalid' ) |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
517 |
.find( ':input:visible' ) |
18 | 518 |
.on( 'change', function() { $( this ).closest( '.form-invalid' ).removeClass( 'form-invalid' ); } ) |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
519 |
.length; |
5 | 520 |
}; |
0 | 521 |
|
16 | 522 |
// Stub for doing better warnings. |
9 | 523 |
/** |
524 |
* Shows message pop-up notice or confirmation message. |
|
525 |
* |
|
526 |
* @since 2.7.0 |
|
527 |
* |
|
528 |
* @type {{warn: showNotice.warn, note: showNotice.note}} |
|
529 |
* |
|
16 | 530 |
* @return {void} |
9 | 531 |
*/ |
532 |
window.showNotice = { |
|
533 |
||
534 |
/** |
|
535 |
* Shows a delete confirmation pop-up message. |
|
536 |
* |
|
537 |
* @since 2.7.0 |
|
538 |
* |
|
16 | 539 |
* @return {boolean} Returns true if the message is confirmed. |
9 | 540 |
*/ |
0 | 541 |
warn : function() { |
16 | 542 |
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.' ) ) ) { |
0 | 543 |
return true; |
544 |
} |
|
545 |
||
546 |
return false; |
|
547 |
}, |
|
548 |
||
9 | 549 |
/** |
550 |
* Shows an alert message. |
|
551 |
* |
|
552 |
* @since 2.7.0 |
|
553 |
* |
|
554 |
* @param text The text to display in the message. |
|
555 |
*/ |
|
0 | 556 |
note : function(text) { |
557 |
alert(text); |
|
558 |
} |
|
559 |
}; |
|
560 |
||
9 | 561 |
/** |
562 |
* Represents the functions for the meta screen options panel. |
|
563 |
* |
|
564 |
* @since 3.2.0 |
|
565 |
* |
|
566 |
* @type {{element: null, toggles: null, page: null, init: screenMeta.init, |
|
567 |
* toggleEvent: screenMeta.toggleEvent, open: screenMeta.open, |
|
568 |
* close: screenMeta.close}} |
|
569 |
* |
|
16 | 570 |
* @return {void} |
9 | 571 |
*/ |
572 |
window.screenMeta = { |
|
0 | 573 |
element: null, // #screen-meta |
574 |
toggles: null, // .screen-meta-toggle |
|
575 |
page: null, // #wpcontent |
|
576 |
||
9 | 577 |
/** |
578 |
* Initializes the screen meta options panel. |
|
579 |
* |
|
580 |
* @since 3.2.0 |
|
581 |
* |
|
16 | 582 |
* @return {void} |
9 | 583 |
*/ |
0 | 584 |
init: function() { |
585 |
this.element = $('#screen-meta'); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
586 |
this.toggles = $( '#screen-meta-links' ).find( '.show-settings' ); |
0 | 587 |
this.page = $('#wpcontent'); |
588 |
||
18 | 589 |
this.toggles.on( 'click', this.toggleEvent ); |
0 | 590 |
}, |
591 |
||
9 | 592 |
/** |
593 |
* Toggles the screen meta options panel. |
|
594 |
* |
|
595 |
* @since 3.2.0 |
|
596 |
* |
|
16 | 597 |
* @return {void} |
9 | 598 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
599 |
toggleEvent: function() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
600 |
var panel = $( '#' + $( this ).attr( 'aria-controls' ) ); |
0 | 601 |
|
602 |
if ( !panel.length ) |
|
603 |
return; |
|
604 |
||
605 |
if ( panel.is(':visible') ) |
|
606 |
screenMeta.close( panel, $(this) ); |
|
607 |
else |
|
608 |
screenMeta.open( panel, $(this) ); |
|
609 |
}, |
|
610 |
||
9 | 611 |
/** |
612 |
* Opens the screen meta options panel. |
|
613 |
* |
|
614 |
* @since 3.2.0 |
|
615 |
* |
|
616 |
* @param {jQuery} panel The screen meta options panel div. |
|
617 |
* @param {jQuery} button The toggle button. |
|
618 |
* |
|
16 | 619 |
* @return {void} |
9 | 620 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
621 |
open: function( panel, button ) { |
0 | 622 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
623 |
$( '#screen-meta-links' ).find( '.screen-meta-toggle' ).not( button.parent() ).css( 'visibility', 'hidden' ); |
0 | 624 |
|
625 |
panel.parent().show(); |
|
9 | 626 |
|
627 |
/** |
|
628 |
* Sets the focus to the meta options panel and adds the necessary CSS classes. |
|
629 |
* |
|
630 |
* @since 3.2.0 |
|
631 |
* |
|
16 | 632 |
* @return {void} |
9 | 633 |
*/ |
0 | 634 |
panel.slideDown( 'fast', function() { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
635 |
panel.removeClass( 'hidden' ).trigger( 'focus' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
636 |
button.addClass( 'screen-meta-active' ).attr( 'aria-expanded', true ); |
0 | 637 |
}); |
5 | 638 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
639 |
$document.trigger( 'screen:options:open' ); |
0 | 640 |
}, |
641 |
||
9 | 642 |
/** |
643 |
* Closes the screen meta options panel. |
|
644 |
* |
|
645 |
* @since 3.2.0 |
|
646 |
* |
|
647 |
* @param {jQuery} panel The screen meta options panel div. |
|
648 |
* @param {jQuery} button The toggle button. |
|
649 |
* |
|
16 | 650 |
* @return {void} |
9 | 651 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
652 |
close: function( panel, button ) { |
9 | 653 |
/** |
654 |
* Hides the screen meta options panel. |
|
655 |
* |
|
656 |
* @since 3.2.0 |
|
657 |
* |
|
16 | 658 |
* @return {void} |
9 | 659 |
*/ |
0 | 660 |
panel.slideUp( 'fast', function() { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
661 |
button.removeClass( 'screen-meta-active' ).attr( 'aria-expanded', false ); |
0 | 662 |
$('.screen-meta-toggle').css('visibility', ''); |
663 |
panel.parent().hide(); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
664 |
panel.addClass( 'hidden' ); |
0 | 665 |
}); |
5 | 666 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
667 |
$document.trigger( 'screen:options:close' ); |
0 | 668 |
} |
669 |
}; |
|
670 |
||
671 |
/** |
|
9 | 672 |
* Initializes the help tabs in the help panel. |
673 |
* |
|
674 |
* @param {Event} e The event object. |
|
675 |
* |
|
16 | 676 |
* @return {void} |
0 | 677 |
*/ |
18 | 678 |
$('.contextual-help-tabs').on( 'click', 'a', function(e) { |
0 | 679 |
var link = $(this), |
680 |
panel; |
|
681 |
||
682 |
e.preventDefault(); |
|
683 |
||
684 |
// Don't do anything if the click is for the tab already showing. |
|
685 |
if ( link.is('.active a') ) |
|
686 |
return false; |
|
687 |
||
16 | 688 |
// Links. |
0 | 689 |
$('.contextual-help-tabs .active').removeClass('active'); |
690 |
link.parent('li').addClass('active'); |
|
691 |
||
692 |
panel = $( link.attr('href') ); |
|
693 |
||
16 | 694 |
// Panels. |
0 | 695 |
$('.help-tab-content').not( panel ).removeClass('active').hide(); |
696 |
panel.addClass('active').show(); |
|
697 |
}); |
|
698 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
699 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
700 |
* Update custom permalink structure via buttons. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
701 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
702 |
var permalinkStructureFocused = false, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
703 |
$permalinkStructure = $( '#permalink_structure' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
704 |
$permalinkStructureInputs = $( '.permalink-structure input:radio' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
705 |
$permalinkCustomSelection = $( '#custom_selection' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
706 |
$availableStructureTags = $( '.form-table.permalink-structure .available-structure-tags button' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
707 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
708 |
// Change permalink structure input when selecting one of the common structures. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
709 |
$permalinkStructureInputs.on( 'change', function() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
710 |
if ( 'custom' === this.value ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
711 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
712 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
713 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
714 |
$permalinkStructure.val( this.value ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
715 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
716 |
// Update button states after selection. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
717 |
$availableStructureTags.each( function() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
718 |
changeStructureTagButtonState( $( this ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
719 |
} ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
720 |
} ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
721 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
722 |
$permalinkStructure.on( 'click input', function() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
723 |
$permalinkCustomSelection.prop( 'checked', true ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
724 |
} ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
725 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
726 |
// Check if the permalink structure input field has had focus at least once. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
727 |
$permalinkStructure.on( 'focus', function( event ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
728 |
permalinkStructureFocused = true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
729 |
$( this ).off( event ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
730 |
} ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
731 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
732 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
733 |
* Enables or disables a structure tag button depending on its usage. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
734 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
735 |
* If the structure is already used in the custom permalink structure, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
736 |
* it will be disabled. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
737 |
* |
16 | 738 |
* @param {Object} button Button jQuery object. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
739 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
740 |
function changeStructureTagButtonState( button ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
741 |
if ( -1 !== $permalinkStructure.val().indexOf( button.text().trim() ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
742 |
button.attr( 'data-label', button.attr( 'aria-label' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
743 |
button.attr( 'aria-label', button.attr( 'data-used' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
744 |
button.attr( 'aria-pressed', true ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
745 |
button.addClass( 'active' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
746 |
} else if ( button.attr( 'data-label' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
747 |
button.attr( 'aria-label', button.attr( 'data-label' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
748 |
button.attr( 'aria-pressed', false ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
749 |
button.removeClass( 'active' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
750 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
751 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
752 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
753 |
// Check initial button state. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
754 |
$availableStructureTags.each( function() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
755 |
changeStructureTagButtonState( $( this ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
756 |
} ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
757 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
758 |
// Observe permalink structure field and disable buttons of tags that are already present. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
759 |
$permalinkStructure.on( 'change', function() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
760 |
$availableStructureTags.each( function() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
761 |
changeStructureTagButtonState( $( this ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
762 |
} ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
763 |
} ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
764 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
765 |
$availableStructureTags.on( 'click', function() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
766 |
var permalinkStructureValue = $permalinkStructure.val(), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
767 |
selectionStart = $permalinkStructure[ 0 ].selectionStart, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
768 |
selectionEnd = $permalinkStructure[ 0 ].selectionEnd, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
769 |
textToAppend = $( this ).text().trim(), |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
770 |
textToAnnounce, |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
771 |
newSelectionStart; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
772 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
773 |
if ( $( this ).hasClass( 'active' ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
774 |
textToAnnounce = $( this ).attr( 'data-removed' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
775 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
776 |
textToAnnounce = $( this ).attr( 'data-added' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
777 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
778 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
779 |
// Remove structure tag if already part of the structure. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
780 |
if ( -1 !== permalinkStructureValue.indexOf( textToAppend ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
781 |
permalinkStructureValue = permalinkStructureValue.replace( textToAppend + '/', '' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
782 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
783 |
$permalinkStructure.val( '/' === permalinkStructureValue ? '' : permalinkStructureValue ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
784 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
785 |
// Announce change to screen readers. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
786 |
$( '#custom_selection_updated' ).text( textToAnnounce ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
787 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
788 |
// Disable button. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
789 |
changeStructureTagButtonState( $( this ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
790 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
791 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
792 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
793 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
794 |
// Input field never had focus, move selection to end of input. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
795 |
if ( ! permalinkStructureFocused && 0 === selectionStart && 0 === selectionEnd ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
796 |
selectionStart = selectionEnd = permalinkStructureValue.length; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
797 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
798 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
799 |
$permalinkCustomSelection.prop( 'checked', true ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
800 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
801 |
// Prepend and append slashes if necessary. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
802 |
if ( '/' !== permalinkStructureValue.substr( 0, selectionStart ).substr( -1 ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
803 |
textToAppend = '/' + textToAppend; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
804 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
805 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
806 |
if ( '/' !== permalinkStructureValue.substr( selectionEnd, 1 ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
807 |
textToAppend = textToAppend + '/'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
808 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
809 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
810 |
// Insert structure tag at the specified position. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
811 |
$permalinkStructure.val( permalinkStructureValue.substr( 0, selectionStart ) + textToAppend + permalinkStructureValue.substr( selectionEnd ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
812 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
813 |
// Announce change to screen readers. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
814 |
$( '#custom_selection_updated' ).text( textToAnnounce ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
815 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
816 |
// Disable button. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
817 |
changeStructureTagButtonState( $( this ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
818 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
819 |
// If input had focus give it back with cursor right after appended text. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
820 |
if ( permalinkStructureFocused && $permalinkStructure[0].setSelectionRange ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
821 |
newSelectionStart = ( permalinkStructureValue.substr( 0, selectionStart ) + textToAppend ).length; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
822 |
$permalinkStructure[0].setSelectionRange( newSelectionStart, newSelectionStart ); |
18 | 823 |
$permalinkStructure.trigger( 'focus' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
824 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
825 |
} ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
826 |
|
18 | 827 |
$( function() { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
828 |
var checks, first, last, checked, sliced, mobileEvent, transitionTimeout, focusedRowActions, |
5 | 829 |
lastClicked = false, |
830 |
pageInput = $('input.current-page'), |
|
831 |
currentPage = pageInput.val(), |
|
832 |
isIOS = /iPhone|iPad|iPod/.test( navigator.userAgent ), |
|
833 |
isAndroid = navigator.userAgent.indexOf( 'Android' ) !== -1, |
|
834 |
$adminMenuWrap = $( '#adminmenuwrap' ), |
|
835 |
$wpwrap = $( '#wpwrap' ), |
|
836 |
$adminmenu = $( '#adminmenu' ), |
|
837 |
$overlay = $( '#wp-responsive-overlay' ), |
|
838 |
$toolbar = $( '#wp-toolbar' ), |
|
839 |
$toolbarPopups = $toolbar.find( 'a[aria-haspopup="true"]' ), |
|
840 |
$sortables = $('.meta-box-sortables'), |
|
841 |
wpResponsiveActive = false, |
|
842 |
$adminbar = $( '#wpadminbar' ), |
|
843 |
lastScrollPosition = 0, |
|
844 |
pinnedMenuTop = false, |
|
845 |
pinnedMenuBottom = false, |
|
846 |
menuTop = 0, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
847 |
menuState, |
5 | 848 |
menuIsPinned = false, |
849 |
height = { |
|
850 |
window: $window.height(), |
|
851 |
wpwrap: $wpwrap.height(), |
|
852 |
adminbar: $adminbar.height(), |
|
853 |
menu: $adminMenuWrap.height() |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
854 |
}, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
855 |
$headerEnd = $( '.wp-header-end' ); |
5 | 856 |
|
9 | 857 |
/** |
858 |
* Makes the fly-out submenu header clickable, when the menu is folded. |
|
859 |
* |
|
860 |
* @param {Event} e The event object. |
|
861 |
* |
|
16 | 862 |
* @return {void} |
9 | 863 |
*/ |
5 | 864 |
$adminmenu.on('click.wp-submenu-head', '.wp-submenu-head', function(e){ |
0 | 865 |
$(e.target).parent().siblings('a').get(0).click(); |
866 |
}); |
|
867 |
||
9 | 868 |
/** |
869 |
* Collapses the admin menu. |
|
870 |
* |
|
16 | 871 |
* @return {void} |
9 | 872 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
873 |
$( '#collapse-button' ).on( 'click.collapse-menu', function() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
874 |
var viewportWidth = getViewportWidth() || 961; |
0 | 875 |
|
16 | 876 |
// Reset any compensation for submenus near the bottom of the screen. |
0 | 877 |
$('#adminmenu div.wp-submenu').css('margin-top', ''); |
878 |
||
19 | 879 |
if ( viewportWidth <= 960 ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
880 |
if ( $body.hasClass('auto-fold') ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
881 |
$body.removeClass('auto-fold').removeClass('folded'); |
0 | 882 |
setUserSetting('unfold', 1); |
883 |
setUserSetting('mfold', 'o'); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
884 |
menuState = 'open'; |
0 | 885 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
886 |
$body.addClass('auto-fold'); |
0 | 887 |
setUserSetting('unfold', 0); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
888 |
menuState = 'folded'; |
0 | 889 |
} |
890 |
} else { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
891 |
if ( $body.hasClass('folded') ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
892 |
$body.removeClass('folded'); |
0 | 893 |
setUserSetting('mfold', 'o'); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
894 |
menuState = 'open'; |
0 | 895 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
896 |
$body.addClass('folded'); |
0 | 897 |
setUserSetting('mfold', 'f'); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
898 |
menuState = 'folded'; |
0 | 899 |
} |
900 |
} |
|
5 | 901 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
902 |
$document.trigger( 'wp-collapse-menu', { state: menuState } ); |
0 | 903 |
}); |
904 |
||
9 | 905 |
/** |
906 |
* Ensures an admin submenu is within the visual viewport. |
|
5 | 907 |
* |
908 |
* @since 4.1.0 |
|
909 |
* |
|
910 |
* @param {jQuery} $menuItem The parent menu item containing the submenu. |
|
9 | 911 |
* |
16 | 912 |
* @return {void} |
5 | 913 |
*/ |
914 |
function adjustSubmenu( $menuItem ) { |
|
915 |
var bottomOffset, pageHeight, adjustment, theFold, menutop, wintop, maxtop, |
|
916 |
$submenu = $menuItem.find( '.wp-submenu' ); |
|
917 |
||
918 |
menutop = $menuItem.offset().top; |
|
919 |
wintop = $window.scrollTop(); |
|
16 | 920 |
maxtop = menutop - wintop - 30; // max = make the top of the sub almost touch admin bar. |
5 | 921 |
|
16 | 922 |
bottomOffset = menutop + $submenu.height() + 1; // Bottom offset of the menu. |
923 |
pageHeight = $wpwrap.height(); // Height of the entire page. |
|
5 | 924 |
adjustment = 60 + bottomOffset - pageHeight; |
16 | 925 |
theFold = $window.height() + wintop - 50; // The fold. |
5 | 926 |
|
927 |
if ( theFold < ( bottomOffset - adjustment ) ) { |
|
928 |
adjustment = bottomOffset - theFold; |
|
929 |
} |
|
930 |
||
931 |
if ( adjustment > maxtop ) { |
|
932 |
adjustment = maxtop; |
|
933 |
} |
|
934 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
935 |
if ( adjustment > 1 && $('#wp-admin-bar-menu-toggle').is(':hidden') ) { |
5 | 936 |
$submenu.css( 'margin-top', '-' + adjustment + 'px' ); |
937 |
} else { |
|
938 |
$submenu.css( 'margin-top', '' ); |
|
939 |
} |
|
940 |
} |
|
941 |
||
16 | 942 |
if ( 'ontouchstart' in window || /IEMobile\/[1-9]/.test(navigator.userAgent) ) { // Touch screen device. |
943 |
// iOS Safari works with touchstart, the rest work with click. |
|
5 | 944 |
mobileEvent = isIOS ? 'touchstart' : 'click'; |
0 | 945 |
|
9 | 946 |
/** |
947 |
* Closes any open submenus when touch/click is not on the menu. |
|
948 |
* |
|
949 |
* @param {Event} e The event object. |
|
950 |
* |
|
16 | 951 |
* @return {void} |
9 | 952 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
953 |
$body.on( mobileEvent+'.wp-mobile-hover', function(e) { |
5 | 954 |
if ( $adminmenu.data('wp-responsive') ) { |
955 |
return; |
|
956 |
} |
|
957 |
||
958 |
if ( ! $( e.target ).closest( '#adminmenu' ).length ) { |
|
959 |
$adminmenu.find( 'li.opensub' ).removeClass( 'opensub' ); |
|
960 |
} |
|
0 | 961 |
}); |
962 |
||
9 | 963 |
/** |
964 |
* Handles the opening or closing the submenu based on the mobile click|touch event. |
|
965 |
* |
|
966 |
* @param {Event} event The event object. |
|
967 |
* |
|
16 | 968 |
* @return {void} |
9 | 969 |
*/ |
5 | 970 |
$adminmenu.find( 'a.wp-has-submenu' ).on( mobileEvent + '.wp-mobile-hover', function( event ) { |
971 |
var $menuItem = $(this).parent(); |
|
972 |
||
973 |
if ( $adminmenu.data( 'wp-responsive' ) ) { |
|
974 |
return; |
|
975 |
} |
|
0 | 976 |
|
16 | 977 |
/* |
978 |
* Show the sub instead of following the link if: |
|
979 |
* - the submenu is not open. |
|
980 |
* - the submenu is not shown inline or the menu is not folded. |
|
981 |
*/ |
|
5 | 982 |
if ( ! $menuItem.hasClass( 'opensub' ) && ( ! $menuItem.hasClass( 'wp-menu-open' ) || $menuItem.width() < 40 ) ) { |
983 |
event.preventDefault(); |
|
984 |
adjustSubmenu( $menuItem ); |
|
985 |
$adminmenu.find( 'li.opensub' ).removeClass( 'opensub' ); |
|
986 |
$menuItem.addClass('opensub'); |
|
0 | 987 |
} |
988 |
}); |
|
989 |
} |
|
990 |
||
5 | 991 |
if ( ! isIOS && ! isAndroid ) { |
992 |
$adminmenu.find( 'li.wp-has-submenu' ).hoverIntent({ |
|
9 | 993 |
|
994 |
/** |
|
995 |
* Opens the submenu when hovered over the menu item for desktops. |
|
996 |
* |
|
16 | 997 |
* @return {void} |
9 | 998 |
*/ |
5 | 999 |
over: function() { |
1000 |
var $menuItem = $( this ), |
|
1001 |
$submenu = $menuItem.find( '.wp-submenu' ), |
|
1002 |
top = parseInt( $submenu.css( 'top' ), 10 ); |
|
0 | 1003 |
|
16 | 1004 |
if ( isNaN( top ) || top > -5 ) { // The submenu is visible. |
5 | 1005 |
return; |
1006 |
} |
|
0 | 1007 |
|
5 | 1008 |
if ( $adminmenu.data( 'wp-responsive' ) ) { |
16 | 1009 |
// The menu is in responsive mode, bail. |
5 | 1010 |
return; |
1011 |
} |
|
0 | 1012 |
|
5 | 1013 |
adjustSubmenu( $menuItem ); |
1014 |
$adminmenu.find( 'li.opensub' ).removeClass( 'opensub' ); |
|
1015 |
$menuItem.addClass( 'opensub' ); |
|
1016 |
}, |
|
9 | 1017 |
|
1018 |
/** |
|
1019 |
* Closes the submenu when no longer hovering the menu item. |
|
1020 |
* |
|
16 | 1021 |
* @return {void} |
9 | 1022 |
*/ |
5 | 1023 |
out: function(){ |
1024 |
if ( $adminmenu.data( 'wp-responsive' ) ) { |
|
16 | 1025 |
// The menu is in responsive mode, bail. |
5 | 1026 |
return; |
1027 |
} |
|
0 | 1028 |
|
5 | 1029 |
$( this ).removeClass( 'opensub' ).find( '.wp-submenu' ).css( 'margin-top', '' ); |
1030 |
}, |
|
1031 |
timeout: 200, |
|
1032 |
sensitivity: 7, |
|
1033 |
interval: 90 |
|
1034 |
}); |
|
0 | 1035 |
|
9 | 1036 |
/** |
1037 |
* Opens the submenu on when focused on the menu item. |
|
1038 |
* |
|
1039 |
* @param {Event} event The event object. |
|
1040 |
* |
|
16 | 1041 |
* @return {void} |
9 | 1042 |
*/ |
5 | 1043 |
$adminmenu.on( 'focus.adminmenu', '.wp-submenu a', function( event ) { |
1044 |
if ( $adminmenu.data( 'wp-responsive' ) ) { |
|
16 | 1045 |
// The menu is in responsive mode, bail. |
5 | 1046 |
return; |
1047 |
} |
|
1048 |
||
1049 |
$( event.target ).closest( 'li.menu-top' ).addClass( 'opensub' ); |
|
9 | 1050 |
|
1051 |
/** |
|
1052 |
* Closes the submenu on blur from the menu item. |
|
1053 |
* |
|
1054 |
* @param {Event} event The event object. |
|
1055 |
* |
|
16 | 1056 |
* @return {void} |
9 | 1057 |
*/ |
5 | 1058 |
}).on( 'blur.adminmenu', '.wp-submenu a', function( event ) { |
1059 |
if ( $adminmenu.data( 'wp-responsive' ) ) { |
|
1060 |
return; |
|
1061 |
} |
|
1062 |
||
1063 |
$( event.target ).closest( 'li.menu-top' ).removeClass( 'opensub' ); |
|
9 | 1064 |
|
1065 |
/** |
|
1066 |
* Adjusts the size for the submenu. |
|
1067 |
* |
|
16 | 1068 |
* @return {void} |
9 | 1069 |
*/ |
5 | 1070 |
}).find( 'li.wp-has-submenu.wp-not-current-submenu' ).on( 'focusin.adminmenu', function() { |
1071 |
adjustSubmenu( $( this ) ); |
|
1072 |
}); |
|
1073 |
} |
|
0 | 1074 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1075 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1076 |
* The `.below-h2` class is here just for backward compatibility with plugins |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1077 |
* that are (incorrectly) using it. Do not use. Use `.inline` instead. See #34570. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1078 |
* If '.wp-header-end' is found, append the notices after it otherwise |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1079 |
* after the first h1 or h2 heading found within the main content. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1080 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1081 |
if ( ! $headerEnd.length ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1082 |
$headerEnd = $( '.wrap h1, .wrap h2' ).first(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1083 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1084 |
$( 'div.updated, div.error, div.notice' ).not( '.inline, .below-h2' ).insertAfter( $headerEnd ); |
5 | 1085 |
|
9 | 1086 |
/** |
1087 |
* Makes notices dismissible. |
|
1088 |
* |
|
1089 |
* @since 4.4.0 |
|
1090 |
* |
|
16 | 1091 |
* @return {void} |
9 | 1092 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1093 |
function makeNoticesDismissible() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1094 |
$( '.notice.is-dismissible' ).each( function() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1095 |
var $el = $( this ), |
16 | 1096 |
$button = $( '<button type="button" class="notice-dismiss"><span class="screen-reader-text"></span></button>' ); |
5 | 1097 |
|
18 | 1098 |
if ( $el.find( '.notice-dismiss' ).length ) { |
1099 |
return; |
|
1100 |
} |
|
1101 |
||
16 | 1102 |
// Ensure plain text. |
1103 |
$button.find( '.screen-reader-text' ).text( __( 'Dismiss this notice.' ) ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1104 |
$button.on( 'click.wp-dismiss-notice', function( event ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1105 |
event.preventDefault(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1106 |
$el.fadeTo( 100, 0, function() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1107 |
$el.slideUp( 100, function() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1108 |
$el.remove(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1109 |
}); |
5 | 1110 |
}); |
1111 |
}); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1112 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1113 |
$el.append( $button ); |
5 | 1114 |
}); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1115 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1116 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1117 |
$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 ); |
0 | 1118 |
|
16 | 1119 |
// Init screen meta. |
0 | 1120 |
screenMeta.init(); |
1121 |
||
9 | 1122 |
/** |
1123 |
* Checks a checkbox. |
|
1124 |
* |
|
1125 |
* This event needs to be delegated. Ticket #37973. |
|
1126 |
* |
|
16 | 1127 |
* @return {boolean} Returns whether a checkbox is checked or not. |
9 | 1128 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1129 |
$body.on( 'click', 'tbody > tr > .check-column :checkbox', function( event ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1130 |
// Shift click to select a range of checkboxes. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1131 |
if ( 'undefined' == event.shiftKey ) { return true; } |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1132 |
if ( event.shiftKey ) { |
0 | 1133 |
if ( !lastClicked ) { return true; } |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1134 |
checks = $( lastClicked ).closest( 'form' ).find( ':checkbox' ).filter( ':visible:enabled' ); |
0 | 1135 |
first = checks.index( lastClicked ); |
1136 |
last = checks.index( this ); |
|
1137 |
checked = $(this).prop('checked'); |
|
1138 |
if ( 0 < first && 0 < last && first != last ) { |
|
1139 |
sliced = ( last > first ) ? checks.slice( first, last ) : checks.slice( last, first ); |
|
1140 |
sliced.prop( 'checked', function() { |
|
1141 |
if ( $(this).closest('tr').is(':visible') ) |
|
1142 |
return checked; |
|
1143 |
||
1144 |
return false; |
|
1145 |
}); |
|
1146 |
} |
|
1147 |
} |
|
1148 |
lastClicked = this; |
|
1149 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1150 |
// Toggle the "Select all" checkboxes depending if the other ones are all checked or not. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1151 |
var unchecked = $(this).closest('tbody').find('tr').find(':checkbox').filter(':visible:enabled').not(':checked'); |
9 | 1152 |
|
1153 |
/** |
|
1154 |
* Determines if all checkboxes are checked. |
|
1155 |
* |
|
16 | 1156 |
* @return {boolean} Returns true if there are no unchecked checkboxes. |
9 | 1157 |
*/ |
0 | 1158 |
$(this).closest('table').children('thead, tfoot').find(':checkbox').prop('checked', function() { |
5 | 1159 |
return ( 0 === unchecked.length ); |
0 | 1160 |
}); |
1161 |
||
1162 |
return true; |
|
1163 |
}); |
|
1164 |
||
9 | 1165 |
/** |
1166 |
* Controls all the toggles on bulk toggle change. |
|
1167 |
* |
|
1168 |
* When the bulk checkbox is changed, all the checkboxes in the tables are changed accordingly. |
|
1169 |
* When the shift-button is pressed while changing the bulk checkbox the checkboxes in the table are inverted. |
|
1170 |
* |
|
1171 |
* This event needs to be delegated. Ticket #37973. |
|
1172 |
* |
|
1173 |
* @param {Event} event The event object. |
|
1174 |
* |
|
16 | 1175 |
* @return {boolean} |
9 | 1176 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1177 |
$body.on( 'click.wp-toggle-checkboxes', 'thead .check-column :checkbox, tfoot .check-column :checkbox', function( event ) { |
5 | 1178 |
var $this = $(this), |
1179 |
$table = $this.closest( 'table' ), |
|
1180 |
controlChecked = $this.prop('checked'), |
|
1181 |
toggle = event.shiftKey || $this.data('wp-toggle'); |
|
0 | 1182 |
|
5 | 1183 |
$table.children( 'tbody' ).filter(':visible') |
1184 |
.children().children('.check-column').find(':checkbox') |
|
9 | 1185 |
/** |
1186 |
* Updates the checked state on the checkbox in the table. |
|
1187 |
* |
|
16 | 1188 |
* @return {boolean} True checks the checkbox, False unchecks the checkbox. |
9 | 1189 |
*/ |
5 | 1190 |
.prop('checked', function() { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1191 |
if ( $(this).is(':hidden,:disabled') ) { |
5 | 1192 |
return false; |
1193 |
} |
|
1194 |
||
1195 |
if ( toggle ) { |
|
1196 |
return ! $(this).prop( 'checked' ); |
|
1197 |
} else if ( controlChecked ) { |
|
1198 |
return true; |
|
1199 |
} |
|
1200 |
||
0 | 1201 |
return false; |
5 | 1202 |
}); |
0 | 1203 |
|
5 | 1204 |
$table.children('thead, tfoot').filter(':visible') |
1205 |
.children().children('.check-column').find(':checkbox') |
|
9 | 1206 |
|
1207 |
/** |
|
1208 |
* Syncs the bulk checkboxes on the top and bottom of the table. |
|
1209 |
* |
|
16 | 1210 |
* @return {boolean} True checks the checkbox, False unchecks the checkbox. |
9 | 1211 |
*/ |
5 | 1212 |
.prop('checked', function() { |
1213 |
if ( toggle ) { |
|
1214 |
return false; |
|
1215 |
} else if ( controlChecked ) { |
|
1216 |
return true; |
|
1217 |
} |
|
1218 |
||
0 | 1219 |
return false; |
5 | 1220 |
}); |
0 | 1221 |
}); |
1222 |
||
9 | 1223 |
/** |
18 | 1224 |
* Marries a secondary control to its primary control. |
1225 |
* |
|
1226 |
* @param {jQuery} topSelector The top selector element. |
|
1227 |
* @param {jQuery} topSubmit The top submit element. |
|
1228 |
* @param {jQuery} bottomSelector The bottom selector element. |
|
1229 |
* @param {jQuery} bottomSubmit The bottom submit element. |
|
1230 |
* @return {void} |
|
1231 |
*/ |
|
1232 |
function marryControls( topSelector, topSubmit, bottomSelector, bottomSubmit ) { |
|
1233 |
/** |
|
1234 |
* Updates the primary selector when the secondary selector is changed. |
|
1235 |
* |
|
1236 |
* @since 5.7.0 |
|
1237 |
* |
|
1238 |
* @return {void} |
|
1239 |
*/ |
|
1240 |
function updateTopSelector() { |
|
1241 |
topSelector.val($(this).val()); |
|
1242 |
} |
|
1243 |
bottomSelector.on('change', updateTopSelector); |
|
1244 |
||
1245 |
/** |
|
1246 |
* Updates the secondary selector when the primary selector is changed. |
|
1247 |
* |
|
1248 |
* @since 5.7.0 |
|
1249 |
* |
|
1250 |
* @return {void} |
|
1251 |
*/ |
|
1252 |
function updateBottomSelector() { |
|
1253 |
bottomSelector.val($(this).val()); |
|
1254 |
} |
|
1255 |
topSelector.on('change', updateBottomSelector); |
|
1256 |
||
1257 |
/** |
|
1258 |
* Triggers the primary submit when then secondary submit is clicked. |
|
1259 |
* |
|
1260 |
* @since 5.7.0 |
|
1261 |
* |
|
1262 |
* @return {void} |
|
1263 |
*/ |
|
1264 |
function triggerSubmitClick(e) { |
|
1265 |
e.preventDefault(); |
|
1266 |
e.stopPropagation(); |
|
1267 |
||
1268 |
topSubmit.trigger('click'); |
|
1269 |
} |
|
1270 |
bottomSubmit.on('click', triggerSubmitClick); |
|
1271 |
} |
|
1272 |
||
1273 |
// Marry the secondary "Bulk actions" controls to the primary controls: |
|
1274 |
marryControls( $('#bulk-action-selector-top'), $('#doaction'), $('#bulk-action-selector-bottom'), $('#doaction2') ); |
|
1275 |
||
1276 |
// Marry the secondary "Change role to" controls to the primary controls: |
|
1277 |
marryControls( $('#new_role'), $('#changeit'), $('#new_role2'), $('#changeit2') ); |
|
1278 |
||
1279 |
/** |
|
9 | 1280 |
* Shows row actions on focus of its parent container element or any other elements contained within. |
1281 |
* |
|
16 | 1282 |
* @return {void} |
9 | 1283 |
*/ |
5 | 1284 |
$( '#wpbody-content' ).on({ |
1285 |
focusin: function() { |
|
1286 |
clearTimeout( transitionTimeout ); |
|
1287 |
focusedRowActions = $( this ).find( '.row-actions' ); |
|
1288 |
// transitionTimeout is necessary for Firefox, but Chrome won't remove the CSS class without a little help. |
|
1289 |
$( '.row-actions' ).not( this ).removeClass( 'visible' ); |
|
1290 |
focusedRowActions.addClass( 'visible' ); |
|
1291 |
}, |
|
1292 |
focusout: function() { |
|
1293 |
// Tabbing between post title and .row-actions links needs a brief pause, otherwise |
|
1294 |
// the .row-actions div gets hidden in transit in some browsers (ahem, Firefox). |
|
1295 |
transitionTimeout = setTimeout( function() { |
|
1296 |
focusedRowActions.removeClass( 'visible' ); |
|
1297 |
}, 30 ); |
|
1298 |
} |
|
18 | 1299 |
}, '.table-view-list .has-row-actions' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1300 |
|
16 | 1301 |
// Toggle list table rows on small screens. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1302 |
$( 'tbody' ).on( 'click', '.toggle-row', function() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1303 |
$( this ).closest( 'tr' ).toggleClass( 'is-expanded' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1304 |
}); |
0 | 1305 |
|
18 | 1306 |
$('#default-password-nag-no').on( 'click', function() { |
0 | 1307 |
setUserSetting('default_password_nag', 'hide'); |
1308 |
$('div.default-password-nag').hide(); |
|
1309 |
return false; |
|
1310 |
}); |
|
1311 |
||
9 | 1312 |
/** |
19 | 1313 |
* Handles tab keypresses in theme and plugin file editor textareas. |
9 | 1314 |
* |
1315 |
* @param {Event} e The event object. |
|
1316 |
* |
|
16 | 1317 |
* @return {void} |
9 | 1318 |
*/ |
18 | 1319 |
$('#newcontent').on('keydown.wpevent_InsertTab', function(e) { |
0 | 1320 |
var el = e.target, selStart, selEnd, val, scroll, sel; |
1321 |
||
9 | 1322 |
// After pressing escape key (keyCode: 27), the tab key should tab out of the textarea. |
1323 |
if ( e.keyCode == 27 ) { |
|
16 | 1324 |
// When pressing Escape: Opera 12 and 27 blur form fields, IE 8 clears them. |
5 | 1325 |
e.preventDefault(); |
0 | 1326 |
$(el).data('tab-out', true); |
1327 |
return; |
|
1328 |
} |
|
1329 |
||
9 | 1330 |
// Only listen for plain tab key (keyCode: 9) without any modifiers. |
1331 |
if ( e.keyCode != 9 || e.ctrlKey || e.altKey || e.shiftKey ) |
|
0 | 1332 |
return; |
1333 |
||
9 | 1334 |
// After tabbing out, reset it so next time the tab key can be used again. |
0 | 1335 |
if ( $(el).data('tab-out') ) { |
1336 |
$(el).data('tab-out', false); |
|
1337 |
return; |
|
1338 |
} |
|
1339 |
||
1340 |
selStart = el.selectionStart; |
|
1341 |
selEnd = el.selectionEnd; |
|
1342 |
val = el.value; |
|
1343 |
||
9 | 1344 |
// If any text is selected, replace the selection with a tab character. |
0 | 1345 |
if ( document.selection ) { |
1346 |
el.focus(); |
|
1347 |
sel = document.selection.createRange(); |
|
1348 |
sel.text = '\t'; |
|
1349 |
} else if ( selStart >= 0 ) { |
|
1350 |
scroll = this.scrollTop; |
|
1351 |
el.value = val.substring(0, selStart).concat('\t', val.substring(selEnd) ); |
|
1352 |
el.selectionStart = el.selectionEnd = selStart + 1; |
|
1353 |
this.scrollTop = scroll; |
|
1354 |
} |
|
1355 |
||
9 | 1356 |
// Cancel the regular tab functionality, to prevent losing focus of the textarea. |
0 | 1357 |
if ( e.stopPropagation ) |
1358 |
e.stopPropagation(); |
|
1359 |
if ( e.preventDefault ) |
|
1360 |
e.preventDefault(); |
|
1361 |
}); |
|
1362 |
||
9 | 1363 |
// Reset page number variable for new filters/searches but not for bulk actions. See #17685. |
0 | 1364 |
if ( pageInput.length ) { |
9 | 1365 |
|
1366 |
/** |
|
1367 |
* Handles pagination variable when filtering the list table. |
|
1368 |
* |
|
1369 |
* Set the pagination argument to the first page when the post-filter form is submitted. |
|
1370 |
* This happens when pressing the 'filter' button on the list table page. |
|
1371 |
* |
|
1372 |
* The pagination argument should not be touched when the bulk action dropdowns are set to do anything. |
|
1373 |
* |
|
1374 |
* The form closest to the pageInput is the post-filter form. |
|
1375 |
* |
|
16 | 1376 |
* @return {void} |
9 | 1377 |
*/ |
18 | 1378 |
pageInput.closest('form').on( 'submit', function() { |
9 | 1379 |
/* |
1380 |
* action = bulk action dropdown at the top of the table |
|
1381 |
*/ |
|
18 | 1382 |
if ( $('select[name="action"]').val() == -1 && pageInput.val() == currentPage ) |
0 | 1383 |
pageInput.val('1'); |
1384 |
}); |
|
1385 |
} |
|
1386 |
||
9 | 1387 |
/** |
1388 |
* Resets the bulk actions when the search button is clicked. |
|
1389 |
* |
|
16 | 1390 |
* @return {void} |
9 | 1391 |
*/ |
18 | 1392 |
$('.search-box input[type="search"], .search-box input[type="submit"]').on( 'mousedown', function () { |
0 | 1393 |
$('select[name^="action"]').val('-1'); |
1394 |
}); |
|
1395 |
||
9 | 1396 |
/** |
1397 |
* Scrolls into view when focus.scroll-into-view is triggered. |
|
1398 |
* |
|
1399 |
* @param {Event} e The event object. |
|
1400 |
* |
|
16 | 1401 |
* @return {void} |
9 | 1402 |
*/ |
0 | 1403 |
$('#contextual-help-link, #show-settings-link').on( 'focus.scroll-into-view', function(e){ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1404 |
if ( e.target.scrollIntoViewIfNeeded ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1405 |
e.target.scrollIntoViewIfNeeded(false); |
0 | 1406 |
}); |
1407 |
||
9 | 1408 |
/** |
1409 |
* Disables the submit upload buttons when no data is entered. |
|
1410 |
* |
|
16 | 1411 |
* @return {void} |
9 | 1412 |
*/ |
0 | 1413 |
(function(){ |
1414 |
var button, input, form = $('form.wp-upload-form'); |
|
9 | 1415 |
|
1416 |
// Exit when no upload form is found. |
|
0 | 1417 |
if ( ! form.length ) |
1418 |
return; |
|
9 | 1419 |
|
0 | 1420 |
button = form.find('input[type="submit"]'); |
1421 |
input = form.find('input[type="file"]'); |
|
1422 |
||
9 | 1423 |
/** |
1424 |
* Determines if any data is entered in any file upload input. |
|
1425 |
* |
|
1426 |
* @since 3.5.0 |
|
1427 |
* |
|
16 | 1428 |
* @return {void} |
9 | 1429 |
*/ |
0 | 1430 |
function toggleUploadButton() { |
9 | 1431 |
// When no inputs have a value, disable the upload buttons. |
0 | 1432 |
button.prop('disabled', '' === input.map( function() { |
1433 |
return $(this).val(); |
|
1434 |
}).get().join('')); |
|
1435 |
} |
|
9 | 1436 |
|
1437 |
// Update the status initially. |
|
0 | 1438 |
toggleUploadButton(); |
9 | 1439 |
// Update the status when any file input changes. |
0 | 1440 |
input.on('change', toggleUploadButton); |
1441 |
})(); |
|
5 | 1442 |
|
9 | 1443 |
/** |
1444 |
* Pins the menu while distraction-free writing is enabled. |
|
1445 |
* |
|
1446 |
* @param {Event} event Event data. |
|
1447 |
* |
|
1448 |
* @since 4.1.0 |
|
1449 |
* |
|
16 | 1450 |
* @return {void} |
9 | 1451 |
*/ |
5 | 1452 |
function pinMenu( event ) { |
1453 |
var windowPos = $window.scrollTop(), |
|
1454 |
resizing = ! event || event.type !== 'scroll'; |
|
1455 |
||
16 | 1456 |
if ( isIOS || $adminmenu.data( 'wp-responsive' ) ) { |
5 | 1457 |
return; |
1458 |
} |
|
1459 |
||
9 | 1460 |
/* |
1461 |
* When the menu is higher than the window and smaller than the entire page. |
|
1462 |
* It should be adjusted to be able to see the entire menu. |
|
1463 |
* |
|
1464 |
* Otherwise it can be accessed normally. |
|
1465 |
*/ |
|
5 | 1466 |
if ( height.menu + height.adminbar < height.window || |
1467 |
height.menu + height.adminbar + 20 > height.wpwrap ) { |
|
1468 |
unpinMenu(); |
|
1469 |
return; |
|
1470 |
} |
|
1471 |
||
1472 |
menuIsPinned = true; |
|
1473 |
||
9 | 1474 |
// If the menu is higher than the window, compensate on scroll. |
5 | 1475 |
if ( height.menu + height.adminbar > height.window ) { |
9 | 1476 |
// Check for overscrolling, this happens when swiping up at the top of the document in modern browsers. |
5 | 1477 |
if ( windowPos < 0 ) { |
9 | 1478 |
// Stick the menu to the top. |
5 | 1479 |
if ( ! pinnedMenuTop ) { |
1480 |
pinnedMenuTop = true; |
|
1481 |
pinnedMenuBottom = false; |
|
1482 |
||
1483 |
$adminMenuWrap.css({ |
|
1484 |
position: 'fixed', |
|
1485 |
top: '', |
|
1486 |
bottom: '' |
|
1487 |
}); |
|
1488 |
} |
|
1489 |
||
1490 |
return; |
|
1491 |
} else if ( windowPos + height.window > $document.height() - 1 ) { |
|
9 | 1492 |
// When overscrolling at the bottom, stick the menu to the bottom. |
5 | 1493 |
if ( ! pinnedMenuBottom ) { |
1494 |
pinnedMenuBottom = true; |
|
1495 |
pinnedMenuTop = false; |
|
1496 |
||
1497 |
$adminMenuWrap.css({ |
|
1498 |
position: 'fixed', |
|
1499 |
top: '', |
|
1500 |
bottom: 0 |
|
1501 |
}); |
|
1502 |
} |
|
1503 |
||
1504 |
return; |
|
1505 |
} |
|
1506 |
||
1507 |
if ( windowPos > lastScrollPosition ) { |
|
9 | 1508 |
// When a down scroll has been detected. |
1509 |
||
1510 |
// If it was pinned to the top, unpin and calculate relative scroll. |
|
5 | 1511 |
if ( pinnedMenuTop ) { |
1512 |
pinnedMenuTop = false; |
|
9 | 1513 |
// Calculate new offset position. |
5 | 1514 |
menuTop = $adminMenuWrap.offset().top - height.adminbar - ( windowPos - lastScrollPosition ); |
1515 |
||
1516 |
if ( menuTop + height.menu + height.adminbar < windowPos + height.window ) { |
|
1517 |
menuTop = windowPos + height.window - height.menu - height.adminbar; |
|
1518 |
} |
|
1519 |
||
1520 |
$adminMenuWrap.css({ |
|
1521 |
position: 'absolute', |
|
1522 |
top: menuTop, |
|
1523 |
bottom: '' |
|
1524 |
}); |
|
1525 |
} else if ( ! pinnedMenuBottom && $adminMenuWrap.offset().top + height.menu < windowPos + height.window ) { |
|
9 | 1526 |
// Pin it to the bottom. |
5 | 1527 |
pinnedMenuBottom = true; |
1528 |
||
1529 |
$adminMenuWrap.css({ |
|
1530 |
position: 'fixed', |
|
1531 |
top: '', |
|
1532 |
bottom: 0 |
|
1533 |
}); |
|
1534 |
} |
|
1535 |
} else if ( windowPos < lastScrollPosition ) { |
|
9 | 1536 |
// When a scroll up is detected. |
1537 |
||
1538 |
// If it was pinned to the bottom, unpin and calculate relative scroll. |
|
5 | 1539 |
if ( pinnedMenuBottom ) { |
1540 |
pinnedMenuBottom = false; |
|
9 | 1541 |
|
1542 |
// Calculate new offset position. |
|
5 | 1543 |
menuTop = $adminMenuWrap.offset().top - height.adminbar + ( lastScrollPosition - windowPos ); |
1544 |
||
1545 |
if ( menuTop + height.menu > windowPos + height.window ) { |
|
1546 |
menuTop = windowPos; |
|
1547 |
} |
|
1548 |
||
1549 |
$adminMenuWrap.css({ |
|
1550 |
position: 'absolute', |
|
1551 |
top: menuTop, |
|
1552 |
bottom: '' |
|
1553 |
}); |
|
1554 |
} else if ( ! pinnedMenuTop && $adminMenuWrap.offset().top >= windowPos + height.adminbar ) { |
|
9 | 1555 |
|
1556 |
// Pin it to the top. |
|
5 | 1557 |
pinnedMenuTop = true; |
1558 |
||
1559 |
$adminMenuWrap.css({ |
|
1560 |
position: 'fixed', |
|
1561 |
top: '', |
|
1562 |
bottom: '' |
|
1563 |
}); |
|
1564 |
} |
|
1565 |
} else if ( resizing ) { |
|
9 | 1566 |
// Window is being resized. |
1567 |
||
5 | 1568 |
pinnedMenuTop = pinnedMenuBottom = false; |
9 | 1569 |
|
1570 |
// Calculate the new offset. |
|
5 | 1571 |
menuTop = windowPos + height.window - height.menu - height.adminbar - 1; |
1572 |
||
1573 |
if ( menuTop > 0 ) { |
|
1574 |
$adminMenuWrap.css({ |
|
1575 |
position: 'absolute', |
|
1576 |
top: menuTop, |
|
1577 |
bottom: '' |
|
1578 |
}); |
|
1579 |
} else { |
|
1580 |
unpinMenu(); |
|
1581 |
} |
|
1582 |
} |
|
1583 |
} |
|
1584 |
||
1585 |
lastScrollPosition = windowPos; |
|
1586 |
} |
|
1587 |
||
9 | 1588 |
/** |
1589 |
* Determines the height of certain elements. |
|
1590 |
* |
|
1591 |
* @since 4.1.0 |
|
1592 |
* |
|
16 | 1593 |
* @return {void} |
9 | 1594 |
*/ |
5 | 1595 |
function resetHeights() { |
1596 |
height = { |
|
1597 |
window: $window.height(), |
|
1598 |
wpwrap: $wpwrap.height(), |
|
1599 |
adminbar: $adminbar.height(), |
|
1600 |
menu: $adminMenuWrap.height() |
|
1601 |
}; |
|
1602 |
} |
|
1603 |
||
9 | 1604 |
/** |
1605 |
* Unpins the menu. |
|
1606 |
* |
|
1607 |
* @since 4.1.0 |
|
1608 |
* |
|
16 | 1609 |
* @return {void} |
9 | 1610 |
*/ |
5 | 1611 |
function unpinMenu() { |
1612 |
if ( isIOS || ! menuIsPinned ) { |
|
1613 |
return; |
|
1614 |
} |
|
1615 |
||
1616 |
pinnedMenuTop = pinnedMenuBottom = menuIsPinned = false; |
|
1617 |
$adminMenuWrap.css({ |
|
1618 |
position: '', |
|
1619 |
top: '', |
|
1620 |
bottom: '' |
|
1621 |
}); |
|
1622 |
} |
|
1623 |
||
9 | 1624 |
/** |
1625 |
* Pins and unpins the menu when applicable. |
|
1626 |
* |
|
1627 |
* @since 4.1.0 |
|
1628 |
* |
|
16 | 1629 |
* @return {void} |
9 | 1630 |
*/ |
5 | 1631 |
function setPinMenu() { |
1632 |
resetHeights(); |
|
1633 |
||
1634 |
if ( $adminmenu.data('wp-responsive') ) { |
|
1635 |
$body.removeClass( 'sticky-menu' ); |
|
1636 |
unpinMenu(); |
|
1637 |
} else if ( height.menu + height.adminbar > height.window ) { |
|
1638 |
pinMenu(); |
|
1639 |
$body.removeClass( 'sticky-menu' ); |
|
1640 |
} else { |
|
1641 |
$body.addClass( 'sticky-menu' ); |
|
1642 |
unpinMenu(); |
|
1643 |
} |
|
1644 |
} |
|
1645 |
||
1646 |
if ( ! isIOS ) { |
|
1647 |
$window.on( 'scroll.pin-menu', pinMenu ); |
|
1648 |
$document.on( 'tinymce-editor-init.pin-menu', function( event, editor ) { |
|
1649 |
editor.on( 'wp-autoresize', resetHeights ); |
|
1650 |
}); |
|
1651 |
} |
|
1652 |
||
9 | 1653 |
/** |
1654 |
* Changes the sortables and responsiveness of metaboxes. |
|
1655 |
* |
|
1656 |
* @since 3.8.0 |
|
1657 |
* |
|
16 | 1658 |
* @return {void} |
9 | 1659 |
*/ |
5 | 1660 |
window.wpResponsive = { |
9 | 1661 |
|
1662 |
/** |
|
1663 |
* Initializes the wpResponsive object. |
|
1664 |
* |
|
1665 |
* @since 3.8.0 |
|
1666 |
* |
|
16 | 1667 |
* @return {void} |
9 | 1668 |
*/ |
5 | 1669 |
init: function() { |
1670 |
var self = this; |
|
1671 |
||
16 | 1672 |
this.maybeDisableSortables = this.maybeDisableSortables.bind( this ); |
1673 |
||
1674 |
// Modify functionality based on custom activate/deactivate event. |
|
5 | 1675 |
$document.on( 'wp-responsive-activate.wp-responsive', function() { |
1676 |
self.activate(); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1677 |
self.toggleAriaHasPopup( 'add' ); |
5 | 1678 |
}).on( 'wp-responsive-deactivate.wp-responsive', function() { |
1679 |
self.deactivate(); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1680 |
self.toggleAriaHasPopup( 'remove' ); |
5 | 1681 |
}); |
1682 |
||
1683 |
$( '#wp-admin-bar-menu-toggle a' ).attr( 'aria-expanded', 'false' ); |
|
1684 |
||
9 | 1685 |
// Toggle sidebar when toggle is clicked. |
5 | 1686 |
$( '#wp-admin-bar-menu-toggle' ).on( 'click.wp-responsive', function( event ) { |
1687 |
event.preventDefault(); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1688 |
|
16 | 1689 |
// Close any open toolbar submenus. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1690 |
$adminbar.find( '.hover' ).removeClass( 'hover' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1691 |
|
5 | 1692 |
$wpwrap.toggleClass( 'wp-responsive-open' ); |
1693 |
if ( $wpwrap.hasClass( 'wp-responsive-open' ) ) { |
|
1694 |
$(this).find('a').attr( 'aria-expanded', 'true' ); |
|
18 | 1695 |
$( '#adminmenu a:first' ).trigger( 'focus' ); |
5 | 1696 |
} else { |
1697 |
$(this).find('a').attr( 'aria-expanded', 'false' ); |
|
1698 |
} |
|
1699 |
} ); |
|
1700 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1701 |
// Close sidebar when target moves outside of toggle and sidebar. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1702 |
$( document ).on( 'click', function( event ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1703 |
if ( ! $wpwrap.hasClass( 'wp-responsive-open' ) || ! document.hasFocus() ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1704 |
return; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1705 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1706 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1707 |
var focusIsInToggle = $.contains( $( '#wp-admin-bar-menu-toggle' )[0], event.target ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1708 |
var focusIsInSidebar = $.contains( $( '#adminmenuwrap' )[0], event.target ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1709 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1710 |
if ( ! focusIsInToggle && ! focusIsInSidebar ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1711 |
$( '#wp-admin-bar-menu-toggle' ).trigger( 'click.wp-responsive' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1712 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1713 |
} ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1714 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1715 |
// Close sidebar when a keypress completes outside of toggle and sidebar. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1716 |
$( document ).on( 'keyup', function( event ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1717 |
var toggleButton = $( '#wp-admin-bar-menu-toggle' )[0]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1718 |
if ( ! $wpwrap.hasClass( 'wp-responsive-open' ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1719 |
return; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1720 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1721 |
if ( 27 === event.keyCode ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1722 |
$( toggleButton ).trigger( 'click.wp-responsive' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1723 |
$( toggleButton ).find( 'a' ).trigger( 'focus' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1724 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1725 |
if ( 9 === event.keyCode ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1726 |
var sidebar = $( '#adminmenuwrap' )[0]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1727 |
var focusedElement = event.relatedTarget || document.activeElement; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1728 |
// A brief delay is required to allow focus to switch to another element. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1729 |
setTimeout( function() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1730 |
var focusIsInToggle = $.contains( toggleButton, focusedElement ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1731 |
var focusIsInSidebar = $.contains( sidebar, focusedElement ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1732 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1733 |
if ( ! focusIsInToggle && ! focusIsInSidebar ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1734 |
$( toggleButton ).trigger( 'click.wp-responsive' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1735 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1736 |
}, 10 ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1737 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1738 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1739 |
}); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1740 |
|
9 | 1741 |
// Add menu events. |
5 | 1742 |
$adminmenu.on( 'click.wp-responsive', 'li.wp-has-submenu > a', function( event ) { |
1743 |
if ( ! $adminmenu.data('wp-responsive') ) { |
|
1744 |
return; |
|
1745 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1746 |
let state = ( 'false' === $( this ).attr( 'aria-expanded' ) ) ? 'true' : 'false'; |
5 | 1747 |
$( this ).parent( 'li' ).toggleClass( 'selected' ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1748 |
$( this ).attr( 'aria-expanded', state ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1749 |
$( this ).trigger( 'focus' ); |
5 | 1750 |
event.preventDefault(); |
1751 |
}); |
|
1752 |
||
1753 |
self.trigger(); |
|
18 | 1754 |
$document.on( 'wp-window-resized.wp-responsive', this.trigger.bind( this ) ); |
5 | 1755 |
|
19 | 1756 |
// This needs to run later as UI Sortable may be initialized when the document is ready. |
16 | 1757 |
$window.on( 'load.wp-responsive', this.maybeDisableSortables ); |
1758 |
$document.on( 'postbox-toggled', this.maybeDisableSortables ); |
|
1759 |
||
1760 |
// When the screen columns are changed, potentially disable sortables. |
|
1761 |
$( '#screen-options-wrap input' ).on( 'click', this.maybeDisableSortables ); |
|
1762 |
}, |
|
5 | 1763 |
|
16 | 1764 |
/** |
1765 |
* Disable sortables if there is only one metabox, or the screen is in one column mode. Otherwise, enable sortables. |
|
1766 |
* |
|
1767 |
* @since 5.3.0 |
|
1768 |
* |
|
1769 |
* @return {void} |
|
1770 |
*/ |
|
1771 |
maybeDisableSortables: function() { |
|
1772 |
var width = navigator.userAgent.indexOf('AppleWebKit/') > -1 ? $window.width() : window.innerWidth; |
|
1773 |
||
1774 |
if ( |
|
1775 |
( width <= 782 ) || |
|
1776 |
( 1 >= $sortables.find( '.ui-sortable-handle:visible' ).length && jQuery( '.columns-prefs-1 input' ).prop( 'checked' ) ) |
|
1777 |
) { |
|
1778 |
this.disableSortables(); |
|
1779 |
} else { |
|
1780 |
this.enableSortables(); |
|
1781 |
} |
|
5 | 1782 |
}, |
1783 |
||
9 | 1784 |
/** |
1785 |
* Changes properties of body and admin menu. |
|
1786 |
* |
|
1787 |
* Pins and unpins the menu and adds the auto-fold class to the body. |
|
1788 |
* Makes the admin menu responsive and disables the metabox sortables. |
|
1789 |
* |
|
1790 |
* @since 3.8.0 |
|
1791 |
* |
|
16 | 1792 |
* @return {void} |
9 | 1793 |
*/ |
5 | 1794 |
activate: function() { |
1795 |
setPinMenu(); |
|
1796 |
||
1797 |
if ( ! $body.hasClass( 'auto-fold' ) ) { |
|
1798 |
$body.addClass( 'auto-fold' ); |
|
1799 |
} |
|
1800 |
||
1801 |
$adminmenu.data( 'wp-responsive', 1 ); |
|
1802 |
this.disableSortables(); |
|
1803 |
}, |
|
1804 |
||
9 | 1805 |
/** |
1806 |
* Changes properties of admin menu and enables metabox sortables. |
|
1807 |
* |
|
1808 |
* Pin and unpin the menu. |
|
1809 |
* Removes the responsiveness of the admin menu and enables the metabox sortables. |
|
1810 |
* |
|
1811 |
* @since 3.8.0 |
|
1812 |
* |
|
16 | 1813 |
* @return {void} |
9 | 1814 |
*/ |
5 | 1815 |
deactivate: function() { |
1816 |
setPinMenu(); |
|
1817 |
$adminmenu.removeData('wp-responsive'); |
|
16 | 1818 |
|
1819 |
this.maybeDisableSortables(); |
|
5 | 1820 |
}, |
1821 |
||
9 | 1822 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1823 |
* Toggles the aria-haspopup attribute for the responsive admin menu. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1824 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1825 |
* The aria-haspopup attribute is only necessary for the responsive menu. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1826 |
* See ticket https://core.trac.wordpress.org/ticket/43095 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1827 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1828 |
* @since 6.6.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1829 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1830 |
* @param {string} action Whether to add or remove the aria-haspopup attribute. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1831 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1832 |
* @return {void} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1833 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1834 |
toggleAriaHasPopup: function( action ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1835 |
var elements = $adminmenu.find( '[data-ariahaspopup]' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1836 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1837 |
if ( action === 'add' ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1838 |
elements.each( function() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1839 |
$( this ).attr( 'aria-haspopup', 'menu' ).attr( 'aria-expanded', 'false' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1840 |
} ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1841 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1842 |
return; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1843 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1844 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1845 |
elements.each( function() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1846 |
$( this ).removeAttr( 'aria-haspopup' ).removeAttr( 'aria-expanded' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1847 |
} ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1848 |
}, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1849 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1850 |
/** |
9 | 1851 |
* Sets the responsiveness and enables the overlay based on the viewport width. |
1852 |
* |
|
1853 |
* @since 3.8.0 |
|
1854 |
* |
|
16 | 1855 |
* @return {void} |
9 | 1856 |
*/ |
5 | 1857 |
trigger: function() { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1858 |
var viewportWidth = getViewportWidth(); |
5 | 1859 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1860 |
// Exclude IE < 9, it doesn't support @media CSS rules. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1861 |
if ( ! viewportWidth ) { |
5 | 1862 |
return; |
1863 |
} |
|
1864 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1865 |
if ( viewportWidth <= 782 ) { |
5 | 1866 |
if ( ! wpResponsiveActive ) { |
1867 |
$document.trigger( 'wp-responsive-activate' ); |
|
1868 |
wpResponsiveActive = true; |
|
1869 |
} |
|
1870 |
} else { |
|
1871 |
if ( wpResponsiveActive ) { |
|
1872 |
$document.trigger( 'wp-responsive-deactivate' ); |
|
1873 |
wpResponsiveActive = false; |
|
1874 |
} |
|
1875 |
} |
|
1876 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1877 |
if ( viewportWidth <= 480 ) { |
5 | 1878 |
this.enableOverlay(); |
1879 |
} else { |
|
1880 |
this.disableOverlay(); |
|
1881 |
} |
|
16 | 1882 |
|
1883 |
this.maybeDisableSortables(); |
|
5 | 1884 |
}, |
1885 |
||
9 | 1886 |
/** |
1887 |
* Inserts a responsive overlay and toggles the window. |
|
1888 |
* |
|
1889 |
* @since 3.8.0 |
|
1890 |
* |
|
16 | 1891 |
* @return {void} |
9 | 1892 |
*/ |
5 | 1893 |
enableOverlay: function() { |
1894 |
if ( $overlay.length === 0 ) { |
|
1895 |
$overlay = $( '<div id="wp-responsive-overlay"></div>' ) |
|
1896 |
.insertAfter( '#wpcontent' ) |
|
1897 |
.hide() |
|
1898 |
.on( 'click.wp-responsive', function() { |
|
1899 |
$toolbar.find( '.menupop.hover' ).removeClass( 'hover' ); |
|
1900 |
$( this ).hide(); |
|
1901 |
}); |
|
1902 |
} |
|
1903 |
||
1904 |
$toolbarPopups.on( 'click.wp-responsive', function() { |
|
1905 |
$overlay.show(); |
|
1906 |
}); |
|
1907 |
}, |
|
1908 |
||
9 | 1909 |
/** |
1910 |
* Disables the responsive overlay and removes the overlay. |
|
1911 |
* |
|
1912 |
* @since 3.8.0 |
|
1913 |
* |
|
16 | 1914 |
* @return {void} |
9 | 1915 |
*/ |
5 | 1916 |
disableOverlay: function() { |
1917 |
$toolbarPopups.off( 'click.wp-responsive' ); |
|
1918 |
$overlay.hide(); |
|
1919 |
}, |
|
1920 |
||
9 | 1921 |
/** |
1922 |
* Disables sortables. |
|
1923 |
* |
|
1924 |
* @since 3.8.0 |
|
1925 |
* |
|
16 | 1926 |
* @return {void} |
9 | 1927 |
*/ |
5 | 1928 |
disableSortables: function() { |
1929 |
if ( $sortables.length ) { |
|
1930 |
try { |
|
9 | 1931 |
$sortables.sortable( 'disable' ); |
16 | 1932 |
$sortables.find( '.ui-sortable-handle' ).addClass( 'is-non-sortable' ); |
9 | 1933 |
} catch ( e ) {} |
5 | 1934 |
} |
1935 |
}, |
|
1936 |
||
9 | 1937 |
/** |
1938 |
* Enables sortables. |
|
1939 |
* |
|
1940 |
* @since 3.8.0 |
|
1941 |
* |
|
16 | 1942 |
* @return {void} |
9 | 1943 |
*/ |
5 | 1944 |
enableSortables: function() { |
1945 |
if ( $sortables.length ) { |
|
1946 |
try { |
|
9 | 1947 |
$sortables.sortable( 'enable' ); |
16 | 1948 |
$sortables.find( '.ui-sortable-handle' ).removeClass( 'is-non-sortable' ); |
9 | 1949 |
} catch ( e ) {} |
5 | 1950 |
} |
1951 |
} |
|
1952 |
}; |
|
1953 |
||
9 | 1954 |
/** |
1955 |
* Add an ARIA role `button` to elements that behave like UI controls when JavaScript is on. |
|
1956 |
* |
|
1957 |
* @since 4.5.0 |
|
1958 |
* |
|
16 | 1959 |
* @return {void} |
9 | 1960 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1961 |
function aria_button_if_js() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1962 |
$( '.aria-button-if-js' ).attr( 'role', 'button' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1963 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1964 |
|
18 | 1965 |
$( document ).on( 'ajaxComplete', function() { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1966 |
aria_button_if_js(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1967 |
}); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1968 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1969 |
/** |
9 | 1970 |
* Get the viewport width. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1971 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1972 |
* @since 4.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1973 |
* |
16 | 1974 |
* @return {number|boolean} The current viewport width or false if the |
1975 |
* browser doesn't support innerWidth (IE < 9). |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1976 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1977 |
function getViewportWidth() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1978 |
var viewportWidth = false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1979 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1980 |
if ( window.innerWidth ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1981 |
// On phones, window.innerWidth is affected by zooming. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1982 |
viewportWidth = Math.max( window.innerWidth, document.documentElement.clientWidth ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1983 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1984 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1985 |
return viewportWidth; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1986 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1987 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1988 |
/** |
9 | 1989 |
* Sets the admin menu collapsed/expanded state. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1990 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1991 |
* Sets the global variable `menuState` and triggers a custom event passing |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1992 |
* the current menu state. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1993 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1994 |
* @since 4.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1995 |
* |
16 | 1996 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1997 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1998 |
function setMenuState() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1999 |
var viewportWidth = getViewportWidth() || 961; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2000 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2001 |
if ( viewportWidth <= 782 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2002 |
menuState = 'responsive'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2003 |
} else if ( $body.hasClass( 'folded' ) || ( $body.hasClass( 'auto-fold' ) && viewportWidth <= 960 && viewportWidth > 782 ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2004 |
menuState = 'folded'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2005 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2006 |
menuState = 'open'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2007 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2008 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2009 |
$document.trigger( 'wp-menu-state-set', { state: menuState } ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2010 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2011 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2012 |
// Set the menu state when the window gets resized. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2013 |
$document.on( 'wp-window-resized.set-menu-state', setMenuState ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2014 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2015 |
/** |
9 | 2016 |
* Sets ARIA attributes on the collapse/expand menu button. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2017 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2018 |
* When the admin menu is open or folded, updates the `aria-expanded` and |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2019 |
* `aria-label` attributes of the button to give feedback to assistive |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2020 |
* technologies. In the responsive view, the button is always hidden. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2021 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2022 |
* @since 4.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2023 |
* |
16 | 2024 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2025 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2026 |
$document.on( 'wp-menu-state-set wp-collapse-menu', function( event, eventData ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2027 |
var $collapseButton = $( '#collapse-button' ), |
16 | 2028 |
ariaExpanded, ariaLabelText; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2029 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2030 |
if ( 'folded' === eventData.state ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2031 |
ariaExpanded = 'false'; |
16 | 2032 |
ariaLabelText = __( 'Expand Main menu' ); |
2033 |
} else { |
|
2034 |
ariaExpanded = 'true'; |
|
2035 |
ariaLabelText = __( 'Collapse Main menu' ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2036 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2037 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2038 |
$collapseButton.attr({ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2039 |
'aria-expanded': ariaExpanded, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2040 |
'aria-label': ariaLabelText |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2041 |
}); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2042 |
}); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2043 |
|
5 | 2044 |
window.wpResponsive.init(); |
2045 |
setPinMenu(); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2046 |
setMenuState(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2047 |
makeNoticesDismissible(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2048 |
aria_button_if_js(); |
5 | 2049 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2050 |
$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 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2051 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2052 |
// Set initial focus on a specific element. |
18 | 2053 |
$( '.wp-initial-focus' ).trigger( 'focus' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2054 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2055 |
// Toggle update details on update-core.php. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2056 |
$body.on( 'click', '.js-update-details-toggle', function() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2057 |
var $updateNotice = $( this ).closest( '.js-update-details' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2058 |
$progressDiv = $( '#' + $updateNotice.data( 'update-details' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2059 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2060 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2061 |
* When clicking on "Show details" move the progress div below the update |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2062 |
* notice. Make sure it gets moved just the first time. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2063 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2064 |
if ( ! $progressDiv.hasClass( 'update-details-moved' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2065 |
$progressDiv.insertAfter( $updateNotice ).addClass( 'update-details-moved' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2066 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2067 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2068 |
// Toggle the progress div visibility. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2069 |
$progressDiv.toggle(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2070 |
// Toggle the Show Details button expanded state. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2071 |
$( this ).attr( 'aria-expanded', $progressDiv.is( ':visible' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2072 |
}); |
0 | 2073 |
}); |
2074 |
||
16 | 2075 |
/** |
2076 |
* Hides the update button for expired plugin or theme uploads. |
|
2077 |
* |
|
2078 |
* On the "Update plugin/theme from uploaded zip" screen, once the upload has expired, |
|
2079 |
* hides the "Replace current with uploaded" button and displays a warning. |
|
2080 |
* |
|
2081 |
* @since 5.5.0 |
|
2082 |
*/ |
|
18 | 2083 |
$( function( $ ) { |
16 | 2084 |
var $overwrite, $warning; |
2085 |
||
2086 |
if ( ! $body.hasClass( 'update-php' ) ) { |
|
2087 |
return; |
|
2088 |
} |
|
2089 |
||
2090 |
$overwrite = $( 'a.update-from-upload-overwrite' ); |
|
2091 |
$warning = $( '.update-from-upload-expired' ); |
|
2092 |
||
2093 |
if ( ! $overwrite.length || ! $warning.length ) { |
|
2094 |
return; |
|
2095 |
} |
|
2096 |
||
2097 |
window.setTimeout( |
|
2098 |
function() { |
|
2099 |
$overwrite.hide(); |
|
2100 |
$warning.removeClass( 'hidden' ); |
|
2101 |
||
2102 |
if ( window.wp && window.wp.a11y ) { |
|
2103 |
window.wp.a11y.speak( $warning.text() ); |
|
2104 |
} |
|
2105 |
}, |
|
2106 |
7140000 // 119 minutes. The uploaded file is deleted after 2 hours. |
|
2107 |
); |
|
2108 |
} ); |
|
2109 |
||
9 | 2110 |
// Fire a custom jQuery event at the end of window resize. |
5 | 2111 |
( function() { |
2112 |
var timeout; |
|
2113 |
||
9 | 2114 |
/** |
2115 |
* Triggers the WP window-resize event. |
|
2116 |
* |
|
2117 |
* @since 3.8.0 |
|
2118 |
* |
|
16 | 2119 |
* @return {void} |
9 | 2120 |
*/ |
5 | 2121 |
function triggerEvent() { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2122 |
$document.trigger( 'wp-window-resized' ); |
5 | 2123 |
} |
2124 |
||
9 | 2125 |
/** |
2126 |
* Fires the trigger event again after 200 ms. |
|
2127 |
* |
|
2128 |
* @since 3.8.0 |
|
2129 |
* |
|
16 | 2130 |
* @return {void} |
9 | 2131 |
*/ |
5 | 2132 |
function fireOnce() { |
2133 |
window.clearTimeout( timeout ); |
|
2134 |
timeout = window.setTimeout( triggerEvent, 200 ); |
|
2135 |
} |
|
0 | 2136 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2137 |
$window.on( 'resize.wp-fire-once', fireOnce ); |
5 | 2138 |
}()); |
0 | 2139 |
|
5 | 2140 |
// Make Windows 8 devices play along nicely. |
2141 |
(function(){ |
|
2142 |
if ( '-ms-user-select' in document.documentElement.style && navigator.userAgent.match(/IEMobile\/10\.0/) ) { |
|
2143 |
var msViewportStyle = document.createElement( 'style' ); |
|
2144 |
msViewportStyle.appendChild( |
|
2145 |
document.createTextNode( '@-ms-viewport{width:auto!important}' ) |
|
2146 |
); |
|
2147 |
document.getElementsByTagName( 'head' )[0].appendChild( msViewportStyle ); |
|
2148 |
} |
|
2149 |
})(); |
|
0 | 2150 |
|
5 | 2151 |
}( jQuery, window )); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2152 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2153 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2154 |
* Freeze animated plugin icons when reduced motion is enabled. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2155 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2156 |
* When the user has enabled the 'prefers-reduced-motion' setting, this module |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2157 |
* stops animations for all GIFs on the page with the class 'plugin-icon' or |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2158 |
* plugin icon images in the update plugins table. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2159 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2160 |
* @since 6.4.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2161 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2162 |
(function() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2163 |
// Private variables and methods. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2164 |
var priv = {}, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2165 |
pub = {}, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2166 |
mediaQuery; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2167 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2168 |
// Initialize pauseAll to false; it will be set to true if reduced motion is preferred. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2169 |
priv.pauseAll = false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2170 |
if ( window.matchMedia ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2171 |
mediaQuery = window.matchMedia( '(prefers-reduced-motion: reduce)' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2172 |
if ( ! mediaQuery || mediaQuery.matches ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2173 |
priv.pauseAll = true; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2174 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2175 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2176 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2177 |
// Method to replace animated GIFs with a static frame. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2178 |
priv.freezeAnimatedPluginIcons = function( img ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2179 |
var coverImage = function() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2180 |
var width = img.width; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2181 |
var height = img.height; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2182 |
var canvas = document.createElement( 'canvas' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2183 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2184 |
// Set canvas dimensions. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2185 |
canvas.width = width; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2186 |
canvas.height = height; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2187 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2188 |
// Copy classes from the image to the canvas. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2189 |
canvas.className = img.className; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2190 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2191 |
// Check if the image is inside a specific table. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2192 |
var isInsideUpdateTable = img.closest( '#update-plugins-table' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2193 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2194 |
if ( isInsideUpdateTable ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2195 |
// Transfer computed styles from image to canvas. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2196 |
var computedStyles = window.getComputedStyle( img ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2197 |
i, max; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2198 |
for ( i = 0, max = computedStyles.length; i < max; i++ ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2199 |
var propName = computedStyles[ i ]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2200 |
var propValue = computedStyles.getPropertyValue( propName ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2201 |
canvas.style[ propName ] = propValue; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2202 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2203 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2204 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2205 |
// Draw the image onto the canvas. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2206 |
canvas.getContext( '2d' ).drawImage( img, 0, 0, width, height ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2207 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2208 |
// Set accessibility attributes on canvas. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2209 |
canvas.setAttribute( 'aria-hidden', 'true' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2210 |
canvas.setAttribute( 'role', 'presentation' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2211 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2212 |
// Insert canvas before the image and set the image to be near-invisible. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2213 |
var parent = img.parentNode; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2214 |
parent.insertBefore( canvas, img ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2215 |
img.style.opacity = 0.01; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2216 |
img.style.width = '0px'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2217 |
img.style.height = '0px'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2218 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2219 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2220 |
// If the image is already loaded, apply the coverImage function. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2221 |
if ( img.complete ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2222 |
coverImage(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2223 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2224 |
// Otherwise, wait for the image to load. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2225 |
img.addEventListener( 'load', coverImage, true ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2226 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2227 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2228 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2229 |
// Public method to freeze all relevant GIFs on the page. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2230 |
pub.freezeAll = function() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2231 |
var images = document.querySelectorAll( '.plugin-icon, #update-plugins-table img' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2232 |
for ( var x = 0; x < images.length; x++ ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2233 |
if ( /\.gif(?:\?|$)/i.test( images[ x ].src ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2234 |
priv.freezeAnimatedPluginIcons( images[ x ] ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2235 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2236 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2237 |
}; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2238 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2239 |
// Only run the freezeAll method if the user prefers reduced motion. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2240 |
if ( true === priv.pauseAll ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2241 |
pub.freezeAll(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2242 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2243 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2244 |
// Listen for jQuery AJAX events. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2245 |
( function( $ ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2246 |
if ( window.pagenow === 'plugin-install' ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2247 |
// Only listen for ajaxComplete if this is the plugin-install.php page. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2248 |
$( document ).ajaxComplete( function( event, xhr, settings ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2249 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2250 |
// Check if this is the 'search-install-plugins' request. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2251 |
if ( settings.data && typeof settings.data === 'string' && settings.data.includes( 'action=search-install-plugins' ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2252 |
// Recheck if the user prefers reduced motion. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2253 |
if ( window.matchMedia ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2254 |
var mediaQuery = window.matchMedia( '(prefers-reduced-motion: reduce)' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2255 |
if ( mediaQuery.matches ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2256 |
pub.freezeAll(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2257 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2258 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2259 |
// Fallback for browsers that don't support matchMedia. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2260 |
if ( true === priv.pauseAll ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2261 |
pub.freezeAll(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2262 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2263 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2264 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2265 |
} ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2266 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2267 |
} )( jQuery ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2268 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2269 |
// Expose public methods. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2270 |
return pub; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2271 |
})(); |