Class: Page

Page(options)

new Page(options)

Mobile page view object

Parameters:
Name Type Description
options Object

Configuration options

Source:

Extends

Members

(static) HEADING_SELECTOR

Selector for matching headings

Source:

defaults

Properties:
Name Type Description
defaults Object

Default options hash.

Properties
Name Type Description
id number

Page ID. The default value of 0 represents a new or missing page. Be sure to override it to avoid side effects.

title string

Title of the page. It includes prefix where needed and is human readable, e.g. Talk:The man who lived.

displayTitle string

HTML title of the page for display. Falls back to defaults.title (escaped) if no value is provided. Must be safe HTML!

namespaceNumber number

the number of the namespace the page belongs to

protection Object

List of permissions as returned by API, e.g. [{ edit: ['*'] }]

sections Array

Array of {Section} objects.

isMainPage boolean

Whether the page is the Main Page.

isMissing boolean

Whether the page exists in the wiki.

thumbnail Object

thumbnail definition corresponding to page image

Properties
Name Type Description
isLandscape boolean

whether the image is in landscape format

width number

of image in pixels.

height number

of image in pixels.

source string

url for image

Overrides:
Mixes In:
Source:

isTemplateMode

Tells the View to ignore tagName and className when constructing the element and to rely solely on the template

Properties:
Name Type Description
isTemplateMode boolean
Inherited From:
Source:

tagName

Name of tag that contains the rendered template

Properties:
Name Type Description
tagName string
Inherited From:
Source:

template

Properties:
Name Type Description
Specifies Mixed

the template used in render(). Object|string|HoganTemplate

Inherited From:
Source:

templatePartials

Specifies partials (sub-templates) for the main template. Example:

Properties:
Type Description
Object
Inherited From:
Source:
Example
// example content for the "some" template (sub-template will be
    // inserted where {{>content}} is):
    // <h1>Heading</h1>
    // {{>content}}

    oo.mfExtend( SomeView, View, {
      template: M.template.get( 'some.hogan' ),
      templatePartials: { content: M.template.get( 'sub.hogan' ) }
    }

Methods

(static) newFromJSON(resp) → {Page}

Create a Page object from an API response.

Parameters:
Name Type Description
resp Object

as representing a page in the API

Source:
Returns:
Type
Page

$(query) → {JQuery.Object}

Wraps this.$el.find, so that you can search for elements in the view's ($el's) scope.

Parameters:
Name Type Description
query string

A jQuery CSS selector.

Inherited From:
Source:
Returns:

jQuery object containing results of the search.

Type
JQuery.Object

after(…contents) → {this}

Parameters:
Name Type Attributes Description
contents string | Node | Array.<Node> | JQuery <repeatable>
Overrides:
Source:
Returns:
Type
this

append(…contents) → {this}

Parameters:
Name Type Attributes Description
contents string | Node | Array.<Node> | JQuery <repeatable>
Overrides:
Source:
Returns:
Type
this

appendTo(target) → {this}

Parameters:
Name Type Description
target string | Node | Array.<Node> | JQuery
Inherited From:
Source:
Returns:
Type
this

before(…contents) → {this}

Parameters:
Name Type Attributes Description
contents string | Node | Array.<Node> | JQuery <repeatable>
Overrides:
Source:
Returns:
Type
this

delegate(eventName, selector, listener)

Add a single event listener to the view's element (or a child element using selector). This only works for delegate-able events: not focus, blur, and not change, submit, and reset in Internet Explorer.

Parameters:
Name Type Description
eventName string
selector string
listener function
Inherited From:
Source:

delegateEvents(events)

Set callbacks, where this.options.events is a hash of

{ 'event selector': 'callback' }

{ 'mousedown .title': 'edit', 'click .button': 'save', 'click .open': function(e) { ... } }

pairs. Callbacks will be bound to the view, with this set properly. Uses event delegation for efficiency. Omitting the selector binds the event to this.el.

Parameters:
Name Type Description
events Object

Optionally set this events instead of the ones on this.

Inherited From:
Source:

detach(selectoropt) → {this}

Parameters:
Name Type Attributes Description
selector string <optional>
Inherited From:
Source:
Returns:
Type
this

getDisplayTitle() → {string}

Retrieve the title that should be displayed to the user

Source:
Returns:

HTML

Type
string

getId() → {number}

Return page id

