Make WordPress Core

Ticket #25824: 25824.js.diff

File 25824.js.diff, 2.1 KB (added by helen, 10 years ago)
  • src/wp-admin/js/dashboard.js

     
    22var ajaxWidgets, ajaxPopulateWidgets, quickPressLoad;
    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;
    1511
     12        updateWelcomePanel = function( visible ) {
     13                $.post( ajaxurl, {
     14                        action: 'update-welcome-panel',
     15                        visible: visible,
     16                        welcomepanelnonce: $('#welcomepanelnonce').val()
     17                });
     18        };
     19
    1620        if ( welcomePanel.hasClass('hidden') && welcomePanelHide.prop('checked') ) {
    1721                welcomePanel.removeClass('hidden');
    1822        }
     
    128132                e.preventDefault();
    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) {
    146140                        cols = 2;
     
    153147                if (1800 < windowWidth) {
    154148                        cols = 4;
    155149                }
    156                 jQuery('.metabox-holder').attr('class', jQuery('.metabox-holder').attr('class').replace(/columns-\d+/, 'columns-' + cols));
    157         }
     150                holder.attr('class', holder.attr('class').replace(/columns-\d+/, 'columns-' + cols));
     151        };
    158152
     153        // Update main column count on load
     154        updateColumnCount($window, metaboxHolder);
     155
     156        $window.resize( _.debounce( function(){
     157                updateColumnCount($window, metaboxHolder);
     158        }, 30) );
     159
    159160} );