Ticket #28326: 28326.2.diff
File 28326.2.diff, 2.4 KB (added by , 4 years ago) |
---|
-
src/js/_enqueues/admin/inline-edit-post.js
390 390 * Enter on a focused field. 391 391 */ 392 392 save : function(id) { 393 var params, fields, page = $('.post_status_page').val() || '';393 var params, fields, rowData, was_sticky, is_sticky, page = $('.post_status_page').val() || ''; 394 394 395 395 if ( typeof(id) === 'object' ) { 396 396 id = this.getId(id); … … 409 409 fields = $('#edit-'+id).find(':input').serialize(); 410 410 params = fields + '&' + $.param(params); 411 411 412 rowData = $('#inline_'+id); 413 was_sticky = $( '.sticky', rowData ).text() === 'sticky'; 414 console.log(rowData); 415 console.log(was_sticky); 412 416 // Make ajax request. 413 417 $.post( ajaxurl, params, 414 418 function(r) { … … 422 426 if ( -1 !== r.indexOf( '<tr' ) ) { 423 427 $(inlineEditPost.what+id).siblings('tr.hidden').addBack().remove(); 424 428 $('#edit-'+id).before(r).remove(); 429 is_sticky = -1 !== r.indexOf( '<div class="sticky">sticky</div>' ); 430 if ( was_sticky && ! is_sticky ) { 431 inlineEditPost.updateCountText( '.sticky span.count', -1 ); 432 } else if ( is_sticky && ! was_sticky ) { 433 inlineEditPost.updateCountText( '.sticky span.count', 1 ); 434 } 435 console.log(r); 436 console.log(is_sticky); 425 437 $( inlineEditPost.what + id ).hide().fadeIn( 400, function() { 426 438 // Move focus back to the Quick Edit button. $( this ) is the row being animated. 427 439 $( this ).find( '.editinline' ) … … 504 516 var id = $(o).closest('tr').attr('id'), 505 517 parts = id.split('-'); 506 518 return parts[parts.length - 1]; 519 }, 520 521 getCount : function(el) { 522 var n = parseInt( el.html().replace(/[^0-9]+/g, ''), 10 ); 523 if ( isNaN(n) ) { 524 return 0; 525 } 526 return n; 527 }, 528 529 updateCount : function(el, n) { 530 var n1 = ''; 531 if ( isNaN(n) ) { 532 return; 533 } 534 n = n < 1 ? '0' : n.toString(); 535 if ( n.length > 3 ) { 536 while ( n.length > 3 ) { 537 n1 = thousandsSeparator + n.substr(n.length - 3) + n1; 538 n = n.substr(0, n.length - 3); 539 } 540 n = n + n1; 541 } 542 el.html('('+n+')'); 543 }, 544 545 updateCountText : function( selector, diff ) { 546 $( selector ).each(function() { 547 var a = $(this), n = inlineEditPost.getCount(a) + diff; 548 if ( n < 1 ) { 549 n = 0; 550 } 551 inlineEditPost.updateCount( a, n ); 552 }); 507 553 } 508 554 }; 509 555