Class: FilterOption

FilterOption(filterTreeType)

A single filter option. A filter option is a field to filter by, like color, size... Contains list of filter items, and clear button, apply button, search box, scroll bar, view more elements.

Constructor

new FilterOption(filterTreeType)

Creates a new FilterOption
Parameters:
Name Type Description
filterTreeType FilterTreeEnum 'vertical' or 'horizontal'
Source:

Extends

Members

children :Array

Array of child components
Type:
  • Array
Overrides:
Default Value:
  • []
Source:

filterItems :Map.<String, FilterOptionItem>

A Map of filter option items id: filter item key value: FilterOptionItem instance
Type:
Source:

parent :Component

The parent component
Type:
  • Component
Overrides:
Default Value:
  • null
Source:

Methods

_callAllBindEvents()

Bind events on the component (include all child-components)
Overrides:
Source:

_callAllInit()

Initialize the component (include all child-components)
Overrides:
Source:

_callAllRender()

Render the component (include all child-components)
Overrides:
Source:

addComponent(childComponent)

Add the child component into a component
Parameters:
Name Type Description
childComponent Object The child component
Overrides:
Source:

afterBindEvents()

After bind evnets on the component
Overrides:
Source:

afterInit()

After initialize callback
Overrides:
Source:

afterRender()

After reder component callback
Overrides:
Source:

beforeBindEvents()

Before bind events on component callback
Overrides:
Source:

beforeInit()

Before initialize callback
Overrides:
Source:

beforeRender()

Before reder component callback
Overrides:
Source:

bindEvents()

Bind events on the component
Overrides:
Source:

getBlockContentTemplate()

Get the content html template of the filter option Different filter option type (list, box, swatch, range...) has different content template. This function is overriden in every filter option type that inherits this class.
Source:

getNumberAppliedFilterItems() → {Number}

Get the number of applied filter items in this filter option.
Source:
Returns:
number of applied filter items
Type
Number

getTemplate() → {string}

Get the filter option template. Depending on its filterTreeType, it returns different templates for 'vertical' and 'horizontal'
Source:
Returns:
Raw html template for a single filter option
Type
string

init()

Initialize component
Overrides:
Source:

isBindEvents()

Returns whether or not binding the events on a component
Overrides:
Source:

isLoopThroughChild()

Returns whether or not the childs of a component is refresh
Overrides:
Source:

isRender()

Returns whether or not the component is rendered
Overrides:
Source:

isSortValues() → {boolean}

Check if we need to sort filter option values
Source:
Returns:
- Whether we need to sort values or not.
Type
boolean

markValuesAsNoRender(values)

Mark values in the array as no render. If we have more than scrollFirstLoadLength filter values, and showMoreType=='scrollbar', don't render all values at once, but append them on scroll.
Parameters:
Name Type Description
values Array The data.values array.
Source:

modifyValues(values)

Modify the value list. For example: add collection All to the list. It modifies the values array in-place.
Parameters:
Name Type Description
values Array The data.values array.
Source:

naturalSortFunction(a, b) → {number}

Function to sort naturally (mixed number and text) Sort number from small to big, and then sort text alphabetically. For text mixed with number, if the text starts with a number, sort the number part first. Ex: 0, 1, 1b, 2, 2a, 2b, ab, ba
Parameters:
Name Type Description
a
b
Source:
Returns:
Type
number

refresh()

Refresh component
Overrides:
Source:

removeComponent(childComponent)

Remove a child component of a component
Parameters:
Name Type Description
childComponent Object The child component
Overrides:
Source:

render()

Render compoment
Overrides:
Source:

setData(data)

Set data for filter option. This will also call the sort function for filter values.
Parameters:
Name Type Description
data Object One element of the array: data.filter.options from API.
Source:

sortValues(values)

Sort the values. This is called if isSortValues() returns true. It modifies the values array in-place.
Parameters:
Name Type Description
values Array The data.values array.
Source: