Class: PhotoList

PhotoList(options)

new PhotoList(options)

Creates a list of photo items

Parameters:
Name Type Description
options Object

Configuration options

Properties
Name Type Description
eventBus OO.EventEmitter

Object used to listen for scroll:throttled events

url string

for overriding default URI for API queries

Source:

Extends

Members

defaults

Properties:
Name Type Description
defaults Object

Default options hash.

Properties
Name Type Description
spinner string

HTML of the spinner icon.

api mw.Api

instance of an api

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:

parseHTML

See parseHTML method of util singleton

Inherited From:
Source:

tagName

Name of tag that contains the rendered template

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

template

Overrides:
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

$(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

appendPhotos(photosData)

Append an array of photos to the view.

Parameters:
Name Type Description
photosData Array

Array of objects describing a new {PhotoItem}

Source:

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.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

enableScroll()

Enables infinite scroll if it's disabled

Source:

hideEmptyMessage()

Hides the message saying the list is empty FIXME: Should be handled in template, not a method.

Source:

hideSpinner()

Hides loading spinner

Source:

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:

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

isEmpty() → {boolean}

Check to see if the current view is an empty list.

Source:
Returns:

whether no images have been rendered

Type
boolean

postRender()

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

Overrides:
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:

showEmptyMessage()

Renders an empty message prior to the list. FIXME: Should be handled in template, not a method.

Source:

showSpinner()

Shows loading spinner

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:

updateEmptyUI()

Shows/hides empty state if PhotoList is empty.

Source: