JSHint fixes for inline-edit-tax.js.

props dougwollison.
fixes #26002.

Built from https://develop.svn.wordpress.org/trunk@26265


git-svn-id: http://core.svn.wordpress.org/trunk@26171 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2013-11-19 04:35:09 +00:00
parent 6212b30ddd
commit 56f5b8b4ec
2 changed files with 37 additions and 16 deletions

View File

@ -1,4 +1,6 @@
/* global inlineEditL10n, ajaxurl */
var inlineEditTax;
(function($) {
inlineEditTax = {
@ -14,34 +16,49 @@ inlineEditTax = {
});
// prepare the edit row
row.keyup(function(e) { if(e.which == 27) return inlineEditTax.revert(); });
row.keyup( function( e ) {
if ( e.which === 27 ) {
return inlineEditTax.revert();
}
});
$('a.cancel', row).click(function() { return inlineEditTax.revert(); });
$('a.save', row).click(function() { return inlineEditTax.save(this); });
$('input, select', row).keydown(function(e) { if(e.which == 13) return inlineEditTax.save(this); });
$( 'a.cancel', row ).click( function() {
return inlineEditTax.revert();
});
$( 'a.save', row ).click( function() {
return inlineEditTax.save(this);
});
$( 'input, select', row ).keydown( function( e ) {
if ( e.which === 13 ) {
return inlineEditTax.save( this );
}
});
$('#posts-filter input[type="submit"]').mousedown(function(e){
$( '#posts-filter input[type="submit"]' ).mousedown( function() {
t.revert();
});
},
toggle : function(el) {
var t = this;
$(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el);
$(t.what+t.getId(el)).css('display') === 'none' ? t.revert() : t.edit(el);
},
edit : function(id) {
var t = this, editRow;
var editRow, rowData,
t = this;
t.revert();
if ( typeof(id) == 'object' )
if ( typeof(id) === 'object' ) {
id = t.getId(id);
}
editRow = $('#inline-edit').clone(true), rowData = $('#inline_'+id);
$('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length);
if ( $(t.what+id).hasClass('alternate') )
if ( $( t.what + id ).hasClass( 'alternate' ) ) {
$(editRow).addClass('alternate');
}
$(t.what+id).hide().after(editRow);
@ -57,8 +74,9 @@ inlineEditTax = {
save : function(id) {
var params, fields, tax = $('input[name="taxonomy"]').val() || '';
if( typeof(id) == 'object' )
if( typeof(id) === 'object' ) {
id = this.getId(id);
}
$('table.widefat .spinner').show();
@ -79,20 +97,23 @@ inlineEditTax = {
$('table.widefat .spinner').hide();
if (r) {
if ( -1 != r.indexOf('<tr') ) {
if ( -1 !== r.indexOf( '<tr' ) ) {
$(inlineEditTax.what+id).remove();
new_id = $(r).attr('id');
$('#edit-'+id).before(r).remove();
row = new_id ? $('#'+new_id) : $(inlineEditTax.what+id);
row.hide().fadeIn();
} else
} else {
$('#edit-'+id+' .inline-edit-save .error').html(r).show();
} else
}
} else {
$('#edit-'+id+' .inline-edit-save .error').html(inlineEditL10n.error).show();
}
if ($(row).prev('tr').hasClass('alternate'))
if ( $( row ).prev( 'tr' ).hasClass( 'alternate' ) ) {
$(row).removeClass('alternate');
}
}
);
return false;
@ -112,7 +133,7 @@ inlineEditTax = {
},
getId : function(o) {
var id = o.tagName == 'TR' ? o.id : $(o).parents('tr').attr('id'), parts = id.split('-');
var id = o.tagName === 'TR' ? o.id : $(o).parents('tr').attr('id'), parts = id.split('-');
return parts[parts.length - 1];
}
};

View File

@ -1 +1 @@
!function(a){inlineEditTax={init:function(){var b=this,c=a("#inline-edit");b.type=a("#the-list").attr("data-wp-lists").substr(5),b.what="#"+b.type+"-",a("#the-list").on("click","a.editinline",function(){return inlineEditTax.edit(this),!1}),c.keyup(function(a){return 27==a.which?inlineEditTax.revert():void 0}),a("a.cancel",c).click(function(){return inlineEditTax.revert()}),a("a.save",c).click(function(){return inlineEditTax.save(this)}),a("input, select",c).keydown(function(a){return 13==a.which?inlineEditTax.save(this):void 0}),a('#posts-filter input[type="submit"]').mousedown(function(){b.revert()})},toggle:function(b){var c=this;"none"==a(c.what+c.getId(b)).css("display")?c.revert():c.edit(b)},edit:function(b){var c,d=this;return d.revert(),"object"==typeof b&&(b=d.getId(b)),c=a("#inline-edit").clone(!0),rowData=a("#inline_"+b),a("td",c).attr("colspan",a(".widefat:first thead th:visible").length),a(d.what+b).hasClass("alternate")&&a(c).addClass("alternate"),a(d.what+b).hide().after(c),a(':input[name="name"]',c).val(a(".name",rowData).text()),a(':input[name="slug"]',c).val(a(".slug",rowData).text()),a(c).attr("id","edit-"+b).addClass("inline-editor").show(),a(".ptitle",c).eq(0).focus(),!1},save:function(b){var c,d,e=a('input[name="taxonomy"]').val()||"";return"object"==typeof b&&(b=this.getId(b)),a("table.widefat .spinner").show(),c={action:"inline-save-tax",tax_type:this.type,tax_ID:b,taxonomy:e},d=a("#edit-"+b).find(":input").serialize(),c=d+"&"+a.param(c),a.post(ajaxurl,c,function(c){var d,e;a("table.widefat .spinner").hide(),c?-1!=c.indexOf("<tr")?(a(inlineEditTax.what+b).remove(),e=a(c).attr("id"),a("#edit-"+b).before(c).remove(),d=e?a("#"+e):a(inlineEditTax.what+b),d.hide().fadeIn()):a("#edit-"+b+" .inline-edit-save .error").html(c).show():a("#edit-"+b+" .inline-edit-save .error").html(inlineEditL10n.error).show(),a(d).prev("tr").hasClass("alternate")&&a(d).removeClass("alternate")}),!1},revert:function(){var b=a("table.widefat tr.inline-editor").attr("id");return b&&(a("table.widefat .spinner").hide(),a("#"+b).remove(),b=b.substr(b.lastIndexOf("-")+1),a(this.what+b).show()),!1},getId:function(b){var c="TR"==b.tagName?b.id:a(b).parents("tr").attr("id"),d=c.split("-");return d[d.length-1]}},a(document).ready(function(){inlineEditTax.init()})}(jQuery);
var inlineEditTax;!function(a){inlineEditTax={init:function(){var b=this,c=a("#inline-edit");b.type=a("#the-list").attr("data-wp-lists").substr(5),b.what="#"+b.type+"-",a("#the-list").on("click","a.editinline",function(){return inlineEditTax.edit(this),!1}),c.keyup(function(a){return 27===a.which?inlineEditTax.revert():void 0}),a("a.cancel",c).click(function(){return inlineEditTax.revert()}),a("a.save",c).click(function(){return inlineEditTax.save(this)}),a("input, select",c).keydown(function(a){return 13===a.which?inlineEditTax.save(this):void 0}),a('#posts-filter input[type="submit"]').mousedown(function(){b.revert()})},toggle:function(b){var c=this;"none"===a(c.what+c.getId(b)).css("display")?c.revert():c.edit(b)},edit:function(b){var c,d,e=this;return e.revert(),"object"==typeof b&&(b=e.getId(b)),c=a("#inline-edit").clone(!0),d=a("#inline_"+b),a("td",c).attr("colspan",a(".widefat:first thead th:visible").length),a(e.what+b).hasClass("alternate")&&a(c).addClass("alternate"),a(e.what+b).hide().after(c),a(':input[name="name"]',c).val(a(".name",d).text()),a(':input[name="slug"]',c).val(a(".slug",d).text()),a(c).attr("id","edit-"+b).addClass("inline-editor").show(),a(".ptitle",c).eq(0).focus(),!1},save:function(b){var c,d,e=a('input[name="taxonomy"]').val()||"";return"object"==typeof b&&(b=this.getId(b)),a("table.widefat .spinner").show(),c={action:"inline-save-tax",tax_type:this.type,tax_ID:b,taxonomy:e},d=a("#edit-"+b).find(":input").serialize(),c=d+"&"+a.param(c),a.post(ajaxurl,c,function(c){var d,e;a("table.widefat .spinner").hide(),c?-1!==c.indexOf("<tr")?(a(inlineEditTax.what+b).remove(),e=a(c).attr("id"),a("#edit-"+b).before(c).remove(),d=e?a("#"+e):a(inlineEditTax.what+b),d.hide().fadeIn()):a("#edit-"+b+" .inline-edit-save .error").html(c).show():a("#edit-"+b+" .inline-edit-save .error").html(inlineEditL10n.error).show(),a(d).prev("tr").hasClass("alternate")&&a(d).removeClass("alternate")}),!1},revert:function(){var b=a("table.widefat tr.inline-editor").attr("id");return b&&(a("table.widefat .spinner").hide(),a("#"+b).remove(),b=b.substr(b.lastIndexOf("-")+1),a(this.what+b).show()),!1},getId:function(b){var c="TR"===b.tagName?b.id:a(b).parents("tr").attr("id"),d=c.split("-");return d[d.length-1]}},a(document).ready(function(){inlineEditTax.init()})}(jQuery);