From: Tim Eulitz Date: Thu, 21 Mar 2019 14:07:28 +0000 (+0100) Subject: Use delegated events for rollback confirmable X-Git-Tag: 1.34.0-rc.0~2428^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/modifier.php?a=commitdiff_plain;h=a2569497f6f02e85c40ce1bfac9ac27c072daf98;p=lhc%2Fweb%2Fwiklou.git Use delegated events for rollback confirmable 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 --- diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 85866066ca..05bbf3cbfa 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -2390,7 +2390,7 @@ "deleting-backlinks-warning": "Warning: [[Special:WhatLinksHere/{{FULLPAGENAME}}|Other pages]] link to or transclude the page you are about to delete.", "deleting-subpages-warning": "Warning: 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", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 5305c432a7..3438272be3 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -2596,7 +2596,7 @@ "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}}", diff --git a/resources/src/mediawiki.rollback.confirmation.js b/resources/src/mediawiki.rollback.confirmation.js index 8bf6786fa9..7e27d7e581 100644 --- a/resources/src/mediawiki.rollback.confirmation.js +++ b/resources/src/mediawiki.rollback.confirmation.js @@ -11,18 +11,17 @@ $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' ) ); + } } ); }() ); diff --git a/tests/selenium/specs/rollback.js b/tests/selenium/specs/rollback.js index 9169064232..d54641b794 100644 --- a/tests/selenium/specs/rollback.js +++ b/tests/selenium/specs/rollback.js @@ -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' ); } );