Extension:Proofread Page/Page viewer/ja

背景
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:


 * A well-known and robust JS API for script and gadget extensibility
 * Zoom and panning that works on desktop and mobile
 * A well-maintained upstream codebase

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:


 * [[File:OOjs UI icon crop.svg]] Select a region of the image for OCR (not merged yet)
 * [[File:OOjs UI icon guide-h.svg]] Add a moveable guide (not merged yet)
 * Zoom in, out and reset zoom to the full page
 * [[File:OOjs UI icon arched-arrow-rtl.svg]] [[File:OOjs UI icon arched-arrow-ltr.svg]] Rotate the image by 90 degrees left or right

Mouse navigation
'''Some of these features are not merged yet: '''

You can scroll and zoom the image as follows:


 * Left click and drag: pan the image
 * Scroll wheel : zoom the image in and out
 * Ctrl + scroll : pan the image up and down
 * Shift + scroll : pan the image side to side
 * Left click : zoom in one step
 * Shift + Left click : zoom out one step

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
The default OpenSeadragon keyboard bindings are used:


 * w, up arrow — move viewport up
 * s, down arrow — move viewport down
 * a, left arrow — move viewport left
 * d, right arrow — move viewport right
 * 0 — zoom / move viewport home
 * -, _ , Shift + W , Shift + up arrow — zoom viewport out
 * =, + , Shift + S , Shift + down arrow — zoom viewport in
 * r — rotate clockwise
 * R — rotate counterclockwise

Marker lines
Not merged yet

The button can be used to add a moveable guide.


 * Click the button to add a guide to the image.
 * Drag a guide to move it
 * Double-click a guide to delete it

Guides will persist when you reload the page, so they can be used to help keep your place while previewing your changes.

Viewer options
There are some options for the page viewer in your preferences, in the  tab, under the   heading.


 * Animation speed
 * This makes the panning and zoom feel smoother. The default is '0', which means there is zero lag and the zoom "snaps" from one level to the next. The OSD default used on many third-party image viewers is 1.2.


 * Zoom step of the viewer
 * This adjusts how "fast" the viewer zooms in and out. The default is 1.2. If you find the zoom too aggressive, you could try to lower it to, say, 1.1.

mw.hook
The following mw.hooks are fired:

mw.proofreadpage
The following objects are presented in the  global object:

mw.proofreadpage.openseadragon
This is a wrapper around the OpenSeadragon API. This object emits two events:

mw.proofreadpage.openseadragon.viewer
The OpenSeadragon viewer object. Only valid after.

This can change, e.g. after the viewer is swapped from horizontal to vertical mode.

mw.proofreadpage.openseadragon.forceInitialize
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:

mw.proofreadpage.openseadragon.getCurrentImage
Get a URL to the current image being displayed on the OpenSeadragon canvas.

This function might error out if called before  is fired.

mw.proofreadpage.getPageViewportControls
 Pending review: 

Returns a jQuery object that holds a  that contains controls for the viewer, which is placed in the WikiEditor toolbar. Scripts can add new controls to this area. Only valid after.

Config variables
The following  variables are added to Page namespace pages. These can be used by gadgets and user scripts.

Resources for OpenSeadragon

 * Demo script adding a minimap to OpenSeadragon using the API
 * OpenSeadragon Viewer documentation

Use by scripts and gadgets
Scripts and gadgets can use the API for anything supported by the OpenSeadragon API via the  object.

Changing the image
The image can be changed by adding an image to the viewer.

For "simple" images (i.e. where you have just an image URL):

You can also directly add an IIIF tiled image source:

Adding buttons to the viewport control toolbar
These can be directly added to the element returned by :

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.

Region selection
This is not merged yet

A region selection module 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:

In this case  is a handler that you should provide.

Events:


 * emitted when a selection starts
 * emitted when a selection ends (the selection is cancelled somehow)

Methods on a :


 * if a selection is active now
 * get the selection rectangle in a co-ordinate system from 0 to 1



関連項目

 * OpenSeadragon API reference: https://openseadragon.github.io/docs/