mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-09 04:11:10 +01:00
a048514d43
Merges [36134] to the 4.4 branch. Props afercia, DvanKooten. Fixes #35047. Built from https://develop.svn.wordpress.org/branches/4.4@36144 git-svn-id: http://core.svn.wordpress.org/branches/4.4@36110 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 line
13 KiB
JavaScript
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=B.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(".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),c.on("click.wp-dismiss-notice",function(a){a.preventDefault(),b.fadeTo(100,0,function(){b.slideUp(100,function(){b.remove()})})}),b.append(c)})}function i(a){var b=e.scrollTop(),c=!a||"scroll"!==a.type;if(!(x||z||C.data("wp-responsive"))){if(O.menu+O.adminbar<O.window||O.menu+O.adminbar+20>O.wpwrap)return void k();if(N=!0,O.menu+O.adminbar>O.window){if(0>b)return void(K||(K=!0,L=!1,A.css({position:"fixed",top:"",bottom:""})));if(b+O.window>d.height()-1)return void(L||(L=!0,K=!1,A.css({position:"fixed",top:"",bottom:0})));b>J?K?(K=!1,M=A.offset().top-O.adminbar-(b-J),M+O.menu+O.adminbar<b+O.window&&(M=b+O.window-O.menu-O.adminbar),A.css({position:"absolute",top:M,bottom:""})):!L&&A.offset().top+O.menu<b+O.window&&(L=!0,A.css({position:"fixed",top:"",bottom:0})):J>b?L?(L=!1,M=A.offset().top-O.adminbar+(J-b),M+O.menu>b+O.window&&(M=b),A.css({position:"absolute",top:M,bottom:""})):!K&&A.offset().top>=b+O.adminbar&&(K=!0,A.css({position:"fixed",top:"",bottom:""})):c&&(K=L=!1,M=b+O.window-O.menu-O.adminbar-1,M>0?A.css({position:"absolute",top:M,bottom:""}):k())}J=b}}function j(){O={window:e.height(),wpwrap:B.height(),adminbar:I.height(),menu:A.height()}}function k(){!x&&N&&(K=L=N=!1,A.css({position:"",top:"",bottom:""}))}function l(){j(),C.data("wp-responsive")?(f.removeClass("sticky-menu"),k()):O.menu+O.adminbar>O.window?(i(),f.removeClass("sticky-menu")):(f.addClass("sticky-menu"),k())}var m,n,o,p,q,r,s,t,u=!1,v=a("input.current-page"),w=v.val(),x=/iPhone|iPad|iPod/.test(navigator.userAgent),y=-1!==navigator.userAgent.indexOf("Android"),z=a(document.documentElement).hasClass("ie8"),A=a("#adminmenuwrap"),B=a("#wpwrap"),C=a("#adminmenu"),D=a("#wp-responsive-overlay"),E=a("#wp-toolbar"),F=E.find('a[aria-haspopup="true"]'),G=a(".meta-box-sortables"),H=!1,I=a("#wpadminbar"),J=0,K=!1,L=!1,M=0,N=!1,O={window:e.height(),wpwrap:B.height(),adminbar:I.height(),menu:A.height()};C.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))&&(r=x?"touchstart":"click",f.on(r+".wp-mobile-hover",function(b){C.data("wp-responsive")||a(b.target).closest("#adminmenu").length||C.find("li.opensub").removeClass("opensub")}),C.find("a.wp-has-submenu").on(r+".wp-mobile-hover",function(b){var c=a(this).parent();C.data("wp-responsive")||c.hasClass("opensub")||c.hasClass("wp-menu-open")&&!(c.width()<40)||(b.preventDefault(),g(c),C.find("li.opensub").removeClass("opensub"),c.addClass("opensub"))})),x||y||(C.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||C.data("wp-responsive")||(g(b),C.find("li.opensub").removeClass("opensub"),b.addClass("opensub"))},out:function(){C.data("wp-responsive")||a(this).removeClass("opensub").find(".wp-submenu").css("margin-top","")},timeout:200,sensitivity:7,interval:90}),C.on("focus.adminmenu",".wp-submenu a",function(b){C.data("wp-responsive")||a(b.target).closest("li.menu-top").addClass("opensub")}).on("blur.adminmenu",".wp-submenu a",function(b){C.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 h1, .wrap h2").first()),d.on("wp-plugin-update-error",function(){h()}),screenMeta.init(),a("tbody").children().children(".check-column").find(":checkbox").click(function(b){if("undefined"==b.shiftKey)return!0;if(b.shiftKey){if(!u)return!0;m=a(u).closest("form").find(":checkbox").filter(":visible:enabled"),n=m.index(u),o=m.index(this),p=a(this).prop("checked"),n>0&&o>0&&n!=o&&(q=o>n?m.slice(n,o):m.slice(o,n),q.prop("checked",function(){return a(this).closest("tr").is(":visible")?p:!1}))}u=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(s),t=a(this).find(".row-actions"),a(".row-actions").not(this).removeClass("visible"),t.addClass("visible")},focusout:function(){s=setTimeout(function(){t.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()}}),v.length&&v.closest("form").submit(function(){-1==a('select[name="action"]').val()&&-1==a('select[name="action2"]').val()&&v.val()==w&&v.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))}(),x||(e.on("scroll.pin-menu",i),d.on("tinymce-editor-init.pin-menu",function(a,b){b.on("wp-autoresize",j)})),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(),I.find(".hover").removeClass("hover"),B.toggleClass("wp-responsive-open"),B.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")}),C.on("click.wp-responsive","li.wp-has-submenu > a",function(b){C.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(){l(),f.hasClass("auto-fold")||f.addClass("auto-fold"),C.data("wp-responsive",1),this.disableSortables()},deactivate:function(){l(),C.removeData("wp-responsive"),this.enableSortables()},trigger:function(){var a;b.innerWidth&&(a=Math.max(b.innerWidth,document.documentElement.clientWidth),782>=a?H||(d.trigger("wp-responsive-activate"),H=!0):H&&(d.trigger("wp-responsive-deactivate"),H=!1),480>=a?this.enableOverlay():this.disableOverlay())},enableOverlay:function(){0===D.length&&(D=a('<div id="wp-responsive-overlay"></div>').insertAfter("#wpcontent").hide().on("click.wp-responsive",function(){E.find(".menupop.hover").removeClass("hover"),a(this).hide()})),F.on("click.wp-responsive",function(){D.show()})},disableOverlay:function(){F.off("click.wp-responsive"),D.hide()},disableSortables:function(){if(G.length)try{G.sortable("disable")}catch(a){}},enableSortables:function(){if(G.length)try{G.sortable("enable")}catch(a){}}},b.wpResponsive.init(),l(),c(),h(),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",l)}),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); |