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

Built from https://develop.svn.wordpress.org/trunk@26390


git-svn-id: http://core.svn.wordpress.org/trunk@26290 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Helen Hou-Sandí 2013-11-26 04:38:09 +00:00
parent 1163eaeb7c
commit e911c4272a
2 changed files with 26 additions and 24 deletions

View File

@ -2,16 +2,20 @@
var ajaxWidgets, ajaxPopulateWidgets, quickPressLoad;
jQuery(document).ready( function($) {
/* Dashboard Welcome Panel */
var welcomePanel = $('#welcome-panel'),
var $window = $( window ),
welcomePanel = $( '#welcome-panel' ),
welcomePanelHide = $('#wp_welcome_panel-hide'),
updateWelcomePanel = function( visible ) {
$.post( ajaxurl, {
action: 'update-welcome-panel',
visible: visible,
welcomepanelnonce: $('#welcomepanelnonce').val()
});
};
updateWelcomePanel,
metaboxHolder = $( '.metabox-holder' ),
updateColumnCount;
updateWelcomePanel = function( visible ) {
$.post( ajaxurl, {
action: 'update-welcome-panel',
visible: visible,
welcomepanelnonce: $( '#welcomepanelnonce' ).val()
});
};
if ( welcomePanel.hasClass('hidden') && welcomePanelHide.prop('checked') ) {
welcomePanel.removeClass('hidden');
@ -128,19 +132,9 @@ jQuery(document).ready( function($) {
e.preventDefault();
});
// Dashboard columns
jQuery(document).ready(function () {
// Update main column count on load
updateColumnCount();
});
jQuery(window).resize( _.debounce( function(){
updateColumnCount();
}, 30) );
function updateColumnCount() {
updateColumnCount = function( $window, $holder ) {
var cols = 1,
windowWidth = parseInt(jQuery(window).width(), 10);
windowWidth = parseInt( $window.width(), 10 );
if (799 < windowWidth && 1299 > windowWidth) {
cols = 2;
@ -153,7 +147,15 @@ jQuery(document).ready( function($) {
if (1800 < windowWidth) {
cols = 4;
}
jQuery('.metabox-holder').attr('class', jQuery('.metabox-holder').attr('class').replace(/columns-\d+/, 'columns-' + cols));
}
$holder.attr( 'class', $holder.attr( 'class' ).replace( /columns-\d+/, 'columns-' + cols ) );
};
// Update main column count on load
updateColumnCount( $window, metaboxHolder );
$window.on( 'resize', _.debounce(function() {
updateColumnCount( $window, metaboxHolder );
}, 30 ) );
} );

View File

@ -1 +1 @@
var ajaxWidgets,ajaxPopulateWidgets,quickPressLoad;jQuery(document).ready(function(a){function b(){var a=1,b=parseInt(jQuery(window).width(),10);b>799&&1299>b&&(a=2),b>1300&&1799>b&&(a=3),b>1800&&(a=4),jQuery(".metabox-holder").attr("class",jQuery(".metabox-holder").attr("class").replace(/columns-\d+/,"columns-"+a))}var c=a("#welcome-panel"),d=a("#wp_welcome_panel-hide"),e=function(b){a.post(ajaxurl,{action:"update-welcome-panel",visible:b,welcomepanelnonce:a("#welcomepanelnonce").val()})};c.hasClass("hidden")&&d.prop("checked")&&c.removeClass("hidden"),a(".welcome-panel-close, .welcome-panel-dismiss a",c).click(function(b){b.preventDefault(),c.addClass("hidden"),e(0),a("#wp_welcome_panel-hide").prop("checked",!1)}),d.click(function(){c.toggleClass("hidden",!this.checked),e(this.checked?1:0)}),ajaxWidgets=["dashboard_primary"],ajaxPopulateWidgets=function(b){function c(b,c){var d,e=a("#"+c+" div.inside:visible").find(".widget-loading");e.length&&(d=e.parent(),setTimeout(function(){d.load(ajaxurl+"?action=dashboard-widgets&widget="+c+"&pagenow="+pagenow,"",function(){d.hide().slideDown("normal",function(){a(this).css("display","")})})},500*b))}b?(b=b.toString(),-1!==a.inArray(b,ajaxWidgets)&&c(0,b)):a.each(ajaxWidgets,c)},ajaxPopulateWidgets(),postboxes.add_postbox_toggles(pagenow,{pbshow:ajaxPopulateWidgets}),quickPressLoad=function(){var b,c=a("#quickpost-action");b=a("#quick-press").submit(function(){function c(){var b=a(".drafts ul li").first();b.css("background","#fffbe5"),setTimeout(function(){b.css("background","none")},1e3)}return a("#dashboard_quick_press #publishing-action .spinner").show(),a('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop("disabled",!0),a.post(b.attr("action"),b.serializeArray(),function(b){a("#dashboard_quick_press .inside").html(b),a("#quick-press").removeClass("initial-form"),quickPressLoad(),c(),a("#title").focus()}),!1}),a("#publish").click(function(){c.val("post-quickpress-publish")}),a("#title, #tags-input, #content").each(function(){var b=a(this),c=a("#"+this.id+"-prompt-text");""===this.value&&c.removeClass("screen-reader-text"),c.click(function(){a(this).addClass("screen-reader-text"),b.focus()}),b.blur(function(){""===this.value&&c.removeClass("screen-reader-text")}),b.focus(function(){c.addClass("screen-reader-text")})}),a("#quick-press").on("click focusin",function(){a(this).addClass("quickpress-open"),a("#description-wrap, p.submit").slideDown(200),wpActiveEditor="content"})},quickPressLoad(),a(".meta-box-sortables").sortable("option","containment","#dashboard-widgets-wrap"),a(".show-more a").on("click",function(b){a(this).fadeOut().closest(".activity-block").find("li.hidden").fadeIn().removeClass("hidden"),b.preventDefault()}),jQuery(document).ready(function(){b()}),jQuery(window).resize(_.debounce(function(){b()},30))});
var ajaxWidgets,ajaxPopulateWidgets,quickPressLoad;jQuery(document).ready(function(a){var b,c,d=a(window),e=a("#welcome-panel"),f=a("#wp_welcome_panel-hide"),g=a(".metabox-holder");b=function(b){a.post(ajaxurl,{action:"update-welcome-panel",visible:b,welcomepanelnonce:a("#welcomepanelnonce").val()})},e.hasClass("hidden")&&f.prop("checked")&&e.removeClass("hidden"),a(".welcome-panel-close, .welcome-panel-dismiss a",e).click(function(c){c.preventDefault(),e.addClass("hidden"),b(0),a("#wp_welcome_panel-hide").prop("checked",!1)}),f.click(function(){e.toggleClass("hidden",!this.checked),b(this.checked?1:0)}),ajaxWidgets=["dashboard_primary"],ajaxPopulateWidgets=function(b){function c(b,c){var d,e=a("#"+c+" div.inside:visible").find(".widget-loading");e.length&&(d=e.parent(),setTimeout(function(){d.load(ajaxurl+"?action=dashboard-widgets&widget="+c+"&pagenow="+pagenow,"",function(){d.hide().slideDown("normal",function(){a(this).css("display","")})})},500*b))}b?(b=b.toString(),-1!==a.inArray(b,ajaxWidgets)&&c(0,b)):a.each(ajaxWidgets,c)},ajaxPopulateWidgets(),postboxes.add_postbox_toggles(pagenow,{pbshow:ajaxPopulateWidgets}),quickPressLoad=function(){var b,c=a("#quickpost-action");b=a("#quick-press").submit(function(){function c(){var b=a(".drafts ul li").first();b.css("background","#fffbe5"),setTimeout(function(){b.css("background","none")},1e3)}return a("#dashboard_quick_press #publishing-action .spinner").show(),a('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop("disabled",!0),a.post(b.attr("action"),b.serializeArray(),function(b){a("#dashboard_quick_press .inside").html(b),a("#quick-press").removeClass("initial-form"),quickPressLoad(),c(),a("#title").focus()}),!1}),a("#publish").click(function(){c.val("post-quickpress-publish")}),a("#title, #tags-input, #content").each(function(){var b=a(this),c=a("#"+this.id+"-prompt-text");""===this.value&&c.removeClass("screen-reader-text"),c.click(function(){a(this).addClass("screen-reader-text"),b.focus()}),b.blur(function(){""===this.value&&c.removeClass("screen-reader-text")}),b.focus(function(){c.addClass("screen-reader-text")})}),a("#quick-press").on("click focusin",function(){a(this).addClass("quickpress-open"),a("#description-wrap, p.submit").slideDown(200),wpActiveEditor="content"})},quickPressLoad(),a(".meta-box-sortables").sortable("option","containment","#dashboard-widgets-wrap"),a(".show-more a").on("click",function(b){a(this).fadeOut().closest(".activity-block").find("li.hidden").fadeIn().removeClass("hidden"),b.preventDefault()}),c=function(a,b){var c=1,d=parseInt(a.width(),10);d>799&&1299>d&&(c=2),d>1300&&1799>d&&(c=3),d>1800&&(c=4),b.attr("class",b.attr("class").replace(/columns-\d+/,"columns-"+c))},c(d,g),d.on("resize",_.debounce(function(){c(d,g)},30))});