mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-07 13:18:14 +02:00
git-svn-id: http://svn.automattic.com/wordpress/trunk@18736 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 line
4.9 KiB
JavaScript
1 line
4.9 KiB
JavaScript
var postboxes;(function(a){postboxes={add_postbox_toggles:function(c,b){this.init(c,b);a(".postbox h3, .postbox .handlediv").click(function(){var d=a(this).parent(".postbox"),e=d.attr("id");if("dashboard_browser_nag"==e){return}d.toggleClass("closed");postboxes.save_state(c);if(e){if(!d.hasClass("closed")&&a.isFunction(postboxes.pbshow)){postboxes.pbshow(e)}else{if(d.hasClass("closed")&&a.isFunction(postboxes.pbhide)){postboxes.pbhide(e)}}}});a(".postbox h3 a").click(function(d){d.stopPropagation()});a(".postbox a.dismiss").click(function(f){var d=a(this).parents(".postbox").attr("id")+"-hide";a("#"+d).prop("checked",false).triggerHandler("click");return false});a(".hide-postbox-tog").click(function(){var d=a(this).val();if(a(this).prop("checked")){a("#"+d).show();if(a.isFunction(postboxes.pbshow)){postboxes.pbshow(d)}}else{a("#"+d).hide();if(a.isFunction(postboxes.pbhide)){postboxes.pbhide(d)}}postboxes.save_state(c)});a('.columns-prefs input[type="radio"]').click(function(){var d=a(this).val(),e=a("#poststuff");if(d=="auto"){a(window).bind("resize.responsive",function(){postboxes.auto_columns()});if(e.length){a(".wrap").removeClass("columns-1").removeClass("columns-2")}postboxes.auto_columns()}else{a(window).unbind("resize.responsive");d=parseInt(d,10);if(e.length){if(d==2){a(".wrap").removeClass("columns-1").addClass("columns-2");e.addClass("has-right-sidebar");if(!a("#side-info-column #side-sortables").length){a("#side-info-column").append(a("#side-sortables"))}}else{if(d==1){a(".wrap").removeClass("columns-2").addClass("columns-1");e.removeClass("has-right-sidebar");if(!a("#post-body-content #side-sortables").length){a("#normal-sortables").before(a("#side-sortables"))}}}}else{postboxes._dash_columns(d)}}postboxes.save_order(c)})},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)},auto_columns:function(){var b=a("#poststuff"),c;if(b.length){c=a("#post-body").width();if(c<800){b.removeClass("has-right-sidebar");if(!a("#post-body-content #side-sortables").length){a("#normal-sortables").before(a("#side-sortables"))}}else{b.addClass("has-right-sidebar");if(!a("#side-info-column #side-sortables").length){a("#side-info-column").append(a("#side-sortables"))}if(c<1150){a(document.body).removeClass("wide-window")}else{a(document.body).addClass("wide-window")}}}else{if(a("#dashboard-widgets-wrap").length){c=a(window).width();if(c<950){this._dash_columns(1)}else{if(c<1300){this._dash_columns(2)}else{if(c<1700){this._dash_columns(3)}else{this._dash_columns(4)}}}}}},_dash_columns:function(b){switch(b){case 1:a("#postbox-container-1").append(a("#side-sortables, #column3-sortables, #column4-sortables"));a("#postbox-container-2, #postbox-container-3, #postbox-container-4").hide();break;case 2:a("#postbox-container-2").append(a("#side-sortables, #column3-sortables, #column4-sortables")).show();a("#postbox-container-3, #postbox-container-4").hide();break;case 3:a("#postbox-container-2").append(a("#side-sortables")).show();a("#postbox-container-3").append(a("#column3-sortables, #column4-sortables")).show();a("#postbox-container-4").hide();break;case 4:a("#postbox-container-2").append(a("#side-sortables")).show();a("#postbox-container-3").append(a("#column3-sortables")).show();a("#postbox-container-4").append(a("#column4-sortables")).show();break;default:return}a(".postbox-container:visible").css("width",100/b+"%")},_colname:function(b){switch(b){case 1:return"normal";break;case 2:return"side";break;case 3:return"column3";break;case 4:return"column4";break;default:return""}},pbshow:false,pbhide:false};a(document).ready(function(){if(!a("#wp_auto_columns").length||a("#wp_auto_columns").prop("checked")){a(window).bind("resize.responsive",function(){postboxes.auto_columns()});postboxes.auto_columns()}})}(jQuery)); |