LFaraone has uploaded a new change for review.
https://gerrit.wikimedia.org/r/264127
Change subject: Add links to toggle checkbox selections in Special:Log
......................................................................
Add links to toggle checkbox selections in Special:Log
This implements a new JavaScript module, mediawiki.checkboxtoggle. The module
is suitable to be reused in any other list of checkboxes.
Bug: T92230
Change-Id: I92141a7079fc7fcd7152ef418d82f4f7969b163b
---
M includes/specials/SpecialLog.php
M languages/i18n/en.json
M languages/i18n/qqq.json
M resources/Resources.php
A resources/src/mediawiki/mediawiki.checkboxtoggle.js
5 files changed, 82 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/27/264127/1
diff --git a/includes/specials/SpecialLog.php b/includes/specials/SpecialLog.php
index e44ce5f..f4ac73e 100644
--- a/includes/specials/SpecialLog.php
+++ b/includes/specials/SpecialLog.php
@@ -258,6 +258,16 @@
$this->msg( 'log-edit-tags' )->text()
) . "\n";
}
+
+ $buttons .= Html::element(
+ 'div',
+ array(
+ 'class' => "toggle-option-placeholder"
+ ),
+ ''
+ ) . "\n";
+ $this->getOutput()->addModules( 'mediawiki.checkboxtoggle' );
+
$s .= $buttons . $formcontents . $buttons;
$s .= Html::closeElement( 'form' );
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index 602c290..63e1d9e 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -1883,7 +1883,11 @@
"logempty": "No matching items in log.",
"log-title-wildcard": "Search titles starting with this text",
"showhideselectedlogentries": "Change visibility of selected log
entries",
+ "log-checkbox-select": "Select: $1",
"log-edit-tags": "Edit tags of selected log entries",
+ "log-checkbox-all": "All",
+ "log-checkbox-none": "None",
+ "log-checkbox-invert": "Invert",
"allpages": "All pages",
"allpages-summary": "",
"nextpage": "Next page ($1)",
diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json
index 8654523..c7a1ea3 100644
--- a/languages/i18n/qqq.json
+++ b/languages/i18n/qqq.json
@@ -2059,6 +2059,10 @@
"log-title-wildcard": "* Appears in: [[Special:Log]]\n* Description: A
check box to enable prefix search option",
"showhideselectedlogentries": "Text of the button which brings up the
[[mw:RevisionDelete|RevisionDelete]] menu on [[Special:Log]].",
"log-edit-tags": "Text of button used to access change tagging
interface. For more information on tags see [[mw:Manual:Tags]].",
+ "log-checkbox-select": "Parameters:\n* $1 - three links:
{{msg-mw|log-checkbox-all}}, {{msg-mw|log-checkbox-none}}, and
{{msg-mw|log-checkbox-invert}} which respectively selects all pages, de-selects
all, and inverts the current selection state\npages\n{{Identical|Select}}",
+ "log-checkbox-all": "Text of button used to mark all revisions or log
entries as selected in a list.",
+ "log-checkbox-none": "Text of button used to mark all revisions or log
entries as unselected in a list.",
+ "log-checkbox-invert": "Text of button used to invert the
currently-selected-state of all revisions or log entries in a list.",
"allpages": "{{doc-special|AllPages}}\nFirst part of the navigation bar
for the special page [[Special:AllPages]] and [[Special:PrefixIndex]].\nThe
other parts are {{msg-mw|Prevpage}} and {{msg-mw|Nextpage}}.\n{{Identical|All
pages}}",
"allpages-summary": "{{doc-specialpagesummary|allpages}}",
"nextpage": "Third part of the navigation bar for the special page
[[Special:AllPages]] and [[Special:PrefixIndex]]. $1 is a page title. The other
parts are {{msg-mw|Allpages}} and {{msg-mw|Prevpage}}.\n\n{{Identical|Next
page}}",
diff --git a/resources/Resources.php b/resources/Resources.php
index 52a9564..b5e3d0a 100644
--- a/resources/Resources.php
+++ b/resources/Resources.php
@@ -1342,6 +1342,19 @@
'position' => 'top', // For $wgPreloadJavaScriptMwUtil
'targets' => array( 'desktop', 'mobile' ),
),
+ 'mediawiki.checkboxtoggle' => array(
+ 'scripts' =>
'resources/src/mediawiki/mediawiki.checkboxtoggle.js',
+ 'position' => 'top',
+ 'dependencies' => array(
+ 'mediawiki.jqueryMsg',
+ ),
+ 'messages' => array(
+ 'log-checkbox-all',
+ 'log-checkbox-none',
+ 'log-checkbox-invert',
+ 'log-checkbox-select',
+ )
+ ),
'mediawiki.cookie' => array(
'scripts' => 'resources/src/mediawiki/mediawiki.cookie.js',
'dependencies' => 'jquery.cookie',
diff --git a/resources/src/mediawiki/mediawiki.checkboxtoggle.js
b/resources/src/mediawiki/mediawiki.checkboxtoggle.js
new file mode 100644
index 0000000..1aee5ba
--- /dev/null
+++ b/resources/src/mediawiki/mediawiki.checkboxtoggle.js
@@ -0,0 +1,51 @@
+/*!
+ * Adds a set of toggle links to an element with the class
+ * `toggle-option-placeholder`, and allows users to perform all / none / invert
+ * operations on a list of checkboxes on the page.
+ *
+ * @licence GNU GPL v2+
+ * @author Luke Faraone <luke at faraone dot cc>
+ *
+ * Based on ext.nuke.js from https://www.mediawiki.org/wiki/Extension:Nuke by
+ * Jeroen De Dauw <jeroendedauw at gmail dot com>
+ */
+
+( function ( mw, $ ) {
+ 'use strict';
+
+ var $checkboxes = $( 'li input[type=checkbox]' );
+
+ function selectAll( check ) {
+ $checkboxes.prop( 'checked', check );
+ }
+
+
+ var $toggleOptions = mw.message('log-checkbox-select', [
+ $( '<a>' )
+ .text( mw.msg( 'log-checkbox-all' ) )
+ .click( function (e) {
+ selectAll( true );
+ e.preventDefault();
+ } ),
+ mw.msg( "comma-separator" ),
+ $( '<a>' )
+ .text( mw.msg( 'log-checkbox-none' ) )
+ .click( function (e) {
+ selectAll( false );
+ e.preventDefault();
+ } ),
+ mw.msg( "comma-separator" ),
+ $( '<a>' )
+ .text( mw.msg( 'log-checkbox-invert' ) )
+ .click( function (e) {
+ $checkboxes.each( function () {
+ $( this ).prop( 'checked', !$( this
).is( ':checked' ) );
+ } );
+ e.preventDefault();
+ } )
+ ]).parseDom();
+
+ $ ( '.toggle-option-placeholder' ).append( $toggleOptions );
+
+}( mediaWiki, jQuery ) );
+
--
To view, visit https://gerrit.wikimedia.org/r/264127
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I92141a7079fc7fcd7152ef418d82f4f7969b163b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: LFaraone <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits