/* Copyright (C) Philippe Meyer 2019-2021 Distributed under the MIT License vanillaSelectBox : v1.05 : setValue() bug correction on single mode. You could not set the value vanillaSelectBox : v1.04 : select all issue fixed by https://github.com/arthur911016 vanillaSelectBox : v1.03 : getResult() an new fonction to get the selected values in an array vanillaSelectBox : v1.02 : Adding 2 new options "itemsSeparator" to change the default "," item separator showing in the button and translations.item to show the item in singular if there is only one. vanillaSelectBox : v1.01 : Removing useless code line 550,551 issue 71 by chchch vanillaSelectBox : v1.00 : Adding a package.json file vanillaSelectBox : v0.78 : Stop using inline styles in the main button. You can steal use keepInlineStyles:true to use the legacy behaviour vanillaSelectBox : v0.77 : Work on place holder with bastoune help => still seems to lose placeholder value on multiple dropdown checkall vanillaSelectBox : v0.76 : New changeTree function : to rebuild the original tree with new data + correcting empty() function vanillaSelectBox : v0.75 : Remote search ready + local search modification : when a check on optgroup checks children only if they not excluded from search. vanillaSelectBox : v0.72 : Remote search (WIP) bugfix [x] Select all duplicated vanillaSelectBox : v0.71 : Remote search (WIP) better code vanillaSelectBox : v0.70 : Remote search (WIP) for users to test vanillaSelectBox : v0.65 : Two levels: bug fix : groups are checked/unchecked when check all/uncheck all is clicked vanillaSelectBox : v0.64 : Two levels: groups are now checkable to check/uncheck the children options vanillaSelectBox : v0.63 : Two levels: one click on the group selects / unselects children vanillaSelectBox : v0.62 : New option: maxOptionWidth set a maximum width for each option for narrow menus vanillaSelectBox : v0.61 : New option: maxSelect, set a maximum to the selectable options in a multiple choice menu vanillaSelectBox : v0.60 : Two levels: Optgroups are now used to show two level dropdowns vanillaSelectBox : v0.59 : Bug fix : search box was overlapping first item in single selects vanillaSelectBox : v0.58 : Bug fixes vanillaSelectBox : v0.57 : Bug fix (minWidth option not honored) vanillaSelectBox : v0.56 : The multiselect checkboxes are a little smaller, maxWidth option is now working + added minWidth option as well The button has now a style attribute to protect its appearance vanillaSelectBox : v0.55 : All attributes from the original select options are copied to the selectBox element vanillaSelectBox : v0.54 : if all the options of the select are selected by the user then the check all checkbox is checked vanillaSelectBox : v0.53 : if all the options of the select are selected then the check all checkbox is checked vanillaSelectBox : v0.52 : Better support of select('all') => command is consistent with checkbox and selecting / deselecting while searching select / uncheck only the found items vanillaSelectBox : v0.51 : Translations for select all/clear all + minor css corrections + don't select disabled items vanillaSelectBox : v0.50 : PR by jaguerra2017 adding a select all/clear all check button + optgroup support ! vanillaSelectBox : v0.41 : Bug corrected, the menu content was misplaced if a css transform was applied on a parent vanillaSelectBox : v0.40 : A click on one selectBox close the other opened boxes vanillaSelectBox : v0.35 : You can enable and disable items vanillaSelectBox : v0.30 : The menu stops moving around on window resize and scroll + z-index in order of creation for multiple instances vanillaSelectBox : v0.26 : Corrected bug in stayOpen mode with disable() function vanillaSelectBox : v0.25 : New option stayOpen, and the dropbox is no longer a dropbox but a nice multi-select previous version : v0.24 : corrected bug affecting options with more than one class https://github.com/PhilippeMarcMeyer/vanillaSelectBox */ let VSBoxCounter = function () { let count = 0; let instances = []; return { set: function (instancePtr) { instances.push({ offset: ++count, ptr: instancePtr }); return instances[instances.length - 1].offset; }, remove: function (instanceNr) { let temp = instances.filter(function (x) { return x.offset != instanceNr; }) instances = temp.splice(0); }, closeAllButMe: function (instanceNr) { instances.forEach(function (x) { if (x.offset != instanceNr) { x.ptr.closeOrder(); } }); } }; }(); function vanillaSelectBox(domSelector, options) { let self = this; this.instanceOffset = VSBoxCounter.set(self); this.domSelector = domSelector; this.root = document.querySelector(domSelector); this.rootToken = null; this.main; this.button; this.title; this.isMultiple = this.root.hasAttribute("multiple"); this.multipleSize = this.isMultiple && this.root.hasAttribute("size") ? parseInt(this.root.getAttribute("size")) : -1; this.isOptgroups = false; this.currentOptgroup = 0; this.drop; this.top; this.left; this.options; this.listElements; this.isDisabled = false; this.search = false; this.searchZone = null; this.inputBox = null; this.disabledItems = []; this.ulminWidth = 140; this.ulmaxWidth = 280; this.ulminHeight = 25; this.maxOptionWidth = Infinity; this.maxSelect = Infinity; this.isInitRemote = false; this.isSearchRemote = false; this.onInit = null; this.onSearch = null; // if isRemote is true : a user defined function that loads more options from the back this.onInitSize = null; this.forbidenAttributes = ["class", "selected", "disabled", "data-text", "data-value", "style"]; this.forbidenClasses = ["active", "disabled"]; this.userOptions = { // maxWidth: 500, minWidth: -1, maxHeight: 400, translations: { "all": "All", "item": "item","items": "items", "selectAll": "Select All", "clearAll": "Clear All" }, search: false, placeHolder: "", stayOpen: false, disableSelectAll: false, buttonItemsSeparator : "," } this.keepInlineStyles = true; this.keepInlineCaretStyles = true; if (options) { if(options.itemsSeparator!= undefined){ this.userOptions.buttonItemsSeparator = options.itemsSeparator; } if (options.maxWidth != undefined) { this.userOptions.maxWidth = options.maxWidth; } if (options.minWidth != undefined) { this.userOptions.minWidth = options.minWidth; } if (options.maxHeight != undefined) { this.userOptions.maxHeight = options.maxHeight; } if (options.translations != undefined) { for (var property in options.translations) { if (options.translations.hasOwnProperty(property)) { if (this.userOptions.translations[property]) { this.userOptions.translations[property] = options.translations[property]; } } } } if (options.placeHolder != undefined) { this.userOptions.placeHolder = options.placeHolder; } if (options.search != undefined) { this.search = options.search; } if (options.remote != undefined && options.remote) { // user defined onInit function if (options.remote.onInit!= undefined && typeof options.remote.onInit === 'function') { this.onInit = options.remote.onInit; this.isInitRemote = true; } if (options.remote.onInitSize != undefined) { this.onInitSize = options.remote.onInitSize; if (this.onInitSize < 3) this.onInitSize = 3; } // user defined remote search function if (options.remote.onSearch != undefined && typeof options.remote.onSearch === 'function') { this.onSearch = options.remote.onSearch; this.isSearchRemote = true; } } if (options.stayOpen != undefined) { this.userOptions.stayOpen = options.stayOpen; } if (options.disableSelectAll != undefined) { this.userOptions.disableSelectAll = options.disableSelectAll; } if (options.maxSelect != undefined && !isNaN(options.maxSelect) && options.maxSelect >= 1) { this.maxSelect = options.maxSelect; this.userOptions.disableSelectAll = true; } if (options.maxOptionWidth != undefined && !isNaN(options.maxOptionWidth) && options.maxOptionWidth >= 20) { this.maxOptionWidth = options.maxOptionWidth; this.ulminWidth = options.maxOptionWidth + 60; this.ulmaxWidth = options.maxOptionWidth + 60; } if(options.keepInlineStyles != undefined ) { this.keepInlineStyles = options.keepInlineStyles; } if(options.keepInlineCaretStyles != undefined ) { this.keepInlineCaretStyles = options.keepInlineCaretStyles; } } this.closeOrder = function () { let self = this; if (!self.userOptions.stayOpen) { self.drop.style.visibility = "hidden"; if (self.search) { self.inputBox.value = ""; Array.prototype.slice.call(self.listElements).forEach(function (x) { x.classList.remove("hide"); }); } } } this.getCssArray = function (selector) { // Why inline css ? To protect the button display from foreign css files let cssArray = []; if (selector === ".vsb-main button") { cssArray = [ // { "key": "min-width", "value": "120px" }, // { "key": "border-radius", "value": "0" }, // { "key": "width", "value": "100%" }, // { "key": "text-align", "value": "left" }, // { "key": "z-index", "value": "1" }, // { "key": "color", "value": "#333" }, // { "key": "background", "value": "white !important" }, // { "key": "border", "value": "1px solid #999 !important" }, // { "key": "line-height", "value": "20px" }, // { "key": "font-size", "value": "14px" }, // { "key": "padding", "value": "6px 12px" } ] } return cssArrayToString(cssArray); function cssArrayToString(cssList) { let list = ""; cssList.forEach(function (x) { list += x.key + ":" + x.value + ";"; }); return list; } } this.init = function () { let self = this; if (self.isInitRemote) { self.onInit("",self.onInitSize) .then(function (data) { self.buildSelect(data); self.createTree(); }); } else { self.createTree(); } } this.getResult = function () { let self = this; let result = []; let collection = self.root.querySelectorAll("option"); collection.forEach(function (x) { if (x.selected) { result.push(x.value); } }); return result; } this.createTree = function () { this.rootToken = self.domSelector.replace(/[^A-Za-z0-9]+/, "") this.root.style.display = "none"; let already = document.getElementById("btn-group-" + this.rootToken); if (already) { already.remove(); } this.main = document.createElement("div"); this.root.parentNode.insertBefore(this.main, this.root.nextSibling); this.main.classList.add("vsb-main"); this.main.setAttribute("id", "btn-group-" + this.rootToken); this.main.style.marginLeft = this.main.style.marginLeft; if (self.userOptions.stayOpen) { this.main.style.minHeight = (this.userOptions.maxHeight + 10) + "px"; } if (self.userOptions.stayOpen) { this.button = document.createElement("div"); } else { this.button = document.createElement("button"); if(this.keepInlineStyles) { var cssList = self.getCssArray(".vsb-main button"); this.button.setAttribute("style", cssList); } } this.button.style.maxWidth = this.userOptions.maxWidth + "px"; if (this.userOptions.minWidth !== -1) { this.button.style.minWidth = this.userOptions.minWidth + "px"; } this.main.appendChild(this.button); this.title = document.createElement("span"); this.button.appendChild(this.title); this.title.classList.add("title"); let caret = document.createElement("span"); this.button.appendChild(caret); caret.classList.add("caret"); if(this.keepInlineCaretStyles) { caret.style.position = "absolute"; caret.style.right = "8px"; caret.style.marginTop = "8px"; } if (self.userOptions.stayOpen) { caret.style.display = "none"; this.title.style.paddingLeft = "20px"; this.title.style.fontStyle = "italic"; this.title.style.verticalAlign = "20%"; } this.drop = document.createElement("div"); this.main.appendChild(this.drop); this.drop.classList.add("vsb-menu"); this.drop.style.zIndex = 2000 - this.instanceOffset; this.ul = document.createElement("ul"); this.drop.appendChild(this.ul); this.ul.style.maxHeight = this.userOptions.maxHeight + "px"; this.ul.style.minWidth = this.ulminWidth + "px"; this.ul.style.maxWidth = this.ulmaxWidth + "px"; this.ul.style.minHeight = this.ulminHeight + "px"; if (this.isMultiple) { this.ul.classList.add("multi"); if (!self.userOptions.disableSelectAll) { let selectAll = document.createElement("option"); selectAll.setAttribute("value", 'all'); selectAll.innerText = self.userOptions.translations.selectAll; this.root.insertBefore(selectAll, (this.root.hasChildNodes()) ? this.root.childNodes[0] : null); } } let selectedTexts = "" let sep = ""; let nrActives = 0; if (this.search) { this.searchZone = document.createElement("div"); this.ul.appendChild(this.searchZone); this.searchZone.classList.add("vsb-js-search-zone"); this.searchZone.style.zIndex = 2001 - this.instanceOffset; this.inputBox = document.createElement("input"); this.searchZone.appendChild(this.inputBox); this.inputBox.setAttribute("type", "text"); this.inputBox.setAttribute("id", "search_" + this.rootToken); if (this.maxOptionWidth < Infinity) { this.searchZone.style.maxWidth = self.maxOptionWidth + 30 + "px"; this.inputBox.style.maxWidth = self.maxOptionWidth + 30 + "px"; } var para = document.createElement("p"); this.ul.appendChild(para); para.style.fontSize = "12px"; para.innerHTML = " "; this.ul.addEventListener("scroll", function (e) { var y = this.scrollTop; self.searchZone.parentNode.style.top = y + "px"; }); } this.options = document.querySelectorAll(this.domSelector + " > option"); Array.prototype.slice.call(this.options).forEach(function (x) { let text = x.textContent; let value = x.value; let originalAttrs; if (x.hasAttributes()) { originalAttrs = Array.prototype.slice.call(x.attributes) .filter(function (a) { return self.forbidenAttributes.indexOf(a.name) === -1 }); } let classes = x.getAttribute("class"); if (classes) { classes = classes .split(" ") .filter(function (c) { return self.forbidenClasses.indexOf(c) === -1 }); } else { classes = []; } let li = document.createElement("li"); let isSelected = x.hasAttribute("selected"); let isDisabled = x.hasAttribute("disabled"); self.ul.appendChild(li); li.setAttribute("data-value", value); li.setAttribute("data-text", text); if (originalAttrs !== undefined) { originalAttrs.forEach(function (a) { li.setAttribute(a.name, a.value); }); } classes.forEach(function (x) { li.classList.add(x); }); if (self.maxOptionWidth < Infinity) { li.classList.add("short"); li.style.maxWidth = self.maxOptionWidth + "px"; } if (isSelected) { nrActives++; selectedTexts += sep + text; sep = self.userOptions.buttonItemsSeparator; li.classList.add("active"); if (!self.isMultiple) { self.title.textContent = text; if (classes.length != 0) { classes.forEach(function (x) { self.title.classList.add(x); }); } } } if (isDisabled) { li.classList.add("disabled"); } li.appendChild(document.createTextNode(" " + text)); }); if (document.querySelector(self.domSelector + ' optgroup') !== null) { self.isOptgroups = true; self.options = document.querySelectorAll(self.domSelector + " option"); let groups = document.querySelectorAll(self.domSelector + ' optgroup'); Array.prototype.slice.call(groups).forEach(function (group) { let groupOptions = group.querySelectorAll('option'); let li = document.createElement("li"); let span = document.createElement("span"); let iCheck = document.createElement("i"); let labelElement = document.createElement("b"); let dataWay = group.getAttribute("data-way"); if (!dataWay) dataWay = "closed"; if (!dataWay || (dataWay !== "closed" && dataWay !== "open")) dataWay = "closed"; li.appendChild(span); li.appendChild(iCheck); self.ul.appendChild(li); li.classList.add('grouped-option'); li.classList.add(dataWay); self.currentOptgroup++; let optId = self.rootToken + "-opt-" + self.currentOptgroup; li.id = optId; li.appendChild(labelElement); labelElement.appendChild(document.createTextNode(group.label)); li.setAttribute("data-text", group.label); self.ul.appendChild(li); Array.prototype.slice.call(groupOptions).forEach(function (x) { let text = x.textContent; let value = x.value; let classes = x.getAttribute("class"); if (classes) { classes = classes.split(" "); } else { classes = []; } classes.push(dataWay); let li = document.createElement("li"); let isSelected = x.hasAttribute("selected"); self.ul.appendChild(li); li.setAttribute("data-value", value); li.setAttribute("data-text", text); li.setAttribute("data-parent", optId); if (classes.length != 0) { classes.forEach(function (x) { li.classList.add(x); }); } if (isSelected) { nrActives++; selectedTexts += sep + text; sep = self.userOptions.buttonItemsSeparator; li.classList.add("active"); if (!self.isMultiple) { self.title.textContent = text; if (classes.length != 0) { classes.forEach(function (x) { self.title.classList.add(x); }); } } } li.appendChild(document.createTextNode(text)); }) }) } let optionsLength = self.options.length - Number(!self.userOptions.disableSelectAll); if (optionsLength == nrActives) { // Bastoune idea to preserve the placeholder let wordForAll = self.userOptions.translations.all; selectedTexts = wordForAll; } else if (self.multipleSize != -1) { if (nrActives > self.multipleSize) { let wordForItems = nrActives === 1 ? self.userOptions.translations.item : self.userOptions.translations.items; selectedTexts = nrActives + " " + wordForItems; } } if (self.isMultiple) { self.title.innerHTML = selectedTexts; } if (self.userOptions.placeHolder != "" && self.title.textContent == "") { self.title.textContent = self.userOptions.placeHolder; } self.listElements = self.drop.querySelectorAll("li:not(.grouped-option)"); if (self.search) { self.inputBox.addEventListener("keyup", function (e) { let searchValue = e.target.value.toUpperCase(); let searchValueLength = searchValue.length; let nrFound = 0; let nrChecked = 0; let selectAll = null; if (self.isSearchRemote) { if (searchValueLength == 0) { self.remoteSearchIntegrate(null); } else if (searchValueLength >= 3) { self.onSearch(searchValue) .then(function (data) { self.remoteSearchIntegrate(data); }); } } else { if (searchValueLength < 3) { Array.prototype.slice.call(self.listElements).forEach(function (x) { if (x.getAttribute('data-value') === 'all') { selectAll = x; } else { x.classList.remove("hidden-search"); nrFound++; nrChecked += x.classList.contains('active'); } }); } else { Array.prototype.slice.call(self.listElements).forEach(function (x) { if (x.getAttribute('data-value') !== 'all') { let text = x.getAttribute("data-text").toUpperCase(); if (text.indexOf(searchValue) === -1 && x.getAttribute('data-value') !== 'all') { x.classList.add("hidden-search"); } else { nrFound++; x.classList.remove("hidden-search"); nrChecked += x.classList.contains('active'); } } else { selectAll = x; } }); } if (selectAll) { if (nrFound === 0) { selectAll.classList.add('disabled'); } else { selectAll.classList.remove('disabled'); } if (nrChecked !== nrFound) { selectAll.classList.remove("active"); selectAll.innerText = self.userOptions.translations.selectAll; selectAll.setAttribute('data-selected', 'false') } else if (nrChecked == self.listElements.length) { selectAll.classList.add("active"); selectAll.innerText = self.userOptions.translations.clearAll; selectAll.setAttribute('data-selected', 'true') } } } }); } if (self.userOptions.stayOpen) { self.drop.style.visibility = "visible"; self.drop.style.boxShadow = "none"; self.drop.style.minHeight = (this.userOptions.maxHeight + 10) + "px"; self.drop.style.position = "relative"; self.drop.style.left = "0px"; self.drop.style.top = "0px"; self.button.style.border = "none"; } else { this.main.addEventListener("click", function (e) { if (self.isDisabled) return; if (self.drop.style.visibility === "visible") { docListener(); } else { self.drop.style.visibility = "visible"; self.main.classList.add('open'); document.addEventListener("click", docListener); e.preventDefault(); e.stopPropagation(); if (!self.userOptions.stayOpen) { VSBoxCounter.closeAllButMe(self.instanceOffset); } } }); } this.drop.addEventListener("click", function (e) { if (self.isDisabled) return; if (e.target.tagName === 'INPUT') return; let isShowHideCommand = e.target.tagName === 'SPAN'; let isCheckCommand = e.target.tagName === 'I'; let liClicked = e.target.parentElement; if (!liClicked.hasAttribute("data-value")) { if (liClicked.classList.contains("grouped-option")) { if (!isShowHideCommand && !isCheckCommand) return; let oldClass, newClass; if (isCheckCommand) { // check or uncheck children self.checkUncheckFromParent(liClicked); } else { //open or close if (liClicked.classList.contains("open")) { oldClass = "open" newClass = "closed" } else { oldClass = "closed" newClass = "open" } liClicked.classList.remove(oldClass); liClicked.classList.add(newClass); let theChildren = self.drop.querySelectorAll("[data-parent='" + liClicked.id + "']"); theChildren.forEach(function (x) { x.classList.remove(oldClass); x.classList.add(newClass); }) } return; } } let choiceValue = e.target.getAttribute("data-value"); let choiceText = e.target.getAttribute("data-text"); let className = e.target.getAttribute("class"); if (className && className.indexOf("disabled") != -1) { return; } if (className && className.indexOf("overflow") != -1) { return; } if (choiceValue === 'all') { if (e.target.hasAttribute('data-selected') && e.target.getAttribute('data-selected') === 'true') { self.setValue('none') } else { self.setValue('all'); } return; } if (!self.isMultiple) { self.root.value = choiceValue; self.title.textContent = choiceText; if (className) { self.title.setAttribute("class", className + " title"); } else { self.title.setAttribute("class", "title"); } Array.prototype.slice.call(self.listElements).forEach(function (x) { x.classList.remove("active"); }); if (choiceText != "") { e.target.classList.add("active"); } self.privateSendChange(); if (!self.userOptions.stayOpen) { docListener(); } } else { let wasActive = false; if (className) { wasActive = className.indexOf("active") != -1; } if (wasActive) { e.target.classList.remove("active"); } else { e.target.classList.add("active"); } if (e.target.hasAttribute("data-parent")) { self.checkUncheckFromChild(e.target); } let selectedTexts = "" let sep = ""; let nrActives = 0; let nrAll = 0; for (let i = 0; i < self.options.length; i++) { nrAll++; if (self.options[i].value == choiceValue) { self.options[i].selected = !wasActive; } if (self.options[i].selected) { nrActives++; selectedTexts += sep + self.options[i].textContent; sep = self.userOptions.buttonItemsSeparator; } } if (nrAll == nrActives - Number(!self.userOptions.disableSelectAll)) { let wordForAll = self.userOptions.translations.all; selectedTexts = wordForAll; } else if (self.multipleSize != -1) { if (nrActives > self.multipleSize) { let wordForItems = nrActives === 1 ? self.userOptions.translations.item : self.userOptions.translations.items; selectedTexts = nrActives + " " + wordForItems; } } self.title.textContent = selectedTexts; self.checkSelectMax(nrActives); self.checkUncheckAll(); self.privateSendChange(); } e.preventDefault(); e.stopPropagation(); if (self.userOptions.placeHolder != "" && self.title.textContent == "") { self.title.textContent = self.userOptions.placeHolder; } }); function docListener() { document.removeEventListener("click", docListener); self.drop.style.visibility = "hidden"; self.main.classList.remove('open'); if (self.search) { self.inputBox.value = ""; Array.prototype.slice.call(self.listElements).forEach(function (x) { x.classList.remove("hidden-search"); }); } } } this.init(); this.checkUncheckAll(); } vanillaSelectBox.prototype.buildSelect = function (data) { let self = this; if(data == null || data.length < 1) return; if(!self.isOptgroups){ self.isOptgroups = data[0].parent != undefined && data[0].parent != ""; } if(self.isOptgroups){ let groups = {}; data = data.filter(function(x){ return x.parent != undefined && x.parent != ""; }); data.forEach(function (x) { if(!groups[x.parent]){ groups[x.parent] = true; } }); for (let group in groups) { let anOptgroup = document.createElement("optgroup"); anOptgroup.setAttribute("label", group); options = data.filter(function(x){ return x.parent == group; }); options.forEach(function (x) { let anOption = document.createElement("option"); anOption.value = x.value; anOption.text = x.text; if(x.selected){ anOption.setAttribute("selected",true) } anOptgroup.appendChild(anOption); }); self.root.appendChild(anOptgroup); } }else{ data.forEach(function (x) { let anOption = document.createElement("option"); anOption.value = x.value; anOption.text = x.text; if(x.selected){ anOption.setAttribute("selected",true) } self.root.appendChild(anOption); }); } } vanillaSelectBox.prototype.remoteSearchIntegrate = function (data) { let self = this; if (data == null || data.length == 0) { let dataChecked = self.optionsCheckedToData(); if(dataChecked) data = dataChecked.slice(0); self.remoteSearchIntegrateIt(data); } else { let dataChecked = self.optionsCheckedToData(); if (dataChecked.length > 0){ for (var i = data.length - 1; i >= 0; i--) { if(dataChecked.indexOf(data[i].id) !=-1){ data.slice(i,1); } } } data = data.concat(dataChecked); self.remoteSearchIntegrateIt(data); } } vanillaSelectBox.prototype.optionsCheckedToData = function () { let self = this; let dataChecked = []; let treeOptions = self.ul.querySelectorAll("li.active:not(.grouped-option)"); let keepParents = {}; if (treeOptions) { Array.prototype.slice.call(treeOptions).forEach(function (x) { let oneData = {"value":x.getAttribute("data-value"),"text":x.getAttribute("data-text"),"selected":true}; if(oneData.value !== "all"){ if(self.isOptgroups){ let parentId = x.getAttribute("data-parent"); if(keepParents[parentId]!=undefined){ oneData.parent = keepParents[parentId]; }else{ let parentPtr = self.ul.querySelector("#"+parentId); let parentName = parentPtr.getAttribute("data-text"); keepParents[parentId] = parentName; oneData.parent = parentName; } } dataChecked.push(oneData); } }); } return dataChecked; } vanillaSelectBox.prototype.removeOptionsNotChecked = function (data) { let self = this; let minimumSize = self.onInitSize; let newSearchSize = data == null ? 0 : data.length; let presentSize = self.root.length; if (presentSize + newSearchSize > minimumSize) { let maxToRemove = presentSize + newSearchSize - minimumSize - 1; let removed = 0; for (var i = self.root.length - 1; i >= 0; i--) { if (self.root.options[i].selected == false) { if (removed <= maxToRemove) { removed++; self.root.remove(i); } } } } } vanillaSelectBox.prototype.changeTree = function (data, options) { let self = this; self.empty(); self.remoteSearchIntegrateIt(data); if (options && options.onSearch) { if (typeof options.onSearch === 'function') { self.onSearch = options.onSearch; self.isSearchRemote = true; } } self.listElements = this.drop.querySelectorAll("li:not(.grouped-option)"); } vanillaSelectBox.prototype.remoteSearchIntegrateIt = function (data) { let self = this; if (data == null || data.length == 0) return; while(self.root.firstChild) self.root.removeChild(self.root.firstChild); self.buildSelect(data); self.reloadTree(); } vanillaSelectBox.prototype.reloadTree = function () { let self = this; let lis = self.ul.querySelectorAll("li"); if (lis != null) { for (var i = lis.length - 1; i >= 0; i--) { if (lis[i].getAttribute('data-value') !== 'all') { self.ul.removeChild(lis[i]); } } } let selectedTexts = "" let sep = ""; let nrActives = 0; let nrAll = 0; if (self.isOptgroups) { if (document.querySelector(self.domSelector + ' optgroup') !== null) { self.options = document.querySelectorAll(this.domSelector + " option"); let groups = document.querySelectorAll(this.domSelector + ' optgroup'); Array.prototype.slice.call(groups).forEach(function (group) { let groupOptions = group.querySelectorAll('option'); let li = document.createElement("li"); let span = document.createElement("span"); let iCheck = document.createElement("i"); let labelElement = document.createElement("b"); let dataWay = group.getAttribute("data-way"); if (!dataWay) dataWay = "closed"; if (!dataWay || (dataWay !== "closed" && dataWay !== "open")) dataWay = "closed"; li.appendChild(span); li.appendChild(iCheck); self.ul.appendChild(li); li.classList.add('grouped-option'); li.classList.add(dataWay); self.currentOptgroup++; let optId = self.rootToken + "-opt-" + self.currentOptgroup; li.id = optId; li.appendChild(labelElement); labelElement.appendChild(document.createTextNode(group.label)); li.setAttribute("data-text", group.label); self.ul.appendChild(li); Array.prototype.slice.call(groupOptions).forEach(function (x) { let text = x.textContent; let value = x.value; let classes = x.getAttribute("class"); if (classes) { classes = classes.split(" "); } else { classes = []; } classes.push(dataWay); let li = document.createElement("li"); let isSelected = x.hasAttribute("selected"); self.ul.appendChild(li); li.setAttribute("data-value", value); li.setAttribute("data-text", text); li.setAttribute("data-parent", optId); if (classes.length != 0) { classes.forEach(function (x) { li.classList.add(x); }); } if (isSelected) { nrActives++; selectedTexts += sep + text; sep = self.userOptions.buttonItemsSeparator; li.classList.add("active"); if (!self.isMultiple) { self.title.textContent = text; if (classes.length != 0) { classes.forEach(function (x) { self.title.classList.add(x); }); } } } li.appendChild(document.createTextNode(text)); }) }) } self.listElements = this.drop.querySelectorAll("li:not(.grouped-option)"); } else { self.options = self.root.querySelectorAll("option"); Array.prototype.slice.call(self.options).forEach(function (x) { let text = x.textContent; let value = x.value; if (value != "all") { let originalAttrs; if (x.hasAttributes()) { originalAttrs = Array.prototype.slice.call(x.attributes) .filter(function (a) { return self.forbidenAttributes.indexOf(a.name) === -1 }); } let classes = x.getAttribute("class"); if (classes) { classes = classes .split(" ") .filter(function (c) { return self.forbidenClasses.indexOf(c) === -1 }); } else { classes = []; } let li = document.createElement("li"); let isSelected = x.hasAttribute("selected"); let isDisabled = x.disabled; self.ul.appendChild(li); li.setAttribute("data-value", value); li.setAttribute("data-text", text); if (originalAttrs !== undefined) { originalAttrs.forEach(function (a) { li.setAttribute(a.name, a.value); }); } classes.forEach(function (x) { li.classList.add(x); }); if (self.maxOptionWidth < Infinity) { li.classList.add("short"); li.style.maxWidth = self.maxOptionWidth + "px"; } if (isSelected) { nrActives++; selectedTexts += sep + text; sep = self.userOptions.buttonItemsSeparator; li.classList.add("active"); if (!self.isMultiple) { self.title.textContent = text; if (classes.length != 0) { classes.forEach(function (x) { self.title.classList.add(x); }); } } } if (isDisabled) { li.classList.add("disabled"); } li.appendChild(document.createTextNode(" " + text)); } }); } } vanillaSelectBox.prototype.disableItems = function (values) { let self = this; let foundValues = []; if (vanillaSelectBox_type(values) == "string") { values = values.split(","); } if (vanillaSelectBox_type(values) == "array") { Array.prototype.slice.call(self.options).forEach(function (x) { if (values.indexOf(x.value) != -1) { foundValues.push(x.value); x.setAttribute("disabled", ""); } }); } Array.prototype.slice.call(self.listElements).forEach(function (x) { let val = x.getAttribute("data-value"); if (foundValues.indexOf(val) != -1) { x.classList.add("disabled"); } }); } vanillaSelectBox.prototype.enableItems = function (values) { let self = this; let foundValues = []; if (vanillaSelectBox_type(values) == "string") { values = values.split(","); } if (vanillaSelectBox_type(values) == "array") { Array.prototype.slice.call(self.options).forEach(function (x) { if (values.indexOf(x.value) != -1) { foundValues.push(x.value); x.removeAttribute("disabled"); } }); } Array.prototype.slice.call(self.listElements).forEach(function (x) { if (foundValues.indexOf(x.getAttribute("data-value")) != -1) { x.classList.remove("disabled"); } }); } vanillaSelectBox.prototype.checkSelectMax = function (nrActives) { let self = this; if (self.maxSelect == Infinity || !self.isMultiple) return; if (self.maxSelect <= nrActives) { Array.prototype.slice.call(self.listElements).forEach(function (x) { if (x.hasAttribute('data-value')) { if (!x.classList.contains('disabled') && !x.classList.contains('active')) { x.classList.add("overflow"); } } }); } else { Array.prototype.slice.call(self.listElements).forEach(function (x) { if (x.classList.contains('overflow')) { x.classList.remove("overflow"); } }); } } vanillaSelectBox.prototype.checkUncheckFromChild = function (liClicked) { let self = this; let parentId = liClicked.getAttribute('data-parent'); let parentLi = document.getElementById(parentId); if (!self.isMultiple) return; let listElements = self.drop.querySelectorAll("li"); let childrenElements = Array.prototype.slice.call(listElements).filter(function (el) { return el.hasAttribute("data-parent") && el.getAttribute('data-parent') == parentId && !el.classList.contains('hidden-search') ; }); let nrChecked = 0; let nrCheckable = childrenElements.length; if (nrCheckable == 0) return; childrenElements.forEach(function (el) { if (el.classList.contains('active')) nrChecked++; }); if (nrChecked === nrCheckable || nrChecked === 0) { if (nrChecked === 0) { parentLi.classList.remove("checked"); } else { parentLi.classList.add("checked"); } } else { parentLi.classList.remove("checked"); } } vanillaSelectBox.prototype.checkUncheckFromParent = function (liClicked) { let self = this; let parentId = liClicked.id; if (!self.isMultiple) return; let listElements = self.drop.querySelectorAll("li"); let childrenElements = Array.prototype.slice.call(listElements).filter(function (el) { return el.hasAttribute("data-parent") && el.getAttribute('data-parent') == parentId && !el.classList.contains('hidden-search'); }); let nrChecked = 0; let nrCheckable = childrenElements.length; if (nrCheckable == 0) return; childrenElements.forEach(function (el) { if (el.classList.contains('active')) nrChecked++; }); if (nrChecked === nrCheckable || nrChecked === 0) { //check all or uncheckAll : just do the opposite childrenElements.forEach(function (el) { var event = document.createEvent('HTMLEvents'); event.initEvent('click', true, false); el.dispatchEvent(event); }); if (nrChecked === 0) { liClicked.classList.add("checked"); } else { liClicked.classList.remove("checked"); } } else { //check all liClicked.classList.remove("checked"); childrenElements.forEach(function (el) { if (!el.classList.contains('active')) { var event = document.createEvent('HTMLEvents'); event.initEvent('click', true, false); el.dispatchEvent(event); } }); } } vanillaSelectBox.prototype.checkUncheckAll = function () { let self = this; if (!self.isMultiple) return; let nrChecked = 0; let nrCheckable = 0; let totalAvailableElements = 0; let checkAllElement = null; if (self.listElements == null) return; Array.prototype.slice.call(self.listElements).forEach(function (x) { if (x.hasAttribute('data-value')) { if (x.getAttribute('data-value') === 'all') { checkAllElement = x; } if (x.getAttribute('data-value') !== 'all' && !x.classList.contains('hidden-search') && !x.classList.contains('disabled')) { nrCheckable++; nrChecked += x.classList.contains('active'); } if (x.getAttribute('data-value') !== 'all' && !x.classList.contains('disabled')) { totalAvailableElements++; } } }); if (checkAllElement) { if (nrChecked === nrCheckable) { // check the checkAll checkbox if (nrChecked === totalAvailableElements) { self.title.textContent = self.userOptions.translations.all; checkAllElement.classList.add("active"); checkAllElement.innerText = self.userOptions.translations.clearAll; checkAllElement.setAttribute('data-selected', 'true') } } else if (nrChecked === 0) { // uncheck the checkAll checkbox self.title.textContent = self.userOptions.placeHolder; checkAllElement.classList.remove("active"); checkAllElement.innerText = self.userOptions.translations.selectAll; checkAllElement.setAttribute('data-selected', 'false') } } } vanillaSelectBox.prototype.setValue = function (values) { let self = this; let listElements = self.drop.querySelectorAll("li"); if (values == null || values == undefined || values == "") { self.empty(); } else { if (self.isMultiple) { if (vanillaSelectBox_type(values) == "string") { if (values === "all") { values = []; Array.prototype.slice.call(listElements).forEach(function (x) { if (x.hasAttribute('data-value')) { let value = x.getAttribute('data-value'); if (value !== 'all') { if (!x.classList.contains('hidden-search') && !x.classList.contains('disabled')) { values.push(x.getAttribute('data-value')); } // already checked (but hidden by search) if (x.classList.contains('active')) { if (x.classList.contains('hidden-search') || x.classList.contains('disabled')) { values.push(value); } } }else{ x.classList.add("active"); } } else if (x.classList.contains('grouped-option')) { x.classList.add("checked"); } }); } else if (values === "none") { values = []; Array.prototype.slice.call(listElements).forEach(function (x) { if (x.hasAttribute('data-value')) { let value = x.getAttribute('data-value'); if (value !== 'all') { if (x.classList.contains('active')) { if (x.classList.contains('hidden-search') || x.classList.contains('disabled')) { values.push(value); } } } } else if (x.classList.contains('grouped-option')) { x.classList.remove("checked"); } }); } else { values = values.split(","); } } let foundValues = []; if (vanillaSelectBox_type(values) == "array") { Array.prototype.slice.call(self.options).forEach(function (x) { if (values.indexOf(x.value) !== -1) { x.selected = true; foundValues.push(x.value); } else { x.selected = false; } }); let selectedTexts = "" let sep = ""; let nrActives = 0; let nrAll = 0; Array.prototype.slice.call(listElements).forEach(function (x) { if (x.value !== 'all') { nrAll++; } if (foundValues.indexOf(x.getAttribute("data-value")) != -1) { x.classList.add("active"); nrActives++; selectedTexts += sep + x.getAttribute("data-text"); sep = self.userOptions.buttonItemsSeparator; } else { x.classList.remove("active"); } }); if (nrAll == nrActives - Number(!self.userOptions.disableSelectAll)) { let wordForAll = self.userOptions.translations.all; selectedTexts = wordForAll; } else if (self.multipleSize != -1) { if (nrActives > self.multipleSize) { let wordForItems = nrActives === 1 ? self.userOptions.translations.item : self.userOptions.translations.items; selectedTexts = nrActives + " " + wordForItems; } } self.title.textContent = selectedTexts; self.privateSendChange(); } self.checkUncheckAll(); } else { let found = false; let text = ""; let classNames = "" Array.prototype.slice.call(listElements).forEach(function (x) { let liVal = x.getAttribute("data-value"); if (liVal == values) { x.classList.add("active"); found = true; text = x.getAttribute("data-text") } else { x.classList.remove("active"); } }); Array.prototype.slice.call(self.options).forEach(function (x) { if (x.value == values) { x.selected = true; className = x.getAttribute("class"); if (!className) className = ""; } else { x.selected = false; } }); if (found) { self.title.textContent = text; if (self.userOptions.placeHolder != "" && self.title.textContent == "") { self.title.textContent = self.userOptions.placeHolder; } if (className != "") { self.title.setAttribute("class", className + " title"); } else { self.title.setAttribute("class", "title"); } } } } } vanillaSelectBox.prototype.privateSendChange = function () { let event = document.createEvent('HTMLEvents'); event.initEvent('change', true, false); this.root.dispatchEvent(event); } vanillaSelectBox.prototype.empty = function () { Array.prototype.slice.call(this.listElements).forEach(function (x) { x.classList.remove("active"); }); let parentElements = this.drop.querySelectorAll("li.grouped-option"); if(parentElements){ Array.prototype.slice.call(parentElements).forEach(function (x) { x.classList.remove("checked"); }); } Array.prototype.slice.call(this.options).forEach(function (x) { x.selected = false; }); this.title.textContent = ""; if (this.userOptions.placeHolder != "" && this.title.textContent == "") { this.title.textContent = this.userOptions.placeHolder; } this.checkUncheckAll(); this.privateSendChange(); } vanillaSelectBox.prototype.destroy = function () { let already = document.getElementById("btn-group-" + this.rootToken); if (already) { VSBoxCounter.remove(this.instanceOffset); already.remove(); this.root.style.display = "inline-block"; } } vanillaSelectBox.prototype.disable = function () { this.main.addEventListener("click", function (e) { e.preventDefault(); e.stopPropagation(); }); let already = document.getElementById("btn-group-" + this.rootToken); if (already) { button = already.querySelector("button") if (button) button.classList.add("disabled"); this.isDisabled = true; } } vanillaSelectBox.prototype.enable = function () { let already = document.getElementById("btn-group-" + this.rootToken); if (already) { button = already.querySelector("button") if (button) button.classList.remove("disabled"); this.isDisabled = false; } } vanillaSelectBox.prototype.showOptions = function () { console.log(this.userOptions); } // Polyfills for IE if (!('remove' in Element.prototype)) { Element.prototype.remove = function () { if (this.parentNode) { this.parentNode.removeChild(this); } }; } function vanillaSelectBox_type(target) { const computedType = Object.prototype.toString.call(target); const stripped = computedType.replace("[object ", "").replace("]", ""); const lowercased = stripped.toLowerCase(); return lowercased; } /*! * GSAP 3.10.4 * https://greensock.com * * @license Copyright 2022, GreenSock. All rights reserved. * Subject to the terms at https://greensock.com/standard-license or for Club GreenSock members, the agreement issued with that membership. * @author: Jack Doyle, jack@greensock.com */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).window=t.window||{})}(this,function(e){"use strict";function _inheritsLoose(t,e){t.prototype=Object.create(e.prototype),(t.prototype.constructor=t).__proto__=e}function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function o(t){return"string"==typeof t}function p(t){return"function"==typeof t}function q(t){return"number"==typeof t}function r(t){return void 0===t}function s(t){return"object"==typeof t}function t(t){return!1!==t}function u(){return"undefined"!=typeof window}function v(t){return p(t)||o(t)}function M(t){return(h=mt(t,ot))&&he}function N(t,e){return console.warn("Invalid property",t,"set to",e,"Missing plugin? gsap.registerPlugin()")}function O(t,e){return!e&&console.warn(t)}function P(t,e){return t&&(ot[t]=e)&&h&&(h[t]=e)||ot}function Q(){return 0}function $(t){var e,r,i=t[0];if(s(i)||p(i)||(t=[t]),!(e=(i._gsap||{}).harness)){for(r=pt.length;r--&&!pt[r].targetTest(i););e=pt[r]}for(r=t.length;r--;)t[r]&&(t[r]._gsap||(t[r]._gsap=new Lt(t[r],e)))||t.splice(r,1);return t}function _(t){return t._gsap||$(xt(t))[0]._gsap}function aa(t,e,i){return(i=t[e])&&p(i)?t[e]():r(i)&&t.getAttribute&&t.getAttribute(e)||i}function ba(t,e){return(t=t.split(",")).forEach(e)||t}function ca(t){return Math.round(1e5*t)/1e5||0}function da(t){return Math.round(1e7*t)/1e7||0}function ea(t,e){var r=e.charAt(0),i=parseFloat(e.substr(2));return t=parseFloat(t),"+"===r?t+i:"-"===r?t-i:"*"===r?t*i:t/i}function fa(t,e){for(var r=e.length,i=0;t.indexOf(e[i])<0&&++ia;)s=s._prev;return s?(e._next=s._next,s._next=e):(e._next=t[r],t[r]=e),e._next?e._next._prev=e:t[i]=e,e._prev=s,e.parent=e._dp=t,e}function sa(t,e,r,i){void 0===r&&(r="_first"),void 0===i&&(i="_last");var n=e._prev,a=e._next;n?n._next=a:t[r]===e&&(t[r]=a),a?a._prev=n:t[i]===e&&(t[i]=n),e._next=e._prev=e.parent=null}function ta(t,e){!t.parent||e&&!t.parent.autoRemoveChildren||t.parent.remove(t),t._act=0}function ua(t,e){if(t&&(!e||e._end>t._dur||e._start<0))for(var r=t;r;)r._dirty=1,r=r.parent;return t}function xa(t){return t._repeat?gt(t._tTime,t=t.duration()+t._rDelay)*t:0}function za(t,e){return(t-e._start)*e._ts+(0<=e._ts?0:e._dirty?e.totalDuration():e._tDur)}function Aa(t){return t._end=da(t._start+(t._tDur/Math.abs(t._ts||t._rts||V)||0))}function Ba(t,e){var r=t._dp;return r&&r.smoothChildTiming&&t._ts&&(t._start=da(r._time-(0V)&&e.render(r,!0)),ua(t,e)._dp&&t._initted&&t._time>=t._dur&&t._ts){if(t._dur(n=Math.abs(n))&&(a=i,o=n);return a}function mb(t){return ta(t),t.scrollTrigger&&t.scrollTrigger.kill(!1),t.progress()<1&&Ot(t,"onInterrupt"),t}function rb(t,e,r){return(6*(t+=t<0?1:1>16,t>>8&Pt,t&Pt]:0:Mt.black;if(!_){if(","===t.substr(-1)&&(t=t.substr(0,t.length-1)),Mt[t])_=Mt[t];else if("#"===t.charAt(0)){if(t.length<6&&(t="#"+(i=t.charAt(1))+i+(n=t.charAt(2))+n+(a=t.charAt(3))+a+(5===t.length?t.charAt(4)+t.charAt(4):"")),9===t.length)return[(_=parseInt(t.substr(1,6),16))>>16,_>>8&Pt,_&Pt,parseInt(t.substr(7),16)/255];_=[(t=parseInt(t.substr(1),16))>>16,t>>8&Pt,t&Pt]}else if("hsl"===t.substr(0,3))if(_=d=t.match(tt),e){if(~t.indexOf("="))return _=t.match(et),r&&_.length<4&&(_[3]=1),_}else s=+_[0]%360/360,o=_[1]/100,i=2*(u=_[2]/100)-(n=u<=.5?u*(o+1):u+o-u*o),3<_.length&&(_[3]*=1),_[0]=rb(s+1/3,i,n),_[1]=rb(s,i,n),_[2]=rb(s-1/3,i,n);else _=t.match(tt)||Mt.transparent;_=_.map(Number)}return e&&!d&&(i=_[0]/Pt,n=_[1]/Pt,a=_[2]/Pt,u=((h=Math.max(i,n,a))+(l=Math.min(i,n,a)))/2,h===l?s=o=0:(f=h-l,o=.5=Y?u.endTime(!1):t._dur;return o(e)&&(isNaN(e)||e in s)?(n=e.charAt(0),a="%"===e.substr(-1),i=e.indexOf("="),"<"===n||">"===n?(0<=i&&(e=e.replace(/=/,"")),("<"===n?u._start:u.endTime(0<=u._repeat))+(parseFloat(e.substr(1))||0)*(a?(i<0?u:r).totalDuration()/100:1)):i<0?(e in s||(s[e]=h),s[e]):(n=parseFloat(e.charAt(i-1)+e.substr(i+1)),a&&r&&(n=n/100*(J(r)?r[0]:r).totalDuration()),1=r&&te)return i;i=i._next}else for(i=t._last;i&&i._start>=r;){if("isPause"===i.data&&i._start=n._start)&&n._ts&&h!==n){if(n.parent!==this)return this.render(t,e,r);if(n.render(0=this.totalDuration()||!v&&c)&&(f!==this._start&&Math.abs(l)===Math.abs(this._ts)||this._lock||(!t&&g||!(v===m&&0=i&&(a instanceof $t?e&&n.push(a):(r&&n.push(a),t&&n.push.apply(n,a.getChildren(!0,e,r)))),a=a._next;return n},e.getById=function getById(t){for(var e=this.getChildren(1,1,1),r=e.length;r--;)if(e[r].vars.id===t)return e[r]},e.remove=function remove(t){return o(t)?this.removeLabel(t):p(t)?this.killTweensOf(t):(sa(this,t),t===this._recent&&(this._recent=this._last),ua(this))},e.totalTime=function totalTime(t,e){return arguments.length?(this._forcing=1,!this._dp&&this._ts&&(this._start=da(Dt.time-(0e:!e||a.isActive())&&i.push(a):(r=a.getTweensOf(n,e)).length&&i.push.apply(i,r),a=a._next;return i},e.tweenTo=function tweenTo(t,e){e=e||{};var r,i=this,n=Tt(i,t),a=e.startAt,s=e.onStart,o=e.onStartParams,u=e.immediateRender,h=$t.to(i,ka({ease:e.ease||"none",lazy:!1,immediateRender:!1,time:n,overwrite:"auto",duration:e.duration||Math.abs((n-(a&&"time"in a?a.time:i._time))/i.timeScale())||V,onStart:function onStart(){if(i.pause(),!r){var t=e.duration||Math.abs((n-(a&&"time"in a?a.time:i._time))/i.timeScale());h._dur!==t&&Ka(h,t,0,1).render(h._time,!0,!0),r=1}s&&s.apply(h,o||[])}},e));return u?h.render(0):h},e.tweenFromTo=function tweenFromTo(t,e,r){return this.tweenTo(e,ka({startAt:{time:Tt(this,t)}},r))},e.recent=function recent(){return this._recent},e.nextLabel=function nextLabel(t){return void 0===t&&(t=this._time),kb(this,Tt(this,t))},e.previousLabel=function previousLabel(t){return void 0===t&&(t=this._time),kb(this,Tt(this,t),1)},e.currentLabel=function currentLabel(t){return arguments.length?this.seek(t,!0):this.previousLabel(this._time+V)},e.shiftChildren=function shiftChildren(t,e,r){void 0===r&&(r=0);for(var i,n=this._first,a=this.labels;n;)n._start>=r&&(n._start+=t,n._end+=t),n=n._next;if(e)for(i in a)a[i]>=r&&(a[i]+=t);return ua(this)},e.invalidate=function invalidate(){var t=this._first;for(this._lock=0;t;)t.invalidate(),t=t._next;return n.prototype.invalidate.call(this)},e.clear=function clear(t){void 0===t&&(t=!0);for(var e,r=this._first;r;)e=r._next,this.remove(r),r=e;return this._dp&&(this._time=this._tTime=this._pTime=0),t&&(this.labels={}),ua(this)},e.totalDuration=function totalDuration(t){var e,r,i,n=0,a=this,s=a._last,o=Y;if(arguments.length)return a.timeScale((a._repeat<0?a.duration():a.totalDuration())/(a.reversed()?-t:t));if(a._dirty){for(i=a.parent;s;)e=s._prev,s._dirty&&s.totalDuration(),o<(r=s._start)&&a._sort&&s._ts&&!a._lock?(a._lock=1,Da(a,s,r-s._delay,1)._lock=0):o=r,r<0&&s._ts&&(n-=r,(!i&&!a._dp||i&&i.smoothChildTiming)&&(a._start+=r/a._ts,a._time-=r,a._tTime-=r),a.shiftChildren(-r,!1,-Infinity),o=0),s._end>n&&s._ts&&(n=s._end),s=e;Ka(a,a===I&&a._time>n?a._time:n,1,1),a._dirty=0}return a._tDur},Timeline.updateRoot=function updateRoot(t){if(I._ts&&(ha(I,za(t,I)),f=Dt.frame),Dt.frame>=_t){_t+=U.autoSleep||120;var e=I._first;if((!e||!e._ts)&&U.autoSleep&&Dt._listeners.length<2){for(;e&&!e._ts;)e=e._next;e||Dt.sleep()}}},Timeline}(Nt);ka(Ut.prototype,{_lock:0,_hasPause:0,_forcing:0});function Ub(t,e,r,i,n,a){var u,h,l,f;if(ft[t]&&!1!==(u=new ft[t]).init(n,u.rawVars?e[t]:function _processVars(t,e,r,i,n){if(p(t)&&(t=Qt(t,n,e,r,i)),!s(t)||t.style&&t.nodeType||J(t)||H(t))return o(t)?Qt(t,n,e,r,i):t;var a,u={};for(a in t)u[a]=Qt(t[a],n,e,r,i);return u}(e[t],i,n,a,r),r,i,a)&&(r._pt=h=new oe(r._pt,n,t,0,1,u.render,u,0,u.priority),r!==d))for(l=r._ptLookup[r._targets.indexOf(n)],f=u._props.length;f--;)l[u._props[f]]=h;return u}function $b(t,r,e,i){var n,a,s=r.ease||i||"power1.inOut";if(J(r))a=e[t]||(e[t]=[]),r.forEach(function(t,e){return a.push({t:e/(r.length-1)*100,v:t,e:s})});else for(n in r)a=e[n]||(e[n]=[]),"ease"===n||a.push({t:parseFloat(t),v:r[n],e:s})}var Yt,qt,Vt=function _addPropTween(t,e,r,i,n,a,s,u,h){p(i)&&(i=i(n||0,t,a));var l,f=t[e],d="get"!==r?r:p(f)?h?t[e.indexOf("set")||!p(t["get"+e.substr(3)])?e:"get"+e.substr(3)](h):t[e]():f,_=p(f)?h?Zt:Wt:Gt;if(o(i)&&(~i.indexOf("random(")&&(i=hb(i)),"="===i.charAt(1)&&(!(l=ea(d,i)+(Ra(d)||0))&&0!==l||(i=l))),d!==i||qt)return isNaN(d*i)||""===i?(f||e in t||N(e,i),function _addComplexStringPropTween(t,e,r,i,n,a,s){var o,u,h,l,f,d,_,p,c=new oe(this._pt,t,e,0,1,ee,null,n),m=0,g=0;for(c.b=r,c.e=i,r+="",(_=~(i+="").indexOf("random("))&&(i=hb(i)),a&&(a(p=[r,i],t,e),r=p[0],i=p[1]),u=r.match(it)||[];o=it.exec(i);)l=o[0],f=i.substring(m,o.index),h?h=(h+1)%5:"rgba("===f.substr(-5)&&(h=1),l!==u[g++]&&(d=parseFloat(u[g-1])||0,c._pt={_next:c._pt,p:f||1===g?f:",",s:d,c:"="===l.charAt(1)?ea(d,l)-d:parseFloat(l)-d,m:h&&h<4?Math.round:0},m=it.lastIndex);return c.c=m")});else{for(f in h={},w)"ease"===f||"easeEach"===f||$b(f,w[f],h,w.easeEach);for(f in h)for(A=h[f].sort(function(t,e){return t.t-e.t}),u=z=0;u=t._tDur||e<0)&&t.ratio===u&&(u&&ta(t,1),r||(Ot(t,u?"onComplete":"onReverseComplete",!0),t._prom&&t._prom()))}else t._zTime||(t._zTime=e)}(this,t,e,r);return this},e.targets=function targets(){return this._targets},e.invalidate=function invalidate(){return this._pt=this._op=this._startAt=this._onUpdate=this._lazy=this.ratio=0,this._ptLookup=[],this.timeline&&this.timeline.invalidate(),R.prototype.invalidate.call(this)},e.resetTo=function resetTo(t,e,r,i){c||Dt.wake(),this._ts||this.play();var n,a=Math.min(this._dur,(this._dp._time-this._start)*this._ts);return this._initted||Xt(this,a),n=this._ease(a/this._dur),function _updatePropTweens(t,e,r,i,n,a,s){var o,u,h,l=(t._pt&&t._ptCache||(t._ptCache={}))[e];if(!l)for(l=t._ptCache[e]=[],u=t._ptLookup,h=t._targets.length;h--;){if((o=u[h][e])&&o.d&&o.d._pt)for(o=o.d._pt;o&&o.p!==e;)o=o._next;if(!o)return qt=1,t.vars[e]="+=0",Xt(t,s),qt=0,1;l.push(o)}for(h=l.length;h--;)(o=l[h]).s=!i&&0!==i||n?o.s+(i||0)+a*o.c:i,o.c=r-o.s,o.e&&(o.e=ca(r)+Ra(o.e)),o.b&&(o.b=o.s+Ra(o.b))}(this,t,e,r,i,n,a)?this.resetTo(t,e,r,i):(Ba(this,0),this.parent||ra(this._dp,this,"_first","_last",this._dp._sort?"_start":0),this.render(0))},e.kill=function kill(t,e){if(void 0===e&&(e="all"),!(t||e&&"all"!==e))return this._lazy=this._pt=0,this.parent?mb(this):this;if(this.timeline){var r=this.timeline.totalDuration();return this.timeline.killTweensOf(t,e,Yt&&!0!==Yt.vars.overwrite)._first||mb(this),this.parent&&r!==this.timeline.totalDuration()&&Ka(this,this._dur*this.timeline._tDur/r,0,1),this}var i,n,a,s,u,h,l,f=this._targets,d=t?xt(t):f,p=this._ptLookup,c=this._pt;if((!e||"all"===e)&&function _arraysMatch(t,e){for(var r=t.length,i=r===e.length;i&&r--&&t[r]===e[r];);return r<0}(f,d))return"all"===e&&(this._pt=0),mb(this);for(i=this._op=this._op||[],"all"!==e&&(o(e)&&(u={},ba(e,function(t){return u[t]=1}),e=u),e=function _addAliasesToVars(t,e){var r,i,n,a,s=t[0]?_(t[0]).harness:0,o=s&&s.aliases;if(!o)return e;for(i in r=mt({},e),o)if(i in r)for(n=(a=o[i].split(",")).length;n--;)r[a[n]]=r[i];return r}(f,e)),l=f.length;l--;)if(~d.indexOf(f[l]))for(u in n=p[l],"all"===e?(i[l]=e,s=n,a={}):(a=i[l]=i[l]||{},s=e),s)(h=n&&n[u])&&("kill"in h.d&&!0!==h.d.kill(u)||sa(this,h,"_pt"),delete n[u]),"all"!==a&&(a[u]=1);return this._initted&&!this._pt&&c&&mb(this),this},Tween.to=function to(t,e,r){return new Tween(t,e,r)},Tween.from=function from(t,e){return Oa(1,arguments)},Tween.delayedCall=function delayedCall(t,e,r,i){return new Tween(e,0,{immediateRender:!1,lazy:!1,overwrite:!1,delay:t,onComplete:e,onReverseComplete:e,onCompleteParams:r,onReverseCompleteParams:r,callbackScope:i})},Tween.fromTo=function fromTo(t,e,r){return Oa(2,arguments)},Tween.set=function set(t,e){return e.duration=0,e.repeatDelay||(e.repeat=0),new Tween(t,e)},Tween.killTweensOf=function killTweensOf(t,e,r){return I.killTweensOf(t,e,r)},Tween}(Nt);ka($t.prototype,{_targets:[],_lazy:0,_startAt:0,_op:0,_onInit:0}),ba("staggerTo,staggerFrom,staggerFromTo",function(r){$t[r]=function(){var t=new Ut,e=wt.call(arguments,0);return e.splice("staggerFromTo"===r?5:4,0,0),t[r].apply(t,e)}});function gc(t,e,r){return t.setAttribute(e,r)}function oc(t,e,r,i){i.mSet(t,e,i.m.call(i.tween,r,i.mt),i)}var Gt=function _setterPlain(t,e,r){return t[e]=r},Wt=function _setterFunc(t,e,r){return t[e](r)},Zt=function _setterFuncWithParam(t,e,r,i){return t[e](i.fp,r)},Ht=function _getSetter(t,e){return p(t[e])?Wt:r(t[e])&&t.setAttribute?gc:Gt},Jt=function _renderPlain(t,e){return e.set(e.t,e.p,Math.round(1e6*(e.s+e.c*t))/1e6,e)},te=function _renderBoolean(t,e){return e.set(e.t,e.p,!!(e.s+e.c*t),e)},ee=function _renderComplexString(t,e){var r=e._pt,i="";if(!t&&e.b)i=e.b;else if(1===t&&e.e)i=e.e;else{for(;r;)i=r.p+(r.m?r.m(r.s+r.c*t):Math.round(1e4*(r.s+r.c*t))/1e4)+i,r=r._next;i+=e.c}e.set(e.t,e.p,i,e)},re=function _renderPropTweens(t,e){for(var r=e._pt;r;)r.r(t,r.d),r=r._next},ie=function _addPluginModifier(t,e,r,i){for(var n,a=this._pt;a;)n=a._next,a.p===i&&a.modifier(t,e,r),a=n},ne=function _killPropTweensOf(t){for(var e,r,i=this._pt;i;)r=i._next,i.p===t&&!i.op||i.op===t?sa(this,i,"_pt"):i.dep||(e=1),i=r;return!e},se=function _sortPropTweensByPriority(t){for(var e,r,i,n,a=t._pt;a;){for(e=a._next,r=i;r&&r.pr>a.pr;)r=r._next;(a._prev=r?r._prev:n)?a._prev._next=a:i=a,(a._next=r)?r._prev=a:n=a,a=e}t._pt=i},oe=(PropTween.prototype.modifier=function modifier(t,e,r){this.mSet=this.mSet||this.set,this.set=oc,this.m=t,this.mt=r,this.tween=e},PropTween);function PropTween(t,e,r,i,n,a,s,o,u){this.t=e,this.s=i,this.c=n,this.p=r,this.r=a||Jt,this.d=s||this,this.set=o||Gt,this.pr=u||0,(this._next=t)&&(t._prev=this)}ba(ct+"parent,duration,ease,delay,overwrite,runBackwards,startAt,yoyo,immediateRender,repeat,repeatDelay,data,paused,reversed,lazy,callbackScope,stringFilter,id,yoyoEase,stagger,inherit,repeatRefresh,keyframes,autoRevert,scrollTrigger",function(t){return ut[t]=1}),ot.TweenMax=ot.TweenLite=$t,ot.TimelineLite=ot.TimelineMax=Ut,I=new Ut({sortChildren:!1,defaults:L,autoRemoveChildren:!0,id:"root",smoothChildTiming:!0}),U.stringFilter=xb;var ue={registerPlugin:function registerPlugin(){for(var t=arguments.length,e=new Array(t),r=0;r1&&void 0!==arguments[1]&&arguments[1],t=document.createElement("div");return t.innerHTML=e.trim(),!0===n?t.children:t.firstChild},r=function(e,n){var t=e.children;return 1===t.length&&t[0].tagName===n},i=function(e){return null!=(e=e||document.querySelector(".basicLightbox"))&&!0===e.ownerDocument.body.contains(e)};t.visible=i;t.create=function(e,n){var t=function(e,n){var t=o('\n\t\t
\n\t\t\t\n\t\t
\n\t')),i=t.querySelector(".basicLightbox__placeholder");e.forEach((function(e){return i.appendChild(e)}));var c=r(i,"IMG"),u=r(i,"VIDEO"),s=r(i,"IFRAME");return!0===c&&t.classList.add("basicLightbox--img"),!0===u&&t.classList.add("basicLightbox--video"),!0===s&&t.classList.add("basicLightbox--iframe"),t}(e=function(e){var n="string"==typeof e,t=e instanceof HTMLElement==1;if(!1===n&&!1===t)throw new Error("Content must be a DOM element/node or string");return!0===n?Array.from(o(e,!0)):"TEMPLATE"===e.tagName?[e.content.cloneNode(!0)]:Array.from(e.children)}(e),n=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(null==(e=Object.assign({},e)).closable&&(e.closable=!0),null==e.className&&(e.className=""),null==e.onShow&&(e.onShow=function(){}),null==e.onClose&&(e.onClose=function(){}),"boolean"!=typeof e.closable)throw new Error("Property `closable` must be a boolean");if("string"!=typeof e.className)throw new Error("Property `className` must be a string");if("function"!=typeof e.onShow)throw new Error("Property `onShow` must be a function");if("function"!=typeof e.onClose)throw new Error("Property `onClose` must be a function");return e}(n)),c=function(e){return!1!==n.onClose(u)&&function(e,n){return e.classList.remove("basicLightbox--visible"),setTimeout((function(){return!1===i(e)||e.parentElement.removeChild(e),n()}),410),!0}(t,(function(){if("function"==typeof e)return e(u)}))};!0===n.closable&&t.addEventListener("click",(function(e){e.target===t&&c()}));var u={element:function(){return t},visible:function(){return i(t)},show:function(e){return!1!==n.onShow(u)&&function(e,n){return document.body.appendChild(e),setTimeout((function(){requestAnimationFrame((function(){return e.classList.add("basicLightbox--visible"),n()}))}),10),!0}(t,(function(){if("function"==typeof e)return e(u)}))},close:c};return u}},{}]},{},[1])(1)}));