X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/11be15bd505d66a91e2c80062190b13e315a04a9..b22765f41bf0b2021b9beb9120ee0ac91fa89292:/wp-admin/js/inline-edit-tax.js diff --git a/wp-admin/js/inline-edit-tax.js b/wp-admin/js/inline-edit-tax.js index 6d5293ac..3bbf4fb7 100644 --- a/wp-admin/js/inline-edit-tax.js +++ b/wp-admin/js/inline-edit-tax.js @@ -1,5 +1,8 @@ +/* global inlineEditL10n, ajaxurl */ +window.wp = window.wp || {}; -(function($) { +var inlineEditTax; +( function( $, wp ) { inlineEditTax = { init : function() { @@ -14,39 +17,57 @@ 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); }); + $( '.cancel', row ).click( function() { + return inlineEditTax.revert(); + }); + $( '.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, val, + 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); + $( 'td', editRow ).attr( 'colspan', $( 'th:visible, td:visible', '.wp-list-table.widefat:first thead' ).length ); - if ( $(t.what+id).hasClass('alternate') ) - $(editRow).addClass('alternate'); + $(t.what+id).hide().after(editRow).after(''); - $(t.what+id).hide().after(editRow); + val = $('.name', rowData); + val.find( 'img' ).replaceWith( function() { return this.alt; } ); + val = val.text(); + $(':input[name="name"]', editRow).val( val ); - $(':input[name="name"]', editRow).val( $('.name', rowData).text() ); - $(':input[name="slug"]', editRow).val( $('.slug', rowData).text() ); + val = $('.slug', rowData); + val.find( 'img' ).replaceWith( function() { return this.alt; } ); + val = val.text(); + $(':input[name="slug"]', editRow).val( val ); $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show(); $('.ptitle', editRow).eq(0).focus(); @@ -57,10 +78,11 @@ 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(); + $( 'table.widefat .spinner' ).addClass( 'is-active' ); params = { action: 'inline-save-tax', @@ -69,29 +91,53 @@ inlineEditTax = { taxonomy: tax }; - fields = $('#edit-'+id+' :input').serialize(); + fields = $('#edit-'+id).find(':input').serialize(); params = fields + '&' + $.param(params); // make ajax request $.post( ajaxurl, params, function(r) { - var row, new_id; - $('table.widefat .spinner').hide(); + var row, new_id, option_value, + $errorSpan = $( '#edit-' + id + ' .inline-edit-save .error' ); + + $( 'table.widefat .spinner' ).removeClass( 'is-active' ); if (r) { - if ( -1 != r.indexOf('