[Rt-commit] rt branch 5.0/upgrade-bootstrap-select-to-1.13.18 created. rt-5.0.2-54-g64cff32f99
BPS Git Server
git at git.bestpractical.com
Thu Dec 30 18:16:06 UTC 2021
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, 5.0/upgrade-bootstrap-select-to-1.13.18 has been created
at 64cff32f991e65566ed439f452ef7865be10ef01 (commit)
- Log -----------------------------------------------------------------
commit 64cff32f991e65566ed439f452ef7865be10ef01
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Dec 31 02:03:53 2021 +0800
Upgrade bootstrap select to 1.13.18
diff --git a/devel/third-party/README b/devel/third-party/README
index 846e6f9da8..25f42f08d5 100644
--- a/devel/third-party/README
+++ b/devel/third-party/README
@@ -14,7 +14,7 @@ Description: combobox for bootstrap
Origin: https://github.com/danielfarrell/bootstrap-combobox
License: Apache
-* bootstrap-select-1.13.10
+* bootstrap-select-1.13.18
Description: modern select with intuitive multiselection, searching, and much more
Origin: https://github.com/snapappointments/bootstrap-select
License: MIT
diff --git a/devel/third-party/bootstrap-select-1.13.10/bootstrap-select.css b/devel/third-party/bootstrap-select-1.13.18/bootstrap-select.css
similarity index 92%
rename from devel/third-party/bootstrap-select-1.13.10/bootstrap-select.css
rename to devel/third-party/bootstrap-select-1.13.18/bootstrap-select.css
index b07486c31e..b90b5b8a60 100644
--- a/devel/third-party/bootstrap-select-1.13.10/bootstrap-select.css
+++ b/devel/third-party/bootstrap-select-1.13.18/bootstrap-select.css
@@ -1,10 +1,34 @@
-/*!
- * Bootstrap-select v1.13.10 (https://developer.snapappointments.com/bootstrap-select)
- *
- * Copyright 2012-2019 SnapAppointments, LLC
- * Licensed under MIT (https://github.com/snapappointments/bootstrap-select/blob/master/LICENSE)
- */
-
+/*!
+ * Bootstrap-select v1.13.18 (https://developer.snapappointments.com/bootstrap-select)
+ *
+ * Copyright 2012-2020 SnapAppointments, LLC
+ * Licensed under MIT (https://github.com/snapappointments/bootstrap-select/blob/master/LICENSE)
+ */
+
+ at -webkit-keyframes bs-notify-fadeOut {
+ 0% {
+ opacity: 0.9;
+ }
+ 100% {
+ opacity: 0;
+ }
+}
+ at -o-keyframes bs-notify-fadeOut {
+ 0% {
+ opacity: 0.9;
+ }
+ 100% {
+ opacity: 0;
+ }
+}
+ at keyframes bs-notify-fadeOut {
+ 0% {
+ opacity: 0.9;
+ }
+ 100% {
+ opacity: 0;
+ }
+}
select.bs-select-hidden,
.bootstrap-select > select.bs-select-hidden,
select.selectpicker {
@@ -90,11 +114,11 @@ select.selectpicker {
.has-error .bootstrap-select .dropdown-toggle,
.error .bootstrap-select .dropdown-toggle,
.bootstrap-select.is-invalid .dropdown-toggle,
-.was-validated .bootstrap-select .selectpicker:invalid + .dropdown-toggle {
+.was-validated .bootstrap-select select:invalid + .dropdown-toggle {
border-color: #b94a48;
}
.bootstrap-select.is-valid .dropdown-toggle,
-.was-validated .bootstrap-select .selectpicker:valid + .dropdown-toggle {
+.was-validated .bootstrap-select select:valid + .dropdown-toggle {
border-color: #28a745;
}
.bootstrap-select.fit-width {
@@ -300,6 +324,11 @@ select.selectpicker {
-moz-box-sizing: border-box;
box-sizing: border-box;
}
+.bootstrap-select .dropdown-menu .notify.fadeOut {
+ -webkit-animation: 300ms linear 750ms forwards bs-notify-fadeOut;
+ -o-animation: 300ms linear 750ms forwards bs-notify-fadeOut;
+ animation: 300ms linear 750ms forwards bs-notify-fadeOut;
+}
.bootstrap-select .no-results {
padding: 3px;
background: #f5f5f5;
@@ -339,6 +368,8 @@ select.selectpicker {
height: 1em;
border-style: solid;
border-width: 0 0.26em 0.26em 0;
+ -webkit-transform-style: preserve-3d;
+ transform-style: preserve-3d;
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
diff --git a/devel/third-party/bootstrap-select-1.13.10/bootstrap-select.js b/devel/third-party/bootstrap-select-1.13.18/bootstrap-select.js
similarity index 83%
rename from devel/third-party/bootstrap-select-1.13.10/bootstrap-select.js
rename to devel/third-party/bootstrap-select-1.13.18/bootstrap-select.js
index 2a4b26e252..21290135cd 100644
--- a/devel/third-party/bootstrap-select-1.13.10/bootstrap-select.js
+++ b/devel/third-party/bootstrap-select-1.13.18/bootstrap-select.js
@@ -1,3139 +1,3248 @@
-/*!
- * Bootstrap-select v1.13.10 (https://developer.snapappointments.com/bootstrap-select)
- *
- * Copyright 2012-2019 SnapAppointments, LLC
- * Licensed under MIT (https://github.com/snapappointments/bootstrap-select/blob/master/LICENSE)
- */
-
-(function (root, factory) {
- if (root === undefined && window !== undefined) root = window;
- if (typeof define === 'function' && define.amd) {
- // AMD. Register as an anonymous module unless amdModuleId is set
- define(["jquery"], function (a0) {
- return (factory(a0));
- });
- } else if (typeof module === 'object' && module.exports) {
- // Node. Does not work with strict CommonJS, but
- // only CommonJS-like environments that support module.exports,
- // like Node.
- module.exports = factory(require("jquery"));
- } else {
- factory(root["jQuery"]);
- }
-}(this, function (jQuery) {
-
-(function ($) {
- 'use strict';
-
- var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
-
- var uriAttrs = [
- 'background',
- 'cite',
- 'href',
- 'itemtype',
- 'longdesc',
- 'poster',
- 'src',
- 'xlink:href'
- ];
-
- var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
-
- var DefaultWhitelist = {
- // Global attributes allowed on any supplied element below.
- '*': ['class', 'dir', 'id', 'lang', 'role', 'tabindex', 'style', ARIA_ATTRIBUTE_PATTERN],
- a: ['target', 'href', 'title', 'rel'],
- area: [],
- b: [],
- br: [],
- col: [],
- code: [],
- div: [],
- em: [],
- hr: [],
- h1: [],
- h2: [],
- h3: [],
- h4: [],
- h5: [],
- h6: [],
- i: [],
- img: ['src', 'alt', 'title', 'width', 'height'],
- li: [],
- ol: [],
- p: [],
- pre: [],
- s: [],
- small: [],
- span: [],
- sub: [],
- sup: [],
- strong: [],
- u: [],
- ul: []
- }
-
- /**
- * A pattern that recognizes a commonly useful subset of URLs that are safe.
- *
- * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
- */
- var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi;
-
- /**
- * A pattern that matches safe data URLs. Only matches image, video and audio types.
- *
- * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
- */
- var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i;
-
- function allowedAttribute (attr, allowedAttributeList) {
- var attrName = attr.nodeName.toLowerCase()
-
- if ($.inArray(attrName, allowedAttributeList) !== -1) {
- if ($.inArray(attrName, uriAttrs) !== -1) {
- return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN))
- }
-
- return true
- }
-
- var regExp = $(allowedAttributeList).filter(function (index, value) {
- return value instanceof RegExp
- })
-
- // Check if a regular expression validates the attribute.
- for (var i = 0, l = regExp.length; i < l; i++) {
- if (attrName.match(regExp[i])) {
- return true
- }
- }
-
- return false
- }
-
- function sanitizeHtml (unsafeElements, whiteList, sanitizeFn) {
- if (sanitizeFn && typeof sanitizeFn === 'function') {
- return sanitizeFn(unsafeElements);
- }
-
- var whitelistKeys = Object.keys(whiteList);
-
- for (var i = 0, len = unsafeElements.length; i < len; i++) {
- var elements = unsafeElements[i].querySelectorAll('*');
-
- for (var j = 0, len2 = elements.length; j < len2; j++) {
- var el = elements[j];
- var elName = el.nodeName.toLowerCase();
-
- if (whitelistKeys.indexOf(elName) === -1) {
- el.parentNode.removeChild(el);
-
- continue;
- }
-
- var attributeList = [].slice.call(el.attributes);
- var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
-
- for (var k = 0, len3 = attributeList.length; k < len3; k++) {
- var attr = attributeList[k];
-
- if (!allowedAttribute(attr, whitelistedAttributes)) {
- el.removeAttribute(attr.nodeName);
- }
- }
- }
- }
- }
-
- // Polyfill for browsers with no classList support
- // Remove in v2
- if (!('classList' in document.createElement('_'))) {
- (function (view) {
- if (!('Element' in view)) return;
-
- var classListProp = 'classList',
- protoProp = 'prototype',
- elemCtrProto = view.Element[protoProp],
- objCtr = Object,
- classListGetter = function () {
- var $elem = $(this);
-
- return {
- add: function (classes) {
- classes = Array.prototype.slice.call(arguments).join(' ');
- return $elem.addClass(classes);
- },
- remove: function (classes) {
- classes = Array.prototype.slice.call(arguments).join(' ');
- return $elem.removeClass(classes);
- },
- toggle: function (classes, force) {
- return $elem.toggleClass(classes, force);
- },
- contains: function (classes) {
- return $elem.hasClass(classes);
- }
- }
- };
-
- if (objCtr.defineProperty) {
- var classListPropDesc = {
- get: classListGetter,
- enumerable: true,
- configurable: true
- };
- try {
- objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc);
- } catch (ex) { // IE 8 doesn't support enumerable:true
- // adding undefined to fight this issue https://github.com/eligrey/classList.js/issues/36
- // modernie IE8-MSW7 machine has IE8 8.0.6001.18702 and is affected
- if (ex.number === undefined || ex.number === -0x7FF5EC54) {
- classListPropDesc.enumerable = false;
- objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc);
- }
- }
- } else if (objCtr[protoProp].__defineGetter__) {
- elemCtrProto.__defineGetter__(classListProp, classListGetter);
- }
- }(window));
- }
-
- var testElement = document.createElement('_');
-
- testElement.classList.add('c1', 'c2');
-
- if (!testElement.classList.contains('c2')) {
- var _add = DOMTokenList.prototype.add,
- _remove = DOMTokenList.prototype.remove;
-
- DOMTokenList.prototype.add = function () {
- Array.prototype.forEach.call(arguments, _add.bind(this));
- }
-
- DOMTokenList.prototype.remove = function () {
- Array.prototype.forEach.call(arguments, _remove.bind(this));
- }
- }
-
- testElement.classList.toggle('c3', false);
-
- // Polyfill for IE 10 and Firefox <24, where classList.toggle does not
- // support the second argument.
- if (testElement.classList.contains('c3')) {
- var _toggle = DOMTokenList.prototype.toggle;
-
- DOMTokenList.prototype.toggle = function (token, force) {
- if (1 in arguments && !this.contains(token) === !force) {
- return force;
- } else {
- return _toggle.call(this, token);
- }
- };
- }
-
- testElement = null;
-
- // shallow array comparison
- function isEqual (array1, array2) {
- return array1.length === array2.length && array1.every(function (element, index) {
- return element === array2[index];
- });
- };
-
- // <editor-fold desc="Shims">
- if (!String.prototype.startsWith) {
- (function () {
- 'use strict'; // needed to support `apply`/`call` with `undefined`/`null`
- var defineProperty = (function () {
- // IE 8 only supports `Object.defineProperty` on DOM elements
- try {
- var object = {};
- var $defineProperty = Object.defineProperty;
- var result = $defineProperty(object, object, object) && $defineProperty;
- } catch (error) {
- }
- return result;
- }());
- var toString = {}.toString;
- var startsWith = function (search) {
- if (this == null) {
- throw new TypeError();
- }
- var string = String(this);
- if (search && toString.call(search) == '[object RegExp]') {
- throw new TypeError();
- }
- var stringLength = string.length;
- var searchString = String(search);
- var searchLength = searchString.length;
- var position = arguments.length > 1 ? arguments[1] : undefined;
- // `ToInteger`
- var pos = position ? Number(position) : 0;
- if (pos != pos) { // better `isNaN`
- pos = 0;
- }
- var start = Math.min(Math.max(pos, 0), stringLength);
- // Avoid the `indexOf` call if no match is possible
- if (searchLength + start > stringLength) {
- return false;
- }
- var index = -1;
- while (++index < searchLength) {
- if (string.charCodeAt(start + index) != searchString.charCodeAt(index)) {
- return false;
- }
- }
- return true;
- };
- if (defineProperty) {
- defineProperty(String.prototype, 'startsWith', {
- 'value': startsWith,
- 'configurable': true,
- 'writable': true
- });
- } else {
- String.prototype.startsWith = startsWith;
- }
- }());
- }
-
- if (!Object.keys) {
- Object.keys = function (
- o, // object
- k, // key
- r // result array
- ) {
- // initialize object and result
- r = [];
- // iterate over object keys
- for (k in o) {
- // fill result array with non-prototypical keys
- r.hasOwnProperty.call(o, k) && r.push(k);
- }
- // return result
- return r;
- };
- }
-
- if (HTMLSelectElement && !HTMLSelectElement.prototype.hasOwnProperty('selectedOptions')) {
- Object.defineProperty(HTMLSelectElement.prototype, 'selectedOptions', {
- get: function () {
- return this.querySelectorAll(':checked');
- }
- });
- }
-
- function getSelectedOptions (select, ignoreDisabled) {
- var selectedOptions = select.selectedOptions,
- options = [],
- opt;
-
- if (ignoreDisabled) {
- for (var i = 0, len = selectedOptions.length; i < len; i++) {
- opt = selectedOptions[i];
-
- if (!(opt.disabled || opt.parentNode.tagName === 'OPTGROUP' && opt.parentNode.disabled)) {
- options.push(opt);
- }
- }
-
- return options;
- }
-
- return selectedOptions;
- }
-
- // much faster than $.val()
- function getSelectValues (select, selectedOptions) {
- var value = [],
- options = selectedOptions || select.selectedOptions,
- opt;
-
- for (var i = 0, len = options.length; i < len; i++) {
- opt = options[i];
-
- if (!(opt.disabled || opt.parentNode.tagName === 'OPTGROUP' && opt.parentNode.disabled)) {
- value.push(opt.value || opt.text);
- }
- }
-
- if (!select.multiple) {
- return !value.length ? null : value[0];
- }
-
- return value;
- }
-
- // set data-selected on select element if the value has been programmatically selected
- // prior to initialization of bootstrap-select
- // * consider removing or replacing an alternative method *
- var valHooks = {
- useDefault: false,
- _set: $.valHooks.select.set
- };
-
- $.valHooks.select.set = function (elem, value) {
- if (value && !valHooks.useDefault) $(elem).data('selected', true);
-
- return valHooks._set.apply(this, arguments);
- };
-
- var changedArguments = null;
-
- var EventIsSupported = (function () {
- try {
- new Event('change');
- return true;
- } catch (e) {
- return false;
- }
- })();
-
- $.fn.triggerNative = function (eventName) {
- var el = this[0],
- event;
-
- if (el.dispatchEvent) { // for modern browsers & IE9+
- if (EventIsSupported) {
- // For modern browsers
- event = new Event(eventName, {
- bubbles: true
- });
- } else {
- // For IE since it doesn't support Event constructor
- event = document.createEvent('Event');
- event.initEvent(eventName, true, false);
- }
-
- el.dispatchEvent(event);
- } else if (el.fireEvent) { // for IE8
- event = document.createEventObject();
- event.eventType = eventName;
- el.fireEvent('on' + eventName, event);
- } else {
- // fall back to jQuery.trigger
- this.trigger(eventName);
- }
- };
- // </editor-fold>
-
- function stringSearch (li, searchString, method, normalize) {
- var stringTypes = [
- 'display',
- 'subtext',
- 'tokens'
- ],
- searchSuccess = false;
-
- for (var i = 0; i < stringTypes.length; i++) {
- var stringType = stringTypes[i],
- string = li[stringType];
-
- if (string) {
- string = string.toString();
-
- // Strip HTML tags. This isn't perfect, but it's much faster than any other method
- if (stringType === 'display') {
- string = string.replace(/<[^>]+>/g, '');
- }
-
- if (normalize) string = normalizeToBase(string);
- string = string.toUpperCase();
-
- if (method === 'contains') {
- searchSuccess = string.indexOf(searchString) >= 0;
- } else {
- searchSuccess = string.startsWith(searchString);
- }
-
- if (searchSuccess) break;
- }
- }
-
- return searchSuccess;
- }
-
- function toInteger (value) {
- return parseInt(value, 10) || 0;
- }
-
- // Borrowed from Lodash (_.deburr)
- /** Used to map Latin Unicode letters to basic Latin letters. */
- var deburredLetters = {
- // Latin-1 Supplement block.
- '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
- '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
- '\xc7': 'C', '\xe7': 'c',
- '\xd0': 'D', '\xf0': 'd',
- '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
- '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
- '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
- '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
- '\xd1': 'N', '\xf1': 'n',
- '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
- '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
- '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
- '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
- '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
- '\xc6': 'Ae', '\xe6': 'ae',
- '\xde': 'Th', '\xfe': 'th',
- '\xdf': 'ss',
- // Latin Extended-A block.
- '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
- '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
- '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
- '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
- '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
- '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
- '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
- '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
- '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
- '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
- '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
- '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
- '\u0134': 'J', '\u0135': 'j',
- '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
- '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
- '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
- '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
- '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
- '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
- '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
- '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
- '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
- '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
- '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
- '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
- '\u0163': 't', '\u0165': 't', '\u0167': 't',
- '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
- '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
- '\u0174': 'W', '\u0175': 'w',
- '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
- '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
- '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
- '\u0132': 'IJ', '\u0133': 'ij',
- '\u0152': 'Oe', '\u0153': 'oe',
- '\u0149': "'n", '\u017f': 's'
- };
-
- /** Used to match Latin Unicode letters (excluding mathematical operators). */
- var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
-
- /** Used to compose unicode character classes. */
- var rsComboMarksRange = '\\u0300-\\u036f',
- reComboHalfMarksRange = '\\ufe20-\\ufe2f',
- rsComboSymbolsRange = '\\u20d0-\\u20ff',
- rsComboMarksExtendedRange = '\\u1ab0-\\u1aff',
- rsComboMarksSupplementRange = '\\u1dc0-\\u1dff',
- rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange + rsComboMarksExtendedRange + rsComboMarksSupplementRange;
-
- /** Used to compose unicode capture groups. */
- var rsCombo = '[' + rsComboRange + ']';
-
- /**
- * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
- * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
- */
- var reComboMark = RegExp(rsCombo, 'g');
-
- function deburrLetter (key) {
- return deburredLetters[key];
- };
-
- function normalizeToBase (string) {
- string = string.toString();
- return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
- }
-
- // List of HTML entities for escaping.
- var escapeMap = {
- '&': '&',
- '<': '<',
- '>': '>',
- '"': '"',
- "'": ''',
- '`': '`'
- };
-
- // Functions for escaping and unescaping strings to/from HTML interpolation.
- var createEscaper = function (map) {
- var escaper = function (match) {
- return map[match];
- };
- // Regexes for identifying a key that needs to be escaped.
- var source = '(?:' + Object.keys(map).join('|') + ')';
- var testRegexp = RegExp(source);
- var replaceRegexp = RegExp(source, 'g');
- return function (string) {
- string = string == null ? '' : '' + string;
- return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;
- };
- };
-
- var htmlEscape = createEscaper(escapeMap);
-
- /**
- * ------------------------------------------------------------------------
- * Constants
- * ------------------------------------------------------------------------
- */
-
- var keyCodeMap = {
- 32: ' ',
- 48: '0',
- 49: '1',
- 50: '2',
- 51: '3',
- 52: '4',
- 53: '5',
- 54: '6',
- 55: '7',
- 56: '8',
- 57: '9',
- 59: ';',
- 65: 'A',
- 66: 'B',
- 67: 'C',
- 68: 'D',
- 69: 'E',
- 70: 'F',
- 71: 'G',
- 72: 'H',
- 73: 'I',
- 74: 'J',
- 75: 'K',
- 76: 'L',
- 77: 'M',
- 78: 'N',
- 79: 'O',
- 80: 'P',
- 81: 'Q',
- 82: 'R',
- 83: 'S',
- 84: 'T',
- 85: 'U',
- 86: 'V',
- 87: 'W',
- 88: 'X',
- 89: 'Y',
- 90: 'Z',
- 96: '0',
- 97: '1',
- 98: '2',
- 99: '3',
- 100: '4',
- 101: '5',
- 102: '6',
- 103: '7',
- 104: '8',
- 105: '9'
- };
-
- var keyCodes = {
- ESCAPE: 27, // KeyboardEvent.which value for Escape (Esc) key
- ENTER: 13, // KeyboardEvent.which value for Enter key
- SPACE: 32, // KeyboardEvent.which value for space key
- TAB: 9, // KeyboardEvent.which value for tab key
- ARROW_UP: 38, // KeyboardEvent.which value for up arrow key
- ARROW_DOWN: 40 // KeyboardEvent.which value for down arrow key
- }
-
- var version = {
- success: false,
- major: '3'
- };
-
- try {
- version.full = ($.fn.dropdown.Constructor.VERSION || '').split(' ')[0].split('.');
- version.major = version.full[0];
- version.success = true;
- } catch (err) {
- // do nothing
- }
-
- var selectId = 0;
-
- var EVENT_KEY = '.bs.select';
-
- var classNames = {
- DISABLED: 'disabled',
- DIVIDER: 'divider',
- SHOW: 'open',
- DROPUP: 'dropup',
- MENU: 'dropdown-menu',
- MENURIGHT: 'dropdown-menu-right',
- MENULEFT: 'dropdown-menu-left',
- // to-do: replace with more advanced template/customization options
- BUTTONCLASS: 'btn-default',
- POPOVERHEADER: 'popover-title',
- ICONBASE: 'glyphicon',
- TICKICON: 'glyphicon-ok'
- }
-
- var Selector = {
- MENU: '.' + classNames.MENU
- }
-
- var elementTemplates = {
- span: document.createElement('span'),
- i: document.createElement('i'),
- subtext: document.createElement('small'),
- a: document.createElement('a'),
- li: document.createElement('li'),
- whitespace: document.createTextNode('\u00A0'),
- fragment: document.createDocumentFragment()
- }
-
- elementTemplates.a.setAttribute('role', 'option');
- elementTemplates.subtext.className = 'text-muted';
-
- elementTemplates.text = elementTemplates.span.cloneNode(false);
- elementTemplates.text.className = 'text';
-
- elementTemplates.checkMark = elementTemplates.span.cloneNode(false);
-
- var REGEXP_ARROW = new RegExp(keyCodes.ARROW_UP + '|' + keyCodes.ARROW_DOWN);
- var REGEXP_TAB_OR_ESCAPE = new RegExp('^' + keyCodes.TAB + '$|' + keyCodes.ESCAPE);
-
- var generateOption = {
- li: function (content, classes, optgroup) {
- var li = elementTemplates.li.cloneNode(false);
-
- if (content) {
- if (content.nodeType === 1 || content.nodeType === 11) {
- li.appendChild(content);
- } else {
- li.innerHTML = content;
- }
- }
-
- if (typeof classes !== 'undefined' && classes !== '') li.className = classes;
- if (typeof optgroup !== 'undefined' && optgroup !== null) li.classList.add('optgroup-' + optgroup);
-
- return li;
- },
-
- a: function (text, classes, inline) {
- var a = elementTemplates.a.cloneNode(true);
-
- if (text) {
- if (text.nodeType === 11) {
- a.appendChild(text);
- } else {
- a.insertAdjacentHTML('beforeend', text);
- }
- }
-
- if (typeof classes !== 'undefined' && classes !== '') a.className = classes;
- if (version.major === '4') a.classList.add('dropdown-item');
- if (inline) a.setAttribute('style', inline);
-
- return a;
- },
-
- text: function (options, useFragment) {
- var textElement = elementTemplates.text.cloneNode(false),
- subtextElement,
- iconElement;
-
- if (options.content) {
- textElement.innerHTML = options.content;
- } else {
- textElement.textContent = options.text;
-
- if (options.icon) {
- var whitespace = elementTemplates.whitespace.cloneNode(false);
-
- // need to use <i> for icons in the button to prevent a breaking change
- // note: switch to span in next major release
- iconElement = (useFragment === true ? elementTemplates.i : elementTemplates.span).cloneNode(false);
- iconElement.className = options.iconBase + ' ' + options.icon;
-
- elementTemplates.fragment.appendChild(iconElement);
- elementTemplates.fragment.appendChild(whitespace);
- }
-
- if (options.subtext) {
- subtextElement = elementTemplates.subtext.cloneNode(false);
- subtextElement.textContent = options.subtext;
- textElement.appendChild(subtextElement);
- }
- }
-
- if (useFragment === true) {
- while (textElement.childNodes.length > 0) {
- elementTemplates.fragment.appendChild(textElement.childNodes[0]);
- }
- } else {
- elementTemplates.fragment.appendChild(textElement);
- }
-
- return elementTemplates.fragment;
- },
-
- label: function (options) {
- var textElement = elementTemplates.text.cloneNode(false),
- subtextElement,
- iconElement;
-
- textElement.innerHTML = options.label;
-
- if (options.icon) {
- var whitespace = elementTemplates.whitespace.cloneNode(false);
-
- iconElement = elementTemplates.span.cloneNode(false);
- iconElement.className = options.iconBase + ' ' + options.icon;
-
- elementTemplates.fragment.appendChild(iconElement);
- elementTemplates.fragment.appendChild(whitespace);
- }
-
- if (options.subtext) {
- subtextElement = elementTemplates.subtext.cloneNode(false);
- subtextElement.textContent = options.subtext;
- textElement.appendChild(subtextElement);
- }
-
- elementTemplates.fragment.appendChild(textElement);
-
- return elementTemplates.fragment;
- }
- }
-
- var Selectpicker = function (element, options) {
- var that = this;
-
- // bootstrap-select has been initialized - revert valHooks.select.set back to its original function
- if (!valHooks.useDefault) {
- $.valHooks.select.set = valHooks._set;
- valHooks.useDefault = true;
- }
-
- this.$element = $(element);
- this.$newElement = null;
- this.$button = null;
- this.$menu = null;
- this.options = options;
- this.selectpicker = {
- main: {},
- search: {},
- current: {}, // current changes if a search is in progress
- view: {},
- keydown: {
- keyHistory: '',
- resetKeyHistory: {
- start: function () {
- return setTimeout(function () {
- that.selectpicker.keydown.keyHistory = '';
- }, 800);
- }
- }
- }
- };
- // If we have no title yet, try to pull it from the html title attribute (jQuery doesnt' pick it up as it's not a
- // data-attribute)
- if (this.options.title === null) {
- this.options.title = this.$element.attr('title');
- }
-
- // Format window padding
- var winPad = this.options.windowPadding;
- if (typeof winPad === 'number') {
- this.options.windowPadding = [winPad, winPad, winPad, winPad];
- }
-
- // Expose public methods
- this.val = Selectpicker.prototype.val;
- this.render = Selectpicker.prototype.render;
- this.refresh = Selectpicker.prototype.refresh;
- this.setStyle = Selectpicker.prototype.setStyle;
- this.selectAll = Selectpicker.prototype.selectAll;
- this.deselectAll = Selectpicker.prototype.deselectAll;
- this.destroy = Selectpicker.prototype.destroy;
- this.remove = Selectpicker.prototype.remove;
- this.show = Selectpicker.prototype.show;
- this.hide = Selectpicker.prototype.hide;
-
- this.init();
- };
-
- Selectpicker.VERSION = '1.13.10';
-
- // part of this is duplicated in i18n/defaults-en_US.js. Make sure to update both.
- Selectpicker.DEFAULTS = {
- noneSelectedText: 'Nothing selected',
- noneResultsText: 'No results matched {0}',
- countSelectedText: function (numSelected, numTotal) {
- return (numSelected == 1) ? '{0} item selected' : '{0} items selected';
- },
- maxOptionsText: function (numAll, numGroup) {
- return [
- (numAll == 1) ? 'Limit reached ({n} item max)' : 'Limit reached ({n} items max)',
- (numGroup == 1) ? 'Group limit reached ({n} item max)' : 'Group limit reached ({n} items max)'
- ];
- },
- selectAllText: 'Select All',
- deselectAllText: 'Deselect All',
- doneButton: false,
- doneButtonText: 'Close',
- multipleSeparator: ', ',
- styleBase: 'btn',
- style: classNames.BUTTONCLASS,
- size: 'auto',
- title: null,
- selectedTextFormat: 'values',
- width: false,
- container: false,
- hideDisabled: false,
- showSubtext: false,
- showIcon: true,
- showContent: true,
- dropupAuto: true,
- header: false,
- liveSearch: false,
- liveSearchPlaceholder: null,
- liveSearchNormalize: false,
- liveSearchStyle: 'contains',
- actionsBox: false,
- iconBase: classNames.ICONBASE,
- tickIcon: classNames.TICKICON,
- showTick: false,
- template: {
- caret: '<span class="caret"></span>'
- },
- maxOptions: false,
- mobile: false,
- selectOnTab: false,
- dropdownAlignRight: false,
- windowPadding: 0,
- virtualScroll: 600,
- display: false,
- sanitize: true,
- sanitizeFn: null,
- whiteList: DefaultWhitelist
- };
-
- Selectpicker.prototype = {
-
- constructor: Selectpicker,
-
- init: function () {
- var that = this,
- id = this.$element.attr('id');
-
- selectId++;
- this.selectId = 'bs-select-' + selectId;
-
- this.$element[0].classList.add('bs-select-hidden');
-
- this.multiple = this.$element.prop('multiple');
- this.autofocus = this.$element.prop('autofocus');
-
- if (this.$element[0].classList.contains('show-tick')) {
- this.options.showTick = true;
- }
-
- this.$newElement = this.createDropdown();
- this.$element
- .after(this.$newElement)
- .prependTo(this.$newElement);
-
- this.$button = this.$newElement.children('button');
- this.$menu = this.$newElement.children(Selector.MENU);
- this.$menuInner = this.$menu.children('.inner');
- this.$searchbox = this.$menu.find('input');
-
- this.$element[0].classList.remove('bs-select-hidden');
-
- if (this.options.dropdownAlignRight === true) this.$menu[0].classList.add(classNames.MENURIGHT);
-
- if (typeof id !== 'undefined') {
- this.$button.attr('data-id', id);
- }
-
- this.checkDisabled();
- this.clickListener();
-
- if (this.options.liveSearch) {
- this.liveSearchListener();
- this.focusedParent = this.$searchbox[0];
- } else {
- this.focusedParent = this.$menuInner[0];
- }
-
- this.setStyle();
- this.render();
- this.setWidth();
- if (this.options.container) {
- this.selectPosition();
- } else {
- this.$element.on('hide' + EVENT_KEY, function () {
- if (that.isVirtual()) {
- // empty menu on close
- var menuInner = that.$menuInner[0],
- emptyMenu = menuInner.firstChild.cloneNode(false);
-
- // replace the existing UL with an empty one - this is faster than $.empty() or innerHTML = ''
- menuInner.replaceChild(emptyMenu, menuInner.firstChild);
- menuInner.scrollTop = 0;
- }
- });
- }
- this.$menu.data('this', this);
- this.$newElement.data('this', this);
- if (this.options.mobile) this.mobile();
-
- this.$newElement.on({
- 'hide.bs.dropdown': function (e) {
- that.$element.trigger('hide' + EVENT_KEY, e);
- },
- 'hidden.bs.dropdown': function (e) {
- that.$element.trigger('hidden' + EVENT_KEY, e);
- },
- 'show.bs.dropdown': function (e) {
- that.$element.trigger('show' + EVENT_KEY, e);
- },
- 'shown.bs.dropdown': function (e) {
- that.$element.trigger('shown' + EVENT_KEY, e);
- }
- });
-
- if (that.$element[0].hasAttribute('required')) {
- this.$element.on('invalid' + EVENT_KEY, function () {
- that.$button[0].classList.add('bs-invalid');
-
- that.$element
- .on('shown' + EVENT_KEY + '.invalid', function () {
- that.$element
- .val(that.$element.val()) // set the value to hide the validation message in Chrome when menu is opened
- .off('shown' + EVENT_KEY + '.invalid');
- })
- .on('rendered' + EVENT_KEY, function () {
- // if select is no longer invalid, remove the bs-invalid class
- if (this.validity.valid) that.$button[0].classList.remove('bs-invalid');
- that.$element.off('rendered' + EVENT_KEY);
- });
-
- that.$button.on('blur' + EVENT_KEY, function () {
- that.$element.trigger('focus').trigger('blur');
- that.$button.off('blur' + EVENT_KEY);
- });
- });
- }
-
- setTimeout(function () {
- that.createLi();
- that.$element.trigger('loaded' + EVENT_KEY);
- });
- },
-
- createDropdown: function () {
- // Options
- // If we are multiple or showTick option is set, then add the show-tick class
- var showTick = (this.multiple || this.options.showTick) ? ' show-tick' : '',
- multiselectable = this.multiple ? ' aria-multiselectable="true"' : '',
- inputGroup = '',
- autofocus = this.autofocus ? ' autofocus' : '';
-
- if (version.major < 4 && this.$element.parent().hasClass('input-group')) {
- inputGroup = ' input-group-btn';
- }
-
- // Elements
- var drop,
- header = '',
- searchbox = '',
- actionsbox = '',
- donebutton = '';
-
- if (this.options.header) {
- header =
- '<div class="' + classNames.POPOVERHEADER + '">' +
- '<button type="button" class="close" aria-hidden="true">×</button>' +
- this.options.header +
- '</div>';
- }
-
- if (this.options.liveSearch) {
- searchbox =
- '<div class="bs-searchbox">' +
- '<input type="text" class="form-control" autocomplete="off"' +
- (
- this.options.liveSearchPlaceholder === null ? ''
- :
- ' placeholder="' + htmlEscape(this.options.liveSearchPlaceholder) + '"'
- ) +
- ' role="combobox" aria-label="Search" aria-controls="' + this.selectId + '" aria-autocomplete="list">' +
- '</div>';
- }
-
- if (this.multiple && this.options.actionsBox) {
- actionsbox =
- '<div class="bs-actionsbox">' +
- '<div class="btn-group btn-group-sm btn-block">' +
- '<button type="button" class="actions-btn bs-select-all btn ' + classNames.BUTTONCLASS + '">' +
- this.options.selectAllText +
- '</button>' +
- '<button type="button" class="actions-btn bs-deselect-all btn ' + classNames.BUTTONCLASS + '">' +
- this.options.deselectAllText +
- '</button>' +
- '</div>' +
- '</div>';
- }
-
- if (this.multiple && this.options.doneButton) {
- donebutton =
- '<div class="bs-donebutton">' +
- '<div class="btn-group btn-block">' +
- '<button type="button" class="btn btn-sm ' + classNames.BUTTONCLASS + '">' +
- this.options.doneButtonText +
- '</button>' +
- '</div>' +
- '</div>';
- }
-
- drop =
- '<div class="dropdown bootstrap-select' + showTick + inputGroup + '">' +
- '<button type="button" class="' + this.options.styleBase + ' dropdown-toggle" ' + (this.options.display === 'static' ? 'data-display="static"' : '') + 'data-toggle="dropdown"' + autofocus + ' role="combobox" aria-owns="' + this.selectId + '" aria-haspopup="listbox" aria-expanded="false">' +
- '<div class="filter-option">' +
- '<div class="filter-option-inner">' +
- '<div class="filter-option-inner-inner"></div>' +
- '</div> ' +
- '</div>' +
- (
- version.major === '4' ? ''
- :
- '<span class="bs-caret">' +
- this.options.template.caret +
- '</span>'
- ) +
- '</button>' +
- '<div class="' + classNames.MENU + ' ' + (version.major === '4' ? '' : classNames.SHOW) + '">' +
- header +
- searchbox +
- actionsbox +
- '<div class="inner ' + classNames.SHOW + '" role="listbox" id="' + this.selectId + '" tabindex="-1" ' + multiselectable + '>' +
- '<ul class="' + classNames.MENU + ' inner ' + (version.major === '4' ? classNames.SHOW : '') + '" role="presentation">' +
- '</ul>' +
- '</div>' +
- donebutton +
- '</div>' +
- '</div>';
-
- return $(drop);
- },
-
- setPositionData: function () {
- this.selectpicker.view.canHighlight = [];
- this.selectpicker.view.size = 0;
-
- for (var i = 0; i < this.selectpicker.current.data.length; i++) {
- var li = this.selectpicker.current.data[i],
- canHighlight = true;
-
- if (li.type === 'divider') {
- canHighlight = false;
- li.height = this.sizeInfo.dividerHeight;
- } else if (li.type === 'optgroup-label') {
- canHighlight = false;
- li.height = this.sizeInfo.dropdownHeaderHeight;
- } else {
- li.height = this.sizeInfo.liHeight;
- }
-
- if (li.disabled) canHighlight = false;
-
- this.selectpicker.view.canHighlight.push(canHighlight);
-
- if (canHighlight) {
- this.selectpicker.view.size++;
- li.posinset = this.selectpicker.view.size;
- }
-
- li.position = (i === 0 ? 0 : this.selectpicker.current.data[i - 1].position) + li.height;
- }
- },
-
- isVirtual: function () {
- return (this.options.virtualScroll !== false) && (this.selectpicker.main.elements.length >= this.options.virtualScroll) || this.options.virtualScroll === true;
- },
-
- createView: function (isSearching, setSize, refresh) {
- var that = this,
- scrollTop = 0,
- active = [],
- selected,
- prevActive;
-
- this.selectpicker.current = isSearching ? this.selectpicker.search : this.selectpicker.main;
-
- this.setPositionData();
-
- if (setSize) {
- if (refresh) {
- scrollTop = this.$menuInner[0].scrollTop;
- } else if (!that.multiple) {
- var element = that.$element[0],
- selectedIndex = (element.options[element.selectedIndex] || {}).liIndex;
-
- if (typeof selectedIndex === 'number' && that.options.size !== false) {
- var selectedData = that.selectpicker.main.data[selectedIndex],
- position = selectedData && selectedData.position;
-
- if (position) {
- scrollTop = position - ((that.sizeInfo.menuInnerHeight + that.sizeInfo.liHeight) / 2);
- }
- }
- }
- }
-
- scroll(scrollTop, true);
-
- this.$menuInner.off('scroll.createView').on('scroll.createView', function (e, updateValue) {
- if (!that.noScroll) scroll(this.scrollTop, updateValue);
- that.noScroll = false;
- });
-
- function scroll (scrollTop, init) {
- var size = that.selectpicker.current.elements.length,
- chunks = [],
- chunkSize,
- chunkCount,
- firstChunk,
- lastChunk,
- currentChunk,
- prevPositions,
- positionIsDifferent,
- previousElements,
- menuIsDifferent = true,
- isVirtual = that.isVirtual();
-
- that.selectpicker.view.scrollTop = scrollTop;
-
- if (isVirtual === true) {
- // if an option that is encountered that is wider than the current menu width, update the menu width accordingly
- if (that.sizeInfo.hasScrollBar && that.$menu[0].offsetWidth > that.sizeInfo.totalMenuWidth) {
- that.sizeInfo.menuWidth = that.$menu[0].offsetWidth;
- that.sizeInfo.totalMenuWidth = that.sizeInfo.menuWidth + that.sizeInfo.scrollBarWidth;
- that.$menu.css('min-width', that.sizeInfo.menuWidth);
- }
- }
-
- chunkSize = Math.ceil(that.sizeInfo.menuInnerHeight / that.sizeInfo.liHeight * 1.5); // number of options in a chunk
- chunkCount = Math.round(size / chunkSize) || 1; // number of chunks
-
- for (var i = 0; i < chunkCount; i++) {
- var endOfChunk = (i + 1) * chunkSize;
-
- if (i === chunkCount - 1) {
- endOfChunk = size;
- }
-
- chunks[i] = [
- (i) * chunkSize + (!i ? 0 : 1),
- endOfChunk
- ];
-
- if (!size) break;
-
- if (currentChunk === undefined && scrollTop <= that.selectpicker.current.data[endOfChunk - 1].position - that.sizeInfo.menuInnerHeight) {
- currentChunk = i;
- }
- }
-
- if (currentChunk === undefined) currentChunk = 0;
-
- prevPositions = [that.selectpicker.view.position0, that.selectpicker.view.position1];
-
- // always display previous, current, and next chunks
- firstChunk = Math.max(0, currentChunk - 1);
- lastChunk = Math.min(chunkCount - 1, currentChunk + 1);
-
- that.selectpicker.view.position0 = isVirtual === false ? 0 : (Math.max(0, chunks[firstChunk][0]) || 0);
- that.selectpicker.view.position1 = isVirtual === false ? size : (Math.min(size, chunks[lastChunk][1]) || 0);
-
- positionIsDifferent = prevPositions[0] !== that.selectpicker.view.position0 || prevPositions[1] !== that.selectpicker.view.position1;
-
- if (that.activeIndex !== undefined) {
- prevActive = that.selectpicker.main.elements[that.prevActiveIndex];
- active = that.selectpicker.main.elements[that.activeIndex];
- selected = that.selectpicker.main.elements[that.selectedIndex];
-
- if (init) {
- if (that.activeIndex !== that.selectedIndex) {
- that.defocusItem(active);
- }
- that.activeIndex = undefined;
- }
-
- if (that.activeIndex && that.activeIndex !== that.selectedIndex) {
- that.defocusItem(selected);
- }
- }
-
- if (that.prevActiveIndex !== undefined && that.prevActiveIndex !== that.activeIndex && that.prevActiveIndex !== that.selectedIndex) {
- that.defocusItem(prevActive);
- }
-
- if (init || positionIsDifferent) {
- previousElements = that.selectpicker.view.visibleElements ? that.selectpicker.view.visibleElements.slice() : [];
-
- if (isVirtual === false) {
- that.selectpicker.view.visibleElements = that.selectpicker.current.elements;
- } else {
- that.selectpicker.view.visibleElements = that.selectpicker.current.elements.slice(that.selectpicker.view.position0, that.selectpicker.view.position1);
- }
-
- that.setOptionStatus();
-
- // if searching, check to make sure the list has actually been updated before updating DOM
- // this prevents unnecessary repaints
- if (isSearching || (isVirtual === false && init)) menuIsDifferent = !isEqual(previousElements, that.selectpicker.view.visibleElements);
-
- // if virtual scroll is disabled and not searching,
- // menu should never need to be updated more than once
- if ((init || isVirtual === true) && menuIsDifferent) {
- var menuInner = that.$menuInner[0],
- menuFragment = document.createDocumentFragment(),
- emptyMenu = menuInner.firstChild.cloneNode(false),
- marginTop,
- marginBottom,
- elements = that.selectpicker.view.visibleElements,
- toSanitize = [];
-
- // replace the existing UL with an empty one - this is faster than $.empty()
- menuInner.replaceChild(emptyMenu, menuInner.firstChild);
-
- for (var i = 0, visibleElementsLen = elements.length; i < visibleElementsLen; i++) {
- var element = elements[i],
- elText,
- elementData;
-
- if (that.options.sanitize) {
- elText = element.lastChild;
-
- if (elText) {
- elementData = that.selectpicker.current.data[i + that.selectpicker.view.position0];
-
- if (elementData && elementData.content && !elementData.sanitized) {
- toSanitize.push(elText);
- elementData.sanitized = true;
- }
- }
- }
-
- menuFragment.appendChild(element);
- }
-
- if (that.options.sanitize && toSanitize.length) {
- sanitizeHtml(toSanitize, that.options.whiteList, that.options.sanitizeFn);
- }
-
- if (isVirtual === true) {
- marginTop = (that.selectpicker.view.position0 === 0 ? 0 : that.selectpicker.current.data[that.selectpicker.view.position0 - 1].position);
- marginBottom = (that.selectpicker.view.position1 > size - 1 ? 0 : that.selectpicker.current.data[size - 1].position - that.selectpicker.current.data[that.selectpicker.view.position1 - 1].position);
-
- menuInner.firstChild.style.marginTop = marginTop + 'px';
- menuInner.firstChild.style.marginBottom = marginBottom + 'px';
- } else {
- menuInner.firstChild.style.marginTop = 0;
- menuInner.firstChild.style.marginBottom = 0;
- }
-
- menuInner.firstChild.appendChild(menuFragment);
- }
- }
-
- that.prevActiveIndex = that.activeIndex;
-
- if (!that.options.liveSearch) {
- that.$menuInner.trigger('focus');
- } else if (isSearching && init) {
- var index = 0,
- newActive;
-
- if (!that.selectpicker.view.canHighlight[index]) {
- index = 1 + that.selectpicker.view.canHighlight.slice(1).indexOf(true);
- }
-
- newActive = that.selectpicker.view.visibleElements[index];
-
- that.defocusItem(that.selectpicker.view.currentActive);
-
- that.activeIndex = (that.selectpicker.current.data[index] || {}).index;
-
- that.focusItem(newActive);
- }
- }
-
- $(window)
- .off('resize' + EVENT_KEY + '.' + this.selectId + '.createView')
- .on('resize' + EVENT_KEY + '.' + this.selectId + '.createView', function () {
- var isActive = that.$newElement.hasClass(classNames.SHOW);
-
- if (isActive) scroll(that.$menuInner[0].scrollTop);
- });
- },
-
- focusItem: function (li, liData, noStyle) {
- if (li) {
- liData = liData || this.selectpicker.main.data[this.activeIndex];
- var a = li.firstChild;
-
- if (a) {
- a.setAttribute('aria-setsize', this.selectpicker.view.size);
- a.setAttribute('aria-posinset', liData.posinset);
-
- if (noStyle !== true) {
- this.focusedParent.setAttribute('aria-activedescendant', a.id);
- li.classList.add('active');
- a.classList.add('active');
- }
- }
- }
- },
-
- defocusItem: function (li) {
- if (li) {
- li.classList.remove('active');
- if (li.firstChild) li.firstChild.classList.remove('active');
- }
- },
-
- setPlaceholder: function () {
- var updateIndex = false;
-
- if (this.options.title && !this.multiple) {
- if (!this.selectpicker.view.titleOption) this.selectpicker.view.titleOption = document.createElement('option');
-
- // this option doesn't create a new <li> element, but does add a new option at the start,
- // so startIndex should increase to prevent having to check every option for the bs-title-option class
- updateIndex = true;
-
- var element = this.$element[0],
- isSelected = false,
- titleNotAppended = !this.selectpicker.view.titleOption.parentNode;
-
- if (titleNotAppended) {
- // Use native JS to prepend option (faster)
- this.selectpicker.view.titleOption.className = 'bs-title-option';
- this.selectpicker.view.titleOption.value = '';
-
- // Check if selected or data-selected attribute is already set on an option. If not, select the titleOption option.
- // the selected item may have been changed by user or programmatically before the bootstrap select plugin runs,
- // if so, the select will have the data-selected attribute
- var $opt = $(element.options[element.selectedIndex]);
- isSelected = $opt.attr('selected') === undefined && this.$element.data('selected') === undefined;
- }
-
- if (titleNotAppended || this.selectpicker.view.titleOption.index !== 0) {
- element.insertBefore(this.selectpicker.view.titleOption, element.firstChild);
- }
-
- // Set selected *after* appending to select,
- // otherwise the option doesn't get selected in IE
- // set using selectedIndex, as setting the selected attr to true here doesn't work in IE11
- if (isSelected) element.selectedIndex = 0;
- }
-
- return updateIndex;
- },
-
- createLi: function () {
- var that = this,
- iconBase = this.options.iconBase,
- optionSelector = ':not([hidden]):not([data-hidden="true"])',
- mainElements = [],
- mainData = [],
- widestOptionLength = 0,
- optID = 0,
- startIndex = this.setPlaceholder() ? 1 : 0; // append the titleOption if necessary and skip the first option in the loop
-
- if (this.options.hideDisabled) optionSelector += ':not(:disabled)';
-
- if ((that.options.showTick || that.multiple) && !elementTemplates.checkMark.parentNode) {
- elementTemplates.checkMark.className = iconBase + ' ' + that.options.tickIcon + ' check-mark';
- elementTemplates.a.appendChild(elementTemplates.checkMark);
- }
-
- var selectOptions = this.$element[0].querySelectorAll('select > *' + optionSelector);
-
- function addDivider (config) {
- var previousData = mainData[mainData.length - 1];
-
- // ensure optgroup doesn't create back-to-back dividers
- if (
- previousData &&
- previousData.type === 'divider' &&
- (previousData.optID || config.optID)
- ) {
- return;
- }
-
- config = config || {};
- config.type = 'divider';
-
- mainElements.push(
- generateOption.li(
- false,
- classNames.DIVIDER,
- (config.optID ? config.optID + 'div' : undefined)
- )
- );
-
- mainData.push(config);
- }
-
- function addOption (option, config) {
- config = config || {};
-
- config.divider = option.getAttribute('data-divider') === 'true';
-
- if (config.divider) {
- addDivider({
- optID: config.optID
- });
- } else {
- var liIndex = mainData.length,
- cssText = option.style.cssText,
- inlineStyle = cssText ? htmlEscape(cssText) : '',
- optionClass = (option.className || '') + (config.optgroupClass || '');
-
- if (config.optID) optionClass = 'opt ' + optionClass;
-
- config.text = option.textContent;
-
- config.content = option.getAttribute('data-content');
- config.tokens = option.getAttribute('data-tokens');
- config.subtext = option.getAttribute('data-subtext');
- config.icon = option.getAttribute('data-icon');
- config.iconBase = iconBase;
-
- var textElement = generateOption.text(config);
- var liElement = generateOption.li(
- generateOption.a(
- textElement,
- optionClass,
- inlineStyle
- ),
- '',
- config.optID
- );
-
- if (liElement.firstChild) {
- liElement.firstChild.id = that.selectId + '-' + liIndex;
- }
-
- mainElements.push(liElement);
-
- option.liIndex = liIndex;
-
- config.display = config.content || config.text;
- config.type = 'option';
- config.index = liIndex;
- config.option = option;
- config.disabled = config.disabled || option.disabled;
-
- mainData.push(config);
-
- var combinedLength = 0;
-
- // count the number of characters in the option - not perfect, but should work in most cases
- if (config.display) combinedLength += config.display.length;
- if (config.subtext) combinedLength += config.subtext.length;
- // if there is an icon, ensure this option's width is checked
- if (config.icon) combinedLength += 1;
-
- if (combinedLength > widestOptionLength) {
- widestOptionLength = combinedLength;
-
- // guess which option is the widest
- // use this when calculating menu width
- // not perfect, but it's fast, and the width will be updating accordingly when scrolling
- that.selectpicker.view.widestOption = mainElements[mainElements.length - 1];
- }
- }
- }
-
- function addOptgroup (index, selectOptions) {
- var optgroup = selectOptions[index],
- previous = selectOptions[index - 1],
- next = selectOptions[index + 1],
- options = optgroup.querySelectorAll('option' + optionSelector);
-
- if (!options.length) return;
-
- var config = {
- label: htmlEscape(optgroup.label),
- subtext: optgroup.getAttribute('data-subtext'),
- icon: optgroup.getAttribute('data-icon'),
- iconBase: iconBase
- },
- optgroupClass = ' ' + (optgroup.className || ''),
- headerIndex,
- lastIndex;
-
- optID++;
-
- if (previous) {
- addDivider({ optID: optID });
- }
-
- var labelElement = generateOption.label(config);
-
- mainElements.push(
- generateOption.li(labelElement, 'dropdown-header' + optgroupClass, optID)
- );
-
- mainData.push({
- display: config.label,
- subtext: config.subtext,
- type: 'optgroup-label',
- optID: optID
- });
-
- for (var j = 0, len = options.length; j < len; j++) {
- var option = options[j];
-
- if (j === 0) {
- headerIndex = mainData.length - 1;
- lastIndex = headerIndex + len;
- }
-
- addOption(option, {
- headerIndex: headerIndex,
- lastIndex: lastIndex,
- optID: optID,
- optgroupClass: optgroupClass,
- disabled: optgroup.disabled
- });
- }
-
- if (next) {
- addDivider({ optID: optID });
- }
- }
-
- for (var len = selectOptions.length; startIndex < len; startIndex++) {
- var item = selectOptions[startIndex];
-
- if (item.tagName !== 'OPTGROUP') {
- addOption(item, {});
- } else {
- addOptgroup(startIndex, selectOptions);
- }
- }
-
- this.selectpicker.main.elements = mainElements;
- this.selectpicker.main.data = mainData;
-
- this.selectpicker.current = this.selectpicker.main;
- },
-
- findLis: function () {
- return this.$menuInner.find('.inner > li');
- },
-
- render: function () {
- // ensure titleOption is appended and selected (if necessary) before getting selectedOptions
- this.setPlaceholder();
-
- var that = this,
- element = this.$element[0],
- selectedOptions = getSelectedOptions(element, this.options.hideDisabled),
- selectedCount = selectedOptions.length,
- button = this.$button[0],
- buttonInner = button.querySelector('.filter-option-inner-inner'),
- multipleSeparator = document.createTextNode(this.options.multipleSeparator),
- titleFragment = elementTemplates.fragment.cloneNode(false),
- showCount,
- countMax,
- hasContent = false;
-
- button.classList.toggle('bs-placeholder', that.multiple ? !selectedCount : !getSelectValues(element, selectedOptions));
-
- this.tabIndex();
-
- if (this.options.selectedTextFormat === 'static') {
- titleFragment = generateOption.text({ text: this.options.title }, true);
- } else {
- showCount = this.multiple && this.options.selectedTextFormat.indexOf('count') !== -1 && selectedCount > 1;
-
- // determine if the number of selected options will be shown (showCount === true)
- if (showCount) {
- countMax = this.options.selectedTextFormat.split('>');
- showCount = (countMax.length > 1 && selectedCount > countMax[1]) || (countMax.length === 1 && selectedCount >= 2);
- }
-
- // only loop through all selected options if the count won't be shown
- if (showCount === false) {
- for (var selectedIndex = 0; selectedIndex < selectedCount; selectedIndex++) {
- if (selectedIndex < 50) {
- var option = selectedOptions[selectedIndex],
- titleOptions = {},
- thisData = {
- content: option.getAttribute('data-content'),
- subtext: option.getAttribute('data-subtext'),
- icon: option.getAttribute('data-icon')
- };
-
- if (this.multiple && selectedIndex > 0) {
- titleFragment.appendChild(multipleSeparator.cloneNode(false));
- }
-
- if (option.title) {
- titleOptions.text = option.title;
- } else if (thisData.content && that.options.showContent) {
- titleOptions.content = thisData.content.toString();
- hasContent = true;
- } else {
- if (that.options.showIcon) {
- titleOptions.icon = thisData.icon;
- titleOptions.iconBase = this.options.iconBase;
- }
- if (that.options.showSubtext && !that.multiple && thisData.subtext) titleOptions.subtext = ' ' + thisData.subtext;
- titleOptions.text = option.textContent.trim();
- }
-
- titleFragment.appendChild(generateOption.text(titleOptions, true));
- } else {
- break;
- }
- }
-
- // add ellipsis
- if (selectedCount > 49) {
- titleFragment.appendChild(document.createTextNode('...'));
- }
- } else {
- var optionSelector = ':not([hidden]):not([data-hidden="true"]):not([data-divider="true"])';
- if (this.options.hideDisabled) optionSelector += ':not(:disabled)';
-
- // If this is a multiselect, and selectedTextFormat is count, then show 1 of 2 selected, etc.
- var totalCount = this.$element[0].querySelectorAll('select > option' + optionSelector + ', optgroup' + optionSelector + ' option' + optionSelector).length,
- tr8nText = (typeof this.options.countSelectedText === 'function') ? this.options.countSelectedText(selectedCount, totalCount) : this.options.countSelectedText;
-
- titleFragment = generateOption.text({
- text: tr8nText.replace('{0}', selectedCount.toString()).replace('{1}', totalCount.toString())
- }, true);
- }
- }
-
- if (this.options.title == undefined) {
- // use .attr to ensure undefined is returned if title attribute is not set
- this.options.title = this.$element.attr('title');
- }
-
- // If the select doesn't have a title, then use the default, or if nothing is set at all, use noneSelectedText
- if (!titleFragment.childNodes.length) {
- titleFragment = generateOption.text({
- text: typeof this.options.title !== 'undefined' ? this.options.title : this.options.noneSelectedText
- }, true);
- }
-
- // strip all HTML tags and trim the result, then unescape any escaped tags
- button.title = titleFragment.textContent.replace(/<[^>]*>?/g, '').trim();
-
- if (this.options.sanitize && hasContent) {
- sanitizeHtml([titleFragment], that.options.whiteList, that.options.sanitizeFn);
- }
-
- buttonInner.innerHTML = '';
- buttonInner.appendChild(titleFragment);
-
- if (version.major < 4 && this.$newElement[0].classList.contains('bs3-has-addon')) {
- var filterExpand = button.querySelector('.filter-expand'),
- clone = buttonInner.cloneNode(true);
-
- clone.className = 'filter-expand';
-
- if (filterExpand) {
- button.replaceChild(clone, filterExpand);
- } else {
- button.appendChild(clone);
- }
- }
-
- this.$element.trigger('rendered' + EVENT_KEY);
- },
-
- /**
- * @param [style]
- * @param [status]
- */
- setStyle: function (newStyle, status) {
- var button = this.$button[0],
- newElement = this.$newElement[0],
- style = this.options.style.trim(),
- buttonClass;
-
- if (this.$element.attr('class')) {
- this.$newElement.addClass(this.$element.attr('class').replace(/selectpicker|mobile-device|bs-select-hidden|validate\[.*\]/gi, ''));
- }
-
- if (version.major < 4) {
- newElement.classList.add('bs3');
-
- if (newElement.parentNode.classList.contains('input-group') &&
- (newElement.previousElementSibling || newElement.nextElementSibling) &&
- (newElement.previousElementSibling || newElement.nextElementSibling).classList.contains('input-group-addon')
- ) {
- newElement.classList.add('bs3-has-addon');
- }
- }
-
- if (newStyle) {
- buttonClass = newStyle.trim();
- } else {
- buttonClass = style;
- }
-
- if (status == 'add') {
- if (buttonClass) button.classList.add.apply(button.classList, buttonClass.split(' '));
- } else if (status == 'remove') {
- if (buttonClass) button.classList.remove.apply(button.classList, buttonClass.split(' '));
- } else {
- if (style) button.classList.remove.apply(button.classList, style.split(' '));
- if (buttonClass) button.classList.add.apply(button.classList, buttonClass.split(' '));
- }
- },
-
- liHeight: function (refresh) {
- if (!refresh && (this.options.size === false || this.sizeInfo)) return;
-
- if (!this.sizeInfo) this.sizeInfo = {};
-
- var newElement = document.createElement('div'),
- menu = document.createElement('div'),
- menuInner = document.createElement('div'),
- menuInnerInner = document.createElement('ul'),
- divider = document.createElement('li'),
- dropdownHeader = document.createElement('li'),
- li = document.createElement('li'),
- a = document.createElement('a'),
- text = document.createElement('span'),
- header = this.options.header && this.$menu.find('.' + classNames.POPOVERHEADER).length > 0 ? this.$menu.find('.' + classNames.POPOVERHEADER)[0].cloneNode(true) : null,
- search = this.options.liveSearch ? document.createElement('div') : null,
- actions = this.options.actionsBox && this.multiple && this.$menu.find('.bs-actionsbox').length > 0 ? this.$menu.find('.bs-actionsbox')[0].cloneNode(true) : null,
- doneButton = this.options.doneButton && this.multiple && this.$menu.find('.bs-donebutton').length > 0 ? this.$menu.find('.bs-donebutton')[0].cloneNode(true) : null,
- firstOption = this.$element.find('option')[0];
-
- this.sizeInfo.selectWidth = this.$newElement[0].offsetWidth;
-
- text.className = 'text';
- a.className = 'dropdown-item ' + (firstOption ? firstOption.className : '');
- newElement.className = this.$menu[0].parentNode.className + ' ' + classNames.SHOW;
- newElement.style.width = this.sizeInfo.selectWidth + 'px';
- if (this.options.width === 'auto') menu.style.minWidth = 0;
- menu.className = classNames.MENU + ' ' + classNames.SHOW;
- menuInner.className = 'inner ' + classNames.SHOW;
- menuInnerInner.className = classNames.MENU + ' inner ' + (version.major === '4' ? classNames.SHOW : '');
- divider.className = classNames.DIVIDER;
- dropdownHeader.className = 'dropdown-header';
-
- text.appendChild(document.createTextNode('\u200b'));
- a.appendChild(text);
- li.appendChild(a);
- dropdownHeader.appendChild(text.cloneNode(true));
-
- if (this.selectpicker.view.widestOption) {
- menuInnerInner.appendChild(this.selectpicker.view.widestOption.cloneNode(true));
- }
-
- menuInnerInner.appendChild(li);
- menuInnerInner.appendChild(divider);
- menuInnerInner.appendChild(dropdownHeader);
- if (header) menu.appendChild(header);
- if (search) {
- var input = document.createElement('input');
- search.className = 'bs-searchbox';
- input.className = 'form-control';
- search.appendChild(input);
- menu.appendChild(search);
- }
- if (actions) menu.appendChild(actions);
- menuInner.appendChild(menuInnerInner);
- menu.appendChild(menuInner);
- if (doneButton) menu.appendChild(doneButton);
- newElement.appendChild(menu);
-
- document.body.appendChild(newElement);
-
- var liHeight = li.offsetHeight,
- dropdownHeaderHeight = dropdownHeader ? dropdownHeader.offsetHeight : 0,
- headerHeight = header ? header.offsetHeight : 0,
- searchHeight = search ? search.offsetHeight : 0,
- actionsHeight = actions ? actions.offsetHeight : 0,
- doneButtonHeight = doneButton ? doneButton.offsetHeight : 0,
- dividerHeight = $(divider).outerHeight(true),
- // fall back to jQuery if getComputedStyle is not supported
- menuStyle = window.getComputedStyle ? window.getComputedStyle(menu) : false,
- menuWidth = menu.offsetWidth,
- $menu = menuStyle ? null : $(menu),
- menuPadding = {
- vert: toInteger(menuStyle ? menuStyle.paddingTop : $menu.css('paddingTop')) +
- toInteger(menuStyle ? menuStyle.paddingBottom : $menu.css('paddingBottom')) +
- toInteger(menuStyle ? menuStyle.borderTopWidth : $menu.css('borderTopWidth')) +
- toInteger(menuStyle ? menuStyle.borderBottomWidth : $menu.css('borderBottomWidth')),
- horiz: toInteger(menuStyle ? menuStyle.paddingLeft : $menu.css('paddingLeft')) +
- toInteger(menuStyle ? menuStyle.paddingRight : $menu.css('paddingRight')) +
- toInteger(menuStyle ? menuStyle.borderLeftWidth : $menu.css('borderLeftWidth')) +
- toInteger(menuStyle ? menuStyle.borderRightWidth : $menu.css('borderRightWidth'))
- },
- menuExtras = {
- vert: menuPadding.vert +
- toInteger(menuStyle ? menuStyle.marginTop : $menu.css('marginTop')) +
- toInteger(menuStyle ? menuStyle.marginBottom : $menu.css('marginBottom')) + 2,
- horiz: menuPadding.horiz +
- toInteger(menuStyle ? menuStyle.marginLeft : $menu.css('marginLeft')) +
- toInteger(menuStyle ? menuStyle.marginRight : $menu.css('marginRight')) + 2
- },
- scrollBarWidth;
-
- menuInner.style.overflowY = 'scroll';
-
- scrollBarWidth = menu.offsetWidth - menuWidth;
-
- document.body.removeChild(newElement);
-
- this.sizeInfo.liHeight = liHeight;
- this.sizeInfo.dropdownHeaderHeight = dropdownHeaderHeight;
- this.sizeInfo.headerHeight = headerHeight;
- this.sizeInfo.searchHeight = searchHeight;
- this.sizeInfo.actionsHeight = actionsHeight;
- this.sizeInfo.doneButtonHeight = doneButtonHeight;
- this.sizeInfo.dividerHeight = dividerHeight;
- this.sizeInfo.menuPadding = menuPadding;
- this.sizeInfo.menuExtras = menuExtras;
- this.sizeInfo.menuWidth = menuWidth;
- this.sizeInfo.totalMenuWidth = this.sizeInfo.menuWidth;
- this.sizeInfo.scrollBarWidth = scrollBarWidth;
- this.sizeInfo.selectHeight = this.$newElement[0].offsetHeight;
-
- this.setPositionData();
- },
-
- getSelectPosition: function () {
- var that = this,
- $window = $(window),
- pos = that.$newElement.offset(),
- $container = $(that.options.container),
- containerPos;
-
- if (that.options.container && $container.length && !$container.is('body')) {
- containerPos = $container.offset();
- containerPos.top += parseInt($container.css('borderTopWidth'));
- containerPos.left += parseInt($container.css('borderLeftWidth'));
- } else {
- containerPos = { top: 0, left: 0 };
- }
-
- var winPad = that.options.windowPadding;
-
- this.sizeInfo.selectOffsetTop = pos.top - containerPos.top - $window.scrollTop();
- this.sizeInfo.selectOffsetBot = $window.height() - this.sizeInfo.selectOffsetTop - this.sizeInfo.selectHeight - containerPos.top - winPad[2];
- this.sizeInfo.selectOffsetLeft = pos.left - containerPos.left - $window.scrollLeft();
- this.sizeInfo.selectOffsetRight = $window.width() - this.sizeInfo.selectOffsetLeft - this.sizeInfo.selectWidth - containerPos.left - winPad[1];
- this.sizeInfo.selectOffsetTop -= winPad[0];
- this.sizeInfo.selectOffsetLeft -= winPad[3];
- },
-
- setMenuSize: function (isAuto) {
- this.getSelectPosition();
-
- var selectWidth = this.sizeInfo.selectWidth,
- liHeight = this.sizeInfo.liHeight,
- headerHeight = this.sizeInfo.headerHeight,
- searchHeight = this.sizeInfo.searchHeight,
- actionsHeight = this.sizeInfo.actionsHeight,
- doneButtonHeight = this.sizeInfo.doneButtonHeight,
- divHeight = this.sizeInfo.dividerHeight,
- menuPadding = this.sizeInfo.menuPadding,
- menuInnerHeight,
- menuHeight,
- divLength = 0,
- minHeight,
- _minHeight,
- maxHeight,
- menuInnerMinHeight,
- estimate;
-
- if (this.options.dropupAuto) {
- // Get the estimated height of the menu without scrollbars.
- // This is useful for smaller menus, where there might be plenty of room
- // below the button without setting dropup, but we can't know
- // the exact height of the menu until createView is called later
- estimate = liHeight * this.selectpicker.current.elements.length + menuPadding.vert;
- this.$newElement.toggleClass(classNames.DROPUP, this.sizeInfo.selectOffsetTop - this.sizeInfo.selectOffsetBot > this.sizeInfo.menuExtras.vert && estimate + this.sizeInfo.menuExtras.vert + 50 > this.sizeInfo.selectOffsetBot);
- }
-
- if (this.options.size === 'auto') {
- _minHeight = this.selectpicker.current.elements.length > 3 ? this.sizeInfo.liHeight * 3 + this.sizeInfo.menuExtras.vert - 2 : 0;
- menuHeight = this.sizeInfo.selectOffsetBot - this.sizeInfo.menuExtras.vert;
- minHeight = _minHeight + headerHeight + searchHeight + actionsHeight + doneButtonHeight;
- menuInnerMinHeight = Math.max(_minHeight - menuPadding.vert, 0);
-
- if (this.$newElement.hasClass(classNames.DROPUP)) {
- menuHeight = this.sizeInfo.selectOffsetTop - this.sizeInfo.menuExtras.vert;
- }
-
- maxHeight = menuHeight;
- menuInnerHeight = menuHeight - headerHeight - searchHeight - actionsHeight - doneButtonHeight - menuPadding.vert;
- } else if (this.options.size && this.options.size != 'auto' && this.selectpicker.current.elements.length > this.options.size) {
- for (var i = 0; i < this.options.size; i++) {
- if (this.selectpicker.current.data[i].type === 'divider') divLength++;
- }
-
- menuHeight = liHeight * this.options.size + divLength * divHeight + menuPadding.vert;
- menuInnerHeight = menuHeight - menuPadding.vert;
- maxHeight = menuHeight + headerHeight + searchHeight + actionsHeight + doneButtonHeight;
- minHeight = menuInnerMinHeight = '';
- }
-
- if (this.options.dropdownAlignRight === 'auto') {
- this.$menu.toggleClass(classNames.MENURIGHT, this.sizeInfo.selectOffsetLeft > this.sizeInfo.selectOffsetRight && this.sizeInfo.selectOffsetRight < (this.sizeInfo.totalMenuWidth - selectWidth));
- }
-
- this.$menu.css({
- 'max-height': maxHeight + 'px',
- 'overflow': 'hidden',
- 'min-height': minHeight + 'px'
- });
-
- this.$menuInner.css({
- 'max-height': menuInnerHeight + 'px',
- 'overflow-y': 'auto',
- 'min-height': menuInnerMinHeight + 'px'
- });
-
- // ensure menuInnerHeight is always a positive number to prevent issues calculating chunkSize in createView
- this.sizeInfo.menuInnerHeight = Math.max(menuInnerHeight, 1);
-
- if (this.selectpicker.current.data.length && this.selectpicker.current.data[this.selectpicker.current.data.length - 1].position > this.sizeInfo.menuInnerHeight) {
- this.sizeInfo.hasScrollBar = true;
- this.sizeInfo.totalMenuWidth = this.sizeInfo.menuWidth + this.sizeInfo.scrollBarWidth;
-
- this.$menu.css('min-width', this.sizeInfo.totalMenuWidth);
- }
-
- if (this.dropdown && this.dropdown._popper) this.dropdown._popper.update();
- },
-
- setSize: function (refresh) {
- this.liHeight(refresh);
-
- if (this.options.header) this.$menu.css('padding-top', 0);
- if (this.options.size === false) return;
-
- var that = this,
- $window = $(window);
-
- this.setMenuSize();
-
- if (this.options.liveSearch) {
- this.$searchbox
- .off('input.setMenuSize propertychange.setMenuSize')
- .on('input.setMenuSize propertychange.setMenuSize', function () {
- return that.setMenuSize();
- });
- }
-
- if (this.options.size === 'auto') {
- $window
- .off('resize' + EVENT_KEY + '.' + this.selectId + '.setMenuSize' + ' scroll' + EVENT_KEY + '.' + this.selectId + '.setMenuSize')
- .on('resize' + EVENT_KEY + '.' + this.selectId + '.setMenuSize' + ' scroll' + EVENT_KEY + '.' + this.selectId + '.setMenuSize', function () {
- return that.setMenuSize();
- });
- } else if (this.options.size && this.options.size != 'auto' && this.selectpicker.current.elements.length > this.options.size) {
- $window.off('resize' + EVENT_KEY + '.' + this.selectId + '.setMenuSize' + ' scroll' + EVENT_KEY + '.' + this.selectId + '.setMenuSize');
- }
-
- that.createView(false, true, refresh);
- },
-
- setWidth: function () {
- var that = this;
-
- if (this.options.width === 'auto') {
- requestAnimationFrame(function () {
- that.$menu.css('min-width', '0');
-
- that.$element.on('loaded' + EVENT_KEY, function () {
- that.liHeight();
- that.setMenuSize();
-
- // Get correct width if element is hidden
- var $selectClone = that.$newElement.clone().appendTo('body'),
- btnWidth = $selectClone.css('width', 'auto').children('button').outerWidth();
-
- $selectClone.remove();
-
- // Set width to whatever's larger, button title or longest option
- that.sizeInfo.selectWidth = Math.max(that.sizeInfo.totalMenuWidth, btnWidth);
- that.$newElement.css('width', that.sizeInfo.selectWidth + 'px');
- });
- });
- } else if (this.options.width === 'fit') {
- // Remove inline min-width so width can be changed from 'auto'
- this.$menu.css('min-width', '');
- this.$newElement.css('width', '').addClass('fit-width');
- } else if (this.options.width) {
- // Remove inline min-width so width can be changed from 'auto'
- this.$menu.css('min-width', '');
- this.$newElement.css('width', this.options.width);
- } else {
- // Remove inline min-width/width so width can be changed
- this.$menu.css('min-width', '');
- this.$newElement.css('width', '');
- }
- // Remove fit-width class if width is changed programmatically
- if (this.$newElement.hasClass('fit-width') && this.options.width !== 'fit') {
- this.$newElement[0].classList.remove('fit-width');
- }
- },
-
- selectPosition: function () {
- this.$bsContainer = $('<div class="bs-container" />');
-
- var that = this,
- $container = $(this.options.container),
- pos,
- containerPos,
- actualHeight,
- getPlacement = function ($element) {
- var containerPosition = {},
- // fall back to dropdown's default display setting if display is not manually set
- display = that.options.display || (
- // Bootstrap 3 doesn't have $.fn.dropdown.Constructor.Default
- $.fn.dropdown.Constructor.Default ? $.fn.dropdown.Constructor.Default.display
- : false
- );
-
- that.$bsContainer.addClass($element.attr('class').replace(/form-control|fit-width/gi, '')).toggleClass(classNames.DROPUP, $element.hasClass(classNames.DROPUP));
- pos = $element.offset();
-
- if (!$container.is('body')) {
- containerPos = $container.offset();
- containerPos.top += parseInt($container.css('borderTopWidth')) - $container.scrollTop();
- containerPos.left += parseInt($container.css('borderLeftWidth')) - $container.scrollLeft();
- } else {
- containerPos = { top: 0, left: 0 };
- }
-
- actualHeight = $element.hasClass(classNames.DROPUP) ? 0 : $element[0].offsetHeight;
-
- // Bootstrap 4+ uses Popper for menu positioning
- if (version.major < 4 || display === 'static') {
- containerPosition.top = pos.top - containerPos.top + actualHeight;
- containerPosition.left = pos.left - containerPos.left;
- }
-
- containerPosition.width = $element[0].offsetWidth;
-
- that.$bsContainer.css(containerPosition);
- };
-
- this.$button.on('click.bs.dropdown.data-api', function () {
- if (that.isDisabled()) {
- return;
- }
-
- getPlacement(that.$newElement);
-
- that.$bsContainer
- .appendTo(that.options.container)
- .toggleClass(classNames.SHOW, !that.$button.hasClass(classNames.SHOW))
- .append(that.$menu);
- });
-
- $(window)
- .off('resize' + EVENT_KEY + '.' + this.selectId + ' scroll' + EVENT_KEY + '.' + this.selectId)
- .on('resize' + EVENT_KEY + '.' + this.selectId + ' scroll' + EVENT_KEY + '.' + this.selectId, function () {
- var isActive = that.$newElement.hasClass(classNames.SHOW);
-
- if (isActive) getPlacement(that.$newElement);
- });
-
- this.$element.on('hide' + EVENT_KEY, function () {
- that.$menu.data('height', that.$menu.height());
- that.$bsContainer.detach();
- });
- },
-
- setOptionStatus: function (selectedOnly) {
- var that = this;
-
- that.noScroll = false;
-
- if (that.selectpicker.view.visibleElements && that.selectpicker.view.visibleElements.length) {
- for (var i = 0; i < that.selectpicker.view.visibleElements.length; i++) {
- var liData = that.selectpicker.current.data[i + that.selectpicker.view.position0],
- option = liData.option;
-
- if (option) {
- if (selectedOnly !== true) {
- that.setDisabled(
- liData.index,
- liData.disabled
- );
- }
-
- that.setSelected(
- liData.index,
- option.selected
- );
- }
- }
- }
- },
-
- /**
- * @param {number} index - the index of the option that is being changed
- * @param {boolean} selected - true if the option is being selected, false if being deselected
- */
- setSelected: function (index, selected) {
- var li = this.selectpicker.main.elements[index],
- liData = this.selectpicker.main.data[index],
- activeIndexIsSet = this.activeIndex !== undefined,
- thisIsActive = this.activeIndex === index,
- prevActive,
- a,
- // if current option is already active
- // OR
- // if the current option is being selected, it's NOT multiple, and
- // activeIndex is undefined:
- // - when the menu is first being opened, OR
- // - after a search has been performed, OR
- // - when retainActive is false when selecting a new option (i.e. index of the newly selected option is not the same as the current activeIndex)
- keepActive = thisIsActive || (selected && !this.multiple && !activeIndexIsSet);
-
- liData.selected = selected;
-
- a = li.firstChild;
-
- if (selected) {
- this.selectedIndex = index;
- }
-
- li.classList.toggle('selected', selected);
-
- if (keepActive) {
- this.focusItem(li, liData);
- this.selectpicker.view.currentActive = li;
- this.activeIndex = index;
- } else {
- this.defocusItem(li);
- }
-
- if (a) {
- a.classList.toggle('selected', selected);
-
- if (selected) {
- a.setAttribute('aria-selected', true);
- } else {
- if (this.multiple) {
- a.setAttribute('aria-selected', false);
- } else {
- a.removeAttribute('aria-selected');
- }
- }
- }
-
- if (!keepActive && !activeIndexIsSet && selected && this.prevActiveIndex !== undefined) {
- prevActive = this.selectpicker.main.elements[this.prevActiveIndex];
-
- this.defocusItem(prevActive);
- }
- },
-
- /**
- * @param {number} index - the index of the option that is being disabled
- * @param {boolean} disabled - true if the option is being disabled, false if being enabled
- */
- setDisabled: function (index, disabled) {
- var li = this.selectpicker.main.elements[index],
- a;
-
- this.selectpicker.main.data[index].disabled = disabled;
-
- a = li.firstChild;
-
- li.classList.toggle(classNames.DISABLED, disabled);
-
- if (a) {
- if (version.major === '4') a.classList.toggle(classNames.DISABLED, disabled);
-
- if (disabled) {
- a.setAttribute('aria-disabled', disabled);
- a.setAttribute('tabindex', -1);
- } else {
- a.removeAttribute('aria-disabled');
- a.setAttribute('tabindex', 0);
- }
- }
- },
-
- isDisabled: function () {
- return this.$element[0].disabled;
- },
-
- checkDisabled: function () {
- var that = this;
-
- if (this.isDisabled()) {
- this.$newElement[0].classList.add(classNames.DISABLED);
- this.$button.addClass(classNames.DISABLED).attr('tabindex', -1).attr('aria-disabled', true);
- } else {
- if (this.$button[0].classList.contains(classNames.DISABLED)) {
- this.$newElement[0].classList.remove(classNames.DISABLED);
- this.$button.removeClass(classNames.DISABLED).attr('aria-disabled', false);
- }
-
- if (this.$button.attr('tabindex') == -1 && !this.$element.data('tabindex')) {
- this.$button.removeAttr('tabindex');
- }
- }
-
- this.$button.on('click', function () {
- return !that.isDisabled();
- });
- },
-
- tabIndex: function () {
- if (this.$element.data('tabindex') !== this.$element.attr('tabindex') &&
- (this.$element.attr('tabindex') !== -98 && this.$element.attr('tabindex') !== '-98')) {
- this.$element.data('tabindex', this.$element.attr('tabindex'));
- this.$button.attr('tabindex', this.$element.data('tabindex'));
- }
-
- this.$element.attr('tabindex', -98);
- },
-
- clickListener: function () {
- var that = this,
- $document = $(document);
-
- $document.data('spaceSelect', false);
-
- this.$button.on('keyup', function (e) {
- if (/(32)/.test(e.keyCode.toString(10)) && $document.data('spaceSelect')) {
- e.preventDefault();
- $document.data('spaceSelect', false);
- }
- });
-
- this.$newElement.on('show.bs.dropdown', function () {
- if (version.major > 3 && !that.dropdown) {
- that.dropdown = that.$button.data('bs.dropdown');
- that.dropdown._menu = that.$menu[0];
- }
- });
-
- this.$button.on('click.bs.dropdown.data-api', function () {
- if (!that.$newElement.hasClass(classNames.SHOW)) {
- that.setSize();
- }
- });
-
- function setFocus () {
- if (that.options.liveSearch) {
- that.$searchbox.trigger('focus');
- } else {
- that.$menuInner.trigger('focus');
- }
- }
-
- function checkPopperExists () {
- if (that.dropdown && that.dropdown._popper && that.dropdown._popper.state.isCreated) {
- setFocus();
- } else {
- requestAnimationFrame(checkPopperExists);
- }
- }
-
- this.$element.on('shown' + EVENT_KEY, function () {
- if (that.$menuInner[0].scrollTop !== that.selectpicker.view.scrollTop) {
- that.$menuInner[0].scrollTop = that.selectpicker.view.scrollTop;
- }
-
- if (version.major > 3) {
- requestAnimationFrame(checkPopperExists);
- } else {
- setFocus();
- }
- });
-
- // ensure posinset and setsize are correct before selecting an option via a click
- this.$menuInner.on('mouseenter', 'li a', function (e) {
- var hoverLi = this.parentElement,
- position0 = that.isVirtual() ? that.selectpicker.view.position0 : 0,
- index = Array.prototype.indexOf.call(hoverLi.parentElement.children, hoverLi),
- hoverData = that.selectpicker.current.data[index + position0];
-
- that.focusItem(hoverLi, hoverData, true);
- });
-
- this.$menuInner.on('click', 'li a', function (e, retainActive) {
- var $this = $(this),
- element = that.$element[0],
- position0 = that.isVirtual() ? that.selectpicker.view.position0 : 0,
- clickedData = that.selectpicker.current.data[$this.parent().index() + position0],
- clickedIndex = clickedData.index,
- prevValue = getSelectValues(element),
- prevIndex = element.selectedIndex,
- prevOption = element.options[prevIndex],
- triggerChange = true;
-
- // Don't close on multi choice menu
- if (that.multiple && that.options.maxOptions !== 1) {
- e.stopPropagation();
- }
-
- e.preventDefault();
-
- // Don't run if the select is disabled
- if (!that.isDisabled() && !$this.parent().hasClass(classNames.DISABLED)) {
- var $options = that.$element.find('option'),
- option = clickedData.option,
- $option = $(option),
- state = option.selected,
- $optgroup = $option.parent('optgroup'),
- $optgroupOptions = $optgroup.find('option'),
- maxOptions = that.options.maxOptions,
- maxOptionsGrp = $optgroup.data('maxOptions') || false;
-
- if (clickedIndex === that.activeIndex) retainActive = true;
-
- if (!retainActive) {
- that.prevActiveIndex = that.activeIndex;
- that.activeIndex = undefined;
- }
-
- if (!that.multiple) { // Deselect all others if not multi select box
- prevOption.selected = false;
- option.selected = true;
- that.setSelected(clickedIndex, true);
- } else { // Toggle the one we have chosen if we are multi select.
- option.selected = !state;
-
- that.setSelected(clickedIndex, !state);
- $this.trigger('blur');
-
- if (maxOptions !== false || maxOptionsGrp !== false) {
- var maxReached = maxOptions < $options.filter(':selected').length,
- maxReachedGrp = maxOptionsGrp < $optgroup.find('option:selected').length;
-
- if ((maxOptions && maxReached) || (maxOptionsGrp && maxReachedGrp)) {
- if (maxOptions && maxOptions == 1) {
- $options.prop('selected', false);
- $option.prop('selected', true);
-
- for (var i = 0; i < $options.length; i++) {
- that.setSelected(i, false);
- }
-
- that.setSelected(clickedIndex, true);
- } else if (maxOptionsGrp && maxOptionsGrp == 1) {
- $optgroup.find('option:selected').prop('selected', false);
- $option.prop('selected', true);
-
- for (var i = 0; i < $optgroupOptions.length; i++) {
- var option = $optgroupOptions[i];
- that.setSelected($options.index(option), false);
- }
-
- that.setSelected(clickedIndex, true);
- } else {
- var maxOptionsText = typeof that.options.maxOptionsText === 'string' ? [that.options.maxOptionsText, that.options.maxOptionsText] : that.options.maxOptionsText,
- maxOptionsArr = typeof maxOptionsText === 'function' ? maxOptionsText(maxOptions, maxOptionsGrp) : maxOptionsText,
- maxTxt = maxOptionsArr[0].replace('{n}', maxOptions),
- maxTxtGrp = maxOptionsArr[1].replace('{n}', maxOptionsGrp),
- $notify = $('<div class="notify"></div>');
- // If {var} is set in array, replace it
- /** @deprecated */
- if (maxOptionsArr[2]) {
- maxTxt = maxTxt.replace('{var}', maxOptionsArr[2][maxOptions > 1 ? 0 : 1]);
- maxTxtGrp = maxTxtGrp.replace('{var}', maxOptionsArr[2][maxOptionsGrp > 1 ? 0 : 1]);
- }
-
- $option.prop('selected', false);
-
- that.$menu.append($notify);
-
- if (maxOptions && maxReached) {
- $notify.append($('<div>' + maxTxt + '</div>'));
- triggerChange = false;
- that.$element.trigger('maxReached' + EVENT_KEY);
- }
-
- if (maxOptionsGrp && maxReachedGrp) {
- $notify.append($('<div>' + maxTxtGrp + '</div>'));
- triggerChange = false;
- that.$element.trigger('maxReachedGrp' + EVENT_KEY);
- }
-
- setTimeout(function () {
- that.setSelected(clickedIndex, false);
- }, 10);
-
- $notify.delay(750).fadeOut(300, function () {
- $(this).remove();
- });
- }
- }
- }
- }
-
- if (!that.multiple || (that.multiple && that.options.maxOptions === 1)) {
- that.$button.trigger('focus');
- } else if (that.options.liveSearch) {
- that.$searchbox.trigger('focus');
- }
-
- // Trigger select 'change'
- if (triggerChange) {
- if (that.multiple || prevIndex !== element.selectedIndex) {
- // $option.prop('selected') is current option state (selected/unselected). prevValue is the value of the select prior to being changed.
- changedArguments = [option.index, $option.prop('selected'), prevValue];
- that.$element
- .triggerNative('change');
- }
- }
- }
- });
-
- this.$menu.on('click', 'li.' + classNames.DISABLED + ' a, .' + classNames.POPOVERHEADER + ', .' + classNames.POPOVERHEADER + ' :not(.close)', function (e) {
- if (e.currentTarget == this) {
- e.preventDefault();
- e.stopPropagation();
- if (that.options.liveSearch && !$(e.target).hasClass('close')) {
- that.$searchbox.trigger('focus');
- } else {
- that.$button.trigger('focus');
- }
- }
- });
-
- this.$menuInner.on('click', '.divider, .dropdown-header', function (e) {
- e.preventDefault();
- e.stopPropagation();
- if (that.options.liveSearch) {
- that.$searchbox.trigger('focus');
- } else {
- that.$button.trigger('focus');
- }
- });
-
- this.$menu.on('click', '.' + classNames.POPOVERHEADER + ' .close', function () {
- that.$button.trigger('click');
- });
-
- this.$searchbox.on('click', function (e) {
- e.stopPropagation();
- });
-
- this.$menu.on('click', '.actions-btn', function (e) {
- if (that.options.liveSearch) {
- that.$searchbox.trigger('focus');
- } else {
- that.$button.trigger('focus');
- }
-
- e.preventDefault();
- e.stopPropagation();
-
- if ($(this).hasClass('bs-select-all')) {
- that.selectAll();
- } else {
- that.deselectAll();
- }
- });
-
- this.$element
- .on('change' + EVENT_KEY, function () {
- that.render();
- that.$element.trigger('changed' + EVENT_KEY, changedArguments);
- changedArguments = null;
- })
- .on('focus' + EVENT_KEY, function () {
- if (!that.options.mobile) that.$button.trigger('focus');
- });
- },
-
- liveSearchListener: function () {
- var that = this,
- noResults = document.createElement('li');
-
- this.$button.on('click.bs.dropdown.data-api', function () {
- if (!!that.$searchbox.val()) {
- that.$searchbox.val('');
- }
- });
-
- this.$searchbox.on('click.bs.dropdown.data-api focus.bs.dropdown.data-api touchend.bs.dropdown.data-api', function (e) {
- e.stopPropagation();
- });
-
- this.$searchbox.on('input propertychange', function () {
- var searchValue = that.$searchbox.val();
-
- that.selectpicker.search.elements = [];
- that.selectpicker.search.data = [];
-
- if (searchValue) {
- var i,
- searchMatch = [],
- q = searchValue.toUpperCase(),
- cache = {},
- cacheArr = [],
- searchStyle = that._searchStyle(),
- normalizeSearch = that.options.liveSearchNormalize;
-
- if (normalizeSearch) q = normalizeToBase(q);
-
- that._$lisSelected = that.$menuInner.find('.selected');
-
- for (var i = 0; i < that.selectpicker.main.data.length; i++) {
- var li = that.selectpicker.main.data[i];
-
- if (!cache[i]) {
- cache[i] = stringSearch(li, q, searchStyle, normalizeSearch);
- }
-
- if (cache[i] && li.headerIndex !== undefined && cacheArr.indexOf(li.headerIndex) === -1) {
- if (li.headerIndex > 0) {
- cache[li.headerIndex - 1] = true;
- cacheArr.push(li.headerIndex - 1);
- }
-
- cache[li.headerIndex] = true;
- cacheArr.push(li.headerIndex);
-
- cache[li.lastIndex + 1] = true;
- }
-
- if (cache[i] && li.type !== 'optgroup-label') cacheArr.push(i);
- }
-
- for (var i = 0, cacheLen = cacheArr.length; i < cacheLen; i++) {
- var index = cacheArr[i],
- prevIndex = cacheArr[i - 1],
- li = that.selectpicker.main.data[index],
- liPrev = that.selectpicker.main.data[prevIndex];
-
- if (li.type !== 'divider' || (li.type === 'divider' && liPrev && liPrev.type !== 'divider' && cacheLen - 1 !== i)) {
- that.selectpicker.search.data.push(li);
- searchMatch.push(that.selectpicker.main.elements[index]);
- }
- }
-
- that.activeIndex = undefined;
- that.noScroll = true;
- that.$menuInner.scrollTop(0);
- that.selectpicker.search.elements = searchMatch;
- that.createView(true);
-
- if (!searchMatch.length) {
- noResults.className = 'no-results';
- noResults.innerHTML = that.options.noneResultsText.replace('{0}', '"' + htmlEscape(searchValue) + '"');
- that.$menuInner[0].firstChild.appendChild(noResults);
- }
- } else {
- that.$menuInner.scrollTop(0);
- that.createView(false);
- }
- });
- },
-
- _searchStyle: function () {
- return this.options.liveSearchStyle || 'contains';
- },
-
- val: function (value) {
- var element = this.$element[0];
-
- if (typeof value !== 'undefined') {
- var prevValue = getSelectValues(element);
-
- changedArguments = [null, null, prevValue];
-
- this.$element
- .val(value)
- .trigger('changed' + EVENT_KEY, changedArguments);
-
- if (this.$newElement.hasClass(classNames.SHOW)) {
- if (this.multiple) {
- this.setOptionStatus(true);
- } else {
- var liSelectedIndex = (element.options[element.selectedIndex] || {}).liIndex;
-
- if (typeof liSelectedIndex === 'number') {
- this.setSelected(this.selectedIndex, false);
- this.setSelected(liSelectedIndex, true);
- }
- }
- }
-
- this.render();
-
- changedArguments = null;
-
- return this.$element;
- } else {
- return this.$element.val();
- }
- },
-
- changeAll: function (status) {
- if (!this.multiple) return;
- if (typeof status === 'undefined') status = true;
-
- var element = this.$element[0],
- previousSelected = 0,
- currentSelected = 0,
- prevValue = getSelectValues(element);
-
- element.classList.add('bs-select-hidden');
-
- for (var i = 0, len = this.selectpicker.current.elements.length; i < len; i++) {
- var liData = this.selectpicker.current.data[i],
- option = liData.option;
-
- if (option && !liData.disabled && liData.type !== 'divider') {
- if (liData.selected) previousSelected++;
- option.selected = status;
- if (status) currentSelected++;
- }
- }
-
- element.classList.remove('bs-select-hidden');
-
- if (previousSelected === currentSelected) return;
-
- this.setOptionStatus();
-
- changedArguments = [null, null, prevValue];
-
- this.$element
- .triggerNative('change');
- },
-
- selectAll: function () {
- return this.changeAll(true);
- },
-
- deselectAll: function () {
- return this.changeAll(false);
- },
-
- toggle: function (e) {
- e = e || window.event;
-
- if (e) e.stopPropagation();
-
- this.$button.trigger('click.bs.dropdown.data-api');
- },
-
- keydown: function (e) {
- var $this = $(this),
- isToggle = $this.hasClass('dropdown-toggle'),
- $parent = isToggle ? $this.closest('.dropdown') : $this.closest(Selector.MENU),
- that = $parent.data('this'),
- $items = that.findLis(),
- index,
- isActive,
- liActive,
- activeLi,
- offset,
- updateScroll = false,
- downOnTab = e.which === keyCodes.TAB && !isToggle && !that.options.selectOnTab,
- isArrowKey = REGEXP_ARROW.test(e.which) || downOnTab,
- scrollTop = that.$menuInner[0].scrollTop,
- isVirtual = that.isVirtual(),
- position0 = isVirtual === true ? that.selectpicker.view.position0 : 0;
-
- isActive = that.$newElement.hasClass(classNames.SHOW);
-
- if (
- !isActive &&
- (
- isArrowKey ||
- (e.which >= 48 && e.which <= 57) ||
- (e.which >= 96 && e.which <= 105) ||
- (e.which >= 65 && e.which <= 90)
- )
- ) {
- that.$button.trigger('click.bs.dropdown.data-api');
-
- if (that.options.liveSearch) {
- that.$searchbox.trigger('focus');
- return;
- }
- }
-
- if (e.which === keyCodes.ESCAPE && isActive) {
- e.preventDefault();
- that.$button.trigger('click.bs.dropdown.data-api').trigger('focus');
- }
-
- if (isArrowKey) { // if up or down
- if (!$items.length) return;
-
- liActive = that.selectpicker.main.elements[that.activeIndex];
- index = liActive ? Array.prototype.indexOf.call(liActive.parentElement.children, liActive) : -1;
-
- if (index !== -1) {
- that.defocusItem(liActive);
- }
-
- if (e.which === keyCodes.ARROW_UP) { // up
- if (index !== -1) index--;
- if (index + position0 < 0) index += $items.length;
-
- if (!that.selectpicker.view.canHighlight[index + position0]) {
- index = that.selectpicker.view.canHighlight.slice(0, index + position0).lastIndexOf(true) - position0;
- if (index === -1) index = $items.length - 1;
- }
- } else if (e.which === keyCodes.ARROW_DOWN || downOnTab) { // down
- index++;
- if (index + position0 >= that.selectpicker.view.canHighlight.length) index = 0;
-
- if (!that.selectpicker.view.canHighlight[index + position0]) {
- index = index + 1 + that.selectpicker.view.canHighlight.slice(index + position0 + 1).indexOf(true);
- }
- }
-
- e.preventDefault();
-
- var liActiveIndex = position0 + index;
-
- if (e.which === keyCodes.ARROW_UP) { // up
- // scroll to bottom and highlight last option
- if (position0 === 0 && index === $items.length - 1) {
- that.$menuInner[0].scrollTop = that.$menuInner[0].scrollHeight;
-
- liActiveIndex = that.selectpicker.current.elements.length - 1;
- } else {
- activeLi = that.selectpicker.current.data[liActiveIndex];
- offset = activeLi.position - activeLi.height;
-
- updateScroll = offset < scrollTop;
- }
- } else if (e.which === keyCodes.ARROW_DOWN || downOnTab) { // down
- // scroll to top and highlight first option
- if (index === 0) {
- that.$menuInner[0].scrollTop = 0;
-
- liActiveIndex = 0;
- } else {
- activeLi = that.selectpicker.current.data[liActiveIndex];
- offset = activeLi.position - that.sizeInfo.menuInnerHeight;
-
- updateScroll = offset > scrollTop;
- }
- }
-
- liActive = that.selectpicker.current.elements[liActiveIndex];
-
- that.activeIndex = that.selectpicker.current.data[liActiveIndex].index;
-
- that.focusItem(liActive);
-
- that.selectpicker.view.currentActive = liActive;
-
- if (updateScroll) that.$menuInner[0].scrollTop = offset;
-
- if (that.options.liveSearch) {
- that.$searchbox.trigger('focus');
- } else {
- $this.trigger('focus');
- }
- } else if (
- (!$this.is('input') && !REGEXP_TAB_OR_ESCAPE.test(e.which)) ||
- (e.which === keyCodes.SPACE && that.selectpicker.keydown.keyHistory)
- ) {
- var searchMatch,
- matches = [],
- keyHistory;
-
- e.preventDefault();
-
- that.selectpicker.keydown.keyHistory += keyCodeMap[e.which];
-
- if (that.selectpicker.keydown.resetKeyHistory.cancel) clearTimeout(that.selectpicker.keydown.resetKeyHistory.cancel);
- that.selectpicker.keydown.resetKeyHistory.cancel = that.selectpicker.keydown.resetKeyHistory.start();
-
- keyHistory = that.selectpicker.keydown.keyHistory;
-
- // if all letters are the same, set keyHistory to just the first character when searching
- if (/^(.)\1+$/.test(keyHistory)) {
- keyHistory = keyHistory.charAt(0);
- }
-
- // find matches
- for (var i = 0; i < that.selectpicker.current.data.length; i++) {
- var li = that.selectpicker.current.data[i],
- hasMatch;
-
- hasMatch = stringSearch(li, keyHistory, 'startsWith', true);
-
- if (hasMatch && that.selectpicker.view.canHighlight[i]) {
- matches.push(li.index);
- }
- }
-
- if (matches.length) {
- var matchIndex = 0;
-
- $items.removeClass('active').find('a').removeClass('active');
-
- // either only one key has been pressed or they are all the same key
- if (keyHistory.length === 1) {
- matchIndex = matches.indexOf(that.activeIndex);
-
- if (matchIndex === -1 || matchIndex === matches.length - 1) {
- matchIndex = 0;
- } else {
- matchIndex++;
- }
- }
-
- searchMatch = matches[matchIndex];
-
- activeLi = that.selectpicker.main.data[searchMatch];
-
- if (scrollTop - activeLi.position > 0) {
- offset = activeLi.position - activeLi.height;
- updateScroll = true;
- } else {
- offset = activeLi.position - that.sizeInfo.menuInnerHeight;
- // if the option is already visible at the current scroll position, just keep it the same
- updateScroll = activeLi.position > scrollTop + that.sizeInfo.menuInnerHeight;
- }
-
- liActive = that.selectpicker.main.elements[searchMatch];
-
- that.activeIndex = matches[matchIndex];
-
- that.focusItem(liActive);
-
- if (liActive) liActive.firstChild.focus();
-
- if (updateScroll) that.$menuInner[0].scrollTop = offset;
-
- $this.trigger('focus');
- }
- }
-
- // Select focused option if "Enter", "Spacebar" or "Tab" (when selectOnTab is true) are pressed inside the menu.
- if (
- isActive &&
- (
- (e.which === keyCodes.SPACE && !that.selectpicker.keydown.keyHistory) ||
- e.which === keyCodes.ENTER ||
- (e.which === keyCodes.TAB && that.options.selectOnTab)
- )
- ) {
- if (e.which !== keyCodes.SPACE) e.preventDefault();
-
- if (!that.options.liveSearch || e.which !== keyCodes.SPACE) {
- that.$menuInner.find('.active a').trigger('click', true); // retain active class
- $this.trigger('focus');
-
- if (!that.options.liveSearch) {
- // Prevent screen from scrolling if the user hits the spacebar
- e.preventDefault();
- // Fixes spacebar selection of dropdown items in FF & IE
- $(document).data('spaceSelect', true);
- }
- }
- }
- },
-
- mobile: function () {
- this.$element[0].classList.add('mobile-device');
- },
-
- refresh: function () {
- // update options if data attributes have been changed
- var config = $.extend({}, this.options, this.$element.data());
- this.options = config;
-
- this.checkDisabled();
- this.setStyle();
- this.render();
- this.createLi();
- this.setWidth();
-
- this.setSize(true);
-
- this.$element.trigger('refreshed' + EVENT_KEY);
- },
-
- hide: function () {
- this.$newElement.hide();
- },
-
- show: function () {
- this.$newElement.show();
- },
-
- remove: function () {
- this.$newElement.remove();
- this.$element.remove();
- },
-
- destroy: function () {
- this.$newElement.before(this.$element).remove();
-
- if (this.$bsContainer) {
- this.$bsContainer.remove();
- } else {
- this.$menu.remove();
- }
-
- this.$element
- .off(EVENT_KEY)
- .removeData('selectpicker')
- .removeClass('bs-select-hidden selectpicker');
-
- $(window).off(EVENT_KEY + '.' + this.selectId);
- }
- };
-
- // SELECTPICKER PLUGIN DEFINITION
- // ==============================
- function Plugin (option) {
- // get the args of the outer function..
- var args = arguments;
- // The arguments of the function are explicitly re-defined from the argument list, because the shift causes them
- // to get lost/corrupted in android 2.3 and IE9 #715 #775
- var _option = option;
-
- [].shift.apply(args);
-
- // if the version was not set successfully
- if (!version.success) {
- // try to retreive it again
- try {
- version.full = ($.fn.dropdown.Constructor.VERSION || '').split(' ')[0].split('.');
- } catch (err) {
- // fall back to use BootstrapVersion if set
- if (Selectpicker.BootstrapVersion) {
- version.full = Selectpicker.BootstrapVersion.split(' ')[0].split('.');
- } else {
- version.full = [version.major, '0', '0'];
-
- console.warn(
- 'There was an issue retrieving Bootstrap\'s version. ' +
- 'Ensure Bootstrap is being loaded before bootstrap-select and there is no namespace collision. ' +
- 'If loading Bootstrap asynchronously, the version may need to be manually specified via $.fn.selectpicker.Constructor.BootstrapVersion.',
- err
- );
- }
- }
-
- version.major = version.full[0];
- version.success = true;
- }
-
- if (version.major === '4') {
- // some defaults need to be changed if using Bootstrap 4
- // check to see if they have already been manually changed before forcing them to update
- var toUpdate = [];
-
- if (Selectpicker.DEFAULTS.style === classNames.BUTTONCLASS) toUpdate.push({ name: 'style', className: 'BUTTONCLASS' });
- if (Selectpicker.DEFAULTS.iconBase === classNames.ICONBASE) toUpdate.push({ name: 'iconBase', className: 'ICONBASE' });
- if (Selectpicker.DEFAULTS.tickIcon === classNames.TICKICON) toUpdate.push({ name: 'tickIcon', className: 'TICKICON' });
-
- classNames.DIVIDER = 'dropdown-divider';
- classNames.SHOW = 'show';
- classNames.BUTTONCLASS = 'btn-light';
- classNames.POPOVERHEADER = 'popover-header';
- classNames.ICONBASE = '';
- classNames.TICKICON = 'bs-ok-default';
-
- for (var i = 0; i < toUpdate.length; i++) {
- var option = toUpdate[i];
- Selectpicker.DEFAULTS[option.name] = classNames[option.className];
- }
- }
-
- var value;
- var chain = this.each(function () {
- var $this = $(this);
- if ($this.is('select')) {
- var data = $this.data('selectpicker'),
- options = typeof _option == 'object' && _option;
-
- if (!data) {
- var dataAttributes = $this.data();
-
- for (var dataAttr in dataAttributes) {
- if (dataAttributes.hasOwnProperty(dataAttr) && $.inArray(dataAttr, DISALLOWED_ATTRIBUTES) !== -1) {
- delete dataAttributes[dataAttr];
- }
- }
-
- var config = $.extend({}, Selectpicker.DEFAULTS, $.fn.selectpicker.defaults || {}, dataAttributes, options);
- config.template = $.extend({}, Selectpicker.DEFAULTS.template, ($.fn.selectpicker.defaults ? $.fn.selectpicker.defaults.template : {}), dataAttributes.template, options.template);
- $this.data('selectpicker', (data = new Selectpicker(this, config)));
- } else if (options) {
- for (var i in options) {
- if (options.hasOwnProperty(i)) {
- data.options[i] = options[i];
- }
- }
- }
-
- if (typeof _option == 'string') {
- if (data[_option] instanceof Function) {
- value = data[_option].apply(data, args);
- } else {
- value = data.options[_option];
- }
- }
- }
- });
-
- if (typeof value !== 'undefined') {
- // noinspection JSUnusedAssignment
- return value;
- } else {
- return chain;
- }
- }
-
- var old = $.fn.selectpicker;
- $.fn.selectpicker = Plugin;
- $.fn.selectpicker.Constructor = Selectpicker;
-
- // SELECTPICKER NO CONFLICT
- // ========================
- $.fn.selectpicker.noConflict = function () {
- $.fn.selectpicker = old;
- return this;
- };
-
- $(document)
- .off('keydown.bs.dropdown.data-api')
- .on('keydown' + EVENT_KEY, '.bootstrap-select [data-toggle="dropdown"], .bootstrap-select [role="listbox"], .bootstrap-select .bs-searchbox input', Selectpicker.prototype.keydown)
- .on('focusin.modal', '.bootstrap-select [data-toggle="dropdown"], .bootstrap-select [role="listbox"], .bootstrap-select .bs-searchbox input', function (e) {
- e.stopPropagation();
- });
-
- // SELECTPICKER DATA-API
- // =====================
- $(window).on('load' + EVENT_KEY + '.data-api', function () {
- $('.selectpicker').each(function () {
- var $selectpicker = $(this);
- Plugin.call($selectpicker, $selectpicker.data());
- })
- });
-})(jQuery);
-
-
+/*!
+ * Bootstrap-select v1.13.18 (https://developer.snapappointments.com/bootstrap-select)
+ *
+ * Copyright 2012-2020 SnapAppointments, LLC
+ * Licensed under MIT (https://github.com/snapappointments/bootstrap-select/blob/master/LICENSE)
+ */
+
+(function (root, factory) {
+ if (root === undefined && window !== undefined) root = window;
+ if (typeof define === 'function' && define.amd) {
+ // AMD. Register as an anonymous module unless amdModuleId is set
+ define(["jquery"], function (a0) {
+ return (factory(a0));
+ });
+ } else if (typeof module === 'object' && module.exports) {
+ // Node. Does not work with strict CommonJS, but
+ // only CommonJS-like environments that support module.exports,
+ // like Node.
+ module.exports = factory(require("jquery"));
+ } else {
+ factory(root["jQuery"]);
+ }
+}(this, function (jQuery) {
+
+(function ($) {
+ 'use strict';
+
+ var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
+
+ var uriAttrs = [
+ 'background',
+ 'cite',
+ 'href',
+ 'itemtype',
+ 'longdesc',
+ 'poster',
+ 'src',
+ 'xlink:href'
+ ];
+
+ var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
+
+ var DefaultWhitelist = {
+ // Global attributes allowed on any supplied element below.
+ '*': ['class', 'dir', 'id', 'lang', 'role', 'tabindex', 'style', ARIA_ATTRIBUTE_PATTERN],
+ a: ['target', 'href', 'title', 'rel'],
+ area: [],
+ b: [],
+ br: [],
+ col: [],
+ code: [],
+ div: [],
+ em: [],
+ hr: [],
+ h1: [],
+ h2: [],
+ h3: [],
+ h4: [],
+ h5: [],
+ h6: [],
+ i: [],
+ img: ['src', 'alt', 'title', 'width', 'height'],
+ li: [],
+ ol: [],
+ p: [],
+ pre: [],
+ s: [],
+ small: [],
+ span: [],
+ sub: [],
+ sup: [],
+ strong: [],
+ u: [],
+ ul: []
+ }
+
+ /**
+ * A pattern that recognizes a commonly useful subset of URLs that are safe.
+ *
+ * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
+ */
+ var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi;
+
+ /**
+ * A pattern that matches safe data URLs. Only matches image, video and audio types.
+ *
+ * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
+ */
+ var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i;
+
+ function allowedAttribute (attr, allowedAttributeList) {
+ var attrName = attr.nodeName.toLowerCase()
+
+ if ($.inArray(attrName, allowedAttributeList) !== -1) {
+ if ($.inArray(attrName, uriAttrs) !== -1) {
+ return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN))
+ }
+
+ return true
+ }
+
+ var regExp = $(allowedAttributeList).filter(function (index, value) {
+ return value instanceof RegExp
+ })
+
+ // Check if a regular expression validates the attribute.
+ for (var i = 0, l = regExp.length; i < l; i++) {
+ if (attrName.match(regExp[i])) {
+ return true
+ }
+ }
+
+ return false
+ }
+
+ function sanitizeHtml (unsafeElements, whiteList, sanitizeFn) {
+ if (sanitizeFn && typeof sanitizeFn === 'function') {
+ return sanitizeFn(unsafeElements);
+ }
+
+ var whitelistKeys = Object.keys(whiteList);
+
+ for (var i = 0, len = unsafeElements.length; i < len; i++) {
+ var elements = unsafeElements[i].querySelectorAll('*');
+
+ for (var j = 0, len2 = elements.length; j < len2; j++) {
+ var el = elements[j];
+ var elName = el.nodeName.toLowerCase();
+
+ if (whitelistKeys.indexOf(elName) === -1) {
+ el.parentNode.removeChild(el);
+
+ continue;
+ }
+
+ var attributeList = [].slice.call(el.attributes);
+ var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
+
+ for (var k = 0, len3 = attributeList.length; k < len3; k++) {
+ var attr = attributeList[k];
+
+ if (!allowedAttribute(attr, whitelistedAttributes)) {
+ el.removeAttribute(attr.nodeName);
+ }
+ }
+ }
+ }
+ }
+
+ // Polyfill for browsers with no classList support
+ // Remove in v2
+ if (!('classList' in document.createElement('_'))) {
+ (function (view) {
+ if (!('Element' in view)) return;
+
+ var classListProp = 'classList',
+ protoProp = 'prototype',
+ elemCtrProto = view.Element[protoProp],
+ objCtr = Object,
+ classListGetter = function () {
+ var $elem = $(this);
+
+ return {
+ add: function (classes) {
+ classes = Array.prototype.slice.call(arguments).join(' ');
+ return $elem.addClass(classes);
+ },
+ remove: function (classes) {
+ classes = Array.prototype.slice.call(arguments).join(' ');
+ return $elem.removeClass(classes);
+ },
+ toggle: function (classes, force) {
+ return $elem.toggleClass(classes, force);
+ },
+ contains: function (classes) {
+ return $elem.hasClass(classes);
+ }
+ }
+ };
+
+ if (objCtr.defineProperty) {
+ var classListPropDesc = {
+ get: classListGetter,
+ enumerable: true,
+ configurable: true
+ };
+ try {
+ objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc);
+ } catch (ex) { // IE 8 doesn't support enumerable:true
+ // adding undefined to fight this issue https://github.com/eligrey/classList.js/issues/36
+ // modernie IE8-MSW7 machine has IE8 8.0.6001.18702 and is affected
+ if (ex.number === undefined || ex.number === -0x7FF5EC54) {
+ classListPropDesc.enumerable = false;
+ objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc);
+ }
+ }
+ } else if (objCtr[protoProp].__defineGetter__) {
+ elemCtrProto.__defineGetter__(classListProp, classListGetter);
+ }
+ }(window));
+ }
+
+ var testElement = document.createElement('_');
+
+ testElement.classList.add('c1', 'c2');
+
+ if (!testElement.classList.contains('c2')) {
+ var _add = DOMTokenList.prototype.add,
+ _remove = DOMTokenList.prototype.remove;
+
+ DOMTokenList.prototype.add = function () {
+ Array.prototype.forEach.call(arguments, _add.bind(this));
+ }
+
+ DOMTokenList.prototype.remove = function () {
+ Array.prototype.forEach.call(arguments, _remove.bind(this));
+ }
+ }
+
+ testElement.classList.toggle('c3', false);
+
+ // Polyfill for IE 10 and Firefox <24, where classList.toggle does not
+ // support the second argument.
+ if (testElement.classList.contains('c3')) {
+ var _toggle = DOMTokenList.prototype.toggle;
+
+ DOMTokenList.prototype.toggle = function (token, force) {
+ if (1 in arguments && !this.contains(token) === !force) {
+ return force;
+ } else {
+ return _toggle.call(this, token);
+ }
+ };
+ }
+
+ testElement = null;
+
+ // shallow array comparison
+ function isEqual (array1, array2) {
+ return array1.length === array2.length && array1.every(function (element, index) {
+ return element === array2[index];
+ });
+ };
+
+ // <editor-fold desc="Shims">
+ if (!String.prototype.startsWith) {
+ (function () {
+ 'use strict'; // needed to support `apply`/`call` with `undefined`/`null`
+ var defineProperty = (function () {
+ // IE 8 only supports `Object.defineProperty` on DOM elements
+ try {
+ var object = {};
+ var $defineProperty = Object.defineProperty;
+ var result = $defineProperty(object, object, object) && $defineProperty;
+ } catch (error) {
+ }
+ return result;
+ }());
+ var toString = {}.toString;
+ var startsWith = function (search) {
+ if (this == null) {
+ throw new TypeError();
+ }
+ var string = String(this);
+ if (search && toString.call(search) == '[object RegExp]') {
+ throw new TypeError();
+ }
+ var stringLength = string.length;
+ var searchString = String(search);
+ var searchLength = searchString.length;
+ var position = arguments.length > 1 ? arguments[1] : undefined;
+ // `ToInteger`
+ var pos = position ? Number(position) : 0;
+ if (pos != pos) { // better `isNaN`
+ pos = 0;
+ }
+ var start = Math.min(Math.max(pos, 0), stringLength);
+ // Avoid the `indexOf` call if no match is possible
+ if (searchLength + start > stringLength) {
+ return false;
+ }
+ var index = -1;
+ while (++index < searchLength) {
+ if (string.charCodeAt(start + index) != searchString.charCodeAt(index)) {
+ return false;
+ }
+ }
+ return true;
+ };
+ if (defineProperty) {
+ defineProperty(String.prototype, 'startsWith', {
+ 'value': startsWith,
+ 'configurable': true,
+ 'writable': true
+ });
+ } else {
+ String.prototype.startsWith = startsWith;
+ }
+ }());
+ }
+
+ if (!Object.keys) {
+ Object.keys = function (
+ o, // object
+ k, // key
+ r // result array
+ ) {
+ // initialize object and result
+ r = [];
+ // iterate over object keys
+ for (k in o) {
+ // fill result array with non-prototypical keys
+ r.hasOwnProperty.call(o, k) && r.push(k);
+ }
+ // return result
+ return r;
+ };
+ }
+
+ if (HTMLSelectElement && !HTMLSelectElement.prototype.hasOwnProperty('selectedOptions')) {
+ Object.defineProperty(HTMLSelectElement.prototype, 'selectedOptions', {
+ get: function () {
+ return this.querySelectorAll(':checked');
+ }
+ });
+ }
+
+ function getSelectedOptions (select, ignoreDisabled) {
+ var selectedOptions = select.selectedOptions,
+ options = [],
+ opt;
+
+ if (ignoreDisabled) {
+ for (var i = 0, len = selectedOptions.length; i < len; i++) {
+ opt = selectedOptions[i];
+
+ if (!(opt.disabled || opt.parentNode.tagName === 'OPTGROUP' && opt.parentNode.disabled)) {
+ options.push(opt);
+ }
+ }
+
+ return options;
+ }
+
+ return selectedOptions;
+ }
+
+ // much faster than $.val()
+ function getSelectValues (select, selectedOptions) {
+ var value = [],
+ options = selectedOptions || select.selectedOptions,
+ opt;
+
+ for (var i = 0, len = options.length; i < len; i++) {
+ opt = options[i];
+
+ if (!(opt.disabled || opt.parentNode.tagName === 'OPTGROUP' && opt.parentNode.disabled)) {
+ value.push(opt.value);
+ }
+ }
+
+ if (!select.multiple) {
+ return !value.length ? null : value[0];
+ }
+
+ return value;
+ }
+
+ // set data-selected on select element if the value has been programmatically selected
+ // prior to initialization of bootstrap-select
+ // * consider removing or replacing an alternative method *
+ var valHooks = {
+ useDefault: false,
+ _set: $.valHooks.select.set
+ };
+
+ $.valHooks.select.set = function (elem, value) {
+ if (value && !valHooks.useDefault) $(elem).data('selected', true);
+
+ return valHooks._set.apply(this, arguments);
+ };
+
+ var changedArguments = null;
+
+ var EventIsSupported = (function () {
+ try {
+ new Event('change');
+ return true;
+ } catch (e) {
+ return false;
+ }
+ })();
+
+ $.fn.triggerNative = function (eventName) {
+ var el = this[0],
+ event;
+
+ if (el.dispatchEvent) { // for modern browsers & IE9+
+ if (EventIsSupported) {
+ // For modern browsers
+ event = new Event(eventName, {
+ bubbles: true
+ });
+ } else {
+ // For IE since it doesn't support Event constructor
+ event = document.createEvent('Event');
+ event.initEvent(eventName, true, false);
+ }
+
+ el.dispatchEvent(event);
+ } else if (el.fireEvent) { // for IE8
+ event = document.createEventObject();
+ event.eventType = eventName;
+ el.fireEvent('on' + eventName, event);
+ } else {
+ // fall back to jQuery.trigger
+ this.trigger(eventName);
+ }
+ };
+ // </editor-fold>
+
+ function stringSearch (li, searchString, method, normalize) {
+ var stringTypes = [
+ 'display',
+ 'subtext',
+ 'tokens'
+ ],
+ searchSuccess = false;
+
+ for (var i = 0; i < stringTypes.length; i++) {
+ var stringType = stringTypes[i],
+ string = li[stringType];
+
+ if (string) {
+ string = string.toString();
+
+ // Strip HTML tags. This isn't perfect, but it's much faster than any other method
+ if (stringType === 'display') {
+ string = string.replace(/<[^>]+>/g, '');
+ }
+
+ if (normalize) string = normalizeToBase(string);
+ string = string.toUpperCase();
+
+ if (method === 'contains') {
+ searchSuccess = string.indexOf(searchString) >= 0;
+ } else {
+ searchSuccess = string.startsWith(searchString);
+ }
+
+ if (searchSuccess) break;
+ }
+ }
+
+ return searchSuccess;
+ }
+
+ function toInteger (value) {
+ return parseInt(value, 10) || 0;
+ }
+
+ // Borrowed from Lodash (_.deburr)
+ /** Used to map Latin Unicode letters to basic Latin letters. */
+ var deburredLetters = {
+ // Latin-1 Supplement block.
+ '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
+ '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
+ '\xc7': 'C', '\xe7': 'c',
+ '\xd0': 'D', '\xf0': 'd',
+ '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
+ '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
+ '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
+ '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
+ '\xd1': 'N', '\xf1': 'n',
+ '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
+ '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
+ '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
+ '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
+ '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
+ '\xc6': 'Ae', '\xe6': 'ae',
+ '\xde': 'Th', '\xfe': 'th',
+ '\xdf': 'ss',
+ // Latin Extended-A block.
+ '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
+ '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
+ '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
+ '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
+ '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
+ '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
+ '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
+ '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
+ '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
+ '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
+ '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
+ '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
+ '\u0134': 'J', '\u0135': 'j',
+ '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
+ '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
+ '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
+ '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
+ '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
+ '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
+ '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
+ '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
+ '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
+ '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
+ '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
+ '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
+ '\u0163': 't', '\u0165': 't', '\u0167': 't',
+ '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
+ '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
+ '\u0174': 'W', '\u0175': 'w',
+ '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
+ '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
+ '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
+ '\u0132': 'IJ', '\u0133': 'ij',
+ '\u0152': 'Oe', '\u0153': 'oe',
+ '\u0149': "'n", '\u017f': 's'
+ };
+
+ /** Used to match Latin Unicode letters (excluding mathematical operators). */
+ var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
+
+ /** Used to compose unicode character classes. */
+ var rsComboMarksRange = '\\u0300-\\u036f',
+ reComboHalfMarksRange = '\\ufe20-\\ufe2f',
+ rsComboSymbolsRange = '\\u20d0-\\u20ff',
+ rsComboMarksExtendedRange = '\\u1ab0-\\u1aff',
+ rsComboMarksSupplementRange = '\\u1dc0-\\u1dff',
+ rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange + rsComboMarksExtendedRange + rsComboMarksSupplementRange;
+
+ /** Used to compose unicode capture groups. */
+ var rsCombo = '[' + rsComboRange + ']';
+
+ /**
+ * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
+ * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
+ */
+ var reComboMark = RegExp(rsCombo, 'g');
+
+ function deburrLetter (key) {
+ return deburredLetters[key];
+ };
+
+ function normalizeToBase (string) {
+ string = string.toString();
+ return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
+ }
+
+ // List of HTML entities for escaping.
+ var escapeMap = {
+ '&': '&',
+ '<': '<',
+ '>': '>',
+ '"': '"',
+ "'": ''',
+ '`': '`'
+ };
+
+ // Functions for escaping and unescaping strings to/from HTML interpolation.
+ var createEscaper = function (map) {
+ var escaper = function (match) {
+ return map[match];
+ };
+ // Regexes for identifying a key that needs to be escaped.
+ var source = '(?:' + Object.keys(map).join('|') + ')';
+ var testRegexp = RegExp(source);
+ var replaceRegexp = RegExp(source, 'g');
+ return function (string) {
+ string = string == null ? '' : '' + string;
+ return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;
+ };
+ };
+
+ var htmlEscape = createEscaper(escapeMap);
+
+ /**
+ * ------------------------------------------------------------------------
+ * Constants
+ * ------------------------------------------------------------------------
+ */
+
+ var keyCodeMap = {
+ 32: ' ',
+ 48: '0',
+ 49: '1',
+ 50: '2',
+ 51: '3',
+ 52: '4',
+ 53: '5',
+ 54: '6',
+ 55: '7',
+ 56: '8',
+ 57: '9',
+ 59: ';',
+ 65: 'A',
+ 66: 'B',
+ 67: 'C',
+ 68: 'D',
+ 69: 'E',
+ 70: 'F',
+ 71: 'G',
+ 72: 'H',
+ 73: 'I',
+ 74: 'J',
+ 75: 'K',
+ 76: 'L',
+ 77: 'M',
+ 78: 'N',
+ 79: 'O',
+ 80: 'P',
+ 81: 'Q',
+ 82: 'R',
+ 83: 'S',
+ 84: 'T',
+ 85: 'U',
+ 86: 'V',
+ 87: 'W',
+ 88: 'X',
+ 89: 'Y',
+ 90: 'Z',
+ 96: '0',
+ 97: '1',
+ 98: '2',
+ 99: '3',
+ 100: '4',
+ 101: '5',
+ 102: '6',
+ 103: '7',
+ 104: '8',
+ 105: '9'
+ };
+
+ var keyCodes = {
+ ESCAPE: 27, // KeyboardEvent.which value for Escape (Esc) key
+ ENTER: 13, // KeyboardEvent.which value for Enter key
+ SPACE: 32, // KeyboardEvent.which value for space key
+ TAB: 9, // KeyboardEvent.which value for tab key
+ ARROW_UP: 38, // KeyboardEvent.which value for up arrow key
+ ARROW_DOWN: 40 // KeyboardEvent.which value for down arrow key
+ }
+
+ var version = {
+ success: false,
+ major: '3'
+ };
+
+ try {
+ version.full = ($.fn.dropdown.Constructor.VERSION || '').split(' ')[0].split('.');
+ version.major = version.full[0];
+ version.success = true;
+ } catch (err) {
+ // do nothing
+ }
+
+ var selectId = 0;
+
+ var EVENT_KEY = '.bs.select';
+
+ var classNames = {
+ DISABLED: 'disabled',
+ DIVIDER: 'divider',
+ SHOW: 'open',
+ DROPUP: 'dropup',
+ MENU: 'dropdown-menu',
+ MENURIGHT: 'dropdown-menu-right',
+ MENULEFT: 'dropdown-menu-left',
+ // to-do: replace with more advanced template/customization options
+ BUTTONCLASS: 'btn-default',
+ POPOVERHEADER: 'popover-title',
+ ICONBASE: 'glyphicon',
+ TICKICON: 'glyphicon-ok'
+ }
+
+ var Selector = {
+ MENU: '.' + classNames.MENU
+ }
+
+ var elementTemplates = {
+ div: document.createElement('div'),
+ span: document.createElement('span'),
+ i: document.createElement('i'),
+ subtext: document.createElement('small'),
+ a: document.createElement('a'),
+ li: document.createElement('li'),
+ whitespace: document.createTextNode('\u00A0'),
+ fragment: document.createDocumentFragment()
+ }
+
+ elementTemplates.noResults = elementTemplates.li.cloneNode(false);
+ elementTemplates.noResults.className = 'no-results';
+
+ elementTemplates.a.setAttribute('role', 'option');
+ elementTemplates.a.className = 'dropdown-item';
+
+ elementTemplates.subtext.className = 'text-muted';
+
+ elementTemplates.text = elementTemplates.span.cloneNode(false);
+ elementTemplates.text.className = 'text';
+
+ elementTemplates.checkMark = elementTemplates.span.cloneNode(false);
+
+ var REGEXP_ARROW = new RegExp(keyCodes.ARROW_UP + '|' + keyCodes.ARROW_DOWN);
+ var REGEXP_TAB_OR_ESCAPE = new RegExp('^' + keyCodes.TAB + '$|' + keyCodes.ESCAPE);
+
+ var generateOption = {
+ li: function (content, classes, optgroup) {
+ var li = elementTemplates.li.cloneNode(false);
+
+ if (content) {
+ if (content.nodeType === 1 || content.nodeType === 11) {
+ li.appendChild(content);
+ } else {
+ li.innerHTML = content;
+ }
+ }
+
+ if (typeof classes !== 'undefined' && classes !== '') li.className = classes;
+ if (typeof optgroup !== 'undefined' && optgroup !== null) li.classList.add('optgroup-' + optgroup);
+
+ return li;
+ },
+
+ a: function (text, classes, inline) {
+ var a = elementTemplates.a.cloneNode(true);
+
+ if (text) {
+ if (text.nodeType === 11) {
+ a.appendChild(text);
+ } else {
+ a.insertAdjacentHTML('beforeend', text);
+ }
+ }
+
+ if (typeof classes !== 'undefined' && classes !== '') a.classList.add.apply(a.classList, classes.split(/\s+/));
+ if (inline) a.setAttribute('style', inline);
+
+ return a;
+ },
+
+ text: function (options, useFragment) {
+ var textElement = elementTemplates.text.cloneNode(false),
+ subtextElement,
+ iconElement;
+
+ if (options.content) {
+ textElement.innerHTML = options.content;
+ } else {
+ textElement.textContent = options.text;
+
+ if (options.icon) {
+ var whitespace = elementTemplates.whitespace.cloneNode(false);
+
+ // need to use <i> for icons in the button to prevent a breaking change
+ // note: switch to span in next major release
+ iconElement = (useFragment === true ? elementTemplates.i : elementTemplates.span).cloneNode(false);
+ iconElement.className = this.options.iconBase + ' ' + options.icon;
+
+ elementTemplates.fragment.appendChild(iconElement);
+ elementTemplates.fragment.appendChild(whitespace);
+ }
+
+ if (options.subtext) {
+ subtextElement = elementTemplates.subtext.cloneNode(false);
+ subtextElement.textContent = options.subtext;
+ textElement.appendChild(subtextElement);
+ }
+ }
+
+ if (useFragment === true) {
+ while (textElement.childNodes.length > 0) {
+ elementTemplates.fragment.appendChild(textElement.childNodes[0]);
+ }
+ } else {
+ elementTemplates.fragment.appendChild(textElement);
+ }
+
+ return elementTemplates.fragment;
+ },
+
+ label: function (options) {
+ var textElement = elementTemplates.text.cloneNode(false),
+ subtextElement,
+ iconElement;
+
+ textElement.innerHTML = options.display;
+
+ if (options.icon) {
+ var whitespace = elementTemplates.whitespace.cloneNode(false);
+
+ iconElement = elementTemplates.span.cloneNode(false);
+ iconElement.className = this.options.iconBase + ' ' + options.icon;
+
+ elementTemplates.fragment.appendChild(iconElement);
+ elementTemplates.fragment.appendChild(whitespace);
+ }
+
+ if (options.subtext) {
+ subtextElement = elementTemplates.subtext.cloneNode(false);
+ subtextElement.textContent = options.subtext;
+ textElement.appendChild(subtextElement);
+ }
+
+ elementTemplates.fragment.appendChild(textElement);
+
+ return elementTemplates.fragment;
+ }
+ }
+
+ function showNoResults (searchMatch, searchValue) {
+ if (!searchMatch.length) {
+ elementTemplates.noResults.innerHTML = this.options.noneResultsText.replace('{0}', '"' + htmlEscape(searchValue) + '"');
+ this.$menuInner[0].firstChild.appendChild(elementTemplates.noResults);
+ }
+ }
+
+ var Selectpicker = function (element, options) {
+ var that = this;
+
+ // bootstrap-select has been initialized - revert valHooks.select.set back to its original function
+ if (!valHooks.useDefault) {
+ $.valHooks.select.set = valHooks._set;
+ valHooks.useDefault = true;
+ }
+
+ this.$element = $(element);
+ this.$newElement = null;
+ this.$button = null;
+ this.$menu = null;
+ this.options = options;
+ this.selectpicker = {
+ main: {},
+ search: {},
+ current: {}, // current changes if a search is in progress
+ view: {},
+ isSearching: false,
+ keydown: {
+ keyHistory: '',
+ resetKeyHistory: {
+ start: function () {
+ return setTimeout(function () {
+ that.selectpicker.keydown.keyHistory = '';
+ }, 800);
+ }
+ }
+ }
+ };
+
+ this.sizeInfo = {};
+
+ // If we have no title yet, try to pull it from the html title attribute (jQuery doesnt' pick it up as it's not a
+ // data-attribute)
+ if (this.options.title === null) {
+ this.options.title = this.$element.attr('title');
+ }
+
+ // Format window padding
+ var winPad = this.options.windowPadding;
+ if (typeof winPad === 'number') {
+ this.options.windowPadding = [winPad, winPad, winPad, winPad];
+ }
+
+ // Expose public methods
+ this.val = Selectpicker.prototype.val;
+ this.render = Selectpicker.prototype.render;
+ this.refresh = Selectpicker.prototype.refresh;
+ this.setStyle = Selectpicker.prototype.setStyle;
+ this.selectAll = Selectpicker.prototype.selectAll;
+ this.deselectAll = Selectpicker.prototype.deselectAll;
+ this.destroy = Selectpicker.prototype.destroy;
+ this.remove = Selectpicker.prototype.remove;
+ this.show = Selectpicker.prototype.show;
+ this.hide = Selectpicker.prototype.hide;
+
+ this.init();
+ };
+
+ Selectpicker.VERSION = '1.13.18';
+
+ // part of this is duplicated in i18n/defaults-en_US.js. Make sure to update both.
+ Selectpicker.DEFAULTS = {
+ noneSelectedText: 'Nothing selected',
+ noneResultsText: 'No results matched {0}',
+ countSelectedText: function (numSelected, numTotal) {
+ return (numSelected == 1) ? '{0} item selected' : '{0} items selected';
+ },
+ maxOptionsText: function (numAll, numGroup) {
+ return [
+ (numAll == 1) ? 'Limit reached ({n} item max)' : 'Limit reached ({n} items max)',
+ (numGroup == 1) ? 'Group limit reached ({n} item max)' : 'Group limit reached ({n} items max)'
+ ];
+ },
+ selectAllText: 'Select All',
+ deselectAllText: 'Deselect All',
+ doneButton: false,
+ doneButtonText: 'Close',
+ multipleSeparator: ', ',
+ styleBase: 'btn',
+ style: classNames.BUTTONCLASS,
+ size: 'auto',
+ title: null,
+ selectedTextFormat: 'values',
+ width: false,
+ container: false,
+ hideDisabled: false,
+ showSubtext: false,
+ showIcon: true,
+ showContent: true,
+ dropupAuto: true,
+ header: false,
+ liveSearch: false,
+ liveSearchPlaceholder: null,
+ liveSearchNormalize: false,
+ liveSearchStyle: 'contains',
+ actionsBox: false,
+ iconBase: classNames.ICONBASE,
+ tickIcon: classNames.TICKICON,
+ showTick: false,
+ template: {
+ caret: '<span class="caret"></span>'
+ },
+ maxOptions: false,
+ mobile: false,
+ selectOnTab: false,
+ dropdownAlignRight: false,
+ windowPadding: 0,
+ virtualScroll: 600,
+ display: false,
+ sanitize: true,
+ sanitizeFn: null,
+ whiteList: DefaultWhitelist
+ };
+
+ Selectpicker.prototype = {
+
+ constructor: Selectpicker,
+
+ init: function () {
+ var that = this,
+ id = this.$element.attr('id'),
+ element = this.$element[0],
+ form = element.form;
+
+ selectId++;
+ this.selectId = 'bs-select-' + selectId;
+
+ element.classList.add('bs-select-hidden');
+
+ this.multiple = this.$element.prop('multiple');
+ this.autofocus = this.$element.prop('autofocus');
+
+ if (element.classList.contains('show-tick')) {
+ this.options.showTick = true;
+ }
+
+ this.$newElement = this.createDropdown();
+ this.buildData();
+ this.$element
+ .after(this.$newElement)
+ .prependTo(this.$newElement);
+
+ // ensure select is associated with form element if it got unlinked after moving it inside newElement
+ if (form && element.form === null) {
+ if (!form.id) form.id = 'form-' + this.selectId;
+ element.setAttribute('form', form.id);
+ }
+
+ this.$button = this.$newElement.children('button');
+ this.$menu = this.$newElement.children(Selector.MENU);
+ this.$menuInner = this.$menu.children('.inner');
+ this.$searchbox = this.$menu.find('input');
+
+ element.classList.remove('bs-select-hidden');
+
+ if (this.options.dropdownAlignRight === true) this.$menu[0].classList.add(classNames.MENURIGHT);
+
+ if (typeof id !== 'undefined') {
+ this.$button.attr('data-id', id);
+ }
+
+ this.checkDisabled();
+ this.clickListener();
+
+ if (this.options.liveSearch) {
+ this.liveSearchListener();
+ this.focusedParent = this.$searchbox[0];
+ } else {
+ this.focusedParent = this.$menuInner[0];
+ }
+
+ this.setStyle();
+ this.render();
+ this.setWidth();
+ if (this.options.container) {
+ this.selectPosition();
+ } else {
+ this.$element.on('hide' + EVENT_KEY, function () {
+ if (that.isVirtual()) {
+ // empty menu on close
+ var menuInner = that.$menuInner[0],
+ emptyMenu = menuInner.firstChild.cloneNode(false);
+
+ // replace the existing UL with an empty one - this is faster than $.empty() or innerHTML = ''
+ menuInner.replaceChild(emptyMenu, menuInner.firstChild);
+ menuInner.scrollTop = 0;
+ }
+ });
+ }
+ this.$menu.data('this', this);
+ this.$newElement.data('this', this);
+ if (this.options.mobile) this.mobile();
+
+ this.$newElement.on({
+ 'hide.bs.dropdown': function (e) {
+ that.$element.trigger('hide' + EVENT_KEY, e);
+ },
+ 'hidden.bs.dropdown': function (e) {
+ that.$element.trigger('hidden' + EVENT_KEY, e);
+ },
+ 'show.bs.dropdown': function (e) {
+ that.$element.trigger('show' + EVENT_KEY, e);
+ },
+ 'shown.bs.dropdown': function (e) {
+ that.$element.trigger('shown' + EVENT_KEY, e);
+ }
+ });
+
+ if (element.hasAttribute('required')) {
+ this.$element.on('invalid' + EVENT_KEY, function () {
+ that.$button[0].classList.add('bs-invalid');
+
+ that.$element
+ .on('shown' + EVENT_KEY + '.invalid', function () {
+ that.$element
+ .val(that.$element.val()) // set the value to hide the validation message in Chrome when menu is opened
+ .off('shown' + EVENT_KEY + '.invalid');
+ })
+ .on('rendered' + EVENT_KEY, function () {
+ // if select is no longer invalid, remove the bs-invalid class
+ if (this.validity.valid) that.$button[0].classList.remove('bs-invalid');
+ that.$element.off('rendered' + EVENT_KEY);
+ });
+
+ that.$button.on('blur' + EVENT_KEY, function () {
+ that.$element.trigger('focus').trigger('blur');
+ that.$button.off('blur' + EVENT_KEY);
+ });
+ });
+ }
+
+ setTimeout(function () {
+ that.buildList();
+ that.$element.trigger('loaded' + EVENT_KEY);
+ });
+ },
+
+ createDropdown: function () {
+ // Options
+ // If we are multiple or showTick option is set, then add the show-tick class
+ var showTick = (this.multiple || this.options.showTick) ? ' show-tick' : '',
+ multiselectable = this.multiple ? ' aria-multiselectable="true"' : '',
+ inputGroup = '',
+ autofocus = this.autofocus ? ' autofocus' : '';
+
+ if (version.major < 4 && this.$element.parent().hasClass('input-group')) {
+ inputGroup = ' input-group-btn';
+ }
+
+ // Elements
+ var drop,
+ header = '',
+ searchbox = '',
+ actionsbox = '',
+ donebutton = '';
+
+ if (this.options.header) {
+ header =
+ '<div class="' + classNames.POPOVERHEADER + '">' +
+ '<button type="button" class="close" aria-hidden="true">×</button>' +
+ this.options.header +
+ '</div>';
+ }
+
+ if (this.options.liveSearch) {
+ searchbox =
+ '<div class="bs-searchbox">' +
+ '<input type="search" class="form-control" autocomplete="off"' +
+ (
+ this.options.liveSearchPlaceholder === null ? ''
+ :
+ ' placeholder="' + htmlEscape(this.options.liveSearchPlaceholder) + '"'
+ ) +
+ ' role="combobox" aria-label="Search" aria-controls="' + this.selectId + '" aria-autocomplete="list">' +
+ '</div>';
+ }
+
+ if (this.multiple && this.options.actionsBox) {
+ actionsbox =
+ '<div class="bs-actionsbox">' +
+ '<div class="btn-group btn-group-sm btn-block">' +
+ '<button type="button" class="actions-btn bs-select-all btn ' + classNames.BUTTONCLASS + '">' +
+ this.options.selectAllText +
+ '</button>' +
+ '<button type="button" class="actions-btn bs-deselect-all btn ' + classNames.BUTTONCLASS + '">' +
+ this.options.deselectAllText +
+ '</button>' +
+ '</div>' +
+ '</div>';
+ }
+
+ if (this.multiple && this.options.doneButton) {
+ donebutton =
+ '<div class="bs-donebutton">' +
+ '<div class="btn-group btn-block">' +
+ '<button type="button" class="btn btn-sm ' + classNames.BUTTONCLASS + '">' +
+ this.options.doneButtonText +
+ '</button>' +
+ '</div>' +
+ '</div>';
+ }
+
+ drop =
+ '<div class="dropdown bootstrap-select' + showTick + inputGroup + '">' +
+ '<button type="button" tabindex="-1" class="' + this.options.styleBase + ' dropdown-toggle" ' + (this.options.display === 'static' ? 'data-display="static"' : '') + 'data-toggle="dropdown"' + autofocus + ' role="combobox" aria-owns="' + this.selectId + '" aria-haspopup="listbox" aria-expanded="false">' +
+ '<div class="filter-option">' +
+ '<div class="filter-option-inner">' +
+ '<div class="filter-option-inner-inner"></div>' +
+ '</div> ' +
+ '</div>' +
+ (
+ version.major === '4' ? ''
+ :
+ '<span class="bs-caret">' +
+ this.options.template.caret +
+ '</span>'
+ ) +
+ '</button>' +
+ '<div class="' + classNames.MENU + ' ' + (version.major === '4' ? '' : classNames.SHOW) + '">' +
+ header +
+ searchbox +
+ actionsbox +
+ '<div class="inner ' + classNames.SHOW + '" role="listbox" id="' + this.selectId + '" tabindex="-1" ' + multiselectable + '>' +
+ '<ul class="' + classNames.MENU + ' inner ' + (version.major === '4' ? classNames.SHOW : '') + '" role="presentation">' +
+ '</ul>' +
+ '</div>' +
+ donebutton +
+ '</div>' +
+ '</div>';
+
+ return $(drop);
+ },
+
+ setPositionData: function () {
+ this.selectpicker.view.canHighlight = [];
+ this.selectpicker.view.size = 0;
+ this.selectpicker.view.firstHighlightIndex = false;
+
+ for (var i = 0; i < this.selectpicker.current.data.length; i++) {
+ var li = this.selectpicker.current.data[i],
+ canHighlight = true;
+
+ if (li.type === 'divider') {
+ canHighlight = false;
+ li.height = this.sizeInfo.dividerHeight;
+ } else if (li.type === 'optgroup-label') {
+ canHighlight = false;
+ li.height = this.sizeInfo.dropdownHeaderHeight;
+ } else {
+ li.height = this.sizeInfo.liHeight;
+ }
+
+ if (li.disabled) canHighlight = false;
+
+ this.selectpicker.view.canHighlight.push(canHighlight);
+
+ if (canHighlight) {
+ this.selectpicker.view.size++;
+ li.posinset = this.selectpicker.view.size;
+ if (this.selectpicker.view.firstHighlightIndex === false) this.selectpicker.view.firstHighlightIndex = i;
+ }
+
+ li.position = (i === 0 ? 0 : this.selectpicker.current.data[i - 1].position) + li.height;
+ }
+ },
+
+ isVirtual: function () {
+ return (this.options.virtualScroll !== false) && (this.selectpicker.main.elements.length >= this.options.virtualScroll) || this.options.virtualScroll === true;
+ },
+
+ createView: function (isSearching, setSize, refresh) {
+ var that = this,
+ scrollTop = 0,
+ active = [],
+ selected,
+ prevActive;
+
+ this.selectpicker.isSearching = isSearching;
+ this.selectpicker.current = isSearching ? this.selectpicker.search : this.selectpicker.main;
+
+ this.setPositionData();
+
+ if (setSize) {
+ if (refresh) {
+ scrollTop = this.$menuInner[0].scrollTop;
+ } else if (!that.multiple) {
+ var element = that.$element[0],
+ selectedIndex = (element.options[element.selectedIndex] || {}).liIndex;
+
+ if (typeof selectedIndex === 'number' && that.options.size !== false) {
+ var selectedData = that.selectpicker.main.data[selectedIndex],
+ position = selectedData && selectedData.position;
+
+ if (position) {
+ scrollTop = position - ((that.sizeInfo.menuInnerHeight + that.sizeInfo.liHeight) / 2);
+ }
+ }
+ }
+ }
+
+ scroll(scrollTop, true);
+
+ this.$menuInner.off('scroll.createView').on('scroll.createView', function (e, updateValue) {
+ if (!that.noScroll) scroll(this.scrollTop, updateValue);
+ that.noScroll = false;
+ });
+
+ function scroll (scrollTop, init) {
+ var size = that.selectpicker.current.elements.length,
+ chunks = [],
+ chunkSize,
+ chunkCount,
+ firstChunk,
+ lastChunk,
+ currentChunk,
+ prevPositions,
+ positionIsDifferent,
+ previousElements,
+ menuIsDifferent = true,
+ isVirtual = that.isVirtual();
+
+ that.selectpicker.view.scrollTop = scrollTop;
+
+ chunkSize = Math.ceil(that.sizeInfo.menuInnerHeight / that.sizeInfo.liHeight * 1.5); // number of options in a chunk
+ chunkCount = Math.round(size / chunkSize) || 1; // number of chunks
+
+ for (var i = 0; i < chunkCount; i++) {
+ var endOfChunk = (i + 1) * chunkSize;
+
+ if (i === chunkCount - 1) {
+ endOfChunk = size;
+ }
+
+ chunks[i] = [
+ (i) * chunkSize + (!i ? 0 : 1),
+ endOfChunk
+ ];
+
+ if (!size) break;
+
+ if (currentChunk === undefined && scrollTop - 1 <= that.selectpicker.current.data[endOfChunk - 1].position - that.sizeInfo.menuInnerHeight) {
+ currentChunk = i;
+ }
+ }
+
+ if (currentChunk === undefined) currentChunk = 0;
+
+ prevPositions = [that.selectpicker.view.position0, that.selectpicker.view.position1];
+
+ // always display previous, current, and next chunks
+ firstChunk = Math.max(0, currentChunk - 1);
+ lastChunk = Math.min(chunkCount - 1, currentChunk + 1);
+
+ that.selectpicker.view.position0 = isVirtual === false ? 0 : (Math.max(0, chunks[firstChunk][0]) || 0);
+ that.selectpicker.view.position1 = isVirtual === false ? size : (Math.min(size, chunks[lastChunk][1]) || 0);
+
+ positionIsDifferent = prevPositions[0] !== that.selectpicker.view.position0 || prevPositions[1] !== that.selectpicker.view.position1;
+
+ if (that.activeIndex !== undefined) {
+ prevActive = that.selectpicker.main.elements[that.prevActiveIndex];
+ active = that.selectpicker.main.elements[that.activeIndex];
+ selected = that.selectpicker.main.elements[that.selectedIndex];
+
+ if (init) {
+ if (that.activeIndex !== that.selectedIndex) {
+ that.defocusItem(active);
+ }
+ that.activeIndex = undefined;
+ }
+
+ if (that.activeIndex && that.activeIndex !== that.selectedIndex) {
+ that.defocusItem(selected);
+ }
+ }
+
+ if (that.prevActiveIndex !== undefined && that.prevActiveIndex !== that.activeIndex && that.prevActiveIndex !== that.selectedIndex) {
+ that.defocusItem(prevActive);
+ }
+
+ if (init || positionIsDifferent) {
+ previousElements = that.selectpicker.view.visibleElements ? that.selectpicker.view.visibleElements.slice() : [];
+
+ if (isVirtual === false) {
+ that.selectpicker.view.visibleElements = that.selectpicker.current.elements;
+ } else {
+ that.selectpicker.view.visibleElements = that.selectpicker.current.elements.slice(that.selectpicker.view.position0, that.selectpicker.view.position1);
+ }
+
+ that.setOptionStatus();
+
+ // if searching, check to make sure the list has actually been updated before updating DOM
+ // this prevents unnecessary repaints
+ if (isSearching || (isVirtual === false && init)) menuIsDifferent = !isEqual(previousElements, that.selectpicker.view.visibleElements);
+
+ // if virtual scroll is disabled and not searching,
+ // menu should never need to be updated more than once
+ if ((init || isVirtual === true) && menuIsDifferent) {
+ var menuInner = that.$menuInner[0],
+ menuFragment = document.createDocumentFragment(),
+ emptyMenu = menuInner.firstChild.cloneNode(false),
+ marginTop,
+ marginBottom,
+ elements = that.selectpicker.view.visibleElements,
+ toSanitize = [];
+
+ // replace the existing UL with an empty one - this is faster than $.empty()
+ menuInner.replaceChild(emptyMenu, menuInner.firstChild);
+
+ for (var i = 0, visibleElementsLen = elements.length; i < visibleElementsLen; i++) {
+ var element = elements[i],
+ elText,
+ elementData;
+
+ if (that.options.sanitize) {
+ elText = element.lastChild;
+
+ if (elText) {
+ elementData = that.selectpicker.current.data[i + that.selectpicker.view.position0];
+
+ if (elementData && elementData.content && !elementData.sanitized) {
+ toSanitize.push(elText);
+ elementData.sanitized = true;
+ }
+ }
+ }
+
+ menuFragment.appendChild(element);
+ }
+
+ if (that.options.sanitize && toSanitize.length) {
+ sanitizeHtml(toSanitize, that.options.whiteList, that.options.sanitizeFn);
+ }
+
+ if (isVirtual === true) {
+ marginTop = (that.selectpicker.view.position0 === 0 ? 0 : that.selectpicker.current.data[that.selectpicker.view.position0 - 1].position);
+ marginBottom = (that.selectpicker.view.position1 > size - 1 ? 0 : that.selectpicker.current.data[size - 1].position - that.selectpicker.current.data[that.selectpicker.view.position1 - 1].position);
+
+ menuInner.firstChild.style.marginTop = marginTop + 'px';
+ menuInner.firstChild.style.marginBottom = marginBottom + 'px';
+ } else {
+ menuInner.firstChild.style.marginTop = 0;
+ menuInner.firstChild.style.marginBottom = 0;
+ }
+
+ menuInner.firstChild.appendChild(menuFragment);
+
+ // if an option is encountered that is wider than the current menu width, update the menu width accordingly
+ // switch to ResizeObserver with increased browser support
+ if (isVirtual === true && that.sizeInfo.hasScrollBar) {
+ var menuInnerInnerWidth = menuInner.firstChild.offsetWidth;
+
+ if (init && menuInnerInnerWidth < that.sizeInfo.menuInnerInnerWidth && that.sizeInfo.totalMenuWidth > that.sizeInfo.selectWidth) {
+ menuInner.firstChild.style.minWidth = that.sizeInfo.menuInnerInnerWidth + 'px';
+ } else if (menuInnerInnerWidth > that.sizeInfo.menuInnerInnerWidth) {
+ // set to 0 to get actual width of menu
+ that.$menu[0].style.minWidth = 0;
+
+ var actualMenuWidth = menuInner.firstChild.offsetWidth;
+
+ if (actualMenuWidth > that.sizeInfo.menuInnerInnerWidth) {
+ that.sizeInfo.menuInnerInnerWidth = actualMenuWidth;
+ menuInner.firstChild.style.minWidth = that.sizeInfo.menuInnerInnerWidth + 'px';
+ }
+
+ // reset to default CSS styling
+ that.$menu[0].style.minWidth = '';
+ }
+ }
+ }
+ }
+
+ that.prevActiveIndex = that.activeIndex;
+
+ if (!that.options.liveSearch) {
+ that.$menuInner.trigger('focus');
+ } else if (isSearching && init) {
+ var index = 0,
+ newActive;
+
+ if (!that.selectpicker.view.canHighlight[index]) {
+ index = 1 + that.selectpicker.view.canHighlight.slice(1).indexOf(true);
+ }
+
+ newActive = that.selectpicker.view.visibleElements[index];
+
+ that.defocusItem(that.selectpicker.view.currentActive);
+
+ that.activeIndex = (that.selectpicker.current.data[index] || {}).index;
+
+ that.focusItem(newActive);
+ }
+ }
+
+ $(window)
+ .off('resize' + EVENT_KEY + '.' + this.selectId + '.createView')
+ .on('resize' + EVENT_KEY + '.' + this.selectId + '.createView', function () {
+ var isActive = that.$newElement.hasClass(classNames.SHOW);
+
+ if (isActive) scroll(that.$menuInner[0].scrollTop);
+ });
+ },
+
+ focusItem: function (li, liData, noStyle) {
+ if (li) {
+ liData = liData || this.selectpicker.main.data[this.activeIndex];
+ var a = li.firstChild;
+
+ if (a) {
+ a.setAttribute('aria-setsize', this.selectpicker.view.size);
+ a.setAttribute('aria-posinset', liData.posinset);
+
+ if (noStyle !== true) {
+ this.focusedParent.setAttribute('aria-activedescendant', a.id);
+ li.classList.add('active');
+ a.classList.add('active');
+ }
+ }
+ }
+ },
+
+ defocusItem: function (li) {
+ if (li) {
+ li.classList.remove('active');
+ if (li.firstChild) li.firstChild.classList.remove('active');
+ }
+ },
+
+ setPlaceholder: function () {
+ var that = this,
+ updateIndex = false;
+
+ if (this.options.title && !this.multiple) {
+ if (!this.selectpicker.view.titleOption) this.selectpicker.view.titleOption = document.createElement('option');
+
+ // this option doesn't create a new <li> element, but does add a new option at the start,
+ // so startIndex should increase to prevent having to check every option for the bs-title-option class
+ updateIndex = true;
+
+ var element = this.$element[0],
+ selectTitleOption = false,
+ titleNotAppended = !this.selectpicker.view.titleOption.parentNode,
+ selectedIndex = element.selectedIndex,
+ selectedOption = element.options[selectedIndex],
+ navigation = window.performance && window.performance.getEntriesByType('navigation'),
+ // Safari doesn't support getEntriesByType('navigation') - fall back to performance.navigation
+ isNotBackForward = (navigation && navigation.length) ? navigation[0].type !== 'back_forward' : window.performance.navigation.type !== 2;
+
+ if (titleNotAppended) {
+ // Use native JS to prepend option (faster)
+ this.selectpicker.view.titleOption.className = 'bs-title-option';
+ this.selectpicker.view.titleOption.value = '';
+
+ // Check if selected or data-selected attribute is already set on an option. If not, select the titleOption option.
+ // the selected item may have been changed by user or programmatically before the bootstrap select plugin runs,
+ // if so, the select will have the data-selected attribute
+ selectTitleOption = !selectedOption || (selectedIndex === 0 && selectedOption.defaultSelected === false && this.$element.data('selected') === undefined);
+ }
+
+ if (titleNotAppended || this.selectpicker.view.titleOption.index !== 0) {
+ element.insertBefore(this.selectpicker.view.titleOption, element.firstChild);
+ }
+
+ // Set selected *after* appending to select,
+ // otherwise the option doesn't get selected in IE
+ // set using selectedIndex, as setting the selected attr to true here doesn't work in IE11
+ if (selectTitleOption && isNotBackForward) {
+ element.selectedIndex = 0;
+ } else if (document.readyState !== 'complete') {
+ // if navigation type is back_forward, there's a chance the select will have its value set by BFCache
+ // wait for that value to be set, then run render again
+ window.addEventListener('pageshow', function () {
+ if (that.selectpicker.view.displayedValue !== element.value) that.render();
+ });
+ }
+ }
+
+ return updateIndex;
+ },
+
+ buildData: function () {
+ var optionSelector = ':not([hidden]):not([data-hidden="true"])',
+ mainData = [],
+ optID = 0,
+ startIndex = this.setPlaceholder() ? 1 : 0; // append the titleOption if necessary and skip the first option in the loop
+
+ if (this.options.hideDisabled) optionSelector += ':not(:disabled)';
+
+ var selectOptions = this.$element[0].querySelectorAll('select > *' + optionSelector);
+
+ function addDivider (config) {
+ var previousData = mainData[mainData.length - 1];
+
+ // ensure optgroup doesn't create back-to-back dividers
+ if (
+ previousData &&
+ previousData.type === 'divider' &&
+ (previousData.optID || config.optID)
+ ) {
+ return;
+ }
+
+ config = config || {};
+ config.type = 'divider';
+
+ mainData.push(config);
+ }
+
+ function addOption (option, config) {
+ config = config || {};
+
+ config.divider = option.getAttribute('data-divider') === 'true';
+
+ if (config.divider) {
+ addDivider({
+ optID: config.optID
+ });
+ } else {
+ var liIndex = mainData.length,
+ cssText = option.style.cssText,
+ inlineStyle = cssText ? htmlEscape(cssText) : '',
+ optionClass = (option.className || '') + (config.optgroupClass || '');
+
+ if (config.optID) optionClass = 'opt ' + optionClass;
+
+ config.optionClass = optionClass.trim();
+ config.inlineStyle = inlineStyle;
+ config.text = option.textContent;
+
+ config.content = option.getAttribute('data-content');
+ config.tokens = option.getAttribute('data-tokens');
+ config.subtext = option.getAttribute('data-subtext');
+ config.icon = option.getAttribute('data-icon');
+
+ option.liIndex = liIndex;
+
+ config.display = config.content || config.text;
+ config.type = 'option';
+ config.index = liIndex;
+ config.option = option;
+ config.selected = !!option.selected;
+ config.disabled = config.disabled || !!option.disabled;
+
+ mainData.push(config);
+ }
+ }
+
+ function addOptgroup (index, selectOptions) {
+ var optgroup = selectOptions[index],
+ // skip placeholder option
+ previous = index - 1 < startIndex ? false : selectOptions[index - 1],
+ next = selectOptions[index + 1],
+ options = optgroup.querySelectorAll('option' + optionSelector);
+
+ if (!options.length) return;
+
+ var config = {
+ display: htmlEscape(optgroup.label),
+ subtext: optgroup.getAttribute('data-subtext'),
+ icon: optgroup.getAttribute('data-icon'),
+ type: 'optgroup-label',
+ optgroupClass: ' ' + (optgroup.className || '')
+ },
+ headerIndex,
+ lastIndex;
+
+ optID++;
+
+ if (previous) {
+ addDivider({ optID: optID });
+ }
+
+ config.optID = optID;
+
+ mainData.push(config);
+
+ for (var j = 0, len = options.length; j < len; j++) {
+ var option = options[j];
+
+ if (j === 0) {
+ headerIndex = mainData.length - 1;
+ lastIndex = headerIndex + len;
+ }
+
+ addOption(option, {
+ headerIndex: headerIndex,
+ lastIndex: lastIndex,
+ optID: config.optID,
+ optgroupClass: config.optgroupClass,
+ disabled: optgroup.disabled
+ });
+ }
+
+ if (next) {
+ addDivider({ optID: optID });
+ }
+ }
+
+ for (var len = selectOptions.length, i = startIndex; i < len; i++) {
+ var item = selectOptions[i];
+
+ if (item.tagName !== 'OPTGROUP') {
+ addOption(item, {});
+ } else {
+ addOptgroup(i, selectOptions);
+ }
+ }
+
+ this.selectpicker.main.data = this.selectpicker.current.data = mainData;
+ },
+
+ buildList: function () {
+ var that = this,
+ selectData = this.selectpicker.main.data,
+ mainElements = [],
+ widestOptionLength = 0;
+
+ if ((that.options.showTick || that.multiple) && !elementTemplates.checkMark.parentNode) {
+ elementTemplates.checkMark.className = this.options.iconBase + ' ' + that.options.tickIcon + ' check-mark';
+ elementTemplates.a.appendChild(elementTemplates.checkMark);
+ }
+
+ function buildElement (item) {
+ var liElement,
+ combinedLength = 0;
+
+ switch (item.type) {
+ case 'divider':
+ liElement = generateOption.li(
+ false,
+ classNames.DIVIDER,
+ (item.optID ? item.optID + 'div' : undefined)
+ );
+
+ break;
+
+ case 'option':
+ liElement = generateOption.li(
+ generateOption.a(
+ generateOption.text.call(that, item),
+ item.optionClass,
+ item.inlineStyle
+ ),
+ '',
+ item.optID
+ );
+
+ if (liElement.firstChild) {
+ liElement.firstChild.id = that.selectId + '-' + item.index;
+ }
+
+ break;
+
+ case 'optgroup-label':
+ liElement = generateOption.li(
+ generateOption.label.call(that, item),
+ 'dropdown-header' + item.optgroupClass,
+ item.optID
+ );
+
+ break;
+ }
+
+ item.element = liElement;
+ mainElements.push(liElement);
+
+ // count the number of characters in the option - not perfect, but should work in most cases
+ if (item.display) combinedLength += item.display.length;
+ if (item.subtext) combinedLength += item.subtext.length;
+ // if there is an icon, ensure this option's width is checked
+ if (item.icon) combinedLength += 1;
+
+ if (combinedLength > widestOptionLength) {
+ widestOptionLength = combinedLength;
+
+ // guess which option is the widest
+ // use this when calculating menu width
+ // not perfect, but it's fast, and the width will be updating accordingly when scrolling
+ that.selectpicker.view.widestOption = mainElements[mainElements.length - 1];
+ }
+ }
+
+ for (var len = selectData.length, i = 0; i < len; i++) {
+ var item = selectData[i];
+
+ buildElement(item);
+ }
+
+ this.selectpicker.main.elements = this.selectpicker.current.elements = mainElements;
+ },
+
+ findLis: function () {
+ return this.$menuInner.find('.inner > li');
+ },
+
+ render: function () {
+ var that = this,
+ element = this.$element[0],
+ // ensure titleOption is appended and selected (if necessary) before getting selectedOptions
+ placeholderSelected = this.setPlaceholder() && element.selectedIndex === 0,
+ selectedOptions = getSelectedOptions(element, this.options.hideDisabled),
+ selectedCount = selectedOptions.length,
+ button = this.$button[0],
+ buttonInner = button.querySelector('.filter-option-inner-inner'),
+ multipleSeparator = document.createTextNode(this.options.multipleSeparator),
+ titleFragment = elementTemplates.fragment.cloneNode(false),
+ showCount,
+ countMax,
+ hasContent = false;
+
+ button.classList.toggle('bs-placeholder', that.multiple ? !selectedCount : !getSelectValues(element, selectedOptions));
+
+ if (!that.multiple && selectedOptions.length === 1) {
+ that.selectpicker.view.displayedValue = getSelectValues(element, selectedOptions);
+ }
+
+ if (this.options.selectedTextFormat === 'static') {
+ titleFragment = generateOption.text.call(this, { text: this.options.title }, true);
+ } else {
+ showCount = this.multiple && this.options.selectedTextFormat.indexOf('count') !== -1 && selectedCount > 1;
+
+ // determine if the number of selected options will be shown (showCount === true)
+ if (showCount) {
+ countMax = this.options.selectedTextFormat.split('>');
+ showCount = (countMax.length > 1 && selectedCount > countMax[1]) || (countMax.length === 1 && selectedCount >= 2);
+ }
+
+ // only loop through all selected options if the count won't be shown
+ if (showCount === false) {
+ if (!placeholderSelected) {
+ for (var selectedIndex = 0; selectedIndex < selectedCount; selectedIndex++) {
+ if (selectedIndex < 50) {
+ var option = selectedOptions[selectedIndex],
+ thisData = this.selectpicker.main.data[option.liIndex],
+ titleOptions = {};
+
+ if (this.multiple && selectedIndex > 0) {
+ titleFragment.appendChild(multipleSeparator.cloneNode(false));
+ }
+
+ if (option.title) {
+ titleOptions.text = option.title;
+ } else if (thisData) {
+ if (thisData.content && that.options.showContent) {
+ titleOptions.content = thisData.content.toString();
+ hasContent = true;
+ } else {
+ if (that.options.showIcon) {
+ titleOptions.icon = thisData.icon;
+ }
+ if (that.options.showSubtext && !that.multiple && thisData.subtext) titleOptions.subtext = ' ' + thisData.subtext;
+ titleOptions.text = option.textContent.trim();
+ }
+ }
+
+ titleFragment.appendChild(generateOption.text.call(this, titleOptions, true));
+ } else {
+ break;
+ }
+ }
+
+ // add ellipsis
+ if (selectedCount > 49) {
+ titleFragment.appendChild(document.createTextNode('...'));
+ }
+ }
+ } else {
+ var optionSelector = ':not([hidden]):not([data-hidden="true"]):not([data-divider="true"])';
+ if (this.options.hideDisabled) optionSelector += ':not(:disabled)';
+
+ // If this is a multiselect, and selectedTextFormat is count, then show 1 of 2 selected, etc.
+ var totalCount = this.$element[0].querySelectorAll('select > option' + optionSelector + ', optgroup' + optionSelector + ' option' + optionSelector).length,
+ tr8nText = (typeof this.options.countSelectedText === 'function') ? this.options.countSelectedText(selectedCount, totalCount) : this.options.countSelectedText;
+
+ titleFragment = generateOption.text.call(this, {
+ text: tr8nText.replace('{0}', selectedCount.toString()).replace('{1}', totalCount.toString())
+ }, true);
+ }
+ }
+
+ if (this.options.title == undefined) {
+ // use .attr to ensure undefined is returned if title attribute is not set
+ this.options.title = this.$element.attr('title');
+ }
+
+ // If the select doesn't have a title, then use the default, or if nothing is set at all, use noneSelectedText
+ if (!titleFragment.childNodes.length) {
+ titleFragment = generateOption.text.call(this, {
+ text: typeof this.options.title !== 'undefined' ? this.options.title : this.options.noneSelectedText
+ }, true);
+ }
+
+ // strip all HTML tags and trim the result, then unescape any escaped tags
+ button.title = titleFragment.textContent.replace(/<[^>]*>?/g, '').trim();
+
+ if (this.options.sanitize && hasContent) {
+ sanitizeHtml([titleFragment], that.options.whiteList, that.options.sanitizeFn);
+ }
+
+ buttonInner.innerHTML = '';
+ buttonInner.appendChild(titleFragment);
+
+ if (version.major < 4 && this.$newElement[0].classList.contains('bs3-has-addon')) {
+ var filterExpand = button.querySelector('.filter-expand'),
+ clone = buttonInner.cloneNode(true);
+
+ clone.className = 'filter-expand';
+
+ if (filterExpand) {
+ button.replaceChild(clone, filterExpand);
+ } else {
+ button.appendChild(clone);
+ }
+ }
+
+ this.$element.trigger('rendered' + EVENT_KEY);
+ },
+
+ /**
+ * @param [style]
+ * @param [status]
+ */
+ setStyle: function (newStyle, status) {
+ var button = this.$button[0],
+ newElement = this.$newElement[0],
+ style = this.options.style.trim(),
+ buttonClass;
+
+ if (this.$element.attr('class')) {
+ this.$newElement.addClass(this.$element.attr('class').replace(/selectpicker|mobile-device|bs-select-hidden|validate\[.*\]/gi, ''));
+ }
+
+ if (version.major < 4) {
+ newElement.classList.add('bs3');
+
+ if (newElement.parentNode.classList && newElement.parentNode.classList.contains('input-group') &&
+ (newElement.previousElementSibling || newElement.nextElementSibling) &&
+ (newElement.previousElementSibling || newElement.nextElementSibling).classList.contains('input-group-addon')
+ ) {
+ newElement.classList.add('bs3-has-addon');
+ }
+ }
+
+ if (newStyle) {
+ buttonClass = newStyle.trim();
+ } else {
+ buttonClass = style;
+ }
+
+ if (status == 'add') {
+ if (buttonClass) button.classList.add.apply(button.classList, buttonClass.split(' '));
+ } else if (status == 'remove') {
+ if (buttonClass) button.classList.remove.apply(button.classList, buttonClass.split(' '));
+ } else {
+ if (style) button.classList.remove.apply(button.classList, style.split(' '));
+ if (buttonClass) button.classList.add.apply(button.classList, buttonClass.split(' '));
+ }
+ },
+
+ liHeight: function (refresh) {
+ if (!refresh && (this.options.size === false || Object.keys(this.sizeInfo).length)) return;
+
+ var newElement = elementTemplates.div.cloneNode(false),
+ menu = elementTemplates.div.cloneNode(false),
+ menuInner = elementTemplates.div.cloneNode(false),
+ menuInnerInner = document.createElement('ul'),
+ divider = elementTemplates.li.cloneNode(false),
+ dropdownHeader = elementTemplates.li.cloneNode(false),
+ li,
+ a = elementTemplates.a.cloneNode(false),
+ text = elementTemplates.span.cloneNode(false),
+ header = this.options.header && this.$menu.find('.' + classNames.POPOVERHEADER).length > 0 ? this.$menu.find('.' + classNames.POPOVERHEADER)[0].cloneNode(true) : null,
+ search = this.options.liveSearch ? elementTemplates.div.cloneNode(false) : null,
+ actions = this.options.actionsBox && this.multiple && this.$menu.find('.bs-actionsbox').length > 0 ? this.$menu.find('.bs-actionsbox')[0].cloneNode(true) : null,
+ doneButton = this.options.doneButton && this.multiple && this.$menu.find('.bs-donebutton').length > 0 ? this.$menu.find('.bs-donebutton')[0].cloneNode(true) : null,
+ firstOption = this.$element.find('option')[0];
+
+ this.sizeInfo.selectWidth = this.$newElement[0].offsetWidth;
+
+ text.className = 'text';
+ a.className = 'dropdown-item ' + (firstOption ? firstOption.className : '');
+ newElement.className = this.$menu[0].parentNode.className + ' ' + classNames.SHOW;
+ newElement.style.width = 0; // ensure button width doesn't affect natural width of menu when calculating
+ if (this.options.width === 'auto') menu.style.minWidth = 0;
+ menu.className = classNames.MENU + ' ' + classNames.SHOW;
+ menuInner.className = 'inner ' + classNames.SHOW;
+ menuInnerInner.className = classNames.MENU + ' inner ' + (version.major === '4' ? classNames.SHOW : '');
+ divider.className = classNames.DIVIDER;
+ dropdownHeader.className = 'dropdown-header';
+
+ text.appendChild(document.createTextNode('\u200b'));
+
+ if (this.selectpicker.current.data.length) {
+ for (var i = 0; i < this.selectpicker.current.data.length; i++) {
+ var data = this.selectpicker.current.data[i];
+ if (data.type === 'option') {
+ li = data.element;
+ break;
+ }
+ }
+ } else {
+ li = elementTemplates.li.cloneNode(false);
+ a.appendChild(text);
+ li.appendChild(a);
+ }
+
+ dropdownHeader.appendChild(text.cloneNode(true));
+
+ if (this.selectpicker.view.widestOption) {
+ menuInnerInner.appendChild(this.selectpicker.view.widestOption.cloneNode(true));
+ }
+
+ menuInnerInner.appendChild(li);
+ menuInnerInner.appendChild(divider);
+ menuInnerInner.appendChild(dropdownHeader);
+ if (header) menu.appendChild(header);
+ if (search) {
+ var input = document.createElement('input');
+ search.className = 'bs-searchbox';
+ input.className = 'form-control';
+ search.appendChild(input);
+ menu.appendChild(search);
+ }
+ if (actions) menu.appendChild(actions);
+ menuInner.appendChild(menuInnerInner);
+ menu.appendChild(menuInner);
+ if (doneButton) menu.appendChild(doneButton);
+ newElement.appendChild(menu);
+
+ document.body.appendChild(newElement);
+
+ var liHeight = li.offsetHeight,
+ dropdownHeaderHeight = dropdownHeader ? dropdownHeader.offsetHeight : 0,
+ headerHeight = header ? header.offsetHeight : 0,
+ searchHeight = search ? search.offsetHeight : 0,
+ actionsHeight = actions ? actions.offsetHeight : 0,
+ doneButtonHeight = doneButton ? doneButton.offsetHeight : 0,
+ dividerHeight = $(divider).outerHeight(true),
+ // fall back to jQuery if getComputedStyle is not supported
+ menuStyle = window.getComputedStyle ? window.getComputedStyle(menu) : false,
+ menuWidth = menu.offsetWidth,
+ $menu = menuStyle ? null : $(menu),
+ menuPadding = {
+ vert: toInteger(menuStyle ? menuStyle.paddingTop : $menu.css('paddingTop')) +
+ toInteger(menuStyle ? menuStyle.paddingBottom : $menu.css('paddingBottom')) +
+ toInteger(menuStyle ? menuStyle.borderTopWidth : $menu.css('borderTopWidth')) +
+ toInteger(menuStyle ? menuStyle.borderBottomWidth : $menu.css('borderBottomWidth')),
+ horiz: toInteger(menuStyle ? menuStyle.paddingLeft : $menu.css('paddingLeft')) +
+ toInteger(menuStyle ? menuStyle.paddingRight : $menu.css('paddingRight')) +
+ toInteger(menuStyle ? menuStyle.borderLeftWidth : $menu.css('borderLeftWidth')) +
+ toInteger(menuStyle ? menuStyle.borderRightWidth : $menu.css('borderRightWidth'))
+ },
+ menuExtras = {
+ vert: menuPadding.vert +
+ toInteger(menuStyle ? menuStyle.marginTop : $menu.css('marginTop')) +
+ toInteger(menuStyle ? menuStyle.marginBottom : $menu.css('marginBottom')) + 2,
+ horiz: menuPadding.horiz +
+ toInteger(menuStyle ? menuStyle.marginLeft : $menu.css('marginLeft')) +
+ toInteger(menuStyle ? menuStyle.marginRight : $menu.css('marginRight')) + 2
+ },
+ scrollBarWidth;
+
+ menuInner.style.overflowY = 'scroll';
+
+ scrollBarWidth = menu.offsetWidth - menuWidth;
+
+ document.body.removeChild(newElement);
+
+ this.sizeInfo.liHeight = liHeight;
+ this.sizeInfo.dropdownHeaderHeight = dropdownHeaderHeight;
+ this.sizeInfo.headerHeight = headerHeight;
+ this.sizeInfo.searchHeight = searchHeight;
+ this.sizeInfo.actionsHeight = actionsHeight;
+ this.sizeInfo.doneButtonHeight = doneButtonHeight;
+ this.sizeInfo.dividerHeight = dividerHeight;
+ this.sizeInfo.menuPadding = menuPadding;
+ this.sizeInfo.menuExtras = menuExtras;
+ this.sizeInfo.menuWidth = menuWidth;
+ this.sizeInfo.menuInnerInnerWidth = menuWidth - menuPadding.horiz;
+ this.sizeInfo.totalMenuWidth = this.sizeInfo.menuWidth;
+ this.sizeInfo.scrollBarWidth = scrollBarWidth;
+ this.sizeInfo.selectHeight = this.$newElement[0].offsetHeight;
+
+ this.setPositionData();
+ },
+
+ getSelectPosition: function () {
+ var that = this,
+ $window = $(window),
+ pos = that.$newElement.offset(),
+ $container = $(that.options.container),
+ containerPos;
+
+ if (that.options.container && $container.length && !$container.is('body')) {
+ containerPos = $container.offset();
+ containerPos.top += parseInt($container.css('borderTopWidth'));
+ containerPos.left += parseInt($container.css('borderLeftWidth'));
+ } else {
+ containerPos = { top: 0, left: 0 };
+ }
+
+ var winPad = that.options.windowPadding;
+
+ this.sizeInfo.selectOffsetTop = pos.top - containerPos.top - $window.scrollTop();
+ this.sizeInfo.selectOffsetBot = $window.height() - this.sizeInfo.selectOffsetTop - this.sizeInfo.selectHeight - containerPos.top - winPad[2];
+ this.sizeInfo.selectOffsetLeft = pos.left - containerPos.left - $window.scrollLeft();
+ this.sizeInfo.selectOffsetRight = $window.width() - this.sizeInfo.selectOffsetLeft - this.sizeInfo.selectWidth - containerPos.left - winPad[1];
+ this.sizeInfo.selectOffsetTop -= winPad[0];
+ this.sizeInfo.selectOffsetLeft -= winPad[3];
+ },
+
+ setMenuSize: function (isAuto) {
+ this.getSelectPosition();
+
+ var selectWidth = this.sizeInfo.selectWidth,
+ liHeight = this.sizeInfo.liHeight,
+ headerHeight = this.sizeInfo.headerHeight,
+ searchHeight = this.sizeInfo.searchHeight,
+ actionsHeight = this.sizeInfo.actionsHeight,
+ doneButtonHeight = this.sizeInfo.doneButtonHeight,
+ divHeight = this.sizeInfo.dividerHeight,
+ menuPadding = this.sizeInfo.menuPadding,
+ menuInnerHeight,
+ menuHeight,
+ divLength = 0,
+ minHeight,
+ _minHeight,
+ maxHeight,
+ menuInnerMinHeight,
+ estimate,
+ isDropup;
+
+ if (this.options.dropupAuto) {
+ // Get the estimated height of the menu without scrollbars.
+ // This is useful for smaller menus, where there might be plenty of room
+ // below the button without setting dropup, but we can't know
+ // the exact height of the menu until createView is called later
+ estimate = liHeight * this.selectpicker.current.elements.length + menuPadding.vert;
+
+ isDropup = this.sizeInfo.selectOffsetTop - this.sizeInfo.selectOffsetBot > this.sizeInfo.menuExtras.vert && estimate + this.sizeInfo.menuExtras.vert + 50 > this.sizeInfo.selectOffsetBot;
+
+ // ensure dropup doesn't change while searching (so menu doesn't bounce back and forth)
+ if (this.selectpicker.isSearching === true) {
+ isDropup = this.selectpicker.dropup;
+ }
+
+ this.$newElement.toggleClass(classNames.DROPUP, isDropup);
+ this.selectpicker.dropup = isDropup;
+ }
+
+ if (this.options.size === 'auto') {
+ _minHeight = this.selectpicker.current.elements.length > 3 ? this.sizeInfo.liHeight * 3 + this.sizeInfo.menuExtras.vert - 2 : 0;
+ menuHeight = this.sizeInfo.selectOffsetBot - this.sizeInfo.menuExtras.vert;
+ minHeight = _minHeight + headerHeight + searchHeight + actionsHeight + doneButtonHeight;
+ menuInnerMinHeight = Math.max(_minHeight - menuPadding.vert, 0);
+
+ if (this.$newElement.hasClass(classNames.DROPUP)) {
+ menuHeight = this.sizeInfo.selectOffsetTop - this.sizeInfo.menuExtras.vert;
+ }
+
+ maxHeight = menuHeight;
+ menuInnerHeight = menuHeight - headerHeight - searchHeight - actionsHeight - doneButtonHeight - menuPadding.vert;
+ } else if (this.options.size && this.options.size != 'auto' && this.selectpicker.current.elements.length > this.options.size) {
+ for (var i = 0; i < this.options.size; i++) {
+ if (this.selectpicker.current.data[i].type === 'divider') divLength++;
+ }
+
+ menuHeight = liHeight * this.options.size + divLength * divHeight + menuPadding.vert;
+ menuInnerHeight = menuHeight - menuPadding.vert;
+ maxHeight = menuHeight + headerHeight + searchHeight + actionsHeight + doneButtonHeight;
+ minHeight = menuInnerMinHeight = '';
+ }
+
+ this.$menu.css({
+ 'max-height': maxHeight + 'px',
+ 'overflow': 'hidden',
+ 'min-height': minHeight + 'px'
+ });
+
+ this.$menuInner.css({
+ 'max-height': menuInnerHeight + 'px',
+ 'overflow-y': 'auto',
+ 'min-height': menuInnerMinHeight + 'px'
+ });
+
+ // ensure menuInnerHeight is always a positive number to prevent issues calculating chunkSize in createView
+ this.sizeInfo.menuInnerHeight = Math.max(menuInnerHeight, 1);
+
+ if (this.selectpicker.current.data.length && this.selectpicker.current.data[this.selectpicker.current.data.length - 1].position > this.sizeInfo.menuInnerHeight) {
+ this.sizeInfo.hasScrollBar = true;
+ this.sizeInfo.totalMenuWidth = this.sizeInfo.menuWidth + this.sizeInfo.scrollBarWidth;
+ }
+
+ if (this.options.dropdownAlignRight === 'auto') {
+ this.$menu.toggleClass(classNames.MENURIGHT, this.sizeInfo.selectOffsetLeft > this.sizeInfo.selectOffsetRight && this.sizeInfo.selectOffsetRight < (this.sizeInfo.totalMenuWidth - selectWidth));
+ }
+
+ if (this.dropdown && this.dropdown._popper) this.dropdown._popper.update();
+ },
+
+ setSize: function (refresh) {
+ this.liHeight(refresh);
+
+ if (this.options.header) this.$menu.css('padding-top', 0);
+
+ if (this.options.size !== false) {
+ var that = this,
+ $window = $(window);
+
+ this.setMenuSize();
+
+ if (this.options.liveSearch) {
+ this.$searchbox
+ .off('input.setMenuSize propertychange.setMenuSize')
+ .on('input.setMenuSize propertychange.setMenuSize', function () {
+ return that.setMenuSize();
+ });
+ }
+
+ if (this.options.size === 'auto') {
+ $window
+ .off('resize' + EVENT_KEY + '.' + this.selectId + '.setMenuSize' + ' scroll' + EVENT_KEY + '.' + this.selectId + '.setMenuSize')
+ .on('resize' + EVENT_KEY + '.' + this.selectId + '.setMenuSize' + ' scroll' + EVENT_KEY + '.' + this.selectId + '.setMenuSize', function () {
+ return that.setMenuSize();
+ });
+ } else if (this.options.size && this.options.size != 'auto' && this.selectpicker.current.elements.length > this.options.size) {
+ $window.off('resize' + EVENT_KEY + '.' + this.selectId + '.setMenuSize' + ' scroll' + EVENT_KEY + '.' + this.selectId + '.setMenuSize');
+ }
+ }
+
+ this.createView(false, true, refresh);
+ },
+
+ setWidth: function () {
+ var that = this;
+
+ if (this.options.width === 'auto') {
+ requestAnimationFrame(function () {
+ that.$menu.css('min-width', '0');
+
+ that.$element.on('loaded' + EVENT_KEY, function () {
+ that.liHeight();
+ that.setMenuSize();
+
+ // Get correct width if element is hidden
+ var $selectClone = that.$newElement.clone().appendTo('body'),
+ btnWidth = $selectClone.css('width', 'auto').children('button').outerWidth();
+
+ $selectClone.remove();
+
+ // Set width to whatever's larger, button title or longest option
+ that.sizeInfo.selectWidth = Math.max(that.sizeInfo.totalMenuWidth, btnWidth);
+ that.$newElement.css('width', that.sizeInfo.selectWidth + 'px');
+ });
+ });
+ } else if (this.options.width === 'fit') {
+ // Remove inline min-width so width can be changed from 'auto'
+ this.$menu.css('min-width', '');
+ this.$newElement.css('width', '').addClass('fit-width');
+ } else if (this.options.width) {
+ // Remove inline min-width so width can be changed from 'auto'
+ this.$menu.css('min-width', '');
+ this.$newElement.css('width', this.options.width);
+ } else {
+ // Remove inline min-width/width so width can be changed
+ this.$menu.css('min-width', '');
+ this.$newElement.css('width', '');
+ }
+ // Remove fit-width class if width is changed programmatically
+ if (this.$newElement.hasClass('fit-width') && this.options.width !== 'fit') {
+ this.$newElement[0].classList.remove('fit-width');
+ }
+ },
+
+ selectPosition: function () {
+ this.$bsContainer = $('<div class="bs-container" />');
+
+ var that = this,
+ $container = $(this.options.container),
+ pos,
+ containerPos,
+ actualHeight,
+ getPlacement = function ($element) {
+ var containerPosition = {},
+ // fall back to dropdown's default display setting if display is not manually set
+ display = that.options.display || (
+ // Bootstrap 3 doesn't have $.fn.dropdown.Constructor.Default
+ $.fn.dropdown.Constructor.Default ? $.fn.dropdown.Constructor.Default.display
+ : false
+ );
+
+ that.$bsContainer.addClass($element.attr('class').replace(/form-control|fit-width/gi, '')).toggleClass(classNames.DROPUP, $element.hasClass(classNames.DROPUP));
+ pos = $element.offset();
+
+ if (!$container.is('body')) {
+ containerPos = $container.offset();
+ containerPos.top += parseInt($container.css('borderTopWidth')) - $container.scrollTop();
+ containerPos.left += parseInt($container.css('borderLeftWidth')) - $container.scrollLeft();
+ } else {
+ containerPos = { top: 0, left: 0 };
+ }
+
+ actualHeight = $element.hasClass(classNames.DROPUP) ? 0 : $element[0].offsetHeight;
+
+ // Bootstrap 4+ uses Popper for menu positioning
+ if (version.major < 4 || display === 'static') {
+ containerPosition.top = pos.top - containerPos.top + actualHeight;
+ containerPosition.left = pos.left - containerPos.left;
+ }
+
+ containerPosition.width = $element[0].offsetWidth;
+
+ that.$bsContainer.css(containerPosition);
+ };
+
+ this.$button.on('click.bs.dropdown.data-api', function () {
+ if (that.isDisabled()) {
+ return;
+ }
+
+ getPlacement(that.$newElement);
+
+ that.$bsContainer
+ .appendTo(that.options.container)
+ .toggleClass(classNames.SHOW, !that.$button.hasClass(classNames.SHOW))
+ .append(that.$menu);
+ });
+
+ $(window)
+ .off('resize' + EVENT_KEY + '.' + this.selectId + ' scroll' + EVENT_KEY + '.' + this.selectId)
+ .on('resize' + EVENT_KEY + '.' + this.selectId + ' scroll' + EVENT_KEY + '.' + this.selectId, function () {
+ var isActive = that.$newElement.hasClass(classNames.SHOW);
+
+ if (isActive) getPlacement(that.$newElement);
+ });
+
+ this.$element.on('hide' + EVENT_KEY, function () {
+ that.$menu.data('height', that.$menu.height());
+ that.$bsContainer.detach();
+ });
+ },
+
+ setOptionStatus: function (selectedOnly) {
+ var that = this;
+
+ that.noScroll = false;
+
+ if (that.selectpicker.view.visibleElements && that.selectpicker.view.visibleElements.length) {
+ for (var i = 0; i < that.selectpicker.view.visibleElements.length; i++) {
+ var liData = that.selectpicker.current.data[i + that.selectpicker.view.position0],
+ option = liData.option;
+
+ if (option) {
+ if (selectedOnly !== true) {
+ that.setDisabled(
+ liData.index,
+ liData.disabled
+ );
+ }
+
+ that.setSelected(
+ liData.index,
+ option.selected
+ );
+ }
+ }
+ }
+ },
+
+ /**
+ * @param {number} index - the index of the option that is being changed
+ * @param {boolean} selected - true if the option is being selected, false if being deselected
+ */
+ setSelected: function (index, selected) {
+ var li = this.selectpicker.main.elements[index],
+ liData = this.selectpicker.main.data[index],
+ activeIndexIsSet = this.activeIndex !== undefined,
+ thisIsActive = this.activeIndex === index,
+ prevActive,
+ a,
+ // if current option is already active
+ // OR
+ // if the current option is being selected, it's NOT multiple, and
+ // activeIndex is undefined:
+ // - when the menu is first being opened, OR
+ // - after a search has been performed, OR
+ // - when retainActive is false when selecting a new option (i.e. index of the newly selected option is not the same as the current activeIndex)
+ keepActive = thisIsActive || (selected && !this.multiple && !activeIndexIsSet);
+
+ liData.selected = selected;
+
+ a = li.firstChild;
+
+ if (selected) {
+ this.selectedIndex = index;
+ }
+
+ li.classList.toggle('selected', selected);
+
+ if (keepActive) {
+ this.focusItem(li, liData);
+ this.selectpicker.view.currentActive = li;
+ this.activeIndex = index;
+ } else {
+ this.defocusItem(li);
+ }
+
+ if (a) {
+ a.classList.toggle('selected', selected);
+
+ if (selected) {
+ a.setAttribute('aria-selected', true);
+ } else {
+ if (this.multiple) {
+ a.setAttribute('aria-selected', false);
+ } else {
+ a.removeAttribute('aria-selected');
+ }
+ }
+ }
+
+ if (!keepActive && !activeIndexIsSet && selected && this.prevActiveIndex !== undefined) {
+ prevActive = this.selectpicker.main.elements[this.prevActiveIndex];
+
+ this.defocusItem(prevActive);
+ }
+ },
+
+ /**
+ * @param {number} index - the index of the option that is being disabled
+ * @param {boolean} disabled - true if the option is being disabled, false if being enabled
+ */
+ setDisabled: function (index, disabled) {
+ var li = this.selectpicker.main.elements[index],
+ a;
+
+ this.selectpicker.main.data[index].disabled = disabled;
+
+ a = li.firstChild;
+
+ li.classList.toggle(classNames.DISABLED, disabled);
+
+ if (a) {
+ if (version.major === '4') a.classList.toggle(classNames.DISABLED, disabled);
+
+ if (disabled) {
+ a.setAttribute('aria-disabled', disabled);
+ a.setAttribute('tabindex', -1);
+ } else {
+ a.removeAttribute('aria-disabled');
+ a.setAttribute('tabindex', 0);
+ }
+ }
+ },
+
+ isDisabled: function () {
+ return this.$element[0].disabled;
+ },
+
+ checkDisabled: function () {
+ if (this.isDisabled()) {
+ this.$newElement[0].classList.add(classNames.DISABLED);
+ this.$button.addClass(classNames.DISABLED).attr('aria-disabled', true);
+ } else {
+ if (this.$button[0].classList.contains(classNames.DISABLED)) {
+ this.$newElement[0].classList.remove(classNames.DISABLED);
+ this.$button.removeClass(classNames.DISABLED).attr('aria-disabled', false);
+ }
+ }
+ },
+
+ clickListener: function () {
+ var that = this,
+ $document = $(document);
+
+ $document.data('spaceSelect', false);
+
+ this.$button.on('keyup', function (e) {
+ if (/(32)/.test(e.keyCode.toString(10)) && $document.data('spaceSelect')) {
+ e.preventDefault();
+ $document.data('spaceSelect', false);
+ }
+ });
+
+ this.$newElement.on('show.bs.dropdown', function () {
+ if (version.major > 3 && !that.dropdown) {
+ that.dropdown = that.$button.data('bs.dropdown');
+ that.dropdown._menu = that.$menu[0];
+ }
+ });
+
+ this.$button.on('click.bs.dropdown.data-api', function () {
+ if (!that.$newElement.hasClass(classNames.SHOW)) {
+ that.setSize();
+ }
+ });
+
+ function setFocus () {
+ if (that.options.liveSearch) {
+ that.$searchbox.trigger('focus');
+ } else {
+ that.$menuInner.trigger('focus');
+ }
+ }
+
+ function checkPopperExists () {
+ if (that.dropdown && that.dropdown._popper && that.dropdown._popper.state.isCreated) {
+ setFocus();
+ } else {
+ requestAnimationFrame(checkPopperExists);
+ }
+ }
+
+ this.$element.on('shown' + EVENT_KEY, function () {
+ if (that.$menuInner[0].scrollTop !== that.selectpicker.view.scrollTop) {
+ that.$menuInner[0].scrollTop = that.selectpicker.view.scrollTop;
+ }
+
+ if (version.major > 3) {
+ requestAnimationFrame(checkPopperExists);
+ } else {
+ setFocus();
+ }
+ });
+
+ // ensure posinset and setsize are correct before selecting an option via a click
+ this.$menuInner.on('mouseenter', 'li a', function (e) {
+ var hoverLi = this.parentElement,
+ position0 = that.isVirtual() ? that.selectpicker.view.position0 : 0,
+ index = Array.prototype.indexOf.call(hoverLi.parentElement.children, hoverLi),
+ hoverData = that.selectpicker.current.data[index + position0];
+
+ that.focusItem(hoverLi, hoverData, true);
+ });
+
+ this.$menuInner.on('click', 'li a', function (e, retainActive) {
+ var $this = $(this),
+ element = that.$element[0],
+ position0 = that.isVirtual() ? that.selectpicker.view.position0 : 0,
+ clickedData = that.selectpicker.current.data[$this.parent().index() + position0],
+ clickedIndex = clickedData.index,
+ prevValue = getSelectValues(element),
+ prevIndex = element.selectedIndex,
+ prevOption = element.options[prevIndex],
+ triggerChange = true;
+
+ // Don't close on multi choice menu
+ if (that.multiple && that.options.maxOptions !== 1) {
+ e.stopPropagation();
+ }
+
+ e.preventDefault();
+
+ // Don't run if the select is disabled
+ if (!that.isDisabled() && !$this.parent().hasClass(classNames.DISABLED)) {
+ var option = clickedData.option,
+ $option = $(option),
+ state = option.selected,
+ $optgroup = $option.parent('optgroup'),
+ $optgroupOptions = $optgroup.find('option'),
+ maxOptions = that.options.maxOptions,
+ maxOptionsGrp = $optgroup.data('maxOptions') || false;
+
+ if (clickedIndex === that.activeIndex) retainActive = true;
+
+ if (!retainActive) {
+ that.prevActiveIndex = that.activeIndex;
+ that.activeIndex = undefined;
+ }
+
+ if (!that.multiple) { // Deselect all others if not multi select box
+ if (prevOption) prevOption.selected = false;
+ option.selected = true;
+ that.setSelected(clickedIndex, true);
+ } else { // Toggle the one we have chosen if we are multi select.
+ option.selected = !state;
+
+ that.setSelected(clickedIndex, !state);
+ that.focusedParent.focus();
+
+ if (maxOptions !== false || maxOptionsGrp !== false) {
+ var maxReached = maxOptions < getSelectedOptions(element).length,
+ maxReachedGrp = maxOptionsGrp < $optgroup.find('option:selected').length;
+
+ if ((maxOptions && maxReached) || (maxOptionsGrp && maxReachedGrp)) {
+ if (maxOptions && maxOptions == 1) {
+ element.selectedIndex = -1;
+ option.selected = true;
+ that.setOptionStatus(true);
+ } else if (maxOptionsGrp && maxOptionsGrp == 1) {
+ for (var i = 0; i < $optgroupOptions.length; i++) {
+ var _option = $optgroupOptions[i];
+ _option.selected = false;
+ that.setSelected(_option.liIndex, false);
+ }
+
+ option.selected = true;
+ that.setSelected(clickedIndex, true);
+ } else {
+ var maxOptionsText = typeof that.options.maxOptionsText === 'string' ? [that.options.maxOptionsText, that.options.maxOptionsText] : that.options.maxOptionsText,
+ maxOptionsArr = typeof maxOptionsText === 'function' ? maxOptionsText(maxOptions, maxOptionsGrp) : maxOptionsText,
+ maxTxt = maxOptionsArr[0].replace('{n}', maxOptions),
+ maxTxtGrp = maxOptionsArr[1].replace('{n}', maxOptionsGrp),
+ $notify = $('<div class="notify"></div>');
+ // If {var} is set in array, replace it
+ /** @deprecated */
+ if (maxOptionsArr[2]) {
+ maxTxt = maxTxt.replace('{var}', maxOptionsArr[2][maxOptions > 1 ? 0 : 1]);
+ maxTxtGrp = maxTxtGrp.replace('{var}', maxOptionsArr[2][maxOptionsGrp > 1 ? 0 : 1]);
+ }
+
+ option.selected = false;
+
+ that.$menu.append($notify);
+
+ if (maxOptions && maxReached) {
+ $notify.append($('<div>' + maxTxt + '</div>'));
+ triggerChange = false;
+ that.$element.trigger('maxReached' + EVENT_KEY);
+ }
+
+ if (maxOptionsGrp && maxReachedGrp) {
+ $notify.append($('<div>' + maxTxtGrp + '</div>'));
+ triggerChange = false;
+ that.$element.trigger('maxReachedGrp' + EVENT_KEY);
+ }
+
+ setTimeout(function () {
+ that.setSelected(clickedIndex, false);
+ }, 10);
+
+ $notify[0].classList.add('fadeOut');
+
+ setTimeout(function () {
+ $notify.remove();
+ }, 1050);
+ }
+ }
+ }
+ }
+
+ if (!that.multiple || (that.multiple && that.options.maxOptions === 1)) {
+ that.$button.trigger('focus');
+ } else if (that.options.liveSearch) {
+ that.$searchbox.trigger('focus');
+ }
+
+ // Trigger select 'change'
+ if (triggerChange) {
+ if (that.multiple || prevIndex !== element.selectedIndex) {
+ // $option.prop('selected') is current option state (selected/unselected). prevValue is the value of the select prior to being changed.
+ changedArguments = [option.index, $option.prop('selected'), prevValue];
+ that.$element
+ .triggerNative('change');
+ }
+ }
+ }
+ });
+
+ this.$menu.on('click', 'li.' + classNames.DISABLED + ' a, .' + classNames.POPOVERHEADER + ', .' + classNames.POPOVERHEADER + ' :not(.close)', function (e) {
+ if (e.currentTarget == this) {
+ e.preventDefault();
+ e.stopPropagation();
+ if (that.options.liveSearch && !$(e.target).hasClass('close')) {
+ that.$searchbox.trigger('focus');
+ } else {
+ that.$button.trigger('focus');
+ }
+ }
+ });
+
+ this.$menuInner.on('click', '.divider, .dropdown-header', function (e) {
+ e.preventDefault();
+ e.stopPropagation();
+ if (that.options.liveSearch) {
+ that.$searchbox.trigger('focus');
+ } else {
+ that.$button.trigger('focus');
+ }
+ });
+
+ this.$menu.on('click', '.' + classNames.POPOVERHEADER + ' .close', function () {
+ that.$button.trigger('click');
+ });
+
+ this.$searchbox.on('click', function (e) {
+ e.stopPropagation();
+ });
+
+ this.$menu.on('click', '.actions-btn', function (e) {
+ if (that.options.liveSearch) {
+ that.$searchbox.trigger('focus');
+ } else {
+ that.$button.trigger('focus');
+ }
+
+ e.preventDefault();
+ e.stopPropagation();
+
+ if ($(this).hasClass('bs-select-all')) {
+ that.selectAll();
+ } else {
+ that.deselectAll();
+ }
+ });
+
+ this.$button
+ .on('focus' + EVENT_KEY, function (e) {
+ var tabindex = that.$element[0].getAttribute('tabindex');
+
+ // only change when button is actually focused
+ if (tabindex !== undefined && e.originalEvent && e.originalEvent.isTrusted) {
+ // apply select element's tabindex to ensure correct order is followed when tabbing to the next element
+ this.setAttribute('tabindex', tabindex);
+ // set element's tabindex to -1 to allow for reverse tabbing
+ that.$element[0].setAttribute('tabindex', -1);
+ that.selectpicker.view.tabindex = tabindex;
+ }
+ })
+ .on('blur' + EVENT_KEY, function (e) {
+ // revert everything to original tabindex
+ if (that.selectpicker.view.tabindex !== undefined && e.originalEvent && e.originalEvent.isTrusted) {
+ that.$element[0].setAttribute('tabindex', that.selectpicker.view.tabindex);
+ this.setAttribute('tabindex', -1);
+ that.selectpicker.view.tabindex = undefined;
+ }
+ });
+
+ this.$element
+ .on('change' + EVENT_KEY, function () {
+ that.render();
+ that.$element.trigger('changed' + EVENT_KEY, changedArguments);
+ changedArguments = null;
+ })
+ .on('focus' + EVENT_KEY, function () {
+ if (!that.options.mobile) that.$button[0].focus();
+ });
+ },
+
+ liveSearchListener: function () {
+ var that = this;
+
+ this.$button.on('click.bs.dropdown.data-api', function () {
+ if (!!that.$searchbox.val()) {
+ that.$searchbox.val('');
+ that.selectpicker.search.previousValue = undefined;
+ }
+ });
+
+ this.$searchbox.on('click.bs.dropdown.data-api focus.bs.dropdown.data-api touchend.bs.dropdown.data-api', function (e) {
+ e.stopPropagation();
+ });
+
+ this.$searchbox.on('input propertychange', function () {
+ var searchValue = that.$searchbox[0].value;
+
+ that.selectpicker.search.elements = [];
+ that.selectpicker.search.data = [];
+
+ if (searchValue) {
+ var i,
+ searchMatch = [],
+ q = searchValue.toUpperCase(),
+ cache = {},
+ cacheArr = [],
+ searchStyle = that._searchStyle(),
+ normalizeSearch = that.options.liveSearchNormalize;
+
+ if (normalizeSearch) q = normalizeToBase(q);
+
+ for (var i = 0; i < that.selectpicker.main.data.length; i++) {
+ var li = that.selectpicker.main.data[i];
+
+ if (!cache[i]) {
+ cache[i] = stringSearch(li, q, searchStyle, normalizeSearch);
+ }
+
+ if (cache[i] && li.headerIndex !== undefined && cacheArr.indexOf(li.headerIndex) === -1) {
+ if (li.headerIndex > 0) {
+ cache[li.headerIndex - 1] = true;
+ cacheArr.push(li.headerIndex - 1);
+ }
+
+ cache[li.headerIndex] = true;
+ cacheArr.push(li.headerIndex);
+
+ cache[li.lastIndex + 1] = true;
+ }
+
+ if (cache[i] && li.type !== 'optgroup-label') cacheArr.push(i);
+ }
+
+ for (var i = 0, cacheLen = cacheArr.length; i < cacheLen; i++) {
+ var index = cacheArr[i],
+ prevIndex = cacheArr[i - 1],
+ li = that.selectpicker.main.data[index],
+ liPrev = that.selectpicker.main.data[prevIndex];
+
+ if (li.type !== 'divider' || (li.type === 'divider' && liPrev && liPrev.type !== 'divider' && cacheLen - 1 !== i)) {
+ that.selectpicker.search.data.push(li);
+ searchMatch.push(that.selectpicker.main.elements[index]);
+ }
+ }
+
+ that.activeIndex = undefined;
+ that.noScroll = true;
+ that.$menuInner.scrollTop(0);
+ that.selectpicker.search.elements = searchMatch;
+ that.createView(true);
+ showNoResults.call(that, searchMatch, searchValue);
+ } else if (that.selectpicker.search.previousValue) { // for IE11 (#2402)
+ that.$menuInner.scrollTop(0);
+ that.createView(false);
+ }
+
+ that.selectpicker.search.previousValue = searchValue;
+ });
+ },
+
+ _searchStyle: function () {
+ return this.options.liveSearchStyle || 'contains';
+ },
+
+ val: function (value) {
+ var element = this.$element[0];
+
+ if (typeof value !== 'undefined') {
+ var prevValue = getSelectValues(element);
+
+ changedArguments = [null, null, prevValue];
+
+ this.$element
+ .val(value)
+ .trigger('changed' + EVENT_KEY, changedArguments);
+
+ if (this.$newElement.hasClass(classNames.SHOW)) {
+ if (this.multiple) {
+ this.setOptionStatus(true);
+ } else {
+ var liSelectedIndex = (element.options[element.selectedIndex] || {}).liIndex;
+
+ if (typeof liSelectedIndex === 'number') {
+ this.setSelected(this.selectedIndex, false);
+ this.setSelected(liSelectedIndex, true);
+ }
+ }
+ }
+
+ this.render();
+
+ changedArguments = null;
+
+ return this.$element;
+ } else {
+ return this.$element.val();
+ }
+ },
+
+ changeAll: function (status) {
+ if (!this.multiple) return;
+ if (typeof status === 'undefined') status = true;
+
+ var element = this.$element[0],
+ previousSelected = 0,
+ currentSelected = 0,
+ prevValue = getSelectValues(element);
+
+ element.classList.add('bs-select-hidden');
+
+ for (var i = 0, data = this.selectpicker.current.data, len = data.length; i < len; i++) {
+ var liData = data[i],
+ option = liData.option;
+
+ if (option && !liData.disabled && liData.type !== 'divider') {
+ if (liData.selected) previousSelected++;
+ option.selected = status;
+ if (status === true) currentSelected++;
+ }
+ }
+
+ element.classList.remove('bs-select-hidden');
+
+ if (previousSelected === currentSelected) return;
+
+ this.setOptionStatus();
+
+ changedArguments = [null, null, prevValue];
+
+ this.$element
+ .triggerNative('change');
+ },
+
+ selectAll: function () {
+ return this.changeAll(true);
+ },
+
+ deselectAll: function () {
+ return this.changeAll(false);
+ },
+
+ toggle: function (e) {
+ e = e || window.event;
+
+ if (e) e.stopPropagation();
+
+ this.$button.trigger('click.bs.dropdown.data-api');
+ },
+
+ keydown: function (e) {
+ var $this = $(this),
+ isToggle = $this.hasClass('dropdown-toggle'),
+ $parent = isToggle ? $this.closest('.dropdown') : $this.closest(Selector.MENU),
+ that = $parent.data('this'),
+ $items = that.findLis(),
+ index,
+ isActive,
+ liActive,
+ activeLi,
+ offset,
+ updateScroll = false,
+ downOnTab = e.which === keyCodes.TAB && !isToggle && !that.options.selectOnTab,
+ isArrowKey = REGEXP_ARROW.test(e.which) || downOnTab,
+ scrollTop = that.$menuInner[0].scrollTop,
+ isVirtual = that.isVirtual(),
+ position0 = isVirtual === true ? that.selectpicker.view.position0 : 0;
+
+ // do nothing if a function key is pressed
+ if (e.which >= 112 && e.which <= 123) return;
+
+ isActive = that.$newElement.hasClass(classNames.SHOW);
+
+ if (
+ !isActive &&
+ (
+ isArrowKey ||
+ (e.which >= 48 && e.which <= 57) ||
+ (e.which >= 96 && e.which <= 105) ||
+ (e.which >= 65 && e.which <= 90)
+ )
+ ) {
+ that.$button.trigger('click.bs.dropdown.data-api');
+
+ if (that.options.liveSearch) {
+ that.$searchbox.trigger('focus');
+ return;
+ }
+ }
+
+ if (e.which === keyCodes.ESCAPE && isActive) {
+ e.preventDefault();
+ that.$button.trigger('click.bs.dropdown.data-api').trigger('focus');
+ }
+
+ if (isArrowKey) { // if up or down
+ if (!$items.length) return;
+
+ liActive = that.selectpicker.main.elements[that.activeIndex];
+ index = liActive ? Array.prototype.indexOf.call(liActive.parentElement.children, liActive) : -1;
+
+ if (index !== -1) {
+ that.defocusItem(liActive);
+ }
+
+ if (e.which === keyCodes.ARROW_UP) { // up
+ if (index !== -1) index--;
+ if (index + position0 < 0) index += $items.length;
+
+ if (!that.selectpicker.view.canHighlight[index + position0]) {
+ index = that.selectpicker.view.canHighlight.slice(0, index + position0).lastIndexOf(true) - position0;
+ if (index === -1) index = $items.length - 1;
+ }
+ } else if (e.which === keyCodes.ARROW_DOWN || downOnTab) { // down
+ index++;
+ if (index + position0 >= that.selectpicker.view.canHighlight.length) index = that.selectpicker.view.firstHighlightIndex;
+
+ if (!that.selectpicker.view.canHighlight[index + position0]) {
+ index = index + 1 + that.selectpicker.view.canHighlight.slice(index + position0 + 1).indexOf(true);
+ }
+ }
+
+ e.preventDefault();
+
+ var liActiveIndex = position0 + index;
+
+ if (e.which === keyCodes.ARROW_UP) { // up
+ // scroll to bottom and highlight last option
+ if (position0 === 0 && index === $items.length - 1) {
+ that.$menuInner[0].scrollTop = that.$menuInner[0].scrollHeight;
+
+ liActiveIndex = that.selectpicker.current.elements.length - 1;
+ } else {
+ activeLi = that.selectpicker.current.data[liActiveIndex];
+ offset = activeLi.position - activeLi.height;
+
+ updateScroll = offset < scrollTop;
+ }
+ } else if (e.which === keyCodes.ARROW_DOWN || downOnTab) { // down
+ // scroll to top and highlight first option
+ if (index === that.selectpicker.view.firstHighlightIndex) {
+ that.$menuInner[0].scrollTop = 0;
+
+ liActiveIndex = that.selectpicker.view.firstHighlightIndex;
+ } else {
+ activeLi = that.selectpicker.current.data[liActiveIndex];
+ offset = activeLi.position - that.sizeInfo.menuInnerHeight;
+
+ updateScroll = offset > scrollTop;
+ }
+ }
+
+ liActive = that.selectpicker.current.elements[liActiveIndex];
+
+ that.activeIndex = that.selectpicker.current.data[liActiveIndex].index;
+
+ that.focusItem(liActive);
+
+ that.selectpicker.view.currentActive = liActive;
+
+ if (updateScroll) that.$menuInner[0].scrollTop = offset;
+
+ if (that.options.liveSearch) {
+ that.$searchbox.trigger('focus');
+ } else {
+ $this.trigger('focus');
+ }
+ } else if (
+ (!$this.is('input') && !REGEXP_TAB_OR_ESCAPE.test(e.which)) ||
+ (e.which === keyCodes.SPACE && that.selectpicker.keydown.keyHistory)
+ ) {
+ var searchMatch,
+ matches = [],
+ keyHistory;
+
+ e.preventDefault();
+
+ that.selectpicker.keydown.keyHistory += keyCodeMap[e.which];
+
+ if (that.selectpicker.keydown.resetKeyHistory.cancel) clearTimeout(that.selectpicker.keydown.resetKeyHistory.cancel);
+ that.selectpicker.keydown.resetKeyHistory.cancel = that.selectpicker.keydown.resetKeyHistory.start();
+
+ keyHistory = that.selectpicker.keydown.keyHistory;
+
+ // if all letters are the same, set keyHistory to just the first character when searching
+ if (/^(.)\1+$/.test(keyHistory)) {
+ keyHistory = keyHistory.charAt(0);
+ }
+
+ // find matches
+ for (var i = 0; i < that.selectpicker.current.data.length; i++) {
+ var li = that.selectpicker.current.data[i],
+ hasMatch;
+
+ hasMatch = stringSearch(li, keyHistory, 'startsWith', true);
+
+ if (hasMatch && that.selectpicker.view.canHighlight[i]) {
+ matches.push(li.index);
+ }
+ }
+
+ if (matches.length) {
+ var matchIndex = 0;
+
+ $items.removeClass('active').find('a').removeClass('active');
+
+ // either only one key has been pressed or they are all the same key
+ if (keyHistory.length === 1) {
+ matchIndex = matches.indexOf(that.activeIndex);
+
+ if (matchIndex === -1 || matchIndex === matches.length - 1) {
+ matchIndex = 0;
+ } else {
+ matchIndex++;
+ }
+ }
+
+ searchMatch = matches[matchIndex];
+
+ activeLi = that.selectpicker.main.data[searchMatch];
+
+ if (scrollTop - activeLi.position > 0) {
+ offset = activeLi.position - activeLi.height;
+ updateScroll = true;
+ } else {
+ offset = activeLi.position - that.sizeInfo.menuInnerHeight;
+ // if the option is already visible at the current scroll position, just keep it the same
+ updateScroll = activeLi.position > scrollTop + that.sizeInfo.menuInnerHeight;
+ }
+
+ liActive = that.selectpicker.main.elements[searchMatch];
+
+ that.activeIndex = matches[matchIndex];
+
+ that.focusItem(liActive);
+
+ if (liActive) liActive.firstChild.focus();
+
+ if (updateScroll) that.$menuInner[0].scrollTop = offset;
+
+ $this.trigger('focus');
+ }
+ }
+
+ // Select focused option if "Enter", "Spacebar" or "Tab" (when selectOnTab is true) are pressed inside the menu.
+ if (
+ isActive &&
+ (
+ (e.which === keyCodes.SPACE && !that.selectpicker.keydown.keyHistory) ||
+ e.which === keyCodes.ENTER ||
+ (e.which === keyCodes.TAB && that.options.selectOnTab)
+ )
+ ) {
+ if (e.which !== keyCodes.SPACE) e.preventDefault();
+
+ if (!that.options.liveSearch || e.which !== keyCodes.SPACE) {
+ that.$menuInner.find('.active a').trigger('click', true); // retain active class
+ $this.trigger('focus');
+
+ if (!that.options.liveSearch) {
+ // Prevent screen from scrolling if the user hits the spacebar
+ e.preventDefault();
+ // Fixes spacebar selection of dropdown items in FF & IE
+ $(document).data('spaceSelect', true);
+ }
+ }
+ }
+ },
+
+ mobile: function () {
+ // ensure mobile is set to true if mobile function is called after init
+ this.options.mobile = true;
+ this.$element[0].classList.add('mobile-device');
+ },
+
+ refresh: function () {
+ // update options if data attributes have been changed
+ var config = $.extend({}, this.options, this.$element.data());
+ this.options = config;
+
+ this.checkDisabled();
+ this.buildData();
+ this.setStyle();
+ this.render();
+ this.buildList();
+ this.setWidth();
+
+ this.setSize(true);
+
+ this.$element.trigger('refreshed' + EVENT_KEY);
+ },
+
+ hide: function () {
+ this.$newElement.hide();
+ },
+
+ show: function () {
+ this.$newElement.show();
+ },
+
+ remove: function () {
+ this.$newElement.remove();
+ this.$element.remove();
+ },
+
+ destroy: function () {
+ this.$newElement.before(this.$element).remove();
+
+ if (this.$bsContainer) {
+ this.$bsContainer.remove();
+ } else {
+ this.$menu.remove();
+ }
+
+ if (this.selectpicker.view.titleOption && this.selectpicker.view.titleOption.parentNode) {
+ this.selectpicker.view.titleOption.parentNode.removeChild(this.selectpicker.view.titleOption);
+ }
+
+ this.$element
+ .off(EVENT_KEY)
+ .removeData('selectpicker')
+ .removeClass('bs-select-hidden selectpicker');
+
+ $(window).off(EVENT_KEY + '.' + this.selectId);
+ }
+ };
+
+ // SELECTPICKER PLUGIN DEFINITION
+ // ==============================
+ function Plugin (option) {
+ // get the args of the outer function..
+ var args = arguments;
+ // The arguments of the function are explicitly re-defined from the argument list, because the shift causes them
+ // to get lost/corrupted in android 2.3 and IE9 #715 #775
+ var _option = option;
+
+ [].shift.apply(args);
+
+ // if the version was not set successfully
+ if (!version.success) {
+ // try to retreive it again
+ try {
+ version.full = ($.fn.dropdown.Constructor.VERSION || '').split(' ')[0].split('.');
+ } catch (err) {
+ // fall back to use BootstrapVersion if set
+ if (Selectpicker.BootstrapVersion) {
+ version.full = Selectpicker.BootstrapVersion.split(' ')[0].split('.');
+ } else {
+ version.full = [version.major, '0', '0'];
+
+ console.warn(
+ 'There was an issue retrieving Bootstrap\'s version. ' +
+ 'Ensure Bootstrap is being loaded before bootstrap-select and there is no namespace collision. ' +
+ 'If loading Bootstrap asynchronously, the version may need to be manually specified via $.fn.selectpicker.Constructor.BootstrapVersion.',
+ err
+ );
+ }
+ }
+
+ version.major = version.full[0];
+ version.success = true;
+ }
+
+ if (version.major === '4') {
+ // some defaults need to be changed if using Bootstrap 4
+ // check to see if they have already been manually changed before forcing them to update
+ var toUpdate = [];
+
+ if (Selectpicker.DEFAULTS.style === classNames.BUTTONCLASS) toUpdate.push({ name: 'style', className: 'BUTTONCLASS' });
+ if (Selectpicker.DEFAULTS.iconBase === classNames.ICONBASE) toUpdate.push({ name: 'iconBase', className: 'ICONBASE' });
+ if (Selectpicker.DEFAULTS.tickIcon === classNames.TICKICON) toUpdate.push({ name: 'tickIcon', className: 'TICKICON' });
+
+ classNames.DIVIDER = 'dropdown-divider';
+ classNames.SHOW = 'show';
+ classNames.BUTTONCLASS = 'btn-light';
+ classNames.POPOVERHEADER = 'popover-header';
+ classNames.ICONBASE = '';
+ classNames.TICKICON = 'bs-ok-default';
+
+ for (var i = 0; i < toUpdate.length; i++) {
+ var option = toUpdate[i];
+ Selectpicker.DEFAULTS[option.name] = classNames[option.className];
+ }
+ }
+
+ var value;
+ var chain = this.each(function () {
+ var $this = $(this);
+ if ($this.is('select')) {
+ var data = $this.data('selectpicker'),
+ options = typeof _option == 'object' && _option;
+
+ if (!data) {
+ var dataAttributes = $this.data();
+
+ for (var dataAttr in dataAttributes) {
+ if (Object.prototype.hasOwnProperty.call(dataAttributes, dataAttr) && $.inArray(dataAttr, DISALLOWED_ATTRIBUTES) !== -1) {
+ delete dataAttributes[dataAttr];
+ }
+ }
+
+ var config = $.extend({}, Selectpicker.DEFAULTS, $.fn.selectpicker.defaults || {}, dataAttributes, options);
+ config.template = $.extend({}, Selectpicker.DEFAULTS.template, ($.fn.selectpicker.defaults ? $.fn.selectpicker.defaults.template : {}), dataAttributes.template, options.template);
+ $this.data('selectpicker', (data = new Selectpicker(this, config)));
+ } else if (options) {
+ for (var i in options) {
+ if (Object.prototype.hasOwnProperty.call(options, i)) {
+ data.options[i] = options[i];
+ }
+ }
+ }
+
+ if (typeof _option == 'string') {
+ if (data[_option] instanceof Function) {
+ value = data[_option].apply(data, args);
+ } else {
+ value = data.options[_option];
+ }
+ }
+ }
+ });
+
+ if (typeof value !== 'undefined') {
+ // noinspection JSUnusedAssignment
+ return value;
+ } else {
+ return chain;
+ }
+ }
+
+ var old = $.fn.selectpicker;
+ $.fn.selectpicker = Plugin;
+ $.fn.selectpicker.Constructor = Selectpicker;
+
+ // SELECTPICKER NO CONFLICT
+ // ========================
+ $.fn.selectpicker.noConflict = function () {
+ $.fn.selectpicker = old;
+ return this;
+ };
+
+ // get Bootstrap's keydown event handler for either Bootstrap 4 or Bootstrap 3
+ function keydownHandler () {
+ if ($.fn.dropdown) {
+ // wait to define until function is called in case Bootstrap isn't loaded yet
+ var bootstrapKeydown = $.fn.dropdown.Constructor._dataApiKeydownHandler || $.fn.dropdown.Constructor.prototype.keydown;
+ return bootstrapKeydown.apply(this, arguments);
+ }
+ }
+
+ $(document)
+ .off('keydown.bs.dropdown.data-api')
+ .on('keydown.bs.dropdown.data-api', ':not(.bootstrap-select) > [data-toggle="dropdown"]', keydownHandler)
+ .on('keydown.bs.dropdown.data-api', ':not(.bootstrap-select) > .dropdown-menu', keydownHandler)
+ .on('keydown' + EVENT_KEY, '.bootstrap-select [data-toggle="dropdown"], .bootstrap-select [role="listbox"], .bootstrap-select .bs-searchbox input', Selectpicker.prototype.keydown)
+ .on('focusin.modal', '.bootstrap-select [data-toggle="dropdown"], .bootstrap-select [role="listbox"], .bootstrap-select .bs-searchbox input', function (e) {
+ e.stopPropagation();
+ });
+
+ // SELECTPICKER DATA-API
+ // =====================
+ $(window).on('load' + EVENT_KEY + '.data-api', function () {
+ $('.selectpicker').each(function () {
+ var $selectpicker = $(this);
+ Plugin.call($selectpicker, $selectpicker.data());
+ })
+ });
+})(jQuery);
+
+
}));
//# sourceMappingURL=bootstrap-select.js.map
\ No newline at end of file
diff --git a/share/static/css/elevator-light/bootstrap-select.css b/share/static/css/elevator-light/bootstrap-select.css
index a1bf7f3248..34edabf854 100644
--- a/share/static/css/elevator-light/bootstrap-select.css
+++ b/share/static/css/elevator-light/bootstrap-select.css
@@ -1,10 +1,34 @@
/*!
- * Bootstrap-select v1.13.10 (https://developer.snapappointments.com/bootstrap-select)
+ * Bootstrap-select v1.13.18 (https://developer.snapappointments.com/bootstrap-select)
*
- * Copyright 2012-2019 SnapAppointments, LLC
+ * Copyright 2012-2020 SnapAppointments, LLC
* Licensed under MIT (https://github.com/snapappointments/bootstrap-select/blob/master/LICENSE)
*/
+ at -webkit-keyframes bs-notify-fadeOut {
+ 0% {
+ opacity: 0.9;
+ }
+ 100% {
+ opacity: 0;
+ }
+}
+ at -o-keyframes bs-notify-fadeOut {
+ 0% {
+ opacity: 0.9;
+ }
+ 100% {
+ opacity: 0;
+ }
+}
+ at keyframes bs-notify-fadeOut {
+ 0% {
+ opacity: 0.9;
+ }
+ 100% {
+ opacity: 0;
+ }
+}
select.bs-select-hidden,
.bootstrap-select > select.bs-select-hidden,
select.selectpicker {
@@ -90,11 +114,11 @@ select.selectpicker {
.has-error .bootstrap-select .dropdown-toggle,
.error .bootstrap-select .dropdown-toggle,
.bootstrap-select.is-invalid .dropdown-toggle,
-.was-validated .bootstrap-select .selectpicker:invalid + .dropdown-toggle {
+.was-validated .bootstrap-select select:invalid + .dropdown-toggle {
border-color: #b94a48;
}
.bootstrap-select.is-valid .dropdown-toggle,
-.was-validated .bootstrap-select .selectpicker:valid + .dropdown-toggle {
+.was-validated .bootstrap-select select:valid + .dropdown-toggle {
border-color: #28a745;
}
.bootstrap-select.fit-width {
@@ -300,6 +324,11 @@ select.selectpicker {
-moz-box-sizing: border-box;
box-sizing: border-box;
}
+.bootstrap-select .dropdown-menu .notify.fadeOut {
+ -webkit-animation: 300ms linear 750ms forwards bs-notify-fadeOut;
+ -o-animation: 300ms linear 750ms forwards bs-notify-fadeOut;
+ animation: 300ms linear 750ms forwards bs-notify-fadeOut;
+}
.bootstrap-select .no-results {
padding: 3px;
background: #f5f5f5;
@@ -339,6 +368,8 @@ select.selectpicker {
height: 1em;
border-style: solid;
border-width: 0 0.26em 0.26em 0;
+ -webkit-transform-style: preserve-3d;
+ transform-style: preserve-3d;
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
diff --git a/share/static/js/bootstrap-select.min.js b/share/static/js/bootstrap-select.min.js
index 887da61ccf..45997388b0 100644
--- a/share/static/js/bootstrap-select.min.js
+++ b/share/static/js/bootstrap-select.min.js
@@ -1,8 +1,8 @@
/*!
- * Bootstrap-select v1.13.10 (https://developer.snapappointments.com/bootstrap-select)
+ * Bootstrap-select v1.13.18 (https://developer.snapappointments.com/bootstrap-select)
*
- * Copyright 2012-2019 SnapAppointments, LLC
+ * Copyright 2012-2020 SnapAppointments, LLC
* Licensed under MIT (https://github.com/snapappointments/bootstrap-select/blob/master/LICENSE)
*/
-!function(e,t){void 0===e&&void 0!==window&&(e=window),"function"==typeof define&&define.amd?define(["jquery"],function(e){return t(e)}):"object"==typeof module&&module.exports?module.exports=t(require("jquery")):t(e.jQuery)}(this,function(e){!function(z){"use strict";var d=["sanitize","whiteList","sanitizeFn"],r=["background","cite","href","itemtype","longdesc","poster","src","xlink:href"],e={"*":["class","dir","id","lang","role","tabindex","style",/^aria-[\w-]*$/i],a:["target","href","title","rel"],area:[],b:[],br:[],col:[],code:[],div:[],em:[],hr:[],h1:[],h2:[],h3:[],h4:[],h5:[],h6:[],i:[],img:["src","alt","title","width","height"],li:[],ol:[],p:[],pre:[],s:[],small:[],span:[],sub:[],sup:[],strong:[],u:[],ul:[]},l=/^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi,a=/^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i;function v(e,t){var i=e.nodeName.toLowerCase();if(-1!==z.inArray(i,t))re
turn-1===z.inArray(i,r)||Boolean(e.nodeValue.match(l)||e.nodeValue.match(a));for(var s=z(t).filter(function(e,t){return t instanceof RegExp}),n=0,o=s.length;n<o;n++)if(i.match(s[n]))return!0;return!1}function P(e,t,i){if(i&&"function"==typeof i)return i(e);for(var s=Object.keys(t),n=0,o=e.length;n<o;n++)for(var r=e[n].querySelectorAll("*"),l=0,a=r.length;l<a;l++){var c=r[l],d=c.nodeName.toLowerCase();if(-1!==s.indexOf(d))for(var h=[].slice.call(c.attributes),p=[].concat(t["*"]||[],t[d]||[]),u=0,f=h.length;u<f;u++){var m=h[u];v(m,p)||c.removeAttribute(m.nodeName)}else c.parentNode.removeChild(c)}}"classList"in document.createElement("_")||function(e){if("Element"in e){var t="classList",i="prototype",s=e.Element[i],n=Object,o=function(){var i=z(this);return{add:function(e){return e=Array.prototype.slice.call(arguments).join(" "),i.addClass(e)},remove:function(e){return e=Array.prototype.slice.call(arguments).join(" "),i.removeClass(e)},toggle:function(e,t){return i.toggleClass(e,t)},c
ontains:function(e){return i.hasClass(e)}}};if(n.defineProperty){var r={get:o,enumerable:!0,configurable:!0};try{n.defineProperty(s,t,r)}catch(e){void 0!==e.number&&-2146823252!==e.number||(r.enumerable=!1,n.defineProperty(s,t,r))}}else n[i].__defineGetter__&&s.__defineGetter__(t,o)}}(window);var t,c,i,s=document.createElement("_");if(s.classList.add("c1","c2"),!s.classList.contains("c2")){var n=DOMTokenList.prototype.add,o=DOMTokenList.prototype.remove;DOMTokenList.prototype.add=function(){Array.prototype.forEach.call(arguments,n.bind(this))},DOMTokenList.prototype.remove=function(){Array.prototype.forEach.call(arguments,o.bind(this))}}if(s.classList.toggle("c3",!1),s.classList.contains("c3")){var h=DOMTokenList.prototype.toggle;DOMTokenList.prototype.toggle=function(e,t){return 1 in arguments&&!this.contains(e)==!t?t:h.call(this,e)}}function O(e,t){for(var i,s=[],n=t||e.selectedOptions,o=0,r=n.length;o<r;o++)(i=n[o]).disabled||"OPTGROUP"===i.parentNode.tagName&&i.parentNode.disabl
ed||s.push(i.value||i.text);return e.multiple?s:s.length?s[0]:null}s=null,String.prototype.startsWith||(t=function(){try{var e={},t=Object.defineProperty,i=t(e,e,e)&&t}catch(e){}return i}(),c={}.toString,i=function(e){if(null==this)throw new TypeError;var t=String(this);if(e&&"[object RegExp]"==c.call(e))throw new TypeError;var i=t.length,s=String(e),n=s.length,o=1<arguments.length?arguments[1]:void 0,r=o?Number(o):0;r!=r&&(r=0);var l=Math.min(Math.max(r,0),i);if(i<n+l)return!1;for(var a=-1;++a<n;)if(t.charCodeAt(l+a)!=s.charCodeAt(a))return!1;return!0},t?t(String.prototype,"startsWith",{value:i,configurable:!0,writable:!0}):String.prototype.startsWith=i),Object.keys||(Object.keys=function(e,t,i){for(t in i=[],e)i.hasOwnProperty.call(e,t)&&i.push(t);return i}),HTMLSelectElement&&!HTMLSelectElement.prototype.hasOwnProperty("selectedOptions")&&Object.defineProperty(HTMLSelectElement.prototype,"selectedOptions",{get:function(){return this.querySelectorAll(":checked")}});var p={useDefau
lt:!1,_set:z.valHooks.select.set};z.valHooks.select.set=function(e,t){return t&&!p.useDefault&&z(e).data("selected",!0),p._set.apply(this,arguments)};var T=null,u=function(){try{return new Event("change"),!0}catch(e){return!1}}();function k(e,t,i,s){for(var n=["display","subtext","tokens"],o=!1,r=0;r<n.length;r++){var l=n[r],a=e[l];if(a&&(a=a.toString(),"display"===l&&(a=a.replace(/<[^>]+>/g,"")),s&&(a=w(a)),a=a.toUpperCase(),o="contains"===i?0<=a.indexOf(t):a.startsWith(t)))break}return o}function A(e){return parseInt(e,10)||0}z.fn.triggerNative=function(e){var t,i=this[0];i.dispatchEvent?(u?t=new Event(e,{bubbles:!0}):(t=document.createEvent("Event")).initEvent(e,!0,!1),i.dispatchEvent(t)):i.fireEvent?((t=document.createEventObject()).eventType=e,i.fireEvent("on"+e,t)):this.trigger(e)};var f={"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc
9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss","\u0100":"A","\u0102":"A","\u0104":"A","\u0101":"a","\u0103":"a","\u0105":"a","\u0106":"C","\u0108":"C","\u010a":"C","\u010c":"C","\u0107":"c","\u0109":"c","\u010b":"c","\u010d":"c","\u010e":"D","\u0110":"D","\u010f":"d","\u0111":"d","\u0112":"E","\u0114":"E","\u0116":"E","\u0118":"E","\u011a":"E","\u0113":"e","\u0115":"e","\u0117":"e","\u0119":"e","\u011b":"e","\u011c":"G","\u011e":"G","\u0120":"G","\u0122":"G","\u011d":"g","\u011f":"g","\u0121":"g","\u0123":"g","\u0124":"H","\u0126":"H","\u0125
":"h","\u0127":"h","\u0128":"I","\u012a":"I","\u012c":"I","\u012e":"I","\u0130":"I","\u0129":"i","\u012b":"i","\u012d":"i","\u012f":"i","\u0131":"i","\u0134":"J","\u0135":"j","\u0136":"K","\u0137":"k","\u0138":"k","\u0139":"L","\u013b":"L","\u013d":"L","\u013f":"L","\u0141":"L","\u013a":"l","\u013c":"l","\u013e":"l","\u0140":"l","\u0142":"l","\u0143":"N","\u0145":"N","\u0147":"N","\u014a":"N","\u0144":"n","\u0146":"n","\u0148":"n","\u014b":"n","\u014c":"O","\u014e":"O","\u0150":"O","\u014d":"o","\u014f":"o","\u0151":"o","\u0154":"R","\u0156":"R","\u0158":"R","\u0155":"r","\u0157":"r","\u0159":"r","\u015a":"S","\u015c":"S","\u015e":"S","\u0160":"S","\u015b":"s","\u015d":"s","\u015f":"s","\u0161":"s","\u0162":"T","\u0164":"T","\u0166":"T","\u0163":"t","\u0165":"t","\u0167":"t","\u0168":"U","\u016a":"U","\u016c":"U","\u016e":"U","\u0170":"U","\u0172":"U","\u0169":"u","\u016b":"u","\u016d":"u","\u016f":"u","\u0171":"u","\u0173":"u","\u0174":"W","\u0175":"w","\u0176":"Y","\u0177":"y","\u
0178":"Y","\u0179":"Z","\u017b":"Z","\u017d":"Z","\u017a":"z","\u017c":"z","\u017e":"z","\u0132":"IJ","\u0133":"ij","\u0152":"Oe","\u0153":"oe","\u0149":"'n","\u017f":"s"},m=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,g=RegExp("[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]","g");function b(e){return f[e]}function w(e){return(e=e.toString())&&e.replace(m,b).replace(g,"")}var I,x,$,y,S,E=(I={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},x=function(e){return I[e]},$="(?:"+Object.keys(I).join("|")+")",y=RegExp($),S=RegExp($,"g"),function(e){return e=null==e?"":""+e,y.test(e)?e.replace(S,x):e}),C={32:" ",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",59:";",65:"A",66:"B",67:"C",68:"D",69:"E",70:"F",71:"G",72:"H",73:"I",74:"J",75:"K",76:"L",77:"M",78:"N",79:"O",80:"P",81:"Q",82:"R",83:"S",84:"T",85:"U",86:"V",87:"W",88:"X",89:"Y",90:"Z",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",1
05:"9"},L=27,N=13,D=32,H=9,B=38,W=40,M={success:!1,major:"3"};try{M.full=(z.fn.dropdown.Constructor.VERSION||"").split(" ")[0].split("."),M.major=M.full[0],M.success=!0}catch(e){}var R=0,U=".bs.select",j={DISABLED:"disabled",DIVIDER:"divider",SHOW:"open",DROPUP:"dropup",MENU:"dropdown-menu",MENURIGHT:"dropdown-menu-right",MENULEFT:"dropdown-menu-left",BUTTONCLASS:"btn-default",POPOVERHEADER:"popover-title",ICONBASE:"glyphicon",TICKICON:"glyphicon-ok"},V={MENU:"."+j.MENU},F={span:document.createElement("span"),i:document.createElement("i"),subtext:document.createElement("small"),a:document.createElement("a"),li:document.createElement("li"),whitespace:document.createTextNode("\xa0"),fragment:document.createDocumentFragment()};F.a.setAttribute("role","option"),F.subtext.className="text-muted",F.text=F.span.cloneNode(!1),F.text.className="text",F.checkMark=F.span.cloneNode(!1);var _=new RegExp(B+"|"+W),G=new RegExp("^"+H+"$|"+L),q=function(e,t,i){var s=F.li.cloneNode(!1);return e&&(1===
e.nodeType||11===e.nodeType?s.appendChild(e):s.innerHTML=e),void 0!==t&&""!==t&&(s.className=t),null!=i&&s.classList.add("optgroup-"+i),s},K=function(e,t,i){var s=F.a.cloneNode(!0);return e&&(11===e.nodeType?s.appendChild(e):s.insertAdjacentHTML("beforeend",e)),void 0!==t&&""!==t&&(s.className=t),"4"===M.major&&s.classList.add("dropdown-item"),i&&s.setAttribute("style",i),s},Y=function(e,t){var i,s,n=F.text.cloneNode(!1);if(e.content)n.innerHTML=e.content;else{if(n.textContent=e.text,e.icon){var o=F.whitespace.cloneNode(!1);(s=(!0===t?F.i:F.span).cloneNode(!1)).className=e.iconBase+" "+e.icon,F.fragment.appendChild(s),F.fragment.appendChild(o)}e.subtext&&((i=F.subtext.cloneNode(!1)).textContent=e.subtext,n.appendChild(i))}if(!0===t)for(;0<n.childNodes.length;)F.fragment.appendChild(n.childNodes[0]);else F.fragment.appendChild(n);return F.fragment},Z=function(e){var t,i,s=F.text.cloneNode(!1);if(s.innerHTML=e.label,e.icon){var n=F.whitespace.cloneNode(!1);(i=F.span.cloneNode(!1)).cla
ssName=e.iconBase+" "+e.icon,F.fragment.appendChild(i),F.fragment.appendChild(n)}return e.subtext&&((t=F.subtext.cloneNode(!1)).textContent=e.subtext,s.appendChild(t)),F.fragment.appendChild(s),F.fragment},J=function(e,t){var i=this;p.useDefault||(z.valHooks.select.set=p._set,p.useDefault=!0),this.$element=z(e),this.$newElement=null,this.$button=null,this.$menu=null,this.options=t,this.selectpicker={main:{},search:{},current:{},view:{},keydown:{keyHistory:"",resetKeyHistory:{start:function(){return setTimeout(function(){i.selectpicker.keydown.keyHistory=""},800)}}}},null===this.options.title&&(this.options.title=this.$element.attr("title"));var s=this.options.windowPadding;"number"==typeof s&&(this.options.windowPadding=[s,s,s,s]),this.val=J.prototype.val,this.render=J.prototype.render,this.refresh=J.prototype.refresh,this.setStyle=J.prototype.setStyle,this.selectAll=J.prototype.selectAll,this.deselectAll=J.prototype.deselectAll,this.destroy=J.prototype.destroy,this.remove=J.prototy
pe.remove,this.show=J.prototype.show,this.hide=J.prototype.hide,this.init()};function Q(e){var l,a=arguments,c=e;if([].shift.apply(a),!M.success){try{M.full=(z.fn.dropdown.Constructor.VERSION||"").split(" ")[0].split(".")}catch(e){J.BootstrapVersion?M.full=J.BootstrapVersion.split(" ")[0].split("."):(M.full=[M.major,"0","0"],console.warn("There was an issue retrieving Bootstrap's version. Ensure Bootstrap is being loaded before bootstrap-select and there is no namespace collision. If loading Bootstrap asynchronously, the version may need to be manually specified via $.fn.selectpicker.Constructor.BootstrapVersion.",e))}M.major=M.full[0],M.success=!0}if("4"===M.major){var t=[];J.DEFAULTS.style===j.BUTTONCLASS&&t.push({name:"style",className:"BUTTONCLASS"}),J.DEFAULTS.iconBase===j.ICONBASE&&t.push({name:"iconBase",className:"ICONBASE"}),J.DEFAULTS.tickIcon===j.TICKICON&&t.push({name:"tickIcon",className:"TICKICON"}),j.DIVIDER="dropdown-divider",j.SHOW="show",j.BUTTONCLASS="btn-light",j
.POPOVERHEADER="popover-header",j.ICONBASE="",j.TICKICON="bs-ok-default";for(var i=0;i<t.length;i++){e=t[i];J.DEFAULTS[e.name]=j[e.className]}}var s=this.each(function(){var e=z(this);if(e.is("select")){var t=e.data("selectpicker"),i="object"==typeof c&&c;if(t){if(i)for(var s in i)i.hasOwnProperty(s)&&(t.options[s]=i[s])}else{var n=e.data();for(var o in n)n.hasOwnProperty(o)&&-1!==z.inArray(o,d)&&delete n[o];var r=z.extend({},J.DEFAULTS,z.fn.selectpicker.defaults||{},n,i);r.template=z.extend({},J.DEFAULTS.template,z.fn.selectpicker.defaults?z.fn.selectpicker.defaults.template:{},n.template,i.template),e.data("selectpicker",t=new J(this,r))}"string"==typeof c&&(l=t[c]instanceof Function?t[c].apply(t,a):t.options[c])}});return void 0!==l?l:s}J.VERSION="1.13.10",J.DEFAULTS={noneSelectedText:"Nothing selected",noneResultsText:"No results matched {0}",countSelectedText:function(e,t){return 1==e?"{0} item selected":"{0} items selected"},maxOptionsText:function(e,t){return[1==e?"Limit reac
hed ({n} item max)":"Limit reached ({n} items max)",1==t?"Group limit reached ({n} item max)":"Group limit reached ({n} items max)"]},selectAllText:"Select All",deselectAllText:"Deselect All",doneButton:!1,doneButtonText:"Close",multipleSeparator:", ",styleBase:"btn",style:j.BUTTONCLASS,size:"auto",title:null,selectedTextFormat:"values",width:!1,container:!1,hideDisabled:!1,showSubtext:!1,showIcon:!0,showContent:!0,dropupAuto:!0,header:!1,liveSearch:!1,liveSearchPlaceholder:null,liveSearchNormalize:!1,liveSearchStyle:"contains",actionsBox:!1,iconBase:j.ICONBASE,tickIcon:j.TICKICON,showTick:!1,template:{caret:'<span class="caret"></span>'},maxOptions:!1,mobile:!1,selectOnTab:!1,dropdownAlignRight:!1,windowPadding:0,virtualScroll:600,display:!1,sanitize:!0,sanitizeFn:null,whiteList:e},J.prototype={constructor:J,init:function(){var i=this,e=this.$element.attr("id");R++,this.selectId="bs-select-"+R,this.$element[0].classList.add("bs-select-hidden"),this.multiple=this.$element.prop("mult
iple"),this.autofocus=this.$element.prop("autofocus"),this.$element[0].classList.contains("show-tick")&&(this.options.showTick=!0),this.$newElement=this.createDropdown(),this.$element.after(this.$newElement).prependTo(this.$newElement),this.$button=this.$newElement.children("button"),this.$menu=this.$newElement.children(V.MENU),this.$menuInner=this.$menu.children(".inner"),this.$searchbox=this.$menu.find("input"),this.$element[0].classList.remove("bs-select-hidden"),!0===this.options.dropdownAlignRight&&this.$menu[0].classList.add(j.MENURIGHT),void 0!==e&&this.$button.attr("data-id",e),this.checkDisabled(),this.clickListener(),this.options.liveSearch?(this.liveSearchListener(),this.focusedParent=this.$searchbox[0]):this.focusedParent=this.$menuInner[0],this.setStyle(),this.render(),this.setWidth(),this.options.container?this.selectPosition():this.$element.on("hide"+U,function(){if(i.isVirtual()){var e=i.$menuInner[0],t=e.firstChild.cloneNode(!1);e.replaceChild(t,e.firstChild),e.scro
llTop=0}}),this.$menu.data("this",this),this.$newElement.data("this",this),this.options.mobile&&this.mobile(),this.$newElement.on({"hide.bs.dropdown":function(e){i.$element.trigger("hide"+U,e)},"hidden.bs.dropdown":function(e){i.$element.trigger("hidden"+U,e)},"show.bs.dropdown":function(e){i.$element.trigger("show"+U,e)},"shown.bs.dropdown":function(e){i.$element.trigger("shown"+U,e)}}),i.$element[0].hasAttribute("required")&&this.$element.on("invalid"+U,function(){i.$button[0].classList.add("bs-invalid"),i.$element.on("shown"+U+".invalid",function(){i.$element.val(i.$element.val()).off("shown"+U+".invalid")}).on("rendered"+U,function(){this.validity.valid&&i.$button[0].classList.remove("bs-invalid"),i.$element.off("rendered"+U)}),i.$button.on("blur"+U,function(){i.$element.trigger("focus").trigger("blur"),i.$button.off("blur"+U)})}),setTimeout(function(){i.createLi(),i.$element.trigger("loaded"+U)})},createDropdown:function(){var e=this.multiple||this.options.showTick?" show-tick"
:"",t=this.multiple?' aria-multiselectable="true"':"",i="",s=this.autofocus?" autofocus":"";M.major<4&&this.$element.parent().hasClass("input-group")&&(i=" input-group-btn");var n,o="",r="",l="",a="";return this.options.header&&(o='<div class="'+j.POPOVERHEADER+'"><button type="button" class="close" aria-hidden="true">×</button>'+this.options.header+"</div>"),this.options.liveSearch&&(r='<div class="bs-searchbox"><input type="text" class="form-control" autocomplete="off"'+(null===this.options.liveSearchPlaceholder?"":' placeholder="'+E(this.options.liveSearchPlaceholder)+'"')+' role="combobox" aria-label="Search" aria-controls="'+this.selectId+'" aria-autocomplete="list"></div>'),this.multiple&&this.options.actionsBox&&(l='<div class="bs-actionsbox"><div class="btn-group btn-group-sm btn-block"><button type="button" class="actions-btn bs-select-all btn '+j.BUTTONCLASS+'">'+this.options.selectAllText+'</button><button type="button" class="actions-btn bs-deselect-all btn '+j.BUT
TONCLASS+'">'+this.options.deselectAllText+"</button></div></div>"),this.multiple&&this.options.doneButton&&(a='<div class="bs-donebutton"><div class="btn-group btn-block"><button type="button" class="btn btn-sm '+j.BUTTONCLASS+'">'+this.options.doneButtonText+"</button></div></div>"),n='<div class="dropdown bootstrap-select'+e+i+'"><button type="button" class="'+this.options.styleBase+' dropdown-toggle" '+("static"===this.options.display?'data-display="static"':"")+'data-toggle="dropdown"'+s+' role="combobox" aria-owns="'+this.selectId+'" aria-haspopup="listbox" aria-expanded="false"><div class="filter-option"><div class="filter-option-inner"><div class="filter-option-inner-inner"></div></div> </div>'+("4"===M.major?"":'<span class="bs-caret">'+this.options.template.caret+"</span>")+'</button><div class="'+j.MENU+" "+("4"===M.major?"":j.SHOW)+'">'+o+r+l+'<div class="inner '+j.SHOW+'" role="listbox" id="'+this.selectId+'" tabindex="-1" '+t+'><ul class="'+j.MENU+" inner "+("4"===M.ma
jor?j.SHOW:"")+'" role="presentation"></ul></div>'+a+"</div></div>",z(n)},setPositionData:function(){this.selectpicker.view.canHighlight=[];for(var e=this.selectpicker.view.size=0;e<this.selectpicker.current.data.length;e++){var t=this.selectpicker.current.data[e],i=!0;"divider"===t.type?(i=!1,t.height=this.sizeInfo.dividerHeight):"optgroup-label"===t.type?(i=!1,t.height=this.sizeInfo.dropdownHeaderHeight):t.height=this.sizeInfo.liHeight,t.disabled&&(i=!1),this.selectpicker.view.canHighlight.push(i),i&&(this.selectpicker.view.size++,t.posinset=this.selectpicker.view.size),t.position=(0===e?0:this.selectpicker.current.data[e-1].position)+t.height}},isVirtual:function(){return!1!==this.options.virtualScroll&&this.selectpicker.main.elements.length>=this.options.virtualScroll||!0===this.options.virtualScroll},createView:function(A,e,t){var L,N,D=this,i=0,H=[];if(this.selectpicker.current=A?this.selectpicker.search:this.selectpicker.main,this.setPositionData(),e)if(t)i=this.$menuInner[0]
.scrollTop;else if(!D.multiple){var s=D.$element[0],n=(s.options[s.selectedIndex]||{}).liIndex;if("number"==typeof n&&!1!==D.options.size){var o=D.selectpicker.main.data[n],r=o&&o.position;r&&(i=r-(D.sizeInfo.menuInnerHeight+D.sizeInfo.liHeight)/2)}}function l(e,t){var i,s,n,o,r,l,a,c,d,h,p=D.selectpicker.current.elements.length,u=[],f=!0,m=D.isVirtual();D.selectpicker.view.scrollTop=e,!0===m&&D.sizeInfo.hasScrollBar&&D.$menu[0].offsetWidth>D.sizeInfo.totalMenuWidth&&(D.sizeInfo.menuWidth=D.$menu[0].offsetWidth,D.sizeInfo.totalMenuWidth=D.sizeInfo.menuWidth+D.sizeInfo.scrollBarWidth,D.$menu.css("min-width",D.sizeInfo.menuWidth)),i=Math.ceil(D.sizeInfo.menuInnerHeight/D.sizeInfo.liHeight*1.5),s=Math.round(p/i)||1;for(var v=0;v<s;v++){var g=(v+1)*i;if(v===s-1&&(g=p),u[v]=[v*i+(v?1:0),g],!p)break;void 0===r&&e<=D.selectpicker.current.data[g-1].position-D.sizeInfo.menuInnerHeight&&(r=v)}if(void 0===r&&(r=0),l=[D.selectpicker.view.position0,D.selectpicker.view.position1],n=Math.max(0,r-1
),o=Math.min(s-1,r+1),D.selectpicker.view.position0=!1===m?0:Math.max(0,u[n][0])||0,D.selectpicker.view.position1=!1===m?p:Math.min(p,u[o][1])||0,a=l[0]!==D.selectpicker.view.position0||l[1]!==D.selectpicker.view.position1,void 0!==D.activeIndex&&(N=D.selectpicker.main.elements[D.prevActiveIndex],H=D.selectpicker.main.elements[D.activeIndex],L=D.selectpicker.main.elements[D.selectedIndex],t&&(D.activeIndex!==D.selectedIndex&&D.defocusItem(H),D.activeIndex=void 0),D.activeIndex&&D.activeIndex!==D.selectedIndex&&D.defocusItem(L)),void 0!==D.prevActiveIndex&&D.prevActiveIndex!==D.activeIndex&&D.prevActiveIndex!==D.selectedIndex&&D.defocusItem(N),(t||a)&&(c=D.selectpicker.view.visibleElements?D.selectpicker.view.visibleElements.slice():[],D.selectpicker.view.visibleElements=!1===m?D.selectpicker.current.elements:D.selectpicker.current.elements.slice(D.selectpicker.view.position0,D.selectpicker.view.position1),D.setOptionStatus(),(A||!1===m&&t)&&(d=c,h=D.selectpicker.view.visibleElements
,f=!(d.length===h.length&&d.every(function(e,t){return e===h[t]}))),(t||!0===m)&&f)){var b,w,I=D.$menuInner[0],x=document.createDocumentFragment(),k=I.firstChild.cloneNode(!1),$=D.selectpicker.view.visibleElements,y=[];I.replaceChild(k,I.firstChild);v=0;for(var S=$.length;v<S;v++){var E,C,O=$[v];D.options.sanitize&&(E=O.lastChild)&&(C=D.selectpicker.current.data[v+D.selectpicker.view.position0])&&C.content&&!C.sanitized&&(y.push(E),C.sanitized=!0),x.appendChild(O)}D.options.sanitize&&y.length&&P(y,D.options.whiteList,D.options.sanitizeFn),I.firstChild.style.marginBottom=!0===m?(b=0===D.selectpicker.view.position0?0:D.selectpicker.current.data[D.selectpicker.view.position0-1].position,w=D.selectpicker.view.position1>p-1?0:D.selectpicker.current.data[p-1].position-D.selectpicker.current.data[D.selectpicker.view.position1-1].position,I.firstChild.style.marginTop=b+"px",w+"px"):I.firstChild.style.marginTop=0,I.firstChild.appendChild(x)}if(D.prevActiveIndex=D.activeIndex,D.options.liveSe
arch){if(A&&t){var z,T=0;D.selectpicker.view.canHighlight[T]||(T=1+D.selectpicker.view.canHighlight.slice(1).indexOf(!0)),z=D.selectpicker.view.visibleElements[T],D.defocusItem(D.selectpicker.view.currentActive),D.activeIndex=(D.selectpicker.current.data[T]||{}).index,D.focusItem(z)}}else D.$menuInner.trigger("focus")}l(i,!0),this.$menuInner.off("scroll.createView").on("scroll.createView",function(e,t){D.noScroll||l(this.scrollTop,t),D.noScroll=!1}),z(window).off("resize"+U+"."+this.selectId+".createView").on("resize"+U+"."+this.selectId+".createView",function(){D.$newElement.hasClass(j.SHOW)&&l(D.$menuInner[0].scrollTop)})},focusItem:function(e,t,i){if(e){t=t||this.selectpicker.main.data[this.activeIndex];var s=e.firstChild;s&&(s.setAttribute("aria-setsize",this.selectpicker.view.size),s.setAttribute("aria-posinset",t.posinset),!0!==i&&(this.focusedParent.setAttribute("aria-activedescendant",s.id),e.classList.add("active"),s.classList.add("active")))}},defocusItem:function(e){e&&(e
.classList.remove("active"),e.firstChild&&e.firstChild.classList.remove("active"))},setPlaceholder:function(){var e=!1;if(this.options.title&&!this.multiple){this.selectpicker.view.titleOption||(this.selectpicker.view.titleOption=document.createElement("option")),e=!0;var t=this.$element[0],i=!1,s=!this.selectpicker.view.titleOption.parentNode;if(s)this.selectpicker.view.titleOption.className="bs-title-option",this.selectpicker.view.titleOption.value="",i=void 0===z(t.options[t.selectedIndex]).attr("selected")&&void 0===this.$element.data("selected");(s||0!==this.selectpicker.view.titleOption.index)&&t.insertBefore(this.selectpicker.view.titleOption,t.firstChild),i&&(t.selectedIndex=0)}return e},createLi:function(){var c=this,f=this.options.iconBase,m=':not([hidden]):not([data-hidden="true"])',v=[],g=[],d=0,b=0,e=this.setPlaceholder()?1:0;this.options.hideDisabled&&(m+=":not(:disabled)"),!c.options.showTick&&!c.multiple||F.checkMark.parentNode||(F.checkMark.className=f+" "+c.options
.tickIcon+" check-mark",F.a.appendChild(F.checkMark));var t=this.$element[0].querySelectorAll("select > *"+m);function w(e){var t=g[g.length-1];t&&"divider"===t.type&&(t.optID||e.optID)||((e=e||{}).type="divider",v.push(q(!1,j.DIVIDER,e.optID?e.optID+"div":void 0)),g.push(e))}function I(e,t){if((t=t||{}).divider="true"===e.getAttribute("data-divider"),t.divider)w({optID:t.optID});else{var i=g.length,s=e.style.cssText,n=s?E(s):"",o=(e.className||"")+(t.optgroupClass||"");t.optID&&(o="opt "+o),t.text=e.textContent,t.content=e.getAttribute("data-content"),t.tokens=e.getAttribute("data-tokens"),t.subtext=e.getAttribute("data-subtext"),t.icon=e.getAttribute("data-icon"),t.iconBase=f;var r=Y(t),l=q(K(r,o,n),"",t.optID);l.firstChild&&(l.firstChild.id=c.selectId+"-"+i),v.push(l),e.liIndex=i,t.display=t.content||t.text,t.type="option",t.index=i,t.option=e,t.disabled=t.disabled||e.disabled,g.push(t);var a=0;t.display&&(a+=t.display.length),t.subtext&&(a+=t.subtext.length),t.icon&&(a+=1),d<a&&
(d=a,c.selectpicker.view.widestOption=v[v.length-1])}}function i(e,t){var i=t[e],s=t[e-1],n=t[e+1],o=i.querySelectorAll("option"+m);if(o.length){var r,l,a={label:E(i.label),subtext:i.getAttribute("data-subtext"),icon:i.getAttribute("data-icon"),iconBase:f},c=" "+(i.className||"");b++,s&&w({optID:b});var d=Z(a);v.push(q(d,"dropdown-header"+c,b)),g.push({display:a.label,subtext:a.subtext,type:"optgroup-label",optID:b});for(var h=0,p=o.length;h<p;h++){var u=o[h];0===h&&(l=(r=g.length-1)+p),I(u,{headerIndex:r,lastIndex:l,optID:b,optgroupClass:c,disabled:i.disabled})}n&&w({optID:b})}}for(var s=t.length;e<s;e++){var n=t[e];"OPTGROUP"!==n.tagName?I(n,{}):i(e,t)}this.selectpicker.main.elements=v,this.selectpicker.main.data=g,this.selectpicker.current=this.selectpicker.main},findLis:function(){return this.$menuInner.find(".inner > li")},render:function(){this.setPlaceholder();var e,t,i=this,s=this.$element[0],n=function(e,t){var i,s=e.selectedOptions,n=[];if(t){for(var o=0,r=s.length;o<r;o++
)(i=s[o]).disabled||"OPTGROUP"===i.parentNode.tagName&&i.parentNode.disabled||n.push(i);return n}return s}(s,this.options.hideDisabled),o=n.length,r=this.$button[0],l=r.querySelector(".filter-option-inner-inner"),a=document.createTextNode(this.options.multipleSeparator),c=F.fragment.cloneNode(!1),d=!1;if(r.classList.toggle("bs-placeholder",i.multiple?!o:!O(s,n)),this.tabIndex(),"static"===this.options.selectedTextFormat)c=Y({text:this.options.title},!0);else if((e=this.multiple&&-1!==this.options.selectedTextFormat.indexOf("count")&&1<o)&&(e=1<(t=this.options.selectedTextFormat.split(">")).length&&o>t[1]||1===t.length&&2<=o),!1===e){for(var h=0;h<o&&h<50;h++){var p=n[h],u={},f={content:p.getAttribute("data-content"),subtext:p.getAttribute("data-subtext"),icon:p.getAttribute("data-icon")};this.multiple&&0<h&&c.appendChild(a.cloneNode(!1)),p.title?u.text=p.title:f.content&&i.options.showContent?(u.content=f.content.toString(),d=!0):(i.options.showIcon&&(u.icon=f.icon,u.iconBase=this.o
ptions.iconBase),i.options.showSubtext&&!i.multiple&&f.subtext&&(u.subtext=" "+f.subtext),u.text=p.textContent.trim()),c.appendChild(Y(u,!0))}49<o&&c.appendChild(document.createTextNode("..."))}else{var m=':not([hidden]):not([data-hidden="true"]):not([data-divider="true"])';this.options.hideDisabled&&(m+=":not(:disabled)");var v=this.$element[0].querySelectorAll("select > option"+m+", optgroup"+m+" option"+m).length,g="function"==typeof this.options.countSelectedText?this.options.countSelectedText(o,v):this.options.countSelectedText;c=Y({text:g.replace("{0}",o.toString()).replace("{1}",v.toString())},!0)}if(null==this.options.title&&(this.options.title=this.$element.attr("title")),c.childNodes.length||(c=Y({text:void 0!==this.options.title?this.options.title:this.options.noneSelectedText},!0)),r.title=c.textContent.replace(/<[^>]*>?/g,"").trim(),this.options.sanitize&&d&&P([c],i.options.whiteList,i.options.sanitizeFn),l.innerHTML="",l.appendChild(c),M.major<4&&this.$newElement[0].cl
assList.contains("bs3-has-addon")){var b=r.querySelector(".filter-expand"),w=l.cloneNode(!0);w.className="filter-expand",b?r.replaceChild(w,b):r.appendChild(w)}this.$element.trigger("rendered"+U)},setStyle:function(e,t){var i,s=this.$button[0],n=this.$newElement[0],o=this.options.style.trim();this.$element.attr("class")&&this.$newElement.addClass(this.$element.attr("class").replace(/selectpicker|mobile-device|bs-select-hidden|validate\[.*\]/gi,"")),M.major<4&&(n.classList.add("bs3"),n.parentNode.classList.contains("input-group")&&(n.previousElementSibling||n.nextElementSibling)&&(n.previousElementSibling||n.nextElementSibling).classList.contains("input-group-addon")&&n.classList.add("bs3-has-addon")),i=e?e.trim():o,"add"==t?i&&s.classList.add.apply(s.classList,i.split(" ")):"remove"==t?i&&s.classList.remove.apply(s.classList,i.split(" ")):(o&&s.classList.remove.apply(s.classList,o.split(" ")),i&&s.classList.add.apply(s.classList,i.split(" ")))},liHeight:function(e){if(e||!1!==this.o
ptions.size&&!this.sizeInfo){this.sizeInfo||(this.sizeInfo={});var t=document.createElement("div"),i=document.createElement("div"),s=document.createElement("div"),n=document.createElement("ul"),o=document.createElement("li"),r=document.createElement("li"),l=document.createElement("li"),a=document.createElement("a"),c=document.createElement("span"),d=this.options.header&&0<this.$menu.find("."+j.POPOVERHEADER).length?this.$menu.find("."+j.POPOVERHEADER)[0].cloneNode(!0):null,h=this.options.liveSearch?document.createElement("div"):null,p=this.options.actionsBox&&this.multiple&&0<this.$menu.find(".bs-actionsbox").length?this.$menu.find(".bs-actionsbox")[0].cloneNode(!0):null,u=this.options.doneButton&&this.multiple&&0<this.$menu.find(".bs-donebutton").length?this.$menu.find(".bs-donebutton")[0].cloneNode(!0):null,f=this.$element.find("option")[0];if(this.sizeInfo.selectWidth=this.$newElement[0].offsetWidth,c.className="text",a.className="dropdown-item "+(f?f.className:""),t.className=th
is.$menu[0].parentNode.className+" "+j.SHOW,t.style.width=this.sizeInfo.selectWidth+"px","auto"===this.options.width&&(i.style.minWidth=0),i.className=j.MENU+" "+j.SHOW,s.className="inner "+j.SHOW,n.className=j.MENU+" inner "+("4"===M.major?j.SHOW:""),o.className=j.DIVIDER,r.className="dropdown-header",c.appendChild(document.createTextNode("\u200b")),a.appendChild(c),l.appendChild(a),r.appendChild(c.cloneNode(!0)),this.selectpicker.view.widestOption&&n.appendChild(this.selectpicker.view.widestOption.cloneNode(!0)),n.appendChild(l),n.appendChild(o),n.appendChild(r),d&&i.appendChild(d),h){var m=document.createElement("input");h.className="bs-searchbox",m.className="form-control",h.appendChild(m),i.appendChild(h)}p&&i.appendChild(p),s.appendChild(n),i.appendChild(s),u&&i.appendChild(u),t.appendChild(i),document.body.appendChild(t);var v,g=l.offsetHeight,b=r?r.offsetHeight:0,w=d?d.offsetHeight:0,I=h?h.offsetHeight:0,x=p?p.offsetHeight:0,k=u?u.offsetHeight:0,$=z(o).outerHeight(!0),y=!!wi
ndow.getComputedStyle&&window.getComputedStyle(i),S=i.offsetWidth,E=y?null:z(i),C={vert:A(y?y.paddingTop:E.css("paddingTop"))+A(y?y.paddingBottom:E.css("paddingBottom"))+A(y?y.borderTopWidth:E.css("borderTopWidth"))+A(y?y.borderBottomWidth:E.css("borderBottomWidth")),horiz:A(y?y.paddingLeft:E.css("paddingLeft"))+A(y?y.paddingRight:E.css("paddingRight"))+A(y?y.borderLeftWidth:E.css("borderLeftWidth"))+A(y?y.borderRightWidth:E.css("borderRightWidth"))},O={vert:C.vert+A(y?y.marginTop:E.css("marginTop"))+A(y?y.marginBottom:E.css("marginBottom"))+2,horiz:C.horiz+A(y?y.marginLeft:E.css("marginLeft"))+A(y?y.marginRight:E.css("marginRight"))+2};s.style.overflowY="scroll",v=i.offsetWidth-S,document.body.removeChild(t),this.sizeInfo.liHeight=g,this.sizeInfo.dropdownHeaderHeight=b,this.sizeInfo.headerHeight=w,this.sizeInfo.searchHeight=I,this.sizeInfo.actionsHeight=x,this.sizeInfo.doneButtonHeight=k,this.sizeInfo.dividerHeight=$,this.sizeInfo.menuPadding=C,this.sizeInfo.menuExtras=O,this.sizeI
nfo.menuWidth=S,this.sizeInfo.totalMenuWidth=this.sizeInfo.menuWidth,this.sizeInfo.scrollBarWidth=v,this.sizeInfo.selectHeight=this.$newElement[0].offsetHeight,this.setPositionData()}},getSelectPosition:function(){var e,t=z(window),i=this.$newElement.offset(),s=z(this.options.container);this.options.container&&s.length&&!s.is("body")?((e=s.offset()).top+=parseInt(s.css("borderTopWidth")),e.left+=parseInt(s.css("borderLeftWidth"))):e={top:0,left:0};var n=this.options.windowPadding;this.sizeInfo.selectOffsetTop=i.top-e.top-t.scrollTop(),this.sizeInfo.selectOffsetBot=t.height()-this.sizeInfo.selectOffsetTop-this.sizeInfo.selectHeight-e.top-n[2],this.sizeInfo.selectOffsetLeft=i.left-e.left-t.scrollLeft(),this.sizeInfo.selectOffsetRight=t.width()-this.sizeInfo.selectOffsetLeft-this.sizeInfo.selectWidth-e.left-n[1],this.sizeInfo.selectOffsetTop-=n[0],this.sizeInfo.selectOffsetLeft-=n[3]},setMenuSize:function(e){this.getSelectPosition();var t,i,s,n,o,r,l,a=this.sizeInfo.selectWidth,c=this.
sizeInfo.liHeight,d=this.sizeInfo.headerHeight,h=this.sizeInfo.searchHeight,p=this.sizeInfo.actionsHeight,u=this.sizeInfo.doneButtonHeight,f=this.sizeInfo.dividerHeight,m=this.sizeInfo.menuPadding,v=0;if(this.options.dropupAuto&&(l=c*this.selectpicker.current.elements.length+m.vert,this.$newElement.toggleClass(j.DROPUP,this.sizeInfo.selectOffsetTop-this.sizeInfo.selectOffsetBot>this.sizeInfo.menuExtras.vert&&l+this.sizeInfo.menuExtras.vert+50>this.sizeInfo.selectOffsetBot)),"auto"===this.options.size)n=3<this.selectpicker.current.elements.length?3*this.sizeInfo.liHeight+this.sizeInfo.menuExtras.vert-2:0,i=this.sizeInfo.selectOffsetBot-this.sizeInfo.menuExtras.vert,s=n+d+h+p+u,r=Math.max(n-m.vert,0),this.$newElement.hasClass(j.DROPUP)&&(i=this.sizeInfo.selectOffsetTop-this.sizeInfo.menuExtras.vert),t=(o=i)-d-h-p-u-m.vert;else if(this.options.size&&"auto"!=this.options.size&&this.selectpicker.current.elements.length>this.options.size){for(var g=0;g<this.options.size;g++)"divider"===th
is.selectpicker.current.data[g].type&&v++;t=(i=c*this.options.size+v*f+m.vert)-m.vert,o=i+d+h+p+u,s=r=""}"auto"===this.options.dropdownAlignRight&&this.$menu.toggleClass(j.MENURIGHT,this.sizeInfo.selectOffsetLeft>this.sizeInfo.selectOffsetRight&&this.sizeInfo.selectOffsetRight<this.sizeInfo.totalMenuWidth-a),this.$menu.css({"max-height":o+"px",overflow:"hidden","min-height":s+"px"}),this.$menuInner.css({"max-height":t+"px","overflow-y":"auto","min-height":r+"px"}),this.sizeInfo.menuInnerHeight=Math.max(t,1),this.selectpicker.current.data.length&&this.selectpicker.current.data[this.selectpicker.current.data.length-1].position>this.sizeInfo.menuInnerHeight&&(this.sizeInfo.hasScrollBar=!0,this.sizeInfo.totalMenuWidth=this.sizeInfo.menuWidth+this.sizeInfo.scrollBarWidth,this.$menu.css("min-width",this.sizeInfo.totalMenuWidth)),this.dropdown&&this.dropdown._popper&&this.dropdown._popper.update()},setSize:function(e){if(this.liHeight(e),this.options.header&&this.$menu.css("padding-top",0)
,!1!==this.options.size){var t=this,i=z(window);this.setMenuSize(),this.options.liveSearch&&this.$searchbox.off("input.setMenuSize propertychange.setMenuSize").on("input.setMenuSize propertychange.setMenuSize",function(){return t.setMenuSize()}),"auto"===this.options.size?i.off("resize"+U+"."+this.selectId+".setMenuSize scroll"+U+"."+this.selectId+".setMenuSize").on("resize"+U+"."+this.selectId+".setMenuSize scroll"+U+"."+this.selectId+".setMenuSize",function(){return t.setMenuSize()}):this.options.size&&"auto"!=this.options.size&&this.selectpicker.current.elements.length>this.options.size&&i.off("resize"+U+"."+this.selectId+".setMenuSize scroll"+U+"."+this.selectId+".setMenuSize"),t.createView(!1,!0,e)}},setWidth:function(){var i=this;"auto"===this.options.width?requestAnimationFrame(function(){i.$menu.css("min-width","0"),i.$element.on("loaded"+U,function(){i.liHeight(),i.setMenuSize();var e=i.$newElement.clone().appendTo("body"),t=e.css("width","auto").children("button").outerWid
th();e.remove(),i.sizeInfo.selectWidth=Math.max(i.sizeInfo.totalMenuWidth,t),i.$newElement.css("width",i.sizeInfo.selectWidth+"px")})}):"fit"===this.options.width?(this.$menu.css("min-width",""),this.$newElement.css("width","").addClass("fit-width")):this.options.width?(this.$menu.css("min-width",""),this.$newElement.css("width",this.options.width)):(this.$menu.css("min-width",""),this.$newElement.css("width","")),this.$newElement.hasClass("fit-width")&&"fit"!==this.options.width&&this.$newElement[0].classList.remove("fit-width")},selectPosition:function(){this.$bsContainer=z('<div class="bs-container" />');var s,n,o,r=this,l=z(this.options.container),e=function(e){var t={},i=r.options.display||!!z.fn.dropdown.Constructor.Default&&z.fn.dropdown.Constructor.Default.display;r.$bsContainer.addClass(e.attr("class").replace(/form-control|fit-width/gi,"")).toggleClass(j.DROPUP,e.hasClass(j.DROPUP)),s=e.offset(),l.is("body")?n={top:0,left:0}:((n=l.offset()).top+=parseInt(l.css("borderTopWi
dth"))-l.scrollTop(),n.left+=parseInt(l.css("borderLeftWidth"))-l.scrollLeft()),o=e.hasClass(j.DROPUP)?0:e[0].offsetHeight,(M.major<4||"static"===i)&&(t.top=s.top-n.top+o,t.left=s.left-n.left),t.width=e[0].offsetWidth,r.$bsContainer.css(t)};this.$button.on("click.bs.dropdown.data-api",function(){r.isDisabled()||(e(r.$newElement),r.$bsContainer.appendTo(r.options.container).toggleClass(j.SHOW,!r.$button.hasClass(j.SHOW)).append(r.$menu))}),z(window).off("resize"+U+"."+this.selectId+" scroll"+U+"."+this.selectId).on("resize"+U+"."+this.selectId+" scroll"+U+"."+this.selectId,function(){r.$newElement.hasClass(j.SHOW)&&e(r.$newElement)}),this.$element.on("hide"+U,function(){r.$menu.data("height",r.$menu.height()),r.$bsContainer.detach()})},setOptionStatus:function(e){var t=this;if(t.noScroll=!1,t.selectpicker.view.visibleElements&&t.selectpicker.view.visibleElements.length)for(var i=0;i<t.selectpicker.view.visibleElements.length;i++){var s=t.selectpicker.current.data[i+t.selectpicker.vie
w.position0],n=s.option;n&&(!0!==e&&t.setDisabled(s.index,s.disabled),t.setSelected(s.index,n.selected))}},setSelected:function(e,t){var i,s,n=this.selectpicker.main.elements[e],o=this.selectpicker.main.data[e],r=void 0!==this.activeIndex,l=this.activeIndex===e||t&&!this.multiple&&!r;o.selected=t,s=n.firstChild,t&&(this.selectedIndex=e),n.classList.toggle("selected",t),l?(this.focusItem(n,o),this.selectpicker.view.currentActive=n,this.activeIndex=e):this.defocusItem(n),s&&(s.classList.toggle("selected",t),t?s.setAttribute("aria-selected",!0):this.multiple?s.setAttribute("aria-selected",!1):s.removeAttribute("aria-selected")),l||r||!t||void 0===this.prevActiveIndex||(i=this.selectpicker.main.elements[this.prevActiveIndex],this.defocusItem(i))},setDisabled:function(e,t){var i,s=this.selectpicker.main.elements[e];this.selectpicker.main.data[e].disabled=t,i=s.firstChild,s.classList.toggle(j.DISABLED,t),i&&("4"===M.major&&i.classList.toggle(j.DISABLED,t),t?(i.setAttribute("aria-disabled"
,t),i.setAttribute("tabindex",-1)):(i.removeAttribute("aria-disabled"),i.setAttribute("tabindex",0)))},isDisabled:function(){return this.$element[0].disabled},checkDisabled:function(){var e=this;this.isDisabled()?(this.$newElement[0].classList.add(j.DISABLED),this.$button.addClass(j.DISABLED).attr("tabindex",-1).attr("aria-disabled",!0)):(this.$button[0].classList.contains(j.DISABLED)&&(this.$newElement[0].classList.remove(j.DISABLED),this.$button.removeClass(j.DISABLED).attr("aria-disabled",!1)),-1!=this.$button.attr("tabindex")||this.$element.data("tabindex")||this.$button.removeAttr("tabindex")),this.$button.on("click",function(){return!e.isDisabled()})},tabIndex:function(){this.$element.data("tabindex")!==this.$element.attr("tabindex")&&-98!==this.$element.attr("tabindex")&&"-98"!==this.$element.attr("tabindex")&&(this.$element.data("tabindex",this.$element.attr("tabindex")),this.$button.attr("tabindex",this.$element.data("tabindex"))),this.$element.attr("tabindex",-98)},clickLi
stener:function(){var C=this,t=z(document);function e(){C.options.liveSearch?C.$searchbox.trigger("focus"):C.$menuInner.trigger("focus")}function i(){C.dropdown&&C.dropdown._popper&&C.dropdown._popper.state.isCreated?e():requestAnimationFrame(i)}t.data("spaceSelect",!1),this.$button.on("keyup",function(e){/(32)/.test(e.keyCode.toString(10))&&t.data("spaceSelect")&&(e.preventDefault(),t.data("spaceSelect",!1))}),this.$newElement.on("show.bs.dropdown",function(){3<M.major&&!C.dropdown&&(C.dropdown=C.$button.data("bs.dropdown"),C.dropdown._menu=C.$menu[0])}),this.$button.on("click.bs.dropdown.data-api",function(){C.$newElement.hasClass(j.SHOW)||C.setSize()}),this.$element.on("shown"+U,function(){C.$menuInner[0].scrollTop!==C.selectpicker.view.scrollTop&&(C.$menuInner[0].scrollTop=C.selectpicker.view.scrollTop),3<M.major?requestAnimationFrame(i):e()}),this.$menuInner.on("mouseenter","li a",function(e){var t=this.parentElement,i=C.isVirtual()?C.selectpicker.view.position0:0,s=Array.proto
type.indexOf.call(t.parentElement.children,t),n=C.selectpicker.current.data[s+i];C.focusItem(t,n,!0)}),this.$menuInner.on("click","li a",function(e,t){var i=z(this),s=C.$element[0],n=C.isVirtual()?C.selectpicker.view.position0:0,o=C.selectpicker.current.data[i.parent().index()+n],r=o.index,l=O(s),a=s.selectedIndex,c=s.options[a],d=!0;if(C.multiple&&1!==C.options.maxOptions&&e.stopPropagation(),e.preventDefault(),!C.isDisabled()&&!i.parent().hasClass(j.DISABLED)){var h=C.$element.find("option"),p=o.option,u=z(p),f=p.selected,m=u.parent("optgroup"),v=m.find("option"),g=C.options.maxOptions,b=m.data("maxOptions")||!1;if(r===C.activeIndex&&(t=!0),t||(C.prevActiveIndex=C.activeIndex,C.activeIndex=void 0),C.multiple){if(p.selected=!f,C.setSelected(r,!f),i.trigger("blur"),!1!==g||!1!==b){var w=g<h.filter(":selected").length,I=b<m.find("option:selected").length;if(g&&w||b&&I)if(g&&1==g){h.prop("selected",!1),u.prop("selected",!0);for(var x=0;x<h.length;x++)C.setSelected(x,!1);C.setSelected(
r,!0)}else if(b&&1==b){m.find("option:selected").prop("selected",!1),u.prop("selected",!0);for(x=0;x<v.length;x++){p=v[x];C.setSelected(h.index(p),!1)}C.setSelected(r,!0)}else{var k="string"==typeof C.options.maxOptionsText?[C.options.maxOptionsText,C.options.maxOptionsText]:C.options.maxOptionsText,$="function"==typeof k?k(g,b):k,y=$[0].replace("{n}",g),S=$[1].replace("{n}",b),E=z('<div class="notify"></div>');$[2]&&(y=y.replace("{var}",$[2][1<g?0:1]),S=S.replace("{var}",$[2][1<b?0:1])),u.prop("selected",!1),C.$menu.append(E),g&&w&&(E.append(z("<div>"+y+"</div>")),d=!1,C.$element.trigger("maxReached"+U)),b&&I&&(E.append(z("<div>"+S+"</div>")),d=!1,C.$element.trigger("maxReachedGrp"+U)),setTimeout(function(){C.setSelected(r,!1)},10),E.delay(750).fadeOut(300,function(){z(this).remove()})}}}else c.selected=!1,p.selected=!0,C.setSelected(r,!0);!C.multiple||C.multiple&&1===C.options.maxOptions?C.$button.trigger("focus"):C.options.liveSearch&&C.$searchbox.trigger("focus"),d&&(C.multiple|
|a!==s.selectedIndex)&&(T=[p.index,u.prop("selected"),l],C.$element.triggerNative("change"))}}),this.$menu.on("click","li."+j.DISABLED+" a, ."+j.POPOVERHEADER+", ."+j.POPOVERHEADER+" :not(.close)",function(e){e.currentTarget==this&&(e.preventDefault(),e.stopPropagation(),C.options.liveSearch&&!z(e.target).hasClass("close")?C.$searchbox.trigger("focus"):C.$button.trigger("focus"))}),this.$menuInner.on("click",".divider, .dropdown-header",function(e){e.preventDefault(),e.stopPropagation(),C.options.liveSearch?C.$searchbox.trigger("focus"):C.$button.trigger("focus")}),this.$menu.on("click","."+j.POPOVERHEADER+" .close",function(){C.$button.trigger("click")}),this.$searchbox.on("click",function(e){e.stopPropagation()}),this.$menu.on("click",".actions-btn",function(e){C.options.liveSearch?C.$searchbox.trigger("focus"):C.$button.trigger("focus"),e.preventDefault(),e.stopPropagation(),z(this).hasClass("bs-select-all")?C.selectAll():C.deselectAll()}),this.$element.on("change"+U,function(){C
.render(),C.$element.trigger("changed"+U,T),T=null}).on("focus"+U,function(){C.options.mobile||C.$button.trigger("focus")})},liveSearchListener:function(){var u=this,f=document.createElement("li");this.$button.on("click.bs.dropdown.data-api",function(){u.$searchbox.val()&&u.$searchbox.val("")}),this.$searchbox.on("click.bs.dropdown.data-api focus.bs.dropdown.data-api touchend.bs.dropdown.data-api",function(e){e.stopPropagation()}),this.$searchbox.on("input propertychange",function(){var e=u.$searchbox.val();if(u.selectpicker.search.elements=[],u.selectpicker.search.data=[],e){var t=[],i=e.toUpperCase(),s={},n=[],o=u._searchStyle(),r=u.options.liveSearchNormalize;r&&(i=w(i)),u._$lisSelected=u.$menuInner.find(".selected");for(var l=0;l<u.selectpicker.main.data.length;l++){var a=u.selectpicker.main.data[l];s[l]||(s[l]=k(a,i,o,r)),s[l]&&void 0!==a.headerIndex&&-1===n.indexOf(a.headerIndex)&&(0<a.headerIndex&&(s[a.headerIndex-1]=!0,n.push(a.headerIndex-1)),s[a.headerIndex]=!0,n.push(a.he
aderIndex),s[a.lastIndex+1]=!0),s[l]&&"optgroup-label"!==a.type&&n.push(l)}l=0;for(var c=n.length;l<c;l++){var d=n[l],h=n[l-1],p=(a=u.selectpicker.main.data[d],u.selectpicker.main.data[h]);("divider"!==a.type||"divider"===a.type&&p&&"divider"!==p.type&&c-1!==l)&&(u.selectpicker.search.data.push(a),t.push(u.selectpicker.main.elements[d]))}u.activeIndex=void 0,u.noScroll=!0,u.$menuInner.scrollTop(0),u.selectpicker.search.elements=t,u.createView(!0),t.length||(f.className="no-results",f.innerHTML=u.options.noneResultsText.replace("{0}",'"'+E(e)+'"'),u.$menuInner[0].firstChild.appendChild(f))}else u.$menuInner.scrollTop(0),u.createView(!1)})},_searchStyle:function(){return this.options.liveSearchStyle||"contains"},val:function(e){var t=this.$element[0];if(void 0===e)return this.$element.val();var i=O(t);if(T=[null,null,i],this.$element.val(e).trigger("changed"+U,T),this.$newElement.hasClass(j.SHOW))if(this.multiple)this.setOptionStatus(!0);else{var s=(t.options[t.selectedIndex]||{}).liI
ndex;"number"==typeof s&&(this.setSelected(this.selectedIndex,!1),this.setSelected(s,!0))}return this.render(),T=null,this.$element},changeAll:function(e){if(this.multiple){void 0===e&&(e=!0);var t=this.$element[0],i=0,s=0,n=O(t);t.classList.add("bs-select-hidden");for(var o=0,r=this.selectpicker.current.elements.length;o<r;o++){var l=this.selectpicker.current.data[o],a=l.option;a&&!l.disabled&&"divider"!==l.type&&(l.selected&&i++,(a.selected=e)&&s++)}t.classList.remove("bs-select-hidden"),i!==s&&(this.setOptionStatus(),T=[null,null,n],this.$element.triggerNative("change"))}},selectAll:function(){return this.changeAll(!0)},deselectAll:function(){return this.changeAll(!1)},toggle:function(e){(e=e||window.event)&&e.stopPropagation(),this.$button.trigger("click.bs.dropdown.data-api")},keydown:function(e){var t,i,s,n,o,r=z(this),l=r.hasClass("dropdown-toggle"),a=(l?r.closest(".dropdown"):r.closest(V.MENU)).data("this"),c=a.findLis(),d=!1,h=e.which===H&&!l&&!a.options.selectOnTab,p=_.tes
t(e.which)||h,u=a.$menuInner[0].scrollTop,f=!0===a.isVirtual()?a.selectpicker.view.position0:0;if(!(i=a.$newElement.hasClass(j.SHOW))&&(p||48<=e.which&&e.which<=57||96<=e.which&&e.which<=105||65<=e.which&&e.which<=90)&&(a.$button.trigger("click.bs.dropdown.data-api"),a.options.liveSearch))a.$searchbox.trigger("focus");else{if(e.which===L&&i&&(e.preventDefault(),a.$button.trigger("click.bs.dropdown.data-api").trigger("focus")),p){if(!c.length)return;-1!==(t=(s=a.selectpicker.main.elements[a.activeIndex])?Array.prototype.indexOf.call(s.parentElement.children,s):-1)&&a.defocusItem(s),e.which===B?(-1!==t&&t--,t+f<0&&(t+=c.length),a.selectpicker.view.canHighlight[t+f]||-1===(t=a.selectpicker.view.canHighlight.slice(0,t+f).lastIndexOf(!0)-f)&&(t=c.length-1)):(e.which===W||h)&&(++t+f>=a.selectpicker.view.canHighlight.length&&(t=0),a.selectpicker.view.canHighlight[t+f]||(t=t+1+a.selectpicker.view.canHighlight.slice(t+f+1).indexOf(!0))),e.preventDefault();var m=f+t;e.which===B?0===f&&t===c.l
ength-1?(a.$menuInner[0].scrollTop=a.$menuInner[0].scrollHeight,m=a.selectpicker.current.elements.length-1):d=(o=(n=a.selectpicker.current.data[m]).position-n.height)<u:(e.which===W||h)&&(0===t?m=a.$menuInner[0].scrollTop=0:d=u<(o=(n=a.selectpicker.current.data[m]).position-a.sizeInfo.menuInnerHeight)),s=a.selectpicker.current.elements[m],a.activeIndex=a.selectpicker.current.data[m].index,a.focusItem(s),a.selectpicker.view.currentActive=s,d&&(a.$menuInner[0].scrollTop=o),a.options.liveSearch?a.$searchbox.trigger("focus"):r.trigger("focus")}else if(!r.is("input")&&!G.test(e.which)||e.which===D&&a.selectpicker.keydown.keyHistory){var v,g,b=[];e.preventDefault(),a.selectpicker.keydown.keyHistory+=C[e.which],a.selectpicker.keydown.resetKeyHistory.cancel&&clearTimeout(a.selectpicker.keydown.resetKeyHistory.cancel),a.selectpicker.keydown.resetKeyHistory.cancel=a.selectpicker.keydown.resetKeyHistory.start(),g=a.selectpicker.keydown.keyHistory,/^(.)\1+$/.test(g)&&(g=g.charAt(0));for(var w=0
;w<a.selectpicker.current.data.length;w++){var I=a.selectpicker.current.data[w];k(I,g,"startsWith",!0)&&a.selectpicker.view.canHighlight[w]&&b.push(I.index)}if(b.length){var x=0;c.removeClass("active").find("a").removeClass("active"),1===g.length&&(-1===(x=b.indexOf(a.activeIndex))||x===b.length-1?x=0:x++),v=b[x],d=0<u-(n=a.selectpicker.main.data[v]).position?(o=n.position-n.height,!0):(o=n.position-a.sizeInfo.menuInnerHeight,n.position>u+a.sizeInfo.menuInnerHeight),s=a.selectpicker.main.elements[v],a.activeIndex=b[x],a.focusItem(s),s&&s.firstChild.focus(),d&&(a.$menuInner[0].scrollTop=o),r.trigger("focus")}}i&&(e.which===D&&!a.selectpicker.keydown.keyHistory||e.which===N||e.which===H&&a.options.selectOnTab)&&(e.which!==D&&e.preventDefault(),a.options.liveSearch&&e.which===D||(a.$menuInner.find(".active a").trigger("click",!0),r.trigger("focus"),a.options.liveSearch||(e.preventDefault(),z(document).data("spaceSelect",!0))))}},mobile:function(){this.$element[0].classList.add("mobile-
device")},refresh:function(){var e=z.extend({},this.options,this.$element.data());this.options=e,this.checkDisabled(),this.setStyle(),this.render(),this.createLi(),this.setWidth(),this.setSize(!0),this.$element.trigger("refreshed"+U)},hide:function(){this.$newElement.hide()},show:function(){this.$newElement.show()},remove:function(){this.$newElement.remove(),this.$element.remove()},destroy:function(){this.$newElement.before(this.$element).remove(),this.$bsContainer?this.$bsContainer.remove():this.$menu.remove(),this.$element.off(U).removeData("selectpicker").removeClass("bs-select-hidden selectpicker"),z(window).off(U+"."+this.selectId)}};var X=z.fn.selectpicker;z.fn.selectpicker=Q,z.fn.selectpicker.Constructor=J,z.fn.selectpicker.noConflict=function(){return z.fn.selectpicker=X,this},z(document).off("keydown.bs.dropdown.data-api").on("keydown"+U,'.bootstrap-select [data-toggle="dropdown"], .bootstrap-select [role="listbox"], .bootstrap-select .bs-searchbox input',J.prototype.keydow
n).on("focusin.modal",'.bootstrap-select [data-toggle="dropdown"], .bootstrap-select [role="listbox"], .bootstrap-select .bs-searchbox input',function(e){e.stopPropagation()}),z(window).on("load"+U+".data-api",function(){z(".selectpicker").each(function(){var e=z(this);Q.call(e,e.data())})})}(e)});
+!function(e,t){void 0===e&&void 0!==window&&(e=window),"function"==typeof define&&define.amd?define(["jquery"],function(e){return t(e)}):"object"==typeof module&&module.exports?module.exports=t(require("jquery")):t(e.jQuery)}(this,function(e){!function(P){"use strict";var d=["sanitize","whiteList","sanitizeFn"],r=["background","cite","href","itemtype","longdesc","poster","src","xlink:href"],e={"*":["class","dir","id","lang","role","tabindex","style",/^aria-[\w-]*$/i],a:["target","href","title","rel"],area:[],b:[],br:[],col:[],code:[],div:[],em:[],hr:[],h1:[],h2:[],h3:[],h4:[],h5:[],h6:[],i:[],img:["src","alt","title","width","height"],li:[],ol:[],p:[],pre:[],s:[],small:[],span:[],sub:[],sup:[],strong:[],u:[],ul:[]},l=/^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi,a=/^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i;function v(e,t){var i=e.nodeName.toLowerCase();if(-1!==P.inArray(i,t))re
turn-1===P.inArray(i,r)||Boolean(e.nodeValue.match(l)||e.nodeValue.match(a));for(var s=P(t).filter(function(e,t){return t instanceof RegExp}),n=0,o=s.length;n<o;n++)if(i.match(s[n]))return!0;return!1}function W(e,t,i){if(i&&"function"==typeof i)return i(e);for(var s=Object.keys(t),n=0,o=e.length;n<o;n++)for(var r=e[n].querySelectorAll("*"),l=0,a=r.length;l<a;l++){var c=r[l],d=c.nodeName.toLowerCase();if(-1!==s.indexOf(d))for(var h=[].slice.call(c.attributes),p=[].concat(t["*"]||[],t[d]||[]),u=0,f=h.length;u<f;u++){var m=h[u];v(m,p)||c.removeAttribute(m.nodeName)}else c.parentNode.removeChild(c)}}"classList"in document.createElement("_")||function(e){if("Element"in e){var t="classList",i="prototype",s=e.Element[i],n=Object,o=function(){var i=P(this);return{add:function(e){return e=Array.prototype.slice.call(arguments).join(" "),i.addClass(e)},remove:function(e){return e=Array.prototype.slice.call(arguments).join(" "),i.removeClass(e)},toggle:function(e,t){return i.toggleClass(e,t)},c
ontains:function(e){return i.hasClass(e)}}};if(n.defineProperty){var r={get:o,enumerable:!0,configurable:!0};try{n.defineProperty(s,t,r)}catch(e){void 0!==e.number&&-2146823252!==e.number||(r.enumerable=!1,n.defineProperty(s,t,r))}}else n[i].__defineGetter__&&s.__defineGetter__(t,o)}}(window);var t,c,i=document.createElement("_");if(i.classList.add("c1","c2"),!i.classList.contains("c2")){var s=DOMTokenList.prototype.add,n=DOMTokenList.prototype.remove;DOMTokenList.prototype.add=function(){Array.prototype.forEach.call(arguments,s.bind(this))},DOMTokenList.prototype.remove=function(){Array.prototype.forEach.call(arguments,n.bind(this))}}if(i.classList.toggle("c3",!1),i.classList.contains("c3")){var o=DOMTokenList.prototype.toggle;DOMTokenList.prototype.toggle=function(e,t){return 1 in arguments&&!this.contains(e)==!t?t:o.call(this,e)}}function h(e){if(null==this)throw new TypeError;var t=String(this);if(e&&"[object RegExp]"==c.call(e))throw new TypeError;var i=t.length,s=String(e),n=s
.length,o=1<arguments.length?arguments[1]:void 0,r=o?Number(o):0;r!=r&&(r=0);var l=Math.min(Math.max(r,0),i);if(i<n+l)return!1;for(var a=-1;++a<n;)if(t.charCodeAt(l+a)!=s.charCodeAt(a))return!1;return!0}function O(e,t){var i,s=e.selectedOptions,n=[];if(t){for(var o=0,r=s.length;o<r;o++)(i=s[o]).disabled||"OPTGROUP"===i.parentNode.tagName&&i.parentNode.disabled||n.push(i);return n}return s}function z(e,t){for(var i,s=[],n=t||e.selectedOptions,o=0,r=n.length;o<r;o++)(i=n[o]).disabled||"OPTGROUP"===i.parentNode.tagName&&i.parentNode.disabled||s.push(i.value);return e.multiple?s:s.length?s[0]:null}i=null,String.prototype.startsWith||(t=function(){try{var e={},t=Object.defineProperty,i=t(e,e,e)&&t}catch(e){}return i}(),c={}.toString,t?t(String.prototype,"startsWith",{value:h,configurable:!0,writable:!0}):String.prototype.startsWith=h),Object.keys||(Object.keys=function(e,t,i){for(t in i=[],e)i.hasOwnProperty.call(e,t)&&i.push(t);return i}),HTMLSelectElement&&!HTMLSelectElement.prototype.
hasOwnProperty("selectedOptions")&&Object.defineProperty(HTMLSelectElement.prototype,"selectedOptions",{get:function(){return this.querySelectorAll(":checked")}});var p={useDefault:!1,_set:P.valHooks.select.set};P.valHooks.select.set=function(e,t){return t&&!p.useDefault&&P(e).data("selected",!0),p._set.apply(this,arguments)};var T=null,u=function(){try{return new Event("change"),!0}catch(e){return!1}}();function k(e,t,i,s){for(var n=["display","subtext","tokens"],o=!1,r=0;r<n.length;r++){var l=n[r],a=e[l];if(a&&(a=a.toString(),"display"===l&&(a=a.replace(/<[^>]+>/g,"")),s&&(a=w(a)),a=a.toUpperCase(),o="contains"===i?0<=a.indexOf(t):a.startsWith(t)))break}return o}function N(e){return parseInt(e,10)||0}P.fn.triggerNative=function(e){var t,i=this[0];i.dispatchEvent?(u?t=new Event(e,{bubbles:!0}):(t=document.createEvent("Event")).initEvent(e,!0,!1),i.dispatchEvent(t)):i.fireEvent?((t=document.createEventObject()).eventType=e,i.fireEvent("on"+e,t)):this.trigger(e)};var f={"\xc0":"A","\
xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss","\u0100":"A","\u0102":"A","\u0104":"A","\u0101":"a","\u0103":"a","\u0105":"a","\u0106":"C","\u0108":"C","\u010a":"C","\u010c":"C","\u0107":"c","\u0109":"c","\u010b":"c","\u010d":"c","\u010e":"D","\u0110":"D","\u010f":"d","\u0111":"d","\u0112":"E","\u0114":"E","\u0116":"E","\u0118":"E","\u011a":"E","\u0113":"e","\u0115":"e
","\u0117":"e","\u0119":"e","\u011b":"e","\u011c":"G","\u011e":"G","\u0120":"G","\u0122":"G","\u011d":"g","\u011f":"g","\u0121":"g","\u0123":"g","\u0124":"H","\u0126":"H","\u0125":"h","\u0127":"h","\u0128":"I","\u012a":"I","\u012c":"I","\u012e":"I","\u0130":"I","\u0129":"i","\u012b":"i","\u012d":"i","\u012f":"i","\u0131":"i","\u0134":"J","\u0135":"j","\u0136":"K","\u0137":"k","\u0138":"k","\u0139":"L","\u013b":"L","\u013d":"L","\u013f":"L","\u0141":"L","\u013a":"l","\u013c":"l","\u013e":"l","\u0140":"l","\u0142":"l","\u0143":"N","\u0145":"N","\u0147":"N","\u014a":"N","\u0144":"n","\u0146":"n","\u0148":"n","\u014b":"n","\u014c":"O","\u014e":"O","\u0150":"O","\u014d":"o","\u014f":"o","\u0151":"o","\u0154":"R","\u0156":"R","\u0158":"R","\u0155":"r","\u0157":"r","\u0159":"r","\u015a":"S","\u015c":"S","\u015e":"S","\u0160":"S","\u015b":"s","\u015d":"s","\u015f":"s","\u0161":"s","\u0162":"T","\u0164":"T","\u0166":"T","\u0163":"t","\u0165":"t","\u0167":"t","\u0168":"U","\u016a":"U","\u016c
":"U","\u016e":"U","\u0170":"U","\u0172":"U","\u0169":"u","\u016b":"u","\u016d":"u","\u016f":"u","\u0171":"u","\u0173":"u","\u0174":"W","\u0175":"w","\u0176":"Y","\u0177":"y","\u0178":"Y","\u0179":"Z","\u017b":"Z","\u017d":"Z","\u017a":"z","\u017c":"z","\u017e":"z","\u0132":"IJ","\u0133":"ij","\u0152":"Oe","\u0153":"oe","\u0149":"'n","\u017f":"s"},m=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,g=RegExp("[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]","g");function b(e){return f[e]}function w(e){return(e=e.toString())&&e.replace(m,b).replace(g,"")}var I,x,y,$,S=(I={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},x="(?:"+Object.keys(I).join("|")+")",y=RegExp(x),$=RegExp(x,"g"),function(e){return e=null==e?"":""+e,y.test(e)?e.replace($,E):e});function E(e){return I[e]}var C={32:" ",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",59:";",65:"A",66:"B",67:"C",68:"D",69:"E",70:"F",71:"G",72:"H",73:"I",74:"J",75
:"K",76:"L",77:"M",78:"N",79:"O",80:"P",81:"Q",82:"R",83:"S",84:"T",85:"U",86:"V",87:"W",88:"X",89:"Y",90:"Z",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9"},A=27,L=13,D=32,H=9,B=38,R=40,M={success:!1,major:"3"};try{M.full=(P.fn.dropdown.Constructor.VERSION||"").split(" ")[0].split("."),M.major=M.full[0],M.success=!0}catch(e){}var U=0,j=".bs.select",V={DISABLED:"disabled",DIVIDER:"divider",SHOW:"open",DROPUP:"dropup",MENU:"dropdown-menu",MENURIGHT:"dropdown-menu-right",MENULEFT:"dropdown-menu-left",BUTTONCLASS:"btn-default",POPOVERHEADER:"popover-title",ICONBASE:"glyphicon",TICKICON:"glyphicon-ok"},F={MENU:"."+V.MENU},_={div:document.createElement("div"),span:document.createElement("span"),i:document.createElement("i"),subtext:document.createElement("small"),a:document.createElement("a"),li:document.createElement("li"),whitespace:document.createTextNode("\xa0"),fragment:document.createDocumentFragment()};_.noResults=_.li.cloneNode(!1),_.noResults.classNa
me="no-results",_.a.setAttribute("role","option"),_.a.className="dropdown-item",_.subtext.className="text-muted",_.text=_.span.cloneNode(!1),_.text.className="text",_.checkMark=_.span.cloneNode(!1);var G=new RegExp(B+"|"+R),q=new RegExp("^"+H+"$|"+A),K={li:function(e,t,i){var s=_.li.cloneNode(!1);return e&&(1===e.nodeType||11===e.nodeType?s.appendChild(e):s.innerHTML=e),void 0!==t&&""!==t&&(s.className=t),null!=i&&s.classList.add("optgroup-"+i),s},a:function(e,t,i){var s=_.a.cloneNode(!0);return e&&(11===e.nodeType?s.appendChild(e):s.insertAdjacentHTML("beforeend",e)),void 0!==t&&""!==t&&s.classList.add.apply(s.classList,t.split(/\s+/)),i&&s.setAttribute("style",i),s},text:function(e,t){var i,s,n=_.text.cloneNode(!1);if(e.content)n.innerHTML=e.content;else{if(n.textContent=e.text,e.icon){var o=_.whitespace.cloneNode(!1);(s=(!0===t?_.i:_.span).cloneNode(!1)).className=this.options.iconBase+" "+e.icon,_.fragment.appendChild(s),_.fragment.appendChild(o)}e.subtext&&((i=_.subtext.cloneNo
de(!1)).textContent=e.subtext,n.appendChild(i))}if(!0===t)for(;0<n.childNodes.length;)_.fragment.appendChild(n.childNodes[0]);else _.fragment.appendChild(n);return _.fragment},label:function(e){var t,i,s=_.text.cloneNode(!1);if(s.innerHTML=e.display,e.icon){var n=_.whitespace.cloneNode(!1);(i=_.span.cloneNode(!1)).className=this.options.iconBase+" "+e.icon,_.fragment.appendChild(i),_.fragment.appendChild(n)}return e.subtext&&((t=_.subtext.cloneNode(!1)).textContent=e.subtext,s.appendChild(t)),_.fragment.appendChild(s),_.fragment}};var Y=function(e,t){var i=this;p.useDefault||(P.valHooks.select.set=p._set,p.useDefault=!0),this.$element=P(e),this.$newElement=null,this.$button=null,this.$menu=null,this.options=t,this.selectpicker={main:{},search:{},current:{},view:{},isSearching:!1,keydown:{keyHistory:"",resetKeyHistory:{start:function(){return setTimeout(function(){i.selectpicker.keydown.keyHistory=""},800)}}}},this.sizeInfo={},null===this.options.title&&(this.options.title=this.$elem
ent.attr("title"));var s=this.options.windowPadding;"number"==typeof s&&(this.options.windowPadding=[s,s,s,s]),this.val=Y.prototype.val,this.render=Y.prototype.render,this.refresh=Y.prototype.refresh,this.setStyle=Y.prototype.setStyle,this.selectAll=Y.prototype.selectAll,this.deselectAll=Y.prototype.deselectAll,this.destroy=Y.prototype.destroy,this.remove=Y.prototype.remove,this.show=Y.prototype.show,this.hide=Y.prototype.hide,this.init()};function Z(e){var l,a=arguments,c=e;if([].shift.apply(a),!M.success){try{M.full=(P.fn.dropdown.Constructor.VERSION||"").split(" ")[0].split(".")}catch(e){Y.BootstrapVersion?M.full=Y.BootstrapVersion.split(" ")[0].split("."):(M.full=[M.major,"0","0"],console.warn("There was an issue retrieving Bootstrap's version. Ensure Bootstrap is being loaded before bootstrap-select and there is no namespace collision. If loading Bootstrap asynchronously, the version may need to be manually specified via $.fn.selectpicker.Constructor.BootstrapVersion.",e))}M.ma
jor=M.full[0],M.success=!0}if("4"===M.major){var t=[];Y.DEFAULTS.style===V.BUTTONCLASS&&t.push({name:"style",className:"BUTTONCLASS"}),Y.DEFAULTS.iconBase===V.ICONBASE&&t.push({name:"iconBase",className:"ICONBASE"}),Y.DEFAULTS.tickIcon===V.TICKICON&&t.push({name:"tickIcon",className:"TICKICON"}),V.DIVIDER="dropdown-divider",V.SHOW="show",V.BUTTONCLASS="btn-light",V.POPOVERHEADER="popover-header",V.ICONBASE="",V.TICKICON="bs-ok-default";for(var i=0;i<t.length;i++){e=t[i];Y.DEFAULTS[e.name]=V[e.className]}}var s=this.each(function(){var e=P(this);if(e.is("select")){var t=e.data("selectpicker"),i="object"==typeof c&&c;if(t){if(i)for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(t.options[s]=i[s])}else{var n=e.data();for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&-1!==P.inArray(o,d)&&delete n[o];var r=P.extend({},Y.DEFAULTS,P.fn.selectpicker.defaults||{},n,i);r.template=P.extend({},Y.DEFAULTS.template,P.fn.selectpicker.defaults?P.fn.selectpicker.defaults.template:{},
n.template,i.template),e.data("selectpicker",t=new Y(this,r))}"string"==typeof c&&(l=t[c]instanceof Function?t[c].apply(t,a):t.options[c])}});return void 0!==l?l:s}Y.VERSION="1.13.18",Y.DEFAULTS={noneSelectedText:"Nothing selected",noneResultsText:"No results matched {0}",countSelectedText:function(e,t){return 1==e?"{0} item selected":"{0} items selected"},maxOptionsText:function(e,t){return[1==e?"Limit reached ({n} item max)":"Limit reached ({n} items max)",1==t?"Group limit reached ({n} item max)":"Group limit reached ({n} items max)"]},selectAllText:"Select All",deselectAllText:"Deselect All",doneButton:!1,doneButtonText:"Close",multipleSeparator:", ",styleBase:"btn",style:V.BUTTONCLASS,size:"auto",title:null,selectedTextFormat:"values",width:!1,container:!1,hideDisabled:!1,showSubtext:!1,showIcon:!0,showContent:!0,dropupAuto:!0,header:!1,liveSearch:!1,liveSearchPlaceholder:null,liveSearchNormalize:!1,liveSearchStyle:"contains",actionsBox:!1,iconBase:V.ICONBASE,tickIcon:V.TICKICO
N,showTick:!1,template:{caret:'<span class="caret"></span>'},maxOptions:!1,mobile:!1,selectOnTab:!1,dropdownAlignRight:!1,windowPadding:0,virtualScroll:600,display:!1,sanitize:!0,sanitizeFn:null,whiteList:e},Y.prototype={constructor:Y,init:function(){var i=this,e=this.$element.attr("id"),t=this.$element[0],s=t.form;U++,this.selectId="bs-select-"+U,t.classList.add("bs-select-hidden"),this.multiple=this.$element.prop("multiple"),this.autofocus=this.$element.prop("autofocus"),t.classList.contains("show-tick")&&(this.options.showTick=!0),this.$newElement=this.createDropdown(),this.buildData(),this.$element.after(this.$newElement).prependTo(this.$newElement),s&&null===t.form&&(s.id||(s.id="form-"+this.selectId),t.setAttribute("form",s.id)),this.$button=this.$newElement.children("button"),this.$menu=this.$newElement.children(F.MENU),this.$menuInner=this.$menu.children(".inner"),this.$searchbox=this.$menu.find("input"),t.classList.remove("bs-select-hidden"),!0===this.options.dropdownAlignR
ight&&this.$menu[0].classList.add(V.MENURIGHT),void 0!==e&&this.$button.attr("data-id",e),this.checkDisabled(),this.clickListener(),this.options.liveSearch?(this.liveSearchListener(),this.focusedParent=this.$searchbox[0]):this.focusedParent=this.$menuInner[0],this.setStyle(),this.render(),this.setWidth(),this.options.container?this.selectPosition():this.$element.on("hide"+j,function(){if(i.isVirtual()){var e=i.$menuInner[0],t=e.firstChild.cloneNode(!1);e.replaceChild(t,e.firstChild),e.scrollTop=0}}),this.$menu.data("this",this),this.$newElement.data("this",this),this.options.mobile&&this.mobile(),this.$newElement.on({"hide.bs.dropdown":function(e){i.$element.trigger("hide"+j,e)},"hidden.bs.dropdown":function(e){i.$element.trigger("hidden"+j,e)},"show.bs.dropdown":function(e){i.$element.trigger("show"+j,e)},"shown.bs.dropdown":function(e){i.$element.trigger("shown"+j,e)}}),t.hasAttribute("required")&&this.$element.on("invalid"+j,function(){i.$button[0].classList.add("bs-invalid"),i.$
element.on("shown"+j+".invalid",function(){i.$element.val(i.$element.val()).off("shown"+j+".invalid")}).on("rendered"+j,function(){this.validity.valid&&i.$button[0].classList.remove("bs-invalid"),i.$element.off("rendered"+j)}),i.$button.on("blur"+j,function(){i.$element.trigger("focus").trigger("blur"),i.$button.off("blur"+j)})}),setTimeout(function(){i.buildList(),i.$element.trigger("loaded"+j)})},createDropdown:function(){var e=this.multiple||this.options.showTick?" show-tick":"",t=this.multiple?' aria-multiselectable="true"':"",i="",s=this.autofocus?" autofocus":"";M.major<4&&this.$element.parent().hasClass("input-group")&&(i=" input-group-btn");var n,o="",r="",l="",a="";return this.options.header&&(o='<div class="'+V.POPOVERHEADER+'"><button type="button" class="close" aria-hidden="true">×</button>'+this.options.header+"</div>"),this.options.liveSearch&&(r='<div class="bs-searchbox"><input type="search" class="form-control" autocomplete="off"'+(null===this.options.liveSear
chPlaceholder?"":' placeholder="'+S(this.options.liveSearchPlaceholder)+'"')+' role="combobox" aria-label="Search" aria-controls="'+this.selectId+'" aria-autocomplete="list"></div>'),this.multiple&&this.options.actionsBox&&(l='<div class="bs-actionsbox"><div class="btn-group btn-group-sm btn-block"><button type="button" class="actions-btn bs-select-all btn '+V.BUTTONCLASS+'">'+this.options.selectAllText+'</button><button type="button" class="actions-btn bs-deselect-all btn '+V.BUTTONCLASS+'">'+this.options.deselectAllText+"</button></div></div>"),this.multiple&&this.options.doneButton&&(a='<div class="bs-donebutton"><div class="btn-group btn-block"><button type="button" class="btn btn-sm '+V.BUTTONCLASS+'">'+this.options.doneButtonText+"</button></div></div>"),n='<div class="dropdown bootstrap-select'+e+i+'"><button type="button" tabindex="-1" class="'+this.options.styleBase+' dropdown-toggle" '+("static"===this.options.display?'data-display="static"':"")+'data-toggle="dropdown"'+s+
' role="combobox" aria-owns="'+this.selectId+'" aria-haspopup="listbox" aria-expanded="false"><div class="filter-option"><div class="filter-option-inner"><div class="filter-option-inner-inner"></div></div> </div>'+("4"===M.major?"":'<span class="bs-caret">'+this.options.template.caret+"</span>")+'</button><div class="'+V.MENU+" "+("4"===M.major?"":V.SHOW)+'">'+o+r+l+'<div class="inner '+V.SHOW+'" role="listbox" id="'+this.selectId+'" tabindex="-1" '+t+'><ul class="'+V.MENU+" inner "+("4"===M.major?V.SHOW:"")+'" role="presentation"></ul></div>'+a+"</div></div>",P(n)},setPositionData:function(){this.selectpicker.view.canHighlight=[],this.selectpicker.view.size=0,this.selectpicker.view.firstHighlightIndex=!1;for(var e=0;e<this.selectpicker.current.data.length;e++){var t=this.selectpicker.current.data[e],i=!0;"divider"===t.type?(i=!1,t.height=this.sizeInfo.dividerHeight):"optgroup-label"===t.type?(i=!1,t.height=this.sizeInfo.dropdownHeaderHeight):t.height=this.sizeInfo.liHeight,t.disabl
ed&&(i=!1),this.selectpicker.view.canHighlight.push(i),i&&(this.selectpicker.view.size++,t.posinset=this.selectpicker.view.size,!1===this.selectpicker.view.firstHighlightIndex&&(this.selectpicker.view.firstHighlightIndex=e)),t.position=(0===e?0:this.selectpicker.current.data[e-1].position)+t.height}},isVirtual:function(){return!1!==this.options.virtualScroll&&this.selectpicker.main.elements.length>=this.options.virtualScroll||!0===this.options.virtualScroll},createView:function(N,e,t){var A,L,D=this,i=0,H=[];if(this.selectpicker.isSearching=N,this.selectpicker.current=N?this.selectpicker.search:this.selectpicker.main,this.setPositionData(),e)if(t)i=this.$menuInner[0].scrollTop;else if(!D.multiple){var s=D.$element[0],n=(s.options[s.selectedIndex]||{}).liIndex;if("number"==typeof n&&!1!==D.options.size){var o=D.selectpicker.main.data[n],r=o&&o.position;r&&(i=r-(D.sizeInfo.menuInnerHeight+D.sizeInfo.liHeight)/2)}}function l(e,t){var i,s,n,o,r,l,a,c,d=D.selectpicker.current.elements.le
ngth,h=[],p=!0,u=D.isVirtual();D.selectpicker.view.scrollTop=e,i=Math.ceil(D.sizeInfo.menuInnerHeight/D.sizeInfo.liHeight*1.5),s=Math.round(d/i)||1;for(var f=0;f<s;f++){var m=(f+1)*i;if(f===s-1&&(m=d),h[f]=[f*i+(f?1:0),m],!d)break;void 0===r&&e-1<=D.selectpicker.current.data[m-1].position-D.sizeInfo.menuInnerHeight&&(r=f)}if(void 0===r&&(r=0),l=[D.selectpicker.view.position0,D.selectpicker.view.position1],n=Math.max(0,r-1),o=Math.min(s-1,r+1),D.selectpicker.view.position0=!1===u?0:Math.max(0,h[n][0])||0,D.selectpicker.view.position1=!1===u?d:Math.min(d,h[o][1])||0,a=l[0]!==D.selectpicker.view.position0||l[1]!==D.selectpicker.view.position1,void 0!==D.activeIndex&&(L=D.selectpicker.main.elements[D.prevActiveIndex],H=D.selectpicker.main.elements[D.activeIndex],A=D.selectpicker.main.elements[D.selectedIndex],t&&(D.activeIndex!==D.selectedIndex&&D.defocusItem(H),D.activeIndex=void 0),D.activeIndex&&D.activeIndex!==D.selectedIndex&&D.defocusItem(A)),void 0!==D.prevActiveIndex&&D.prevActi
veIndex!==D.activeIndex&&D.prevActiveIndex!==D.selectedIndex&&D.defocusItem(L),(t||a)&&(c=D.selectpicker.view.visibleElements?D.selectpicker.view.visibleElements.slice():[],D.selectpicker.view.visibleElements=!1===u?D.selectpicker.current.elements:D.selectpicker.current.elements.slice(D.selectpicker.view.position0,D.selectpicker.view.position1),D.setOptionStatus(),(N||!1===u&&t)&&(p=!function(e,i){return e.length===i.length&&e.every(function(e,t){return e===i[t]})}(c,D.selectpicker.view.visibleElements)),(t||!0===u)&&p)){var v,g,b=D.$menuInner[0],w=document.createDocumentFragment(),I=b.firstChild.cloneNode(!1),x=D.selectpicker.view.visibleElements,k=[];b.replaceChild(I,b.firstChild);f=0;for(var y=x.length;f<y;f++){var $,S,E=x[f];D.options.sanitize&&($=E.lastChild)&&(S=D.selectpicker.current.data[f+D.selectpicker.view.position0])&&S.content&&!S.sanitized&&(k.push($),S.sanitized=!0),w.appendChild(E)}if(D.options.sanitize&&k.length&&W(k,D.options.whiteList,D.options.sanitizeFn),!0===u?
(v=0===D.selectpicker.view.position0?0:D.selectpicker.current.data[D.selectpicker.view.position0-1].position,g=D.selectpicker.view.position1>d-1?0:D.selectpicker.current.data[d-1].position-D.selectpicker.current.data[D.selectpicker.view.position1-1].position,b.firstChild.style.marginTop=v+"px",b.firstChild.style.marginBottom=g+"px"):(b.firstChild.style.marginTop=0,b.firstChild.style.marginBottom=0),b.firstChild.appendChild(w),!0===u&&D.sizeInfo.hasScrollBar){var C=b.firstChild.offsetWidth;if(t&&C<D.sizeInfo.menuInnerInnerWidth&&D.sizeInfo.totalMenuWidth>D.sizeInfo.selectWidth)b.firstChild.style.minWidth=D.sizeInfo.menuInnerInnerWidth+"px";else if(C>D.sizeInfo.menuInnerInnerWidth){D.$menu[0].style.minWidth=0;var O=b.firstChild.offsetWidth;O>D.sizeInfo.menuInnerInnerWidth&&(D.sizeInfo.menuInnerInnerWidth=O,b.firstChild.style.minWidth=D.sizeInfo.menuInnerInnerWidth+"px"),D.$menu[0].style.minWidth=""}}}if(D.prevActiveIndex=D.activeIndex,D.options.liveSearch){if(N&&t){var z,T=0;D.selectp
icker.view.canHighlight[T]||(T=1+D.selectpicker.view.canHighlight.slice(1).indexOf(!0)),z=D.selectpicker.view.visibleElements[T],D.defocusItem(D.selectpicker.view.currentActive),D.activeIndex=(D.selectpicker.current.data[T]||{}).index,D.focusItem(z)}}else D.$menuInner.trigger("focus")}l(i,!0),this.$menuInner.off("scroll.createView").on("scroll.createView",function(e,t){D.noScroll||l(this.scrollTop,t),D.noScroll=!1}),P(window).off("resize"+j+"."+this.selectId+".createView").on("resize"+j+"."+this.selectId+".createView",function(){D.$newElement.hasClass(V.SHOW)&&l(D.$menuInner[0].scrollTop)})},focusItem:function(e,t,i){if(e){t=t||this.selectpicker.main.data[this.activeIndex];var s=e.firstChild;s&&(s.setAttribute("aria-setsize",this.selectpicker.view.size),s.setAttribute("aria-posinset",t.posinset),!0!==i&&(this.focusedParent.setAttribute("aria-activedescendant",s.id),e.classList.add("active"),s.classList.add("active")))}},defocusItem:function(e){e&&(e.classList.remove("active"),e.firs
tChild&&e.firstChild.classList.remove("active"))},setPlaceholder:function(){var e=this,t=!1;if(this.options.title&&!this.multiple){this.selectpicker.view.titleOption||(this.selectpicker.view.titleOption=document.createElement("option")),t=!0;var i=this.$element[0],s=!1,n=!this.selectpicker.view.titleOption.parentNode,o=i.selectedIndex,r=i.options[o],l=window.performance&&window.performance.getEntriesByType("navigation"),a=l&&l.length?"back_forward"!==l[0].type:2!==window.performance.navigation.type;n&&(this.selectpicker.view.titleOption.className="bs-title-option",this.selectpicker.view.titleOption.value="",s=!r||0===o&&!1===r.defaultSelected&&void 0===this.$element.data("selected")),!n&&0===this.selectpicker.view.titleOption.index||i.insertBefore(this.selectpicker.view.titleOption,i.firstChild),s&&a?i.selectedIndex=0:"complete"!==document.readyState&&window.addEventListener("pageshow",function(){e.selectpicker.view.displayedValue!==i.value&&e.render()})}return t},buildData:function
(){var p=':not([hidden]):not([data-hidden="true"])',u=[],f=0,m=this.setPlaceholder()?1:0;this.options.hideDisabled&&(p+=":not(:disabled)");var e=this.$element[0].querySelectorAll("select > *"+p);function v(e){var t=u[u.length-1];t&&"divider"===t.type&&(t.optID||e.optID)||((e=e||{}).type="divider",u.push(e))}function g(e,t){if((t=t||{}).divider="true"===e.getAttribute("data-divider"),t.divider)v({optID:t.optID});else{var i=u.length,s=e.style.cssText,n=s?S(s):"",o=(e.className||"")+(t.optgroupClass||"");t.optID&&(o="opt "+o),t.optionClass=o.trim(),t.inlineStyle=n,t.text=e.textContent,t.content=e.getAttribute("data-content"),t.tokens=e.getAttribute("data-tokens"),t.subtext=e.getAttribute("data-subtext"),t.icon=e.getAttribute("data-icon"),e.liIndex=i,t.display=t.content||t.text,t.type="option",t.index=i,t.option=e,t.selected=!!e.selected,t.disabled=t.disabled||!!e.disabled,u.push(t)}}function t(e,t){var i=t[e],s=!(e-1<m)&&t[e-1],n=t[e+1],o=i.querySelectorAll("option"+p);if(o.length){var
r,l,a={display:S(i.label),subtext:i.getAttribute("data-subtext"),icon:i.getAttribute("data-icon"),type:"optgroup-label",optgroupClass:" "+(i.className||"")};f++,s&&v({optID:f}),a.optID=f,u.push(a);for(var c=0,d=o.length;c<d;c++){var h=o[c];0===c&&(l=(r=u.length-1)+d),g(h,{headerIndex:r,lastIndex:l,optID:a.optID,optgroupClass:a.optgroupClass,disabled:i.disabled})}n&&v({optID:f})}}for(var i=e.length,s=m;s<i;s++){var n=e[s];"OPTGROUP"!==n.tagName?g(n,{}):t(s,e)}this.selectpicker.main.data=this.selectpicker.current.data=u},buildList:function(){var s=this,e=this.selectpicker.main.data,n=[],o=0;function t(e){var t,i=0;switch(e.type){case"divider":t=K.li(!1,V.DIVIDER,e.optID?e.optID+"div":void 0);break;case"option":(t=K.li(K.a(K.text.call(s,e),e.optionClass,e.inlineStyle),"",e.optID)).firstChild&&(t.firstChild.id=s.selectId+"-"+e.index);break;case"optgroup-label":t=K.li(K.label.call(s,e),"dropdown-header"+e.optgroupClass,e.optID)}e.element=t,n.push(t),e.display&&(i+=e.display.length),e.su
btext&&(i+=e.subtext.length),e.icon&&(i+=1),o<i&&(o=i,s.selectpicker.view.widestOption=n[n.length-1])}!s.options.showTick&&!s.multiple||_.checkMark.parentNode||(_.checkMark.className=this.options.iconBase+" "+s.options.tickIcon+" check-mark",_.a.appendChild(_.checkMark));for(var i=e.length,r=0;r<i;r++){t(e[r])}this.selectpicker.main.elements=this.selectpicker.current.elements=n},findLis:function(){return this.$menuInner.find(".inner > li")},render:function(){var e,t=this,i=this.$element[0],s=this.setPlaceholder()&&0===i.selectedIndex,n=O(i,this.options.hideDisabled),o=n.length,r=this.$button[0],l=r.querySelector(".filter-option-inner-inner"),a=document.createTextNode(this.options.multipleSeparator),c=_.fragment.cloneNode(!1),d=!1;if(r.classList.toggle("bs-placeholder",t.multiple?!o:!z(i,n)),t.multiple||1!==n.length||(t.selectpicker.view.displayedValue=z(i,n)),"static"===this.options.selectedTextFormat)c=K.text.call(this,{text:this.options.title},!0);else if(!1===(this.multiple&&-1!=
=this.options.selectedTextFormat.indexOf("count")&&1<o&&(1<(e=this.options.selectedTextFormat.split(">")).length&&o>e[1]||1===e.length&&2<=o))){if(!s){for(var h=0;h<o&&h<50;h++){var p=n[h],u=this.selectpicker.main.data[p.liIndex],f={};this.multiple&&0<h&&c.appendChild(a.cloneNode(!1)),p.title?f.text=p.title:u&&(u.content&&t.options.showContent?(f.content=u.content.toString(),d=!0):(t.options.showIcon&&(f.icon=u.icon),t.options.showSubtext&&!t.multiple&&u.subtext&&(f.subtext=" "+u.subtext),f.text=p.textContent.trim())),c.appendChild(K.text.call(this,f,!0))}49<o&&c.appendChild(document.createTextNode("..."))}}else{var m=':not([hidden]):not([data-hidden="true"]):not([data-divider="true"])';this.options.hideDisabled&&(m+=":not(:disabled)");var v=this.$element[0].querySelectorAll("select > option"+m+", optgroup"+m+" option"+m).length,g="function"==typeof this.options.countSelectedText?this.options.countSelectedText(o,v):this.options.countSelectedText;c=K.text.call(this,{text:g.replace("{
0}",o.toString()).replace("{1}",v.toString())},!0)}if(null==this.options.title&&(this.options.title=this.$element.attr("title")),c.childNodes.length||(c=K.text.call(this,{text:void 0!==this.options.title?this.options.title:this.options.noneSelectedText},!0)),r.title=c.textContent.replace(/<[^>]*>?/g,"").trim(),this.options.sanitize&&d&&W([c],t.options.whiteList,t.options.sanitizeFn),l.innerHTML="",l.appendChild(c),M.major<4&&this.$newElement[0].classList.contains("bs3-has-addon")){var b=r.querySelector(".filter-expand"),w=l.cloneNode(!0);w.className="filter-expand",b?r.replaceChild(w,b):r.appendChild(w)}this.$element.trigger("rendered"+j)},setStyle:function(e,t){var i,s=this.$button[0],n=this.$newElement[0],o=this.options.style.trim();this.$element.attr("class")&&this.$newElement.addClass(this.$element.attr("class").replace(/selectpicker|mobile-device|bs-select-hidden|validate\[.*\]/gi,"")),M.major<4&&(n.classList.add("bs3"),n.parentNode.classList&&n.parentNode.classList.contains("i
nput-group")&&(n.previousElementSibling||n.nextElementSibling)&&(n.previousElementSibling||n.nextElementSibling).classList.contains("input-group-addon")&&n.classList.add("bs3-has-addon")),i=e?e.trim():o,"add"==t?i&&s.classList.add.apply(s.classList,i.split(" ")):"remove"==t?i&&s.classList.remove.apply(s.classList,i.split(" ")):(o&&s.classList.remove.apply(s.classList,o.split(" ")),i&&s.classList.add.apply(s.classList,i.split(" ")))},liHeight:function(e){if(e||!1!==this.options.size&&!Object.keys(this.sizeInfo).length){var t,i=_.div.cloneNode(!1),s=_.div.cloneNode(!1),n=_.div.cloneNode(!1),o=document.createElement("ul"),r=_.li.cloneNode(!1),l=_.li.cloneNode(!1),a=_.a.cloneNode(!1),c=_.span.cloneNode(!1),d=this.options.header&&0<this.$menu.find("."+V.POPOVERHEADER).length?this.$menu.find("."+V.POPOVERHEADER)[0].cloneNode(!0):null,h=this.options.liveSearch?_.div.cloneNode(!1):null,p=this.options.actionsBox&&this.multiple&&0<this.$menu.find(".bs-actionsbox").length?this.$menu.find(".bs-
actionsbox")[0].cloneNode(!0):null,u=this.options.doneButton&&this.multiple&&0<this.$menu.find(".bs-donebutton").length?this.$menu.find(".bs-donebutton")[0].cloneNode(!0):null,f=this.$element.find("option")[0];if(this.sizeInfo.selectWidth=this.$newElement[0].offsetWidth,c.className="text",a.className="dropdown-item "+(f?f.className:""),i.className=this.$menu[0].parentNode.className+" "+V.SHOW,i.style.width=0,"auto"===this.options.width&&(s.style.minWidth=0),s.className=V.MENU+" "+V.SHOW,n.className="inner "+V.SHOW,o.className=V.MENU+" inner "+("4"===M.major?V.SHOW:""),r.className=V.DIVIDER,l.className="dropdown-header",c.appendChild(document.createTextNode("\u200b")),this.selectpicker.current.data.length)for(var m=0;m<this.selectpicker.current.data.length;m++){var v=this.selectpicker.current.data[m];if("option"===v.type){t=v.element;break}}else t=_.li.cloneNode(!1),a.appendChild(c),t.appendChild(a);if(l.appendChild(c.cloneNode(!0)),this.selectpicker.view.widestOption&&o.appendChild(
this.selectpicker.view.widestOption.cloneNode(!0)),o.appendChild(t),o.appendChild(r),o.appendChild(l),d&&s.appendChild(d),h){var g=document.createElement("input");h.className="bs-searchbox",g.className="form-control",h.appendChild(g),s.appendChild(h)}p&&s.appendChild(p),n.appendChild(o),s.appendChild(n),u&&s.appendChild(u),i.appendChild(s),document.body.appendChild(i);var b,w=t.offsetHeight,I=l?l.offsetHeight:0,x=d?d.offsetHeight:0,k=h?h.offsetHeight:0,y=p?p.offsetHeight:0,$=u?u.offsetHeight:0,S=P(r).outerHeight(!0),E=!!window.getComputedStyle&&window.getComputedStyle(s),C=s.offsetWidth,O=E?null:P(s),z={vert:N(E?E.paddingTop:O.css("paddingTop"))+N(E?E.paddingBottom:O.css("paddingBottom"))+N(E?E.borderTopWidth:O.css("borderTopWidth"))+N(E?E.borderBottomWidth:O.css("borderBottomWidth")),horiz:N(E?E.paddingLeft:O.css("paddingLeft"))+N(E?E.paddingRight:O.css("paddingRight"))+N(E?E.borderLeftWidth:O.css("borderLeftWidth"))+N(E?E.borderRightWidth:O.css("borderRightWidth"))},T={vert:z.vert
+N(E?E.marginTop:O.css("marginTop"))+N(E?E.marginBottom:O.css("marginBottom"))+2,horiz:z.horiz+N(E?E.marginLeft:O.css("marginLeft"))+N(E?E.marginRight:O.css("marginRight"))+2};n.style.overflowY="scroll",b=s.offsetWidth-C,document.body.removeChild(i),this.sizeInfo.liHeight=w,this.sizeInfo.dropdownHeaderHeight=I,this.sizeInfo.headerHeight=x,this.sizeInfo.searchHeight=k,this.sizeInfo.actionsHeight=y,this.sizeInfo.doneButtonHeight=$,this.sizeInfo.dividerHeight=S,this.sizeInfo.menuPadding=z,this.sizeInfo.menuExtras=T,this.sizeInfo.menuWidth=C,this.sizeInfo.menuInnerInnerWidth=C-z.horiz,this.sizeInfo.totalMenuWidth=this.sizeInfo.menuWidth,this.sizeInfo.scrollBarWidth=b,this.sizeInfo.selectHeight=this.$newElement[0].offsetHeight,this.setPositionData()}},getSelectPosition:function(){var e,t=P(window),i=this.$newElement.offset(),s=P(this.options.container);this.options.container&&s.length&&!s.is("body")?((e=s.offset()).top+=parseInt(s.css("borderTopWidth")),e.left+=parseInt(s.css("borderLeft
Width"))):e={top:0,left:0};var n=this.options.windowPadding;this.sizeInfo.selectOffsetTop=i.top-e.top-t.scrollTop(),this.sizeInfo.selectOffsetBot=t.height()-this.sizeInfo.selectOffsetTop-this.sizeInfo.selectHeight-e.top-n[2],this.sizeInfo.selectOffsetLeft=i.left-e.left-t.scrollLeft(),this.sizeInfo.selectOffsetRight=t.width()-this.sizeInfo.selectOffsetLeft-this.sizeInfo.selectWidth-e.left-n[1],this.sizeInfo.selectOffsetTop-=n[0],this.sizeInfo.selectOffsetLeft-=n[3]},setMenuSize:function(e){this.getSelectPosition();var t,i,s,n,o,r,l,a,c=this.sizeInfo.selectWidth,d=this.sizeInfo.liHeight,h=this.sizeInfo.headerHeight,p=this.sizeInfo.searchHeight,u=this.sizeInfo.actionsHeight,f=this.sizeInfo.doneButtonHeight,m=this.sizeInfo.dividerHeight,v=this.sizeInfo.menuPadding,g=0;if(this.options.dropupAuto&&(l=d*this.selectpicker.current.elements.length+v.vert,a=this.sizeInfo.selectOffsetTop-this.sizeInfo.selectOffsetBot>this.sizeInfo.menuExtras.vert&&l+this.sizeInfo.menuExtras.vert+50>this.sizeInf
o.selectOffsetBot,!0===this.selectpicker.isSearching&&(a=this.selectpicker.dropup),this.$newElement.toggleClass(V.DROPUP,a),this.selectpicker.dropup=a),"auto"===this.options.size)n=3<this.selectpicker.current.elements.length?3*this.sizeInfo.liHeight+this.sizeInfo.menuExtras.vert-2:0,i=this.sizeInfo.selectOffsetBot-this.sizeInfo.menuExtras.vert,s=n+h+p+u+f,r=Math.max(n-v.vert,0),this.$newElement.hasClass(V.DROPUP)&&(i=this.sizeInfo.selectOffsetTop-this.sizeInfo.menuExtras.vert),t=(o=i)-h-p-u-f-v.vert;else if(this.options.size&&"auto"!=this.options.size&&this.selectpicker.current.elements.length>this.options.size){for(var b=0;b<this.options.size;b++)"divider"===this.selectpicker.current.data[b].type&&g++;t=(i=d*this.options.size+g*m+v.vert)-v.vert,o=i+h+p+u+f,s=r=""}this.$menu.css({"max-height":o+"px",overflow:"hidden","min-height":s+"px"}),this.$menuInner.css({"max-height":t+"px","overflow-y":"auto","min-height":r+"px"}),this.sizeInfo.menuInnerHeight=Math.max(t,1),this.selectpicker.c
urrent.data.length&&this.selectpicker.current.data[this.selectpicker.current.data.length-1].position>this.sizeInfo.menuInnerHeight&&(this.sizeInfo.hasScrollBar=!0,this.sizeInfo.totalMenuWidth=this.sizeInfo.menuWidth+this.sizeInfo.scrollBarWidth),"auto"===this.options.dropdownAlignRight&&this.$menu.toggleClass(V.MENURIGHT,this.sizeInfo.selectOffsetLeft>this.sizeInfo.selectOffsetRight&&this.sizeInfo.selectOffsetRight<this.sizeInfo.totalMenuWidth-c),this.dropdown&&this.dropdown._popper&&this.dropdown._popper.update()},setSize:function(e){if(this.liHeight(e),this.options.header&&this.$menu.css("padding-top",0),!1!==this.options.size){var t=this,i=P(window);this.setMenuSize(),this.options.liveSearch&&this.$searchbox.off("input.setMenuSize propertychange.setMenuSize").on("input.setMenuSize propertychange.setMenuSize",function(){return t.setMenuSize()}),"auto"===this.options.size?i.off("resize"+j+"."+this.selectId+".setMenuSize scroll"+j+"."+this.selectId+".setMenuSize").on("resize"+j+"."+
this.selectId+".setMenuSize scroll"+j+"."+this.selectId+".setMenuSize",function(){return t.setMenuSize()}):this.options.size&&"auto"!=this.options.size&&this.selectpicker.current.elements.length>this.options.size&&i.off("resize"+j+"."+this.selectId+".setMenuSize scroll"+j+"."+this.selectId+".setMenuSize")}this.createView(!1,!0,e)},setWidth:function(){var i=this;"auto"===this.options.width?requestAnimationFrame(function(){i.$menu.css("min-width","0"),i.$element.on("loaded"+j,function(){i.liHeight(),i.setMenuSize();var e=i.$newElement.clone().appendTo("body"),t=e.css("width","auto").children("button").outerWidth();e.remove(),i.sizeInfo.selectWidth=Math.max(i.sizeInfo.totalMenuWidth,t),i.$newElement.css("width",i.sizeInfo.selectWidth+"px")})}):"fit"===this.options.width?(this.$menu.css("min-width",""),this.$newElement.css("width","").addClass("fit-width")):this.options.width?(this.$menu.css("min-width",""),this.$newElement.css("width",this.options.width)):(this.$menu.css("min-width",""
),this.$newElement.css("width","")),this.$newElement.hasClass("fit-width")&&"fit"!==this.options.width&&this.$newElement[0].classList.remove("fit-width")},selectPosition:function(){this.$bsContainer=P('<div class="bs-container" />');function e(e){var t={},i=r.options.display||!!P.fn.dropdown.Constructor.Default&&P.fn.dropdown.Constructor.Default.display;r.$bsContainer.addClass(e.attr("class").replace(/form-control|fit-width/gi,"")).toggleClass(V.DROPUP,e.hasClass(V.DROPUP)),s=e.offset(),l.is("body")?n={top:0,left:0}:((n=l.offset()).top+=parseInt(l.css("borderTopWidth"))-l.scrollTop(),n.left+=parseInt(l.css("borderLeftWidth"))-l.scrollLeft()),o=e.hasClass(V.DROPUP)?0:e[0].offsetHeight,(M.major<4||"static"===i)&&(t.top=s.top-n.top+o,t.left=s.left-n.left),t.width=e[0].offsetWidth,r.$bsContainer.css(t)}var s,n,o,r=this,l=P(this.options.container);this.$button.on("click.bs.dropdown.data-api",function(){r.isDisabled()||(e(r.$newElement),r.$bsContainer.appendTo(r.options.container).toggleC
lass(V.SHOW,!r.$button.hasClass(V.SHOW)).append(r.$menu))}),P(window).off("resize"+j+"."+this.selectId+" scroll"+j+"."+this.selectId).on("resize"+j+"."+this.selectId+" scroll"+j+"."+this.selectId,function(){r.$newElement.hasClass(V.SHOW)&&e(r.$newElement)}),this.$element.on("hide"+j,function(){r.$menu.data("height",r.$menu.height()),r.$bsContainer.detach()})},setOptionStatus:function(e){var t=this;if(t.noScroll=!1,t.selectpicker.view.visibleElements&&t.selectpicker.view.visibleElements.length)for(var i=0;i<t.selectpicker.view.visibleElements.length;i++){var s=t.selectpicker.current.data[i+t.selectpicker.view.position0],n=s.option;n&&(!0!==e&&t.setDisabled(s.index,s.disabled),t.setSelected(s.index,n.selected))}},setSelected:function(e,t){var i,s,n=this.selectpicker.main.elements[e],o=this.selectpicker.main.data[e],r=void 0!==this.activeIndex,l=this.activeIndex===e||t&&!this.multiple&&!r;o.selected=t,s=n.firstChild,t&&(this.selectedIndex=e),n.classList.toggle("selected",t),l?(this.foc
usItem(n,o),this.selectpicker.view.currentActive=n,this.activeIndex=e):this.defocusItem(n),s&&(s.classList.toggle("selected",t),t?s.setAttribute("aria-selected",!0):this.multiple?s.setAttribute("aria-selected",!1):s.removeAttribute("aria-selected")),l||r||!t||void 0===this.prevActiveIndex||(i=this.selectpicker.main.elements[this.prevActiveIndex],this.defocusItem(i))},setDisabled:function(e,t){var i,s=this.selectpicker.main.elements[e];this.selectpicker.main.data[e].disabled=t,i=s.firstChild,s.classList.toggle(V.DISABLED,t),i&&("4"===M.major&&i.classList.toggle(V.DISABLED,t),t?(i.setAttribute("aria-disabled",t),i.setAttribute("tabindex",-1)):(i.removeAttribute("aria-disabled"),i.setAttribute("tabindex",0)))},isDisabled:function(){return this.$element[0].disabled},checkDisabled:function(){this.isDisabled()?(this.$newElement[0].classList.add(V.DISABLED),this.$button.addClass(V.DISABLED).attr("aria-disabled",!0)):this.$button[0].classList.contains(V.DISABLED)&&(this.$newElement[0].class
List.remove(V.DISABLED),this.$button.removeClass(V.DISABLED).attr("aria-disabled",!1))},clickListener:function(){var C=this,t=P(document);function e(){C.options.liveSearch?C.$searchbox.trigger("focus"):C.$menuInner.trigger("focus")}function i(){C.dropdown&&C.dropdown._popper&&C.dropdown._popper.state.isCreated?e():requestAnimationFrame(i)}t.data("spaceSelect",!1),this.$button.on("keyup",function(e){/(32)/.test(e.keyCode.toString(10))&&t.data("spaceSelect")&&(e.preventDefault(),t.data("spaceSelect",!1))}),this.$newElement.on("show.bs.dropdown",function(){3<M.major&&!C.dropdown&&(C.dropdown=C.$button.data("bs.dropdown"),C.dropdown._menu=C.$menu[0])}),this.$button.on("click.bs.dropdown.data-api",function(){C.$newElement.hasClass(V.SHOW)||C.setSize()}),this.$element.on("shown"+j,function(){C.$menuInner[0].scrollTop!==C.selectpicker.view.scrollTop&&(C.$menuInner[0].scrollTop=C.selectpicker.view.scrollTop),3<M.major?requestAnimationFrame(i):e()}),this.$menuInner.on("mouseenter","li a",fun
ction(e){var t=this.parentElement,i=C.isVirtual()?C.selectpicker.view.position0:0,s=Array.prototype.indexOf.call(t.parentElement.children,t),n=C.selectpicker.current.data[s+i];C.focusItem(t,n,!0)}),this.$menuInner.on("click","li a",function(e,t){var i=P(this),s=C.$element[0],n=C.isVirtual()?C.selectpicker.view.position0:0,o=C.selectpicker.current.data[i.parent().index()+n],r=o.index,l=z(s),a=s.selectedIndex,c=s.options[a],d=!0;if(C.multiple&&1!==C.options.maxOptions&&e.stopPropagation(),e.preventDefault(),!C.isDisabled()&&!i.parent().hasClass(V.DISABLED)){var h=o.option,p=P(h),u=h.selected,f=p.parent("optgroup"),m=f.find("option"),v=C.options.maxOptions,g=f.data("maxOptions")||!1;if(r===C.activeIndex&&(t=!0),t||(C.prevActiveIndex=C.activeIndex,C.activeIndex=void 0),C.multiple){if(h.selected=!u,C.setSelected(r,!u),C.focusedParent.focus(),!1!==v||!1!==g){var b=v<O(s).length,w=g<f.find("option:selected").length;if(v&&b||g&&w)if(v&&1==v)s.selectedIndex=-1,h.selected=!0,C.setOptionStatus
(!0);else if(g&&1==g){for(var I=0;I<m.length;I++){var x=m[I];x.selected=!1,C.setSelected(x.liIndex,!1)}h.selected=!0,C.setSelected(r,!0)}else{var k="string"==typeof C.options.maxOptionsText?[C.options.maxOptionsText,C.options.maxOptionsText]:C.options.maxOptionsText,y="function"==typeof k?k(v,g):k,$=y[0].replace("{n}",v),S=y[1].replace("{n}",g),E=P('<div class="notify"></div>');y[2]&&($=$.replace("{var}",y[2][1<v?0:1]),S=S.replace("{var}",y[2][1<g?0:1])),h.selected=!1,C.$menu.append(E),v&&b&&(E.append(P("<div>"+$+"</div>")),d=!1,C.$element.trigger("maxReached"+j)),g&&w&&(E.append(P("<div>"+S+"</div>")),d=!1,C.$element.trigger("maxReachedGrp"+j)),setTimeout(function(){C.setSelected(r,!1)},10),E[0].classList.add("fadeOut"),setTimeout(function(){E.remove()},1050)}}}else c&&(c.selected=!1),h.selected=!0,C.setSelected(r,!0);!C.multiple||C.multiple&&1===C.options.maxOptions?C.$button.trigger("focus"):C.options.liveSearch&&C.$searchbox.trigger("focus"),d&&(!C.multiple&&a===s.selectedIndex|
|(T=[h.index,p.prop("selected"),l],C.$element.triggerNative("change")))}}),this.$menu.on("click","li."+V.DISABLED+" a, ."+V.POPOVERHEADER+", ."+V.POPOVERHEADER+" :not(.close)",function(e){e.currentTarget==this&&(e.preventDefault(),e.stopPropagation(),C.options.liveSearch&&!P(e.target).hasClass("close")?C.$searchbox.trigger("focus"):C.$button.trigger("focus"))}),this.$menuInner.on("click",".divider, .dropdown-header",function(e){e.preventDefault(),e.stopPropagation(),C.options.liveSearch?C.$searchbox.trigger("focus"):C.$button.trigger("focus")}),this.$menu.on("click","."+V.POPOVERHEADER+" .close",function(){C.$button.trigger("click")}),this.$searchbox.on("click",function(e){e.stopPropagation()}),this.$menu.on("click",".actions-btn",function(e){C.options.liveSearch?C.$searchbox.trigger("focus"):C.$button.trigger("focus"),e.preventDefault(),e.stopPropagation(),P(this).hasClass("bs-select-all")?C.selectAll():C.deselectAll()}),this.$button.on("focus"+j,function(e){var t=C.$element[0].get
Attribute("tabindex");void 0!==t&&e.originalEvent&&e.originalEvent.isTrusted&&(this.setAttribute("tabindex",t),C.$element[0].setAttribute("tabindex",-1),C.selectpicker.view.tabindex=t)}).on("blur"+j,function(e){void 0!==C.selectpicker.view.tabindex&&e.originalEvent&&e.originalEvent.isTrusted&&(C.$element[0].setAttribute("tabindex",C.selectpicker.view.tabindex),this.setAttribute("tabindex",-1),C.selectpicker.view.tabindex=void 0)}),this.$element.on("change"+j,function(){C.render(),C.$element.trigger("changed"+j,T),T=null}).on("focus"+j,function(){C.options.mobile||C.$button[0].focus()})},liveSearchListener:function(){var u=this;this.$button.on("click.bs.dropdown.data-api",function(){u.$searchbox.val()&&(u.$searchbox.val(""),u.selectpicker.search.previousValue=void 0)}),this.$searchbox.on("click.bs.dropdown.data-api focus.bs.dropdown.data-api touchend.bs.dropdown.data-api",function(e){e.stopPropagation()}),this.$searchbox.on("input propertychange",function(){var e=u.$searchbox[0].valu
e;if(u.selectpicker.search.elements=[],u.selectpicker.search.data=[],e){var t=[],i=e.toUpperCase(),s={},n=[],o=u._searchStyle(),r=u.options.liveSearchNormalize;r&&(i=w(i));for(var l=0;l<u.selectpicker.main.data.length;l++){var a=u.selectpicker.main.data[l];s[l]||(s[l]=k(a,i,o,r)),s[l]&&void 0!==a.headerIndex&&-1===n.indexOf(a.headerIndex)&&(0<a.headerIndex&&(s[a.headerIndex-1]=!0,n.push(a.headerIndex-1)),s[a.headerIndex]=!0,n.push(a.headerIndex),s[a.lastIndex+1]=!0),s[l]&&"optgroup-label"!==a.type&&n.push(l)}l=0;for(var c=n.length;l<c;l++){var d=n[l],h=n[l-1],p=(a=u.selectpicker.main.data[d],u.selectpicker.main.data[h]);("divider"!==a.type||"divider"===a.type&&p&&"divider"!==p.type&&c-1!==l)&&(u.selectpicker.search.data.push(a),t.push(u.selectpicker.main.elements[d]))}u.activeIndex=void 0,u.noScroll=!0,u.$menuInner.scrollTop(0),u.selectpicker.search.elements=t,u.createView(!0),function(e,t){e.length||(_.noResults.innerHTML=this.options.noneResultsText.replace("{0}",'"'+S(t)+'"'),thi
s.$menuInner[0].firstChild.appendChild(_.noResults))}.call(u,t,e)}else u.selectpicker.search.previousValue&&(u.$menuInner.scrollTop(0),u.createView(!1));u.selectpicker.search.previousValue=e})},_searchStyle:function(){return this.options.liveSearchStyle||"contains"},val:function(e){var t=this.$element[0];if(void 0===e)return this.$element.val();var i=z(t);if(T=[null,null,i],this.$element.val(e).trigger("changed"+j,T),this.$newElement.hasClass(V.SHOW))if(this.multiple)this.setOptionStatus(!0);else{var s=(t.options[t.selectedIndex]||{}).liIndex;"number"==typeof s&&(this.setSelected(this.selectedIndex,!1),this.setSelected(s,!0))}return this.render(),T=null,this.$element},changeAll:function(e){if(this.multiple){void 0===e&&(e=!0);var t=this.$element[0],i=0,s=0,n=z(t);t.classList.add("bs-select-hidden");for(var o=0,r=this.selectpicker.current.data,l=r.length;o<l;o++){var a=r[o],c=a.option;c&&!a.disabled&&"divider"!==a.type&&(a.selected&&i++,!0===(c.selected=e)&&s++)}t.classList.remove("b
s-select-hidden"),i!==s&&(this.setOptionStatus(),T=[null,null,n],this.$element.triggerNative("change"))}},selectAll:function(){return this.changeAll(!0)},deselectAll:function(){return this.changeAll(!1)},toggle:function(e){(e=e||window.event)&&e.stopPropagation(),this.$button.trigger("click.bs.dropdown.data-api")},keydown:function(e){var t,i,s,n,o,r=P(this),l=r.hasClass("dropdown-toggle"),a=(l?r.closest(".dropdown"):r.closest(F.MENU)).data("this"),c=a.findLis(),d=!1,h=e.which===H&&!l&&!a.options.selectOnTab,p=G.test(e.which)||h,u=a.$menuInner[0].scrollTop,f=!0===a.isVirtual()?a.selectpicker.view.position0:0;if(!(112<=e.which&&e.which<=123))if(!(i=a.$newElement.hasClass(V.SHOW))&&(p||48<=e.which&&e.which<=57||96<=e.which&&e.which<=105||65<=e.which&&e.which<=90)&&(a.$button.trigger("click.bs.dropdown.data-api"),a.options.liveSearch))a.$searchbox.trigger("focus");else{if(e.which===A&&i&&(e.preventDefault(),a.$button.trigger("click.bs.dropdown.data-api").trigger("focus")),p){if(!c.lengt
h)return;-1!==(t=(s=a.selectpicker.main.elements[a.activeIndex])?Array.prototype.indexOf.call(s.parentElement.children,s):-1)&&a.defocusItem(s),e.which===B?(-1!==t&&t--,t+f<0&&(t+=c.length),a.selectpicker.view.canHighlight[t+f]||-1===(t=a.selectpicker.view.canHighlight.slice(0,t+f).lastIndexOf(!0)-f)&&(t=c.length-1)):e.which!==R&&!h||(++t+f>=a.selectpicker.view.canHighlight.length&&(t=a.selectpicker.view.firstHighlightIndex),a.selectpicker.view.canHighlight[t+f]||(t=t+1+a.selectpicker.view.canHighlight.slice(t+f+1).indexOf(!0))),e.preventDefault();var m=f+t;e.which===B?0===f&&t===c.length-1?(a.$menuInner[0].scrollTop=a.$menuInner[0].scrollHeight,m=a.selectpicker.current.elements.length-1):d=(o=(n=a.selectpicker.current.data[m]).position-n.height)<u:e.which!==R&&!h||(t===a.selectpicker.view.firstHighlightIndex?(a.$menuInner[0].scrollTop=0,m=a.selectpicker.view.firstHighlightIndex):d=u<(o=(n=a.selectpicker.current.data[m]).position-a.sizeInfo.menuInnerHeight)),s=a.selectpicker.current
.elements[m],a.activeIndex=a.selectpicker.current.data[m].index,a.focusItem(s),a.selectpicker.view.currentActive=s,d&&(a.$menuInner[0].scrollTop=o),a.options.liveSearch?a.$searchbox.trigger("focus"):r.trigger("focus")}else if(!r.is("input")&&!q.test(e.which)||e.which===D&&a.selectpicker.keydown.keyHistory){var v,g,b=[];e.preventDefault(),a.selectpicker.keydown.keyHistory+=C[e.which],a.selectpicker.keydown.resetKeyHistory.cancel&&clearTimeout(a.selectpicker.keydown.resetKeyHistory.cancel),a.selectpicker.keydown.resetKeyHistory.cancel=a.selectpicker.keydown.resetKeyHistory.start(),g=a.selectpicker.keydown.keyHistory,/^(.)\1+$/.test(g)&&(g=g.charAt(0));for(var w=0;w<a.selectpicker.current.data.length;w++){var I=a.selectpicker.current.data[w];k(I,g,"startsWith",!0)&&a.selectpicker.view.canHighlight[w]&&b.push(I.index)}if(b.length){var x=0;c.removeClass("active").find("a").removeClass("active"),1===g.length&&(-1===(x=b.indexOf(a.activeIndex))||x===b.length-1?x=0:x++),v=b[x],d=0<u-(n=a.se
lectpicker.main.data[v]).position?(o=n.position-n.height,!0):(o=n.position-a.sizeInfo.menuInnerHeight,n.position>u+a.sizeInfo.menuInnerHeight),s=a.selectpicker.main.elements[v],a.activeIndex=b[x],a.focusItem(s),s&&s.firstChild.focus(),d&&(a.$menuInner[0].scrollTop=o),r.trigger("focus")}}i&&(e.which===D&&!a.selectpicker.keydown.keyHistory||e.which===L||e.which===H&&a.options.selectOnTab)&&(e.which!==D&&e.preventDefault(),a.options.liveSearch&&e.which===D||(a.$menuInner.find(".active a").trigger("click",!0),r.trigger("focus"),a.options.liveSearch||(e.preventDefault(),P(document).data("spaceSelect",!0))))}},mobile:function(){this.options.mobile=!0,this.$element[0].classList.add("mobile-device")},refresh:function(){var e=P.extend({},this.options,this.$element.data());this.options=e,this.checkDisabled(),this.buildData(),this.setStyle(),this.render(),this.buildList(),this.setWidth(),this.setSize(!0),this.$element.trigger("refreshed"+j)},hide:function(){this.$newElement.hide()},show:functi
on(){this.$newElement.show()},remove:function(){this.$newElement.remove(),this.$element.remove()},destroy:function(){this.$newElement.before(this.$element).remove(),this.$bsContainer?this.$bsContainer.remove():this.$menu.remove(),this.selectpicker.view.titleOption&&this.selectpicker.view.titleOption.parentNode&&this.selectpicker.view.titleOption.parentNode.removeChild(this.selectpicker.view.titleOption),this.$element.off(j).removeData("selectpicker").removeClass("bs-select-hidden selectpicker"),P(window).off(j+"."+this.selectId)}};var J=P.fn.selectpicker;function Q(){if(P.fn.dropdown)return(P.fn.dropdown.Constructor._dataApiKeydownHandler||P.fn.dropdown.Constructor.prototype.keydown).apply(this,arguments)}P.fn.selectpicker=Z,P.fn.selectpicker.Constructor=Y,P.fn.selectpicker.noConflict=function(){return P.fn.selectpicker=J,this},P(document).off("keydown.bs.dropdown.data-api").on("keydown.bs.dropdown.data-api",':not(.bootstrap-select) > [data-toggle="dropdown"]',Q).on("keydown.bs.drop
down.data-api",":not(.bootstrap-select) > .dropdown-menu",Q).on("keydown"+j,'.bootstrap-select [data-toggle="dropdown"], .bootstrap-select [role="listbox"], .bootstrap-select .bs-searchbox input',Y.prototype.keydown).on("focusin.modal",'.bootstrap-select [data-toggle="dropdown"], .bootstrap-select [role="listbox"], .bootstrap-select .bs-searchbox input',function(e){e.stopPropagation()}),P(window).on("load"+j+".data-api",function(){P(".selectpicker").each(function(){var e=P(this);Z.call(e,e.data())})})}(e)});
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list