Make WordPress Core

Ticket #32818: 32818.diff

File 32818.diff, 2.7 KB (added by polevaultweb, 10 years ago)
  • src/wp-includes/script-loader.php

     
    474474                        'replyApprove' => __( 'Approve and Reply' ),
    475475                        'reply' => __( 'Reply' ),
    476476                        'warnQuickEdit' => __( "Are you sure you want to edit this comment?\nThe changes you made will be lost." ),
     477                        'warnDiscardChanges' => __( "Are you sure you want to do this?\nThe reply changes you made will be lost." ),
    477478                ) );
    478479
    479480                $scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", array('jquery'), false, 1 );
  • src/wp-admin/js/edit-comments.js

     
    495495commentReply = {
    496496        cid : '',
    497497        act : '',
     498        originalContent : '',
    498499
    499500        init : function() {
    500501                var row = $('#replyrow');
     
    578579                $( '.spinner', replyrow ).removeClass( 'is-active' );
    579580
    580581                this.cid = '';
     582                this.originalContent = '';
    581583        },
    582584
    583585        open : function(comment_id, post_id, action) {
     
    586588                        c = $('#comment-' + comment_id),
    587589                        h = c.height();
    588590
     591                if ( ! this.discardChanges() ) {
     592                        // Ask the user to preserve any edits to already open comments
     593                        return false;
     594                }
     595
    589596                t.close();
    590597                t.cid = comment_id;
    591598
     
    594601                action = action || 'replyto';
    595602                act = 'edit' == action ? 'edit' : 'replyto';
    596603                act = t.act = act + '-comment';
     604                t.originalContent = $('textarea.comment', rowData).val();
    597605
    598606                $('#action', editRow).val(act);
    599607                $('#comment_post_ID', editRow).val(post_id);
     
    766774                        $('table.comments-box').css('display', '');
    767775                        $('#no-comments').remove();
    768776                });
     777        },
     778
     779        /**
     780         * If an open reply has been changed, warn the user they will lose changes
     781         * and act on the response.
     782         *
     783         * @returns {boolean}
     784         */
     785        discardChanges: function() {
     786                var editRow = $( '#replyrow' );
     787
     788                if  ( this.originalContent === $( '#replycontent', editRow ).val() ) {
     789                        return true;
     790                }
     791
     792                return window.confirm( adminCommentsL10n.warnDiscardChanges );
    769793        }
    770794};
    771795
  • src/wp-admin/js/post.js

     
    268268
    269269                        if ( typeof commentReply !== 'undefined' ) {
    270270                                /*
     271                                 * Don't submit the edit post if a comment reply has been edited
     272                                 * and the user wants to preserve it.
     273                                 */
     274                                if ( ! commentReply.discardChanges() ) {
     275                                        return false;
     276                                }
     277
     278                                /*
    271279                                 * Close the comment edit/reply form if open to stop the form
    272280                                 * action from interfering with the post's form action.
    273281                                 */