Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*!
- * Bootstrap-select v1.6.5 (http://silviomoreto.github.io/bootstrap-select)
- *
- * Copyright 2013-2015 bootstrap-select
- * Licensed under MIT (https://github.com/silviomoreto/bootstrap-select/blob/master/LICENSE)
- */
- ! function(a) {
- "use strict";
- function b(b) {
- var c = [{
- re: /[\xC0-\xC6]/g,
- ch: "A"
- }, {
- re: /[\xE0-\xE6]/g,
- ch: "a"
- }, {
- re: /[\xC8-\xCB]/g,
- ch: "E"
- }, {
- re: /[\xE8-\xEB]/g,
- ch: "e"
- }, {
- re: /[\xCC-\xCF]/g,
- ch: "I"
- }, {
- re: /[\xEC-\xEF]/g,
- ch: "i"
- }, {
- re: /[\xD2-\xD6]/g,
- ch: "O"
- }, {
- re: /[\xF2-\xF6]/g,
- ch: "o"
- }, {
- re: /[\xD9-\xDC]/g,
- ch: "U"
- }, {
- re: /[\xF9-\xFC]/g,
- ch: "u"
- }, {
- re: /[\xC7-\xE7]/g,
- ch: "c"
- }, {
- re: /[\xD1]/g,
- ch: "N"
- }, {
- re: /[\xF1]/g,
- ch: "n"
- }];
- return a.each(c, function() {
- b = b.replace(this.re, this.ch)
- }), b
- }
- function c(a) {
- var b = {
- "&": "&",
- "<": "<",
- ">": ">",
- '"': """,
- "'": "'",
- "`": "`"
- },
- c = "(?:" + Object.keys(b).join("|") + ")",
- d = new RegExp(c),
- e = new RegExp(c, "g"),
- f = null == a ? "" : "" + a;
- return d.test(f) ? f.replace(e, function(a) {
- return b[a]
- }) : f
- }
- function d(b, c) {
- var d = arguments,
- f = b,
- g = c;
- [].shift.apply(d);
- var h, i = this.each(function() {
- var b = a(this);
- if (b.is("select")) {
- var c = b.data("selectpicker"),
- i = "object" == typeof f && f;
- if (c) {
- if (i)
- for (var j in i) i.hasOwnProperty(j) && (c.options[j] = i[j])
- } else {
- var k = a.extend({}, e.DEFAULTS, a.fn.selectpicker.defaults || {}, b.data(), i);
- b.data("selectpicker", c = new e(this, k, g))
- }
- "string" == typeof f && (h = c[f] instanceof Function ? c[f].apply(c, d) : c.options[f])
- }
- });
- return "undefined" != typeof h ? h : i
- }
- String.prototype.includes || ! function() {
- var a = {}.toString,
- b = function() {
- try {
- var a = {},
- b = Object.defineProperty,
- c = b(a, a, a) && b
- } catch (d) {}
- return c
- }(),
- c = "".indexOf,
- d = function(b) {
- if (null == this) throw TypeError();
- var d = String(this);
- if (b && "[object RegExp]" == a.call(b)) throw TypeError();
- var e = d.length,
- f = String(b),
- g = f.length,
- h = arguments.length > 1 ? arguments[1] : void 0,
- i = h ? Number(h) : 0;
- i != i && (i = 0);
- var j = Math.min(Math.max(i, 0), e);
- return g + j > e ? !1 : -1 != c.call(d, f, i)
- };
- b ? b(String.prototype, "includes", {
- value: d,
- configurable: !0,
- writable: !0
- }) : String.prototype.includes = d
- }(), String.prototype.startsWith || ! function() {
- var a = function() {
- try {
- var a = {},
- b = Object.defineProperty,
- c = b(a, a, a) && b
- } catch (d) {}
- return c
- }(),
- b = {}.toString,
- c = function(a) {
- if (null == this) throw TypeError();
- var c = String(this);
- if (a && "[object RegExp]" == b.call(a)) throw TypeError();
- var d = c.length,
- e = String(a),
- f = e.length,
- g = arguments.length > 1 ? arguments[1] : void 0,
- h = g ? Number(g) : 0;
- h != h && (h = 0);
- var i = Math.min(Math.max(h, 0), d);
- if (f + i > d) return !1;
- for (var j = -1; ++j < f;)
- if (c.charCodeAt(i + j) != e.charCodeAt(j)) return !1;
- return !0
- };
- a ? a(String.prototype, "startsWith", {
- value: c,
- configurable: !0,
- writable: !0
- }) : String.prototype.startsWith = c
- }(), a.expr[":"].icontains = function(b, c, d) {
- var e = a(b),
- f = (e.data("tokens") || e.text()).toUpperCase();
- return f.includes(d[3].toUpperCase())
- }, a.expr[":"].ibegins = function(b, c, d) {
- var e = a(b),
- f = (e.data("tokens") || e.text()).toUpperCase();
- return f.startsWith(d[3].toUpperCase())
- }, a.expr[":"].aicontains = function(b, c, d) {
- var e = a(b),
- f = (e.data("tokens") || e.data("normalizedText") || e.text()).toUpperCase();
- return f.includes(f, d[3])
- }, a.expr[":"].aibegins = function(b, c, d) {
- var e = a(b),
- f = (e.data("tokens") || e.data("normalizedText") || e.text()).toUpperCase();
- return f.startsWith(d[3].toUpperCase())
- };
- var e = function(b, c, d) {
- d && (d.stopPropagation(), d.preventDefault()), this.$element = a(b), this.$newElement = null, this.$button = null, this.$menu = null, this.$lis = null, this.options = c, null === this.options.title && (this.options.title = this.$element.attr("title")), this.val = e.prototype.val, this.render = e.prototype.render, this.refresh = e.prototype.refresh, this.setStyle = e.prototype.setStyle, this.selectAll = e.prototype.selectAll, this.deselectAll = e.prototype.deselectAll, this.destroy = e.prototype.remove, this.remove = e.prototype.remove, this.show = e.prototype.show, this.hide = e.prototype.hide, this.init()
- };
- e.VERSION = "1.6.5", e.DEFAULTS = {
- noneSelectedText: "Nothing selected",
- noneResultsText: "No results matched {0}",
- countSelectedText: function(a) {
- return 1 == a ? "{0} item selected" : "{0} items selected"
- },
- maxOptionsText: function(a, b) {
- return [1 == a ? "Limit reached ({n} item max)" : "Limit reached ({n} items max)", 1 == b ? "Group limit reached ({n} item max)" : "Group limit reached ({n} items max)"]
- },
- selectAllText: "Select All",
- deselectAllText: "Deselect All",
- doneButton: !1,
- doneButtonText: "Close",
- multipleSeparator: ", ",
- style: "btn-default",
- 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: "glyphicon",
- tickIcon: "glyphicon-ok",
- maxOptions: !1,
- mobile: !1,
- selectOnTab: !1,
- dropdownAlignRight: !1
- }, e.prototype = {
- constructor: e,
- init: function() {
- var b = this,
- c = this.$element.attr("id");
- this.$element.hide(), this.multiple = this.$element.prop("multiple"), this.autofocus = this.$element.prop("autofocus"), this.$newElement = this.createView(), this.$element.after(this.$newElement), this.$button = this.$newElement.children("button"), this.$menu = this.$newElement.children(".dropdown-menu"), this.$searchbox = this.$menu.find("input"), this.options.dropdownAlignRight && this.$menu.addClass("dropdown-menu-right"), "undefined" != typeof c && (this.$button.attr("data-id", c), a('label[for="' + c + '"]').click(function(a) {
- a.preventDefault(), b.$button.focus()
- })), this.checkDisabled(), this.clickListener(), this.options.liveSearch && this.liveSearchListener(), this.render(), this.liHeight(), this.setStyle(), this.setWidth(), this.options.container && this.selectPosition(), this.$menu.data("this", this), this.$newElement.data("this", this), this.options.mobile && this.mobile()
- },
- createDropdown: function() {
- var b = this.multiple ? " show-tick" : "",
- d = this.$element.parent().hasClass("input-group") ? " input-group-btn" : "",
- e = this.autofocus ? " autofocus" : "",
- f = this.options.header ? '<div class="popover-title"><button type="button" class="close" aria-hidden="true">×</button>' + this.options.header + "</div>" : "",
- g = this.options.liveSearch ? '<div class="bs-searchbox"><input type="text" class="form-control" autocomplete="off"' + (null === this.options.liveSearchPlaceholder ? "" : ' placeholder="' + c(this.options.liveSearchPlaceholder) + '"') + "></div>" : "",
- h = this.multiple && this.options.actionsBox ? '<div class="bs-actionsbox"><div class="btn-group btn-group-sm btn-block"><button class="actions-btn bs-select-all btn btn-default">' + this.options.selectAllText + '</button><button class="actions-btn bs-deselect-all btn btn-default">' + this.options.deselectAllText + "</button></div></div>" : "",
- i = this.multiple && this.options.doneButton ? '<div class="bs-donebutton"><div class="btn-group btn-block"><button class="btn btn-sm btn-default">' + this.options.doneButtonText + "</button></div></div>" : "",
- j = '<div class="btn-group bootstrap-select' + b + d + '"><button type="button" class="btn dropdown-toggle" data-toggle="dropdown"' + e + '><span class="filter-option pull-left"></span> <span class="caret"></span></button><div class="dropdown-menu open">' + f + g + h + '<ul class="dropdown-menu inner" role="menu"></ul>' + i + "</div></div>";
- return a(j)
- },
- createView: function() {
- var a = this.createDropdown(),
- b = this.createLi();
- return a.find("ul").append(b), a
- },
- reloadLi: function() {
- this.destroyLi();
- var a = this.createLi();
- this.$menu.find("ul").append(a)
- },
- destroyLi: function() {
- this.$menu.find("li").remove()
- },
- createLi: function() {
- var d = this,
- e = [],
- f = 0,
- g = function(a, b, c, d) {
- return "<li" + ("undefined" != typeof c & "" !== c ? ' class="' + c + '"' : "") + ("undefined" != typeof b & null !== b ? ' data-original-index="' + b + '"' : "") + ("undefined" != typeof d & null !== d ? 'data-optgroup="' + d + '"' : "") + ">" + a + "</li>"
- },
- h = function(a, e, f, g) {
- return '<a tabindex="0"' + ("undefined" != typeof e ? ' class="' + e + '"' : "") + ("undefined" != typeof f ? ' style="' + f + '"' : "") + ' data-normalized-text="' + b(c(a)) + '"' + ("undefined" != typeof g || null !== g ? ' data-tokens="' + g + '"' : "") + ">" + a + '<span class="' + d.options.iconBase + " " + d.options.tickIcon + ' check-mark"></span></a>'
- };
- return this.$element.find("option").each(function(b) {
- var c = a(this),
- i = c.attr("class") || "",
- j = c.attr("style"),
- k = c.data("content") ? c.data("content") : c.html(),
- l = c.data("tokens") ? c.data("tokens") : null,
- m = "undefined" != typeof c.data("subtext") ? '<small class="text-muted">' + c.data("subtext") + "</small>" : "",
- n = "undefined" != typeof c.data("icon") ? '<span class="' + d.options.iconBase + " " + c.data("icon") + '"></span> ' : "",
- o = c.is(":disabled") || c.parent().is(":disabled");
- if ("" !== n && o && (n = "<span>" + n + "</span>"), c.data("content") || (k = n + '<span class="text">' + k + m + "</span>"), !d.options.hideDisabled || !o)
- if (c.parent().is("optgroup") && c.data("divider") !== !0) {
- if (0 === c.index()) {
- f += 1;
- var p = c.parent().attr("label"),
- q = "undefined" != typeof c.parent().data("subtext") ? '<small class="text-muted">' + c.parent().data("subtext") + "</small>" : "",
- r = c.parent().data("icon") ? '<span class="' + d.options.iconBase + " " + c.parent().data("icon") + '"></span> ' : "";
- p = r + '<span class="text">' + p + q + "</span>", 0 !== b && e.length > 0 && e.push(g("", null, "divider", f + "div")), e.push(g(p, null, "dropdown-header", f))
- }
- e.push(g(h(k, "opt " + i, j, l), b, "", f))
- } else c.data("divider") === !0 ? e.push(g("", b, "divider")) : c.data("hidden") === !0 ? e.push(g(h(k, i, j, l), b, "hidden is-hidden")) : (c.prev().is("optgroup") && e.push(g("", null, "divider", f + "div")), e.push(g(h(k, i, j, l), b)))
- }), this.multiple || 0 !== this.$element.find("option:selected").length || this.options.title || this.$element.find("option").eq(0).prop("selected", !0).attr("selected", "selected"), a(e.join(""))
- },
- findLis: function() {
- return null == this.$lis && (this.$lis = this.$menu.find("li")), this.$lis
- },
- render: function(b) {
- var c = this;
- b !== !1 && this.$element.find("option").each(function(b) {
- c.setDisabled(b, a(this).is(":disabled") || a(this).parent().is(":disabled")), c.setSelected(b, a(this).is(":selected"))
- }), this.tabIndex();
- var d = this.options.hideDisabled ? ":enabled" : "",
- e = this.$element.find("option:selected" + d).map(function() {
- var b, d = a(this),
- e = d.data("icon") && c.options.showIcon ? '<i class="' + c.options.iconBase + " " + d.data("icon") + '"></i> ' : "";
- return b = c.options.showSubtext && d.data("subtext") && !c.multiple ? ' <small class="text-muted">' + d.data("subtext") + "</small>" : "", "undefined" != typeof d.attr("title") ? d.attr("title") : d.data("content") && c.options.showContent ? d.data("content") : e + d.html() + b
- }).toArray(),
- f = this.multiple ? e.join(this.options.multipleSeparator) : e[0];
- if (this.multiple && this.options.selectedTextFormat.indexOf("count") > -1) {
- var g = this.options.selectedTextFormat.split(">");
- if (g.length > 1 && e.length > g[1] || 1 == g.length && e.length >= 2) {
- d = this.options.hideDisabled ? ", [disabled]" : "";
- var h = this.$element.find("option").not('[data-divider="true"], [data-hidden="true"]' + d).length,
- i = "function" == typeof this.options.countSelectedText ? this.options.countSelectedText(e.length, h) : this.options.countSelectedText;
- f = i.replace("{0}", e.length.toString()).replace("{1}", h.toString())
- }
- }
- void 0 == this.options.title && (this.options.title = this.$element.attr("title")), "static" == this.options.selectedTextFormat && (f = this.options.title), f || (f = "undefined" != typeof this.options.title ? this.options.title : this.options.noneSelectedText), this.$button.attr("title", a.trim(f.replace(/<[^>]*>?/g, ""))), this.$button.children(".filter-option").html(f)
- },
- setStyle: function(a, b) {
- this.$element.attr("class") && this.$newElement.addClass(this.$element.attr("class").replace(/selectpicker|mobile-device|validate\[.*\]/gi, ""));
- var c = a ? a : this.options.style;
- "add" == b ? this.$button.addClass(c) : "remove" == b ? this.$button.removeClass(c) : (this.$button.removeClass(this.options.style), this.$button.addClass(c))
- },
- liHeight: function() {
- if (this.options.size !== !1) {
- var a = this.$menu.parent().clone().children(".dropdown-toggle").prop("autofocus", !1).end().appendTo("body"),
- b = a.addClass("open").children(".dropdown-menu"),
- c = b.find("li").not(".divider, .dropdown-header").filter(":visible").children("a").outerHeight(),
- d = this.options.header ? b.find(".popover-title").outerHeight() : 0,
- e = this.options.liveSearch ? b.find(".bs-searchbox").outerHeight() : 0,
- f = this.options.actionsBox ? b.find(".bs-actionsbox").outerHeight() : 0,
- g = this.multiple ? b.find(".bs-donebutton").outerHeight() : 0;
- a.remove(), this.$newElement.data("liHeight", c).data("headerHeight", d).data("searchHeight", e).data("actionsHeight", f).data("doneButtonHeight", g)
- }
- },
- setSize: function() {
- this.findLis();
- var b, c, d, e = this,
- f = this.$menu,
- g = f.children(".inner"),
- h = this.$newElement.outerHeight(),
- i = this.$newElement.data("liHeight"),
- j = this.$newElement.data("headerHeight"),
- k = this.$newElement.data("searchHeight"),
- l = this.$newElement.data("actionsHeight"),
- m = this.$newElement.data("doneButtonHeight"),
- n = this.$lis.filter(".divider").outerHeight(!0),
- o = parseInt(f.css("padding-top")) + parseInt(f.css("padding-bottom")) + parseInt(f.css("border-top-width")) + parseInt(f.css("border-bottom-width")),
- p = this.options.hideDisabled ? ".disabled" : "",
- q = a(window),
- r = o + parseInt(f.css("margin-top")) + parseInt(f.css("margin-bottom")) + 2,
- s = function() {
- c = e.$newElement.offset().top - q.scrollTop(), d = q.height() - c - h
- };
- if (s(), this.options.header && f.css("padding-top", 0), "auto" == this.options.size) {
- var t = function() {
- var a, h = e.$lis.not(".hidden");
- s(), b = d - r, e.options.dropupAuto && e.$newElement.toggleClass("dropup", c > d && b - r < f.height()), e.$newElement.hasClass("dropup") && (b = c - r), a = h.length + h.filter(".dropdown-header").length > 3 ? 3 * i + r - 2 : 0, f.css({
- "max-height": b + "px",
- overflow: "hidden",
- "min-height": a + j + k + l + m + "px"
- }), g.css({
- "max-height": b - j - k - l - m - o + "px",
- "overflow-y": "auto",
- "min-height": Math.max(a - o, 0) + "px"
- })
- };
- t(), this.$searchbox.off("input.getSize propertychange.getSize").on("input.getSize propertychange.getSize", t), q.off("resize.getSize scroll.getSize").on("resize.getSize scroll.getSize", t)
- } else if (this.options.size && "auto" != this.options.size && f.find("li").not(p).length > this.options.size) {
- var u = this.$lis.not(".divider").not(p).children().slice(0, this.options.size).last().parent().index(),
- v = this.$lis.slice(0, u + 1).filter(".divider").length;
- b = i * this.options.size + v * n + o, e.options.dropupAuto && this.$newElement.toggleClass("dropup", c > d && b < f.height()), f.css({
- "max-height": b + j + k + l + m + "px",
- overflow: "hidden"
- }), g.css({
- "max-height": b - o + "px",
- "overflow-y": "auto"
- })
- }
- },
- setWidth: function() {
- if ("auto" == this.options.width) {
- this.$menu.css("min-width", "0");
- var a = this.$newElement.clone().appendTo("body"),
- b = a.children(".dropdown-menu").css("width"),
- c = a.css("width", "auto").children("button").css("width");
- a.remove(), this.$newElement.css("width", Math.max(parseInt(b), parseInt(c)) + "px")
- } else "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.removeClass("fit-width")
- },
- selectPosition: function() {
- var b, c, d = this,
- e = "<div />",
- f = a(e),
- g = function(a) {
- f.addClass(a.attr("class").replace(/form-control/gi, "")).toggleClass("dropup", a.hasClass("dropup")), b = a.offset(), c = a.hasClass("dropup") ? 0 : a[0].offsetHeight, f.css({
- top: b.top + c,
- left: b.left,
- width: a[0].offsetWidth,
- position: "absolute"
- })
- };
- this.$newElement.on("click", function() {
- d.isDisabled() || (g(a(this)), f.appendTo(d.options.container), f.toggleClass("open", !a(this).hasClass("open")), f.append(d.$menu))
- }), a(window).on("resize scroll", function() {
- g(d.$newElement)
- }), a("html").on("click", function(b) {
- a(b.target).closest(d.$newElement).length < 1 && f.removeClass("open")
- })
- },
- setSelected: function(a, b) {
- this.findLis(), this.$lis.filter('[data-original-index="' + a + '"]').toggleClass("selected", b)
- },
- setDisabled: function(a, b) {
- this.findLis(), b ? this.$lis.filter('[data-original-index="' + a + '"]').addClass("disabled").children("a").attr("href", "#").attr("tabindex", -1) : this.$lis.filter('[data-original-index="' + a + '"]').removeClass("disabled").children("a").removeAttr("href").attr("tabindex", 0)
- },
- isDisabled: function() {
- return this.$element.is(":disabled")
- },
- checkDisabled: function() {
- var a = this;
- this.isDisabled() ? this.$button.addClass("disabled").attr("tabindex", -1) : (this.$button.hasClass("disabled") && this.$button.removeClass("disabled"), -1 != this.$button.attr("tabindex") || this.$element.data("tabindex") || this.$button.removeAttr("tabindex")), this.$button.click(function() {
- return !a.isDisabled()
- })
- },
- tabIndex: function() {
- this.$element.is("[tabindex]") && (this.$element.data("tabindex", this.$element.attr("tabindex")), this.$button.attr("tabindex", this.$element.data("tabindex")))
- },
- clickListener: function() {
- var b = this;
- this.$newElement.on("touchstart.dropdown", ".dropdown-menu", function(a) {
- a.stopPropagation()
- }), this.$newElement.on("click", function() {
- b.setSize(), b.options.liveSearch || b.multiple || setTimeout(function() {
- b.$menu.find(".selected a").focus()
- }, 10)
- }), this.$menu.on("click", "li a", function(c) {
- var d = a(this),
- e = d.parent().data("originalIndex"),
- f = b.$element.val(),
- g = b.$element.prop("selectedIndex");
- if (b.multiple && c.stopPropagation(), c.preventDefault(), !b.isDisabled() && !d.parent().hasClass("disabled")) {
- var h = b.$element.find("option"),
- i = h.eq(e),
- j = i.prop("selected"),
- k = i.parent("optgroup"),
- l = b.options.maxOptions,
- m = k.data("maxOptions") || !1;
- if (b.multiple) {
- if (i.prop("selected", !j), b.setSelected(e, !j), d.blur(), l !== !1 || m !== !1) {
- var n = l < h.filter(":selected").length,
- o = m < k.find("option:selected").length;
- if (l && n || m && o)
- if (l && 1 == l) h.prop("selected", !1), i.prop("selected", !0), b.$menu.find(".selected").removeClass("selected"), b.setSelected(e, !0);
- else if (m && 1 == m) {
- k.find("option:selected").prop("selected", !1), i.prop("selected", !0);
- var p = d.data("optgroup");
- b.$menu.find(".selected").has('a[data-optgroup="' + p + '"]').removeClass("selected"), b.setSelected(e, !0)
- } else {
- var q = "function" == typeof b.options.maxOptionsText ? b.options.maxOptionsText(l, m) : b.options.maxOptionsText,
- r = q[0].replace("{n}", l),
- s = q[1].replace("{n}", m),
- t = a('<div class="notify"></div>');
- q[2] && (r = r.replace("{var}", q[2][l > 1 ? 0 : 1]), s = s.replace("{var}", q[2][m > 1 ? 0 : 1])), i.prop("selected", !1), b.$menu.append(t), l && n && (t.append(a("<div>" + r + "</div>")), b.$element.trigger("maxReached.bs.select")), m && o && (t.append(a("<div>" + s + "</div>")), b.$element.trigger("maxReachedGrp.bs.select")), setTimeout(function() {
- b.setSelected(e, !1)
- }, 10), t.delay(750).fadeOut(300, function() {
- a(this).remove()
- })
- }
- }
- } else h.prop("selected", !1), i.prop("selected", !0), b.$menu.find(".selected").removeClass("selected"), b.setSelected(e, !0);
- b.multiple ? b.options.liveSearch && b.$searchbox.focus() : b.$button.focus(), (f != b.$element.val() && b.multiple || g != b.$element.prop("selectedIndex") && !b.multiple) && b.$element.change()
- }
- }), this.$menu.on("click", "li.disabled a, .popover-title, .popover-title :not(.close)", function(a) {
- a.currentTarget == this && (a.preventDefault(), a.stopPropagation(), b.options.liveSearch ? b.$searchbox.focus() : b.$button.focus())
- }), this.$menu.on("click", "li.divider, li.dropdown-header", function(a) {
- a.preventDefault(), a.stopPropagation(), b.options.liveSearch ? b.$searchbox.focus() : b.$button.focus()
- }), this.$menu.on("click", ".popover-title .close", function() {
- b.$button.focus()
- }), this.$searchbox.on("click", function(a) {
- a.stopPropagation()
- }), this.$menu.on("click", ".actions-btn", function(c) {
- b.options.liveSearch ? b.$searchbox.focus() : b.$button.focus(), c.preventDefault(), c.stopPropagation(), a(this).hasClass("bs-select-all") ? b.selectAll() : b.deselectAll(), b.$element.change()
- }), this.$element.change(function() {
- b.render(!1)
- })
- },
- liveSearchListener: function() {
- var d = this,
- e = a('<li class="no-results"></li>');
- this.$newElement.on("click.dropdown.data-api touchstart.dropdown.data-api", function() {
- d.$menu.find(".active").removeClass("active"), d.$searchbox.val() && (d.$searchbox.val(""), d.$lis.not(".is-hidden").removeClass("hidden"), e.parent().length && e.remove()), d.multiple || d.$menu.find(".selected").addClass("active"), setTimeout(function() {
- d.$searchbox.focus()
- }, 10)
- }), this.$searchbox.on("click.dropdown.data-api focus.dropdown.data-api touchend.dropdown.data-api", function(a) {
- a.stopPropagation()
- }), this.$searchbox.on("input propertychange", function() {
- if (d.$searchbox.val()) {
- var f = d.$lis.not(".is-hidden").removeClass("hidden").children("a");
- f = f.not(d.options.liveSearchNormalize ? ":a" + d._searchStyle() + "(" + b(d.$searchbox.val()) + ")" : ":" + d._searchStyle() + "(" + d.$searchbox.val() + ")"), f.parent().addClass("hidden"), d.$lis.filter(".dropdown-header").each(function() {
- var b = a(this),
- c = b.data("optgroup");
- 0 === d.$lis.filter("[data-optgroup=" + c + "]").not(b).not(".hidden").length && (b.addClass("hidden"), d.$lis.filter("[data-optgroup=" + c + "div]").addClass("hidden"))
- });
- var g = d.$lis.not(".hidden");
- g.each(function(b) {
- var c = a(this);
- c.hasClass("divider") && (c.index() === g.eq(0).index() || c.index() === g.last().index() || g.eq(b + 1).hasClass("divider")) && c.addClass("hidden")
- }), d.$lis.not(".hidden, .no-results").length ? e.parent().length && e.remove() : (e.parent().length && e.remove(), e.html(d.options.noneResultsText.replace("{0}", '"' + c(d.$searchbox.val()) + '"')).show(), d.$menu.append(e))
- } else d.$lis.not(".is-hidden").removeClass("hidden"), e.parent().length && e.remove();
- d.$lis.filter(".active").removeClass("active"), d.$lis.not(".hidden, .divider, .dropdown-header").eq(0).addClass("active").children("a").focus(), a(this).focus()
- })
- },
- _searchStyle: function() {
- var a = "icontains";
- switch (this.options.liveSearchStyle) {
- case "begins":
- case "startsWith":
- a = "ibegins";
- break;
- case "contains":
- }
- return a
- },
- val: function(a) {
- return "undefined" != typeof a ? (this.$element.val(a), this.render(), this.$element) : this.$element.val()
- },
- selectAll: function() {
- this.findLis(), this.$element.find("option:enabled").not("[data-divider], [data-hidden]").prop("selected", !0), this.$lis.not(".divider, .dropdown-header, .disabled, .hidden").addClass("selected"), this.render(!1)
- },
- deselectAll: function() {
- this.findLis(), this.$element.find("option:enabled").not("[data-divider], [data-hidden]").prop("selected", !1), this.$lis.not(".divider, .dropdown-header, .disabled, .hidden").removeClass("selected"), this.render(!1)
- },
- keydown: function(c) {
- var d, e, f, g, h, i, j, k, l, m = a(this),
- n = m.is("input") ? m.parent().parent() : m.parent(),
- o = n.data("this"),
- p = {
- 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"
- };
- if (o.options.liveSearch && (n = m.parent().parent()), o.options.container && (n = o.$menu), d = a("[role=menu] li a", n), l = o.$menu.parent().hasClass("open"), !l && /([0-9]|[A-z])/.test(String.fromCharCode(c.keyCode)) && (o.options.container ? o.$newElement.trigger("click") : (o.setSize(), o.$menu.parent().addClass("open"), l = !0), o.$searchbox.focus()), o.options.liveSearch && (/(^9$|27)/.test(c.keyCode.toString(10)) && l && 0 === o.$menu.find(".active").length && (c.preventDefault(), o.$menu.parent().removeClass("open"), o.$button.focus()), d = a("[role=menu] li:not(.divider):not(.dropdown-header):visible a", n), m.val() || /(38|40)/.test(c.keyCode.toString(10)) || 0 === d.filter(".active").length && (d = o.$newElement.find("li a"), d = d.filter(o.options.liveSearchNormalize ? ":a" + o._searchStyle() + "(" + b(p[c.keyCode]) + ")" : ":" + o._searchStyle() + "(" + p[c.keyCode] + ")"))), d.length) {
- if (/(38|40)/.test(c.keyCode.toString(10))) e = d.index(d.filter(":focus")), g = d.parent(":not(.disabled):visible").first().index(), h = d.parent(":not(.disabled):visible").last().index(), f = d.eq(e).parent().nextAll(":not(.disabled):visible").eq(0).index(), i = d.eq(e).parent().prevAll(":not(.disabled):visible").eq(0).index(), j = d.eq(f).parent().prevAll(":not(.disabled):visible").eq(0).index(), o.options.liveSearch && (d.each(function(b) {
- a(this).hasClass("disabled") || a(this).data("index", b)
- }), e = d.index(d.filter(".active")), g = d.filter(":not(.disabled):visible").first().data("index"), h = d.filter(":not(.disabled):visible").last().data("index"), f = d.eq(e).nextAll(":not(.disabled):visible").eq(0).data("index"), i = d.eq(e).prevAll(":not(.disabled):visible").eq(0).data("index"), j = d.eq(f).prevAll(":not(.disabled):visible").eq(0).data("index")), k = m.data("prevIndex"), 38 == c.keyCode ? (o.options.liveSearch && (e -= 1), e != j && e > i && (e = i), g > e && (e = g), e == k && (e = h)) : 40 == c.keyCode && (o.options.liveSearch && (e += 1), -1 == e && (e = 0), e != j && f > e && (e = f), e > h && (e = h), e == k && (e = g)), m.data("prevIndex", e), o.options.liveSearch ? (c.preventDefault(), m.hasClass("dropdown-toggle") || (d.removeClass("active"), d.eq(e).addClass("active").children("a").focus(), m.focus())) : d.eq(e).focus();
- else if (!m.is("input")) {
- var q, r, s = [];
- d.each(function() {
- a(this).parent().hasClass("disabled") || a.trim(a(this).text().toLowerCase()).substring(0, 1) == p[c.keyCode] && s.push(a(this).parent().index())
- }), q = a(document).data("keycount"), q++, a(document).data("keycount", q), r = a.trim(a(":focus").text().toLowerCase()).substring(0, 1), r != p[c.keyCode] ? (q = 1, a(document).data("keycount", q)) : q >= s.length && (a(document).data("keycount", 0), q > s.length && (q = 1)), d.eq(s[q - 1]).focus()
- }
- if ((/(13|32)/.test(c.keyCode.toString(10)) || /(^9$)/.test(c.keyCode.toString(10)) && o.options.selectOnTab) && l) {
- if (/(32)/.test(c.keyCode.toString(10)) || c.preventDefault(), o.options.liveSearch) / (32) / .test(c.keyCode.toString(10)) || (o.$menu.find(".active a").click(), m.focus());
- else {
- var t = a(":focus");
- t.click(), t.focus(), c.preventDefault()
- }
- a(document).data("keycount", 0)
- }(/(^9$|27)/.test(c.keyCode.toString(10)) && l && (o.multiple || o.options.liveSearch) || /(27)/.test(c.keyCode.toString(10)) && !l) && (o.$menu.parent().removeClass("open"), o.$button.focus())
- }
- },
- mobile: function() {
- this.$element.addClass("mobile-device").appendTo(this.$newElement), this.options.container && this.$menu.hide()
- },
- refresh: function() {
- this.$lis = null, this.reloadLi(), this.render(), this.setWidth(), this.setStyle(), this.checkDisabled(), this.liHeight()
- },
- hide: function() {
- this.$newElement.hide()
- },
- show: function() {
- this.$newElement.show()
- },
- remove: function() {
- this.$newElement.remove(), this.$element.remove()
- }
- };
- var f = a.fn.selectpicker;
- a.fn.selectpicker = d, a.fn.selectpicker.Constructor = e, a.fn.selectpicker.noConflict = function() {
- return a.fn.selectpicker = f, this
- }, a(document).data("keycount", 0).on("keydown", ".bootstrap-select [data-toggle=dropdown], .bootstrap-select [role=menu], .bs-searchbox input", e.prototype.keydown).on("focusin.modal", ".bootstrap-select [data-toggle=dropdown], .bootstrap-select [role=menu], .bs-searchbox input", function(a) {
- a.stopPropagation()
- }), a(window).on("load.bs.select.data-api", function() {
- a(".selectpicker").each(function() {
- var b = a(this);
- d.call(b, b.data())
- })
- })
- }(jQuery);
- //# sourceMappingURL=bootstrap-select.js.map
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement