1 /* global setUserSetting, ajaxurl, commonL10n, alert, confirm, pagenow */
2 var showNotice, adminMenu, columns, validateForm, screenMeta;
3 ( function( $, window, undefined ) {
4 var $document = $( document ),
6 $body = $( document.body );
9 // (perhaps) needed for back-compat
13 restoreMenuState : function() {},
14 toggle : function() {},
15 favorites : function() {}
18 // show/hide/save table columns
22 $('.hide-column-tog', '#adv-settings').click( function() {
23 var $t = $(this), column = $t.val();
24 if ( $t.prop('checked') )
27 that.unchecked(column);
29 columns.saveManageColumnsState();
33 saveManageColumnsState : function() {
34 var hidden = this.hidden();
36 action: 'hidden-columns',
38 screenoptionnonce: $('#screenoptionnonce').val(),
43 checked : function(column) {
44 $('.column-' + column).removeClass( 'hidden' );
45 this.colSpanChange(+1);
48 unchecked : function(column) {
49 $('.column-' + column).addClass( 'hidden' );
50 this.colSpanChange(-1);
54 return $( '.manage-column[id]' ).filter( ':hidden' ).map(function() {
59 useCheckboxesForHidden : function() {
60 this.hidden = function(){
61 return $('.hide-column-tog').not(':checked').map(function() {
63 return id.substring( id, id.length - 5 );
68 colSpanChange : function(diff) {
69 var $t = $('table').find('.colspanchange'), n;
72 n = parseInt( $t.attr('colspan'), 10 ) + diff;
73 $t.attr('colspan', n.toString());
77 $document.ready(function(){columns.init();});
79 validateForm = function( form ) {
81 .find( '.form-required' )
82 .filter( function() { return $( 'input:visible', this ).val() === ''; } )
83 .addClass( 'form-invalid' )
84 .find( 'input:visible' )
85 .change( function() { $( this ).closest( '.form-invalid' ).removeClass( 'form-invalid' ); } )
89 // stub for doing better warnings
92 var msg = commonL10n.warnDelete || '';
100 note : function(text) {
106 element: null, // #screen-meta
107 toggles: null, // .screen-meta-toggle
108 page: null, // #wpcontent
111 this.element = $('#screen-meta');
112 this.toggles = $( '#screen-meta-links' ).find( '.show-settings' );
113 this.page = $('#wpcontent');
115 this.toggles.click( this.toggleEvent );
118 toggleEvent: function() {
119 var panel = $( '#' + $( this ).attr( 'aria-controls' ) );
124 if ( panel.is(':visible') )
125 screenMeta.close( panel, $(this) );
127 screenMeta.open( panel, $(this) );
130 open: function( panel, button ) {
132 $( '#screen-meta-links' ).find( '.screen-meta-toggle' ).not( button.parent() ).css( 'visibility', 'hidden' );
134 panel.parent().show();
135 panel.slideDown( 'fast', function() {
137 button.addClass( 'screen-meta-active' ).attr( 'aria-expanded', true );
140 $document.trigger( 'screen:options:open' );
143 close: function( panel, button ) {
144 panel.slideUp( 'fast', function() {
145 button.removeClass( 'screen-meta-active' ).attr( 'aria-expanded', false );
146 $('.screen-meta-toggle').css('visibility', '');
147 panel.parent().hide();
150 $document.trigger( 'screen:options:close' );
157 $('.contextual-help-tabs').delegate('a', 'click', function(e) {
163 // Don't do anything if the click is for the tab already showing.
164 if ( link.is('.active a') )
168 $('.contextual-help-tabs .active').removeClass('active');
169 link.parent('li').addClass('active');
171 panel = $( link.attr('href') );
174 $('.help-tab-content').not( panel ).removeClass('active').hide();
175 panel.addClass('active').show();
178 $document.ready( function() {
179 var checks, first, last, checked, sliced, mobileEvent, transitionTimeout, focusedRowActions,
181 pageInput = $('input.current-page'),
182 currentPage = pageInput.val(),
183 isIOS = /iPhone|iPad|iPod/.test( navigator.userAgent ),
184 isAndroid = navigator.userAgent.indexOf( 'Android' ) !== -1,
185 isIE8 = $( document.documentElement ).hasClass( 'ie8' ),
186 $adminMenuWrap = $( '#adminmenuwrap' ),
187 $wpwrap = $( '#wpwrap' ),
188 $adminmenu = $( '#adminmenu' ),
189 $overlay = $( '#wp-responsive-overlay' ),
190 $toolbar = $( '#wp-toolbar' ),
191 $toolbarPopups = $toolbar.find( 'a[aria-haspopup="true"]' ),
192 $sortables = $('.meta-box-sortables'),
193 wpResponsiveActive = false,
194 $adminbar = $( '#wpadminbar' ),
195 lastScrollPosition = 0,
196 pinnedMenuTop = false,
197 pinnedMenuBottom = false,
199 menuIsPinned = false,
201 window: $window.height(),
202 wpwrap: $wpwrap.height(),
203 adminbar: $adminbar.height(),
204 menu: $adminMenuWrap.height()
208 // when the menu is folded, make the fly-out submenu header clickable
209 $adminmenu.on('click.wp-submenu-head', '.wp-submenu-head', function(e){
210 $(e.target).parent().siblings('a').get(0).click();
213 $('#collapse-menu').on('click.collapse-menu', function() {
214 var respWidth, state;
216 // reset any compensation for submenus near the bottom of the screen
217 $('#adminmenu div.wp-submenu').css('margin-top', '');
219 if ( window.innerWidth ) {
220 // window.innerWidth is affected by zooming on phones
221 respWidth = Math.max( window.innerWidth, document.documentElement.clientWidth );
223 // IE < 9 doesn't support @media CSS rules
227 if ( respWidth && respWidth < 960 ) {
228 if ( $body.hasClass('auto-fold') ) {
229 $body.removeClass('auto-fold').removeClass('folded');
230 setUserSetting('unfold', 1);
231 setUserSetting('mfold', 'o');
234 $body.addClass('auto-fold');
235 setUserSetting('unfold', 0);
239 if ( $body.hasClass('folded') ) {
240 $body.removeClass('folded');
241 setUserSetting('mfold', 'o');
244 $body.addClass('folded');
245 setUserSetting('mfold', 'f');
250 currentMenuItemHasPopup();
251 $document.trigger( 'wp-collapse-menu', { state: state } );
254 // Handle the `aria-haspopup` attribute on the current menu item when it has a sub-menu.
255 function currentMenuItemHasPopup() {
257 $current = $( 'a.wp-has-current-submenu' );
259 if ( window.innerWidth ) {
260 respWidth = Math.max( window.innerWidth, document.documentElement.clientWidth );
265 if ( $body.hasClass( 'folded' ) || ( $body.hasClass( 'auto-fold' ) && respWidth && respWidth <= 960 && respWidth > 782 ) ) {
266 // When folded or auto-folded and not responsive view, the current menu item does have a fly-out sub-menu.
267 $current.attr( 'aria-haspopup', 'true' );
269 // When expanded or in responsive view, reset aria-haspopup.
270 $current.attr( 'aria-haspopup', 'false' );
274 $document.on( 'wp-window-resized wp-responsive-activate wp-responsive-deactivate', currentMenuItemHasPopup );
277 * Ensure an admin submenu is within the visual viewport.
281 * @param {jQuery} $menuItem The parent menu item containing the submenu.
283 function adjustSubmenu( $menuItem ) {
284 var bottomOffset, pageHeight, adjustment, theFold, menutop, wintop, maxtop,
285 $submenu = $menuItem.find( '.wp-submenu' );
287 menutop = $menuItem.offset().top;
288 wintop = $window.scrollTop();
289 maxtop = menutop - wintop - 30; // max = make the top of the sub almost touch admin bar
291 bottomOffset = menutop + $submenu.height() + 1; // Bottom offset of the menu
292 pageHeight = $wpwrap.height(); // Height of the entire page
293 adjustment = 60 + bottomOffset - pageHeight;
294 theFold = $window.height() + wintop - 50; // The fold
296 if ( theFold < ( bottomOffset - adjustment ) ) {
297 adjustment = bottomOffset - theFold;
300 if ( adjustment > maxtop ) {
304 if ( adjustment > 1 ) {
305 $submenu.css( 'margin-top', '-' + adjustment + 'px' );
307 $submenu.css( 'margin-top', '' );
311 if ( 'ontouchstart' in window || /IEMobile\/[1-9]/.test(navigator.userAgent) ) { // touch screen device
312 // iOS Safari works with touchstart, the rest work with click
313 mobileEvent = isIOS ? 'touchstart' : 'click';
315 // close any open submenus when touch/click is not on the menu
316 $body.on( mobileEvent+'.wp-mobile-hover', function(e) {
317 if ( $adminmenu.data('wp-responsive') ) {
321 if ( ! $( e.target ).closest( '#adminmenu' ).length ) {
322 $adminmenu.find( 'li.opensub' ).removeClass( 'opensub' );
326 $adminmenu.find( 'a.wp-has-submenu' ).on( mobileEvent + '.wp-mobile-hover', function( event ) {
327 var $menuItem = $(this).parent();
329 if ( $adminmenu.data( 'wp-responsive' ) ) {
333 // Show the sub instead of following the link if:
334 // - the submenu is not open
335 // - the submenu is not shown inline or the menu is not folded
336 if ( ! $menuItem.hasClass( 'opensub' ) && ( ! $menuItem.hasClass( 'wp-menu-open' ) || $menuItem.width() < 40 ) ) {
337 event.preventDefault();
338 adjustSubmenu( $menuItem );
339 $adminmenu.find( 'li.opensub' ).removeClass( 'opensub' );
340 $menuItem.addClass('opensub');
345 if ( ! isIOS && ! isAndroid ) {
346 $adminmenu.find( 'li.wp-has-submenu' ).hoverIntent({
348 var $menuItem = $( this ),
349 $submenu = $menuItem.find( '.wp-submenu' ),
350 top = parseInt( $submenu.css( 'top' ), 10 );
352 if ( isNaN( top ) || top > -5 ) { // the submenu is visible
356 if ( $adminmenu.data( 'wp-responsive' ) ) {
357 // The menu is in responsive mode, bail
361 adjustSubmenu( $menuItem );
362 $adminmenu.find( 'li.opensub' ).removeClass( 'opensub' );
363 $menuItem.addClass( 'opensub' );
366 if ( $adminmenu.data( 'wp-responsive' ) ) {
367 // The menu is in responsive mode, bail
371 $( this ).removeClass( 'opensub' ).find( '.wp-submenu' ).css( 'margin-top', '' );
378 $adminmenu.on( 'focus.adminmenu', '.wp-submenu a', function( event ) {
379 if ( $adminmenu.data( 'wp-responsive' ) ) {
380 // The menu is in responsive mode, bail
384 $( event.target ).closest( 'li.menu-top' ).addClass( 'opensub' );
385 }).on( 'blur.adminmenu', '.wp-submenu a', function( event ) {
386 if ( $adminmenu.data( 'wp-responsive' ) ) {
390 $( event.target ).closest( 'li.menu-top' ).removeClass( 'opensub' );
391 }).find( 'li.wp-has-submenu.wp-not-current-submenu' ).on( 'focusin.adminmenu', function() {
392 adjustSubmenu( $( this ) );
397 * The `.below-h2` class is here just for backward compatibility with plugins
398 * that are (incorrectly) using it. Do not use. Use `.inline` instead. See #34570.
400 $( 'div.updated, div.error, div.notice' ).not( '.inline, .below-h2' ).insertAfter( $( '.wrap h1, .wrap h2' ).first() );
402 // Make notices dismissible
403 function makeNoticesDismissible() {
404 $( '.notice.is-dismissible' ).each( function() {
406 $button = $( '<button type="button" class="notice-dismiss"><span class="screen-reader-text"></span></button>' ),
407 btnText = commonL10n.dismiss || '';
410 $button.find( '.screen-reader-text' ).text( btnText );
411 $button.on( 'click.wp-dismiss-notice', function( event ) {
412 event.preventDefault();
413 $el.fadeTo( 100, 0, function() {
414 $el.slideUp( 100, function() {
420 $el.append( $button );
424 $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 );
429 // check all checkboxes
430 $('tbody').children().children('.check-column').find(':checkbox').click( function(e) {
431 if ( 'undefined' == e.shiftKey ) { return true; }
433 if ( !lastClicked ) { return true; }
434 checks = $( lastClicked ).closest( 'form' ).find( ':checkbox' ).filter( ':visible:enabled' );
435 first = checks.index( lastClicked );
436 last = checks.index( this );
437 checked = $(this).prop('checked');
438 if ( 0 < first && 0 < last && first != last ) {
439 sliced = ( last > first ) ? checks.slice( first, last ) : checks.slice( last, first );
440 sliced.prop( 'checked', function() {
441 if ( $(this).closest('tr').is(':visible') )
450 // toggle "check all" checkboxes
451 var unchecked = $(this).closest('tbody').find(':checkbox').filter(':visible:enabled').not(':checked');
452 $(this).closest('table').children('thead, tfoot').find(':checkbox').prop('checked', function() {
453 return ( 0 === unchecked.length );
459 $('thead, tfoot').find('.check-column :checkbox').on( 'click.wp-toggle-checkboxes', function( event ) {
461 $table = $this.closest( 'table' ),
462 controlChecked = $this.prop('checked'),
463 toggle = event.shiftKey || $this.data('wp-toggle');
465 $table.children( 'tbody' ).filter(':visible')
466 .children().children('.check-column').find(':checkbox')
467 .prop('checked', function() {
468 if ( $(this).is(':hidden,:disabled') ) {
473 return ! $(this).prop( 'checked' );
474 } else if ( controlChecked ) {
481 $table.children('thead, tfoot').filter(':visible')
482 .children().children('.check-column').find(':checkbox')
483 .prop('checked', function() {
486 } else if ( controlChecked ) {
494 // Show row actions on keyboard focus of its parent container element or any other elements contained within
495 $( '#wpbody-content' ).on({
496 focusin: function() {
497 clearTimeout( transitionTimeout );
498 focusedRowActions = $( this ).find( '.row-actions' );
499 // transitionTimeout is necessary for Firefox, but Chrome won't remove the CSS class without a little help.
500 $( '.row-actions' ).not( this ).removeClass( 'visible' );
501 focusedRowActions.addClass( 'visible' );
503 focusout: function() {
504 // Tabbing between post title and .row-actions links needs a brief pause, otherwise
505 // the .row-actions div gets hidden in transit in some browsers (ahem, Firefox).
506 transitionTimeout = setTimeout( function() {
507 focusedRowActions.removeClass( 'visible' );
510 }, '.has-row-actions' );
512 // Toggle list table rows on small screens
513 $( 'tbody' ).on( 'click', '.toggle-row', function() {
514 $( this ).closest( 'tr' ).toggleClass( 'is-expanded' );
517 $('#default-password-nag-no').click( function() {
518 setUserSetting('default_password_nag', 'hide');
519 $('div.default-password-nag').hide();
524 $('#newcontent').bind('keydown.wpevent_InsertTab', function(e) {
525 var el = e.target, selStart, selEnd, val, scroll, sel;
527 if ( e.keyCode == 27 ) { // escape key
528 // when pressing Escape: Opera 12 and 27 blur form fields, IE 8 clears them
530 $(el).data('tab-out', true);
534 if ( e.keyCode != 9 || e.ctrlKey || e.altKey || e.shiftKey ) // tab key
537 if ( $(el).data('tab-out') ) {
538 $(el).data('tab-out', false);
542 selStart = el.selectionStart;
543 selEnd = el.selectionEnd;
546 if ( document.selection ) {
548 sel = document.selection.createRange();
550 } else if ( selStart >= 0 ) {
551 scroll = this.scrollTop;
552 el.value = val.substring(0, selStart).concat('\t', val.substring(selEnd) );
553 el.selectionStart = el.selectionEnd = selStart + 1;
554 this.scrollTop = scroll;
557 if ( e.stopPropagation )
559 if ( e.preventDefault )
563 if ( pageInput.length ) {
564 pageInput.closest('form').submit( function() {
566 // Reset paging var for new filters/searches but not for bulk actions. See #17685.
567 if ( $('select[name="action"]').val() == -1 && $('select[name="action2"]').val() == -1 && pageInput.val() == currentPage )
572 $('.search-box input[type="search"], .search-box input[type="submit"]').mousedown(function () {
573 $('select[name^="action"]').val('-1');
576 // Scroll into view when focused
577 $('#contextual-help-link, #show-settings-link').on( 'focus.scroll-into-view', function(e){
578 if ( e.target.scrollIntoView )
579 e.target.scrollIntoView(false);
582 // Disable upload buttons until files are selected
584 var button, input, form = $('form.wp-upload-form');
587 button = form.find('input[type="submit"]');
588 input = form.find('input[type="file"]');
590 function toggleUploadButton() {
591 button.prop('disabled', '' === input.map( function() {
592 return $(this).val();
595 toggleUploadButton();
596 input.on('change', toggleUploadButton);
599 function pinMenu( event ) {
600 var windowPos = $window.scrollTop(),
601 resizing = ! event || event.type !== 'scroll';
603 if ( isIOS || isIE8 || $adminmenu.data( 'wp-responsive' ) ) {
607 if ( height.menu + height.adminbar < height.window ||
608 height.menu + height.adminbar + 20 > height.wpwrap ) {
615 if ( height.menu + height.adminbar > height.window ) {
616 // Check for overscrolling
617 if ( windowPos < 0 ) {
618 if ( ! pinnedMenuTop ) {
619 pinnedMenuTop = true;
620 pinnedMenuBottom = false;
630 } else if ( windowPos + height.window > $document.height() - 1 ) {
631 if ( ! pinnedMenuBottom ) {
632 pinnedMenuBottom = true;
633 pinnedMenuTop = false;
645 if ( windowPos > lastScrollPosition ) {
647 if ( pinnedMenuTop ) {
649 pinnedMenuTop = false;
650 menuTop = $adminMenuWrap.offset().top - height.adminbar - ( windowPos - lastScrollPosition );
652 if ( menuTop + height.menu + height.adminbar < windowPos + height.window ) {
653 menuTop = windowPos + height.window - height.menu - height.adminbar;
657 position: 'absolute',
661 } else if ( ! pinnedMenuBottom && $adminMenuWrap.offset().top + height.menu < windowPos + height.window ) {
663 pinnedMenuBottom = true;
671 } else if ( windowPos < lastScrollPosition ) {
673 if ( pinnedMenuBottom ) {
675 pinnedMenuBottom = false;
676 menuTop = $adminMenuWrap.offset().top - height.adminbar + ( lastScrollPosition - windowPos );
678 if ( menuTop + height.menu > windowPos + height.window ) {
683 position: 'absolute',
687 } else if ( ! pinnedMenuTop && $adminMenuWrap.offset().top >= windowPos + height.adminbar ) {
689 pinnedMenuTop = true;
697 } else if ( resizing ) {
699 pinnedMenuTop = pinnedMenuBottom = false;
700 menuTop = windowPos + height.window - height.menu - height.adminbar - 1;
704 position: 'absolute',
714 lastScrollPosition = windowPos;
717 function resetHeights() {
719 window: $window.height(),
720 wpwrap: $wpwrap.height(),
721 adminbar: $adminbar.height(),
722 menu: $adminMenuWrap.height()
726 function unpinMenu() {
727 if ( isIOS || ! menuIsPinned ) {
731 pinnedMenuTop = pinnedMenuBottom = menuIsPinned = false;
739 function setPinMenu() {
742 if ( $adminmenu.data('wp-responsive') ) {
743 $body.removeClass( 'sticky-menu' );
745 } else if ( height.menu + height.adminbar > height.window ) {
747 $body.removeClass( 'sticky-menu' );
749 $body.addClass( 'sticky-menu' );
755 $window.on( 'scroll.pin-menu', pinMenu );
756 $document.on( 'tinymce-editor-init.pin-menu', function( event, editor ) {
757 editor.on( 'wp-autoresize', resetHeights );
761 window.wpResponsive = {
765 // Modify functionality based on custom activate/deactivate event
766 $document.on( 'wp-responsive-activate.wp-responsive', function() {
768 }).on( 'wp-responsive-deactivate.wp-responsive', function() {
772 $( '#wp-admin-bar-menu-toggle a' ).attr( 'aria-expanded', 'false' );
774 // Toggle sidebar when toggle is clicked
775 $( '#wp-admin-bar-menu-toggle' ).on( 'click.wp-responsive', function( event ) {
776 event.preventDefault();
778 // close any open toolbar submenus
779 $adminbar.find( '.hover' ).removeClass( 'hover' );
781 $wpwrap.toggleClass( 'wp-responsive-open' );
782 if ( $wpwrap.hasClass( 'wp-responsive-open' ) ) {
783 $(this).find('a').attr( 'aria-expanded', 'true' );
784 $( '#adminmenu a:first' ).focus();
786 $(this).find('a').attr( 'aria-expanded', 'false' );
791 $adminmenu.on( 'click.wp-responsive', 'li.wp-has-submenu > a', function( event ) {
792 if ( ! $adminmenu.data('wp-responsive') ) {
796 $( this ).parent( 'li' ).toggleClass( 'selected' );
797 event.preventDefault();
801 $document.on( 'wp-window-resized.wp-responsive', $.proxy( this.trigger, this ) );
803 // This needs to run later as UI Sortable may be initialized later on $(document).ready()
804 $window.on( 'load.wp-responsive', function() {
805 var width = navigator.userAgent.indexOf('AppleWebKit/') > -1 ? $window.width() : window.innerWidth;
807 if ( width <= 782 ) {
808 self.disableSortables();
813 activate: function() {
816 if ( ! $body.hasClass( 'auto-fold' ) ) {
817 $body.addClass( 'auto-fold' );
820 $adminmenu.data( 'wp-responsive', 1 );
821 this.disableSortables();
824 deactivate: function() {
826 $adminmenu.removeData('wp-responsive');
827 this.enableSortables();
830 trigger: function() {
833 if ( window.innerWidth ) {
834 // window.innerWidth is affected by zooming on phones
835 width = Math.max( window.innerWidth, document.documentElement.clientWidth );
837 // Exclude IE < 9, it doesn't support @media CSS rules
841 if ( width <= 782 ) {
842 if ( ! wpResponsiveActive ) {
843 $document.trigger( 'wp-responsive-activate' );
844 wpResponsiveActive = true;
847 if ( wpResponsiveActive ) {
848 $document.trigger( 'wp-responsive-deactivate' );
849 wpResponsiveActive = false;
853 if ( width <= 480 ) {
854 this.enableOverlay();
856 this.disableOverlay();
860 enableOverlay: function() {
861 if ( $overlay.length === 0 ) {
862 $overlay = $( '<div id="wp-responsive-overlay"></div>' )
863 .insertAfter( '#wpcontent' )
865 .on( 'click.wp-responsive', function() {
866 $toolbar.find( '.menupop.hover' ).removeClass( 'hover' );
871 $toolbarPopups.on( 'click.wp-responsive', function() {
876 disableOverlay: function() {
877 $toolbarPopups.off( 'click.wp-responsive' );
881 disableSortables: function() {
882 if ( $sortables.length ) {
884 $sortables.sortable('disable');
889 enableSortables: function() {
890 if ( $sortables.length ) {
892 $sortables.sortable('enable');
898 // Add an ARIA role `button` to elements that behave like UI controls when JavaScript is on.
899 function aria_button_if_js() {
900 $( '.aria-button-if-js' ).attr( 'role', 'button' );
903 $( document ).ajaxComplete( function() {
907 window.wpResponsive.init();
909 currentMenuItemHasPopup();
910 makeNoticesDismissible();
913 $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 );
915 // Set initial focus on a specific element.
916 $( '.wp-initial-focus' ).focus();
919 // Fire a custom jQuery event at the end of window resize
923 function triggerEvent() {
924 $document.trigger( 'wp-window-resized' );
927 function fireOnce() {
928 window.clearTimeout( timeout );
929 timeout = window.setTimeout( triggerEvent, 200 );
932 $window.on( 'resize.wp-fire-once', fireOnce );
935 // Make Windows 8 devices play along nicely.
937 if ( '-ms-user-select' in document.documentElement.style && navigator.userAgent.match(/IEMobile\/10\.0/) ) {
938 var msViewportStyle = document.createElement( 'style' );
939 msViewportStyle.appendChild(
940 document.createTextNode( '@-ms-viewport{width:auto!important}' )
942 document.getElementsByTagName( 'head' )[0].appendChild( msViewportStyle );
946 }( jQuery, window ));