6 var t = this, row = $('#inline-edit');
8 t.type = $('#the-list').attr('className').substr(5);
9 t.what = '#'+t.type+'-';
11 // get all editable rows
12 t.rows = $('tr.iedit');
14 // prepare the edit row
15 row.keyup(function(e) { if(e.which == 27) return inlineEditTax.revert(); });
17 $('a.cancel', row).click(function() { return inlineEditTax.revert(); });
18 $('a.save', row).click(function() { return inlineEditTax.save(this); });
19 $('input, select', row).keydown(function(e) { if(e.which == 13) return inlineEditTax.save(this); });
24 $('#posts-filter input[type="submit"]').click(function(e){
25 if ( $('form#posts-filter tr.inline-editor').length > 0 )
30 toggle : function(el) {
32 $(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el);
35 addEvents : function(r) {
37 $(this).find('a.editinline').click(function() { inlineEditTax.edit(this); return false; });
42 var t = this, editRow;
45 if ( typeof(id) == 'object' )
48 editRow = $('#inline-edit').clone(true), rowData = $('#inline_'+id);
49 $('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length);
51 if ( $(t.what+id).hasClass('alternate') )
52 $(editRow).addClass('alternate');
54 $(t.what+id).hide().after(editRow);
56 $(':input[name="name"]', editRow).val( $('.name', rowData).text() );
57 $(':input[name="slug"]', editRow).val( $('.slug', rowData).text() );
59 $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show();
60 $('.ptitle', editRow).eq(0).focus();
66 var params, fields, tax = $('input[name="taxonomy"]').val() || '';
68 if( typeof(id) == 'object' )
71 $('table.widefat .inline-edit-save .waiting').show();
74 action: 'inline-save-tax',
80 fields = $('#edit-'+id+' :input').fieldSerialize();
81 params = fields + '&' + $.param(params);
84 $.post('admin-ajax.php', params,
87 $('table.widefat .inline-edit-save .waiting').hide();
90 if ( -1 != r.indexOf('<tr') ) {
91 $(inlineEditTax.what+id).remove();
92 new_id = $(r).attr('id');
94 $('#edit-'+id).before(r).remove();
95 row = new_id ? $('#'+new_id) : $(inlineEditTax.what+id);
98 inlineEditTax.addEvents(row);
101 $('#edit-'+id+' .inline-edit-save .error').html(r).show();
103 $('#edit-'+id+' .inline-edit-save .error').html(inlineEditL10n.error).show();
109 revert : function() {
110 var id = $('table.widefat tr.inline-editor').attr('id');
113 $('table.widefat .inline-edit-save .waiting').hide();
115 id = id.substr( id.lastIndexOf('-') + 1 );
116 $(this.what+id).show();
122 getId : function(o) {
123 var id = o.tagName == 'TR' ? o.id : $(o).parents('tr').attr('id'), parts = id.split('-');
124 return parts[parts.length - 1];
128 $(document).ready(function(){inlineEditTax.init();});