Use delegated events for rollback confirmable
authorTim Eulitz <tim.eulitz@wikimedia.de>
Thu, 21 Mar 2019 14:07:28 +0000 (15:07 +0100)
committerTim Eulitz <tim.eulitz@wikimedia.de>
Thu, 21 Mar 2019 17:14:07 +0000 (18:14 +0100)
This change is necessary to make the rollback confirmation work even
when the list of items which can be rolled back is updated via
JavaScript (this is possible on RecentChanges, for example).

Bug: T218354
Change-Id: Idafe1380b283cf0056ff1efdffa04aca92cf1217

languages/i18n/en.json
languages/i18n/qqq.json
resources/src/mediawiki.rollback.confirmation.js
tests/selenium/specs/rollback.js

index 8586606..05bbf3c 100644 (file)
        "deleting-backlinks-warning": "<strong>Warning:</strong> [[Special:WhatLinksHere/{{FULLPAGENAME}}|Other pages]] link to or transclude the page you are about to delete.",
        "deleting-subpages-warning": "<strong>Warning:</strong> The page you are about to delete has [[Special:PrefixIndex/{{FULLPAGENAME}}/|{{PLURAL:$1|a subpage|$1 subpages|51=over 50 subpages}}]].",
        "rollback": "Roll back edits",
-       "rollback-confirmation-confirm": "Rollback of {{PLURAL:$1|0=these edits|one edit|$1 edits}}?",
+       "rollback-confirmation-confirm": "Please confirm:",
        "rollback-confirmation-yes": "Rollback",
        "rollback-confirmation-no": "Cancel",
        "rollbacklink": "rollback",
index 5305c43..3438272 100644 (file)
        "deleting-backlinks-warning": "A warning shown when a page that is being deleted has at least one link to it or is transcluded in at least one page.",
        "deleting-subpages-warning": "A warning shown when a page that is being deleted has at least one subpage. $1 is the number of subpages of the page. For any number of subpages over 50, $1 will be 51.\nSee also:\n* {{msg-mw|Deleting-backlinks-warning}}",
        "rollback": "{{Identical|Rollback}}",
-       "rollback-confirmation-confirm": "Question shown to user to confirm that they want to proceed with the rollback.\n\nParameters:\n* $1 - number of edits that will be rolled back.",
+       "rollback-confirmation-confirm": "Prompt which asks the user to confirm that they want to really perform the rollback action after clicking on the rollback button.",
        "rollback-confirmation-yes": "Button text to confirm that a rollback should be executed.",
        "rollback-confirmation-no": "Button text to cancel a rollback instead of executing it.",
        "rollbacklink": "{{Doc-actionlink}}\nThis link text appears on the recent changes page to users who have the \"rollback\" right.\nThis message has a tooltip {{msg-mw|tooltip-rollback}}\n{{Identical|Rollback}}",
index 8bf6786..7e27d7e 100644 (file)
                $form.appendTo( 'body' ).trigger( 'submit' );
        };
 
-       $( '.mw-rollback-link a' ).each( function () {
-               $( this ).confirmable( {
-                       i18n: {
-                               confirm: mw.msg( 'rollback-confirmation-confirm', $( this ).data( 'rollback-count' ) ),
-                               yes: mw.msg( 'rollback-confirmation-yes' ),
-                               no: mw.msg( 'rollback-confirmation-no' )
-                       },
-                       handler: function ( e ) {
-                               e.preventDefault();
-                               postRollback( $( this ).attr( 'href' ) );
-                       }
-               } );
+       $( '#mw-content-text' ).confirmable( {
+               i18n: {
+                       confirm: mw.msg( 'rollback-confirmation-confirm', $( this ).data( 'rollback-count' ) ),
+                       yes: mw.msg( 'rollback-confirmation-yes' ),
+                       no: mw.msg( 'rollback-confirmation-no' )
+               },
+               delegate: '.mw-rollback-link a',
+               handler: function ( e ) {
+                       e.preventDefault();
+                       postRollback( $( this ).attr( 'href' ) );
+               }
        } );
 
 }() );
index 9169064..d54641b 100644 (file)
@@ -43,7 +43,7 @@ describe( 'Rollback with confirmation', function () {
 
                HistoryPage.rollback.click();
 
-               assert.strictEqual( HistoryPage.rollbackConfirmable.getText(), 'Rollback of one edit?' );
+               assert.strictEqual( HistoryPage.rollbackConfirmable.getText(), 'Please confirm:' );
                assert.strictEqual( HistoryPage.rollbackConfirmableYes.getText(), 'Rollback' );
                assert.strictEqual( HistoryPage.rollbackConfirmableNo.getText(), 'Cancel' );
        } );