The ProofreadPage extension uses the popular OpenSeadragon (OSD) library to provide a zoomable image viewer in the Page namespace and the Pagelist editor. This provides various useful features:
OpenSeadragon replaced the previous home-made jQuery implementation in release 1.38.0-wmf.9.
The main viewport controls are found on the top right of the image viewer:
From left to right:
Some of these features are not merged yet: Gerrit change 740369
You can scroll and zoom the image as follows:
The middle mouse button switches the normal and Ctrl-key modes (so Ctrl+scroll becomes zoom and normal scroll becomes pan). The cursor changes to identify which mode you are in.
Keyboard navigation[edit]The default OpenSeadragon keyboard bindings are used:
Not merged yet
The button can be used to add a moveable guide.
Guides will persist when you reload the page, so they can be used to help keep your place while previewing your changes.
There are some options for the page viewer in your preferences, in the Editing
tab, under the Proofreading interface options
heading.
The following mw.hooks are fired:
Hook Description Argumentsext.proofreadpage.osd-controller-availiable
Fired when the OpenSeadragon controller has been initialized.
osdController
the OpenSeadragon controller object (also available as mw.proofreadpage.openseadragon
)ext.proofreadpage.osd-no-image-found
Fired when the OpenSeadragon controller fails to initialized, can be used to show error messages.
No arguments
The following objects are presented in the mw.proofreadpage
global object:
This is a wrapper around the OpenSeadragon API. This object emits two events:
Event Description Argumentsprp-osd-before-creation
Fired just before the OpenSeadragon is initialized
osdParams
the OpenSeadragon parameters object. This contains the configuration that will be sent to OpenSeadragon and can be modified by userscripts to customize how OpenSeadragon looks/feels. A list of all potential values can be found in the OpenSeadragon documentation.prp-osd-after-creation
Fired when the OpenSeadragon viewer has initialized and the images loaded userscripts can use this event to hook into and listen for OpenSeadragon specific 'events', such as panning/zooming actions etc.
viewer
the OpenSeadragon viewer object (also availiable as mw.proofreadpage.openseadragon.viewer
)The OpenSeadragon viewer object. Only valid after prp-osd-after-creation
.
This can change, e.g. after the viewer is swapped from horizontal to vertical mode.
mw.proofreadpage.openseadragon.forceInitialize()[edit]This will force OpenSeadragon to initialize, causing all the events to be fired and the hooks to be run.
For a userscript making changes to OpenSeadragon, this allows changes to be applied immediately.
For example:
function initialize( openseadragon ) { openseadragon.on( 'prp-osd-before-creation', function ( osdParams ) { // Make your changes here, for example, here we set the `showNavigator` parameter to true osdParams['showNavigator'] = true; } ); openseadragon.on( 'prp-osd-after-creation', function ( viewer ) { // Do something // .... // .... } ); // Force Openseadragon to update with the changes openseadragon.forceInitialize(); }mw.proofreadpage.openseadragon.getCurrentImage()[edit]
Get a URL to the current image being displayed on the OpenSeadragon canvas.
This function might error out if called before prp-osd-after-creation
is fired.
Pending review: Gerrit change 736203
Returns a jQuery object that holds a <div>
that contains controls for the viewer, which is placed in the WikiEditor toolbar. Scripts can add new controls to this area. Only valid after ext.proofreadpage.osd-viewer-ready
.
The following mw.config
variables are added to Page namespace pages. These can be used by gadgets and user scripts.
prpFormattedPageNumber
The formatted page number (usually what's actually written on the page) string "20"
prpImageFullSize
The URL of the full-size page image (the largest image of the current page) string "//upload.wikimedia.org/wikipedia/commons/thumb/a/a8/My_mortal_enemy_-_1926.djvu/page20-3893px-My_mortal_enemy_-_1926.djvu.jpg"
prpImageThumbnail
The URL of the thumbnail page image (the size used in the page viewer) string "//upload.wikimedia.org/wikipedia/commons/thumb/a/a8/My_mortal_enemy_-_1926.djvu/page20-1024px-My_mortal_enemy_-_1926.djvu.jpg"
prpIndexFields
The values of any index fields in the index data config object marked js: true
object { Progress: "C", Transclusion: "no", Footer: "\n", … }
prpIndexTitle
The name of the associated index page string "Index:My mortal enemy - 1926.djvu"
prpPageQuality
The current quality level of the page (0-4, 1 if the page doesn't exist yet) integer 1
prpPageQualityUser
The name of the last user to set the quality string "SomeUser"
Resources for OpenSeadragon[edit]
Use by scripts and gadgets[edit]
Scripts and gadgets can use the API for anything supported by the OpenSeadragon API via the mw.proofreadpage.openseadragon.viewer
object.
The image can be changed by adding an image to the viewer.
For "simple" images (i.e. where you have just an image URL):
mw.proofreadpage.openseadragon.on( 'prp-osd-before-creation', function ( osdParams ) { osdParams['tileSources'] = [{url: 'image_url_here'}]; } ); mw.proofreadpage.openseadragon.forceInitialize();
You can also directly add an IIIF tiled image source:
mw.proofreadpage.openseadragon.on( 'prp-osd-before-creation', function ( osdParams ) { osdParams['tileSources'] = iiif_json_source; } ); mw.proofreadpage.openseadragon.forceInitialize();Adding buttons to the viewport control toolbar[edit]
These can be directly added to the element returned by mw.proofreadpage.getPageViewportControls()
:
var button = new OO.ui.ButtonWidget( { icon: 'home', // choose an icon framed: false, classes: [ 'tool' ] } ); mw.proofreadpage.getPageViewportControls().append( button );
Tools do not have to go in this toolbar to interact with the OpenSeadragon viewer; they can also go in the sidebar, the normal toolbar (for which the WikiEditor toolbar configuration system can be used) or anywhere else in the DOM.
This is not merged yet Gerrit change 741125
A region selection module (ext.proofreadpage.page.regionselection
) is provided that allows scripts to add a simple rectangular region selection.
The region selection is communicated by OOUI events. Instantiate a region selector and bind handlers like this:
mw.loader.using( 'ext.proofreadpage.page.regionselection', function( require ) { var RegionSelection = require( 'ext.proofreadpage.page.regionselection' ); var regionSelector = new RegionSelection(); mw.hook( 'ext.proofreadpage.osd-viewer-ready' ).add( function ( viewer ) { regionSelector.register( viewer ); regionSelector.connect( this, { [ regionSelector.events.selectionStart ]: [ 'onRegionToggle', true ], [ regionSelector.events.selectionEnd ]: [ 'onRegionToggle', false ] } ); } ); // start a selection regionSelector.toggleSelection( true ); } );
In this case onRegionToggle
is a handler that you should provide.
Events:
selectionStart
emitted when a selection startsselectionEnd
emitted when a selection ends (the selection is cancelled somehow)Methods on a RegionSelector
:
isActive()
if a selection is active nowgetSelection()
get the selection rectangle in a co-ordinate system from 0 to 1RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4