From 8416d1c0e0ea8527758dece96ff67c3404d1b889 Mon Sep 17 00:00:00 2001 From: azaozz Date: Mon, 13 Jun 2011 00:24:47 +0000 Subject: [PATCH] Make sure the browser nag in shown first on the dashboard no matter what! See #17323 git-svn-id: http://svn.automattic.com/wordpress/trunk@18295 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/template.php | 10 +++++++++- wp-admin/js/postbox.dev.js | 24 +++++++++--------------- wp-admin/js/postbox.js | 2 +- wp-includes/script-loader.php | 2 +- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 1f6d7b1450..50ed22b0a9 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -943,9 +943,17 @@ function do_meta_boxes($page, $context, $object) { // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page" ) ) { foreach ( $sorted as $box_context => $ids ) - foreach ( explode(',', $ids) as $id ) + $_ids = explode(',', $ids); + + if ( $k = array_search('dashboard_browser_nag', $_ids, true) ) { // it's ok if this is the first value, i.e. $k == 0 + unset($_ids[$k]); + array_unshift($_ids, 'dashboard_browser_nag'); + } + + foreach ( $_ids as $id ) { if ( $id ) add_meta_box( $id, null, null, $page, $box_context, 'sorted' ); + } } $already_sorted = true; diff --git a/wp-admin/js/postbox.dev.js b/wp-admin/js/postbox.dev.js index cbab287a8f..b367d916ac 100644 --- a/wp-admin/js/postbox.dev.js +++ b/wp-admin/js/postbox.dev.js @@ -100,24 +100,18 @@ var postboxes; forcePlaceholderSize: true, helper: 'clone', opacity: 0.65, - start: function(e,ui) { - $('body').css({ - WebkitUserSelect: 'none', - KhtmlUserSelect: 'none' - }); - /* - if ( $.browser.msie ) - return; - ui.item.addClass('noclick'); - */ - }, stop: function(e,ui) { + if ( $(this).find('#dashboard_browser_nag').is(':visible') && 'dashboard_browser_nag' != this.firstChild.id ) { + $(this).sortable('cancel'); + return; + } + postboxes.save_order(page); ui.item.parent().removeClass('temp-border'); - $('body').css({ - WebkitUserSelect: '', - KhtmlUserSelect: '' - }); + }, + receive: function(e,ui) { + if ( 'dashboard_browser_nag' == ui.item[0].id ) + $(ui.sender).sortable('cancel'); } }); }, diff --git a/wp-admin/js/postbox.js b/wp-admin/js/postbox.js index 7c781915aa..99a1f00388 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"),f=e.attr("id");if("dashboard_browser_nag"==f){return}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(".postbox a.dismiss").click(function(g){var f=a(this).parents(".postbox").attr("id")+"-hide";a("#"+f).prop("checked",false).triggerHandler("click");return false});a(".hide-postbox-tog").click(function(){var e=a(this).val();if(a(this).prop("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(ajaxurl,{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(ajaxurl,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");if("dashboard_browser_nag"==f){return}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(".postbox a.dismiss").click(function(g){var f=a(this).parents(".postbox").attr("id")+"-hide";a("#"+f).prop("checked",false).triggerHandler("click");return false});a(".hide-postbox-tog").click(function(){var e=a(this).val();if(a(this).prop("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,stop:function(f,d){if(a(this).find("#dashboard_browser_nag").is(":visible")&&"dashboard_browser_nag"!=this.firstChild.id){a(this).sortable("cancel");return}postboxes.save_order(c);d.item.parent().removeClass("temp-border")},receive:function(f,d){if("dashboard_browser_nag"==d.item[0].id){a(d.sender).sortable("cancel")}}})},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(ajaxurl,{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(ajaxurl,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 5b6129b7d4..abc5a18e86 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -324,7 +324,7 @@ function wp_default_scripts( &$scripts ) { $scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", array('jquery'), '20110524' ); $scripts->add_data( 'xfn', 'group', 1 ); - $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), '20110524' ); + $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), '20110612' ); $scripts->add_data( 'postbox', 'group', 1 ); $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), '20110524' );