Ticket #26002: 26002.3.diff
| File 26002.3.diff, 3.3 KB (added by , 13 years ago) |
|---|
-
inline-edit-tax.js
1 /* global inlineEditL10n, ajaxurl */ 1 2 2 3 (function($) { 3 inlineEditTax = {4 var inlineEditTax = { 4 5 5 6 init : function() { 6 7 var t = this, row = $('#inline-edit'); … … 14 15 }); 15 16 16 17 // prepare the edit row 17 row.keyup(function(e) { if(e.which == 27) return inlineEditTax.revert(); }); 18 row.keyup(function(e) { 19 if(e.which === 27) { 20 return inlineEditTax.revert(); 21 } 22 }); 18 23 19 $('a.cancel', row).click(function() { return inlineEditTax.revert(); }); 20 $('a.save', row).click(function() { return inlineEditTax.save(this); }); 21 $('input, select', row).keydown(function(e) { if(e.which == 13) return inlineEditTax.save(this); }); 24 $('a.cancel', row).click(function() { 25 return inlineEditTax.revert(); 26 }); 27 $('a.save', row).click(function() { 28 return inlineEditTax.save(this); 29 }); 30 $('input, select', row).keydown(function(e) { 31 if(e.which === 13) { 32 return inlineEditTax.save(this); 33 } 34 }); 22 35 23 $('#posts-filter input[type="submit"]').mousedown(function( e){36 $('#posts-filter input[type="submit"]').mousedown(function(){ 24 37 t.revert(); 25 38 }); 26 39 }, 27 40 28 41 toggle : function(el) { 29 42 var t = this; 30 $(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el);43 $(t.what+t.getId(el)).css('display') === 'none' ? t.revert() : t.edit(el); 31 44 }, 32 45 33 46 edit : function(id) { 34 var t = this, editRow ;47 var t = this, editRow, rowData; 35 48 t.revert(); 36 49 37 if ( typeof(id) == 'object' )50 if ( typeof(id) === 'object' ) { 38 51 id = t.getId(id); 52 } 39 53 40 54 editRow = $('#inline-edit').clone(true), rowData = $('#inline_'+id); 41 55 $('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length); 42 56 43 if ( $(t.what+id).hasClass('alternate') ) 57 if ( $(t.what+id).hasClass('alternate') ) { 44 58 $(editRow).addClass('alternate'); 59 } 45 60 46 61 $(t.what+id).hide().after(editRow); 47 62 … … 57 72 save : function(id) { 58 73 var params, fields, tax = $('input[name="taxonomy"]').val() || ''; 59 74 60 if( typeof(id) == 'object' )75 if( typeof(id) === 'object' ) { 61 76 id = this.getId(id); 77 } 62 78 63 79 $('table.widefat .spinner').show(); 64 80 … … 79 95 $('table.widefat .spinner').hide(); 80 96 81 97 if (r) { 82 if ( -1 != r.indexOf('<tr') ) {98 if ( -1 !== r.indexOf('<tr') ) { 83 99 $(inlineEditTax.what+id).remove(); 84 100 new_id = $(r).attr('id'); 85 101 86 102 $('#edit-'+id).before(r).remove(); 87 103 row = new_id ? $('#'+new_id) : $(inlineEditTax.what+id); 88 104 row.hide().fadeIn(); 89 } else 105 } else { 90 106 $('#edit-'+id+' .inline-edit-save .error').html(r).show(); 91 } else 107 } 108 } else { 92 109 $('#edit-'+id+' .inline-edit-save .error').html(inlineEditL10n.error).show(); 110 } 93 111 94 if ($(row).prev('tr').hasClass('alternate')) 112 if ($(row).prev('tr').hasClass('alternate')) { 95 113 $(row).removeClass('alternate'); 114 } 96 115 } 97 116 ); 98 117 return false; … … 112 131 }, 113 132 114 133 getId : function(o) { 115 var id = o.tagName == 'TR' ? o.id : $(o).parents('tr').attr('id'), parts = id.split('-');134 var id = o.tagName === 'TR' ? o.id : $(o).parents('tr').attr('id'), parts = id.split('-'); 116 135 return parts[parts.length - 1]; 117 136 } 118 137 };