new SearchMenuUI()
Search Menu UI.
Contains the "behavior" of the search bar. It submits the search query, parses the results, displays matches and filters and responds to clicks and key presses. Further resources:
Members
(protected) config :module:searchmenu.SearchMenuConfig
Configuration.
Type:
- Source:
(protected) currentSearchText :String
Search text that correspondents to the currently shown results.
Type:
- String
- Source:
(protected) focusOutTimer :Timer
Timer that is used to wait before the menu is closed.
Type:
- Timer
- Source:
(protected) waitBeforeSearchTimer :Timer
Timer that is used to wait before the search service is called.
Type:
- Timer
- Source:
Methods
(protected, static) addMainMenuNavigationHandlers(element, config)
Reacts to input events (keys, ...) to navigate through main menu entries.
Parameters:
Name | Type | Description |
---|---|---|
element |
Element | to add event handlers |
config |
SearchMenuConfig | search configuration |
- Source:
(protected, static) addSubMenuNavigationHandlers(element)
Reacts to input events (keys, ...) to navigate through sub menu entries.
Parameters:
Name | Type | Description |
---|---|---|
element |
Element | to add event handlers |
- Source:
(protected, static) createListElement(text, id, elementTag)
Creates a new list element to be used for search results.
Parameters:
Name | Type | Description |
---|---|---|
text |
string | inside the list element |
id |
number | id of the list element |
elementTag |
string | tag (e.g. "li") for the element |
- Source:
(protected, static) createListEntryElement(entry, view, id, text)
Creates a new list entry element to be used for search results, filter options, details and filters.
Parameters:
Name | Type | Description |
---|---|---|
entry |
DescribedEntry | entry data |
view |
module:searchmenu.SearchViewDescription | description |
id |
number | id of the list element |
text |
String | text of the list element |
- Source:
(protected, static) createListEntryInnerHtmlText(entry, view, id, resolveTemplate)
Creates the inner HTML Text for a list entry to be used for search results, filter options, details and filters.
Parameters:
Name | Type | Description |
---|---|---|
entry |
DescribedEntry | entry data |
view |
module:searchmenu.SearchViewDescription | description |
id |
number | id of the list element |
resolveTemplate |
module:searchmenu.TemplateResolver | function that resolves variables inside a template with contents of a source object |
- Source:
(protected, static) extractListElementIdProperties(id) → {module:searchmenu.ListElementIdProperties}
Extracts properties like type and index from the given list element id string.
Parameters:
Name | Type | Description |
---|---|---|
id |
string |
- Source:
Returns:
list element id properties
(protected, static) findSelectedEntry(element, array, equalMatcher) → {DescribedEntry}
Extracts the entry data that it referred by the element given by its ID out of the list of data entries.
Parameters:
Name | Type | Description |
---|---|---|
element |
string | id |
array |
Array.<DescribedEntry> | of described entries |
equalMatcher |
boolean | takes the existing and the new entry as parameters and returns true if they are considered "equal". |
- Source:
Returns:
described entry out of the given entries, that suits the element given by its id.
- Type
- DescribedEntry
(protected, static) focusNextMenuEntry(event, onMissingNext)
Selects and focusses the next menu entry.
Parameters:
Name | Type | Description |
---|---|---|
event |
Event | |
onMissingNext |
module:searchmenu.MenuEntryNotFoundHandler | is called, if no "next" entry could be found. |
- Source:
(protected, static) focusPreviousMenuEntry(event, onMissingPrevious)
Selects and focusses the previous menu entry.
Parameters:
Name | Type | Description |
---|---|---|
event |
Event | |
onMissingPrevious |
module:searchmenu.MenuEntryNotFoundHandler | is called, if no "previous" entry could be found. |
- Source:
(protected, static) forEachIdElementIncludingChildren(element, callback)
The given callback will be called for the given parent and all its direct child nodes, that contain an id property.
Parameters:
Name | Type | Description |
---|---|---|
element |
Element | parent to be inspected |
callback |
module:searchmenu.ElementFoundListener | will be called for every found child and the given parent itself |
- Source:
(protected, static) forEachListEntryElement(listParentElementId, listEntryElementFunction) → {Object}
Iterates through all child nodes of the given parent and calls the given function. If the function returns a value, it will be returned directly. If the function returns nothing, the iteration continues.
Parameters:
Name | Type | Description |
---|---|---|
listParentElementId |
String | |
listEntryElementFunction |
module:searchmenu.ListElementFunction |
- Source:
Returns:
result of the first entry element function, that had returned one, or null.
- Type
- Object
(protected, static) getListElementCountOfType(list) → {number}
Parameters:
Name | Type | Description |
---|---|---|
list |
String | element type name e.g. "li". |
- Source:
Returns:
list element count of the given type
- Type
- number
(protected, static) getListEntryByFieldName(category, fieldName, listParentElementId) → {HTMLElement}
Searches all child elements of the given parent element for an entry with the given fieldName contained in the hidden fields structure.
Parameters:
Name | Type | Description |
---|---|---|
category |
String | of the element to search for |
fieldName |
String | of the element to search for |
listParentElementId |
String | id of the parent element that child nodes will be searched |
- Source:
Returns:
returns the element that matches the given fieldName or null, if it hadn't been found.
- Type
- HTMLElement
(protected, static) getScrollY() → {number}
Browser compatible version of the standard "window.scrollY".
- Source:
Returns:
y scroll position in pixel
- Type
- number
(protected, static) getSelectedUrlTemplate(listParentElementId, category) → {String}
Gets the currently selected url template for navigation.
Parameters:
Name | Type | Description |
---|---|---|
listParentElementId |
String | id of the parent element that child nodes will be searched |
category |
String | the url template needs to belong to the same category |
- Source:
Returns:
returns the url template or null, if nothing could be found
- Type
- String
(protected, static) getYPositionOfElement() → {number}
Browser compatible Y position of the given element.
- Source:
Returns:
y position in pixel
- Type
- number
(protected, static) handleEventWithConfig(config, eventHandler)
Parameters:
Name | Type | Description |
---|---|---|
config |
SearchMenuConfig | search configuration |
eventHandler |
EventListener | event handler |
- Source:
(protected, static) handleEventWithEntriesAndConfig(entries, config, eventHandler)
Parameters:
Name | Type | Description |
---|---|---|
entries |
Array.<Object> | raw data of the entry |
config |
module:searchmenu.SearchMenuConfig | search configuration |
eventHandler |
EventListener | event handler |
- Source:
(protected, static) hide(elementId)
Hides the element given by its id.
Parameters:
Name | Type | Description |
---|---|---|
elementId |
ID of the element that should be hidden |
- Source:
(protected, static) hideElement(element)
Hides the given element.
Parameters:
Name | Type | Description |
---|---|---|
element |
element that should be hidden |
- Source:
(protected, static) hideViewOf(element)
Hides the view (by removing the class "show"), that contains the given element. The view is identified by the existing style class "show".
Parameters:
Name | Type | Description |
---|---|---|
element |
Element |
- Source:
(protected, static) insertAtBeginningIfMissing(entries, entryToAdd, equalMatcher) → {Array.<Object>}
Adds the given entry at be beginning of the given array of entries if it's missing. The equalFunction determines, if the new value is missing (returns false) or not (returns true). If the entry to add is null, the entries are returned directly.
Parameters:
Name | Type | Description |
---|---|---|
entries |
Array.<Object> | |
entryToAdd |
Object | |
equalMatcher |
boolean | takes the existing and the new entry as parameters and returns true if they are considered "equal". |
- Source:
Returns:
- Type
- Array.<Object>
(protected, static) keyCodeOf(event)
Returns the key code of the event or -1 if it is no available.
Parameters:
Name | Type | Description |
---|---|---|
event |
KeyboardEvent |
- Source:
Returns:
key code or -1 if not available
(protected, static) parentThatMatches(element, predicate)
Returns the parent of the element (or the element itself), that matches the given predicate. Returns null, if no element had been found.
Parameters:
Name | Type | Description |
---|---|---|
element |
Element | |
predicate |
module:searchmenu.ElementPredicate |
- Source:
(protected, static) preventDefaultEventHandling(inputevent)
Prevents the given event inside an event handler to get handled anywhere else. Pressing the arrow key up can lead to scrolling up the view. This is not useful, if the arrow key navigates the focus inside a sub menu, that is fully contained inside the current view.
Parameters:
Name | Type | Description |
---|---|---|
inputevent |
InputEvent |
- Source:
(protected, static) removeChildElement(event)
Removes the event target element from its parent.
Parameters:
Name | Type | Description |
---|---|---|
event |
InputEvent |
- Source:
(protected, static) returnToMainMenu(event)
Exit sub menu from event entry and return to main menu.
Parameters:
Name | Type | Description |
---|---|---|
event |
InputEvent |
- Source:
(protected, static) selectFilterOption(event, entries, config)
Gets called when a filter option is selected and copies it into the filter view, where all selected filters are collected.
Parameters:
Name | Type | Description |
---|---|---|
event |
Event | |
entries |
DescribedEntry | |
config |
module:searchmenu.SearchMenuConfig |
- Source:
(protected, static) show(elementId)
Shows the element given by its id.
Parameters:
Name | Type | Description |
---|---|---|
elementId |
Element | ID of the element that should be shown |
- Source:
(protected, static) showElement(element)
Shows the given element.
Parameters:
Name | Type | Description |
---|---|---|
element |
Element | element that should be shown |
- Source:
(protected, static) toggleFilterEntry(event)
Toggles a filter to inactive and vice versa.
Parameters:
Name | Type | Description |
---|---|---|
event |
InputEvent |
- Source:
(protected, static) updateListEntryElement(already, text)
Updates an already existing list entry element to be used for search results, filter options, details and filters.
Parameters:
Name | Type | Description |
---|---|---|
already |
Node | existing element |
text |
String | updated element text |
- Source: