6 var t = this, row = $('#inline-edit');
8 t.type = $('#the-list').attr('className').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"]').click(function(e){
24 if ( $('form#posts-filter tr.inline-editor').length > 0 )
29 toggle : function(el) {
31 $(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el);
35 var t = this, editRow;
38 if ( typeof(id) == 'object' )
41 editRow = $('#inline-edit').clone(true), rowData = $('#inline_'+id);
42 $('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length);
44 if ( $(t.what+id).hasClass('alternate') )
45 $(editRow).addClass('alternate');
47 $(t.what+id).hide().after(editRow);
49 $(':input[name="name"]', editRow).val( $('.name', rowData).text() );
50 $(':input[name="slug"]', editRow).val( $('.slug', rowData).text() );
52 $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show();
53 $('.ptitle', editRow).eq(0).focus();
59 var params, fields, tax = $('input[name="taxonomy"]').val() || '';
61 if( typeof(id) == 'object' )
64 $('table.widefat .inline-edit-save .waiting').show();
67 action: 'inline-save-tax',
73 fields = $('#edit-'+id+' :input').serialize();
74 params = fields + '&' + $.param(params);
77 $.post('admin-ajax.php', params,
80 $('table.widefat .inline-edit-save .waiting').hide();
83 if ( -1 != r.indexOf('<tr') ) {
84 $(inlineEditTax.what+id).remove();
85 new_id = $(r).attr('id');
87 $('#edit-'+id).before(r).remove();
88 row = new_id ? $('#'+new_id) : $(inlineEditTax.what+id);
91 $('#edit-'+id+' .inline-edit-save .error').html(r).show();
93 $('#edit-'+id+' .inline-edit-save .error').html(inlineEditL10n.error).show();
100 var id = $('table.widefat tr.inline-editor').attr('id');
103 $('table.widefat .inline-edit-save .waiting').hide();
105 id = id.substr( id.lastIndexOf('-') + 1 );
106 $(this.what+id).show();
112 getId : function(o) {
113 var id = o.tagName == 'TR' ? o.id : $(o).parents('tr').attr('id'), parts = id.split('-');
114 return parts[parts.length - 1];
118 $(document).ready(function(){inlineEditTax.init();});