Class Initialization

The main purpose of this class is to initialize the framework (a.k.a the code executed when calling Coveo.init).
It's also in charge or registering the available components, as well as the method that we expost to the global Coveo scope.
For example, the Coveo.executeQuery function will be registed in this class by the QueryController.

Index

Methods

Static automaticallyCreateComponentsInside

  • automaticallyCreateComponentsInside(element: HTMLElement, initParameters: IInitializationParameters, ignore?: string[]): IInitResult

Static automaticallyCreateComponentsInsideResult

  • automaticallyCreateComponentsInsideResult(resultElement: HTMLElement, result: IQueryResult, optionsToInject?: object): IInitResult
  • Scan the result element and all its children for known components. Initialize every known result component found.

    See also : Initialization.automaticallyCreateComponentsInside.

    Parameters

    • resultElement: HTMLElement

      The root element to scan for known components

    • result: IQueryResult

      The result which needs to be passed to each result component constructor.

    • Default value optionsToInject: object = {}

      A set of options to inject for the components found inside the resultElement. These options will be merged with any options passed during the "init" call of the search interface.

    Returns IInitResult

Static getListOfLoadedComponents

  • getListOfLoadedComponents(): string[]

Static getListOfRegisteredComponents

  • getListOfRegisteredComponents(): String[]
  • Return the list of all known components (the list of ID for each component), whether they are actually loaded or not.

    Returns String[]

Static getRegisteredComponent

Static getRegisteredFieldsComponentForQuery

  • getRegisteredFieldsComponentForQuery(componentId: string): string[]
  • Returns all the fields that the framework currently knows should be added to the query, for a given component.

    This is used when the is set to true (which is true by default).

    The framework tries to only include the needed fields from the index, for performance reasons.

    Parameters

    • componentId: string

    Returns string[]

Static getRegisteredFieldsForQuery

  • getRegisteredFieldsForQuery(): string[]
  • Returns all the fields that the framework currently knows should be added to the query.

    This is used when the is set to true (which is true by default).

    The framework tries to only include the needed fields from the index, for performance reasons.

    Returns string[]

Static initRecommendationInterface

  • initRecommendationInterface(element: HTMLElement, options?: any): IInitResult
  • Create a new recommendation search interface. This is the function executed when calling Coveo.initRecommendation.

    Parameters

    • element: HTMLElement
    • Default value options: any = {}

    Returns IInitResult

Static initSearchInterface

  • initSearchInterface(element: HTMLElement, options?: any): IInitResult
  • Create a new standard search interface. This is the function executed when calling Coveo.init.

    Parameters

    • element: HTMLElement
    • Default value options: any = {}

    Returns IInitResult

Static initStandaloneSearchInterface

  • initStandaloneSearchInterface(element: HTMLElement, options?: any): IInitResult
  • Create a new standalone search interface (standalone search box). This is the function executed when calling Coveo.initSearchbox.

    Parameters

    • element: HTMLElement
    • Default value options: any = {}

    Returns IInitResult

Static initializeFramework

  • initializeFramework(element: HTMLElement, options: any, initSearchInterfaceFunction: function): Promise<object>
  • Initialize the framework. Note that this function should not normally be called directly, but instead using a globally registered function (e.g.: Coveo.init), or Initialization.initSearchInterface or Initialization.initStandaloneSearchInterface
    (e.g. : Coveo.init or Coveo.initSearchbox).

    Parameters

    • element: HTMLElement

      The element on which to initialize the interface.

    • options: any

      The options for all components (eg: {Searchbox : {enableSearchAsYouType : true}}).

    • initSearchInterfaceFunction: function

      The function to execute to create the SearchInterface component. Different init call will create different SearchInterface.

        • (...args: any[]): IInitResult
        • Parameters

          • Rest ...args: any[]

          Returns IInitResult

    Returns Promise<object>

Static isComponentClassIdRegistered

  • isComponentClassIdRegistered(componentClassId: string): boolean
  • Check if a component is already registered, using it's ID (e.g. : 'Facet').

    Parameters

    • componentClassId: string

    Returns boolean

Static isNamedMethodRegistered

  • isNamedMethodRegistered(methodName: string): boolean

Static monkeyPatchComponentMethod

  • monkeyPatchComponentMethod(methodName: string, element: HTMLElement, handler: function): void
  • 'Monkey patch' (replace the function with a new one) a given method on a component instance.

    Parameters

    • methodName: string
    • element: HTMLElement
    • handler: function
        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    Returns void

Static registerAutoCreateComponent

  • Register a new Component to be recognized by the framework. This essentially mean that when we call Coveo.init, the Initialization class will scan the DOM for known component (which have registed themselves with this call) and create a new component on each element.

    This is meant to register the component to be loaded "eagerly" (Immediately available when the UI scripts are included)

    Parameters

    Returns void

Static registerComponentFields

  • registerComponentFields(componentId: string, fields: string[]): void
  • Set the fields that the component needs to add to the query.

    This is used when the is set to true (which is true by default).

    The framework tries to only include the needed fields from the index, for performance reasons.

    Parameters

    • componentId: string

      The id for the result template component (see Result Templates).

    • fields: string[]

    Returns void

Static registerDefaultOptions

  • registerDefaultOptions(element: HTMLElement, options: __type): void
  • Register a new set of options for a given element.
    When the element is eventually initialized as a component, those options will be used / merged to create the final option set to use for this component.
    Note that this function should not normally be called directly, but instead using the global Coveo.options function

    Parameters

    • element: HTMLElement
    • options: __type

    Returns void

Static registerNamedMethod

  • registerNamedMethod(methodName: string, handler: function): void
  • Register a new globally available method in the Coveo namespace (e.g.: Coveo.init).

    Parameters

    • methodName: string

      The method name to register.

    • handler: function

      The function to execute when the method is called.

        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    Returns void

Hierarchy

  • Initialization