mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-19 00:55:13 +01:00
05135541be
git-svn-id: http://svn.automattic.com/wordpress/trunk@10641 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 line
3.0 KiB
JavaScript
1 line
3.0 KiB
JavaScript
var postboxes;(function(a){postboxes={add_postbox_toggles:function(c,b){a(".postbox h3, .postbox .handlediv").click(function(){a(a(this).parent().get(0)).toggleClass("closed");postboxes.save_state(c)});a(".postbox h3 a").click(function(f){f.stopPropagation()});a(".hide-postbox-tog").click(function(){var e=jQuery(this).val();if(jQuery(this).attr("checked")){jQuery("#"+e).show();if(a.isFunction(postboxes.pbshow)){postboxes.pbshow(e)}}else{jQuery("#"+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;if(e){for(f=4;(f>e&&f>1);f--){a("#"+d(f-1)+"-sortables").append(a("#"+d(f)+"-sortables").children(".postbox"));a("#"+d(f)+"-sortables").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""}}this.expandSidebar();this.init(c,b)},expandSidebar:function(b){if(!a("#side-info-column").length){return}if(b||a("#side-sortables > .postbox:visible").length){if(!a("#post-body").hasClass("has-sidebar")){a("#post-body").addClass("has-sidebar");var c=Math.min(a("#post-body").height(),300);a("#side-sortables").css({minHeight:c+"px",height:"auto"})}}else{a("#post-body").removeClass("has-sidebar");a("#side-sortables").css({minHeight:"0"});if(a.browser.msie&&a.browser.version.charAt(0)==7){a("#side-sortables").css({height:"0"})}}},init:function(d,b){var c=a("#dashboard-widgets").length;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",distance:2,tolerance:"pointer",toleranceMove:"tolerance",sort:function(g,f){if(c){return}if(a(document).width()-g.clientX<300){if(!a("#post-body").hasClass("has-sidebar")){var h=a("#side-sortables").offset();a("#side-sortables").append(f.item);a(f.placeholder).css({top:h.top,left:h.left}).width(a(f.item).width());postboxes.expandSidebar(1)}}},stop:function(g,f){postboxes.save_order(d);f.item.parent().removeClass("temp-border");postboxes.expandSidebar()}})},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});postboxes.expandSidebar()},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)); |