dropDownListStyling.mjs 1.39 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"use strict";

import { vanillaSelectBox } from "../thirdparty/vanillaSelectBox.mjs";

/**
 * Use the `vanillaDropDown` library to style the buildings & data points drop down list
 *
 * @returns {undefined}
 */
const styleBuildingsDataPointsDropDown = function () {
  // Create our dropdown list using `vanillaSelectBox`; supports the selection of multiple options
  new vanillaSelectBox("#drop-down--bldg-data-point", {
    disableSelectAll: true,
    maxSelect: 5,
    placeHolder: "--Select--",
    search: false,
  });
};

/**
 * Use the `vanillaDropDown` library to style the chart type,
 * aggregation type and sampling rates drop down lists
 *
 * @returns {undefined} undefined
 */
const styleOtherDropDownLists = function () {
  // Array of CSS selector strings
  const cssSelectorStringsArr = [
    "#drop-down--chart-type",
    "#drop-down--aggregation-type",
    "#drop-down--sampling-rate",
  ];

  // Create our dropdown lists using `vanillaSelectBox`
  cssSelectorStringsArr.forEach((cssSelectorString) => {
    new vanillaSelectBox(cssSelectorString, {
      disableSelectAll: true,
      maxSelect: 1,
      placeHolder: "--Select--",
      search: false,
    });
  });
};

/**
 *  Use the `vanillaDropDown` library to style all the drop down lists
 *
 * @returns {undefined} undefined
 */
export const styleAllDropDownLists = function () {
  styleBuildingsDataPointsDropDown();
  styleOtherDropDownLists();
};