FANDOM


The BotoneraPopups script adds a popup (in-page) with links to useful actions will appear when hovering a link while the CTRL key is pressed.

Features

  • Access in one single click to nearly all possible actions on one page for any link already present on a page (edit, history, delete, move, backlinks, etc.). Not only wiki links but any arbitrary link on the page that points to a wiki page.
  • Same for users when the link is related to a user (block, contributions, userpage, talk).
  • Rollback with a custom rollback summary, hide rollbacks from Recent Changes and/or omit the diff after rollback, using the core rollback functionality of MediaWiki.
  • Toggle preview on diffs and preview on first edit without manually editing the URL or changing your preferences.

Usage

Hold down the CTRL key of your keyboard and hover your mouse pointer over a link on the wiki. If the link points to an article, a popup will appear at the bottom of the link with links to several available actions related to the article:

  • Page actions: view, edit, history, purge, delete (sysops only), protect (sysops only)
  • Special pages: What links here, List pages with same prefix, rename/move, view logs, see last change in a diff
  • User actions: When the link is a user page or related to a user: View contribs, user logs, user blocks, block user (sysops only)
  • Diffs: When the link is a diff or permalink: Links to previous diff, next diff, and actual diff, and edit next or previous revision.
  • Rollback: When the link is a rollback one: Toggle "bot" flag (hides from RecentChanges), toggle diff after rollback, use a custom message for rollback summary.
  • Other options: Toggle preview on first edit (only popup links), toggle preview when diff (only popup links).

To hide the popup, click on the close link (being represented as [X]) or hit the ESC key of your keyboard.

You can switch links from targeting the article page or the talk page with two switch buttons near the page title inside the popup.

Additionally, a change link is next to them to change the page title with an arbitrary one (useful for getting the pagename prettified without underscores, to quickly get edit links to another page, etc.). If you close the popup or you hover another link with the CTRL key pressed, the target page will be reset.

The option to toggle preview on edit will remain with the same state for the current page. You can toggle it on or off by clicking on it, and edit links in the popup will change accordingly. The same happens with the option to display a preview when we get a diff page. Both options are initially set making a query to the api for user options (that you can configure through Special:Preferences), and the values stored in a cookie. If you change your preferences, it should get fresh values. If not, simply go to Special:Preferences on the wiki you have this script installed and it will refresh the values of the cookie.

The rollback options last for the current page: toggle of bot flag, diff, and custom message. It's useful for pages with more than one rollback link (Contributions page, or Recent Changes). The bot and diff toggles can be toggled on and off by clicking on them, and the custom rollback summary link will open an input box for placing (or viewing) the current custom rollback message. You can remove it by setting it to an empty string. The diff link gets initialized with your preferences, as the other options discussed above. Rollback options only apply to the rollback link of the popup.

Installation

Add the following to w:Special:MyPage/global.js (for personal use on all FANDOM-hosted wikis) or Special:MyPage/monobook.js/Special:MyPage/wikia.js on a specific wiki. Note that one of the scripts has a language code on it (BotoneraPopups/UILang/en.js). Replace it with the language code of your choice if a localization exists in that language. Check #Language.

For English text
// BEGIN BotoneraPopups
importArticles({
    type: "script",
    articles: [
        "u:dev:MediaWiki:BotoneraPopups/BotoneraPopups.js",
        "u:dev:MediaWiki:BotoneraPopups/WikiArticle.js",
        "u:dev:MediaWiki:BotoneraPopups/UILang/en.js",
        "u:dev:MediaWiki:BotoneraPopups/code.js"
    ]
});
// END
For Spanish text
// BEGIN BotoneraPopups
importArticles({
    type: "script",
    articles: [
        "u:dev:MediaWiki:BotoneraPopups/BotoneraPopups.js",
        "u:dev:MediaWiki:BotoneraPopups/WikiArticle.js",
        "u:dev:MediaWiki:BotoneraPopups/UILang/es.js",
        "u:dev:MediaWiki:BotoneraPopups/code.js"
    ]
});
// END
For Polish text
// BEGIN BotoneraPopups
importArticles({
    type: "script",
    articles: [
        "u:dev:MediaWiki:BotoneraPopups/BotoneraPopups.js",
        "u:dev:MediaWiki:BotoneraPopups/WikiArticle.js",
        "u:dev:MediaWiki:BotoneraPopups/UILang/pl.js",
        "u:dev:MediaWiki:BotoneraPopups/code.js"
    ]
});
// END
For Russian text
// BEGIN BotoneraPopups
importArticles({
    type: "script",
    articles: [
        "u:dev:MediaWiki:BotoneraPopups/BotoneraPopups.js",
        "u:dev:MediaWiki:BotoneraPopups/WikiArticle.js",
        "u:dev:MediaWiki:BotoneraPopups/UILang/ru.js",
        "u:dev:MediaWiki:BotoneraPopups/code.js"
    ]
});
// END

And so on.


For improved user experience, if you plan to edit on a wiki whose language is other than English, you should set up additional code listed on /Content language support.

Fine-tuning

The following additional options are not required but may be useful specially for languages other than English:

Namespaces

This is only needed on wikis whose their content language is not set to English.

This script already has built-in functionality to detect namespaces being used on the wiki, which are used to distinguish article from talk page namespaces. In languages other than English namespaces are localized. That's not a problem, since namespace information is already present in the page, but this information lacks the "canonical" namespace name in English. English namespace names are normally not needed, but internally some namespaces (like User) are handled specially to display user-related actions, and if a link using the English namespace is encountered, with no valid canonical namespace information it could not resolve the localized namespace and will treat it as if the namespace is a mere prefix, failing to render the talk page link.

To cover those cases, please add the code provided at Content language support.

Special page aliases

