Module: alfresco/header/SearchBox

alfresco/header/SearchBox

This widget provides multiple ways in which search requests can be made. As well as supporting the basic ability to allow the user to enter a search term and hit the return key to go to a configurable search results page it also supports the ability to immediately show search results for documents, sites and users as characters are entered. These "live search" results can be completely disabled or individually disabled for any combination of documents, [sites]{@link module:alfresco/header/SearchBox#showSiteResults} and users.

It's possible to override placeholder text as well as the live search result titles for documents, [sites]{@link module:alfresco/header/SearchBox#sitesTitle} and users. Links for individual results can also be configured and it is also possible to include hidden search terms in the search queries to tailor the results.

Author:
  • Dave Draper
  • Kevin Roast
License:
Source:

Mixes In

  • external:dojo/_TemplatedMixin

Members

_keyRepeatWait :number

Type:
  • number
Default Value:
  • 250
Source:

_lastSearchIndex :number

Type:
  • number
Default Value:
  • 0
Source:

_LiveSearch :object

Type:
  • object
Default Value:
  • null
Source:

_minimumSearchLength :number

Type:
  • number
Default Value:
  • 2
Source:

_requests :object

Type:
  • object
Default Value:
  • null
Source:

_resultPageSize :number

Type:
  • number
Default Value:
  • 5
Source:

_searchMenu :object

Type:
  • object
Default Value:
  • null
Source:

accessibilityInstruction :string

The text to use for the accessibility instruction on the input field.
Type:
  • string
Default Value:
  • "search.label"
Source:

advancedSearch :boolean

Type:
  • boolean
Default Value:
  • true
Source:

alignment :boolean

This indicates whether or not the live search popup should be aligned to the right or left of the search box. It defaults to true as this is the expected location of the search box in Alfresco Share.
Type:
  • boolean
Default Value:
  • "right"
Source:

allsites :boolean

Type:
  • boolean
Default Value:
  • false
Source:

blogPage :string

This is the page to navigate to for blog post links. It defaults to "blog-postview" (as this is the standard blog post page in Alfresco Share) but it can be configured to go to a custom page.
Type:
  • string
Default Value:
  • "blog-postview"
Source:

containerNodeDocs :object

DOM element container for Documents
Type:
  • object
Source:

containerNodePeople :object

DOM element container for People
Type:
  • object
Source:

containerNodeSites :object

DOM element container for Sites
Type:
  • object
Source:

contextRepositoryLabel :string

The label to display for selection of searching in Repository context in the live search results panel.
Type:
  • string
Since:
  • 1.0.78
Default Value:
  • "search.in-repository"
Source:

contextSiteLabel :string

The label to display for selection of searching in Site context in the live search results panel.
Type:
  • string
Since:
  • 1.0.78
Default Value:
  • "search.in-site"
Source:

cssRequirements :object[]

An array of the CSS files to use with this widget.
Type:
  • object[]
Default Value:
  • [{cssFile:"./css/SearchBox.css"}]
Source:

defaultSearchScope :string

The default scope to use when requesting a search.
Type:
  • string
Default Value:
  • "repo"
Source:

documentLibraryPage :string

This is the page to navigate to for document container links. It defaults to the "documentlibrary" (as this is the standard document library page in Alfresco Share) but it can be configured to go to a custom page.
Type:
  • string
Default Value:
  • "documentlibrary"
Source:

documentPage :string

This is the page to navigate to for document links. It defaults to "document-details" (as this is the standard document details page in Alfresco Share) but it can be configured to go to a custom page.
Type:
  • string
Default Value:
  • "document-details"
Source:

documentsTitle :string

The title to use as above document results in the live search results panel.
Type:
  • string
Default Value:
  • "search.documents"
Source:

enableContextLiveSearch :boolean

Eanble the context switching feature of live search.
Type:
  • boolean
Since:
  • 1.0.78
Default Value:
  • false
Source:

height :string

An optional height that can be configured for the live search results. Without this being set the available space will be used (and may cause the page to grow). When a height is set it will prevent the results box growing beyond that size and will add scrollbars to alllow access to all the results.
Type:
  • string
Since:
  • 1.0.76
Default Value:
  • null
Source:

hiddenSearchTerms :string

Some additional search terms to include in search requests that will not be displayed to the user. Setting this can tailor the results that are shown in both the search results page and the live search results.
Type:
  • string
Source:

i18nRequirements :object[]

An array of the i18n files to use with this widget.
Type:
  • object[]
Default Value:
  • [{i18nFile: "./i18n/SearchBox.properties"}]
Source:

i18nScope :string

The scope to use for i18n messages.
Type:
  • string
Source:

i18nScope :string

The scope to use for i18n messages.
Type:
  • string
Source:

label :string

Type:
  • string
Default Value:
  • null
Source:

lastSearchText :string

Type:
  • string
Default Value:
  • null
Source:

linkToFacetedSearch :boolean

This indicated whether or not the search box should link to the faceted search page or not. It is used by the generateSearchPageLink fuction to determine the URL to generate for displaying search results. By default it will be the faceted search page.
Type:
  • boolean
Default Value:
  • true
Source:

liveSearch :boolean

Type:
  • boolean
Default Value:
  • true
Source:

liveSearchDocumentsUri :string

The URI to use performing the live search for documents. If the default is re-configured then REST API to be used is expected to be able to handle the request parameter of "t" for the search term, "maxResults" for the page size and "startIndex" for the first result in the page. The REST API is expected to be a Repository based WebScript supporting the GET method.
Type:
  • string
Since:
  • 1.0.37
Default Value:
  • "slingshot/live-search-docs"
Source:

liveSearchHeight :string

An optional height that can be configured for the live search results. Without this being set the available space will be used (and may cause the page to grow). When a height is set it will prevent the results box growing beyond that size and will add scrollbars to alllow access to all the results.
Type:
  • string
Since:
  • 1.0.76
Default Value:
  • null
Source:

liveSearchPeopleUri :string

The URI to use performing the live search for people. If the default is re-configured then REST API to be used is expected to be able to handle the request parameter of "t" for the search term, "maxResults" for the page size and "startIndex" for the first result in the page. The REST API is expected to be a Repository based WebScript supporting the GET method.
Type:
  • string
Since:
  • 1.0.37
Default Value:
  • "slingshot/live-search-people"
Source:

liveSearchSitesUri :string

The URI to use performing the live search for sites. If the default is re-configured then REST API to be used is expected to be able to handle the request parameter of "t" for the search term, "maxResults" for the page size and "startIndex" for the first result in the page. The REST API is expected to be a Repository based WebScript supporting the GET method.
Type:
  • string
Since:
  • 1.0.37
Default Value:
  • "slingshot/live-search-sites"
Source:

moreTitle :string

The title to use on the button for retrieving more document results.
Type:
  • string
Default Value:
  • "search.more"
Source:

peoplePage :string

This is the page to navigate to for user links. It defaults to "profile" (as this is the standard profile page in Alfresco Share) but it can be configured to go to a custom page. The page will be prefixed with the standard user URI token mapping (e.g. user//)
Type:
  • string
Default Value:
  • "profile"
Source:

peopleTitle :string

The title to use as above people results in the live search results panel.
Type:
  • string
Default Value:
  • "search.people"
Source:

placeholder :string

The placeholder text to set in the main input field.
Type:
  • string
Default Value:
  • "search.instruction"
Source:

publishGlobal :boolean

Indicates whether publications made when clicking on a result are published globally or not
Type:
  • boolean
Default Value:
  • false
Source:

publishPayload :object

This is an optional payload to publish when a results is clicked. This is only used when publishTopic is configured to be a topic string.
Type:
  • object
Default Value:
  • null
Source:

publishPayloadItemMixin :boolean

Indicates whether or not to include the current item in the payload published when clicking on a result. By default this is configured to be true so that the details of the result that has been clicked on will be included in the payload.
Type:
  • boolean
Default Value:
  • true
Source:

publishPayloadModifiers :string[]

Modifiers to use when processing the payload published when clicking on a result. This is only used when the publishPayloadType is configured to be "PROCESS".
Type:
  • string[]
Default Value:
  • null
Source:

publishPayloadType :object

The type of payload to use when clicking on results. This can be set to one of "CONFIGURED", "CURRENT_ITEM", "PROCESS" or "BUILD" depending on how the payload should be generated.
Type:
  • object
Default Value:
  • null
Source:

publishToParent :boolean

Indicates whether publications made when clicking on a result are published on the parent pub/sub scope or not.
Type:
  • boolean
Default Value:
  • false
Source:

publishTopic :string

This is an optional topic to publish on when a results is clicked. Configuring a publishTopic means that clicking on any results (e.g. wiki, blog, document, site, person, etc) will result in that topic being published. The payload can be configured using a combination of the publishPayloadType, publishPayloadModifiers and publishPayloadItemMixin attributes.
Type:
  • string
Default Value:
  • null
Source:

repositoryTitle :string

The title to use on the repository search toggle.
Type:
  • string
Since:
  • 1.0.78
Default Value:
  • "search.in-repository.tooltip"
Source:

resultsCounts :string

Type:
  • string
Default Value:
  • null
Source:
Type:
  • object
Default Value:
  • null
Source:
Type:
  • object
Source:

searchResultsPage :string

The search results page to use. If this is left as the default of null then it is assumed that the widget is being used within Alfresco Share and the standard search page or faceted search page will be used (depending upon the configuration of linkToFacetedSearch). Alternatively this can be configured to be a custom page.
Type:
  • string
Default Value:
  • null
Source:

showDocumentResults :boolean

Indicates whether or not document results should be displayed in the live search pane.
Type:
  • boolean
Default Value:
  • true
Source:

showPeopleResults :boolean

Indicates whether or not people results should be displayed in the live search pane.
Type:
  • boolean
Default Value:
  • true
Source:

showSiteResults :boolean

Indicates whether or not site results should be displayed in the live search pane.
Type:
  • boolean
Default Value:
  • true
Source:

site :string

Type:
  • string
Default Value:
  • null
Source:

siteContext :boolean

True if the current site ID context should be passed to the document search API
Type:
  • boolean
Since:
  • 1.0.78
Default Value:
  • false
Source:

siteName :string

The optional display name label for the current site.
Type:
  • string
Since:
  • 1.0.78
Default Value:
  • null
Source:

sitePage :string

This is the page to navigate to for site home links. It defaults to "dashboard" (as this is the standard dashboard page in Alfresco Share) but it can be configured to go to a custom page. The page will be prefixed with the standard site URI token mapping (e.g. site//)
Type:
  • string
Default Value:
  • "dashboard"
Source:

sitesTitle :string

The title to use as above site results in the live search results panel.
Type:
  • string
Default Value:
  • "search.sites"
Source:

siteTitle :string

The title to use on the site search toggle.
Type:
  • string
Since:
  • 1.0.78
Default Value:
  • "search.in-site.tooltip"
Source:

suppressRedirect :boolean

If this is overridden to be true then hitting the enter key will not trigger a redirect to a search results page.
Type:
  • boolean
Default Value:
  • false
Source:

templateString :string

Type:
  • string
Source:

templateString :string

Type:
  • string
Source:

templateString :String

The HTML template to use for the widget.
Type:
  • String
Source:

width :integer

This is the width of the search input field (in pixels).
Type:
  • integer
Default Value:
  • "180"
Source:

wikiPage :string

This is the page to navigate to for wiki page links. It defaults to "wiki-page" (as this is the standard Wiki page in Alfresco Share) but it can be configured to go to a custom page.
Type:
  • string
Default Value:
  • "wiki-page"
Source:

Methods

addAccessibilityLabel()

When the search box loads, add a label to support accessibility
Source:

clearResults()

Source:

createLiveSearchDocument(data) → {object}

Creates a widget to render a single live search document result.
Parameters:
Name Type Description
data object The data to create the document rendering with
Since:
  • 1.0.37
Source:
Returns:
An instance of LiveSearchItem
Type
object

createLiveSearchPerson(data) → {object}

Creates a widget to render a single live search person result.
Parameters:
Name Type Description
data object The data to create the person rendering with
Since:
  • 1.0.37
Source:
Returns:
An instance of LiveSearchItem
Type
object

createLiveSearchSite(data) → {object}

Creates a widget to render a single live search site result.
Parameters:
Name Type Description
data object The data to create the site rendering with
Since:
  • 1.0.37
Source:
Returns:
An instance of LiveSearchItem
Type
object
This function is called from the onSearchBoxKeyUp function when the enter key is pressed and will generate a link to either the faceted search page or the old search page based on the value of linkToFacetedSearch. This function can also be overridden by extending modules to link to an entirely new search page.
Parameters:
Name Type Description
terms string The search terms to use
Source:
Returns:
The URL for the search page.
Type
string

generateSearchTerm()

This function is used to construct the search terms that are passed to a search service. The terms provided by the user (e.g. the text that the user has typed) is parenthesized and concatonated with any hiddenSearchTerms so that the scope of the user search request is not lost.
Since:
  • 1.0.31
Support:
  • This function is safe to be overridden by extending or mixing modules (at least until the next major release). The inherited code does not need to be called however the overriding function must perform the designated action and return the appropriate data where appropriate.
Source:

liveSearchDocuments(terms, startIndex)

Parameters:
Name Type Description
terms string
startIndex number
Source:

liveSearchPeople(terms, startIndex)

Parameters:
Name Type Description
terms string The search terms
startIndex number
Source:

liveSearchSites(terms, startIndex)

Parameters:
Name Type Description
terms string The search terms
startIndex number
Source:

onMetaClick(evt)

Handles any clicks on the meta information containing in the link (e.g. links to specific sites that documents are found in).
Parameters:
Name Type Description
evt object The click event
Source:

onResultClick(evt)

Handle storing of a "last" user search in local storage list
Parameters:
Name Type Description
evt object The click event
Source:

onSaveLastUserSearch()

Source:

onSearchBoxKeyDown(evt)

Handles keydown events that occur on the element. Used to page through last user searches and ensure no other components handle the cursor key events.
Parameters:
Name Type Description
evt object The keydown event
Source:

onSearchBoxKeyUp(evt)

Handles keyup events that occur on the element used for capturing search terms.
Parameters:
Name Type Description
evt object The keyup event
Source:

onSearchClearClick(evt)

Parameters:
Name Type Description
evt object The click event
Source:

onSearchDocsMoreClick()

Source:

postCreate()

Default Value:
  • 1.0.76
Source:

postCreate()

Run after widget created
Since:
  • 1.0.47
Source:

postCreate()

Source:

postMixInProperties()

Source:

postMixInProperties()

Source:

processLiveSearchDocument(item) → {object}

Process the live search item for a document and create the HTML entity representing it
Parameters:
Name Type Description
item object The data item to create the document entity from
Since:
  • 1.0.46
Source:
Returns:
An instance of LiveSearchItem
Type
object

processLiveSearchPerson(item) → {object}

Process the live search item for a person and create the HTML entity representing it
Parameters:
Name Type Description
item object The data item to create the person entity from
Since:
  • 1.0.46
Source:
Returns:
An instance of LiveSearchItem
Type
object

processLiveSearchSite(item) → {object}

Process the live search item for a site and create the HTML entity representing it
Parameters:
Name Type Description
item object The data item to create the site entity from
Since:
  • 1.0.46
Source:
Returns:
An instance of LiveSearchItem
Type
object

updateResults()

Source:

<inner> _supportsLocalStorage() → {boolean}

Check if the web browser supports HTML5 local storage
Source:
Returns:
true if local storage is available, false otherwise
Type
boolean