From 8bf771fc40bcadd25e1b13ffcb3f293d789797b4 Mon Sep 17 00:00:00 2001 From: Amir Sarabadani Date: Wed, 28 Dec 2016 11:45:54 +0330 Subject: [PATCH] Ask for confirmation when nuking Bug: T131975 Change-Id: I908c1aacdc8069ea9ae1ec860eef5421d9da2fab --- .jshintrc | 3 ++- Nuke_body.php | 2 ++ ext.nuke.confirm.js | 14 ++++++++++++++ extension.json | 8 ++++++++ i18n/en.json | 3 ++- i18n/qqq.json | 3 ++- 6 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 ext.nuke.confirm.js diff --git a/.jshintrc b/.jshintrc index 946c0035..9494e554 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,6 +1,7 @@ { "predef": [ - "jQuery" + "jQuery", + "mediaWiki" ], /* Common */ diff --git a/Nuke_body.php b/Nuke_body.php index fad94585..38a6f421 100644 --- a/Nuke_body.php +++ b/Nuke_body.php @@ -146,6 +146,8 @@ class SpecialNuke extends SpecialPage { return; } + $out->addModules( 'ext.nuke.confirm' ); + if ( $username === '' ) { $out->addWikiMsg( 'nuke-list-multiple' ); } else { diff --git a/ext.nuke.confirm.js b/ext.nuke.confirm.js new file mode 100644 index 00000000..6d40c9f5 --- /dev/null +++ b/ext.nuke.confirm.js @@ -0,0 +1,14 @@ +( function ( mw, $ ) { + $( document ).ready( function () { + /*global confirm */ + + // Confirm nuke + $( 'form[name="nukelist"]' ).on( 'submit', function () { + var pages = $( this ).find( 'input[name="pages[]"][type="checkbox"]:checked' ); + if ( pages.length ) { + return confirm( mw.msg( 'nuke-confirm', pages.length ).text() ); + } + } ); + + } ); +}( mediaWiki, jQuery ) ); diff --git a/extension.json b/extension.json index 329d7df8..62447c80 100644 --- a/extension.json +++ b/extension.json @@ -30,6 +30,14 @@ "scripts": [ "ext.nuke.js" ] + }, + "ext.nuke.confirm": { + "scripts": [ + "ext.nuke.confirm.js" + ], + "messages": [ + "nuke-confirm" + ] } }, "ResourceFileModulePaths": { diff --git a/i18n/en.json b/i18n/en.json index 71cda055..dc22fe81 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -30,5 +30,6 @@ "nuke-viewchanges": "view changes", "nuke-namespace": "Limit to namespace:", "nuke-linkoncontribs": "mass delete", - "nuke-linkoncontribs-text": "Mass delete pages where {{GENDER:$1|this user}} is the only author" + "nuke-linkoncontribs-text": "Mass delete pages where {{GENDER:$1|this user}} is the only author", + "nuke-confirm": "You are about to delete {{PLURAL:$1|one page|$1 pages}}. Are you sure that you want to delete?" } diff --git a/i18n/qqq.json b/i18n/qqq.json index 0aeae899..4604066f 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -41,5 +41,6 @@ "nuke-viewchanges": "Used as link text.\n\nThe link points to History page of the page.\n\nThis message follows:\n* {{msg-mw|nuke-editby}} and {{msg-mw|comma-separator}}\n* or empty string (if username is empty).\n{{Identical|View changes}}", "nuke-namespace": "Label shown on [[Special:Nuke]] in front of the namespace input that allows choosing a namespace to filter the search by", "nuke-linkoncontribs": "Used as link text which is used on [[Special:Contributions]] and [[Special:DeletedContributions]].\n\nOnly added if a user has rights to nuke pages.\n\nThe link has the tooltip {{msg-mw|Nuke-linkoncontribs-text}}.\n{{Identical|Mass delete}}", - "nuke-linkoncontribs-text": "Tooltip for the link which is labeled {{msg-mw|Nuke-linkoncontribs}} Parameters:\n* $1 is the target user name used for GENDER." + "nuke-linkoncontribs-text": "Tooltip for the link which is labeled {{msg-mw|Nuke-linkoncontribs}} Parameters:\n* $1 is the target user name used for GENDER.", + "nuke-confirm": "Message when the user is trying to delete pages." }