Wikipedia:Tools/Navigation popups
From Wikipedia, the free encyclopedia
Navigation popups offer easy access to article previews and several Wikipedia functions in popup windows which appear when you hover the mouse over links.
Quick installation: add {{subst:navpop}} to your monobook.js (or equivalent file if you use a different skin). See below for full installation instructions.
If you're having trouble, you may like to peruse some frequently asked questions.
Contents |
[edit] Features
- Preview the first part of the article text (kudos to User:Pilaf for his Live Preview script which makes this possible)
- Preview images from image links
- Preview the first image on each article
- Preview diffs in watchlist, history and related changes.
- Preview selected wikilinks when editing (use the mouse to select one wikilink)
- One click revert of vandalism from history browser (see image)
- Tells you about redirects, stubs and disambiguation pages
- Gives page information like size, number of links, number of images, number of categories and page age
- Should work on all Wikimedia wikis
- One-click access to
- edit page
- user contributions
- Interiot's tool (edit count)
- email user
- history
- watch and unwatch
- view or edit talk page
- what links here
- related changes
- for administrators, protect and unprotect, delete and block user
- user log and block log
- list subpages of user pages
- Wikipedia search, global Wikipedia search and Google search
- Shortcut keys (optional)
- Automatically fix links to bypass redirects and disambiguation pages (optional)
[edit] Installation
You must have a user account in order to install and use the Navigation popups feature. If you do not have an account you will need to create one and log in.
The next step is to add {{subst:navpop}} to your monobook.js page. This will add the following code to your .js file:
// [[User:Lupin/popups.js]] document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
Note: If you are using a skin other than MonoBook (the default), the relevant file you will need to edit is listed below.
- Classic skin: standard.js
- Cologne Blue: cologneblue.js
- Chick: chick.js
- Simple: simple.js
- Nostalgia: nostalgia.js
- MySkin: myskin.js
After saving the page, clear your browser's cache (hold SHIFT key while reloading/refreshing page; on Mozilla Firefox Shift-Control-R). Assuming that you have not disabled javascript in your browser, a popup should appear whenever you hover your mouse over an internal link in Wikipedia. To install the script on the commons or wiktionary, repeat this procedure on those wikis. To uninstall the script, delete the above lines from the same page and clear your browser's cache.
[edit] Usage guide
This tool generates "popup hints" when you hover the mouse pointer over active links and images.
Many of the arguably most important features can be used from the watchlist.
- hover over a diff link to show a summary of the difference that edit has made
- hover over a link to an article version to show a short excerpt of the version
There should also be some "navigation links" which access many functions including one-click reversion, editing that page and so on. These may appear in the popup itself, or may be hidden in an "actions" menu depending on your browser and your settings.
In normal articles:
- hold the mouse over links pulls up a short excerpt of the linked-to article, then hover over the actions link if necessary to see more commands
- if you hold the shift key then you can drag the popup around
[edit] Configuration (optional)
[edit] Changing the appearance of your popups
By editing your user CSS file, you can change the appearance of the popups. Your user CSS file has exactly the same name as the javascript file, but with "css" instead of "js" at the end. So for most people, the file to edit is monobook.css.
Here is an example which gives an orange-flavoured popup with a border and changes the font used. This makes the popups look pretty silly, but it shows the sort of thing you can do if you feel like it.
.navpopup { background-color: #FFBE20 !important; font-family: serif !important; color: #404 !important; font-size: medium !important; }
[edit] Options
There are some options that you can set. To do so, edit your user javascript file (such as monobook.js) and add a line of the form
- option = value;
where option and value are chosen from the table below. For example, to prevent all downloading and turn on admin links, you need something like this in your javascript file:
// [[User:Lupin/popups.js]] - please include this line document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); simplePopups=true; popupAdminLinks=true;
|
||
Option | Values* | Description |
---|---|---|
[edit] | ||
popupDelay | decimal number, 0.5 | The number of seconds before popups appear. |
popupHideDelay | decimal number, 0.5 | The approximate number of seconds between the mouse leaving a popup and its disapperance. |
simplePopups | true, false | If you just want the links or find the amount of bandwidth consumed too great, then set this to true. No data will be downloaded and the popups will just consist of a list of links. |
popupStructure | 'original', 'fancy', 'fancy2', 'menus', 'shortmenus', 'lite', 'nostalgia' | Select the structure of the popups. The 'original' setting, which is the default if simplePopups is true (or if your browser is known not to support menus), has all the navigation links in the popup itself; 'fancy' and fancy2 are variants of this. The 'menus' setting, which is the default if simplePopups is not true, puts the navigation links in popup menus which appear when you mouseover the links beside the popup title. 'shortmenus' is a less cluttered version of 'menus' with fewer links. Finally, 'nostalgia' is a simple menuless structure, while 'lite' is a very simple structure, with just the preview and no navigation links at all.
Note that to set this variable, you need to include the single quotes, e.g. popupStructure='fancy';. |
popupActionsMenu | true, false | When using menus, you can either have the title link in the popup generating a menu (if this is set to false) or a separate "actions" menu (if this is set to true, the default). |
popupImages | true, false | If this is false then images are never displayed. |
popupSubpopups | true, false | If this is true then popups are generated for links in previews. |
popupOnEditSelection | true, false | If this is true then popups are generated for selected wikilinks when editing. |
popupAdminLinks | true, false | If this variable is set to true then links which administrators can use to block people, delete pages and protect or unprotect pages will appear in the popups. |
popupShortcutKeys | true, false | If this variable is set to true then you can focus some of the links in the popups quickly by pressing keys. When you hover the mouse over a link with a shortcut, the shortcut key appears at the end of the popup hint. For example, in Firefox or Opera, to quickly edit an article in a new tab you can type 'e Control-Enter'. Pressing escape should hide the popup, too. |
popupFixRedirs | true, false | If this variable is set to true then you can automatically "fix" links to redirect pages by clicking on the "Redirects" link. Note: you probably don't want to "fix" such links every time you come across them, and you definitely don't want to go on a hunt for them to "fix" them. See /About fixing redirects. |
popupWatchRedirredPages | true, false, null | If this variable is set to true then fixed redirect pages will always be watched; if it's false, then they'll always be unwatched. If it's null, then the page will be watched or unwatched according to the settings in your user preferences. |
popupRedirAutoClick | 'wpSave', 'wpPreview', 'wpDiff' | The button which is automatically pressed when fixing redirects. |
popupRedlinkRemoval | true, false | If this variable is set to true then you can automatically remove links to non-existent pages (so-called "red links") by selecting "Remove this link". |
popupFixDabs | true, false | If this variable is set to true then you can automatically "fix" links to disambiguation pages by clicking one of the links at the very bottom of the popup. |
popupAllDabsStubs | true, false | If this variable is set to false then only pages that look like stubs or disambiguation pages in the article namespace are treated specially. (Setting this to true can lead to lots of false positives). |
popupWatchDisambiggedPages | true, false, null | If this variable is set to true then fixed dab pages will always be watched; if it's false, then they'll always be unwatched. If it's null, then the page will be watched or unwatched according to the settings in your user preferences. |
popupNavLinks | true, false | If this is true then navigation links are displayed. If false, then these are switched off. |
popupLastEditLink | true, false | Whether the popup should contain a "lastEdit" link. |
popupHistoricalLinks | true, false | When hovering over links to old revisions and diff links, extra links such as "editOld" are generated if this is true. Otherwise, you get the same links as when hovering over an ordinary link. |
popupPreviews | true, false | If this is true and you haven't set simplePopups, then a preview of the first part of the article will appear. (Reports of pages for which this is done badly are most welcome). If false, then this is switched off. |
popupSummaryData | true, false | If this is true summary data for the target page is displayed. If false, then this is switched off. |
popupLastModified | true, false | If true then the age of the page is displayed in the summary data. This is the amount of time that has elapsed since the article was edited. |
popupDiffDates | true, false | If true, the dates of the revisions being compared are shown when previewing diffs. |
popupImageLinks | true, false | If true, pages linking to an image should appear in the preview. This currently does not work for commons images. |
popupOnlyArticleLinks | true, false | If true, then popups are only generated for links in the article. Otherwise, many other links (such as Edit, Help) get popups too. |
imagePopupsForImages | true, false | By default, preview images are loaded even when hovering over visible images. Setting this to false turns that off. |
popupMaxWidth | 350, an integer or false | The maximum width of the popup in pixels. Setting this to false means the popup will expand to accommodate its contents. |
popupInitialWidth | an integer or false | The initial width of the popup in pixels. Setting this to false means the popup will initially be the size needed to accommodate its initial contents. |
popupEditCounterTool | "kate", "interiot", "custom" | The edit counter tool to use, chosen from Kate's tool, Interiot's tool or a custom url defined by popupEditCounterUrl. |
popupEditCounterUrl | "" | The url for a custom edit counter. You can use replaceable parameters in this url: $1 will be replaced with the username, and $2 with the database name (for example, enwiki_p). |
popupDragHandle | false, 'popupTopLinks', ... | The name of an element by which the popup can be dragged without holding the shift key. If false, then the popup can be dragged using the shift key instead. |
popupAdjustDates | true, false | If true, then dates in history, diff and user contributions previews are adjusted according to the settings in your user preferences. |
popupThumbAction | "imagepage", "sizetoggle", "linkfull" | This controls what happens when you click the image in a preview. "imagepage" takes you to the image page (and will generate a subpopup when you hover over the image), unless the popup is generated for the image page; "sizetoggle" means the image size is toggled on click, and "linkfull" means that the image links directly to the full size version.
|
Edit summaries | [edit] | |
popupRevertSummary | a string | The edit summary used when reverting and not using a queried revert summary (see below). The first %s appearing in this string is replaced with the revision ID of the page being reverted to. |
popupRevertSummaryPrompt | true, false | If true, you will be given the chance to change the default revert summary with each reversion. |
popupQueriedRevertSummary | a string | The edit summary used when reverting and using the query interface to get information about the reversion. A $1, $2, $3 in the string are replaced with the revision ID, the timestamp and the editor corresponding to the revision being reverted to. |
popupQueriedRevertToPreviousSummary | a string | The edit summary used when reverting using diff links such as those found on user contributions pages and using the query interface to get information about the reversion. A $1, $2, $3 in the string are replaced with the revision ID, the timestamp and the editor corresponding to the revision immediately after the revision being reverted to. |
popupFixRedirsSummary | a string | The edit summary used when fixing redirects. The first %s appearing in this string is replaced with the redirect page, and the second %s is replaced with the target page. |
popupFixDabsSummary | a string | The edit summary used when disambiguating links. The first %s appearing in this string is replaced with the disambiguation page, and the second %s is replaced with the target page. |
popupRedlinkSummary | a string | The edit summary used when removing red links. The first %s appearing in this string is replaced with the red link name.
|
Preview options | [edit] | |
popupHistoryPreviewLimit | an integer, 25 | Preview at most this many edits from the top of the page's history. |
popupCategoryMembers | true, false | Whether or not to preview members of categories. |
popupPreviewHistory | true, false | Whether or not to generate special previews for links to history pages. |
popupContribsPreviewLimit | an integer, 25 | Preview at most this many user contributions. |
popupPreviewKillTemplates | true, false | If true, templates referred to in an article are simply deleted from previews; otherwise, they're shown as raw wikitext. |
popupPreviewRawTemplates | true, false | If true, template pages (that is, pages in the Template: namespace) are previewed entirely as raw wikitext; otherwise, an attempt is made to render them in the preview. |
popupPreviewFirstParOnly | true, false | If true, previews are restricted to the first paragraph of the article. |
popupMaxPreviewSentences | an integer, 4 | The maximum number of sentences to extract from something approximating the beginning of an article for the preview. |
popupMaxPreviewCharacters | an integer, 600 | The maximum number of characters to extract from something approximating the beginning of an article for the preview.
|
Technical options | [edit] | |
popupNavLinkSeparator | string, ' ⋅ ' |
HTML inserted between the navigation links. This defaults to ' • ' in Konqueror and to ' · ' in Microsoft browsers, as they don't appear to like the ⋅ character. |
popupAppendRedirNavLinks | true, false | If true, then a new set of navigation links is generated for the target of redirects; if false, then you're warned about the redirect but no navigation links are generated. This does nothing if popupNavLinks is false. |
removeTitles | true, false | The titles (the default popup hints) of links are moved to the main link of the popup if this is true. If this is false then they're not. |
popupLazyDownloads | true, false | If true, then downloads are not performed before the popup is shown. If false, then they are started as soon as you mouseover a link. |
popupLazyPreviews | true, false | If true, then previews are not generated before the popup is shown. If false, then they are generated as soon as the necessary data is available.
|
Experimental options | [edit] | |
The following options are not thoroughly tested and/or are not yet documented: popupCookies, popupExtraUserMenu, popupLinksNewWindow, popupHistoryLimit, popupDiffDatePrinter, popupExtendedRevertSummary, popupTimeOffset, popupPreviewCutHeadings. |
*Default values are listed in bold
More options may be added, and requests for more configurability are welcome.
[edit] Advanced customization
You can define custom filters for articles. These are javascript functions which are run after the page statistics are generated, and their output is appended (as HTML) to that part of the popup. (Note that if simplePopups is true or popupSummaryData is false, then nothing will be displayed).
The way to set this up is to write a filter function which accepts a string (the wikitext of the article) as input, and returns a fragment of HTML. Repeat for as many filters as you want, and then create an array extraPopupFilters which contains all of the functions, in the order in which you want them to be run.
For example, let's say you want to be told whenever the wikitext of an article contains a table written using HTML tags rather than wiki markup. One way to do this is to add the following to your user javascript file:
// initialize the array - only do this once extraPopupFilters=[]; // define the function function popupFilterHtmlTable (wikiText) { if (/<table/i.test(wikiText)) return '<table>'; else return ''; }; // add the function to the array (you can repeat this for lots of functions) extraPopupFilters.push(popupFilterHtmlTable);
Then when a popup is generated for a page containing an HTML table, you should see <table> in the popup. (It may also appear for other pages, such as this page. Correcting this defect is left as an exercise for the reader).
[edit] Translations
Please see this page for translations of the script interface and of this page into other languages. You'll also find instructions for creating a translation yourself.
[edit] Browser problems
[edit] Safari
Some people have found that Safari crashes a lot when running this script. Lupin would be interested to hear if this is still the case or not, and would greatly welcome assistance from someone who knows some javascript in getting to the bottom of these problems.
The menus do not function correctly in the most recent releases of Safari. Using a Webkit nightly build may give correctly functioning menus, but note that WebKit nightlies are notoriously unstable.
[edit] Opera
Older versions of Opera have bugs which prevent the menus from functioning correctly. Using a current version (9.0 or higher) should give correctly functioning menus, but you may still experience problems sometimes, with popups not loading, or not disappearing after the mouse is moved away.
[edit] Feedback
Bugs, problems, suggestions and enhancements to Lupin, please.
I have set up a page where you can list pages with incorrect previews.
[edit] Development version
This tool remains under development. The very latest version is available at User:Lupin/popupsdev.js and it sees new features before the stable version. Be warned that it does break every so often, though. If you do want to install it, you can type
{{subst:js|User:Lupin/popupsdev.js}}
into your user javascript file and delete your current popups installation from that file.
[edit] See also
- Wikipedia:Easy navigation – Proposed guideline
- Help:User style – Customize Wikipedia page layout
[edit] Credits and external links
This tool depends on some other peoples' work:
- User:Pilaf/InstaView (née Live Preview) by Pilaf
- a Javascript MD5 hash function by Paul Johnston and others, available here
- domdrag by Aaron Boodman
- An implementation of a diff algorithm by John Resig
Older versions of the tool used overlib by Erik Bosrup.
[edit] Wikipedians who have helped
- Brian0918 - a little code and lots of inspiration
- Eddideigel - translation work
- IceKarma - aborting download code, making much better use of bandwidth
- Mike Dillon - the page age code
- Yurik - with his fantastic mediawiki BotQuery extension
- Zocky - the menus
- Zyxw - preview enhancements
- ....and many more with helpful suggestions, comments and bug reports