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

2 lines
6.5 KiB
JavaScript
Raw Normal View History

/*! This file is auto-generated */
!function(l){var a=l(document),n=wp.i18n.__;window.postboxes={handle_click:function(){var e,s=l(this),o=s.closest(".postbox"),t=o.attr("id");"dashboard_browser_nag"!==t&&(o.toggleClass("closed"),e=!o.hasClass("closed"),s.hasClass("handlediv")?s.attr("aria-expanded",e):s.closest(".postbox").find("button.handlediv").attr("aria-expanded",e),"press-this"!==postboxes.page&&postboxes.save_state(postboxes.page),t&&(!o.hasClass("closed")&&l.isFunction(postboxes.pbshow)?postboxes.pbshow(t):o.hasClass("closed")&&l.isFunction(postboxes.pbhide)&&postboxes.pbhide(t)),a.trigger("postbox-toggled",o))},handleOrder:function(){var e,s=l(this),o=s.closest(".postbox"),t=o.attr("id"),a=o.closest(".meta-box-sortables").find(".postbox:visible"),r=a.length,i=a.index(o);if("dashboard_browser_nag"!==t){if("true"===s.attr("aria-disabled"))return e=s.hasClass("handle-order-higher")?n("The box is on the first position"):n("The box is on the last position"),void wp.a11y.speak(e);if(s.hasClass("handle-order-higher")){if(0===i)return void postboxes.handleOrderBetweenSortables("previous",s,o);o.prevAll(".postbox:visible").eq(0).before(o),s.focus(),postboxes.updateOrderButtonsProperties(),postboxes.save_order(postboxes.page)}if(s.hasClass("handle-order-lower")){if(i+1===r)return void postboxes.handleOrderBetweenSortables("next",s,o);o.nextAll(".postbox:visible").eq(0).after(o),s.focus(),postboxes.updateOrderButtonsProperties(),postboxes.save_order(postboxes.page)}}},handleOrderBetweenSortables:function(e,s,o){var t,a,r=s.closest(".meta-box-sortables").attr("id"),i=[];l(".meta-box-sortables:visible").each(function(){i.push(l(this).attr("id"))}),1!==i.length&&(t=l.inArray(r,i),a=o.detach(),"previous"===e&&l(a).appendTo("#"+i[t-1]),"next"===e&&l(a).prependTo("#"+i[t+1]),postboxes._mark_area(),s.focus(),postboxes.updateOrderButtonsProperties(),postboxes.save_order(postboxes.page))},updateOrderButtonsProperties:function(){var e=l(".meta-box-sortables:visible:first").attr("id"),s=l(".meta-box-sortables:visible:last").attr("id"),o=l(".postbox:visible:first"),t=l(".postbox:visible:last"),a=o.attr("id"),r=t.attr("id"),i=o.closest(".meta-box-sortables").attr("id"),n=t.closest(".meta-box-sortables").attr("id"),d=l(".handle-order-higher"),b=l(".handle-order-lower");d.attr("aria-disabled","false").removeClass("hidden"),b.attr("aria-disabled","false").removeClass("hidden"),e===s&&a===r&&(d.addClass("hidden"),b.addClass("hidden")),e===i&&l(o).find(".handle-order-higher").attr("aria-disabled","true"),s===n&&l(".postbox:visible .handle-order-lower").last().attr("aria-disabled","true")},add_postbox_toggles:function(t,e){var s=l(".postbox .hndle, .postbox .handlediv"),o=l(".postbox .handle-order-higher, .postbox .handle-order-lower");this.page=t,this.init(t,e),s.on("click.postboxes",this.handle_click),o.on("click.postboxes",this.handleOrder),l(".postbox .hndle a").click(function(e){e.stopPropagation()}),l(".postbox a.dismiss").on("click.postboxes",function(e){var s=l(this).parents(".postbox").attr("id")+"-hide";e.preventDefault(),l("#"+s).prop("checked",!1).triggerHandler("click")}),l(".hide-postbox-tog").bind("click.postboxes",function(){var e=l(this),s=e.val(),o=l("#"+s);e.prop("checked")?(o.show(),l.isFunction(postboxes.pbshow)&&postboxes.pbshow(s)):(o.hide(),l.isFunction(postboxes.pbhide)&&postboxes.pbhide(s)),postboxes.save_state(t),postboxes._mark_area(),a.trigger("postbox-toggled",o)}),l('.columns-prefs input[type="radio"]').bind("click.postboxes",function(){var e=parseInt(l(this).val(),10);e&&(postboxes._pb_edit(e),postboxes.save_order(t))})},init:function(s,e){var o=l(document.body).hasClass("mobile"),t=l(".postbox .handlediv");l.extend(this,e||{}),l(".meta-box-sortables").sortable({placeholder:"sortable-placeholder",connectWith:".meta-box-sortables",items:".postbox",handle:".hndle",cursor:"move",delay:o?200:0,distance:2,tolerance:"pointer",forcePlaceholderSize:!0,helper:function(e,s){return s.clone().find(":input").attr("name",function(e,s){return"sort_"+parseInt(1e5*Math.random(),10).toString()+"_"+s}).end()},opacity:.65,start:function(){l("body").addClass("is-