WordPress.org

Make WordPress Core

Changeset 11614


Ignore:
Timestamp:
06/20/09 10:32:09 (5 years ago)
Author:
azaozz
Message:

Always load the Dashboard RSS widgets with AJAX, see #10133 for 2.8

Location:
branches/2.8
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/2.8/wp-admin/includes/dashboard.php

    r11605 r11614  
    606606 
    607607function wp_dashboard_incoming_links() { 
    608     wp_dashboard_cached_rss_widget( 'dashboard_incoming_links', 'wp_dashboard_incoming_links_output' ); 
     608    echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>'; 
    609609} 
    610610 
     
    691691 
    692692function wp_dashboard_primary() { 
    693     wp_dashboard_cached_rss_widget( 'dashboard_primary', 'wp_dashboard_rss_output' ); 
     693    echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>'; 
    694694} 
    695695 
     
    713713 
    714714function wp_dashboard_secondary() { 
    715     wp_dashboard_cached_rss_widget( 'dashboard_secondary', 'wp_dashboard_secondary_output' ); 
     715    echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>'; 
    716716} 
    717717 
     
    748748 
    749749function wp_dashboard_plugins() { 
    750     wp_dashboard_cached_rss_widget( 'dashboard_plugins', 'wp_dashboard_plugins_output', array( 
    751         'http://wordpress.org/extend/plugins/rss/browse/popular/', 
    752         'http://wordpress.org/extend/plugins/rss/browse/new/', 
    753         'http://wordpress.org/extend/plugins/rss/browse/updated/' 
    754     ) ); 
     750    echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>'; 
    755751} 
    756752 
  • branches/2.8/wp-admin/js/dashboard.dev.js

    r11203 r11614  
     1var ajaxWidgets, ajaxPopulateWidgets, quickPressLoad; 
    12 
    23jQuery(document).ready( function($) { 
    3     var ajaxWidgets, ajaxPopulateWidgets, quickPressLoad; 
    44    // These widgets are sometimes populated via ajax 
    55    ajaxWidgets = [ 
     
    1010    ]; 
    1111 
    12     ajaxPopulateWidgets = function() { 
    13         $.each( ajaxWidgets, function() { 
    14             var e = jQuery('#' + this + ':visible div.inside').find('.widget-loading'); 
    15             if ( e.size() ) { e.parent().load('index-extra.php?jax=' + this); } 
    16         } ); 
     12    ajaxPopulateWidgets = function(el) { 
     13        show = function(id, i) { 
     14            var p, e = $('#' + id + ' div.inside:visible').find('.widget-loading'); 
     15            if ( e.length ) { 
     16                p = e.parent(); 
     17                setTimeout( function(){ 
     18                    p.load('index-extra.php?jax=' + id, '', function() { 
     19                        p.hide().slideDown('normal', function(){ 
     20                            $(this).css('display', ''); 
     21                            if ( 'dashboard_plugins' == id && $.isFunction(tb_init) ) 
     22                                tb_init('#dashboard_plugins a.thickbox'); 
     23                        }); 
     24                    }); 
     25                }, i * 500 ); 
     26            } 
     27        } 
     28        if ( el ) { 
     29            el = el.toString(); 
     30            if ( $.inArray(el, ajaxWidgets) != -1 ) 
     31                show(el, 0); 
     32        } else { 
     33            $.each( ajaxWidgets, function(i) { 
     34                show(this, i); 
     35            }); 
     36        } 
    1737    }; 
    1838    ajaxPopulateWidgets(); 
    1939 
    20     postboxes.add_postbox_toggles('dashboard', { onShow: ajaxPopulateWidgets } ); 
     40    postboxes.add_postbox_toggles('dashboard', { pbshow: ajaxPopulateWidgets } ); 
    2141 
    2242    /* QuickPress */ 
  • branches/2.8/wp-admin/js/dashboard.js

    r11203 r11614  
    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('<img src="images/wpspin_light.gif" style="margin: 0 6px 0 0; vertical-align: middle" />');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()}); 
     1var 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('<img src="images/wpspin_light.gif" style="margin: 0 6px 0 0; vertical-align: middle" />');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()}); 
  • branches/2.8/wp-admin/js/postbox.dev.js

    r10849 r11614  
    55            this.init(page,args); 
    66            $('.postbox h3, .postbox .handlediv').click( function() { 
    7                 var p = $(this).parent('.postbox'); 
    8                 /* 
    9                 if ( p.hasClass('noclick') ) { 
    10                     p.removeClass('noclick'); 
    11                     return false; 
    12                 } 
    13                 */ 
     7                var p = $(this).parent('.postbox'), id = p.attr('id'); 
    148                p.toggleClass('closed'); 
    159                postboxes.save_state(page); 
     10                if ( id ) { 
     11                    if ( !p.hasClass('closed') && $.isFunction(postboxes.pbshow) ) 
     12                        postboxes.pbshow(id); 
     13                    else if ( p.hasClass('closed') && $.isFunction(postboxes.pbhide) ) 
     14                        postboxes.pbhide(id); 
     15                } 
    1616            } ); 
    1717            $('.postbox h3 a').click( function(e) { 
  • branches/2.8/wp-admin/js/postbox.js

    r10849 r11614  
    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)); 
     1var 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)); 
  • branches/2.8/wp-includes/script-loader.php

    r11547 r11614  
    250250        $scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", false, '3517m' ); 
    251251 
    252         $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), '20090327' ); 
     252        $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), '20090618' ); 
    253253        $scripts->add_data( 'postbox', 'group', 1 ); 
    254254        $scripts->localize( 'postbox', 'postboxL10n', array( 
     
    378378        $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' ); 
    379379 
    380         $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox' ), '20090201' ); 
     380        $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox' ), '20090618' ); 
    381381        $scripts->add_data( 'dashboard', 'group', 1 ); 
    382382 
Note: See TracChangeset for help on using the changeset viewer.