Class: SearchOverlay

SearchOverlay(params)

new SearchOverlay(params)

Overlay displaying search results

Parameters:
Name Type Description
params Object

Configuration options

Source:
Fires:

Extends

Members

closeOnContentTap

Flag overlay to close on content tap

Properties:
Type Description
boolean
Inherited From:
Source:

defaults

Properties:
Name Type Description
defaults Object

Default options hash.

Properties
Name Type Description
gatewayClass SearchGateway

The class to use to setup an API gateway. FIXME: Should be removed when wikidata descriptions in stable (T101719)

router Router

instance

clearIcon Object

options for the button that clears the search text.

searchContentIcon Object

options for the button that allows you to search within content

searchTerm string

Search text.

placeholderMsg string

Search input placeholder text.

clearMsg string

Tooltip for clear button that appears when you type into search box.

searchContentMsg string

Caption for a button performing full text search of a given search query.

noResultsMsg string

Message informing user that no pages were found for a given query.

searchContentNoResultsMsg string

Used when no pages with matching titles were found.

action string

The value of wgScript

feedback Object

options for the feedback link below the search results

Overrides:
Mixes In:
Source:

events

Source:

fullScreen

Is overlay fullscreen

Properties:
Type Description
boolean
Inherited From:
Source:

hasFixedHeader

Identify whether the element contains position fixed elements

Properties:
Type Description
boolean
Inherited From:
Source:

hideOnExitClick

True if this.hide() should be invoked before firing the Overlay-exit event

Properties:
Type Description
boolean
Inherited From:
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

Properties:
Name Type Description
Specifies Mixed

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

Inherited From:
Source:

templatePartials

Overrides:
Source:

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>
Inherited From:
Source:
Returns:
Type
this

append(…contents) → {this}

Parameters:
Name Type Attributes Description
contents string | Node | Array.<Node> | JQuery <repeatable>
Inherited From:
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>
Inherited From:
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

hide(forceopt) → {boolean}

Detach the overlay from the current view

Parameters:
Name Type Attributes Description
force boolean <optional>

Whether the overlay should be closed regardless of state (see PhotoUploadProgress)

Overrides:
Source:
Returns:

Whether the overlay was successfully hidden or not

Type
boolean

hideKeyboardOnScroll()

Hide the keyboard when scrolling starts (avoid weird situation when user taps on an item, the keyboard hides and wrong item is clicked).

Source:

hideSpinner()

Hide the spinner near to the input field.

Inherited From:
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

onClickClear() → {boolean}

Initialize the button that clears the search field

Source:
Returns:

False to cancel the native event

Type
boolean

onClickOverlayContent()

Tapping on background only should hide the overlay

Source:

onClickOverlayContentDiv(ev)

Stop propagation

Parameters:
Name Type Description
ev jQuery.Event
Source:

onClickResult(ev)

Handle the user clicking a result.

Parameters:
Name Type Description
ev jQuery.Event
Source:

onClickSearchContent()

Initialize 'search within pages' functionality

Source:

onExitClick(ev)

ClickBack event handler

Parameters:
Name Type Description
ev Object

event object

Inherited From:
Source:

onInputInput()

Make sure search header is docked to the top of the screen when the user begins typing so that there is adequate space for search results above the keyboard. (This is only a potential issue when sitenotices are displayed.)

Source:

onTouchMove(ev)

Event handler for touch move, for IOS

Parameters:
Name Type Description
ev Object

Event Object

Inherited From:
Source:

onTouchStart(ev)

Event handler for touchstart, for IOS

Parameters:
Name Type Description
ev Object

Event Object

Inherited From:
Source:

performSearch()

Perform search and render results inside current view. FIXME: Much of the logic for caching and pending queries inside this function should actually live in SearchGateway, please move out.

Source:

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>
Inherited From:
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.

Inherited From:
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:

setupEmulatedIosOverlayScrolling()

Setups an emulated scroll behaviour for overlays in ios.

Inherited From:
Source:

show()

Attach overlay to current view and show it.

Overrides:
Source:

(protected) showHidden(className)

Show elements that are selected by the className. Also hide .hideable elements Can't use jQuery's hide() and show() because show() sets display: block. And we want display: table for headers.

Parameters:
Name Type Description
className string

CSS selector to show

Inherited From:
Source:

showKeyboard()

Trigger a focus() event on search input in order to bring up the virtual keyboard.

Source:

showSpinner()

Shows the spinner right to the input field.

Inherited From:
Source:

stopPropagation(ev)

Stop clicks in the overlay from propagating to the page (prevents non-fullscreen overlays from being closed when they're tapped)

Parameters:
Name Type Description
ev Object

Event Object

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:

Events

hide

Fired when the overlay is closed.

Inherited From:
Source:

search-result-click

Fired when the user clicks a search result

Type:
  • Object
Properties:
Name Type Description
result jQuery.Object

The jQuery-wrapped DOM element that the user clicked

resultIndex number

The zero-based index of the result in the set of results

originalEvent jQuery.Event

The original event

Source:

search-results

Fired when search API returns results

Type:
  • Object
Properties:
Name Type Description
results Array.<Object>

The results returned by the search API

Source:

search-show

Fired after the search overlay is shown

Source:

search-start

Fired immediately before the search API request is sent

Properties:
Name Type Description
data Object

related to the current search

Source: