| [ Index ] |
PHP Cross Reference of WordPress |
[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('class').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"]').mousedown(function(e){ 24 t.revert(); 25 }); 26 }, 27 28 toggle : function(el) { 29 var t = this; 30 $(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el); 31 }, 32 33 edit : function(id) { 34 var t = this, editRow; 35 t.revert(); 36 37 if ( typeof(id) == 'object' ) 38 id = t.getId(id); 39 40 editRow = $('#inline-edit').clone(true), rowData = $('#inline_'+id); 41 $('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length); 42 43 if ( $(t.what+id).hasClass('alternate') ) 44 $(editRow).addClass('alternate'); 45 46 $(t.what+id).hide().after(editRow); 47 48 $(':input[name="name"]', editRow).val( $('.name', rowData).text() ); 49 $(':input[name="slug"]', editRow).val( $('.slug', rowData).text() ); 50 51 $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show(); 52 $('.ptitle', editRow).eq(0).focus(); 53 54 return false; 55 }, 56 57 save : function(id) { 58 var params, fields, tax = $('input[name="taxonomy"]').val() || ''; 59 60 if( typeof(id) == 'object' ) 61 id = this.getId(id); 62 63 $('table.widefat .inline-edit-save .waiting').show(); 64 65 params = { 66 action: 'inline-save-tax', 67 tax_type: this.type, 68 tax_ID: id, 69 taxonomy: tax 70 }; 71 72 fields = $('#edit-'+id+' :input').serialize(); 73 params = fields + '&' + $.param(params); 74 75 // make ajax request 76 $.post( ajaxurl, params, 77 function(r) { 78 var row, new_id; 79 $('table.widefat .inline-edit-save .waiting').hide(); 80 81 if (r) { 82 if ( -1 != r.indexOf('<tr') ) { 83 $(inlineEditTax.what+id).remove(); 84 new_id = $(r).attr('id'); 85 86 $('#edit-'+id).before(r).remove(); 87 row = new_id ? $('#'+new_id) : $(inlineEditTax.what+id); 88 row.hide().fadeIn(); 89 } else 90 $('#edit-'+id+' .inline-edit-save .error').html(r).show(); 91 } else 92 $('#edit-'+id+' .inline-edit-save .error').html(inlineEditL10n.error).show(); 93 } 94 ); 95 return false; 96 }, 97 98 revert : function() { 99 var id = $('table.widefat tr.inline-editor').attr('id'); 100 101 if ( id ) { 102 $('table.widefat .inline-edit-save .waiting').hide(); 103 $('#'+id).remove(); 104 id = id.substr( id.lastIndexOf('-') + 1 ); 105 $(this.what+id).show(); 106 } 107 108 return false; 109 }, 110 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]; 114 } 115 }; 116 117 $(document).ready(function(){inlineEditTax.init();}); 118 })(jQuery);
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Fri May 25 03:56:23 2012 | Hosted by follow the white rabbit. |