6 var t = this, row = $('#inline-edit');
8 t.type = $('#the-list').attr('class').substr(5);
9 t.what = '#'+t.type+'-';
11 $('.editinline').live('click', function(){
12 inlineEditTax.edit(this);
16 // prepare the edit row
17 row.keyup(function(e) { if(e.which == 27) return inlineEditTax.revert(); });
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); });
23 $('#posts-filter input[type="submit"]').mousedown(function(e){
28 toggle : function(el) {
30 $(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el);
34 var t = this, editRow;
37 if ( typeof(id) == 'object' )
40 editRow = $('#inline-edit').clone(true), rowData = $('#inline_'+id);
41 $('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length);
43 if ( $(t.what+id).hasClass('alternate') )
44 $(editRow).addClass('alternate');
46 $(t.what+id).hide().after(editRow);
48 $(':input[name="name"]', editRow).val( $('.name', rowData).text() );
49 $(':input[name="slug"]', editRow).val( $('.slug', rowData).text() );
51 $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show();
52 $('.ptitle', editRow).eq(0).focus();
58 var params, fields, tax = $('input[name="taxonomy"]').val() || '';
60 if( typeof(id) == 'object' )
63 $('table.widefat .inline-edit-save .waiting').show();
66 action: 'inline-save-tax',
72 fields = $('#edit-'+id+' :input').serialize();
73 params = fields + '&' + $.param(params);
76 $.post( ajaxurl, params,
79 $('table.widefat .inline-edit-save .waiting').hide();
82 if ( -1 != r.indexOf('<tr') ) {
83 $(inlineEditTax.what+id).remove();
84 new_id = $(r).attr('id');
86 $('#edit-'+id).before(r).remove();
87 row = new_id ? $('#'+new_id) : $(inlineEditTax.what+id);
90 $('#edit-'+id+' .inline-edit-save .error').html(r).show();
92 $('#edit-'+id+' .inline-edit-save .error').html(inlineEditL10n.error).show();
99 var id = $('table.widefat tr.inline-editor').attr('id');
102 $('table.widefat .inline-edit-save .waiting').hide();
104 id = id.substr( id.lastIndexOf('-') + 1 );
105 $(this.what+id).show();
111 getId : function(o) {
112 var id = o.tagName == 'TR' ? o.id : $(o).parents('tr').attr('id'), parts = id.split('-');
113 return parts[parts.length - 1];
117 $(document).ready(function(){inlineEditTax.init();});