Skip to main content

ElementCheckboxDropdown

Namespace for creating (DOM-based) dropdown menus filled with checkboxes

Index

Functions

FromList

  • FromList(id: string, checkboxList: readonly string[], eventListener: (this: HTMLInputElement, event: Event) => void, options?: { checked: boolean; parent: HTMLElement }): HTMLDivElement
  • Construct a dropdown menu with labeled checkboxes


    Parameters

    • id: string

      The ID of the element

    • checkboxList: readonly string[]

      The checkbox labels

    • eventListener: (this: HTMLInputElement, event: Event) => void

      The event listener to-be attached to all checkboxes

      • optionaloptions: { checked: boolean; parent: HTMLElement } = null
        • checked: boolean

          Whether all checkboxes should be initially checked

        • parent: HTMLElement

          The parent element of the dropdown menu; defaults to document.body

      Returns HTMLDivElement

      • The created dropdown menu

    FromRecord

    • FromRecord(id: string, checkboxRecord: Record<string, readonly string[]>, eventListener: (this: HTMLInputElement, event: Event) => void, options?: { checked: boolean; parent: HTMLElement }): HTMLDivElement
    • Construct a dropdown menu with labeled checkboxes, each group of checkboxes having a header associated with them


      Parameters

      • id: string

        The ID of the element

      • checkboxRecord: Record<string, readonly string[]>

        The checkbox labels

      • eventListener: (this: HTMLInputElement, event: Event) => void

        The event listener to-be attached to all checkboxes

        • optionaloptions: { checked: boolean; parent: HTMLElement } = null
          • checked: boolean

            Whether all checkboxes should be initially checked

          • parent: HTMLElement

            The parent element of the dropdown menu; defaults to document.body

        Returns HTMLDivElement

        • The created dropdown menu

      _CreateCheckboxPair

      • _CreateCheckboxPair(idPrefix: string, idSuffix: string, spanText: string, listener: (this: HTMLInputElement, event: Event) => void, checked?: boolean): HTMLOptions<label>

      • Parameters

        • idPrefix: string
        • idSuffix: string
        • spanText: string
        • listener: (this: HTMLInputElement, event: Event) => void
          • checked: boolean = false

          Returns HTMLOptions<label>