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) {
33 $(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el);
36 addEvents : function(r) {
38 $(this).find('a.editinline').click(function() { inlineEditTax.edit(this); return false; });
39 $(this).find('.hide-if-no-js').removeClass('hide-if-no-js');
47 if ( typeof(id) == 'object' )
50 var editRow = $('#inline-edit').clone(true), rowData = $('#inline_'+id);
51 $('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length);
53 if ( $(t.what+id).hasClass('alternate') )
54 $(editRow).addClass('alternate');
56 $(t.what+id).hide().after(editRow);
58 $(':input[name="name"]', editRow).val( $('.name', rowData).text() );
59 $(':input[name="slug"]', editRow).val( $('.slug', rowData).text() );
62 var cat_parent = $('.cat_parent', rowData).text();
63 if ( cat_parent != '0' )
64 $('select[name="parent"]', editRow).val(cat_parent);
66 // remove the current parent and children from the parent dropdown
67 var pageOpt = $('select[name="parent"] option[value="'+id+'"]', editRow);
68 if ( pageOpt.length > 0 ) {
69 var pageLevel = pageOpt[0].className.split('-')[1], nextPage = pageOpt, pageLoop = true;
71 var nextPage = nextPage.next('option');
72 if (nextPage.length == 0) break;
73 var nextLevel = nextPage[0].className.split('-')[1];
74 if ( nextLevel <= pageLevel ) {
84 $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show();
85 $('.ptitle', editRow).eq(0).focus();
91 if( typeof(id) == 'object' )
94 $('table.widefat .inline-edit-save .waiting').show();
97 action: 'inline-save-tax',
102 var fields = $('#edit-'+id+' :input').fieldSerialize();
103 params = fields + '&' + $.param(params);
106 $.post('admin-ajax.php', params,
109 $('table.widefat .inline-edit-save .waiting').hide();
112 if ( -1 != r.indexOf('<tr') ) {
113 $(inlineEditTax.what+id).remove();
114 $('#edit-'+id).before(r).remove();
116 var row = $(inlineEditTax.what+id);
119 row.find('.hide-if-no-js').removeClass('hide-if-no-js');
120 inlineEditTax.addEvents(row);
123 $('#edit-'+id+' .inline-edit-save .error').html(r).show();
125 $('#edit-'+id+' .inline-edit-save .error').html(inlineEditL10n.error).show();
131 revert : function() {
132 var id = $('table.widefat tr.inline-editor').attr('id');
135 $('table.widefat .inline-edit-save .waiting').hide();
137 id = id.substr( id.lastIndexOf('-') + 1 );
138 $(this.what+id).show();
144 getId : function(o) {
145 var id = o.tagName == 'TR' ? o.id : $(o).parents('tr').attr('id');
146 var parts = id.split('-');
147 return parts[parts.length - 1];
151 $(document).ready(function(){inlineEditTax.init();});