Source:
Returns:
Type
number

getLeadSectionElement() → {jQuery.Object|null}

Get the lead section of the page view.

Source:
Returns:
Type
jQuery.Object | null

getNamespaceId() → {number}

return namespace id

Source:
Returns:

namespace Number

Type
number

Returns a jQuery object representing all redlinks on the page.

Source:
Returns:
Type
jQuery.Object

getRevisionId() → {number}

Return the latest revision id for this page

Source:
Returns:
Type
number

getSection(id) → {Section}

FIXME: Change function signature to take the anchor of the heading

Parameters:
Name Type Description
id string

of the section as defined by MobileFormatter. Note, that currently, this is different from the PHP parser in that it relates to top-level sections. For example, mf-section-1 would relate to section 1. See FIXME.

Source:
Returns:
Type
Section

getSections() → {Array}

Obtain the list of high level (and grouped) sections. Note that this list will not include subsections.

Source:
Returns:

of Section instances

Type
Array

getThumbnails() → {Array.<Thumbnail>}

Return all the thumbnails in the article. Images which have a class or link container (.image|.thumbimage) that matches one of the items of the constant BLACKLISTED_THUMBNAIL_CLASS_SELECTORS will be excluded. A thumbnail nested inside one of these classes will still be returned. e.g. <div class="noviewer"><a class="image"><img></a></div> is not a valid thumbnail <a class="image noviewer"><img></a> is not a valid thumbnail <a class="image"><img class="noviewer"></a> is not a valid thumbnail

Source:
Returns:
Type
Array.<Thumbnail>

getTitle() → {string}

Return prefixed page title

Source:
Returns:
Type
string

initialize(options)

Run once during construction to set up the View

Parameters:
Name Type Description
options Object

Object passed to the constructor.

Properties
Name Type Attributes Description
events Object.<string, string> <optional>
Inherited From:
Source:

inNamespace(namespace) → {boolean}

Determine if current page is in a specified namespace

Parameters:
Name Type Description
namespace string

Name of namespace

Source:
Returns:
Type
boolean

insertAfter(target) → {this}

Parameters:
Name Type Description
target string | Node | Array.<Node> | JQuery
Inherited From:
Source:
Returns:
Type
this

insertBefore(target) → {this}

Parameters:
Name Type Description
target string | Node | Array.<Node> | JQuery
Inherited From:
Source:
Returns:
Type
this

isMainPage() → {boolean}

Checks whether the current page is the main page

Source:
Returns:
Type
boolean

isTalkPage() → {boolean}

Determines if current page is a talk page

Source:
Returns:

Whether the page is a talk page or not

Type
boolean

isWatched() → {boolean}

Checks whether the current page is watched

Source:
Returns:
Type
boolean

isWikiText() → {boolean}

Determines if content model is wikitext

Source:
Returns:
Type
boolean

parseHTML(html) → {jQuery.Object}

See parseHTML method of util singleton

Parameters:
Name Type Description
html string

to turn into a jQuery object.

Inherited From:
Source:
Returns:
Type
jQuery.Object

postRender()

Function called after the view is rendered. Can be redefined in objects that extend View.

Inherited From:
Source:

prepend(…contents) → {this}

Parameters:
Name Type Attributes Description
contents string | Node | Array.<Node> | JQuery <repeatable>
Overrides:
Source:
Returns:
Type
this

prependTo(target) → {this}

Parameters:
Name Type Description
target string | Node | Array.<Node> | JQuery
Inherited From:
Source:
Returns:
Type
this

preRender()

Function called before the view is rendered. Can be redefined in objects that extend View.

Overrides:
Source:

remove(selectoropt) → {this}

Parameters:
Name Type Attributes Description
selector string <optional>
Inherited From:
Source:
Returns:
Type
this

render(data)

Fill this.$el with template rendered using data if template is set.

Parameters:
Name Type Description
data Object

Template data. Will be merged into the view's options

Inherited From:
Source:

undelegate(eventName, selector, listener)

A finer-grained undelegateEvents for removing a single delegated event. selector and listener are both optional.

Parameters:
Name Type Description
eventName string
selector string
listener function
Inherited From:
Source:

undelegateEvents()

Clears all callbacks previously bound to the view by delegateEvents. You usually don't need to use this, but may wish to if you have multiple views attached to the same DOM element.

Inherited From:
Source: