WordPress/wp-admin/js/postbox.min.js

1 line
3.4 KiB
JavaScript

var postboxes;!function(i){var a=i(document);postboxes={add_postbox_toggles:function(s,e){var t=this;t.init(s,e),i(".postbox .hndle, .postbox .handlediv").bind("click.postboxes",function(){var e=i(this).parent(".postbox"),o=e.attr("id");"dashboard_browser_nag"!=o&&(e.toggleClass("closed"),"press-this"!=s&&t.save_state(s),o&&(!e.hasClass("closed")&&i.isFunction(postboxes.pbshow)?t.pbshow(o):e.hasClass("closed")&&i.isFunction(postboxes.pbhide)&&t.pbhide(o)),a.trigger("postbox-toggled",e))}),i(".postbox .hndle a").click(function(e){e.stopPropagation()}),i(".postbox a.dismiss").bind("click.postboxes",function(){var e=i(this).parents(".postbox").attr("id")+"-hide";return i("#"+e).prop("checked",!1).triggerHandler("click"),!1}),i(".hide-postbox-tog").bind("click.postboxes",function(){var e=i(this).val(),o=i("#"+e);i(this).prop("checked")?(o.show(),i.isFunction(postboxes.pbshow)&&t.pbshow(e)):(o.hide(),i.isFunction(postboxes.pbhide)&&t.pbhide(e)),t.save_state(s),t._mark_area(),a.trigger("postbox-toggled",o)}),i('.columns-prefs input[type="radio"]').bind("click.postboxes",function(){var e=parseInt(i(this).val(),10);e&&(t._pb_edit(e),t.save_order(s))})},init:function(e,o){var s=i(document.body).hasClass("mobile");i.extend(this,o||{}),i("#wpbody-content").css("overflow","hidden"),i(".meta-box-sortables").sortable({placeholder:"sortable-placeholder",connectWith:".meta-box-sortables",items:".postbox",handle:".hndle",cursor:"move",delay:s?200:0,distance:2,tolerance:"pointer",forcePlaceholderSize:!0,helper:"clone",opacity:.65,stop:function(){i(this).find("#dashboard_browser_nag").is(":visible")&&"dashboard_browser_nag"!=this.firstChild.id?i(this).sortable("cancel"):postboxes.save_order(e)},receive:function(e,o){"dashboard_browser_nag"==o.item[0].id&&i(o.sender).sortable("cancel"),postboxes._mark_area()}}),s&&(i(document.body).bind("orientationchange.postboxes",function(){postboxes._pb_change()}),this._pb_change()),this._mark_area()},save_state:function(e){var o=i(".postbox").filter(".closed").map(function(){return this.id}).get().join(","),s=i(".postbox").filter(":hidden").map(function(){return this.id}).get().join(",");i.post(ajaxurl,{action:"closed-postboxes",closed:o,hidden:s,closedpostboxesnonce:jQuery("#closedpostboxesnonce").val(),page:e})},save_order:function(e){var o=i(".columns-prefs input:checked").val()||0,s={action:"meta-box-order",_ajax_nonce:i("#meta-box-order-nonce").val(),page_columns:o,page:e};i(".meta-box-sortables").each(function(){s["order["+this.id.split("-")[0]+"]"]=i(this).sortable("toArray").join(",")}),i.post(ajaxurl,s)},_mark_area:function(){var o=i("div.postbox:visible").length,e=i("#post-body #side-sortables");i("#dashboard-widgets .meta-box-sortables:visible").each(function(){var e=i(this);1==o||e.children(".postbox:visible").length?e.removeClass("empty-container"):e.addClass("empty-container")}),e.length&&(e.children(".postbox:visible").length?e.removeClass("empty-container"):"280px"==i("#postbox-container-1").css("width")&&e.addClass("empty-container"))},_pb_edit:function(e){var o=i(".metabox-holder").get(0);o&&(o.className=o.className.replace(/columns-\d+/,"columns-"+e)),i(document).trigger("postboxes-columnchange")},_pb_change:function(){var e=i('label.columns-prefs-1 input[type="radio"]');switch(window.orientation){case 90:case-90:e.length&&e.is(":checked")||this._pb_edit(2);break;case 0:case 180:i("#poststuff").length?this._pb_edit(1):e.length&&e.is(":checked")||this._pb_edit(2)}},pbshow:!1,pbhide:!1}}(jQuery);