Make WordPress Core

Ticket #15898: 15898-example-js.patch

File 15898-example-js.patch, 2.1 KB (added by azaozz, 14 years ago)

Idea for handling the changes to the approved parrent comment

  • wp-admin/js/edit-comments.dev.js

     
    1 var theList, theExtraList, toggleWithKeyboard = false;
     1var theList, theExtraList, toggleWithKeyboard = false, getCount, updateCount;
    22(function($) {
    33
    44setCommentsList = function() {
     
    117117
    118118        }
    119119
    120         function getCount(el) {
     120        getCount = function(el) {
    121121                var n = parseInt( el.html().replace(/[^0-9]+/g, ''), 10 );
    122122                if ( isNaN(n) )
    123123                        return 0;
    124124                return n;
    125125        }
    126126
    127         function updateCount(el, n) {
     127        updateCount = function(el, n) {
    128128                var n1 = '';
    129129                if ( isNaN(n) )
    130130                        return;
     
    453453        },
    454454
    455455        show : function(xml) {
    456                 var r, c, id, bg;
     456                var t = this, r, c, id, bg, el, pid;
    457457
    458458                if ( typeof(xml) == 'string' ) {
    459                         this.error({'responseText': xml});
     459                        t.error({'responseText': xml});
    460460                        return false;
    461461                }
    462462
    463463                r = wpAjax.parseAjaxResponse(xml);
    464464                if ( r.errors ) {
    465                         this.error({'responseText': wpAjax.broken});
     465                        t.error({'responseText': wpAjax.broken});
    466466                        return false;
    467467                }
    468468
     
    475475                $(c).hide()
    476476                $('#replyrow').after(c);
    477477
    478                 this.revert();
    479                 this.addEvents($(id));
    480                 bg = $(id).hasClass('unapproved') ? '#ffffe0' : '#fff';
     478                if ( r.supplemental.parrent_approved ) {
     479                        el = $('span.pending-count');
     480                        pid = '#comment-' + r.supplemental.parrent_approved;
     481                        updateCount( el, 1 + getCount(el) );
     482                }
    481483
     484                t.revert();
     485                t.addEvents($(id));
     486                bg = $(id).hasClass('unapproved') ? '#FFFFE0' : '#FFFFFF';
     487
    482488                $(id)
    483489                        .animate( { 'backgroundColor':'#CCEEBB' }, 600 )
    484                         .animate( { 'backgroundColor': bg }, 600 );
     490                        .animate( { 'backgroundColor': bg }, 600, function(){
     491                                if ( pid ) {
     492                                        pid = $(pid)
     493                                                .animate( { 'backgroundColor':'#CCEEBB' }, 600 )
     494                                                .animate( { 'backgroundColor': '#FFFFFF' }, 600 );
    485495
    486                 // $.fn.wpList.process($(id));
     496                                        pid.find('.row-actions .approve').hide();
     497                                        pid.find('.row-actions .unapprove').show();
     498                                }
     499                        });
    487500        },
    488501
    489502        error : function(r) {