Advertisement
Guest User

Untitled

a guest
May 23rd, 2015
490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 37.84 KB | None | 0 0
  1. /*!
  2.  * Bootstrap-select v1.6.5 (http://silviomoreto.github.io/bootstrap-select)
  3.  *
  4.  * Copyright 2013-2015 bootstrap-select
  5.  * Licensed under MIT (https://github.com/silviomoreto/bootstrap-select/blob/master/LICENSE)
  6.  */
  7. ! function(a) {
  8.     "use strict";
  9.  
  10.     function b(b) {
  11.         var c = [{
  12.             re: /[\xC0-\xC6]/g,
  13.             ch: "A"
  14.         }, {
  15.             re: /[\xE0-\xE6]/g,
  16.             ch: "a"
  17.         }, {
  18.             re: /[\xC8-\xCB]/g,
  19.             ch: "E"
  20.         }, {
  21.             re: /[\xE8-\xEB]/g,
  22.             ch: "e"
  23.         }, {
  24.             re: /[\xCC-\xCF]/g,
  25.             ch: "I"
  26.         }, {
  27.             re: /[\xEC-\xEF]/g,
  28.             ch: "i"
  29.         }, {
  30.             re: /[\xD2-\xD6]/g,
  31.             ch: "O"
  32.         }, {
  33.             re: /[\xF2-\xF6]/g,
  34.             ch: "o"
  35.         }, {
  36.             re: /[\xD9-\xDC]/g,
  37.             ch: "U"
  38.         }, {
  39.             re: /[\xF9-\xFC]/g,
  40.             ch: "u"
  41.         }, {
  42.             re: /[\xC7-\xE7]/g,
  43.             ch: "c"
  44.         }, {
  45.             re: /[\xD1]/g,
  46.             ch: "N"
  47.         }, {
  48.             re: /[\xF1]/g,
  49.             ch: "n"
  50.         }];
  51.         return a.each(c, function() {
  52.             b = b.replace(this.re, this.ch)
  53.         }), b
  54.     }
  55.  
  56.     function c(a) {
  57.         var b = {
  58.                 "&": "&",
  59.                 "<": "&lt;",
  60.                 ">": "&gt;",
  61.                 '"': "&quot;",
  62.                 "'": "&#x27;",
  63.                 "`": "&#x60;"
  64.             },
  65.             c = "(?:" + Object.keys(b).join("|") + ")",
  66.             d = new RegExp(c),
  67.             e = new RegExp(c, "g"),
  68.             f = null == a ? "" : "" + a;
  69.         return d.test(f) ? f.replace(e, function(a) {
  70.             return b[a]
  71.         }) : f
  72.     }
  73.  
  74.     function d(b, c) {
  75.         var d = arguments,
  76.             f = b,
  77.             g = c;
  78.         [].shift.apply(d);
  79.         var h, i = this.each(function() {
  80.             var b = a(this);
  81.             if (b.is("select")) {
  82.                 var c = b.data("selectpicker"),
  83.                     i = "object" == typeof f && f;
  84.                 if (c) {
  85.                     if (i)
  86.                         for (var j in i) i.hasOwnProperty(j) && (c.options[j] = i[j])
  87.                 } else {
  88.                     var k = a.extend({}, e.DEFAULTS, a.fn.selectpicker.defaults || {}, b.data(), i);
  89.                     b.data("selectpicker", c = new e(this, k, g))
  90.                 }
  91.                 "string" == typeof f && (h = c[f] instanceof Function ? c[f].apply(c, d) : c.options[f])
  92.             }
  93.         });
  94.         return "undefined" != typeof h ? h : i
  95.     }
  96.     String.prototype.includes || ! function() {
  97.         var a = {}.toString,
  98.             b = function() {
  99.                 try {
  100.                     var a = {},
  101.                         b = Object.defineProperty,
  102.                         c = b(a, a, a) && b
  103.                 } catch (d) {}
  104.                 return c
  105.             }(),
  106.             c = "".indexOf,
  107.             d = function(b) {
  108.                 if (null == this) throw TypeError();
  109.                 var d = String(this);
  110.                 if (b && "[object RegExp]" == a.call(b)) throw TypeError();
  111.                 var e = d.length,
  112.                     f = String(b),
  113.                     g = f.length,
  114.                     h = arguments.length > 1 ? arguments[1] : void 0,
  115.                     i = h ? Number(h) : 0;
  116.                 i != i && (i = 0);
  117.                 var j = Math.min(Math.max(i, 0), e);
  118.                 return g + j > e ? !1 : -1 != c.call(d, f, i)
  119.             };
  120.         b ? b(String.prototype, "includes", {
  121.             value: d,
  122.             configurable: !0,
  123.             writable: !0
  124.         }) : String.prototype.includes = d
  125.     }(), String.prototype.startsWith || ! function() {
  126.         var a = function() {
  127.                 try {
  128.                     var a = {},
  129.                         b = Object.defineProperty,
  130.                         c = b(a, a, a) && b
  131.                 } catch (d) {}
  132.                 return c
  133.             }(),
  134.             b = {}.toString,
  135.             c = function(a) {
  136.                 if (null == this) throw TypeError();
  137.                 var c = String(this);
  138.                 if (a && "[object RegExp]" == b.call(a)) throw TypeError();
  139.                 var d = c.length,
  140.                     e = String(a),
  141.                     f = e.length,
  142.                     g = arguments.length > 1 ? arguments[1] : void 0,
  143.                     h = g ? Number(g) : 0;
  144.                 h != h && (h = 0);
  145.                 var i = Math.min(Math.max(h, 0), d);
  146.                 if (f + i > d) return !1;
  147.                 for (var j = -1; ++j < f;)
  148.                     if (c.charCodeAt(i + j) != e.charCodeAt(j)) return !1;
  149.                 return !0
  150.             };
  151.         a ? a(String.prototype, "startsWith", {
  152.             value: c,
  153.             configurable: !0,
  154.             writable: !0
  155.         }) : String.prototype.startsWith = c
  156.     }(), a.expr[":"].icontains = function(b, c, d) {
  157.         var e = a(b),
  158.             f = (e.data("tokens") || e.text()).toUpperCase();
  159.         return f.includes(d[3].toUpperCase())
  160.     }, a.expr[":"].ibegins = function(b, c, d) {
  161.         var e = a(b),
  162.             f = (e.data("tokens") || e.text()).toUpperCase();
  163.         return f.startsWith(d[3].toUpperCase())
  164.     }, a.expr[":"].aicontains = function(b, c, d) {
  165.         var e = a(b),
  166.             f = (e.data("tokens") || e.data("normalizedText") || e.text()).toUpperCase();
  167.         return f.includes(f, d[3])
  168.     }, a.expr[":"].aibegins = function(b, c, d) {
  169.         var e = a(b),
  170.             f = (e.data("tokens") || e.data("normalizedText") || e.text()).toUpperCase();
  171.         return f.startsWith(d[3].toUpperCase())
  172.     };
  173.     var e = function(b, c, d) {
  174.         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()
  175.     };
  176.     e.VERSION = "1.6.5", e.DEFAULTS = {
  177.         noneSelectedText: "Nothing selected",
  178.         noneResultsText: "No results matched {0}",
  179.         countSelectedText: function(a) {
  180.             return 1 == a ? "{0} item selected" : "{0} items selected"
  181.         },
  182.         maxOptionsText: function(a, b) {
  183.             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)"]
  184.         },
  185.         selectAllText: "Select All",
  186.         deselectAllText: "Deselect All",
  187.         doneButton: !1,
  188.         doneButtonText: "Close",
  189.         multipleSeparator: ", ",
  190.         style: "btn-default",
  191.         size: "auto",
  192.         title: null,
  193.         selectedTextFormat: "values",
  194.         width: !1,
  195.         container: !1,
  196.         hideDisabled: !1,
  197.         showSubtext: !1,
  198.         showIcon: !0,
  199.         showContent: !0,
  200.         dropupAuto: !0,
  201.         header: !1,
  202.         liveSearch: !1,
  203.         liveSearchPlaceholder: null,
  204.         liveSearchNormalize: !1,
  205.         liveSearchStyle: "contains",
  206.         actionsBox: !1,
  207.         iconBase: "glyphicon",
  208.         tickIcon: "glyphicon-ok",
  209.         maxOptions: !1,
  210.         mobile: !1,
  211.         selectOnTab: !1,
  212.         dropdownAlignRight: !1
  213.     }, e.prototype = {
  214.         constructor: e,
  215.         init: function() {
  216.             var b = this,
  217.                 c = this.$element.attr("id");
  218.             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) {
  219.                 a.preventDefault(), b.$button.focus()
  220.             })), 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()
  221.         },
  222.         createDropdown: function() {
  223.             var b = this.multiple ? " show-tick" : "",
  224.                 d = this.$element.parent().hasClass("input-group") ? " input-group-btn" : "",
  225.                 e = this.autofocus ? " autofocus" : "",
  226.                 f = this.options.header ? '<div class="popover-title"><button type="button" class="close" aria-hidden="true">&times;</button>' + this.options.header + "</div>" : "",
  227.                 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>" : "",
  228.                 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>" : "",
  229.                 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>" : "",
  230.                 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>&nbsp;<span class="caret"></span></button><div class="dropdown-menu open">' + f + g + h + '<ul class="dropdown-menu inner" role="menu"></ul>' + i + "</div></div>";
  231.             return a(j)
  232.         },
  233.         createView: function() {
  234.             var a = this.createDropdown(),
  235.                 b = this.createLi();
  236.             return a.find("ul").append(b), a
  237.         },
  238.         reloadLi: function() {
  239.             this.destroyLi();
  240.             var a = this.createLi();
  241.             this.$menu.find("ul").append(a)
  242.         },
  243.         destroyLi: function() {
  244.             this.$menu.find("li").remove()
  245.         },
  246.         createLi: function() {
  247.             var d = this,
  248.                 e = [],
  249.                 f = 0,
  250.                 g = function(a, b, c, d) {
  251.                     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>"
  252.                 },
  253.                 h = function(a, e, f, g) {
  254.                     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>'
  255.                 };
  256.             return this.$element.find("option").each(function(b) {
  257.                 var c = a(this),
  258.                     i = c.attr("class") || "",
  259.                     j = c.attr("style"),
  260.                     k = c.data("content") ? c.data("content") : c.html(),
  261.                     l = c.data("tokens") ? c.data("tokens") : null,
  262.                     m = "undefined" != typeof c.data("subtext") ? '<small class="text-muted">' + c.data("subtext") + "</small>" : "",
  263.                     n = "undefined" != typeof c.data("icon") ? '<span class="' + d.options.iconBase + " " + c.data("icon") + '"></span> ' : "",
  264.                     o = c.is(":disabled") || c.parent().is(":disabled");
  265.                 if ("" !== n && o && (n = "<span>" + n + "</span>"), c.data("content") || (k = n + '<span class="text">' + k + m + "</span>"), !d.options.hideDisabled || !o)
  266.                     if (c.parent().is("optgroup") && c.data("divider") !== !0) {
  267.                         if (0 === c.index()) {
  268.                             f += 1;
  269.                             var p = c.parent().attr("label"),
  270.                                 q = "undefined" != typeof c.parent().data("subtext") ? '<small class="text-muted">' + c.parent().data("subtext") + "</small>" : "",
  271.                                 r = c.parent().data("icon") ? '<span class="' + d.options.iconBase + " " + c.parent().data("icon") + '"></span> ' : "";
  272.                             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))
  273.                         }
  274.                         e.push(g(h(k, "opt " + i, j, l), b, "", f))
  275.                     } 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)))
  276.             }), 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(""))
  277.         },
  278.         findLis: function() {
  279.             return null == this.$lis && (this.$lis = this.$menu.find("li")), this.$lis
  280.         },
  281.         render: function(b) {
  282.             var c = this;
  283.             b !== !1 && this.$element.find("option").each(function(b) {
  284.                 c.setDisabled(b, a(this).is(":disabled") || a(this).parent().is(":disabled")), c.setSelected(b, a(this).is(":selected"))
  285.             }), this.tabIndex();
  286.             var d = this.options.hideDisabled ? ":enabled" : "",
  287.                 e = this.$element.find("option:selected" + d).map(function() {
  288.                     var b, d = a(this),
  289.                         e = d.data("icon") && c.options.showIcon ? '<i class="' + c.options.iconBase + " " + d.data("icon") + '"></i> ' : "";
  290.                     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
  291.                 }).toArray(),
  292.                 f = this.multiple ? e.join(this.options.multipleSeparator) : e[0];
  293.             if (this.multiple && this.options.selectedTextFormat.indexOf("count") > -1) {
  294.                 var g = this.options.selectedTextFormat.split(">");
  295.                 if (g.length > 1 && e.length > g[1] || 1 == g.length && e.length >= 2) {
  296.                     d = this.options.hideDisabled ? ", [disabled]" : "";
  297.                     var h = this.$element.find("option").not('[data-divider="true"], [data-hidden="true"]' + d).length,
  298.                         i = "function" == typeof this.options.countSelectedText ? this.options.countSelectedText(e.length, h) : this.options.countSelectedText;
  299.                     f = i.replace("{0}", e.length.toString()).replace("{1}", h.toString())
  300.                 }
  301.             }
  302.             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)
  303.         },
  304.         setStyle: function(a, b) {
  305.             this.$element.attr("class") && this.$newElement.addClass(this.$element.attr("class").replace(/selectpicker|mobile-device|validate\[.*\]/gi, ""));
  306.             var c = a ? a : this.options.style;
  307.             "add" == b ? this.$button.addClass(c) : "remove" == b ? this.$button.removeClass(c) : (this.$button.removeClass(this.options.style), this.$button.addClass(c))
  308.         },
  309.         liHeight: function() {
  310.             if (this.options.size !== !1) {
  311.                 var a = this.$menu.parent().clone().children(".dropdown-toggle").prop("autofocus", !1).end().appendTo("body"),
  312.                     b = a.addClass("open").children(".dropdown-menu"),
  313.                     c = b.find("li").not(".divider, .dropdown-header").filter(":visible").children("a").outerHeight(),
  314.                     d = this.options.header ? b.find(".popover-title").outerHeight() : 0,
  315.                     e = this.options.liveSearch ? b.find(".bs-searchbox").outerHeight() : 0,
  316.                     f = this.options.actionsBox ? b.find(".bs-actionsbox").outerHeight() : 0,
  317.                     g = this.multiple ? b.find(".bs-donebutton").outerHeight() : 0;
  318.                 a.remove(), this.$newElement.data("liHeight", c).data("headerHeight", d).data("searchHeight", e).data("actionsHeight", f).data("doneButtonHeight", g)
  319.             }
  320.         },
  321.         setSize: function() {
  322.             this.findLis();
  323.             var b, c, d, e = this,
  324.                 f = this.$menu,
  325.                 g = f.children(".inner"),
  326.                 h = this.$newElement.outerHeight(),
  327.                 i = this.$newElement.data("liHeight"),
  328.                 j = this.$newElement.data("headerHeight"),
  329.                 k = this.$newElement.data("searchHeight"),
  330.                 l = this.$newElement.data("actionsHeight"),
  331.                 m = this.$newElement.data("doneButtonHeight"),
  332.                 n = this.$lis.filter(".divider").outerHeight(!0),
  333.                 o = parseInt(f.css("padding-top")) + parseInt(f.css("padding-bottom")) + parseInt(f.css("border-top-width")) + parseInt(f.css("border-bottom-width")),
  334.                 p = this.options.hideDisabled ? ".disabled" : "",
  335.                 q = a(window),
  336.                 r = o + parseInt(f.css("margin-top")) + parseInt(f.css("margin-bottom")) + 2,
  337.                 s = function() {
  338.                     c = e.$newElement.offset().top - q.scrollTop(), d = q.height() - c - h
  339.                 };
  340.             if (s(), this.options.header && f.css("padding-top", 0), "auto" == this.options.size) {
  341.                 var t = function() {
  342.                     var a, h = e.$lis.not(".hidden");
  343.                     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({
  344.                         "max-height": b + "px",
  345.                         overflow: "hidden",
  346.                         "min-height": a + j + k + l + m + "px"
  347.                     }), g.css({
  348.                         "max-height": b - j - k - l - m - o + "px",
  349.                         "overflow-y": "auto",
  350.                         "min-height": Math.max(a - o, 0) + "px"
  351.                     })
  352.                 };
  353.                 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)
  354.             } else if (this.options.size && "auto" != this.options.size && f.find("li").not(p).length > this.options.size) {
  355.                 var u = this.$lis.not(".divider").not(p).children().slice(0, this.options.size).last().parent().index(),
  356.                     v = this.$lis.slice(0, u + 1).filter(".divider").length;
  357.                 b = i * this.options.size + v * n + o, e.options.dropupAuto && this.$newElement.toggleClass("dropup", c > d && b < f.height()), f.css({
  358.                     "max-height": b + j + k + l + m + "px",
  359.                     overflow: "hidden"
  360.                 }), g.css({
  361.                     "max-height": b - o + "px",
  362.                     "overflow-y": "auto"
  363.                 })
  364.             }
  365.         },
  366.         setWidth: function() {
  367.             if ("auto" == this.options.width) {
  368.                 this.$menu.css("min-width", "0");
  369.                 var a = this.$newElement.clone().appendTo("body"),
  370.                     b = a.children(".dropdown-menu").css("width"),
  371.                     c = a.css("width", "auto").children("button").css("width");
  372.                 a.remove(), this.$newElement.css("width", Math.max(parseInt(b), parseInt(c)) + "px")
  373.             } 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", ""));
  374.             this.$newElement.hasClass("fit-width") && "fit" !== this.options.width && this.$newElement.removeClass("fit-width")
  375.         },
  376.         selectPosition: function() {
  377.             var b, c, d = this,
  378.                 e = "<div />",
  379.                 f = a(e),
  380.                 g = function(a) {
  381.                     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({
  382.                         top: b.top + c,
  383.                         left: b.left,
  384.                         width: a[0].offsetWidth,
  385.                         position: "absolute"
  386.                     })
  387.                 };
  388.             this.$newElement.on("click", function() {
  389.                 d.isDisabled() || (g(a(this)), f.appendTo(d.options.container), f.toggleClass("open", !a(this).hasClass("open")), f.append(d.$menu))
  390.             }), a(window).on("resize scroll", function() {
  391.                 g(d.$newElement)
  392.             }), a("html").on("click", function(b) {
  393.                 a(b.target).closest(d.$newElement).length < 1 && f.removeClass("open")
  394.             })
  395.         },
  396.         setSelected: function(a, b) {
  397.             this.findLis(), this.$lis.filter('[data-original-index="' + a + '"]').toggleClass("selected", b)
  398.         },
  399.         setDisabled: function(a, b) {
  400.             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)
  401.         },
  402.         isDisabled: function() {
  403.             return this.$element.is(":disabled")
  404.         },
  405.         checkDisabled: function() {
  406.             var a = this;
  407.             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() {
  408.                 return !a.isDisabled()
  409.             })
  410.         },
  411.         tabIndex: function() {
  412.             this.$element.is("[tabindex]") && (this.$element.data("tabindex", this.$element.attr("tabindex")), this.$button.attr("tabindex", this.$element.data("tabindex")))
  413.         },
  414.         clickListener: function() {
  415.             var b = this;
  416.             this.$newElement.on("touchstart.dropdown", ".dropdown-menu", function(a) {
  417.                 a.stopPropagation()
  418.             }), this.$newElement.on("click", function() {
  419.                 b.setSize(), b.options.liveSearch || b.multiple || setTimeout(function() {
  420.                     b.$menu.find(".selected a").focus()
  421.                 }, 10)
  422.             }), this.$menu.on("click", "li a", function(c) {
  423.                 var d = a(this),
  424.                     e = d.parent().data("originalIndex"),
  425.                     f = b.$element.val(),
  426.                     g = b.$element.prop("selectedIndex");
  427.                 if (b.multiple && c.stopPropagation(), c.preventDefault(), !b.isDisabled() && !d.parent().hasClass("disabled")) {
  428.                     var h = b.$element.find("option"),
  429.                         i = h.eq(e),
  430.                         j = i.prop("selected"),
  431.                         k = i.parent("optgroup"),
  432.                         l = b.options.maxOptions,
  433.                         m = k.data("maxOptions") || !1;
  434.                     if (b.multiple) {
  435.                         if (i.prop("selected", !j), b.setSelected(e, !j), d.blur(), l !== !1 || m !== !1) {
  436.                             var n = l < h.filter(":selected").length,
  437.                                 o = m < k.find("option:selected").length;
  438.                             if (l && n || m && o)
  439.                                 if (l && 1 == l) h.prop("selected", !1), i.prop("selected", !0), b.$menu.find(".selected").removeClass("selected"), b.setSelected(e, !0);
  440.                                 else if (m && 1 == m) {
  441.                                 k.find("option:selected").prop("selected", !1), i.prop("selected", !0);
  442.                                 var p = d.data("optgroup");
  443.                                 b.$menu.find(".selected").has('a[data-optgroup="' + p + '"]').removeClass("selected"), b.setSelected(e, !0)
  444.                             } else {
  445.                                 var q = "function" == typeof b.options.maxOptionsText ? b.options.maxOptionsText(l, m) : b.options.maxOptionsText,
  446.                                     r = q[0].replace("{n}", l),
  447.                                     s = q[1].replace("{n}", m),
  448.                                     t = a('<div class="notify"></div>');
  449.                                 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() {
  450.                                     b.setSelected(e, !1)
  451.                                 }, 10), t.delay(750).fadeOut(300, function() {
  452.                                     a(this).remove()
  453.                                 })
  454.                             }
  455.                         }
  456.                     } else h.prop("selected", !1), i.prop("selected", !0), b.$menu.find(".selected").removeClass("selected"), b.setSelected(e, !0);
  457.                     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()
  458.                 }
  459.             }), this.$menu.on("click", "li.disabled a, .popover-title, .popover-title :not(.close)", function(a) {
  460.                 a.currentTarget == this && (a.preventDefault(), a.stopPropagation(), b.options.liveSearch ? b.$searchbox.focus() : b.$button.focus())
  461.             }), this.$menu.on("click", "li.divider, li.dropdown-header", function(a) {
  462.                 a.preventDefault(), a.stopPropagation(), b.options.liveSearch ? b.$searchbox.focus() : b.$button.focus()
  463.             }), this.$menu.on("click", ".popover-title .close", function() {
  464.                 b.$button.focus()
  465.             }), this.$searchbox.on("click", function(a) {
  466.                 a.stopPropagation()
  467.             }), this.$menu.on("click", ".actions-btn", function(c) {
  468.                 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()
  469.             }), this.$element.change(function() {
  470.                 b.render(!1)
  471.             })
  472.         },
  473.         liveSearchListener: function() {
  474.             var d = this,
  475.                 e = a('<li class="no-results"></li>');
  476.             this.$newElement.on("click.dropdown.data-api touchstart.dropdown.data-api", function() {
  477.                 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() {
  478.                     d.$searchbox.focus()
  479.                 }, 10)
  480.             }), this.$searchbox.on("click.dropdown.data-api focus.dropdown.data-api touchend.dropdown.data-api", function(a) {
  481.                 a.stopPropagation()
  482.             }), this.$searchbox.on("input propertychange", function() {
  483.                 if (d.$searchbox.val()) {
  484.                     var f = d.$lis.not(".is-hidden").removeClass("hidden").children("a");
  485.                     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() {
  486.                         var b = a(this),
  487.                             c = b.data("optgroup");
  488.                         0 === d.$lis.filter("[data-optgroup=" + c + "]").not(b).not(".hidden").length && (b.addClass("hidden"), d.$lis.filter("[data-optgroup=" + c + "div]").addClass("hidden"))
  489.                     });
  490.                     var g = d.$lis.not(".hidden");
  491.                     g.each(function(b) {
  492.                         var c = a(this);
  493.                         c.hasClass("divider") && (c.index() === g.eq(0).index() || c.index() === g.last().index() || g.eq(b + 1).hasClass("divider")) && c.addClass("hidden")
  494.                     }), 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))
  495.                 } else d.$lis.not(".is-hidden").removeClass("hidden"), e.parent().length && e.remove();
  496.                 d.$lis.filter(".active").removeClass("active"), d.$lis.not(".hidden, .divider, .dropdown-header").eq(0).addClass("active").children("a").focus(), a(this).focus()
  497.             })
  498.         },
  499.         _searchStyle: function() {
  500.             var a = "icontains";
  501.             switch (this.options.liveSearchStyle) {
  502.                 case "begins":
  503.                 case "startsWith":
  504.                     a = "ibegins";
  505.                     break;
  506.                 case "contains":
  507.             }
  508.             return a
  509.         },
  510.         val: function(a) {
  511.             return "undefined" != typeof a ? (this.$element.val(a), this.render(), this.$element) : this.$element.val()
  512.         },
  513.         selectAll: function() {
  514.             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)
  515.         },
  516.         deselectAll: function() {
  517.             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)
  518.         },
  519.         keydown: function(c) {
  520.             var d, e, f, g, h, i, j, k, l, m = a(this),
  521.                 n = m.is("input") ? m.parent().parent() : m.parent(),
  522.                 o = n.data("this"),
  523.                 p = {
  524.                     32: " ",
  525.                     48: "0",
  526.                     49: "1",
  527.                     50: "2",
  528.                     51: "3",
  529.                     52: "4",
  530.                     53: "5",
  531.                     54: "6",
  532.                     55: "7",
  533.                     56: "8",
  534.                     57: "9",
  535.                     59: ";",
  536.                     65: "a",
  537.                     66: "b",
  538.                     67: "c",
  539.                     68: "d",
  540.                     69: "e",
  541.                     70: "f",
  542.                     71: "g",
  543.                     72: "h",
  544.                     73: "i",
  545.                     74: "j",
  546.                     75: "k",
  547.                     76: "l",
  548.                     77: "m",
  549.                     78: "n",
  550.                     79: "o",
  551.                     80: "p",
  552.                     81: "q",
  553.                     82: "r",
  554.                     83: "s",
  555.                     84: "t",
  556.                     85: "u",
  557.                     86: "v",
  558.                     87: "w",
  559.                     88: "x",
  560.                     89: "y",
  561.                     90: "z",
  562.                     96: "0",
  563.                     97: "1",
  564.                     98: "2",
  565.                     99: "3",
  566.                     100: "4",
  567.                     101: "5",
  568.                     102: "6",
  569.                     103: "7",
  570.                     104: "8",
  571.                     105: "9"
  572.                 };
  573.             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) {
  574.                 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) {
  575.                     a(this).hasClass("disabled") || a(this).data("index", b)
  576.                 }), 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();
  577.                 else if (!m.is("input")) {
  578.                     var q, r, s = [];
  579.                     d.each(function() {
  580.                         a(this).parent().hasClass("disabled") || a.trim(a(this).text().toLowerCase()).substring(0, 1) == p[c.keyCode] && s.push(a(this).parent().index())
  581.                     }), 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()
  582.                 }
  583.                 if ((/(13|32)/.test(c.keyCode.toString(10)) || /(^9$)/.test(c.keyCode.toString(10)) && o.options.selectOnTab) && l) {
  584.                     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());
  585.                     else {
  586.                         var t = a(":focus");
  587.                         t.click(), t.focus(), c.preventDefault()
  588.                     }
  589.                     a(document).data("keycount", 0)
  590.                 }(/(^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())
  591.             }
  592.         },
  593.         mobile: function() {
  594.             this.$element.addClass("mobile-device").appendTo(this.$newElement), this.options.container && this.$menu.hide()
  595.         },
  596.         refresh: function() {
  597.             this.$lis = null, this.reloadLi(), this.render(), this.setWidth(), this.setStyle(), this.checkDisabled(), this.liHeight()
  598.         },
  599.         hide: function() {
  600.             this.$newElement.hide()
  601.         },
  602.         show: function() {
  603.             this.$newElement.show()
  604.         },
  605.         remove: function() {
  606.             this.$newElement.remove(), this.$element.remove()
  607.         }
  608.     };
  609.     var f = a.fn.selectpicker;
  610.     a.fn.selectpicker = d, a.fn.selectpicker.Constructor = e, a.fn.selectpicker.noConflict = function() {
  611.         return a.fn.selectpicker = f, this
  612.     }, 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) {
  613.         a.stopPropagation()
  614.     }), a(window).on("load.bs.select.data-api", function() {
  615.         a(".selectpicker").each(function() {
  616.             var b = a(this);
  617.             d.call(b, b.data())
  618.         })
  619.     })
  620. }(jQuery);
  621. //# sourceMappingURL=bootstrap-select.js.map
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement