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

1 line
7.6 KiB
JavaScript

var showNotice,adminMenu,columns,validateForm,screenMeta;(function(a){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 d=a(this),c=d.val();if(d.prop("checked")){b.checked(c)}else{b.unchecked(c)}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).show();this.colSpanChange(+1)},unchecked:function(b){a(".column-"+b).hide();this.colSpanChange(-1)},hidden:function(){return a(".manage-column").filter(":hidden").map(function(){return this.id}).get().join(",")},useCheckboxesForHidden:function(){this.hidden=function(){return a(".hide-column-tog").not(":checked").map(function(){var b=this.id;return b.substring(b,b.length-5)}).get().join(",")}},colSpanChange:function(b){var d=a("table").find(".colspanchange"),c;if(!d.length){return}c=parseInt(d.attr("colspan"),10)+b;d.attr("colspan",c.toString())}};a(document).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 b=commonL10n.warnDelete||"";if(confirm(b)){return true}return false},note:function(b){alert(b)}};screenMeta={element:null,toggles:null,page:null,init:function(){this.element=a("#screen-meta");this.toggles=a(".screen-meta-toggle a");this.page=a("#wpcontent");this.toggles.click(this.toggleEvent)},toggleEvent:function(c){var b=a(this.href.replace(/.+#/,"#"));c.preventDefault();if(!b.length){return}if(b.is(":visible")){screenMeta.close(b,a(this))}else{screenMeta.open(b,a(this))}},open:function(b,c){a(".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",true)})},close:function(b,c){b.slideUp("fast",function(){c.removeClass("screen-meta-active").attr("aria-expanded",false);a(".screen-meta-toggle").css("visibility","");b.parent().hide()})}};a(".contextual-help-tabs").delegate("a","click focus",function(d){var c=a(this),b;d.preventDefault();if(c.is(".active a")){return false}a(".contextual-help-tabs .active").removeClass("active");c.parent("li").addClass("active");b=a(c.attr("href"));a(".help-tab-content").not(b).removeClass("active").hide();b.addClass("active").show()});a(document).ready(function(){var i=false,d,f,j,h,c=a("#adminmenu"),b,e=a("input.current-page"),g=e.val();c.on("click.wp-submenu-head",".wp-submenu-head",function(k){a(k.target).parent().siblings("a").get(0).click()});a("#collapse-menu").on("click.collapse-menu",function(l){var k=a(document.body);a("#adminmenu div.wp-submenu").css("margin-top","");if(a(window).width()<900){if(k.hasClass("auto-fold")){k.removeClass("auto-fold");setUserSetting("unfold",1);k.removeClass("folded");deleteUserSetting("mfold")}else{k.addClass("auto-fold");deleteUserSetting("unfold")}}else{if(k.hasClass("folded")){k.removeClass("folded");deleteUserSetting("mfold")}else{k.addClass("folded");setUserSetting("mfold","f")}}});if("ontouchstart" in window||/IEMobile\/[1-9]/.test(navigator.userAgent)){b=/Mobile\/.+Safari/.test(navigator.userAgent)?"touchstart":"click";a(document.body).on(b+".wp-mobile-hover",function(k){if(!a(k.target).closest("#adminmenu").length){c.find("li.wp-has-submenu.opensub").removeClass("opensub")}});c.find("a.wp-has-submenu").on(b+".wp-mobile-hover",function(m){var l=a(this),k=l.parent();if(!k.hasClass("opensub")&&(!k.hasClass("wp-menu-open")||k.width()<40)){m.preventDefault();c.find("li.opensub").removeClass("opensub");k.addClass("opensub")}})}c.find("li.wp-has-submenu").hoverIntent({over:function(s){var u,q,k,r,l=a(this).find(".wp-submenu"),v,n,p,t=parseInt(l.css("top"),10);if(isNaN(t)||t>-5){return}v=a(this).offset().top;n=a(window).scrollTop();p=v-n-30;u=v+l.height()+1;q=a("#wpwrap").height();k=60+u-q;r=a(window).height()+n-15;if(r<(u-k)){k=u-r}if(k>p){k=p}if(k>1){l.css("margin-top","-"+k+"px")}else{l.css("margin-top","")}c.find("li.menu-top").removeClass("opensub");a(this).addClass("opensub")},out:function(){a(this).removeClass("opensub").find(".wp-submenu").css("margin-top","")},timeout:200,sensitivity:7,interval:90});c.on("focus.adminmenu",".wp-submenu a",function(k){a(k.target).closest("li.menu-top").addClass("opensub")}).on("blur.adminmenu",".wp-submenu a",function(k){a(k.target).closest("li.menu-top").removeClass("opensub")});a("div.wrap h2:first").nextAll("div.updated, div.error").addClass("below-h2");a("div.updated, div.error").not(".below-h2, .inline").insertAfter(a("div.wrap h2:first"));screenMeta.init();a("tbody").children().children(".check-column").find(":checkbox").click(function(l){if("undefined"==l.shiftKey){return true}if(l.shiftKey){if(!i){return true}d=a(i).closest("form").find(":checkbox");f=d.index(i);j=d.index(this);h=a(this).prop("checked");if(0<f&&0<j&&f!=j){d.slice(f,j).prop("checked",function(){if(a(this).closest("tr").is(":visible")){return h}return false})}}i=this;var k=a(this).closest("tbody").find(":checkbox").filter(":visible").not(":checked");a(this).closest("table").children("thead, tfoot").find(":checkbox").prop("checked",function(){return(0==k.length)});return true});a("thead, tfoot").find(".check-column :checkbox").click(function(m){var n=a(this).prop("checked"),l="undefined"==typeof toggleWithKeyboard?false:toggleWithKeyboard,k=m.shiftKey||l;a(this).closest("table").children("tbody").filter(":visible").children().children(".check-column").find(":checkbox").prop("checked",function(){if(a(this).is(":hidden")){return false}if(k){return a(this).prop("checked")}else{if(n){return true}}return false});a(this).closest("table").children("thead, tfoot").filter(":visible").children().children(".check-column").find(":checkbox").prop("checked",function(){if(k){return false}else{if(n){return true}}return false})});a("#default-password-nag-no").click(function(){setUserSetting("default_password_nag","hide");a("div.default-password-nag").hide();return false});a("#newcontent").bind("keydown.wpevent_InsertTab",function(p){var m=p.target,r,l,q,k,o;if(p.keyCode==27){a(m).data("tab-out",true);return}if(p.keyCode!=9||p.ctrlKey||p.altKey||p.shiftKey){return}if(a(m).data("tab-out")){a(m).data("tab-out",false);return}r=m.selectionStart;l=m.selectionEnd;q=m.value;try{this.lastKey=9}catch(n){}if(document.selection){m.focus();o=document.selection.createRange();o.text="\t"}else{if(r>=0){k=this.scrollTop;m.value=q.substring(0,r).concat("\t",q.substring(l));m.selectionStart=m.selectionEnd=r+1;this.scrollTop=k}}if(p.stopPropagation){p.stopPropagation()}if(p.preventDefault){p.preventDefault()}});a("#newcontent").bind("blur.wpevent_InsertTab",function(k){if(this.lastKey&&9==this.lastKey){this.focus()}});if(e.length){e.closest("form").submit(function(k){if(a('select[name="action"]').val()==-1&&a('select[name="action2"]').val()==-1&&e.val()==g){e.val("1")}})}a("#contextual-help-link, #show-settings-link").on("focus.scroll-into-view",function(k){if(k.target.scrollIntoView){k.target.scrollIntoView(false)}});(function(){var l,k,m=a("form.wp-upload-form");if(!m.length){return}l=m.find('input[type="submit"]');k=m.find('input[type="file"]');function n(){l.prop("disabled",""===k.map(function(){return a(this).val()}).get().join(""))}n();k.on("change",n)})()});a(document).bind("wp_CloseOnEscape",function(c,b){if(typeof(b.cb)!="function"){return}if(typeof(b.condition)!="function"||b.condition()){b.cb()}return true})})(jQuery);