-
+ 58A2E12401CC7677080783281CE0711A3F715B1FE117E5D3EDF1B3AFAD8B7315325834D93A5D1917C416EDC644BEDD069054A1D0960CD214C7ACDDBEA4F550F5
mp-wp/wp-admin/js/inline-edit-tax.js
(0 . 0)(1 . 152)
50260
50261 (function($) {
50262 inlineEditTax = {
50263
50264 init : function() {
50265 var t = this, row = $('#inline-edit');
50266
50267 t.type = $('#the-list').attr('className').substr(5);
50268 t.what = '#'+t.type+'-';
50269
50270 // get all editable rows
50271 t.rows = $('tr.iedit');
50272
50273 // prepare the edit row
50274 row.keyup(function(e) { if(e.which == 27) return inlineEditTax.revert(); });
50275
50276 $('a.cancel', row).click(function() { return inlineEditTax.revert(); });
50277 $('a.save', row).click(function() { return inlineEditTax.save(this); });
50278 $('input, select', row).keydown(function(e) { if(e.which == 13) return inlineEditTax.save(this); });
50279
50280 // add events
50281 t.addEvents(t.rows);
50282
50283 $('#posts-filter input[type="submit"]').click(function(e){
50284 if ( $('form#posts-filter tr.inline-editor').length > 0 )
50285 t.revert();
50286 });
50287 },
50288
50289 toggle : function(el) {
50290 var t = this;
50291
50292 $(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el);
50293 },
50294
50295 addEvents : function(r) {
50296 r.each(function() {
50297 $(this).find('a.editinline').click(function() { inlineEditTax.edit(this); return false; });
50298 $(this).find('.hide-if-no-js').removeClass('hide-if-no-js');
50299 });
50300 },
50301
50302 edit : function(id) {
50303 var t = this;
50304 t.revert();
50305
50306 if ( typeof(id) == 'object' )
50307 id = t.getId(id);
50308
50309 var editRow = $('#inline-edit').clone(true), rowData = $('#inline_'+id);
50310 $('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length);
50311
50312 if ( $(t.what+id).hasClass('alternate') )
50313 $(editRow).addClass('alternate');
50314
50315 $(t.what+id).hide().after(editRow);
50316
50317 $(':input[name="name"]', editRow).val( $('.name', rowData).text() );
50318 $(':input[name="slug"]', editRow).val( $('.slug', rowData).text() );
50319
50320 // cat parents
50321 var cat_parent = $('.cat_parent', rowData).text();
50322 if ( cat_parent != '0' )
50323 $('select[name="parent"]', editRow).val(cat_parent);
50324
50325 // remove the current parent and children from the parent dropdown
50326 var pageOpt = $('select[name="parent"] option[value="'+id+'"]', editRow);
50327 if ( pageOpt.length > 0 ) {
50328 var pageLevel = pageOpt[0].className.split('-')[1], nextPage = pageOpt, pageLoop = true;
50329 while ( pageLoop ) {
50330 var nextPage = nextPage.next('option');
50331 if (nextPage.length == 0) break;
50332 var nextLevel = nextPage[0].className.split('-')[1];
50333 if ( nextLevel <= pageLevel ) {
50334 pageLoop = false;
50335 } else {
50336 nextPage.remove();
50337 nextPage = pageOpt;
50338 }
50339 }
50340 pageOpt.remove();
50341 }
50342
50343 $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show();
50344 $('.ptitle', editRow).eq(0).focus();
50345
50346 return false;
50347 },
50348
50349 save : function(id) {
50350 if( typeof(id) == 'object' )
50351 id = this.getId(id);
50352
50353 $('table.widefat .inline-edit-save .waiting').show();
50354
50355 var params = {
50356 action: 'inline-save-tax',
50357 tax_type: this.type,
50358 tax_ID: id
50359 };
50360
50361 var fields = $('#edit-'+id+' :input').fieldSerialize();
50362 params = fields + '&' + $.param(params);
50363
50364 // make ajax request
50365 $.post('admin-ajax.php', params,
50366 function(r) {
50367
50368 $('table.widefat .inline-edit-save .waiting').hide();
50369
50370 if (r) {
50371 if ( -1 != r.indexOf('<tr') ) {
50372 $(inlineEditTax.what+id).remove();
50373 $('#edit-'+id).before(r).remove();
50374
50375 var row = $(inlineEditTax.what+id);
50376 row.hide();
50377
50378 row.find('.hide-if-no-js').removeClass('hide-if-no-js');
50379 inlineEditTax.addEvents(row);
50380 row.fadeIn();
50381 } else
50382 $('#edit-'+id+' .inline-edit-save .error').html(r).show();
50383 } else
50384 $('#edit-'+id+' .inline-edit-save .error').html(inlineEditL10n.error).show();
50385 }
50386 );
50387 return false;
50388 },
50389
50390 revert : function() {
50391 var id = $('table.widefat tr.inline-editor').attr('id');
50392
50393 if ( id ) {
50394 $('table.widefat .inline-edit-save .waiting').hide();
50395 $('#'+id).remove();
50396 id = id.substr( id.lastIndexOf('-') + 1 );
50397 $(this.what+id).show();
50398 }
50399
50400 return false;
50401 },
50402
50403 getId : function(o) {
50404 var id = o.tagName == 'TR' ? o.id : $(o).parents('tr').attr('id');
50405 var parts = id.split('-');
50406 return parts[parts.length - 1];
50407 }
50408 };
50409
50410 $(document).ready(function(){inlineEditTax.init();});
50411 })(jQuery);