1 line
15 KiB
JavaScript
1 line
15 KiB
JavaScript
!function(Q,V){var q=Q(document),B=Q(V),H=Q(document.body);V.adminMenu={init:function(){},fold:function(){},restoreMenuState:function(){},toggle:function(){},favorites:function(){}},V.columns={init:function(){var n=this;Q(".hide-column-tog","#adv-settings").click(function(){var e=Q(this),t=e.val();e.prop("checked")?n.checked(t):n.unchecked(t),columns.saveManageColumnsState()})},saveManageColumnsState:function(){var e=this.hidden();Q.post(ajaxurl,{action:"hidden-columns",hidden:e,screenoptionnonce:Q("#screenoptionnonce").val(),page:pagenow})},checked:function(e){Q(".column-"+e).removeClass("hidden"),this.colSpanChange(1)},unchecked:function(e){Q(".column-"+e).addClass("hidden"),this.colSpanChange(-1)},hidden:function(){return Q(".manage-column[id]").filter(".hidden").map(function(){return this.id}).get().join(",")},useCheckboxesForHidden:function(){this.hidden=function(){return Q(".hide-column-tog").not(":checked").map(function(){var e=this.id;return e.substring(e,e.length-5)}).get().join(",")}},colSpanChange:function(e){var t=Q("table").find(".colspanchange");t.length&&(e=parseInt(t.attr("colspan"),10)+e,t.attr("colspan",e.toString()))}},q.ready(function(){columns.init()}),V.validateForm=function(e){return!Q(e).find(".form-required").filter(function(){return""===Q(":input:visible",this).val()}).addClass("form-invalid").find(":input:visible").change(function(){Q(this).closest(".form-invalid").removeClass("form-invalid")}).length},V.showNotice={warn:function(){var e=commonL10n.warnDelete||"";return!!confirm(e)},note:function(e){alert(e)}},V.screenMeta={element:null,toggles:null,page:null,init:function(){this.element=Q("#screen-meta"),this.toggles=Q("#screen-meta-links").find(".show-settings"),this.page=Q("#wpcontent"),this.toggles.click(this.toggleEvent)},toggleEvent:function(){var e=Q("#"+Q(this).attr("aria-controls"));e.length&&(e.is(":visible")?screenMeta.close(e,Q(this)):screenMeta.open(e,Q(this)))},open:function(e,t){Q("#screen-meta-links").find(".screen-meta-toggle").not(t.parent()).css("visibility","hidden"),e.parent().show(),e.slideDown("fast",function(){e.focus(),t.addClass("screen-meta-active").attr("aria-expanded",!0)}),q.trigger("screen:options:open")},close:function(e,t){e.slideUp("fast",function(){t.removeClass("screen-meta-active").attr("aria-expanded",!1),Q(".screen-meta-toggle").css("visibility",""),e.parent().hide()}),q.trigger("screen:options:close")}},Q(".contextual-help-tabs").delegate("a","click",function(e){var t=Q(this);if(e.preventDefault(),t.is(".active a"))return!1;Q(".contextual-help-tabs .active").removeClass("active"),t.parent("li").addClass("active"),t=Q(t.attr("href")),Q(".help-tab-content").not(t).removeClass("active").hide(),t.addClass("active").show()});var e,s=!1,a=Q("#permalink_structure"),t=Q(".permalink-structure input:radio"),r=Q("#custom_selection"),n=Q(".form-table.permalink-structure .available-structure-tags button");function l(e){-1!==a.val().indexOf(e.text().trim())?(e.attr("data-label",e.attr("aria-label")),e.attr("aria-label",e.attr("data-used")),e.attr("aria-pressed",!0),e.addClass("active")):e.attr("data-label")&&(e.attr("aria-label",e.attr("data-label")),e.attr("aria-pressed",!1),e.removeClass("active"))}function i(){q.trigger("wp-window-resized")}t.on("change",function(){"custom"!==this.value&&(a.val(this.value),n.each(function(){l(Q(this))}))}),a.on("click input",function(){r.prop("checked",!0)}),a.on("focus",function(e){s=!0,Q(this).off(e)}),n.each(function(){l(Q(this))}),a.on("change",function(){n.each(function(){l(Q(this))})}),n.on("click",function(){var e=a.val(),t=a[0].selectionStart,n=a[0].selectionEnd,i=Q(this).text().trim(),o=Q(this).attr("data-added");if(-1!==e.indexOf(i))return e=e.replace(i+"/",""),a.val("/"===e?"":e),Q("#custom_selection_updated").text(o),void l(Q(this));s||0!==t||0!==n||(t=n=e.length),r.prop("checked",!0),"/"!==e.substr(0,t).substr(-1)&&(i="/"+i),"/"!==e.substr(n,1)&&(i+="/"),a.val(e.substr(0,t)+i+e.substr(n)),Q("#custom_selection_updated").text(o),l(Q(this)),s&&a[0].setSelectionRange&&(i=(e.substr(0,t)+i).length,a[0].setSelectionRange(i,i),a.focus())}),q.ready(function(){var n,i,o,s,e,t,a,r,l,c,d=!1,u=Q("input.current-page"),p=u.val(),f=/iPhone|iPad|iPod/.test(navigator.userAgent),h=-1!==navigator.userAgent.indexOf("Android"),m=Q(document.documentElement).hasClass("ie8"),v=Q("#adminmenuwrap"),b=Q("#wpwrap"),g=Q("#adminmenu"),w=Q("#wp-responsive-overlay"),k=Q("#wp-toolbar"),C=k.find('a[aria-haspopup="true"]'),x=Q(".meta-box-sortables"),y=!1,S=Q("#wpadminbar"),D=0,M=!1,E=!1,T=0,j=!1,A={window:B.height(),wpwrap:b.height(),adminbar:S.height(),menu:v.height()},_=Q(".wp-header-end");function I(){var e=Q("a.wp-has-current-submenu");"folded"===r?e.attr("aria-haspopup","true"):e.attr("aria-haspopup","false")}function O(e){var t=e.find(".wp-submenu"),n=e.offset().top,i=B.scrollTop(),o=n-i-30,e=n+t.height()+1,n=60+e-b.height(),i=B.height()+i-50;1<(n=o<(n=i<e-n?e-i:n)?o:n)?t.css("margin-top","-"+n+"px"):t.css("margin-top","")}function U(){Q(".notice.is-dismissible").each(function(){var t=Q(this),e=Q('<button type="button" class="notice-dismiss"><span class="screen-reader-text"></span></button>'),n=commonL10n.dismiss||"";e.find(".screen-reader-text").text(n),e.on("click.wp-dismiss-notice",function(e){e.preventDefault(),t.fadeTo(100,0,function(){t.slideUp(100,function(){t.remove()})})}),t.append(e)})}function K(){l.prop("disabled",""===c.map(function(){return Q(this).val()}).get().join(""))}function z(e){var t=B.scrollTop(),e=!e||"scroll"!==e.type;if(!(f||m||g.data("wp-responsive")))if(A.menu+A.adminbar<A.window||A.menu+A.adminbar+20>A.wpwrap)P();else{if(j=!0,A.menu+A.adminbar>A.window){if(t<0)return void(M||(E=!(M=!0),v.css({position:"fixed",top:"",bottom:""})));if(t+A.window>q.height()-1)return void(E||(M=!(E=!0),v.css({position:"fixed",top:"",bottom:0})));D<t?M?(M=!1,(T=v.offset().top-A.adminbar-(t-D))+A.menu+A.adminbar<t+A.window&&(T=t+A.window-A.menu-A.adminbar),v.css({position:"absolute",top:T,bottom:""})):!E&&v.offset().top+A.menu<t+A.window&&(E=!0,v.css({position:"fixed",top:"",bottom:0})):t<D?E?(E=!1,(T=v.offset().top-A.adminbar+(D-t))+A.menu>t+A.window&&(T=t),v.css({position:"absolute",top:T,bottom:""})):!M&&v.offset().top>=t+A.adminbar&&(M=!0,v.css({position:"fixed",top:"",bottom:""})):e&&(M=E=!1,0<(T=t+A.window-A.menu-A.adminbar-1)?v.css({position:"absolute",top:T,bottom:""}):P())}D=t}}function N(){A={window:B.height(),wpwrap:b.height(),adminbar:S.height(),menu:v.height()}}function P(){!f&&j&&(M=E=j=!1,v.css({position:"",top:"",bottom:""}))}function R(){N(),g.data("wp-responsive")?(H.removeClass("sticky-menu"),P()):A.menu+A.adminbar>A.window?(z(),H.removeClass("sticky-menu")):(H.addClass("sticky-menu"),P())}function W(){Q(".aria-button-if-js").attr("role","button")}function L(){var e=!1;return e=V.innerWidth?Math.max(V.innerWidth,document.documentElement.clientWidth):e}function F(){var e=L()||961;r=e<=782?"responsive":H.hasClass("folded")||H.hasClass("auto-fold")&&e<=960&&782<e?"folded":"open",q.trigger("wp-menu-state-set",{state:r})}g.on("click.wp-submenu-head",".wp-submenu-head",function(e){Q(e.target).parent().siblings("a").get(0).click()}),Q("#collapse-button").on("click.collapse-menu",function(){var e=L()||961;Q("#adminmenu div.wp-submenu").css("margin-top",""),r=e<960?H.hasClass("auto-fold")?(H.removeClass("auto-fold").removeClass("folded"),setUserSetting("unfold",1),setUserSetting("mfold","o"),"open"):(H.addClass("auto-fold"),setUserSetting("unfold",0),"folded"):H.hasClass("folded")?(H.removeClass("folded"),setUserSetting("mfold","o"),"open"):(H.addClass("folded"),setUserSetting("mfold","f"),"folded"),q.trigger("wp-collapse-menu",{state:r})}),q.on("wp-menu-state-set wp-collapse-menu wp-responsive-activate wp-responsive-deactivate",I),("ontouchstart"in V||/IEMobile\/[1-9]/.test(navigator.userAgent))&&(H.on((e=f?"touchstart":"click")+".wp-mobile-hover",function(e){g.data("wp-responsive")||Q(e.target).closest("#adminmenu").length||g.find("li.opensub").removeClass("opensub")}),g.find("a.wp-has-submenu").on(e+".wp-mobile-hover",function(e){var t=Q(this).parent();g.data("wp-responsive")||t.hasClass("opensub")||t.hasClass("wp-menu-open")&&!(t.width()<40)||(e.preventDefault(),O(t),g.find("li.opensub").removeClass("opensub"),t.addClass("opensub"))})),f||h||(g.find("li.wp-has-submenu").hoverIntent({over:function(){var e=Q(this),t=e.find(".wp-submenu"),t=parseInt(t.css("top"),10);isNaN(t)||-5<t||g.data("wp-responsive")||(O(e),g.find("li.opensub").removeClass("opensub"),e.addClass("opensub"))},out:function(){g.data("wp-responsive")||Q(this).removeClass("opensub").find(".wp-submenu").css("margin-top","")},timeout:200,sensitivity:7,interval:90}),g.on("focus.adminmenu",".wp-submenu a",function(e){g.data("wp-responsive")||Q(e.target).closest("li.menu-top").addClass("opensub")}).on("blur.adminmenu",".wp-submenu a",function(e){g.data("wp-responsive")||Q(e.target).closest("li.menu-top").removeClass("opensub")}).find("li.wp-has-submenu.wp-not-current-submenu").on("focusin.adminmenu",function(){O(Q(this))})),_.length||(_=Q(".wrap h1, .wrap h2").first()),Q("div.updated, div.error, div.notice").not(".inline, .below-h2").insertAfter(_),q.on("wp-updates-notice-added wp-plugin-install-error wp-plugin-update-error wp-plugin-delete-error wp-theme-install-error wp-theme-delete-error",U),screenMeta.init(),H.on("click","tbody > tr > .check-column :checkbox",function(e){if("undefined"==e.shiftKey)return!0;if(e.shiftKey){if(!d)return!0;n=Q(d).closest("form").find(":checkbox").filter(":visible:enabled"),i=n.index(d),o=n.index(this),s=Q(this).prop("checked"),0<i&&0<o&&i!=o&&(i<o?n.slice(i,o):n.slice(o,i)).prop("checked",function(){return!!Q(this).closest("tr").is(":visible")&&s})}var t=Q(d=this).closest("tbody").find(":checkbox").filter(":visible:enabled").not(":checked");return Q(this).closest("table").children("thead, tfoot").find(":checkbox").prop("checked",function(){return 0===t.length}),!0}),H.on("click.wp-toggle-checkboxes","thead .check-column :checkbox, tfoot .check-column :checkbox",function(e){var t=Q(this),n=t.closest("table"),i=t.prop("checked"),o=e.shiftKey||t.data("wp-toggle");n.children("tbody").filter(":visible").children().children(".check-column").find(":checkbox").prop("checked",function(){return!Q(this).is(":hidden,:disabled")&&(o?!Q(this).prop("checked"):!!i)}),n.children("thead, tfoot").filter(":visible").children().children(".check-column").find(":checkbox").prop("checked",function(){return!o&&!!i})}),Q("#wpbody-content").on({focusin:function(){clearTimeout(t),a=Q(this).find(".row-actions"),Q(".row-actions").not(this).removeClass("visible"),a.addClass("visible")},focusout:function(){t=setTimeout(function(){a.removeClass("visible")},30)}},".has-row-actions"),Q("tbody").on("click",".toggle-row",function(){Q(this).closest("tr").toggleClass("is-expanded")}),Q("#default-password-nag-no").click(function(){return setUserSetting("default_password_nag","hide"),Q("div.default-password-nag").hide(),!1}),Q("#newcontent").bind("keydown.wpevent_InsertTab",function(e){var t,n,i,o,s=e.target;if(27==e.keyCode)return e.preventDefault(),void Q(s).data("tab-out",!0);9!=e.keyCode||e.ctrlKey||e.altKey||e.shiftKey||(Q(s).data("tab-out")?Q(s).data("tab-out",!1):(t=s.selectionStart,n=s.selectionEnd,i=s.value,document.selection?(s.focus(),document.selection.createRange().text="\t"):0<=t&&(o=this.scrollTop,s.value=i.substring(0,t).concat("\t",i.substring(n)),s.selectionStart=s.selectionEnd=t+1,this.scrollTop=o),e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()))}),u.length&&u.closest("form").submit(function(){-1==Q('select[name="action"]').val()&&-1==Q('select[name="action2"]').val()&&u.val()==p&&u.val("1")}),Q('.search-box input[type="search"], .search-box input[type="submit"]').mousedown(function(){Q('select[name^="action"]').val("-1")}),Q("#contextual-help-link, #show-settings-link").on("focus.scroll-into-view",function(e){e.target.scrollIntoView&&e.target.scrollIntoView(!1)}),(_=Q("form.wp-upload-form")).length&&(l=_.find('input[type="submit"]'),c=_.find('input[type="file"]'),K(),c.on("change",K)),f||(B.on("scroll.pin-menu",z),q.on("tinymce-editor-init.pin-menu",function(e,t){t.on("wp-autoresize",N)})),V.wpResponsive={init:function(){var e=this;this.maybeDisableSortables=this.maybeDisableSortables.bind(this),q.on("wp-responsive-activate.wp-responsive",function(){e.activate()}).on("wp-responsive-deactivate.wp-responsive",function(){e.deactivate()}),Q("#wp-admin-bar-menu-toggle a").attr("aria-expanded","false"),Q("#wp-admin-bar-menu-toggle").on("click.wp-responsive",function(e){e.preventDefault(),S.find(".hover").removeClass("hover"),b.toggleClass("wp-responsive-open"),b.hasClass("wp-responsive-open")?(Q(this).find("a").attr("aria-expanded","true"),Q("#adminmenu a:first").focus()):Q(this).find("a").attr("aria-expanded","false")}),g.on("click.wp-responsive","li.wp-has-submenu > a",function(e){g.data("wp-responsive")&&(Q(this).parent("li").toggleClass("selected"),e.preventDefault())}),e.trigger(),q.on("wp-window-resized.wp-responsive",Q.proxy(this.trigger,this)),B.on("load.wp-responsive",this.maybeDisableSortables),q.on("postbox-toggled",this.maybeDisableSortables),Q("#screen-options-wrap input").on("click",this.maybeDisableSortables)},maybeDisableSortables:function(){(-1<navigator.userAgent.indexOf("AppleWebKit/")?B.width():V.innerWidth)<=782||x.find(".ui-sortable-handle:visible").length<=1&&jQuery(".columns-prefs-1 input").prop("checked")?this.disableSortables():this.enableSortables()},activate:function(){R(),H.hasClass("auto-fold")||H.addClass("auto-fold"),g.data("wp-responsive",1),this.disableSortables()},deactivate:function(){R(),g.removeData("wp-responsive"),this.maybeDisableSortables()},trigger:function(){var e=L();e&&(e<=782?y||(q.trigger("wp-responsive-activate"),y=!0):y&&(q.trigger("wp-responsive-deactivate"),y=!1),e<=480?this.enableOverlay():this.disableOverlay(),this.maybeDisableSortables())},enableOverlay:function(){0===w.length&&(w=Q('<div id="wp-responsive-overlay"></div>').insertAfter("#wpcontent").hide().on("click.wp-responsive",function(){k.find(".menupop.hover").removeClass("hover"),Q(this).hide()})),C.on("click.wp-responsive",function(){w.show()})},disableOverlay:function(){C.off("click.wp-responsive"),w.hide()},disableSortables:function(){if(x.length)try{x.sortable("disable"),x.find(".ui-sortable-handle").addClass("is-non-sortable")}catch(e){}},enableSortables:function(){if(x.length)try{x.sortable("enable"),x.find(".ui-sortable-handle").removeClass("is-non-sortable")}catch(e){}}},Q(document).ajaxComplete(function(){W()}),q.on("wp-window-resized.set-menu-state",F),q.on("wp-menu-state-set wp-collapse-menu",function(e,t){var n=Q("#collapse-button"),i="true",o=commonL10n.collapseMenu;"folded"===t.state&&(i="false",o=commonL10n.expandMenu),n.attr({"aria-expanded":i,"aria-label":o})}),V.wpResponsive.init(),R(),F(),I(),U(),W(),q.on("wp-pin-menu wp-window-resized.pin-menu postboxes-columnchange.pin-menu postbox-toggled.pin-menu wp-collapse-menu.pin-menu wp-scroll-start.pin-menu",R),Q(".wp-initial-focus").focus(),H.on("click",".js-update-details-toggle",function(){var e=Q(this).closest(".js-update-details"),t=Q("#"+e.data("update-details"));t.hasClass("update-details-moved")||t.insertAfter(e).addClass("update-details-moved"),t.toggle(),Q(this).attr("aria-expanded",t.is(":visible"))})}),B.on("resize.wp-fire-once",function(){V.clearTimeout(e),e=V.setTimeout(i,200)}),"-ms-user-select"in document.documentElement.style&&navigator.userAgent.match(/IEMobile\/10\.0/)&&((t=document.createElement("style")).appendChild(document.createTextNode("@-ms-viewport{width:auto!important}")),document.getElementsByTagName("head")[0].appendChild(t))}(jQuery,window); |