For wikis in languages other than English, links to special pages may fail to be properly recognized to feature the target article instead of the Special page. For example, links to Special:Contributions which would make the popup target the user, or Special:Upload that would make the popup target the file.

To fix that, you should provide a list of Special page aliases. See Content language support for code that you can use for this purpose.

In addition to that, providing a list of Special page aliases for special pages used in the links of the popup would make they point to the default special page name used in that language, instead of the "canonical" special page in English, so it saves a redirect and the link will be marked as visited if it were accessed also from a normal wiki link.

A list of special page aliases could be accessed through the API. For example: [1]

To provide the list of special page aliases, extend (to avoid overwriting other variables) the window.BotoneraPopups.wikisiteinfo object, providing an object with key specialpagealiases which value should match the structure used by the output of the api (see link above). Not all special pages listed on the api need to be defined. Contributions and Upload should be defined. Other specials used in links in the popup may be useful, but not necessary.

See examples at /Content language support.

You can safely place that code before or after calling the code to import the script.

Language

If you follow the steps mentioned on #Installation, you should get a localized version matching your preferred language. If you have rollback rights on the wiki you are on, please see #Custom rollback message prefix for how to localize it, since it's a message that depends on the content language and not the UI language.

To create a new translation, go to MediaWiki:BotoneraPopups/UILang/en.js, copy the source code, and create a new page (changing the en language code with the language you want to localize) with the same contents, replacing the values of each message name. Please have in mind that the code is JavaScript, and each message should be surrounded of single or double quotes (both should match). If you want to use single or double quotes as part of the message, escape that character putting a backslash (\) in front of it, or switch the quotes from single to double or vice-versa.

Then replicate the contents of MediaWiki:BotoneraPopups/Code/en.js on a page with the same prefix, adapting the language code.

Current defined languages are:

  • en (English)
  • es (Español)
  • pl (Polski)

Custom rollback message prefix

The custom rollback message prefix is a message that is inserted before your custom rollback message when you define a custom rollback message. It will provide a "standard" way to identify that your edit was actually a rollback, and to display useful information of the action in the page history. This prefix won't be used if you don't provide a custom rollback message.

The code you need for this may be already listed in Content language support. Continue reading if you want to customize it or you need a custom language not supported already.

The message defaults to Reverted edits by [[Special:Contributions/$1|$1]]:, where $1 is replaced by the name of the user whose edits are being rolled back. Because in many situations we don't have the name of the previous author, it only has the first part of the standard message and not the to last version by $2 part.

To localize it, use the following syntax:

// Create if not exists
if (!window.BotoneraPopups) {
    window.BotoneraPopups = {};
}
 
window.BotoneraPopups.rollbackSummaryPrefix = 'Reverted edits by [[Special:Contributions/$1|$1]]: ';

You can wrap the window.BotoneraPopups.rollbackSummaryPrefix inside an if (window.wgContentLanguage == 'en') { ... }, changing the language code to match the language of the localized message, in case you put that in your global.js and you have rollback rights in wikis with different languages, so every language get the desired localization.

Select what special key needs to be hold for the popup to appear

By default, the CTRL key is required to be hold when entering a link for the popup to appear. If you prefer the ALT or SHIFT key for that (or even a combination of more than one key) you can change that by modifying the displayOnKey property.

This is the default configuration:

// Create if not exists
if (!window.BotoneraPopups) {
    window.BotoneraPopups = {};
}
// Change key binding for opening popup
window.BotoneraPopups.displayOnKey = $.extend(true, window.BotoneraPopups.displayOnKey, {ctrlKey: true, altKey: false, shiftKey: false});

You need to change the value of each key (ctrlKey, altKey, shiftKey) to true for requiring that key to be hold for the popup to appear, or false for not requiring that key. Note that if you set all 3 keys to false the popup will open with the need of any key being hold.

Make the popup to appear directly on key press

By default the popup is only shown when the mouse enters a link while one of the configured keys are pressed. If the mouse is already over a link and you press the key that triggers the popup it won't display. Note that enabling this feature may cause it to appear when you use shortcut keys, like CTRL+C, etc. You could avoid that by changing the keys that trigger the popup to appear.

You can make it to display adding the following code:

// Create if not exists
if (!window.BotoneraPopups) {
    window.BotoneraPopups = {};
}
// Open popup on keypress
if (BotoneraPopups.setDisplayOnKeyDown) {
    BotoneraPopups.setDisplayOnKeyDown(true);
} else {
    BotoneraPopups.displayOnKeyDown = true;
}

Hide the popup when the page loses the focus

If you want the popup to hide itself when the browser window / browser tab loses the focus (for example, when opening links in new windows, etc.) you can use the following code for that purpose:

// Hide BotoneraPopups on page blur
$(function() {
    $(window).blur(function() {
        if (window.BotoneraPopups && window.BotoneraPopups.hide) {
            window.BotoneraPopups.hide();
        }
    });
});

Code

Release notes

(not a new release) (12 January 2015)
  • FANDOM changes the location of the scripts and breaks the templates=expand URL parameter. The code used previously to include this script is broken. This page has been updated to reflect the new way to include the script.
2.5 (17 November 2012)
  • New configuration variable (displayOnKeyDown / setDisplayOnKeyDown) to make the popup to appear directly on keypress over a link instead of having to enter the mouse into the link area.
  • Fixed issue when the popup occasionally moved to the upper left corner.
2.3-2.4 (29 September 2012)
  • Benefit from 1.19 migration: No need to store the relevant user preferences to a session cookie when they're accessible through mw.user.options
2.2 (13 July 2012)
  • Allow user to decide which special key needs to be hold for the popup to appear
2.1 (4 June 2012)
  • Allow late specification of canonical namespaces without a complete list of namespaces
2.0 (4 June 2012)
  • Published on dev.wikia

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.