6 var t = this, row = $('#inline-edit'); |
6 var t = this, row = $('#inline-edit'); |
7 |
7 |
8 t.type = $('#the-list').attr('className').substr(5); |
8 t.type = $('#the-list').attr('className').substr(5); |
9 t.what = '#'+t.type+'-'; |
9 t.what = '#'+t.type+'-'; |
10 |
10 |
11 // get all editable rows |
11 $('.editinline').live('click', function(){ |
12 t.rows = $('tr.iedit'); |
12 inlineEditTax.edit(this); |
|
13 return false; |
|
14 }); |
13 |
15 |
14 // prepare the edit row |
16 // prepare the edit row |
15 row.keyup(function(e) { if(e.which == 27) return inlineEditTax.revert(); }); |
17 row.keyup(function(e) { if(e.which == 27) return inlineEditTax.revert(); }); |
16 |
18 |
17 $('a.cancel', row).click(function() { return inlineEditTax.revert(); }); |
19 $('a.cancel', row).click(function() { return inlineEditTax.revert(); }); |
18 $('a.save', row).click(function() { return inlineEditTax.save(this); }); |
20 $('a.save', row).click(function() { return inlineEditTax.save(this); }); |
19 $('input, select', row).keydown(function(e) { if(e.which == 13) return inlineEditTax.save(this); }); |
21 $('input, select', row).keydown(function(e) { if(e.which == 13) return inlineEditTax.save(this); }); |
20 |
|
21 // add events |
|
22 t.addEvents(t.rows); |
|
23 |
22 |
24 $('#posts-filter input[type="submit"]').click(function(e){ |
23 $('#posts-filter input[type="submit"]').click(function(e){ |
25 if ( $('form#posts-filter tr.inline-editor').length > 0 ) |
24 if ( $('form#posts-filter tr.inline-editor').length > 0 ) |
26 t.revert(); |
25 t.revert(); |
27 }); |
26 }); |
28 }, |
27 }, |
29 |
28 |
30 toggle : function(el) { |
29 toggle : function(el) { |
31 var t = this; |
30 var t = this; |
32 $(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el); |
31 $(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el); |
33 }, |
|
34 |
|
35 addEvents : function(r) { |
|
36 r.each(function() { |
|
37 $(this).find('a.editinline').click(function() { inlineEditTax.edit(this); return false; }); |
|
38 }); |
|
39 }, |
32 }, |
40 |
33 |
41 edit : function(id) { |
34 edit : function(id) { |
42 var t = this, editRow; |
35 var t = this, editRow; |
43 t.revert(); |
36 t.revert(); |
91 $(inlineEditTax.what+id).remove(); |
84 $(inlineEditTax.what+id).remove(); |
92 new_id = $(r).attr('id'); |
85 new_id = $(r).attr('id'); |
93 |
86 |
94 $('#edit-'+id).before(r).remove(); |
87 $('#edit-'+id).before(r).remove(); |
95 row = new_id ? $('#'+new_id) : $(inlineEditTax.what+id); |
88 row = new_id ? $('#'+new_id) : $(inlineEditTax.what+id); |
96 row.hide(); |
89 row.hide().fadeIn(); |
97 |
|
98 inlineEditTax.addEvents(row); |
|
99 row.fadeIn(); |
|
100 } else |
90 } else |
101 $('#edit-'+id+' .inline-edit-save .error').html(r).show(); |
91 $('#edit-'+id+' .inline-edit-save .error').html(r).show(); |
102 } else |
92 } else |
103 $('#edit-'+id+' .inline-edit-save .error').html(inlineEditL10n.error).show(); |
93 $('#edit-'+id+' .inline-edit-save .error').html(inlineEditL10n.error).show(); |
104 } |
94 } |