| [ Index ] |
PHP Cross Reference of Wordpress 2.9.1 |
[Summary view] [Print] [Text view]
1 2 (function($) { 3 inlineEditTax = { 4 5 init : function() { 6 var t = this, row = $('#inline-edit'); 7 8 t.type = $('#the-list').attr('className').substr(5); 9 t.what = '#'+t.type+'-'; 10 11 $('.editinline').live('click', function(){ 12 inlineEditTax.edit(this); 13 return false; 14 }); 15 16 // prepare the edit row 17 row.keyup(function(e) { if(e.which == 27) return inlineEditTax.revert(); }); 18 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); }); 22 23 $('#posts-filter input[type="submit"]').click(function(e){ 24 if ( $('form#posts-filter tr.inline-editor').length > 0 ) 25 t.revert(); 26 }); 27 }, 28 29 toggle : function(el) { 30 var t = this; 31 $(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el); 32 }, 33 34 edit : function(id) { 35 var t = this, editRow; 36 t.revert(); 37 38 if ( typeof(id) == 'object' ) 39 id = t.getId(id); 40 41 editRow = $('#inline-edit').clone(true), rowData = $('#inline_'+id); 42 $('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length); 43 44 if ( $(t.what+id).hasClass('alternate') ) 45 $(editRow).addClass('alternate'); 46 47 $(t.what+id).hide().after(editRow); 48 49 $(':input[name="name"]', editRow).val( $('.name', rowData).text() ); 50 $(':input[name="slug"]', editRow).val( $('.slug', rowData).text() ); 51 52 $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show(); 53 $('.ptitle', editRow).eq(0).focus(); 54 55 return false; 56 }, 57 58 save : function(id) { 59 var params, fields, tax = $('input[name="taxonomy"]').val() || ''; 60 61 if( typeof(id) == 'object' ) 62 id = this.getId(id); 63 64 $('table.widefat .inline-edit-save .waiting').show(); 65 66 params = { 67 action: 'inline-save-tax', 68 tax_type: this.type, 69 tax_ID: id, 70 taxonomy: tax 71 }; 72 73 fields = $('#edit-'+id+' :input').serialize(); 74 params = fields + '&' + $.param(params); 75 76 // make ajax request 77 $.post('admin-ajax.php', params, 78 function(r) { 79 var row, new_id; 80 $('table.widefat .inline-edit-save .waiting').hide(); 81 82 if (r) { 83 if ( -1 != r.indexOf('<tr') ) { 84 $(inlineEditTax.what+id).remove(); 85 new_id = $(r).attr('id'); 86 87 $('#edit-'+id).before(r).remove(); 88 row = new_id ? $('#'+new_id) : $(inlineEditTax.what+id); 89 row.hide().fadeIn(); 90 } else 91 $('#edit-'+id+' .inline-edit-save .error').html(r).show(); 92 } else 93 $('#edit-'+id+' .inline-edit-save .error').html(inlineEditL10n.error).show(); 94 } 95 ); 96 return false; 97 }, 98 99 revert : function() { 100 var id = $('table.widefat tr.inline-editor').attr('id'); 101 102 if ( id ) { 103 $('table.widefat .inline-edit-save .waiting').hide(); 104 $('#'+id).remove(); 105 id = id.substr( id.lastIndexOf('-') + 1 ); 106 $(this.what+id).show(); 107 } 108 109 return false; 110 }, 111 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]; 115 } 116 }; 117 118 $(document).ready(function(){inlineEditTax.init();}); 119 })(jQuery);
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Fri Jan 8 00:19:48 2010 | Cross-referenced by PHPXref 0.7 |