Fix JSHint errors in tags.js.
props atimmer. fixes #26009. Built from https://develop.svn.wordpress.org/trunk@26198 git-svn-id: http://core.svn.wordpress.org/trunk@26106 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
14c473535b
commit
8daa128928
|
@ -1,6 +1,8 @@
|
||||||
|
/* global ajaxurl, wpAjax, tagsl10n, showNotice, validateForm */
|
||||||
|
|
||||||
jQuery(document).ready(function($) {
|
jQuery(document).ready(function($) {
|
||||||
|
|
||||||
$('#the-list').on('click', '.delete-tag', function(e){
|
$( '#the-list' ).on( 'click', '.delete-tag', function() {
|
||||||
var t = $(this), tr = t.parents('tr'), r = true, data;
|
var t = $(this), tr = t.parents('tr'), r = true, data;
|
||||||
if ( 'undefined' != showNotice )
|
if ( 'undefined' != showNotice )
|
||||||
r = showNotice.warn();
|
r = showNotice.warn();
|
||||||
|
@ -33,30 +35,32 @@ jQuery(document).ready(function($) {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$.post(ajaxurl, $('#addtag').serialize(), function(r){
|
$.post(ajaxurl, $('#addtag').serialize(), function(r){
|
||||||
|
var res, parent, term, indent, i;
|
||||||
|
|
||||||
$('#ajax-response').empty();
|
$('#ajax-response').empty();
|
||||||
var res = wpAjax.parseAjaxResponse(r, 'ajax-response');
|
res = wpAjax.parseAjaxResponse( r, 'ajax-response' );
|
||||||
if ( ! res || res.errors )
|
if ( ! res || res.errors )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var parent = form.find('select#parent').val();
|
parent = form.find( 'select#parent' ).val();
|
||||||
|
|
||||||
if ( parent > 0 && $('#tag-' + parent ).length > 0 ) // If the parent exists on this page, insert it below. Else insert it at the top of the list.
|
if ( parent > 0 && $('#tag-' + parent ).length > 0 ) // If the parent exists on this page, insert it below. Else insert it at the top of the list.
|
||||||
$('.tags #tag-' + parent).after( res.responses[0].supplemental['noparents'] ); // As the parent exists, Insert the version with - - - prefixed
|
$( '.tags #tag-' + parent ).after( res.responses[0].supplemental.noparents ); // As the parent exists, Insert the version with - - - prefixed
|
||||||
else
|
else
|
||||||
$('.tags').prepend( res.responses[0].supplemental['parents'] ); // As the parent is not visible, Insert the version with Parent - Child - ThisTerm
|
$( '.tags' ).prepend( res.responses[0].supplemental.parents ); // As the parent is not visible, Insert the version with Parent - Child - ThisTerm
|
||||||
|
|
||||||
$('.tags .no-items').remove();
|
$('.tags .no-items').remove();
|
||||||
|
|
||||||
if ( form.find('select#parent') ) {
|
if ( form.find('select#parent') ) {
|
||||||
// Parents field exists, Add new term to the list.
|
// Parents field exists, Add new term to the list.
|
||||||
var term = res.responses[1].supplemental;
|
term = res.responses[1].supplemental;
|
||||||
|
|
||||||
// Create an indent for the Parent field
|
// Create an indent for the Parent field
|
||||||
var indent = '';
|
indent = '';
|
||||||
for ( var i = 0; i < res.responses[1].position; i++ )
|
for ( i = 0; i < res.responses[1].position; i++ )
|
||||||
indent += ' ';
|
indent += ' ';
|
||||||
|
|
||||||
form.find('select#parent option:selected').after('<option value="' + term['term_id'] + '">' + indent + term['name'] + '</option>');
|
form.find( 'select#parent option:selected' ).after( '<option value="' + term.term_id + '">' + indent + term.name + '</option>' );
|
||||||
}
|
}
|
||||||
|
|
||||||
$('input[type="text"]:visible, textarea:visible', form).val('');
|
$('input[type="text"]:visible, textarea:visible', form).val('');
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
jQuery(document).ready(function(a){a("#the-list").on("click",".delete-tag",function(){var b,c=a(this),d=c.parents("tr"),e=!0;return"undefined"!=showNotice&&(e=showNotice.warn()),e&&(b=c.attr("href").replace(/[^?]*\?/,"").replace(/action=delete/,"action=delete-tag"),a.post(ajaxurl,b,function(c){"1"==c?(a("#ajax-response").empty(),d.fadeOut("normal",function(){d.remove()}),a('select#parent option[value="'+b.match(/tag_ID=(\d+)/)[1]+'"]').remove(),a("a.tag-link-"+b.match(/tag_ID=(\d+)/)[1]).remove()):"-1"==c?(a("#ajax-response").empty().append('<div class="error"><p>'+tagsl10n.noPerm+"</p></div>"),d.children().css("backgroundColor","")):(a("#ajax-response").empty().append('<div class="error"><p>'+tagsl10n.broken+"</p></div>"),d.children().css("backgroundColor",""))}),d.children().css("backgroundColor","#f33")),!1}),a("#submit").click(function(){var b=a(this).parents("form");return validateForm(b)?(a.post(ajaxurl,a("#addtag").serialize(),function(c){a("#ajax-response").empty();var d=wpAjax.parseAjaxResponse(c,"ajax-response");if(d&&!d.errors){var e=b.find("select#parent").val();if(e>0&&a("#tag-"+e).length>0?a(".tags #tag-"+e).after(d.responses[0].supplemental.noparents):a(".tags").prepend(d.responses[0].supplemental.parents),a(".tags .no-items").remove(),b.find("select#parent")){for(var f=d.responses[1].supplemental,g="",h=0;h<d.responses[1].position;h++)g+=" ";b.find("select#parent option:selected").after('<option value="'+f.term_id+'">'+g+f.name+"</option>")}a('input[type="text"]:visible, textarea:visible',b).val("")}}),!1):!1})});
|
jQuery(document).ready(function(a){a("#the-list").on("click",".delete-tag",function(){var b,c=a(this),d=c.parents("tr"),e=!0;return"undefined"!=showNotice&&(e=showNotice.warn()),e&&(b=c.attr("href").replace(/[^?]*\?/,"").replace(/action=delete/,"action=delete-tag"),a.post(ajaxurl,b,function(c){"1"==c?(a("#ajax-response").empty(),d.fadeOut("normal",function(){d.remove()}),a('select#parent option[value="'+b.match(/tag_ID=(\d+)/)[1]+'"]').remove(),a("a.tag-link-"+b.match(/tag_ID=(\d+)/)[1]).remove()):"-1"==c?(a("#ajax-response").empty().append('<div class="error"><p>'+tagsl10n.noPerm+"</p></div>"),d.children().css("backgroundColor","")):(a("#ajax-response").empty().append('<div class="error"><p>'+tagsl10n.broken+"</p></div>"),d.children().css("backgroundColor",""))}),d.children().css("backgroundColor","#f33")),!1}),a("#submit").click(function(){var b=a(this).parents("form");return validateForm(b)?(a.post(ajaxurl,a("#addtag").serialize(),function(c){var d,e,f,g,h;if(a("#ajax-response").empty(),d=wpAjax.parseAjaxResponse(c,"ajax-response"),d&&!d.errors){if(e=b.find("select#parent").val(),e>0&&a("#tag-"+e).length>0?a(".tags #tag-"+e).after(d.responses[0].supplemental.noparents):a(".tags").prepend(d.responses[0].supplemental.parents),a(".tags .no-items").remove(),b.find("select#parent")){for(f=d.responses[1].supplemental,g="",h=0;h<d.responses[1].position;h++)g+=" ";b.find("select#parent option:selected").after('<option value="'+f.term_id+'">'+g+f.name+"</option>")}a('input[type="text"]:visible, textarea:visible',b).val("")}}),!1):!1})});
|
Loading…
Reference in New Issue