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

1 line
13 KiB
JavaScript

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