From 740a42b75aab705cbfa267b65ef7907cd83761df Mon Sep 17 00:00:00 2001 From: azaozz Date: Sat, 20 Jun 2009 10:30:09 +0000 Subject: [PATCH] Always load the Dashboard RSS widgets with AJAX, see #10133 for trunk git-svn-id: http://svn.automattic.com/wordpress/trunk@11613 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/dashboard.php | 12 ++++-------- wp-admin/js/dashboard.dev.js | 34 ++++++++++++++++++++++++++------- wp-admin/js/dashboard.js | 2 +- wp-admin/js/postbox.dev.js | 14 +++++++------- wp-admin/js/postbox.js | 2 +- wp-includes/script-loader.php | 4 ++-- 6 files changed, 42 insertions(+), 26 deletions(-) diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index 27a2cee8b2..56c5581ef8 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -605,7 +605,7 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) { } function wp_dashboard_incoming_links() { - wp_dashboard_cached_rss_widget( 'dashboard_incoming_links', 'wp_dashboard_incoming_links_output' ); + echo '

' . __( 'Loading…' ) . '

' . __('This widget requires JavaScript.') . '

'; } /** @@ -690,7 +690,7 @@ function wp_dashboard_incoming_links_control() { } function wp_dashboard_primary() { - wp_dashboard_cached_rss_widget( 'dashboard_primary', 'wp_dashboard_rss_output' ); + echo '

' . __( 'Loading…' ) . '

' . __('This widget requires JavaScript.') . '

'; } function wp_dashboard_primary_control() { @@ -712,7 +712,7 @@ function wp_dashboard_rss_output( $widget_id ) { } function wp_dashboard_secondary() { - wp_dashboard_cached_rss_widget( 'dashboard_secondary', 'wp_dashboard_secondary_output' ); + echo '

' . __( 'Loading…' ) . '

' . __('This widget requires JavaScript.') . '

'; } function wp_dashboard_secondary_control() { @@ -747,11 +747,7 @@ function wp_dashboard_secondary_output() { } function wp_dashboard_plugins() { - wp_dashboard_cached_rss_widget( 'dashboard_plugins', 'wp_dashboard_plugins_output', array( - 'http://wordpress.org/extend/plugins/rss/browse/popular/', - 'http://wordpress.org/extend/plugins/rss/browse/new/', - 'http://wordpress.org/extend/plugins/rss/browse/updated/' - ) ); + echo '

' . __( 'Loading…' ) . '

' . __('This widget requires JavaScript.') . '

