|
@@ -1,5 +1,5 @@
|
|
|
/*!
|
|
|
- * Bootstrap-select v1.12.2 (http://silviomoreto.github.io/bootstrap-select)
|
|
|
+ * Bootstrap-select v1.12.4 (http://silviomoreto.github.io/bootstrap-select)
|
|
|
*
|
|
|
* Copyright 2013-2017 bootstrap-select
|
|
|
* Licensed under MIT (https://github.com/silviomoreto/bootstrap-select/blob/master/LICENSE)
|
|
@@ -164,12 +164,22 @@
|
|
|
};
|
|
|
|
|
|
var changed_arguments = 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 (typeof Event === 'function') {
|
|
|
+ if (EventIsSupported) {
|
|
|
// For modern browsers
|
|
|
event = new Event(eventName, {
|
|
|
bubbles: true
|
|
@@ -194,28 +204,28 @@
|
|
|
|
|
|
// Case insensitive contains search
|
|
|
$.expr.pseudos.icontains = function (obj, index, meta) {
|
|
|
- var $obj = $(obj);
|
|
|
+ var $obj = $(obj).find('a');
|
|
|
var haystack = ($obj.data('tokens') || $obj.text()).toString().toUpperCase();
|
|
|
return haystack.includes(meta[3].toUpperCase());
|
|
|
};
|
|
|
|
|
|
// Case insensitive begins search
|
|
|
$.expr.pseudos.ibegins = function (obj, index, meta) {
|
|
|
- var $obj = $(obj);
|
|
|
+ var $obj = $(obj).find('a');
|
|
|
var haystack = ($obj.data('tokens') || $obj.text()).toString().toUpperCase();
|
|
|
return haystack.startsWith(meta[3].toUpperCase());
|
|
|
};
|
|
|
|
|
|
// Case and accent insensitive contains search
|
|
|
$.expr.pseudos.aicontains = function (obj, index, meta) {
|
|
|
- var $obj = $(obj);
|
|
|
+ var $obj = $(obj).find('a');
|
|
|
var haystack = ($obj.data('tokens') || $obj.data('normalizedText') || $obj.text()).toString().toUpperCase();
|
|
|
return haystack.includes(meta[3].toUpperCase());
|
|
|
};
|
|
|
|
|
|
// Case and accent insensitive begins search
|
|
|
$.expr.pseudos.aibegins = function (obj, index, meta) {
|
|
|
- var $obj = $(obj);
|
|
|
+ var $obj = $(obj).find('a');
|
|
|
var haystack = ($obj.data('tokens') || $obj.data('normalizedText') || $obj.text()).toString().toUpperCase();
|
|
|
return haystack.startsWith(meta[3].toUpperCase());
|
|
|
};
|
|
@@ -327,7 +337,7 @@
|
|
|
this.init();
|
|
|
};
|
|
|
|
|
|
- Selectpicker.VERSION = '1.12.2';
|
|
|
+ Selectpicker.VERSION = '1.12.4';
|
|
|
|
|
|
// part of this is duplicated in i18n/defaults-en_US.js. Make sure to update both.
|
|
|
Selectpicker.DEFAULTS = {
|
|
@@ -444,9 +454,7 @@
|
|
|
|
|
|
if (that.$element[0].hasAttribute('required')) {
|
|
|
this.$element.on('invalid', function () {
|
|
|
- that.$button
|
|
|
- .addClass('bs-invalid')
|
|
|
- .focus();
|
|
|
+ that.$button.addClass('bs-invalid');
|
|
|
|
|
|
that.$element.on({
|
|
|
'focus.bs.select': function () {
|
|
@@ -464,6 +472,11 @@
|
|
|
that.$element.off('rendered.bs.select');
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ that.$button.on('blur.bs.select', function() {
|
|
|
+ that.$element.focus().blur();
|
|
|
+ that.$button.off('blur.bs.select');
|
|
|
+ });
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -559,9 +572,9 @@
|
|
|
*/
|
|
|
var generateLI = function (content, index, classes, optgroup) {
|
|
|
return '<li' +
|
|
|
- ((typeof classes !== 'undefined' & '' !== classes) ? ' class="' + classes + '"' : '') +
|
|
|
- ((typeof index !== 'undefined' & null !== index) ? ' data-original-index="' + index + '"' : '') +
|
|
|
- ((typeof optgroup !== 'undefined' & null !== optgroup) ? 'data-optgroup="' + optgroup + '"' : '') +
|
|
|
+ ((typeof classes !== 'undefined' && '' !== classes) ? ' class="' + classes + '"' : '') +
|
|
|
+ ((typeof index !== 'undefined' && null !== index) ? ' data-original-index="' + index + '"' : '') +
|
|
|
+ ((typeof optgroup !== 'undefined' && null !== optgroup) ? 'data-optgroup="' + optgroup + '"' : '') +
|
|
|
'>' + content + '</li>';
|
|
|
};
|
|
|
|
|
@@ -605,7 +618,9 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- this.$element.find('option').each(function (index) {
|
|
|
+ var $selectOptions = this.$element.find('option');
|
|
|
+
|
|
|
+ $selectOptions.each(function (index) {
|
|
|
var $this = $(this);
|
|
|
|
|
|
liIndex++;
|
|
@@ -614,7 +629,7 @@
|
|
|
|
|
|
// Get the class and text for the option
|
|
|
var optionClass = this.className || '',
|
|
|
- inline = this.style.cssText,
|
|
|
+ inline = htmlEscape(this.style.cssText),
|
|
|
text = $this.data('content') ? $this.data('content') : $this.html(),
|
|
|
tokens = $this.data('tokens') ? $this.data('tokens') : null,
|
|
|
subtext = typeof $this.data('subtext') !== 'undefined' ? '<small class="text-muted">' + $this.data('subtext') + '</small>' : '',
|
|
@@ -622,13 +637,20 @@
|
|
|
$parent = $this.parent(),
|
|
|
isOptgroup = $parent[0].tagName === 'OPTGROUP',
|
|
|
isOptgroupDisabled = isOptgroup && $parent[0].disabled,
|
|
|
- isDisabled = this.disabled || isOptgroupDisabled;
|
|
|
+ isDisabled = this.disabled || isOptgroupDisabled,
|
|
|
+ prevHiddenIndex;
|
|
|
|
|
|
if (icon !== '' && isDisabled) {
|
|
|
icon = '<span>' + icon + '</span>';
|
|
|
}
|
|
|
|
|
|
if (that.options.hideDisabled && (isDisabled && !isOptgroup || isOptgroupDisabled)) {
|
|
|
+ // set prevHiddenIndex - the index of the first hidden option in a group of hidden options
|
|
|
+ // used to determine whether or not a divider should be placed after an optgroup if there are
|
|
|
+ // hidden options between the optgroup and the first visible option
|
|
|
+ prevHiddenIndex = $this.data('prevHiddenIndex');
|
|
|
+ $this.next().data('prevHiddenIndex', (prevHiddenIndex !== undefined ? prevHiddenIndex : index));
|
|
|
+
|
|
|
liIndex--;
|
|
|
return;
|
|
|
}
|
|
@@ -680,31 +702,26 @@
|
|
|
} else if ($this.data('divider') === true) {
|
|
|
_li.push(generateLI('', index, 'divider'));
|
|
|
} else if ($this.data('hidden') === true) {
|
|
|
+ // set prevHiddenIndex - the index of the first hidden option in a group of hidden options
|
|
|
+ // used to determine whether or not a divider should be placed after an optgroup if there are
|
|
|
+ // hidden options between the optgroup and the first visible option
|
|
|
+ prevHiddenIndex = $this.data('prevHiddenIndex');
|
|
|
+ $this.next().data('prevHiddenIndex', (prevHiddenIndex !== undefined ? prevHiddenIndex : index));
|
|
|
+
|
|
|
_li.push(generateLI(generateA(text, optionClass, inline, tokens), index, 'hidden is-hidden'));
|
|
|
} else {
|
|
|
var showDivider = this.previousElementSibling && this.previousElementSibling.tagName === 'OPTGROUP';
|
|
|
|
|
|
// if previous element is not an optgroup and hideDisabled is true
|
|
|
if (!showDivider && that.options.hideDisabled) {
|
|
|
- // get previous elements
|
|
|
- var $prev = $(this).prevAll();
|
|
|
-
|
|
|
- for (var i = 0; i < $prev.length; i++) {
|
|
|
- // find the first element in the previous elements that is an optgroup
|
|
|
- if ($prev[i].tagName === 'OPTGROUP') {
|
|
|
- var optGroupDistance = 0;
|
|
|
-
|
|
|
- // loop through the options in between the current option and the optgroup
|
|
|
- // and check if they are hidden or disabled
|
|
|
- for (var d = 0; d < i; d++) {
|
|
|
- var prevOption = $prev[d];
|
|
|
- if (prevOption.disabled || $(prevOption).data('hidden') === true) optGroupDistance++;
|
|
|
- }
|
|
|
-
|
|
|
- // if all of the options between the current option and the optgroup are hidden or disabled, show the divider
|
|
|
- if (optGroupDistance === i) showDivider = true;
|
|
|
-
|
|
|
- break;
|
|
|
+ prevHiddenIndex = $this.data('prevHiddenIndex');
|
|
|
+
|
|
|
+ if (prevHiddenIndex !== undefined) {
|
|
|
+ // select the element **before** the first hidden element in the group
|
|
|
+ var prevHidden = $selectOptions.eq(prevHiddenIndex)[0].previousElementSibling;
|
|
|
+
|
|
|
+ if (prevHidden && prevHidden.tagName === 'OPTGROUP' && !prevHidden.disabled) {
|
|
|
+ showDivider = true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -737,11 +754,12 @@
|
|
|
*/
|
|
|
render: function (updateLi) {
|
|
|
var that = this,
|
|
|
- notDisabled;
|
|
|
+ notDisabled,
|
|
|
+ $selectOptions = this.$element.find('option');
|
|
|
|
|
|
//Update the LI to match the SELECT
|
|
|
if (updateLi !== false) {
|
|
|
- this.$element.find('option').each(function (index) {
|
|
|
+ $selectOptions.each(function (index) {
|
|
|
var $lis = that.findLis().eq(that.liObj[index]);
|
|
|
|
|
|
that.setDisabled(index, this.disabled || this.parentNode.tagName === 'OPTGROUP' && this.parentNode.disabled, $lis);
|
|
@@ -753,7 +771,7 @@
|
|
|
|
|
|
this.tabIndex();
|
|
|
|
|
|
- var selectedItems = this.$element.find('option').map(function () {
|
|
|
+ var selectedItems = $selectOptions.map(function () {
|
|
|
if (this.selected) {
|
|
|
if (that.options.hideDisabled && (this.disabled || this.parentNode.tagName === 'OPTGROUP' && this.parentNode.disabled)) return;
|
|
|
|
|
@@ -785,7 +803,7 @@
|
|
|
var max = this.options.selectedTextFormat.split('>');
|
|
|
if ((max.length > 1 && selectedItems.length > max[1]) || (max.length == 1 && selectedItems.length >= 2)) {
|
|
|
notDisabled = this.options.hideDisabled ? ', [disabled]' : '';
|
|
|
- var totalCount = this.$element.find('option').not('[data-divider="true"], [data-hidden="true"]' + notDisabled).length,
|
|
|
+ var totalCount = $selectOptions.not('[data-divider="true"], [data-hidden="true"]' + notDisabled).length,
|
|
|
tr8nText = (typeof this.options.countSelectedText === 'function') ? this.options.countSelectedText(selectedItems.length, totalCount) : this.options.countSelectedText;
|
|
|
title = tr8nText.replace('{0}', selectedItems.length.toString()).replace('{1}', totalCount.toString());
|
|
|
}
|
|
@@ -1445,9 +1463,9 @@
|
|
|
var $searchBase = that.$lis.not('.is-hidden, .divider, .dropdown-header'),
|
|
|
$hideItems;
|
|
|
if (that.options.liveSearchNormalize) {
|
|
|
- $hideItems = $searchBase.find('a').not(':a' + that._searchStyle() + '("' + normalizeToBase(that.$searchbox.val()) + '")');
|
|
|
+ $hideItems = $searchBase.not(':a' + that._searchStyle() + '("' + normalizeToBase(that.$searchbox.val()) + '")');
|
|
|
} else {
|
|
|
- $hideItems = $searchBase.find('a').not(':' + that._searchStyle() + '("' + that.$searchbox.val() + '")');
|
|
|
+ $hideItems = $searchBase.not(':' + that._searchStyle() + '("' + that.$searchbox.val() + '")');
|
|
|
}
|
|
|
|
|
|
if ($hideItems.length === $searchBase.length) {
|
|
@@ -1455,7 +1473,7 @@
|
|
|
that.$menuInner.append($no_results);
|
|
|
that.$lis.addClass('hidden');
|
|
|
} else {
|
|
|
- $hideItems.parent().addClass('hidden');
|
|
|
+ $hideItems.addClass('hidden');
|
|
|
|
|
|
var $lisVisible = that.$lis.not('.hidden'),
|
|
|
$foundDiv;
|
|
@@ -1480,6 +1498,7 @@
|
|
|
if ($foundDiv) $foundDiv.addClass('hidden');
|
|
|
|
|
|
$searchBase.not('.hidden').first().addClass('active');
|
|
|
+ that.$menuInner.scrollTop(0);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -1561,11 +1580,6 @@
|
|
|
$items,
|
|
|
that = $parent.data('this'),
|
|
|
index,
|
|
|
- next,
|
|
|
- first,
|
|
|
- last,
|
|
|
- prev,
|
|
|
- nextPrev,
|
|
|
prevIndex,
|
|
|
isActive,
|
|
|
selector = ':not(.disabled, .hidden, .dropdown-header, .divider)',
|
|
@@ -1620,11 +1634,6 @@
|
|
|
105: '9'
|
|
|
};
|
|
|
|
|
|
- if (that.options.liveSearch) $parent = $this.parent().parent();
|
|
|
-
|
|
|
- if (that.options.container) $parent = that.$menu;
|
|
|
-
|
|
|
- $items = $('[role="listbox"] li', $parent);
|
|
|
|
|
|
isActive = that.$newElement.hasClass('open');
|
|
|
|
|
@@ -1647,60 +1656,29 @@
|
|
|
that.$menuInner.click();
|
|
|
that.$button.focus();
|
|
|
}
|
|
|
- // $items contains li elements when liveSearch is enabled
|
|
|
- $items = $('[role="listbox"] li' + selector, $parent);
|
|
|
- if (!$this.val() && !/(38|40)/.test(e.keyCode.toString(10))) {
|
|
|
- if ($items.filter('.active').length === 0) {
|
|
|
- $items = that.$menuInner.find('li');
|
|
|
- if (that.options.liveSearchNormalize) {
|
|
|
- $items = $items.filter(':a' + that._searchStyle() + '(' + normalizeToBase(keyCodeMap[e.keyCode]) + ')');
|
|
|
- } else {
|
|
|
- $items = $items.filter(':' + that._searchStyle() + '(' + keyCodeMap[e.keyCode] + ')');
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
- if (!$items.length) return;
|
|
|
-
|
|
|
if (/(38|40)/.test(e.keyCode.toString(10))) {
|
|
|
- index = $items.index($items.find('a').filter(':focus').parent());
|
|
|
- first = $items.filter(selector).first().index();
|
|
|
- last = $items.filter(selector).last().index();
|
|
|
- next = $items.eq(index).nextAll(selector).eq(0).index();
|
|
|
- prev = $items.eq(index).prevAll(selector).eq(0).index();
|
|
|
- nextPrev = $items.eq(next).prevAll(selector).eq(0).index();
|
|
|
+ $items = that.$lis.filter(selector);
|
|
|
+ if (!$items.length) return;
|
|
|
|
|
|
- if (that.options.liveSearch) {
|
|
|
- $items.each(function (i) {
|
|
|
- if (!$(this).hasClass('disabled')) {
|
|
|
- $(this).data('index', i);
|
|
|
- }
|
|
|
- });
|
|
|
+ if (!that.options.liveSearch) {
|
|
|
+ index = $items.index($items.find('a').filter(':focus').parent());
|
|
|
+ } else {
|
|
|
index = $items.index($items.filter('.active'));
|
|
|
- first = $items.first().data('index');
|
|
|
- last = $items.last().data('index');
|
|
|
- next = $items.eq(index).nextAll().eq(0).data('index');
|
|
|
- prev = $items.eq(index).prevAll().eq(0).data('index');
|
|
|
- nextPrev = $items.eq(next).prevAll().eq(0).data('index');
|
|
|
}
|
|
|
|
|
|
- prevIndex = $this.data('prevIndex');
|
|
|
+ prevIndex = that.$menuInner.data('prevIndex');
|
|
|
|
|
|
if (e.keyCode == 38) {
|
|
|
- if (that.options.liveSearch) index--;
|
|
|
- if (index != nextPrev && index > prev) index = prev;
|
|
|
- if (index < first) index = first;
|
|
|
- if (index == prevIndex) index = last;
|
|
|
+ if ((that.options.liveSearch || index == prevIndex) && index != -1) index--;
|
|
|
+ if (index < 0) index += $items.length;
|
|
|
} else if (e.keyCode == 40) {
|
|
|
- if (that.options.liveSearch) index++;
|
|
|
- if (index == -1) index = 0;
|
|
|
- if (index != nextPrev && index < next) index = next;
|
|
|
- if (index > last) index = last;
|
|
|
- if (index == prevIndex) index = first;
|
|
|
+ if (that.options.liveSearch || index == prevIndex) index++;
|
|
|
+ index = index % $items.length;
|
|
|
}
|
|
|
|
|
|
- $this.data('prevIndex', index);
|
|
|
+ that.$menuInner.data('prevIndex', index);
|
|
|
|
|
|
if (!that.options.liveSearch) {
|
|
|
$items.eq(index).children('a').focus();
|
|
@@ -1717,11 +1695,10 @@
|
|
|
count,
|
|
|
prevKey;
|
|
|
|
|
|
- $items.each(function () {
|
|
|
- if (!$(this).hasClass('disabled')) {
|
|
|
- if ($.trim($(this).children('a').text().toLowerCase()).substring(0, 1) == keyCodeMap[e.keyCode]) {
|
|
|
- keyIndex.push($(this).index());
|
|
|
- }
|
|
|
+ $items = that.$lis.filter(selector);
|
|
|
+ $items.each(function (i) {
|
|
|
+ if ($.trim($(this).children('a').text().toLowerCase()).substring(0, 1) == keyCodeMap[e.keyCode]) {
|
|
|
+ keyIndex.push(i);
|
|
|
}
|
|
|
});
|
|
|
|