Ticket #25824: 25824.js.2.diff
File 25824.js.2.diff, 2.1 KB (added by , 10 years ago) |
---|
-
src/wp-admin/js/dashboard.js
2 2 var ajaxWidgets, ajaxPopulateWidgets, quickPressLoad; 3 3 4 4 jQuery(document).ready( function($) { 5 /* Dashboard Welcome Panel */6 var welcomePanel = $('#welcome-panel'),5 var $window = $( window ), 6 welcomePanel = $( '#welcome-panel' ), 7 7 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; 15 11 12 updateWelcomePanel = function( visible ) { 13 $.post( ajaxurl, { 14 action: 'update-welcome-panel', 15 visible: visible, 16 welcomepanelnonce: $( '#welcomepanelnonce' ).val() 17 }); 18 }; 19 16 20 if ( welcomePanel.hasClass('hidden') && welcomePanelHide.prop('checked') ) { 17 21 welcomePanel.removeClass('hidden'); 18 22 } … … 128 132 e.preventDefault(); 129 133 }); 130 134 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) { 142 136 var cols = 1, 143 windowWidth = parseInt( jQuery(window).width(), 10);137 windowWidth = parseInt( $window.width(), 10 ); 144 138 145 139 if (799 < windowWidth && 1299 > windowWidth) { 146 140 cols = 2; … … 153 147 if (1800 < windowWidth) { 154 148 cols = 4; 155 149 } 156 jQuery('.metabox-holder').attr('class', jQuery('.metabox-holder').attr('class').replace(/columns-\d+/, 'columns-' + cols));157 }158 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 ) ); 160 159 161 } );