'; } /** diff --git a/wp-admin/js/dashboard.dev.js b/wp-admin/js/dashboard.dev.js index 75d4521de4..aa33391c8b 100644 --- a/wp-admin/js/dashboard.dev.js +++ b/wp-admin/js/dashboard.dev.js @@ -1,6 +1,6 @@ +var ajaxWidgets, ajaxPopulateWidgets, quickPressLoad; jQuery(document).ready( function($) { - var ajaxWidgets, ajaxPopulateWidgets, quickPressLoad; // These widgets are sometimes populated via ajax ajaxWidgets = [ 'dashboard_incoming_links', @@ -9,15 +9,35 @@ jQuery(document).ready( function($) { 'dashboard_plugins' ]; - ajaxPopulateWidgets = function() { - $.each( ajaxWidgets, function() { - var e = jQuery('#' + this + ':visible div.inside').find('.widget-loading'); - if ( e.size() ) { e.parent().load('index-extra.php?jax=' + this); } - } ); + ajaxPopulateWidgets = function(el) { + show = function(id, i) { + var p, e = $('#' + id + ' div.inside:visible').find('.widget-loading'); + if ( e.length ) { + p = e.parent(); + setTimeout( function(){ + p.load('index-extra.php?jax=' + id, '', function() { + p.hide().slideDown('normal', function(){ + $(this).css('display', ''); + if ( 'dashboard_plugins' == id && $.isFunction(tb_init) ) + tb_init('#dashboard_plugins a.thickbox'); + }); + }); + }, i * 500 ); + } + } + if ( el ) { + el = el.toString(); + if ( $.inArray(el, ajaxWidgets) != -1 ) + show(el, 0); + } else { + $.each( ajaxWidgets, function(i) { + show(this, i); + }); + } }; ajaxPopulateWidgets(); - postboxes.add_postbox_toggles('dashboard', { onShow: ajaxPopulateWidgets } ); + postboxes.add_postbox_toggles('dashboard', { pbshow: ajaxPopulateWidgets } ); /* QuickPress */ quickPressLoad = function() { diff --git a/wp-admin/js/dashboard.js b/wp-admin/js/dashboard.js index 8c20f1ecf2..c9886183e4 100644 --- a/wp-admin/js/dashboard.js +++ b/wp-admin/js/dashboard.js @@ -1 +1 @@ -jQuery(document).ready(function(c){var a,b,d;a=["dashboard_incoming_links","dashboard_primary","dashboard_secondary","dashboard_plugins"];b=function(){c.each(a,function(){var f=jQuery("#"+this+":visible div.inside").find(".widget-loading");if(f.size()){f.parent().load("index-extra.php?jax="+this)}})};b();postboxes.add_postbox_toggles("dashboard",{onShow:b});d=function(){var e=c("#quickpost-action"),f;f=c("#quick-press").submit(function(){c("#dashboard_quick_press h3").append('');c('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr("disabled","disabled");if("post"==e.val()){e.val("post-quickpress-publish")}c("#dashboard_quick_press div.inside").load(f.attr("action"),f.serializeArray(),function(){c("#dashboard_quick_press h3 img").remove();c('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr("disabled","");c("#dashboard_quick_press ul").find("li").each(function(){c("#dashboard_recent_drafts ul").prepend(this)}).end().remove();tb_init("a.thickbox");d()});return false});c("#publish").click(function(){e.val("post-quickpress-publish")})};d()}); \ No newline at end of file +var ajaxWidgets,ajaxPopulateWidgets,quickPressLoad;jQuery(document).ready(function(a){ajaxWidgets=["dashboard_incoming_links","dashboard_primary","dashboard_secondary","dashboard_plugins"];ajaxPopulateWidgets=function(b){show=function(g,c){var f,d=a("#"+g+" div.inside:visible").find(".widget-loading");if(d.length){f=d.parent();setTimeout(function(){f.load("index-extra.php?jax="+g,"",function(){f.hide().slideDown("normal",function(){a(this).css("display","");if("dashboard_plugins"==g&&a.isFunction(tb_init)){tb_init("#dashboard_plugins a.thickbox")}})})},c*500)}};if(b){b=b.toString();if(a.inArray(b,ajaxWidgets)!=-1){show(b,0)}}else{a.each(ajaxWidgets,function(c){show(this,c)})}};ajaxPopulateWidgets();postboxes.add_postbox_toggles("dashboard",{pbshow:ajaxPopulateWidgets});quickPressLoad=function(){var b=a("#quickpost-action"),c;c=a("#quick-press").submit(function(){a("#dashboard_quick_press h3").append('');a('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr("disabled","disabled");if("post"==b.val()){b.val("post-quickpress-publish")}a("#dashboard_quick_press div.inside").load(c.attr("action"),c.serializeArray(),function(){a("#dashboard_quick_press h3 img").remove();a('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr("disabled","");a("#dashboard_quick_press ul").find("li").each(function(){a("#dashboard_recent_drafts ul").prepend(this)}).end().remove();tb_init("a.thickbox");quickPressLoad()});return false});a("#publish").click(function(){b.val("post-quickpress-publish")})};quickPressLoad()}); \ No newline at end of file diff --git a/wp-admin/js/postbox.dev.js b/wp-admin/js/postbox.dev.js index 32e7898b0c..d9ca79987e 100644 --- a/wp-admin/js/postbox.dev.js +++ b/wp-admin/js/postbox.dev.js @@ -4,15 +4,15 @@ var postboxes; add_postbox_toggles : function(page,args) { this.init(page,args); $('.postbox h3, .postbox .handlediv').click( function() { - var p = $(this).parent('.postbox'); - /* - if ( p.hasClass('noclick') ) { - p.removeClass('noclick'); - return false; - } - */ + var p = $(this).parent('.postbox'), id = p.attr('id'); p.toggleClass('closed'); postboxes.save_state(page); + if ( id ) { + if ( !p.hasClass('closed') && $.isFunction(postboxes.pbshow) ) + postboxes.pbshow(id); + else if ( p.hasClass('closed') && $.isFunction(postboxes.pbhide) ) + postboxes.pbhide(id); + } } ); $('.postbox h3 a').click( function(e) { e.stopPropagation(); diff --git a/wp-admin/js/postbox.js b/wp-admin/js/postbox.js index 3d5d21b319..3b6415b170 100644 --- a/wp-admin/js/postbox.js +++ b/wp-admin/js/postbox.js @@ -1 +1 @@ -var postboxes;(function(a){postboxes={add_postbox_toggles:function(c,b){this.init(c,b);a(".postbox h3, .postbox .handlediv").click(function(){var e=a(this).parent(".postbox");e.toggleClass("closed");postboxes.save_state(c)});a(".postbox h3 a").click(function(f){f.stopPropagation()});a(".hide-postbox-tog").click(function(){var e=a(this).val();if(a(this).attr("checked")){a("#"+e).show();if(a.isFunction(postboxes.pbshow)){postboxes.pbshow(e)}}else{a("#"+e).hide();if(a.isFunction(postboxes.pbhide)){postboxes.pbhide(e)}}postboxes.save_state(c)});a('.columns-prefs input[type="radio"]').click(function(){var e=a(this).val(),f,g,h=a("#poststuff");if(h.length){if(e==2){h.addClass("has-right-sidebar");a("#side-sortables").addClass("temp-border")}else{if(e==1){h.removeClass("has-right-sidebar");a("#normal-sortables").append(a("#side-sortables").children(".postbox"))}}}else{for(f=4;(f>e&&f>1);f--){g=a("#"+d(f)+"-sortables");a("#"+d(f-1)+"-sortables").append(g.children(".postbox"));g.parent().hide()}for(f=1;f<=e;f++){g=a("#"+d(f)+"-sortables");if(g.parent().is(":hidden")){g.addClass("temp-border").parent().show()}}a(".postbox-container:visible").css("width",98/e+"%")}postboxes.save_order(c)});function d(e){switch(e){case 1:return"normal";break;case 2:return"side";break;case 3:return"column3";break;case 4:return"column4";break;default:return""}}},init:function(c,b){a.extend(this,b||{});a("#wpbody-content").css("overflow","hidden");a(".meta-box-sortables").sortable({placeholder:"sortable-placeholder",connectWith:".meta-box-sortables",items:".postbox",handle:".hndle",cursor:"move",distance:2,tolerance:"pointer",forcePlaceholderSize:true,helper:"clone",opacity:0.65,start:function(f,d){a("body").css({WebkitUserSelect:"none",KhtmlUserSelect:"none"})},stop:function(f,d){postboxes.save_order(c);d.item.parent().removeClass("temp-border");a("body").css({WebkitUserSelect:"",KhtmlUserSelect:""})}})},save_state:function(d){var b=a(".postbox").filter(".closed").map(function(){return this.id}).get().join(","),c=a(".postbox").filter(":hidden").map(function(){return this.id}).get().join(",");a.post(postboxL10n.requestFile,{action:"closed-postboxes",closed:b,hidden:c,closedpostboxesnonce:jQuery("#closedpostboxesnonce").val(),page:d})},save_order:function(c){var b,d=a(".columns-prefs input:checked").val()||0;b={action:"meta-box-order",_ajax_nonce:a("#meta-box-order-nonce").val(),page_columns:d,page:c};a(".meta-box-sortables").each(function(){b["order["+this.id.split("-")[0]+"]"]=a(this).sortable("toArray").join(",")});a.post(postboxL10n.requestFile,b)},pbshow:false,pbhide:false}}(jQuery)); \ No newline at end of file +var postboxes;(function(a){postboxes={add_postbox_toggles:function(c,b){this.init(c,b);a(".postbox h3, .postbox .handlediv").click(function(){var e=a(this).parent(".postbox"),f=e.attr("id");e.toggleClass("closed");postboxes.save_state(c);if(f){if(!e.hasClass("closed")&&a.isFunction(postboxes.pbshow)){postboxes.pbshow(f)}else{if(e.hasClass("closed")&&a.isFunction(postboxes.pbhide)){postboxes.pbhide(f)}}}});a(".postbox h3 a").click(function(f){f.stopPropagation()});a(".hide-postbox-tog").click(function(){var e=a(this).val();if(a(this).attr("checked")){a("#"+e).show();if(a.isFunction(postboxes.pbshow)){postboxes.pbshow(e)}}else{a("#"+e).hide();if(a.isFunction(postboxes.pbhide)){postboxes.pbhide(e)}}postboxes.save_state(c)});a('.columns-prefs input[type="radio"]').click(function(){var e=a(this).val(),f,g,h=a("#poststuff");if(h.length){if(e==2){h.addClass("has-right-sidebar");a("#side-sortables").addClass("temp-border")}else{if(e==1){h.removeClass("has-right-sidebar");a("#normal-sortables").append(a("#side-sortables").children(".postbox"))}}}else{for(f=4;(f>e&&f>1);f--){g=a("#"+d(f)+"-sortables");a("#"+d(f-1)+"-sortables").append(g.children(".postbox"));g.parent().hide()}for(f=1;f<=e;f++){g=a("#"+d(f)+"-sortables");if(g.parent().is(":hidden")){g.addClass("temp-border").parent().show()}}a(".postbox-container:visible").css("width",98/e+"%")}postboxes.save_order(c)});function d(e){switch(e){case 1:return"normal";break;case 2:return"side";break;case 3:return"column3";break;case 4:return"column4";break;default:return""}}},init:function(c,b){a.extend(this,b||{});a("#wpbody-content").css("overflow","hidden");a(".meta-box-sortables").sortable({placeholder:"sortable-placeholder",connectWith:".meta-box-sortables",items:".postbox",handle:".hndle",cursor:"move",distance:2,tolerance:"pointer",forcePlaceholderSize:true,helper:"clone",opacity:0.65,start:function(f,d){a("body").css({WebkitUserSelect:"none",KhtmlUserSelect:"none"})},stop:function(f,d){postboxes.save_order(c);d.item.parent().removeClass("temp-border");a("body").css({WebkitUserSelect:"",KhtmlUserSelect:""})}})},save_state:function(d){var b=a(".postbox").filter(".closed").map(function(){return this.id}).get().join(","),c=a(".postbox").filter(":hidden").map(function(){return this.id}).get().join(",");a.post(postboxL10n.requestFile,{action:"closed-postboxes",closed:b,hidden:c,closedpostboxesnonce:jQuery("#closedpostboxesnonce").val(),page:d})},save_order:function(c){var b,d=a(".columns-prefs input:checked").val()||0;b={action:"meta-box-order",_ajax_nonce:a("#meta-box-order-nonce").val(),page_columns:d,page:c};a(".meta-box-sortables").each(function(){b["order["+this.id.split("-")[0]+"]"]=a(this).sortable("toArray").join(",")});a.post(postboxL10n.requestFile,b)},pbshow:false,pbhide:false}}(jQuery)); \ No newline at end of file diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index d0ea4e1506..5dd7a46db2 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -249,7 +249,7 @@ function wp_default_scripts( &$scripts ) { $scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", false, '3517m' ); - $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), '20090327' ); + $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), '20090618' ); $scripts->add_data( 'postbox', 'group', 1 ); $scripts->localize( 'postbox', 'postboxL10n', array( 'requestFile' => admin_url('admin-ajax.php') @@ -377,7 +377,7 @@ function wp_default_scripts( &$scripts ) { $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' ); - $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox' ), '20090201' ); + $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox' ), '20090618' ); $scripts->add_data( 'dashboard', 'group', 1 ); $scripts->add( 'hoverIntent', "/wp-includes/js/hoverIntent$suffix.js", array('jquery'), '20090102' );