]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/js/common.js
WordPress 3.7-scripts
[autoinstalls/wordpress.git] / wp-admin / js / common.js
index 0f6b84d08a4b82cf6658d566943e0125dda6d403..822af979da8ac6db6e21cc98165f560c9afc22da 100644 (file)
@@ -160,7 +160,7 @@ $('.contextual-help-tabs').delegate('a', 'click focus', function(e) {
 });
 
 $(document).ready( function() {
-       var lastClicked = false, checks, first, last, checked, menu = $('#adminmenu'), mobileEvent,
+       var lastClicked = false, checks, first, last, checked, sliced, menu = $('#adminmenu'), mobileEvent,
                pageInput = $('input.current-page'), currentPage = pageInput.val();
 
        // when the menu is folded, make the fly-out submenu header clickable
@@ -169,25 +169,31 @@ $(document).ready( function() {
        });
 
        $('#collapse-menu').on('click.collapse-menu', function(e){
-               var body = $(document.body);
+               var body = $( document.body ), respWidth;
 
                // reset any compensation for submenus near the bottom of the screen
                $('#adminmenu div.wp-submenu').css('margin-top', '');
 
-               if ( $(window).width() < 900 ) {
+               // WebKit excludes the width of the vertical scrollbar when applying the CSS "@media screen and (max-width: ...)"
+               // and matches $(window).width().
+               // Firefox and IE > 8 include the scrollbar width, so after the jQuery normalization
+               // $(window).width() is 884px but window.innerWidth is 900px.
+               // (using window.innerWidth also excludes IE < 9)
+               respWidth = navigator.userAgent.indexOf('AppleWebKit/') > -1 ? $(window).width() : window.innerWidth;
+
+               if ( respWidth && respWidth < 900 ) {
                        if ( body.hasClass('auto-fold') ) {
-                               body.removeClass('auto-fold');
+                               body.removeClass('auto-fold').removeClass('folded');
                                setUserSetting('unfold', 1);
-                               body.removeClass('folded');
-                               deleteUserSetting('mfold');
+                               setUserSetting('mfold', 'o');
                        } else {
                                body.addClass('auto-fold');
-                               deleteUserSetting('unfold');
+                               setUserSetting('unfold', 0);
                        }
                } else {
                        if ( body.hasClass('folded') ) {
                                body.removeClass('folded');
-                               deleteUserSetting('mfold');
+                               setUserSetting('mfold', 'o');
                        } else {
                                body.addClass('folded');
                                setUserSetting('mfold', 'f');
@@ -280,7 +286,8 @@ $(document).ready( function() {
                        last = checks.index( this );
                        checked = $(this).prop('checked');
                        if ( 0 < first && 0 < last && first != last ) {
-                               checks.slice( first, last ).prop( 'checked', function(){
+                               sliced = ( last > first ) ? checks.slice( first, last ) : checks.slice( last, first );
+                               sliced.prop( 'checked', function() {
                                        if ( $(this).closest('tr').is(':visible') )
                                                return checked;
 
@@ -307,7 +314,7 @@ $(document).ready( function() {
                $(this).closest( 'table' ).children( 'tbody' ).filter(':visible')
                .children().children('.check-column').find(':checkbox')
                .prop('checked', function() {
-                       if ( $(this).closest('tr').is(':hidden') )
+                       if ( $(this).is(':hidden') )
                                return false;
                        if ( toggle )
                                return $(this).prop( 'checked' );
@@ -327,6 +334,20 @@ $(document).ready( function() {
                });
        });
 
+       // Show row actions on keyboard focus of its parent container element or any other elements contained within
+       var transitionTimeout, focusedRowActions;
+       $( 'td.post-title, td.title, td.comment, .bookmarks td.column-name, td.blogname, td.username, .dashboard-comment-wrap' ).focusin(function(){
+               clearTimeout( transitionTimeout );
+               focusedRowActions = $(this).find( '.row-actions' );
+               focusedRowActions.addClass( 'visible' );
+       }).focusout(function(){
+               // Tabbing between post title and .row-actions links needs a brief pause, otherwise
+               // the .row-actions div gets hidden in transit in some browsers (ahem, Firefox).
+               transitionTimeout = setTimeout(function(){
+                       focusedRowActions.removeClass( 'visible' );
+               }, 30);
+       });
+
        $('#default-password-nag-no').click( function() {
                setUserSetting('default_password_nag', 'hide');
                $('div.default-password-nag').hide();
@@ -389,6 +410,10 @@ $(document).ready( function() {
                });
        }
 
+       $('.search-box input[type="search"], .search-box input[type="submit"]').mousedown(function () {
+               $('select[name^="action"]').val('-1');
+       });
+
        // Scroll into view when focused
        $('#contextual-help-link, #show-settings-link').on( 'focus.scroll-into-view', function(e){
                if ( e.target.scrollIntoView )