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

2 lines
6.5 KiB
JavaScript
Raw Normal View History

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