From 72efe7c1ec52c6b61de5c1d9394fc6a3dd442665 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Tue, 12 Nov 2013 23:56:09 +0000 Subject: [PATCH] Free common.js of JSHint errors. props jorbin. fixes #25912. Built from https://develop.svn.wordpress.org/trunk@26112 git-svn-id: http://core.svn.wordpress.org/trunk@26024 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/js/common.js | 31 ++++++++++++++++++++----------- wp-admin/js/common.min.js | 2 +- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/wp-admin/js/common.js b/wp-admin/js/common.js index 822af979da..fd1c8ddcdf 100644 --- a/wp-admin/js/common.js +++ b/wp-admin/js/common.js @@ -1,3 +1,4 @@ +/* global setUserSetting, ajaxurl, commonL10n, alert, confirm, toggleWithKeyboard, pagenow */ var showNotice, adminMenu, columns, validateForm, screenMeta; (function($){ // Removed in 3.3. @@ -65,13 +66,19 @@ columns = { n = parseInt( $t.attr('colspan'), 10 ) + diff; $t.attr('colspan', n.toString()); } -} +}; $(document).ready(function(){columns.init();}); validateForm = function( form ) { - return !$( form ).find('.form-required').filter( function() { return $('input:visible', this).val() == ''; } ).addClass( 'form-invalid' ).find('input:visible').change( function() { $(this).closest('.form-invalid').removeClass( 'form-invalid' ); } ).size(); -} + return !$( form ) + .find( '.form-required' ) + .filter( function() { return $( 'input:visible', this ).val() === ''; } ) + .addClass( 'form-invalid' ) + .find( 'input:visible' ) + .change( function() { $( this ).closest( '.form-invalid' ).removeClass( 'form-invalid' ); } ) + .size(); +}; // stub for doing better warnings showNotice = { @@ -160,15 +167,18 @@ $('.contextual-help-tabs').delegate('a', 'click focus', function(e) { }); $(document).ready( function() { - var lastClicked = false, checks, first, last, checked, sliced, menu = $('#adminmenu'), mobileEvent, - pageInput = $('input.current-page'), currentPage = pageInput.val(); + var checks, first, last, checked, sliced, mobileEvent, transitionTimeout, focusedRowActions, + lastClicked = false, + menu = $('#adminmenu'), + pageInput = $('input.current-page'), + currentPage = pageInput.val(); // when the menu is folded, make the fly-out submenu header clickable menu.on('click.wp-submenu-head', '.wp-submenu-head', function(e){ $(e.target).parent().siblings('a').get(0).click(); }); - $('#collapse-menu').on('click.collapse-menu', function(e){ + $('#collapse-menu').on('click.collapse-menu', function() { var body = $( document.body ), respWidth; // reset any compensation for submenus near the bottom of the screen @@ -226,7 +236,7 @@ $(document).ready( function() { } menu.find('li.wp-has-submenu').hoverIntent({ - over: function(e){ + over: function() { var b, h, o, f, m = $(this).find('.wp-submenu'), menutop, wintop, maxtop, top = parseInt( m.css('top'), 10 ); if ( isNaN(top) || top > -5 ) // meaning the submenu is visible @@ -300,7 +310,7 @@ $(document).ready( function() { // toggle "check all" checkboxes var unchecked = $(this).closest('tbody').find(':checkbox').filter(':visible').not(':checked'); $(this).closest('table').children('thead, tfoot').find(':checkbox').prop('checked', function() { - return ( 0 == unchecked.length ); + return ( 0 === unchecked.length ); }); return true; @@ -335,7 +345,6 @@ $(document).ready( function() { }); // Show row actions on keyboard focus of its parent container element or any other elements contained within - var transitionTimeout, focusedRowActions; $( 'td.post-title, td.title, td.comment, .bookmarks td.column-name, td.blogname, td.username, .dashboard-comment-wrap' ).focusin(function(){ clearTimeout( transitionTimeout ); focusedRowActions = $(this).find( '.row-actions' ); @@ -396,13 +405,13 @@ $(document).ready( function() { e.preventDefault(); }); - $('#newcontent').bind('blur.wpevent_InsertTab', function(e) { + $('#newcontent').bind('blur.wpevent_InsertTab', function() { if ( this.lastKey && 9 == this.lastKey ) this.focus(); }); if ( pageInput.length ) { - pageInput.closest('form').submit( function(e){ + pageInput.closest('form').submit( function() { // Reset paging var for new filters/searches but not for bulk actions. See #17685. if ( $('select[name="action"]').val() == -1 && $('select[name="action2"]').val() == -1 && pageInput.val() == currentPage ) diff --git a/wp-admin/js/common.min.js b/wp-admin/js/common.min.js index 430e0c2ddf..1795f3f98d 100644 --- a/wp-admin/js/common.min.js +++ b/wp-admin/js/common.min.js @@ -1 +1 @@ -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 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).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 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()))}},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 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-toggle a"),this.page=a("#wpcontent"),this.toggles.click(this.toggleEvent)},toggleEvent:function(b){var c=a(this.href.replace(/.+#/,"#"));b.preventDefault(),c.length&&(c.is(":visible")?screenMeta.close(c,a(this)):screenMeta.open(c,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",!0)})},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()})}},a(".contextual-help-tabs").delegate("a","click focus",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(),c.addClass("active").show(),void 0)}),a(document).ready(function(){var b,c,d,e,f,g,h=!1,i=a("#adminmenu"),j=a("input.current-page"),k=j.val();i.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 b,c=a(document.body);a("#adminmenu div.wp-submenu").css("margin-top",""),b=navigator.userAgent.indexOf("AppleWebKit/")>-1?a(window).width():window.innerWidth,b&&900>b?c.hasClass("auto-fold")?(c.removeClass("auto-fold").removeClass("folded"),setUserSetting("unfold",1),setUserSetting("mfold","o")):(c.addClass("auto-fold"),setUserSetting("unfold",0)):c.hasClass("folded")?(c.removeClass("folded"),setUserSetting("mfold","o")):(c.addClass("folded"),setUserSetting("mfold","f"))}),("ontouchstart"in window||/IEMobile\/[1-9]/.test(navigator.userAgent))&&(g=/Mobile\/.+Safari/.test(navigator.userAgent)?"touchstart":"click",a(document.body).on(g+".wp-mobile-hover",function(b){a(b.target).closest("#adminmenu").length||i.find("li.wp-has-submenu.opensub").removeClass("opensub")}),i.find("a.wp-has-submenu").on(g+".wp-mobile-hover",function(b){var c=a(this),d=c.parent();d.hasClass("opensub")||d.hasClass("wp-menu-open")&&!(d.width()<40)||(b.preventDefault(),i.find("li.opensub").removeClass("opensub"),d.addClass("opensub"))})),i.find("li.wp-has-submenu").hoverIntent({over:function(){var b,c,d,e,f,g,h,j=a(this).find(".wp-submenu"),k=parseInt(j.css("top"),10);isNaN(k)||k>-5||(f=a(this).offset().top,g=a(window).scrollTop(),h=f-g-30,b=f+j.height()+1,c=a("#wpwrap").height(),d=60+b-c,e=a(window).height()+g-15,b-d>e&&(d=b-e),d>h&&(d=h),d>1?j.css("margin-top","-"+d+"px"):j.css("margin-top",""),i.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}),i.on("focus.adminmenu",".wp-submenu a",function(b){a(b.target).closest("li.menu-top").addClass("opensub")}).on("blur.adminmenu",".wp-submenu a",function(b){a(b.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(g){if("undefined"==g.shiftKey)return!0;if(g.shiftKey){if(!h)return!0;b=a(h).closest("form").find(":checkbox"),c=b.index(h),d=b.index(this),e=a(this).prop("checked"),c>0&&d>0&&c!=d&&(f=d>c?b.slice(c,d):b.slice(d,c),f.prop("checked",function(){return a(this).closest("tr").is(":visible")?e:!1}))}h=this;var i=a(this).closest("tbody").find(":checkbox").filter(":visible").not(":checked");return a(this).closest("table").children("thead, tfoot").find(":checkbox").prop("checked",function(){return 0==i.length}),!0}),a("thead, tfoot").find(".check-column :checkbox").click(function(b){var c=a(this).prop("checked"),d="undefined"==typeof toggleWithKeyboard?!1:toggleWithKeyboard,e=b.shiftKey||d;a(this).closest("table").children("tbody").filter(":visible").children().children(".check-column").find(":checkbox").prop("checked",function(){return a(this).is(":hidden")?!1:e?a(this).prop("checked"):c?!0:!1}),a(this).closest("table").children("thead, tfoot").filter(":visible").children().children(".check-column").find(":checkbox").prop("checked",function(){return e?!1:c?!0:!1})});var l,m;a("td.post-title, td.title, td.comment, .bookmarks td.column-name, td.blogname, td.username, .dashboard-comment-wrap").focusin(function(){clearTimeout(l),m=a(this).find(".row-actions"),m.addClass("visible")}).focusout(function(){l=setTimeout(function(){m.removeClass("visible")},30)}),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 a(h).data("tab-out",!0),void 0;if(!(9!=b.keyCode||b.ctrlKey||b.altKey||b.shiftKey)){if(a(h).data("tab-out"))return a(h).data("tab-out",!1),void 0;c=h.selectionStart,d=h.selectionEnd,e=h.value;try{this.lastKey=9}catch(i){}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()}}),a("#newcontent").bind("blur.wpevent_InsertTab",function(){this.lastKey&&9==this.lastKey&&this.focus()}),j.length&&j.closest("form").submit(function(){-1==a('select[name="action"]').val()&&-1==a('select[name="action2"]').val()&&j.val()==k&&j.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))}()}),a(document).bind("wp_CloseOnEscape",function(a,b){return"function"==typeof b.cb?(("function"!=typeof b.condition||b.condition())&&b.cb(),!0):void 0})}(jQuery); \ No newline at end of file +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 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).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 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()))}},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 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-toggle a"),this.page=a("#wpcontent"),this.toggles.click(this.toggleEvent)},toggleEvent:function(b){var c=a(this.href.replace(/.+#/,"#"));b.preventDefault(),c.length&&(c.is(":visible")?screenMeta.close(c,a(this)):screenMeta.open(c,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",!0)})},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()})}},a(".contextual-help-tabs").delegate("a","click focus",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(),c.addClass("active").show(),void 0)}),a(document).ready(function(){var b,c,d,e,f,g,h,i,j=!1,k=a("#adminmenu"),l=a("input.current-page"),m=l.val();k.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 b,c=a(document.body);a("#adminmenu div.wp-submenu").css("margin-top",""),b=navigator.userAgent.indexOf("AppleWebKit/")>-1?a(window).width():window.innerWidth,b&&900>b?c.hasClass("auto-fold")?(c.removeClass("auto-fold").removeClass("folded"),setUserSetting("unfold",1),setUserSetting("mfold","o")):(c.addClass("auto-fold"),setUserSetting("unfold",0)):c.hasClass("folded")?(c.removeClass("folded"),setUserSetting("mfold","o")):(c.addClass("folded"),setUserSetting("mfold","f"))}),("ontouchstart"in window||/IEMobile\/[1-9]/.test(navigator.userAgent))&&(g=/Mobile\/.+Safari/.test(navigator.userAgent)?"touchstart":"click",a(document.body).on(g+".wp-mobile-hover",function(b){a(b.target).closest("#adminmenu").length||k.find("li.wp-has-submenu.opensub").removeClass("opensub")}),k.find("a.wp-has-submenu").on(g+".wp-mobile-hover",function(b){var c=a(this),d=c.parent();d.hasClass("opensub")||d.hasClass("wp-menu-open")&&!(d.width()<40)||(b.preventDefault(),k.find("li.opensub").removeClass("opensub"),d.addClass("opensub"))})),k.find("li.wp-has-submenu").hoverIntent({over:function(){var b,c,d,e,f,g,h,i=a(this).find(".wp-submenu"),j=parseInt(i.css("top"),10);isNaN(j)||j>-5||(f=a(this).offset().top,g=a(window).scrollTop(),h=f-g-30,b=f+i.height()+1,c=a("#wpwrap").height(),d=60+b-c,e=a(window).height()+g-15,b-d>e&&(d=b-e),d>h&&(d=h),d>1?i.css("margin-top","-"+d+"px"):i.css("margin-top",""),k.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}),k.on("focus.adminmenu",".wp-submenu a",function(b){a(b.target).closest("li.menu-top").addClass("opensub")}).on("blur.adminmenu",".wp-submenu a",function(b){a(b.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(g){if("undefined"==g.shiftKey)return!0;if(g.shiftKey){if(!j)return!0;b=a(j).closest("form").find(":checkbox"),c=b.index(j),d=b.index(this),e=a(this).prop("checked"),c>0&&d>0&&c!=d&&(f=d>c?b.slice(c,d):b.slice(d,c),f.prop("checked",function(){return a(this).closest("tr").is(":visible")?e:!1}))}j=this;var h=a(this).closest("tbody").find(":checkbox").filter(":visible").not(":checked");return a(this).closest("table").children("thead, tfoot").find(":checkbox").prop("checked",function(){return 0===h.length}),!0}),a("thead, tfoot").find(".check-column :checkbox").click(function(b){var c=a(this).prop("checked"),d="undefined"==typeof toggleWithKeyboard?!1:toggleWithKeyboard,e=b.shiftKey||d;a(this).closest("table").children("tbody").filter(":visible").children().children(".check-column").find(":checkbox").prop("checked",function(){return a(this).is(":hidden")?!1:e?a(this).prop("checked"):c?!0:!1}),a(this).closest("table").children("thead, tfoot").filter(":visible").children().children(".check-column").find(":checkbox").prop("checked",function(){return e?!1:c?!0:!1})}),a("td.post-title, td.title, td.comment, .bookmarks td.column-name, td.blogname, td.username, .dashboard-comment-wrap").focusin(function(){clearTimeout(h),i=a(this).find(".row-actions"),i.addClass("visible")}).focusout(function(){h=setTimeout(function(){i.removeClass("visible")},30)}),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 a(h).data("tab-out",!0),void 0;if(!(9!=b.keyCode||b.ctrlKey||b.altKey||b.shiftKey)){if(a(h).data("tab-out"))return a(h).data("tab-out",!1),void 0;c=h.selectionStart,d=h.selectionEnd,e=h.value;try{this.lastKey=9}catch(i){}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()}}),a("#newcontent").bind("blur.wpevent_InsertTab",function(){this.lastKey&&9==this.lastKey&&this.focus()}),l.length&&l.closest("form").submit(function(){-1==a('select[name="action"]').val()&&-1==a('select[name="action2"]').val()&&l.val()==m&&l.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))}()}),a(document).bind("wp_CloseOnEscape",function(a,b){return"function"==typeof b.cb?(("function"!=typeof b.condition||b.condition())&&b.cb(),!0):void 0})}(jQuery); \ No newline at end of file