Make WordPress Core

Changeset 26390


Ignore:
Timestamp:
11/26/2013 04:37:27 AM (10 years ago)
Author:
helen
Message:

Dashboard JS cleanup. props kadamwhite, helen. see #25824.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/dashboard.js

    r26372 r26390  
    33
    44jQuery(document).ready( function($) {
    5     /* Dashboard Welcome Panel */
    6     var welcomePanel = $('#welcome-panel'),
     5    var $window = $( window ),
     6        welcomePanel = $( '#welcome-panel' ),
    77        welcomePanelHide = $('#wp_welcome_panel-hide'),
    8         updateWelcomePanel = function( visible ) {
    9             $.post( ajaxurl, {
    10                 action: 'update-welcome-panel',
    11                 visible: visible,
    12                 welcomepanelnonce: $('#welcomepanelnonce').val()
    13             });
    14         };
     8        updateWelcomePanel,
     9        metaboxHolder = $( '.metabox-holder' ),
     10        updateColumnCount;
     11
     12    updateWelcomePanel = function( visible ) {
     13        $.post( ajaxurl, {
     14            action: 'update-welcome-panel',
     15            visible: visible,
     16            welcomepanelnonce: $( '#welcomepanelnonce' ).val()
     17        });
     18    };
    1519
    1620    if ( welcomePanel.hasClass('hidden') && welcomePanelHide.prop('checked') ) {
     
    129133    });
    130134
    131     // Dashboard columns
    132     jQuery(document).ready(function () {
    133         // Update main column count on load
    134         updateColumnCount();
    135     });
    136 
    137     jQuery(window).resize( _.debounce( function(){
    138         updateColumnCount();
    139     }, 30) );
    140 
    141     function updateColumnCount() {
     135    updateColumnCount = function( $window, $holder ) {
    142136        var cols = 1,
    143             windowWidth = parseInt(jQuery(window).width(), 10);
     137            windowWidth = parseInt( $window.width(), 10 );
    144138
    145139        if (799 < windowWidth && 1299 > windowWidth) {
     
    154148            cols = 4;
    155149        }
    156         jQuery('.metabox-holder').attr('class', jQuery('.metabox-holder').attr('class').replace(/columns-\d+/, 'columns-' + cols));
    157     }
     150
     151        $holder.attr( 'class', $holder.attr( 'class' ).replace( /columns-\d+/, 'columns-' + cols ) );
     152    };
     153
     154    // Update main column count on load
     155    updateColumnCount( $window, metaboxHolder );
     156
     157    $window.on( 'resize', _.debounce(function() {
     158        updateColumnCount( $window, metaboxHolder );
     159    }, 30 ) );
    158160
    159161} );
Note: See TracChangeset for help on using the changeset viewer.