Make WordPress Core

Ticket #32818: 32818.patch

File 32818.patch, 2.8 KB (added by rachelbaker, 9 years ago)

Refresh with minor documentation and function name edits

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

     
    563563commentReply = {
    564564        cid : '',
    565565        act : '',
     566        originalContent : '',
    566567
    567568        init : function() {
    568569                var row = $('#replyrow');
     
    646647                $( '.spinner', replyrow ).removeClass( 'is-active' );
    647648
    648649                this.cid = '';
     650                this.originalContent = '';
    649651        },
    650652
    651653        open : function(comment_id, post_id, action) {
     
    655657                        h = c.height(),
    656658                        colspanVal = 0;
    657659
     660                if ( ! this.discardCommentChanges() ) {
     661                        return false;
     662                }
     663
    658664                t.close();
    659665                t.cid = comment_id;
    660666
     
    663669                action = action || 'replyto';
    664670                act = 'edit' == action ? 'edit' : 'replyto';
    665671                act = t.act = act + '-comment';
     672                t.originalContent = $('textarea.comment', rowData).val();
    666673                colspanVal = $( '> th:visible, > td:visible', c ).length;
    667674
    668675                // Make sure it's actually a table and there's a `colspan` value to apply.
     
    850857                        $('table.comments-box').css('display', '');
    851858                        $('#no-comments').remove();
    852859                });
     860        },
     861
     862        /**
     863         * Alert the user if they have unsaved changes on a comment that will be
     864         * lost if they proceed.
     865         *
     866         * @returns {boolean}
     867         */
     868        discardCommentChanges: function() {
     869                var editRow = $( '#replyrow' );
     870
     871                if  ( this.originalContent === $( '#replycontent', editRow ).val() ) {
     872                        return true;
     873                }
     874
     875                return window.confirm( adminCommentsL10n.warnCommentChanges );
    853876        }
    854877};
    855878
  • src/wp-admin/js/post.js

     
    272272
    273273                        if ( typeof commentReply !== 'undefined' ) {
    274274                                /*
     275                                 * Warn the user they have an unsaved comment before submitting
     276                                 * the post data for update.
     277                                 */
     278                                if ( ! commentReply.discardCommentChanges() ) {
     279                                        return false;
     280                                }
     281
     282                                /*
    275283                                 * Close the comment edit/reply form if open to stop the form
    276284                                 * action from interfering with the post's form action.
    277285                                 */
  • src/wp-includes/script-loader.php

     
    495495                        'replyApprove' => __( 'Approve and Reply' ),
    496496                        'reply' => __( 'Reply' ),
    497497                        'warnQuickEdit' => __( "Are you sure you want to edit this comment?\nThe changes you made will be lost." ),
     498                        'warnCommentChanges' => __( "Are you sure you want to do this?\nThe comment changes you made will be lost." ),
    498499                        'docTitleComments' => __( 'Comments' ),
    499500                        /* translators: %s: comments count */
    500501                        'docTitleCommentsCount' => __( 'Comments (%s)' ),