User:Haza-w/Drop-down menus

From wikishia
User page | Talk page | Contributions | .JS | .CSS | E-mail

This script adds page options (and, if applicable, user options) drop-down menus to the "cactions" toolbar. It supports the Vector, MonoBook and Modern skins.

Overview

Once installed, the tool installs links to drop-down menus containing useful user and page options.

User options are displayed on all user and user talk pages, as well as on contributions pages. Page options are displayed on all pages except special pages.

File:Cactions tool.png
Screenshot of the page options menu on the main page, using the MonoBook skin. Click to enlarge.


Hovering over the links brings down the following menus:

| style="width:50%; text-align:left; vertical-align:top;" |

User options

| style="width:50%; text-align:left; vertical-align:top;" |

Page options

  • Page logs >
    • All page logs
    • Deletion log
    • Move log
    • Patrol log
    • Protection log
    • Upload log (images only)
  • History [6]
  • Move page [6]
  • Watch/unwatch page [6]
  • Protect/unprotect page [2][6]
  • Delete/undelete page [2][6]
  • Latest diff
  • Edit intro
  • Page analysis [4]
  • Purge cache


  1. 1.0 1.1 1.2 This replaces the link in the "toolbox" portlet on user/user talk base pages. The toolbox links are removed unless tbusr is set to true.
  2. 2.0 2.1 2.2 Links listed in italics are admin-only options.
  3. 3.0 3.1 These are external links to X!'s edit counter and edit summary usage analyser on the Wikimedia toolserver.
  4. 4.0 4.1 This is an external link to WikiChecker, and only appears on English Wikipedia pages.
  5. This is an external link to VasilievVV's SUL account tool on the Wikimedia toolserver.
  6. 6.0 6.1 6.2 6.3 6.4 This replaces the link in the "cactions" portlet by default. If itabs is disabled, then this link will not appear.


Smart menus

When a user drop-down menu is generated in an AJAX-compatible browser, the script quietly makes small AJAX calls to the MediaWiki API to obtain more information about that user. (If you're bandwidth-conscious, this typically results in about 4-8Kb of extra downstream traffic, including packet encapsulation.) This allows for options to be displayed, hidden or disabled, depending on that user's properties.

Examples of "smart" user menus:

The first screenshot is from the user page of a sysop, with links to administrative activity logs. The second is from the user page of a non-sysop who has no user subpages, so the userspace link is disabled.

Similarly, the third screenshot is from the user page of a user who is not blocked and has no previous blocks, whereas the fourth is from the user page of a user who is currently blocked.

File:Cactions tool 6.png
An example custom shortcuts portlet.

If you wish, you can prevent the script from making XMLHttpRequests (and hence stop the smart-disable functionality) by setting the xmlhr option; for more information, see #Configuration.


Shortcuts

The script can also install a personalised shortcuts portlet, underneath the toolbox. For more information, see #Configuration.

Setup

The easiest way to install the drop-down menus script is to select it as a Wikipedia gadget: access your preferences, select the Gadgets tab, and check the "Add page and user options..." entry in the User interface gadgets list.

When installed as a gadget, the script will use the default configuration settings. If you wish to customise the script, or install it on another wiki, you will need to follow the installation instructions below.

Installation

To install the tool, open your personal JS subpage. This depends on your MediaWiki skin, and can be found from the list below.

Skin Personal JS
Modern (preview) User:<username>/modern.js
MonoBook (preview) User:<username>/monobook.js
Vector (preview) User:<username>/vector.js
en.wikipedia.org

If installing the tool to your account on en.wikipedia.org, then add the following to your personal JS:

{{subst:js|User:Haza-w/cactions.js}}
Other WMF wikis

If installing the tool to your account on another Wikimedia Foundation wiki, then add the following to your personal JS:

// [[:w:en:User:Haza-w/Drop-down menus]]
importScriptURI('http://en.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=User:Haza-w/cactions.js');

Configuration

When manually installed, the tool has the following configurable options.

  • itabs: By default, the tool will remove the existing page tabs (history, move, protect, ...) and move them to the page options drop-down menu. However, you can choose to use the original tabs without moving them to the page options menu.
  • Shortcuts: This adds a shortcuts portlet to the sidebar, which you can configure with your own useful links.
  • Toolbox links: This suppresses the removal of some links from the "toolbox" portlet on base pages in the user and user talk namespaces. The links in the user options menu will still remain.
  • XMLHttpRequests: This allows disabling the AJAX calls associated with the smart menus feature.

To configure these options, insert the code below anywhere in your personal JS, and replace the values in italics according to the table below. If an option is not defined, then the default value will be used.

var cactions = {
    itabs: true,
    svars: [],
    tbusr: false,
    xmlhr: true
};
Variable Values Result
itabs true (default)
  • Removes default page tabs (history, move, [un]watch, [un]delete etc.) from cactions toolbar
  • Adds page links to page drop-down menu
false
  • Does not add page links to page drop-down menu
  • Keeps original page tabs
svars [] (default)
  • Does not add a shortcuts box to portlet toolbar
Array([text1,link1], [text2,link2], ...)
  • Adds a shortcuts box to portlet toolbar
  • Creates shortcut links as defined by array elements
tbusr false (default)
  • Removes user links from the toolbox portlet if they occur.
true
  • Suppresses removal of toolbox user links.
xmlhr true (default)
  • Enables XMLHttpRequests as part of the smart menus functionality.
false
  • Disables smart menus.

An example configuration would look something like the following:

var cactions = {
    itabs: false,
    svars: Array(
        ['New pages',           mw.config.get('wgScript') + '?title=Special:NewPages&action=view'],
        ['User talk templates', mw.config.get('wgScript') + '?title=Wikipedia:Template_messages/User_talk_namespace&action=view'],
        ['AIV reports',         mw.config.get('wgScript') + '?title=Wikipedia:Administrator_intervention_against_vandalism&action=view'],
        ['Speedy deletion',     mw.config.get('wgScript') + '?title=Wikipedia:Criteria_for_speedy_deletion&action=view']
    )
};

This disables itabs and creates a shortcuts portlet with links to Special:NewPages, WP:TM/UTN, WP:AIV and WP:CSD. Values for tbusr and xmlhr are not supplied, so their default values are used.

FAQ

  • Why haven't you used Vector's own drop-down menus engine?
    The main reason is that Vector's drop-down menus do not support nesting, which is a key aspect of this script. In addition, the elements of Vector's drop-down menus are larger and bulkier, and so to keep with the style would mean that particularly the user menu would become far too large.


Bugs/feature requests

If you have any feedback on the tool, then please leave a message on my user talk page.