1/* jshint forin:true, noarg:true, noempty:true, eqeqeq:true, boss:true, undef:true, curly:true, browser:true, jquery:true */ 2/* 3 * jQuery MultiSelect UI Widget 1.14pre 4 * Copyright (c) 2012 Eric Hynds 5 * 6 * http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/ 7 * 8 * Depends: 9 * - jQuery 1.4.2+ 10 * - jQuery UI 1.8 widget factory 11 * 12 * Optional: 13 * - jQuery UI effects 14 * - jQuery UI position utility 15 * 16 * Dual licensed under the MIT and GPL licenses: 17 * http://www.opensource.org/licenses/mit-license.php 18 * http://www.gnu.org/licenses/gpl.html 19 * 20 */ 21!function (e, t) { var i = 0, s = e(document); e.widget("ech.multiselect", { options: { header: !0, height: 175, minWidth: 225, classes: "", checkAllText: "Check all", uncheckAllText: "Uncheck all", noneSelectedText: "Select options", selectedText: "# selected", selectedList: 0, show: null, hide: null, autoOpen: !1, multiple: !0, position: {}, appendTo: "body" }, _create: function () { var t = this.element.hide(), s = this.options; this.speed = e.fx.speeds._default, this._isOpen = !1, this._namespaceID = this.eventNamespace || "multiselect" + i; var l = (this.button = e('<button type="button"><span class="ui-icon ui-icon-triangle-1-s"></span></button>')).addClass("ui-multiselect ui-widget ui-state-default ui-corner-all").addClass(s.classes).attr({ title: t.attr("title"), "aria-haspopup": !0, tabIndex: t.attr("tabIndex") }).insertAfter(t), n = ((this.buttonlabel = e("<span />")).html(s.noneSelectedText).appendTo(l), (this.menu = e("<div />")).addClass("ui-multiselect-menu ui-widget ui-widget-content ui-corner-all").addClass(s.classes).appendTo(e(s.appendTo))), a = (this.header = e("<div />")).addClass("ui-widget-header ui-corner-all ui-multiselect-header ui-helper-clearfix").appendTo(n); (this.headerLinkContainer = e("<ul />")).addClass("ui-helper-reset").html(function () { return s.header === !0 ? '<li><a class="ui-multiselect-all" href="#"><span class="ui-icon ui-icon-check"></span><span>' + s.checkAllText + '</span></a></li><li><a class="ui-multiselect-none" href="#"><span class="ui-icon ui-icon-closethick"></span><span>' + s.uncheckAllText + "</span></a></li>" : "string" == typeof s.header ? "<li>" + s.header + "</li>" : "" }).append('<li class="ui-multiselect-close"><a href="#" class="ui-multiselect-close"><span class="ui-icon ui-icon-circle-close"></span></a></li>').appendTo(a), (this.checkboxContainer = e("<ul />")).addClass("ui-multiselect-checkboxes ui-helper-reset").appendTo(n); this._bindEvents(), this.refresh(!0), s.multiple || n.addClass("ui-multiselect-single"), i++ }, _init: function () { this.options.header === !1 && this.header.hide(), this.options.multiple || this.headerLinkContainer.find(".ui-multiselect-all, .ui-multiselect-none").hide(), this.options.autoOpen && this.open(), this.element.is(":disabled") && this.disable() }, refresh: function (t) { var s = this.element, l = this.options, n = this.menu, a = this.checkboxContainer, o = [], u = "", h = s.attr("id") || i++; s.find("option").each(function (t) { var i, s = (e(this), this.parentNode), n = this.innerHTML, a = this.title, c = this.value, r = "ui-multiselect-" + (this.id || h + "-option-" + t), d = this.disabled, p = this.selected, m = ["ui-corner-all"], f = (d ? "ui-multiselect-disabled " : " ") + this.className; "OPTGROUP" === s.tagName && (i = s.getAttribute("label"), -1 === e.inArray(i, o) && (u += '<li class="ui-multiselect-optgroup-label ' + s.className + '"><a href="#">' + i + "</a></li>", o.push(i))), d && m.push("ui-state-disabled"), p && !l.multiple && m.push("ui-state-active"), u += '<li class="' + f + '">', u += '<label for="' + r + '" title="' + a + '" class="' + m.join(" ") + '">', u += '<input id="' + r + '" name="multiselect_' + h + '" type="' + (l.multiple ? "checkbox" : "radio") + '" value="' + c + '" title="' + a + '"', p && (u += ' checked="checked"', u += ' aria-selected="true"'), d && (u += ' disabled="disabled"', u += ' aria-disabled="true"'), u += " /><span>" + n + "</span></label></li>" }), a.html(u), this.labels = n.find("label"), this.inputs = this.labels.children("input"), this._setButtonWidth(), this._setMenuWidth(), this.button[0].defaultValue = this.update(), t || this._trigger("refresh") }, update: function () { var t, i = this.options, s = this.inputs, l = s.filter(":checked"), n = l.length; return t = 0 === n ? i.noneSelectedText : e.isFunction(i.selectedText) ? i.selectedText.call(this, n, s.length, l.get()) : /\d/.test(i.selectedList) && i.selectedList > 0 && n <= i.selectedList ? l.map(function () { return e(this).next().html() }).get().join(", ") : i.selectedText.replace("#", n).replace("#", s.length), this._setButtonValue(t), t }, _setButtonValue: function (e) { this.buttonlabel.text(e) }, _bindEvents: function () { function t() { return i[i._isOpen ? "close" : "open"](), !1 } var i = this, l = this.button; l.find("span").bind("click.multiselect", t), l.bind({ click: t, keypress: function (e) { switch (e.which) { case 27: case 38: case 37: i.close(); break; case 39: case 40: i.open() } }, mouseenter: function () { l.hasClass("ui-state-disabled") || e(this).addClass("ui-state-hover") }, mouseleave: function () { e(this).removeClass("ui-state-hover") }, focus: function () { l.hasClass("ui-state-disabled") || e(this).addClass("ui-state-focus") }, blur: function () { e(this).removeClass("ui-state-focus") } }), this.header.delegate("a", "click.multiselect", function (t) { e(this).hasClass("ui-multiselect-close") ? i.close() : i[e(this).hasClass("ui-multiselect-all") ? "checkAll" : "uncheckAll"](), t.preventDefault() }), this.menu.delegate("li.ui-multiselect-optgroup-label a", "click.multiselect", function (t) { t.preventDefault(); var s = e(this), l = s.parent().nextUntil("li.ui-multiselect-optgroup-label").find("input:visible:not(:disabled)"), n = l.get(), a = s.parent().text(); i._trigger("beforeoptgrouptoggle", t, { inputs: n, label: a }) !== !1 && (i._toggleChecked(l.filter(":checked").length !== l.length, l), i._trigger("optgrouptoggle", t, { inputs: n, label: a, checked: n[0].checked })) }).delegate("label", "mouseenter.multiselect", function () { e(this).hasClass("ui-state-disabled") || (i.labels.removeClass("ui-state-hover"), e(this).addClass("ui-state-hover").find("input").focus()) }).delegate("label", "keydown.multiselect", function (t) { switch (t.preventDefault(), t.which) { case 9: case 27: i.close(); break; case 38: case 40: case 37: case 39: i._traverse(t.which, this); break; case 13: e(this).find("input")[0].click() } }).delegate('input[type="checkbox"], input[type="radio"]', "click.multiselect", function (t) { var s = e(this), l = this.value, n = this.checked, a = i.element.find("option"); return this.disabled || i._trigger("click", t, { value: l, text: this.title, checked: n }) === !1 ? void t.preventDefault() : (s.focus(), s.attr("aria-selected", n), a.each(function () { this.value === l ? this.selected = n : i.options.multiple || (this.selected = !1) }), i.options.multiple || (i.labels.removeClass("ui-state-active"), s.closest("label").toggleClass("ui-state-active", n), i.close()), i.element.trigger("change"), void setTimeout(e.proxy(i.update, i), 10)) }), s.bind("mousedown." + this._namespaceID, function (t) { var s = t.target; !i._isOpen || s === i.button[0] || s === i.menu[0] || e.contains(i.menu[0], s) || e.contains(i.button[0], s) || i.close() }), e(this.element[0].form).bind("reset.multiselect", function () { setTimeout(e.proxy(i.refresh, i), 10) }) }, _setButtonWidth: function () { var e = this.element.outerWidth(), t = this.options; /\d/.test(t.minWidth) && e < t.minWidth && (e = t.minWidth), this.button.outerWidth(e) }, _setMenuWidth: function () { var e = this.menu; e.outerWidth(this.button.outerWidth()) }, _traverse: function (t, i) { var s = e(i), l = 38 === t || 37 === t, n = s.parent()[l ? "prevAll" : "nextAll"]("li:not(.ui-multiselect-disabled, .ui-multiselect-optgroup-label)").first(); if (n.length) n.find("label").trigger("mouseover"); else { var a = this.menu.find("ul").last(); this.menu.find("label")[l ? "last" : "first"]().trigger("mouseover"), a.scrollTop(l ? a.height() : 0) } }, _toggleState: function (e, t) { return function () { this.disabled || (this[e] = t), t ? this.setAttribute("aria-selected", !0) : this.removeAttribute("aria-selected") } }, _toggleChecked: function (t, i) { var s = i && i.length ? i : this.inputs, l = this; s.each(this._toggleState("checked", t)), s.eq(0).focus(), this.update(); var n = s.map(function () { return this.value }).get(); this.element.find("option").each(function () { !this.disabled && e.inArray(this.value, n) > -1 && l._toggleState("selected", t).call(this) }), s.length && this.element.trigger("change") }, _toggleDisabled: function (t) { this.button.attr({ disabled: t, "aria-disabled": t })[t ? "addClass" : "removeClass"]("ui-state-disabled"); var i = this.menu.find("input"), s = "ech-multiselect-disabled"; i = t ? i.filter(":enabled").data(s, !0) : i.filter(function () { return e.data(this, s) === !0 }).removeData(s), i.attr({ disabled: t, "arial-disabled": t }).parent()[t ? "addClass" : "removeClass"]("ui-state-disabled"), this.element.attr({ disabled: t, "aria-disabled": t }) }, open: function (t) { var i = this, s = this.button, l = this.menu, n = this.speed, a = this.options, o = []; if (this._trigger("beforeopen") !== !1 && !s.hasClass("ui-state-disabled") && !this._isOpen) { var u = l.find("ul").last(), h = a.show; e.isArray(a.show) && (h = a.show[0], n = a.show[1] || i.speed), h && (o = [h, n]), u.scrollTop(0).height(a.height), this.position(), e.fn.show.apply(l, o), this.labels.filter(":not(.ui-state-disabled)").eq(0).trigger("mouseover").trigger("mouseenter").find("input").trigger("focus"), s.addClass("ui-state-active"), this._isOpen = !0, this._trigger("open") } }, close: function () { if (this._trigger("beforeclose") !== !1) { var t = this.options, i = t.hide, s = this.speed, l = []; e.isArray(t.hide) && (i = t.hide[0], s = t.hide[1] || this.speed), i && (l = [i, s]), e.fn.hide.apply(this.menu, l), this.button.removeClass("ui-state-active").trigger("blur").trigger("mouseleave"), this._isOpen = !1, this._trigger("close") } }, enable: function () { this._toggleDisabled(!1) }, disable: function () { this._toggleDisabled(!0) }, checkAll: function (e) { this._toggleChecked(!0), this._trigger("checkAll") }, uncheckAll: function () { this._toggleChecked(!1), this._trigger("uncheckAll") }, getChecked: function () { return this.menu.find("input").filter(":checked") }, destroy: function () { return e.Widget.prototype.destroy.call(this), s.unbind(this._namespaceID), this.button.remove(), this.menu.remove(), this.element.show(), this }, isOpen: function () { return this._isOpen }, widget: function () { return this.menu }, getButton: function () { return this.button }, position: function () { var t = this.options; if (e.ui.position && !e.isEmptyObject(t.position)) t.position.of = t.position.of || this.button, this.menu.show().position(t.position).hide(); else { var i = this.button.offset(); this.menu.css({ top: i.top + this.button.outerHeight(), left: i.left }) } }, _setOption: function (t, i) { var s = this.menu; switch (t) { case "header": s.find("div.ui-multiselect-header")[i ? "show" : "hide"](); break; case "checkAllText": s.find("a.ui-multiselect-all span").eq(-1).text(i); break; case "uncheckAllText": s.find("a.ui-multiselect-none span").eq(-1).text(i); break; case "height": s.find("ul").last().height(parseInt(i, 10)); break; case "minWidth": this.options[t] = parseInt(i, 10), this._setButtonWidth(), this._setMenuWidth(); break; case "selectedText": case "selectedList": case "noneSelectedText": this.options[t] = i, this.update(); break; case "classes": s.add(this.button).removeClass(this.options.classes).addClass(i); break; case "multiple": s.toggleClass("ui-multiselect-single", !i), this.options.multiple = i, this.element[0].multiple = i, this.refresh(); break; case "position": this.position() }
21 e.Widget.prototype._setOption.apply(this, arguments) } }) }(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.