User:Js/ajaxPreview

From OpenWetWare

Jump to: navigation, search
{{#titleparts:Js/ajaxPreview|1|-1}}
Browsers *
Skins *
Code {{#titleparts:Js/ajaxPreview|1|-1}}.js
Updated 2009-7-26; Expression error: unrecognised word "abs"
Developer   AlexSm

The script adds new preview and changes Ajax update buttons:

  • they are faster than standard buttons,
  • they retain the text cursor position and undo (Ctrl-Z) history,
  • and preview button uses less traffic.


Note that the standard «Show preview» is still required:

  • to update the preview of interwikis, categories, edit summary, and the list of used templates;
  • after you insert <source lang="xxx"> or <categorytree> for the first time.


Installation

Add this to your monobook.js (unless you use some other skin)
importScript('User:Js/ajaxPreview.js')


Configuration

By default the new buttons:

  • are placed on the right from the toolbar:

BIAb........................   previewchanges

  • capture p and v accesskeys from the standart buttons.
  • get names from the standard buttons (using last word).

This can be changed with the following parameters in your monobook.js.

Position:

ajaxPreviewPos = 'left' //buttons on the left
ajaxPreviewPos = 'bottom' //buttons on the bottom, replacing standard

Then standard buttons are then moved to the right and marked with ">": Save page Show preview> Show changes>

Accesskeys:

ajaxPreviewKey = 'o' //"preview" button accesskey
ajaxDiffKey = 'b' //"changes" button accesskey

Use empty string '' to disable accesskey.

Button text:

ajaxPreviewButton = 'Ω' //"preview" button text
ajaxDiffButton = 'Δ' //"changes" button text

Scrolling:

ajaxPreviewScrollTop = true //scroll to the top of preview/changes area after each update


Compatibility with scripts

The script automatically calls sortable and collapsible JavaScript code after every preview update.

You can make it call any custom userscripts by defining ajaxPreviewExec() function. For example, if you use NavPopups and want popups to appear in the Ajax-updated preview, use the following code:

ajaxPreviewExec = function(previewArea){ //code to execute after each preview update
  if (window.setupTooltips) setupTooltips(previewArea)
}


Notes

  • Script should work in all modern browsers, except Firefor 3 early betas.
  • Script was tested in Firefox 1.5, 2 and 3, Opera 9.27 and 9.52, IE 6 and 7.
  • «Preview» button uses &live index.php parameter, just like Live preview which is disabled here.
  • «Changes» button has to submit and receive the full page, since the MediaWiki cannot return "raw" changes.

ru:Википедия:Гаджеты/Ajax предпросмотр

Personal tools