Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Moobot = function(a) {
- a.paths = {
- root: "r/47/",
- js: "/r/47/js/",
- css: "/r/47/css/",
- img: "/r/47/img/",
- sounds: "/r/47/sounds/",
- data: "/r/47/data/",
- templates: "/r/47/templates/"
- };
- return a
- }(Moobot || {}),
- Moobot = function(a) {
- a.social = {
- twitter: "MoobotApp",
- facebook: "Moobot",
- youtube: "TwitchTVMoobot",
- tumblr: "MoobotApp"
- };
- return a
- }(Moobot || {});
- ! function(a) {
- a(function() {
- var d = a.support,
- c;
- a: {
- c = document.createElement("bootstrap");
- var b = {
- WebkitTransition: "webkitTransitionEnd",
- MozTransition: "transitionend",
- OTransition: "oTransitionEnd otransitionend",
- transition: "transitionend"
- },
- e;
- for (e in b)
- if (void 0 !== c.style[e]) {
- c = b[e];
- break a
- }
- c = void 0
- }
- d.transition = c && {
- end: c
- }
- })
- }(window.jQuery);
- ! function(a) {
- var d = function(c) {
- a(c).on("click", '[data-dismiss="alert"]', this.close)
- };
- d.prototype.close = function(c) {
- function b() {
- d.trigger("closed").remove()
- }
- var e = a(this),
- f = e.attr("data-target"),
- d;
- f || (f = e.attr("href"), f = f && f.replace(/.*(?=#[^\s]*$)/, ""));
- d = a(f);
- c && c.preventDefault();
- d.length || (d = e.hasClass("alert") ? e : e.parent());
- d.trigger(c = a.Event("close"));
- c.isDefaultPrevented() || (d.removeClass("in"), a.support.transition && d.hasClass("fade") ? d.on(a.support.transition.end, b) : b())
- };
- a.fn.alert = function(c) {
- return this.each(function() {
- var b =
- a(this),
- e = b.data("alert");
- e || b.data("alert", e = new d(this));
- "string" == typeof c && e[c].call(b)
- })
- };
- a.fn.alert.Constructor = d;
- a(function() {
- a("body").on("click.alert.data-api", '[data-dismiss="alert"]', d.prototype.close)
- })
- }(window.jQuery);
- ! function(a) {
- var d = function(c, b) {
- this.$element = a(c);
- this.options = a.extend({}, a.fn.button.defaults, b)
- };
- d.prototype.setState = function(a) {
- var b = this.$element,
- e = b.data(),
- d = b.is("input") ? "val" : "html";
- a += "Text";
- e.resetText || b.data("resetText", b[d]());
- b[d](e[a] || this.options[a]);
- setTimeout(function() {
- "loadingText" == a ? b.addClass("disabled").attr("disabled", "disabled") : b.removeClass("disabled").removeAttr("disabled")
- }, 0)
- };
- d.prototype.toggle = function() {
- var a = this.$element.closest('[data-toggle="buttons-radio"]');
- a && a.find(".active").removeClass("active");
- this.$element.toggleClass("active")
- };
- a.fn.button = function(c) {
- return this.each(function() {
- var b = a(this),
- e = b.data("button"),
- f = "object" == typeof c && c;
- e || b.data("button", e = new d(this, f));
- "toggle" == c ? e.toggle() : c && e.setState(c)
- })
- };
- a.fn.button.defaults = {
- loadingText: "loading..."
- };
- a.fn.button.Constructor = d;
- a(function() {
- a("body").on("click.button.data-api", "[data-toggle^=button]", function(c) {
- c = a(c.target);
- c.hasClass("btn") || (c = c.closest(".btn"));
- c.button("toggle")
- })
- })
- }(window.jQuery);
- ! function(a) {
- var d = function(c, b) {
- this.$element = a(c);
- this.options = b;
- this.options.slide && this.slide(this.options.slide);
- "hover" == this.options.pause && this.$element.on("mouseenter", a.proxy(this.pause, this)).on("mouseleave", a.proxy(this.cycle, this))
- };
- d.prototype = {
- cycle: function(c) {
- return c || (this.paused = !1), this.options.interval && !this.paused && (this.interval = setInterval(a.proxy(this.next, this), this.options.interval)), this
- },
- to: function(c) {
- var b = this.$element.find(".item.active"),
- e = b.parent().children(),
- b = e.index(b),
- d = this;
- if (!(c > e.length - 1 || 0 > c)) return this.sliding ? this.$element.one("slid", function() {
- d.to(c)
- }) : b == c ? this.pause().cycle() : this.slide(c > b ? "next" : "prev", a(e[c]))
- },
- pause: function(c) {
- return c || (this.paused = !0), this.$element.find(".next, .prev").length && a.support.transition.end && (this.$element.trigger(a.support.transition.end), this.cycle()), clearInterval(this.interval), this.interval = null, this
- },
- next: function() {
- if (!this.sliding) return this.slide("next")
- },
- prev: function() {
- if (!this.sliding) return this.slide("prev")
- },
- slide: function(c, b) {
- var e = this.$element.find(".item.active"),
- d = b || e[c](),
- h = this.interval,
- g = "next" == c ? "left" : "right",
- m = "next" == c ? "first" : "last",
- k = this,
- n = a.Event("slide", {
- relatedTarget: d[0]
- });
- this.sliding = !0;
- h && this.pause();
- d = d.length ? d : this.$element.find(".item")[m]();
- if (!d.hasClass("active")) {
- if (a.support.transition && this.$element.hasClass("slide")) {
- this.$element.trigger(n);
- if (n.isDefaultPrevented()) return;
- d.addClass(c);
- d[0].offsetWidth;
- e.addClass(g);
- d.addClass(g);
- this.$element.one(a.support.transition.end,
- function() {
- d.removeClass([c, g].join(" ")).addClass("active");
- e.removeClass(["active", g].join(" "));
- k.sliding = !1;
- setTimeout(function() {
- k.$element.trigger("slid")
- }, 0)
- })
- } else {
- this.$element.trigger(n);
- if (n.isDefaultPrevented()) return;
- e.removeClass("active");
- d.addClass("active");
- this.sliding = !1;
- this.$element.trigger("slid")
- }
- return h && this.cycle(), this
- }
- }
- };
- a.fn.carousel = function(c) {
- return this.each(function() {
- var b = a(this),
- e = b.data("carousel"),
- f = a.extend({}, a.fn.carousel.defaults, "object" == typeof c && c),
- h = "string" == typeof c ? c : f.slide;
- e || b.data("carousel", e = new d(this, f));
- "number" == typeof c ? e.to(c) : h ? e[h]() : f.interval && e.cycle()
- })
- };
- a.fn.carousel.defaults = {
- interval: 5E3,
- pause: "hover"
- };
- a.fn.carousel.Constructor = d;
- a(function() {
- a("body").on("click.carousel.data-api", "[data-slide]", function(c) {
- var b = a(this),
- e, d = a(b.attr("data-target") || (e = b.attr("href")) && e.replace(/.*(?=#[^\s]+$)/, "")),
- b = !d.data("modal") && a.extend({}, d.data(), b.data());
- d.carousel(b);
- c.preventDefault()
- })
- })
- }(window.jQuery);
- ! function(a) {
- var d = function(c, b) {
- this.$element = a(c);
- this.options = a.extend({}, a.fn.collapse.defaults, b);
- this.options.parent && (this.$parent = a(this.options.parent));
- this.options.toggle && this.toggle()
- };
- d.prototype = {
- constructor: d,
- dimension: function() {
- return this.$element.hasClass("width") ? "width" : "height"
- },
- show: function() {
- var c, b, e, d;
- if (!this.transitioning) {
- c = this.dimension();
- b = a.camelCase(["scroll", c].join("-"));
- if ((e = this.$parent && this.$parent.find("> .accordion-group > .in")) && e.length) {
- if ((d = e.data("collapse")) &&
- d.transitioning) return;
- e.collapse("hide");
- d || e.data("collapse", null)
- }
- this.$element[c](0);
- this.transition("addClass", a.Event("show"), "shown");
- a.support.transition && this.$element[c](this.$element[0][b])
- }
- },
- hide: function() {
- var c;
- this.transitioning || (c = this.dimension(), this.reset(this.$element[c]()), this.transition("removeClass", a.Event("hide"), "hidden"), this.$element[c](0))
- },
- reset: function(a) {
- var b = this.dimension();
- return this.$element.removeClass("collapse")[b](a || "auto")[0].offsetWidth, this.$element[null !==
- a ? "addClass" : "removeClass"]("collapse"), this
- },
- transition: function(c, b, e) {
- var d = this,
- h = function() {
- "show" == b.type && d.reset();
- d.transitioning = 0;
- d.$element.trigger(e)
- };
- this.$element.trigger(b);
- b.isDefaultPrevented() || (this.transitioning = 1, this.$element[c]("in"), a.support.transition && this.$element.hasClass("collapse") ? this.$element.one(a.support.transition.end, h) : h())
- },
- toggle: function() {
- this[this.$element.hasClass("in") ? "hide" : "show"]()
- }
- };
- a.fn.collapse = function(c) {
- return this.each(function() {
- var b = a(this),
- e = b.data("collapse"),
- f = "object" == typeof c && c;
- e || b.data("collapse", e = new d(this, f));
- "string" == typeof c && e[c]()
- })
- };
- a.fn.collapse.defaults = {
- toggle: !0
- };
- a.fn.collapse.Constructor = d;
- a(function() {
- a("body").on("click.collapse.data-api", "[data-toggle=collapse]", function(c) {
- var b = a(this),
- e;
- c = b.attr("data-target") || c.preventDefault() || (e = b.attr("href")) && e.replace(/.*(?=#[^\s]+$)/, "");
- e = a(c).data("collapse") ? "toggle" : b.data();
- b[a(c).hasClass("in") ? "addClass" : "removeClass"]("collapsed");
- a(c).collapse(e)
- })
- })
- }(window.jQuery);
- ! function(a) {
- function d() {
- c(a(b)).removeClass("open")
- }
- function c(c) {
- var b = c.attr("data-target"),
- e;
- return b || (b = c.attr("href"), b = b && /#/.test(b) && b.replace(/.*(?=#[^\s]*$)/, "")), e = a(b), e.length || (e = c.parent()), e
- }
- var b = "[data-toggle=dropdown]",
- e = function(c) {
- var b = a(c).on("click.dropdown.data-api", this.toggle);
- a("html").on("click.dropdown.data-api", function() {
- b.parent().removeClass("open")
- })
- };
- e.prototype = {
- constructor: e,
- toggle: function(b) {
- b = a(this);
- var e, g;
- if (!b.is(".disabled, :disabled")) return e = c(b),
- g = e.hasClass("open"), d(), g || (e.toggleClass("open"), b.focus()), !1
- },
- keydown: function(b) {
- var e, d, m;
- if (/(38|40|27)/.test(b.keyCode) && (e = a(this), b.preventDefault(), b.stopPropagation(), !e.is(".disabled, :disabled"))) {
- d = c(e);
- m = d.hasClass("open");
- if (!m || m && 27 == b.keyCode) return e.click();
- e = a("[role=menu] li:not(.divider) a", d);
- e.length && (d = e.index(e.filter(":focus")), 38 == b.keyCode && 0 < d && d--, 40 == b.keyCode && d < e.length - 1 && d++, ~d || (d = 0), e.eq(d).focus())
- }
- }
- };
- a.fn.dropdown = function(c) {
- return this.each(function() {
- var b =
- a(this),
- d = b.data("dropdown");
- d || b.data("dropdown", d = new e(this));
- "string" == typeof c && d[c].call(b)
- })
- };
- a.fn.dropdown.Constructor = e;
- a(function() {
- a("html").on("click.dropdown.data-api touchstart.dropdown.data-api", d);
- a("body").on("click.dropdown touchstart.dropdown.data-api", ".dropdown form", function(a) {
- a.stopPropagation()
- }).on("click.dropdown.data-api touchstart.dropdown.data-api", b, e.prototype.toggle).on("keydown.dropdown.data-api touchstart.dropdown.data-api", b + ", [role=menu]", e.prototype.keydown)
- })
- }(window.jQuery);
- ! function(a) {
- var d = function(c, b) {
- this.options = b;
- this.$element = a(c).delegate('[data-dismiss="modal"]', "click.dismiss.modal", a.proxy(this.hide, this));
- this.options.remote && this.$element.find(".modal-body").load(this.options.remote)
- };
- d.prototype = {
- constructor: d,
- toggle: function() {
- return this[this.isShown ? "hide" : "show"]()
- },
- show: function() {
- var c = this,
- b = a.Event("show");
- this.$element.trigger(b);
- this.isShown || b.isDefaultPrevented() || (a("body").addClass("modal-open"), this.isShown = !0, this.escape(), this.backdrop(function() {
- var b =
- a.support.transition && c.$element.hasClass("fade");
- c.$element.parent().length || c.$element.appendTo(document.body);
- c.$element.show();
- b && c.$element[0].offsetWidth;
- c.$element.addClass("in").attr("aria-hidden", !1).focus();
- c.enforceFocus();
- b ? c.$element.one(a.support.transition.end, function() {
- c.$element.trigger("shown")
- }) : c.$element.trigger("shown")
- }))
- },
- hide: function(c) {
- c && c.preventDefault();
- c = a.Event("hide");
- this.$element.trigger(c);
- this.isShown && !c.isDefaultPrevented() && (this.isShown = !1, a("body").removeClass("modal-open"),
- this.escape(), a(document).off("focusin.modal"), this.$element.removeClass("in").attr("aria-hidden", !0), a.support.transition && this.$element.hasClass("fade") ? this.hideWithTransition() : this.hideModal())
- },
- enforceFocus: function() {
- var c = this;
- a(document).on("focusin.modal", function(a) {
- c.$element[0] !== a.target && !c.$element.has(a.target).length && c.$element.focus()
- })
- },
- escape: function() {
- var a = this;
- this.isShown && this.options.keyboard ? this.$element.on("keyup.dismiss.modal", function(b) {
- 27 == b.which && a.hide()
- }) : this.isShown ||
- this.$element.off("keyup.dismiss.modal")
- },
- hideWithTransition: function() {
- var c = this,
- b = setTimeout(function() {
- c.$element.off(a.support.transition.end);
- c.hideModal()
- }, 500);
- this.$element.one(a.support.transition.end, function() {
- clearTimeout(b);
- c.hideModal()
- })
- },
- hideModal: function(a) {
- this.$element.hide().trigger("hidden");
- this.backdrop()
- },
- removeBackdrop: function() {
- this.$backdrop.remove();
- this.$backdrop = null
- },
- backdrop: function(c) {
- var b = this.$element.hasClass("fade") ? "fade" : "";
- if (this.isShown && this.options.backdrop) {
- var e =
- a.support.transition && b;
- this.$backdrop = a('<div class="modal-backdrop ' + b + '" />').appendTo(document.body);
- "static" != this.options.backdrop && this.$backdrop.click(a.proxy(this.hide, this));
- e && this.$backdrop[0].offsetWidth;
- this.$backdrop.addClass("in");
- e ? this.$backdrop.one(a.support.transition.end, c) : c()
- } else !this.isShown && this.$backdrop ? (this.$backdrop.removeClass("in"), a.support.transition && this.$element.hasClass("fade") ? this.$backdrop.one(a.support.transition.end, a.proxy(this.removeBackdrop, this)) : this.removeBackdrop()) :
- c && c()
- }
- };
- a.fn.modal = function(c) {
- return this.each(function() {
- var b = a(this),
- e = b.data("modal"),
- f = a.extend({}, a.fn.modal.defaults, b.data(), "object" == typeof c && c);
- e || b.data("modal", e = new d(this, f));
- "string" == typeof c ? e[c]() : f.show && e.show()
- })
- };
- a.fn.modal.defaults = {
- backdrop: !0,
- keyboard: !0,
- show: !0
- };
- a.fn.modal.Constructor = d;
- a(function() {
- a("body").on("click.modal.data-api", '[data-toggle="modal"]', function(c) {
- var b = a(this),
- e = b.attr("href"),
- d = a(b.attr("data-target") || e && e.replace(/.*(?=#[^\s]+$)/, "")),
- e = d.data("modal") ?
- "toggle" : a.extend({
- remote: !/#/.test(e) && e
- }, d.data(), b.data());
- c.preventDefault();
- d.modal(e).one("hide", function() {
- b.focus()
- })
- })
- })
- }(window.jQuery);
- ! function(a) {
- var d = function(a, b) {
- this.init("tooltip", a, b)
- };
- d.prototype = {
- constructor: d,
- init: function(c, b, e) {
- var d, h;
- this.type = c;
- this.$element = a(b);
- this.options = this.getOptions(e);
- this.enabled = !0;
- "click" == this.options.trigger ? this.$element.on("click." + this.type, this.options.selector, a.proxy(this.toggle, this)) : "manual" != this.options.trigger && (d = "hover" == this.options.trigger ? "mouseenter" : "focus", h = "hover" == this.options.trigger ? "mouseleave" : "blur", this.$element.on(d + "." + this.type, this.options.selector,
- a.proxy(this.enter, this)), this.$element.on(h + "." + this.type, this.options.selector, a.proxy(this.leave, this)));
- this.options.selector ? this._options = a.extend({}, this.options, {
- trigger: "manual",
- selector: ""
- }) : this.fixTitle()
- },
- getOptions: function(c) {
- return c = a.extend({}, a.fn[this.type].defaults, c, this.$element.data()), c.delay && "number" == typeof c.delay && (c.delay = {
- show: c.delay,
- hide: c.delay
- }), c
- },
- enter: function(c) {
- var b = a(c.currentTarget)[this.type](this._options).data(this.type);
- if (!b.options.delay || !b.options.delay.show) return b.show();
- clearTimeout(this.timeout);
- b.hoverState = "in";
- this.timeout = setTimeout(function() {
- "in" == b.hoverState && b.show()
- }, b.options.delay.show)
- },
- leave: function(c) {
- var b = a(c.currentTarget)[this.type](this._options).data(this.type);
- this.timeout && clearTimeout(this.timeout);
- if (!b.options.delay || !b.options.delay.hide) return b.hide();
- b.hoverState = "out";
- this.timeout = setTimeout(function() {
- "out" == b.hoverState && b.hide()
- }, b.options.delay.hide)
- },
- show: function() {
- var a, b, e, d, h, g, m;
- if (this.hasContent() && this.enabled) {
- a = this.tip();
- this.setContent();
- this.options.animation && a.addClass("fade");
- g = "function" == typeof this.options.placement ? this.options.placement.call(this, a[0], this.$element[0]) : this.options.placement;
- b = /in/.test(g);
- a.remove().css({
- top: 0,
- left: 0,
- display: "block"
- }).appendTo(b ? this.$element : document.body);
- e = this.getPosition(b);
- d = a[0].offsetWidth;
- h = a[0].offsetHeight;
- switch (b ? g.split(" ")[1] : g) {
- case "bottom":
- m = {
- top: e.top + e.height,
- left: e.left + e.width / 2 - d / 2
- };
- break;
- case "top":
- m = {
- top: e.top - h,
- left: e.left + e.width / 2 - d / 2
- };
- break;
- case "left":
- m = {
- top: e.top + e.height / 2 - h / 2,
- left: e.left - d
- };
- break;
- case "right":
- m = {
- top: e.top + e.height / 2 - h / 2,
- left: e.left + e.width
- }
- }
- a.css(m).addClass(g).addClass("in")
- }
- },
- setContent: function() {
- var a = this.tip(),
- b = this.getTitle();
- a.find(".tooltip-inner")[this.options.html ? "html" : "text"](b);
- a.removeClass("fade in top bottom left right")
- },
- hide: function() {
- function c() {
- var c = setTimeout(function() {
- b.off(a.support.transition.end).remove()
- }, 500);
- b.one(a.support.transition.end, function() {
- clearTimeout(c);
- b.remove()
- })
- }
- var b = this.tip();
- return b.removeClass("in"), a.support.transition && this.$tip.hasClass("fade") ? c() : b.remove(), this
- },
- fixTitle: function() {
- var a = this.$element;
- (a.attr("title") || "string" != typeof a.attr("data-original-title")) && a.attr("data-original-title", a.attr("title") || "").removeAttr("title")
- },
- hasContent: function() {
- return this.getTitle()
- },
- getPosition: function(c) {
- return a.extend({}, c ? {
- top: 0,
- left: 0
- } : this.$element.offset(), {
- width: this.$element[0].offsetWidth,
- height: this.$element[0].offsetHeight
- })
- },
- getTitle: function() {
- var a,
- b = this.$element,
- d = this.options;
- return a = b.attr("data-original-title") || ("function" == typeof d.title ? d.title.call(b[0]) : d.title), a
- },
- tip: function() {
- return this.$tip = this.$tip || a(this.options.template)
- },
- validate: function() {
- this.$element[0].parentNode || (this.hide(), this.$element = null, this.options = null)
- },
- enable: function() {
- this.enabled = !0
- },
- disable: function() {
- this.enabled = !1
- },
- toggleEnabled: function() {
- this.enabled = !this.enabled
- },
- toggle: function() {
- this[this.tip().hasClass("in") ? "hide" : "show"]()
- },
- destroy: function() {
- this.hide().$element.off("." +
- this.type).removeData(this.type)
- }
- };
- a.fn.tooltip = function(c) {
- return this.each(function() {
- var b = a(this),
- e = b.data("tooltip"),
- f = "object" == typeof c && c;
- e || b.data("tooltip", e = new d(this, f));
- "string" == typeof c && e[c]()
- })
- };
- a.fn.tooltip.Constructor = d;
- a.fn.tooltip.defaults = {
- animation: !1,
- placement: "top",
- selector: !1,
- template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
- trigger: "hover",
- title: "",
- delay: 0,
- html: !0
- }
- }(window.jQuery);
- ! function(a) {
- var d = function(a, b) {
- this.init("popover", a, b)
- };
- d.prototype = a.extend({}, a.fn.tooltip.Constructor.prototype, {
- constructor: d,
- setContent: function() {
- var a = this.tip(),
- b = this.getTitle(),
- d = this.getContent();
- a.find(".popover-title")[this.options.html ? "html" : "text"](b);
- a.find(".popover-content > *")[this.options.html ? "html" : "text"](d);
- a.removeClass("fade top bottom left right in")
- },
- hasContent: function() {
- return this.getTitle() || this.getContent()
- },
- getContent: function() {
- var a, b = this.$element,
- d = this.options;
- return a = b.attr("data-content") || ("function" == typeof d.content ? d.content.call(b[0]) : d.content), a
- },
- tip: function() {
- return this.$tip || (this.$tip = a(this.options.template)), this.$tip
- },
- destroy: function() {
- this.hide().$element.off("." + this.type).removeData(this.type)
- }
- });
- a.fn.popover = function(c) {
- return this.each(function() {
- var b = a(this),
- e = b.data("popover"),
- f = "object" == typeof c && c;
- e || b.data("popover", e = new d(this, f));
- "string" == typeof c && e[c]()
- })
- };
- a.fn.popover.Constructor = d;
- a.fn.popover.defaults = a.extend({},
- a.fn.tooltip.defaults, {
- placement: "right",
- trigger: "click",
- content: "",
- template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'
- })
- }(window.jQuery);
- ! function(a) {
- function d(c, b) {
- var d = a.proxy(this.process, this),
- f = a(c).is("body") ? a(window) : a(c),
- h;
- this.options = a.extend({}, a.fn.scrollspy.defaults, b);
- this.$scrollElement = f.on("scroll.scroll-spy.data-api", d);
- this.selector = (this.options.target || (h = a(c).attr("href")) && h.replace(/.*(?=#[^\s]+$)/, "") || "") + " .nav li > a";
- this.$body = a("body");
- this.refresh();
- this.process()
- }
- d.prototype = {
- constructor: d,
- refresh: function() {
- var c = this;
- this.offsets = a([]);
- this.targets = a([]);
- this.$body.find(this.selector).map(function() {
- var c =
- a(this),
- c = c.data("target") || c.attr("href"),
- d = /^#\w/.test(c) && a(c);
- return d && d.length && [
- [d.position().top, c]
- ] || null
- }).sort(function(a, c) {
- return a[0] - c[0]
- }).each(function() {
- c.offsets.push(this[0]);
- c.targets.push(this[1])
- })
- },
- process: function() {
- var a = this.$scrollElement.scrollTop() + this.options.offset,
- b = (this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight) - this.$scrollElement.height(),
- d = this.offsets,
- f = this.targets,
- h = this.activeTarget,
- g;
- if (a >= b) return h != (g = f.last()[0]) && this.activate(g);
- for (g =
- d.length; g--;) h != f[g] && a >= d[g] && (!d[g + 1] || a <= d[g + 1]) && this.activate(f[g])
- },
- activate: function(c) {
- this.activeTarget = c;
- a(this.selector).parent(".active").removeClass("active");
- c = a(this.selector + '[data-target="' + c + '"],' + this.selector + '[href="' + c + '"]').parent("li").addClass("active");
- c.parent(".dropdown-menu").length && (c = c.closest("li.dropdown").addClass("active"));
- c.trigger("activate")
- }
- };
- a.fn.scrollspy = function(c) {
- return this.each(function() {
- var b = a(this),
- e = b.data("scrollspy"),
- f = "object" == typeof c && c;
- e || b.data("scrollspy", e = new d(this, f));
- "string" == typeof c && e[c]()
- })
- };
- a.fn.scrollspy.Constructor = d;
- a.fn.scrollspy.defaults = {
- offset: 10
- };
- a(window).on("load", function() {
- a('[data-spy="scroll"]').each(function() {
- var c = a(this);
- c.scrollspy(c.data())
- })
- })
- }(window.jQuery);
- ! function(a) {
- var d = function(c) {
- this.element = a(c)
- };
- d.prototype = {
- constructor: d,
- show: function() {
- var c = this.element,
- b = c.closest("ul:not(.dropdown-menu)"),
- d = c.attr("data-target"),
- f, h;
- d || (d = c.attr("href"), d = d && d.replace(/.*(?=#[^\s]*$)/, ""));
- c.parent("li").hasClass("active") || (f = b.find(".active a").last()[0], h = a.Event("show", {
- relatedTarget: f
- }), c.trigger(h), h.isDefaultPrevented() || (d = a(d), this.activate(c.parent("li"), b), this.activate(d, d.parent(), function() {
- c.trigger({
- type: "shown",
- relatedTarget: f
- })
- })))
- },
- activate: function(c, b, d) {
- function f() {
- h.removeClass("active").find("> .dropdown-menu > .active").removeClass("active");
- c.addClass("active");
- g ? (c[0].offsetWidth, c.addClass("in")) : c.removeClass("fade");
- c.parent(".dropdown-menu") && c.closest("li.dropdown").addClass("active");
- d && d()
- }
- var h = b.find("> .active"),
- g = d && a.support.transition && h.hasClass("fade");
- g ? h.one(a.support.transition.end, f) : f();
- h.removeClass("in")
- }
- };
- a.fn.tab = function(c) {
- return this.each(function() {
- var b = a(this),
- e = b.data("tab");
- e || b.data("tab",
- e = new d(this));
- "string" == typeof c && e[c]()
- })
- };
- a.fn.tab.Constructor = d;
- a(function() {
- a("body").on("click.tab.data-api", '[data-toggle="tab"], [data-toggle="pill"]', function(c) {
- c.preventDefault();
- a(this).tab("show")
- })
- })
- }(window.jQuery);
- ! function(a) {
- var d = function(c, b) {
- this.$element = a(c);
- this.options = a.extend({}, a.fn.typeahead.defaults, b);
- this.matcher = this.options.matcher || this.matcher;
- this.sorter = this.options.sorter || this.sorter;
- this.highlighter = this.options.highlighter || this.highlighter;
- this.updater = this.options.updater || this.updater;
- this.$menu = a(this.options.menu).appendTo("body");
- this.source = this.options.source;
- this.shown = !1;
- this.listen()
- };
- d.prototype = {
- constructor: d,
- select: function() {
- var a = this.$menu.find(".active").attr("data-value");
- return this.$element.val(this.updater(a)).change(), this.hide()
- },
- updater: function(a) {
- return a
- },
- show: function() {
- var c = a.extend({}, this.$element.offset(), {
- height: this.$element[0].offsetHeight
- });
- return this.$menu.css({
- top: c.top + c.height,
- left: c.left
- }), this.$menu.show(), this.shown = !0, this
- },
- hide: function() {
- return this.$menu.hide(), this.shown = !1, this
- },
- lookup: function(c) {
- var b;
- return this.query = this.$element.val(), !this.query || this.query.length < this.options.minLength ? this.shown ? this.hide() : this : (b = a.isFunction(this.source) ?
- this.source(this.query, a.proxy(this.process, this)) : this.source, b ? this.process(b) : this)
- },
- process: function(c) {
- var b = this;
- return c = a.grep(c, function(a) {
- return b.matcher(a)
- }), c = this.sorter(c), c.length ? this.render(c.slice(0, this.options.items)).show() : this.shown ? this.hide() : this
- },
- matcher: function(a) {
- return ~a.toLowerCase().indexOf(this.query.toLowerCase())
- },
- sorter: function(a) {
- for (var b = [], d = [], f = [], h; h = a.shift();) h.toLowerCase().indexOf(this.query.toLowerCase()) ? ~h.indexOf(this.query) ? d.push(h) : f.push(h) :
- b.push(h);
- return b.concat(d, f)
- },
- highlighter: function(a) {
- var b = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
- return a.replace(new RegExp("(" + b + ")", "ig"), function(a, c) {
- return "<strong>" + c + "</strong>"
- })
- },
- render: function(c) {
- var b = this;
- return c = a(c).map(function(c, d) {
- return c = a(b.options.item).attr("data-value", d), c.find("a").html(b.highlighter(d)), c[0]
- }), c.first().addClass("active"), this.$menu.html(c), this
- },
- next: function(c) {
- c = this.$menu.find(".active").removeClass("active").next();
- c.length ||
- (c = a(this.$menu.find("li")[0]));
- c.addClass("active")
- },
- prev: function(a) {
- a = this.$menu.find(".active").removeClass("active").prev();
- a.length || (a = this.$menu.find("li").last());
- a.addClass("active")
- },
- listen: function() {
- this.$element.on("blur", a.proxy(this.blur, this)).on("keypress", a.proxy(this.keypress, this)).on("keyup", a.proxy(this.keyup, this));
- (a.browser.chrome || a.browser.webkit || a.browser.msie) && this.$element.on("keydown", a.proxy(this.keydown, this));
- this.$menu.on("click", a.proxy(this.click, this)).on("mouseenter",
- "li", a.proxy(this.mouseenter, this))
- },
- move: function(a) {
- if (this.shown) {
- switch (a.keyCode) {
- case 9:
- case 13:
- case 27:
- a.preventDefault();
- break;
- case 38:
- a.preventDefault();
- this.prev();
- break;
- case 40:
- a.preventDefault(), this.next()
- }
- a.stopPropagation()
- }
- },
- keydown: function(c) {
- this.suppressKeyPressRepeat = !~a.inArray(c.keyCode, [40, 38, 9, 13, 27]);
- this.move(c)
- },
- keypress: function(a) {
- this.suppressKeyPressRepeat || this.move(a)
- },
- keyup: function(a) {
- switch (a.keyCode) {
- case 40:
- case 38:
- break;
- case 9:
- case 13:
- if (!this.shown) return;
- this.select();
- break;
- case 27:
- if (!this.shown) return;
- this.hide();
- break;
- default:
- this.lookup()
- }
- a.stopPropagation();
- a.preventDefault()
- },
- blur: function(a) {
- var b = this;
- setTimeout(function() {
- b.hide()
- }, 150)
- },
- click: function(a) {
- a.stopPropagation();
- a.preventDefault();
- this.select()
- },
- mouseenter: function(c) {
- this.$menu.find(".active").removeClass("active");
- a(c.currentTarget).addClass("active")
- }
- };
- a.fn.typeahead = function(c) {
- return this.each(function() {
- var b = a(this),
- e = b.data("typeahead"),
- f = "object" == typeof c && c;
- e || b.data("typeahead",
- e = new d(this, f));
- "string" == typeof c && e[c]()
- })
- };
- a.fn.typeahead.defaults = {
- source: [],
- items: 8,
- menu: '<ul class="typeahead dropdown-menu"></ul>',
- item: '<li><a href="#"></a></li>',
- minLength: 1
- };
- a.fn.typeahead.Constructor = d;
- a(function() {
- a("body").on("focus.typeahead.data-api", '[data-provide="typeahead"]', function(c) {
- var b = a(this);
- b.data("typeahead") || (c.preventDefault(), b.typeahead(b.data()))
- })
- })
- }(window.jQuery);
- ! function(a) {
- var d = function(c, b) {
- this.options = a.extend({}, a.fn.affix.defaults, b);
- this.$window = a(window).on("scroll.affix.data-api", a.proxy(this.checkPosition, this));
- this.$element = a(c);
- this.checkPosition()
- };
- d.prototype.checkPosition = function() {
- if (this.$element.is(":visible")) {
- var c = a(document).height(),
- b = this.$window.scrollTop(),
- d = this.$element.offset(),
- f = this.options.offset,
- h = f.bottom,
- g = f.top;
- "object" != typeof f && (h = g = f);
- "function" == typeof g && (g = f.top());
- "function" == typeof h && (h = f.bottom());
- c = null !=
- this.unpin && b + this.unpin <= d.top ? !1 : null != h && d.top + this.$element.height() >= c - h ? "bottom" : null != g && b <= g ? "top" : !1;
- this.affixed !== c && (this.affixed = c, this.unpin = "bottom" == c ? d.top - b : null, this.$element.removeClass("affix affix-top affix-bottom").addClass("affix" + (c ? "-" + c : "")))
- }
- };
- a.fn.affix = function(c) {
- return this.each(function() {
- var b = a(this),
- e = b.data("affix"),
- f = "object" == typeof c && c;
- e || b.data("affix", e = new d(this, f));
- "string" == typeof c && e[c]()
- })
- };
- a.fn.affix.Constructor = d;
- a.fn.affix.defaults = {
- offset: 0
- };
- a(window).on("load",
- function() {
- a('[data-spy="affix"]').each(function() {
- var c = a(this),
- b = c.data();
- b.offset = b.offset || {};
- b.offsetBottom && (b.offset.bottom = b.offsetBottom);
- b.offsetTop && (b.offset.top = b.offsetTop);
- c.affix(b)
- })
- })
- }(window.jQuery);
- (function(a, d, c) {
- function b(a) {
- var b = {},
- d = /^jQuery\d+$/;
- c.each(a.attributes, function(a, c) {
- c.specified && !d.test(c.name) && (b[c.name] = c.value)
- });
- return b
- }
- function e(a, b) {
- var e = c(this);
- if (this.value == e.attr("placeholder") && e.hasClass("placeholder"))
- if (e.data("placeholder-password")) {
- e = e.hide().next().show().attr("id", e.removeAttr("id").data("placeholder-id"));
- if (!0 === a) return e[0].value = b;
- e.focus()
- } else this.value = "", e.removeClass("placeholder"), this == d.activeElement && this.select()
- }
- function f() {
- var a,
- d = c(this),
- f = this.id;
- if ("" == this.value) {
- if ("password" == this.type) {
- if (!d.data("placeholder-textinput")) {
- try {
- a = d.clone().attr({
- type: "text"
- })
- } catch (k) {
- a = c("<input>").attr(c.extend(b(this), {
- type: "text"
- }))
- }
- a.removeAttr("name").data({
- "placeholder-password": !0,
- "placeholder-id": f
- }).bind("focus.placeholder", e);
- d.data({
- "placeholder-textinput": a,
- "placeholder-id": f
- }).before(a)
- }
- d = d.removeAttr("id").hide().prev().attr("id", f).show()
- }
- d.addClass("placeholder");
- d[0].value = d.attr("placeholder")
- } else d.removeClass("placeholder")
- }
- var h = "placeholder" in d.createElement("input"),
- g = "placeholder" in d.createElement("textarea"),
- m = c.fn,
- k = c.valHooks;
- h && g ? (m = m.placeholder = function() {
- return this
- }, m.input = m.textarea = !0) : (m = m.placeholder = function() {
- this.filter((h ? "textarea" : ":input") + "[placeholder]").not(".placeholder").bind({
- "focus.placeholder": e,
- "blur.placeholder": f
- }).data("placeholder-enabled", !0).trigger("blur.placeholder");
- return this
- }, m.input = h, m.textarea = g, m = {
- get: function(a) {
- var b = c(a);
- return b.data("placeholder-enabled") && b.hasClass("placeholder") ?
- "" : a.value
- },
- set: function(a, b) {
- var k = c(a);
- if (!k.data("placeholder-enabled")) return a.value = b;
- "" == b ? (a.value = b, a != d.activeElement && f.call(a)) : k.hasClass("placeholder") ? e.call(a, !0, b) || (a.value = b) : a.value = b;
- return k
- }
- }, h || (k.input = m), g || (k.textarea = m), c(function() {
- c(d).delegate("form", "submit.placeholder", function() {
- var a = c(".placeholder", this).each(e);
- setTimeout(function() {
- a.each(f)
- }, 10)
- })
- }), c(a).bind("beforeunload.placeholder", function() {
- c(".placeholder").each(function() {
- this.value = ""
- })
- }))
- })(this, document,
- jQuery);
- (function(a) {
- "function" === typeof define && define.amd ? define(["jquery"], a) : "object" === typeof exports ? a(require("jquery")) : a(jQuery)
- })(function(a) {
- function d(a) {
- a = e.json ? JSON.stringify(a) : String(a);
- return e.raw ? a : encodeURIComponent(a)
- }
- function c(c, d) {
- var g;
- if (e.raw) g = c;
- else a: {
- var m = c;
- 0 === m.indexOf('"') && (m = m.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, "\\"));
- try {
- m = decodeURIComponent(m.replace(b, " "));
- g = e.json ? JSON.parse(m) : m;
- break a
- } catch (k) {}
- g = void 0
- }
- return a.isFunction(d) ? d(g) : g
- }
- var b = /\+/g,
- e =
- a.cookie = function(b, h, g) {
- if (void 0 !== h && !a.isFunction(h)) {
- g = a.extend({}, e.defaults, g);
- if ("number" === typeof g.expires) {
- var m = g.expires,
- k = g.expires = new Date;
- k.setTime(+k + 864E5 * m)
- }
- return document.cookie = [e.raw ? b : encodeURIComponent(b), "=", d(h), g.expires ? "; expires=" + g.expires.toUTCString() : "", g.path ? "; path=" + g.path : "", g.domain ? "; domain=" + g.domain : "", g.secure ? "; secure" : ""].join("")
- }
- g = b ? void 0 : {};
- for (var m = document.cookie ? document.cookie.split("; ") : [], k = 0, n = m.length; k < n; k++) {
- var q = m[k].split("="),
- l;
- l = q.shift();
- l = e.raw ? l : decodeURIComponent(l);
- q = q.join("=");
- if (b && b === l) {
- g = c(q, h);
- break
- }
- b || void 0 === (q = c(q)) || (g[l] = q)
- }
- return g
- };
- e.defaults = {};
- a.removeCookie = function(c, b) {
- if (void 0 === a.cookie(c)) return !1;
- a.cookie(c, "", a.extend({}, b, {
- expires: -1
- }));
- return !a.cookie(c)
- }
- });
- (function(a) {
- var d = !a.support.opacity;
- void 0 === a.proxy && a.extend({
- proxy: function(a, b) {
- a && (proxy = function() {
- return a.apply(b || this, arguments)
- });
- return proxy
- }
- });
- a.extend(a.easing, {
- easeOutBackMin: function(a, b, d, f, h, g) {
- void 0 === g && (g = 1);
- return f * ((b = b / h - 1) * b * ((g + 1) * b + g) + 1) + d
- }
- });
- a.extend(a.expr[":"], {
- value: function(c) {
- return a(c).val()
- }
- });
- a.extend({
- MsgBoxObject: {
- defaults: {
- name: "jquery-msgbox",
- zIndex: 1E4,
- width: 420,
- height: "auto",
- background: "#FFFFFF",
- modal: !0,
- overlay: {
- background: "rgba(33,18,51,0.9)",
- opacity: .5
- },
- showDuration: 200,
- closeDuration: 100,
- moveDuration: 550,
- shake: {
- distance: 10,
- duration: 100,
- transition: "easeOutBackMin",
- loops: 2
- },
- form: {
- active: !1,
- action: "#",
- method: "post"
- },
- emergefrom: "top"
- },
- options: {},
- esqueleto: {
- msgbox: [],
- wrapper: [],
- form: [],
- buttons: [],
- inputs: []
- },
- visible: !1,
- i: 0,
- animation: !1,
- config: function(c) {
- this.options = a.extend(!0, this.options, c);
- this.overlay.element.css(this.options.overlay);
- this.overlay.options.hideOnClick = !this.options.modal;
- this.esqueleto.msgbox.css({
- width: this.options.width,
- height: this.options.height,
- "background-color": this.options.background
- });
- this.moveBox()
- },
- overlay: {
- create: function(c) {
- this.options = c;
- this.element = a('<div id="' + (new Date).getTime() + '"></div>');
- this.element.css(a.extend({}, {
- position: "fixed",
- top: 0,
- left: 0,
- opacity: 0,
- display: "none",
- "z-index": this.options.zIndex
- }, this.options.style));
- this.element.click(a.proxy(function(c) {
- this.options.hideOnClick && (a.isFunction(this.options.callback) ? this.options.callback() : this.hide());
- c.preventDefault()
- }, this));
- this.hidden = !0;
- this.inject();
- return this
- },
- inject: function() {
- this.target = a(document.body);
- this.target.append(this.element);
- if (d) {
- this.element.css({
- position: "absolute"
- });
- var c = parseInt(this.element.css("zIndex"));
- if (!c) {
- var c = 1,
- b = this.element.css("position");
- "static" != b && b || this.element.css({
- position: "relative"
- });
- this.element.css({
- zIndex: c
- })
- }
- c = (this.options.zIndex || 0 === this.options.zIndex) && c > this.options.zIndex ? this.options.zIndex : c - 1;
- 0 > c && (c = 1);
- this.shim = a('<iframe id="IF_' + (new Date).getTime() + '" scrolling="no" frameborder=0 src=""></div>');
- this.shim.css({
- zIndex: c,
- position: "absolute",
- top: 0,
- left: 0,
- border: "none",
- width: 0,
- height: 0,
- opacity: 0
- });
- this.shim.insertAfter(this.element);
- a("html, body").css({
- height: "100%",
- width: "100%",
- "margin-left": 0,
- "margin-right": 0
- })
- }
- },
- resize: function(c, b) {
- this.element.css({
- height: 0,
- width: 0
- });
- this.shim && this.shim.css({
- height: 0,
- width: 0
- });
- a(document).width();
- var d = a(document).height();
- this.element.css({
- width: "100%",
- height: b ? b : d
- });
- this.shim && (this.shim.css({
- height: 0,
- width: 0
- }), this.shim.css({
- position: "absolute",
- left: 0,
- top: 0,
- width: this.element.width(),
- height: b ? b : d
- }));
- return this
- },
- show: function() {
- a(".modal") && a(".modal").removeAttr("tabindex");
- a.browser.msie && a(".modal") && a(".modal").hide();
- if (!this.hidden) return this;
- this.transition && this.transition.stop();
- this.target.bind("resize", a.proxy(this.resize, this));
- this.resize();
- this.shim && this.shim.css({
- display: "block"
- });
- this.hidden = !1;
- this.transition = this.element.fadeIn(this.options.showDuration, a.proxy(function() {
- this.element.trigger("show")
- }, this));
- return this
- },
- hide: function() {
- a(".modal") &&
- (a(".modal").attr("tabindex", "-1"), a(".modal").focus());
- a.browser.msie && a(".modal") && a(".modal").show();
- if (this.hidden) return this;
- this.transition && this.transition.stop();
- this.target.unbind("resize");
- this.shim && this.shim.css({
- display: "none"
- });
- this.hidden = !0;
- this.transition = this.element.fadeOut(this.options.closeDuration, a.proxy(function() {
- this.element.trigger("hide");
- this.element.css({
- height: 0,
- width: 0
- })
- }, this));
- return this
- }
- },
- create: function() {
- this.options = a.extend(!0, this.defaults, this.options);
- this.overlay.create({
- style: this.options.overlay,
- hideOnClick: !this.options.modal,
- zIndex: this.options.zIndex - 1,
- showDuration: this.options.showDuration,
- closeDuration: this.options.closeDuration
- });
- this.esqueleto.msgbox = a('<div class="' + this.options.name + '"></div>');
- this.esqueleto.msgbox.css({
- display: "none",
- position: "absolute",
- top: 0,
- left: 0,
- width: this.options.width,
- height: this.options.height,
- "z-index": this.options.zIndex,
- "word-wrap": "break-word",
- "-moz-box-shadow": "0 0 15px rgba(0, 0, 0, 0.5)",
- "-webkit-box-shadow": "0 0 15px rgba(0, 0, 0, 0.5)",
- "box-shadow": "0 0 15px rgba(0, 0, 0, 0.5)",
- "-moz-border-radius": "6px",
- "-webkit-border-radius": "6px",
- "border-radius": "6px",
- "background-color": this.options.background
- });
- this.esqueleto.wrapper = a('<div class="' + this.options.name + '-wrapper"></div>');
- this.esqueleto.msgbox.append(this.esqueleto.wrapper);
- this.esqueleto.form = a('<form action="' + this.options.formaction + '" method="post"></form>');
- this.esqueleto.wrapper.append(this.esqueleto.form);
- this.esqueleto.wrapper.css({
- height: d ? 80 : "auto",
- "min-height": 80,
- zoom: 1
- });
- a("body").append(this.esqueleto.msgbox);
- this.addevents();
- return this.esqueleto.msgbox
- },
- addevents: function() {
- a(window).bind("resize", a.proxy(function() {
- this.visible && (this.overlay.resize(), this.moveBox())
- }, this));
- a(window).bind("scroll", a.proxy(function() {
- this.visible && this.moveBox()
- }, this));
- this.esqueleto.msgbox.bind("keyup", a.proxy(function(a) {
- 27 == a.keyCode && this.close(!1)
- }, this));
- this.esqueleto.form.bind("submit", a.proxy(function(c) {
- a("input[type=submit]:first, button[type=submit]:first, button:first", this.esqueleto.form).trigger("click");
- options.form.active || c.preventDefault()
- }, this));
- this.overlay.element.bind("show", a.proxy(function() {
- a(this).triggerHandler("show")
- }, this));
- this.overlay.element.bind("hide", a.proxy(function() {
- a(this).triggerHandler("close")
- }, this))
- },
- show: function(c, b, d) {
- var f = "alert info error prompt confirm custom".split(" ");
- this.esqueleto.msgbox.queue(this.options.name, a.proxy(function(h) {
- b = a.extend(!0, {
- type: "alert",
- form: {
- active: !1
- }
- }, b || {});
- h = "undefined" === typeof b.buttons ? "confirm" == b.type || "prompt" == b.type ? [{
- type: "submit",
- value: "Ok"
- }, {
- type: "cancel",
- value: "Cancel"
- }] : [{
- type: "submit",
- value: "Ok"
- }] : b.buttons;
- var g = "undefined" === typeof b.inputs && "prompt" == b.type ? [{
- type: "text",
- name: "prompt",
- value: ""
- }] : b.inputs;
- this.callback = a.isFunction(d) ? d : function(a) {};
- "undefined" !== typeof g && (this.esqueleto.inputs = a('<div class="' + this.options.name + '-inputs"></div>'), this.esqueleto.form.append(this.esqueleto.inputs), a.each(g, a.proxy(function(c, b) {
- if ("checkbox" == b.type) iLabel = b.label ? '<label class="' + this.options.name + '-label">' : "", fLabel =
- b.label ? b.label + "</label>" : "", b.value = void 0 === b.value ? "1" : b.value, iName = void 0 === b.name ? this.options.name + "-label-" + c : b.name, iChecked = b.checked, this.esqueleto.inputs.append(a(iLabel + '<input type="' + b.type + '" style="display:inline; width:auto;" name="' + iName + '" value="' + b.value + '" autocomplete="off"' + (iChecked ? ' checked="true"' : "") + "/> " + fLabel));
- else if ("number" == b.type) iLabel = b.label ? '<label class="' + this.options.name + '-label">' + b.label : "", fLabel = b.label ? "</label>" : "", b.value = void 0 === b.value ? "" :
- b.value, b.placeholder = void 0 === b.placeholder ? "" : b.placeholder, iRequired = void 0 === b.required || 0 == b.required ? "" : 'required="true"', iMin = "undefined" === typeof b.min ? "" : 'min="' + b.min + '"', iMax = "undefined" === typeof b.max ? "" : 'max="' + b.max + '"', iName = void 0 === b.name ? this.options.name + "-label-" + c : b.name, this.esqueleto.inputs.append(a(iLabel + '<input type="' + b.type + '" name="' + iName + '" value="' + b.value + '" placeholder="' + b.placeholder + '" autocomplete="off" ' + iRequired + " " + iMin + " " + iMax + "/> " + fLabel));
- else if ("select" ==
- b.type) {
- if ("undefined" !== typeof b.options && b.options instanceof Array && 0 < b.options.length) {
- iLabel = b.label ? '<label class="' + this.options.name + '-label">' + b.label : "";
- fLabel = b.label ? "</label>" : "";
- b.value = void 0 === b.value ? "" : b.value;
- b.placeholder = void 0 === b.placeholder ? "" : b.placeholder;
- iRequired = void 0 === b.required || 0 == b.required ? "" : 'required="true"';
- iName = void 0 === b.name ? this.options.name + "-label-" + c : b.name;
- var d = a(iLabel + '<select name="' + iName + '" ' + iRequired + '><option value="" disabled selected style="display:none;">' +
- b.placeholder + "</option></select> " + fLabel);
- a.map(b.options, function(b) {
- a(d).find("select").append('<option value="' + b + '">' + b + "</option>")
- });
- b.selected && a(d).find("select").val(b.selected);
- this.esqueleto.inputs.append(d)
- }
- } else iLabel = b.label ? '<label class="' + this.options.name + '-label">' + b.label : "", fLabel = b.label ? "</label>" : "", b.value = void 0 === b.value ? "" : b.value, b.placeholder = void 0 === b.placeholder ? "" : b.placeholder, iRequired = void 0 === b.required || 0 == b.required ? "" : 'required="true"', iMaxLength = void 0 ===
- typeof b.maxlength ? "" : 'maxlength="' + b.maxlength + '"', iName = void 0 === b.name ? this.options.name + "-label-" + c : b.name, this.esqueleto.inputs.append(a(iLabel + '<input type="' + b.type + '" name="' + iName + '" value="' + b.value + '" placeholder="' + b.placeholder + '" autocomplete="off" ' + iRequired + " " + iMaxLength + "/>" + fLabel))
- }, this)));
- this.esqueleto.buttons = a('<div class="' + this.options.name + '-buttons"></div>');
- this.esqueleto.form.append(this.esqueleto.buttons);
- b.form.active ? (this.esqueleto.form.attr("action", void 0 === b.form.action ?
- "#" : b.form.action), this.esqueleto.form.attr("method", void 0 === b.form.method ? "post" : b.form.method), this.options.form.active = !0) : (this.esqueleto.form.attr("action", "#"), this.esqueleto.form.attr("method", "post"), this.options.form.active = !1);
- "prompt" != b.type ? a.each(h, a.proxy(function(b, c) {
- "submit" == c.type ? this.esqueleto.buttons.append(a('<button type="submit" class="' + this.options.name + "-button-submit btn btn-primary" + (c["class"] || "") + '">' + c.value + "</button>").bind("click", a.proxy(function(a) {
- this.close(c.value);
- a.preventDefault()
- }, this))) : "cancel" == c.type && this.esqueleto.buttons.append(a('<button type="button" class="' + this.options.name + "-button-cancel btn" + (c["class"] || "") + '">' + c.value + "</button>").bind("click", a.proxy(function(a) {
- this.close(!1);
- a.preventDefault()
- }, this)))
- }, this)) : "prompt" == b.type && a.each(h, a.proxy(function(c, b) {
- "submit" == b.type ? this.esqueleto.buttons.append(a('<button type="submit" class="' + this.options.name + "-button-submit btn btn-primary" + (b["class"] || "") + '">' + b.value + "</button>").bind("click",
- a.proxy(function(b) {
- if (0 < a('input[required="true"]:not(:value)').length) a('input[required="true"]:not(:value):first').focus(), this.shake();
- else {
- if (this.options.form.active) return !0;
- this.close(this.toArguments(a("input, select", this.esqueleto.inputs)))
- }
- b.preventDefault()
- }, this))) : "cancel" == b.type && this.esqueleto.buttons.append(a('<button type="button" class="' + this.options.name + "-button-cancel btn" + (b["class"] || "") + '">' + b.value + "</button>").bind("click", a.proxy(function(a) {
- this.close(!1);
- a.preventDefault()
- },
- this)))
- }, this));
- this.esqueleto.form.prepend(c);
- a.each(f, a.proxy(function(a, b) {
- this.esqueleto.wrapper.removeClass(this.options.name + "-" + b)
- }, this));
- this.esqueleto.wrapper.addClass(this.options.name + "-" + b.type);
- this.moveBox();
- this.visible = !0;
- this.overlay.show();
- this.esqueleto.msgbox.css({
- display: "block",
- left: (a(document).width() - this.options.width) / 2
- });
- this.moveBox();
- setTimeout(a.proxy(function() {
- var b = a("input, button", this.esqueleto.msgbox);
- b.length && b.get(0).focus()
- }, this), this.options.moveDuration)
- },
- this));
- this.i++;
- 1 == this.i && this.esqueleto.msgbox.dequeue(this.options.name)
- },
- toArguments: function(c) {
- return a.map(c, function(b) {
- return a(b).val()
- })
- },
- moveBox: function() {
- var c = a(window).width(),
- b = a(window).height(),
- d = a(window).scrollLeft(),
- f = a(window).scrollTop(),
- h = this.esqueleto.msgbox.outerHeight(),
- g = 0,
- m = 0,
- g = d + (c - this.options.width) / 2,
- m = "bottom" == this.options.emergefrom ? f + b + 80 : f - h - 80;
- this.visible ? (this.animation && this.animation.stop, this.animation = this.esqueleto.msgbox.animate({
- left: g,
- top: f + (b - h) /
- 2
- }, {
- duration: this.options.moveDuration,
- queue: !1,
- easing: "easeOutBackMin"
- })) : this.esqueleto.msgbox.css({
- top: m,
- left: g
- })
- },
- close: function(c) {
- this.esqueleto.msgbox.css({
- display: "none",
- top: 0
- });
- this.visible = !1;
- a.isFunction(this.callback) && this.callback.apply(this, a.makeArray(c));
- setTimeout(a.proxy(function() {
- this.i--;
- this.esqueleto.msgbox.dequeue(this.options.name)
- }, this), this.options.closeDuration);
- 1 == this.i && this.overlay.hide();
- this.moveBox();
- this.esqueleto.form.empty()
- },
- shake: function() {
- var a = this.options.shake.distance,
- b = this.options.shake.duration,
- d = this.options.shake.transition,
- f = this.options.shake.loops,
- h = this.esqueleto.msgbox.position().left,
- g = this.esqueleto.msgbox;
- for (i = 0; i < f; i++) g.animate({
- left: h + a
- }, b, d), g.animate({
- left: h - a
- }, b, d);
- g.animate({
- left: h + a
- }, b, d);
- g.animate({
- left: h
- }, b, d)
- }
- },
- msgbox: function(c, b, d) {
- if ("object" == typeof c) a.MsgBoxObject.config(c);
- else return a.MsgBoxObject.show(c, b, d)
- }
- });
- a(function() {
- if (1.2 < parseFloat(a.fn.jquery)) a.MsgBoxObject.create();
- else throw "The jQuery version that was loaded is too old. MsgBox requires jQuery 1.3+";
- })
- })(jQuery);
- var _ = {};
- (function() {
- var a = {
- escape: {
- "&": "&",
- "<": "<",
- ">": ">",
- '"': """,
- "'": "'"
- },
- unescape: {}
- };
- $.map(a.escape, function(c, b) {
- a.unescape[c] = b
- });
- var d = {
- escape: new RegExp("[" + $.map(a.escape, function(a, b) {
- return b
- }).join("") + "]", "g"),
- unescape: new RegExp("(" + $.map(a.unescape, function(a, b) {
- return b
- }).join("|") + ")", "g")
- };
- $.map(["escape", "unescape"], function(c) {
- _[c] = function(b) {
- return null == b ? "" : ("" + b).replace(d[c], function(b) {
- return a[c][b]
- })
- }
- })
- })();
- (function(a) {
- a.event.special.destroyed = {
- remove: function(a) {
- a.handler && a.handler()
- }
- }
- })(jQuery);
- (function() {
- var a = {},
- d = this,
- c = d.async;
- a.noConflict = function() {
- d.async = c;
- return a
- };
- var b = function(a, b) {
- if (a.forEach) return a.forEach(b);
- for (var c = 0; c < a.length; c += 1) b(a[c], c, a)
- },
- e = function(a, c) {
- if (a.map) return a.map(c);
- var d = [];
- b(a, function(a, b, e) {
- d.push(c(a, b, e))
- });
- return d
- },
- f = function(a, c, d) {
- if (a.reduce) return a.reduce(c, d);
- b(a, function(a, b, e) {
- d = c(d, a, b, e)
- });
- return d
- },
- h = function(a) {
- if (Object.keys) return Object.keys(a);
- var b = [],
- c;
- for (c in a) a.hasOwnProperty(c) && b.push(c);
- return b
- };
- a.nextTick = "undefined" !==
- typeof process && process.nextTick ? process.nextTick : function(a) {
- setTimeout(a, 0)
- };
- a.forEach = function(a, c, d) {
- d = d || function() {};
- if (!a.length) return d();
- var e = 0;
- b(a, function(b) {
- c(b, function(b) {
- b ? (d(b), d = function() {}) : (e += 1, e === a.length && d(null))
- })
- })
- };
- a.forEachSeries = function(a, b, c) {
- c = c || function() {};
- if (!a.length) return c();
- var d = 0,
- e = function() {
- b(a[d], function(b) {
- b ? (c(b), c = function() {}) : (d += 1, d === a.length ? c(null) : e())
- })
- };
- e()
- };
- a.forEachLimit = function(a, b, c, d) {
- d = d || function() {};
- if (!a.length || 0 >= b) return d();
- var e = 0,
- f = 0,
- h = 0;
- (function E() {
- if (e === a.length) return d();
- for (; h < b && f < a.length;) f += 1, h += 1, c(a[f - 1], function(b) {
- b ? (d(b), d = function() {}) : (e += 1, --h, e === a.length ? d() : E())
- })
- })()
- };
- var g = function(b) {
- return function() {
- var c = Array.prototype.slice.call(arguments);
- return b.apply(null, [a.forEach].concat(c))
- }
- },
- m = function(b) {
- return function() {
- var c = Array.prototype.slice.call(arguments);
- return b.apply(null, [a.forEachSeries].concat(c))
- }
- },
- k = function(a, b, c, d) {
- var f = [];
- b = e(b, function(a, b) {
- return {
- index: b,
- value: a
- }
- });
- a(b,
- function(a, b) {
- c(a.value, function(c, d) {
- f[a.index] = d;
- b(c)
- })
- },
- function(a) {
- d(a, f)
- })
- };
- a.map = g(k);
- a.mapSeries = m(k);
- a.reduce = function(b, c, d, e) {
- a.forEachSeries(b, function(a, b) {
- d(c, a, function(a, d) {
- c = d;
- b(a)
- })
- }, function(a) {
- e(a, c)
- })
- };
- a.inject = a.reduce;
- a.foldl = a.reduce;
- a.reduceRight = function(b, c, d, f) {
- b = e(b, function(a) {
- return a
- }).reverse();
- a.reduce(b, c, d, f)
- };
- a.foldr = a.reduceRight;
- k = function(a, b, c, d) {
- var f = [];
- b = e(b, function(a, b) {
- return {
- index: b,
- value: a
- }
- });
- a(b, function(a, b) {
- c(a.value, function(c) {
- c && f.push(a);
- b()
- })
- },
- function(a) {
- d(e(f.sort(function(a, b) {
- return a.index - b.index
- }), function(a) {
- return a.value
- }))
- })
- };
- a.filter = g(k);
- a.filterSeries = m(k);
- a.select = a.filter;
- a.selectSeries = a.filterSeries;
- k = function(a, b, c, d) {
- var f = [];
- b = e(b, function(a, b) {
- return {
- index: b,
- value: a
- }
- });
- a(b, function(a, b) {
- c(a.value, function(c) {
- c || f.push(a);
- b()
- })
- }, function(a) {
- d(e(f.sort(function(a, b) {
- return a.index - b.index
- }), function(a) {
- return a.value
- }))
- })
- };
- a.reject = g(k);
- a.rejectSeries = m(k);
- k = function(a, b, c, d) {
- a(b, function(a, b) {
- c(a, function(c) {
- c ? (d(a),
- d = function() {}) : b()
- })
- }, function(a) {
- d()
- })
- };
- a.detect = g(k);
- a.detectSeries = m(k);
- a.some = function(b, c, d) {
- a.forEach(b, function(a, b) {
- c(a, function(a) {
- a && (d(!0), d = function() {});
- b()
- })
- }, function(a) {
- d(!1)
- })
- };
- a.any = a.some;
- a.every = function(b, c, d) {
- a.forEach(b, function(a, b) {
- c(a, function(a) {
- a || (d(!1), d = function() {});
- b()
- })
- }, function(a) {
- d(!0)
- })
- };
- a.all = a.every;
- a.sortBy = function(b, c, d) {
- a.map(b, function(a, b) {
- c(a, function(c, d) {
- c ? b(c) : b(null, {
- value: a,
- criteria: d
- })
- })
- }, function(a, b) {
- if (a) return d(a);
- d(null, e(b.sort(function(a,
- b) {
- var c = a.criteria,
- d = b.criteria;
- return c < d ? -1 : c > d ? 1 : 0
- }), function(a) {
- return a.value
- }))
- })
- };
- a.auto = function(a, c) {
- c = c || function() {};
- var d = h(a);
- if (!d.length) return c(null);
- var e = {},
- g = [],
- k = function(a) {
- g.unshift(a)
- },
- m = function() {
- b(g.slice(0), function(a) {
- a()
- })
- };
- k(function() {
- h(e).length === d.length && (c(null, e), c = function() {})
- });
- b(d, function(b) {
- var d = a[b] instanceof Function ? [a[b]] : a[b],
- h = function(a) {
- if (a) c(a), c = function() {};
- else {
- var r = Array.prototype.slice.call(arguments, 1);
- 1 >= r.length && (r = r[0]);
- e[b] = r;
- m()
- }
- },
- r = d.slice(0, Math.abs(d.length - 1)) || [],
- B = function() {
- return f(r, function(a, b) {
- return a && e.hasOwnProperty(b)
- }, !0) && !e.hasOwnProperty(b)
- };
- if (B()) d[d.length - 1](h, e);
- else {
- var w = function() {
- if (B()) {
- a: for (var a = w, b = 0; b < g.length; b += 1)
- if (g[b] === a) {
- g.splice(b, 1);
- break a
- }d[d.length - 1](h, e)
- }
- };
- k(w)
- }
- })
- };
- a.waterfall = function(b, c) {
- c = c || function() {};
- if (!b.length) return c();
- var d = function(b) {
- return function(e) {
- if (e) c(e), c = function() {};
- else {
- var f = Array.prototype.slice.call(arguments, 1),
- h = b.next();
- h ? f.push(d(h)) : f.push(c);
- a.nextTick(function() {
- b.apply(null, f)
- })
- }
- }
- };
- d(a.iterator(b))()
- };
- a.parallel = function(b, c) {
- c = c || function() {};
- if (b.constructor === Array) a.map(b, function(a, b) {
- a && a(function(a) {
- var c = Array.prototype.slice.call(arguments, 1);
- 1 >= c.length && (c = c[0]);
- b.call(null, a, c)
- })
- }, c);
- else {
- var d = {};
- a.forEach(h(b), function(a, c) {
- b[a](function(b) {
- var e = Array.prototype.slice.call(arguments, 1);
- 1 >= e.length && (e = e[0]);
- d[a] = e;
- c(b)
- })
- }, function(a) {
- c(a, d)
- })
- }
- };
- a.series = function(b, c) {
- c = c || function() {};
- if (b.constructor === Array) a.mapSeries(b,
- function(a, b) {
- a && a(function(a) {
- var c = Array.prototype.slice.call(arguments, 1);
- 1 >= c.length && (c = c[0]);
- b.call(null, a, c)
- })
- }, c);
- else {
- var d = {};
- a.forEachSeries(h(b), function(a, c) {
- b[a](function(b) {
- var e = Array.prototype.slice.call(arguments, 1);
- 1 >= e.length && (e = e[0]);
- d[a] = e;
- c(b)
- })
- }, function(a) {
- c(a, d)
- })
- }
- };
- a.iterator = function(a) {
- var b = function(c) {
- var d = function() {
- a.length && a[c].apply(null, arguments);
- return d.next()
- };
- d.next = function() {
- return c < a.length - 1 ? b(c + 1) : null
- };
- return d
- };
- return b(0)
- };
- a.apply = function(a) {
- var b =
- Array.prototype.slice.call(arguments, 1);
- return function() {
- return a.apply(null, b.concat(Array.prototype.slice.call(arguments)))
- }
- };
- k = function(a, b, c, d) {
- var e = [];
- a(b, function(a, b) {
- c(a, function(a, c) {
- e = e.concat(c || []);
- b(a)
- })
- }, function(a) {
- d(a, e)
- })
- };
- a.concat = g(k);
- a.concatSeries = m(k);
- a.whilst = function(b, c, d) {
- b() ? c(function(e) {
- if (e) return d(e);
- a.whilst(b, c, d)
- }) : d()
- };
- a.until = function(b, c, d) {
- b() ? d() : c(function(e) {
- if (e) return d(e);
- a.until(b, c, d)
- })
- };
- a.queue = function(c, d) {
- var e = 0,
- f = {
- tasks: [],
- concurrency: d,
- saturated: null,
- empty: null,
- drain: null,
- push: function(c, e) {
- c.constructor !== Array && (c = [c]);
- b(c, function(b) {
- f.tasks.push({
- data: b,
- callback: "function" === typeof e ? e : null
- });
- f.saturated && f.tasks.length == d && f.saturated();
- a.nextTick(f.process)
- })
- },
- process: function() {
- if (e < f.concurrency && f.tasks.length) {
- var a = f.tasks.shift();
- f.empty && 0 == f.tasks.length && f.empty();
- e += 1;
- c(a.data, function() {
- --e;
- a.callback && a.callback.apply(a, arguments);
- f.drain && 0 == f.tasks.length + e && f.drain();
- f.process()
- })
- }
- },
- length: function() {
- return f.tasks.length
- },
- running: function() {
- return e
- }
- };
- return f
- };
- g = function(a) {
- return function(c) {
- var d = Array.prototype.slice.call(arguments, 1);
- c.apply(null, d.concat([function(c) {
- var d = Array.prototype.slice.call(arguments, 1);
- "undefined" !== typeof console && (c ? console.error && console.error(c) : console[a] && b(d, function(b) {
- console[a](b)
- }))
- }]))
- }
- };
- a.log = g("log");
- a.dir = g("dir");
- a.memoize = function(a, b) {
- var c = {},
- d = {};
- b = b || function(a) {
- return a
- };
- var e = function() {
- var e = Array.prototype.slice.call(arguments),
- f = e.pop(),
- h = b.apply(null, e);
- h in
- c ? f.apply(null, c[h]) : h in d ? d[h].push(f) : (d[h] = [f], a.apply(null, e.concat([function() {
- c[h] = arguments;
- var a = d[h];
- delete d[h];
- for (var b = 0, r = a.length; b < r; b++) a[b].apply(null, arguments)
- }])))
- };
- e.unmemoized = a;
- return e
- };
- a.unmemoize = function(a) {
- return function() {
- return (a.unmemoized || a).apply(null, arguments)
- }
- };
- "undefined" !== typeof define && define.amd ? define("async", [], function() {
- return a
- }) : "undefined" !== typeof module && module.exports ? module.exports = a : d.async = a
- })();
- (kite = function(a, d) {
- function c(a) {
- console && console.log("kite:" + a)
- }
- function b(a, b) {
- for (var c = a + 1; c < b;) {
- var d = p[c];
- c & 1 ? d ? c += d() : ++c : (l += d, ++c)
- }
- }
- function e(a, c, d) {
- var e = v,
- f = y;
- if (a instanceof Array) {
- var h = a.length;
- for (y = 0; y < h; ++y) v = a[y], b(c, d)
- } else v = a, y = void 0, b(c, d);
- v = e;
- y = f
- }
- function f(a, b) {
- D = a;
- l = "";
- u = b || kite.formatters || {};
- e(a instanceof Array ? {
- "": a
- } : a, -1, p.length);
- return l
- }
- function h(a, b, c, d) {
- return function() {
- var f = v[a],
- h;
- h = f ? f instanceof Array && 0 == f.length ? !1 : !0 : !1;
- return h ? (e(f, b, c), (d || c) - b) : c -
- b
- }
- }
- function g(a) {
- var b = u[a];
- if ("function" == typeof b) return b;
- a = a.replace("@", "_val_").replace("#", "_ctx_");
- try {
- return new Function("_val_", "_ctx_", "_root_", "_formatters_", "_log_", "{try { with(_formatters_) {with(_root_){return (" + a + ");}}} catch(e){_log_('formatter:' + e + ' in " + a + "');}}")
- } catch (d) {
- c(d + " in " + a)
- }
- }
- function m(a) {
- if ("" == a) return a;
- var b, d = a.indexOf("|");
- 0 <= d && (b = a.substr(d + 1), a = a.substr(0, d), b = g(b));
- if ("" == a || "." == a) return b ? function() {
- l += b(v, v, D, u, c);
- return 1
- } : function() {
- void 0 !== v &&
- (l += v);
- return 1
- };
- if (/^w+$/.test(a)) return b ? function() {
- l += b(v[a], v, D, u, c);
- return 1
- } : function() {
- var b = v[a];
- void 0 !== b && (l += b);
- return 1
- };
- var e;
- try {
- e = new Function("_in_", "_log_", "{try {return (_in_." + a + ");} catch(e){ _log_(e + ' in " + a + "'); }}")
- } catch (f) {
- c(f + " in " + a);
- return
- }
- return b ? function() {
- l += b(e(v, c), v, D, u, c);
- return 1
- } : function() {
- var a = e(v, c);
- void 0 !== a && (l += a);
- return 1
- }
- }
- function k(a, c) {
- return function() {
- b(a, c);
- return c - a + 1
- }
- }
- function n(a, d, e, w) {
- var f = new Function("_ctx_", "at", "_formatters_", "_log_",
- "try { with(_formatters_){with(_ctx_) {return (" + a + ");}}} catch(e){_log_('conditional:' + e + ' in \"" + a + "\"'); }");
- return function() {
- return f(v, y, u, c) ? (b(d, e), w - d) : e - d
- }
- }
- function q() {
- for (var b = 0; b < a.length;) {
- var c = a.indexOf("{{", b);
- if (0 > c) break;
- var d = a.indexOf("}}", c + 2);
- if (0 > d) break;
- p.push(a.substring(b, c));
- p.push(a.substring(c + 2, d));
- b = d + 2
- }
- p.push(a.substr(b))
- }
- var l = "",
- p = [],
- D = null,
- v = null,
- y = 0,
- u = kite.formatters || {};
- if ("#" == a.charAt(0)) {
- var E = null,
- E = document.getElementById(a.substr(1));
- if (!E) throw "Template element #" +
- E + " not found";
- a = E.innerHTML
- }(function() {
- function a(e, f) {
- for (var h = e + 2; h < d; h += 2) {
- var g = p[h];
- switch (g.charAt(0)) {
- case "#":
- h = b(h, g.substr(1));
- continue;
- case "?":
- h = c(h, g.substr(1));
- "/?" == p[h] ? p[h] = "" : h -= 2;
- continue;
- case "/":
- return p[e] = k(e, h), g.substr(1) == f && (p[h] = ""), h;
- case "^":
- return p[e] = k(e, h), h;
- default:
- p[h] = m(g)
- }
- }
- return h
- }
- function b(e, f) {
- for (var g = e + 2; g < d; g += 2) {
- var k = p[g];
- switch (k.charAt(0)) {
- case "#":
- g = b(g, k.substr(1));
- continue;
- case "?":
- g = c(g, k.substr(1));
- "/?" == p[g] ? p[g] = "" : g -= 2;
- continue;
- case "^":
- if (k.substr(1) ==
- f) return k = g, g = a(g, f), p[e] = h(f, e, k, g), g;
- p[e] = h(f, e, g, g);
- return g - 2;
- case "/":
- p[e] = h(f, e, g);
- if (k.substr(1) != f) return g - 2;
- p[g] = "";
- return g;
- default:
- p[g] = m(k)
- }
- }
- return g
- }
- function c(e, f) {
- for (var h = e + 2; h < d; h += 2) {
- var g = p[h];
- switch (g.charAt(0)) {
- case "#":
- h = b(h, g.substr(1));
- continue;
- case "?":
- var k = h,
- h = c(h, g.substr(1));
- p[e] = n(f, e, k, h);
- return h;
- case "^":
- if ("?" == g.substr(1)) return k = h, h = a(h, "?"), p[e] = n(f, e, k, h), h;
- p[e] = n(f, e, h, h);
- return h;
- case "/":
- p[e] = n(f, e, h, h);
- if ("?" != g.substr(1)) return h - 2;
- p[h] = "";
- return h;
- default:
- p[h] =
- m(g)
- }
- }
- return h
- }
- q();
- var d = p.length;
- b(-1, "")
- })();
- return void 0 === d ? function(a, b) {
- return f(a, b)
- } : f(d, u)
- }).formatters = {
- date: function(a) {
- var d = a.split("-");
- return 3 != d.length ? a : "January February March April May June July August September October November December".split(" ")[parseInt(d[1], 10) - 1] + " " + parseInt(d[2], 10) + ", " + d[0]
- },
- escaped: function(a) {
- return a.replace("&", "&").replace('"', """).replace("'", "'").replace("<", "<").replace(">", ">")
- }
- };
- window.Modernizr = function(a, d, c) {
- var b = {},
- e = d.documentElement,
- f = d.createElement("modernizr"),
- f = f.style,
- h = " -webkit- -moz- -o- -ms- ".split(" "),
- g = {},
- m = [],
- k = m.slice,
- n, q = function(a, b, c, f) {
- var h, r, B, w, g = d.createElement("div"),
- G = d.body,
- k = G || d.createElement("body");
- if (parseInt(c, 10))
- for (; c--;) B = d.createElement("div"), B.id = f ? f[c] : "modernizr" + (c + 1), g.appendChild(B);
- return h = ['­<style id="smodernizr">', a, "</style>"].join(""), g.id = "modernizr", (G ? g : k).innerHTML += h, k.appendChild(g), G || (k.style.background =
- "", k.style.overflow = "hidden", w = e.style.overflow, e.style.overflow = "hidden", e.appendChild(k)), r = b(g, a), G ? g.parentNode.removeChild(g) : (k.parentNode.removeChild(k), e.style.overflow = w), !!r
- },
- l = {}.hasOwnProperty,
- p;
- "undefined" !== typeof l && "undefined" !== typeof l.call ? p = function(a, b) {
- return l.call(a, b)
- } : p = function(a, b) {
- return b in a && "undefined" === typeof a.constructor.prototype[b]
- };
- Function.prototype.bind || (Function.prototype.bind = function(a) {
- var b = this;
- if ("function" != typeof b) throw new TypeError;
- var c = k.call(arguments,
- 1),
- d = function() {
- if (this instanceof d) {
- var e = function() {};
- e.prototype = b.prototype;
- var e = new e,
- r = b.apply(e, c.concat(k.call(arguments)));
- return Object(r) === r ? r : e
- }
- return b.apply(a, c.concat(k.call(arguments)))
- };
- return d
- });
- g.touch = function() {
- var b;
- return "ontouchstart" in a || a.DocumentTouch && d instanceof DocumentTouch ? b = !0 : q(["@media (", h.join("touch-enabled),("), "modernizr){#modernizr{top:9px;position:absolute}}"].join(""), function(a) {
- b = 9 === a.offsetTop
- }), b
- };
- g.audio = function() {
- var a = d.createElement("audio"),
- b = !1;
- try {
- if (b = !!a.canPlayType) b = new Boolean(b), b.ogg = a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, ""), b.mp3 = a.canPlayType("audio/mpeg;").replace(/^no$/, ""), b.wav = a.canPlayType('audio/wav; codecs="1"').replace(/^no$/, ""), b.m4a = (a.canPlayType("audio/x-m4a;") || a.canPlayType("audio/aac;")).replace(/^no$/, "")
- } catch (c) {}
- return b
- };
- g.localstorage = function() {
- try {
- return localStorage.setItem("modernizr", "modernizr"), localStorage.removeItem("modernizr"), !0
- } catch (a) {
- return !1
- }
- };
- for (var D in g) p(g,
- D) && (n = D.toLowerCase(), b[n] = g[D](), m.push((b[n] ? "" : "no-") + n));
- b.addTest = function(a, d) {
- if ("object" == typeof a)
- for (var f in a) p(a, f) && b.addTest(f, a[f]);
- else {
- a = a.toLowerCase();
- if (b[a] !== c) return b;
- d = "function" == typeof d ? d() : d;
- "undefined" != typeof enableClasses && enableClasses && (e.className += " " + (d ? "" : "no-") + a);
- b[a] = d
- }
- return b
- };
- f.cssText = "";
- return f = null, b._version = "2.6.3", b._prefixes = h, b.testStyles = q, b
- }(this, this.document);
- (function(a, d) {
- var c = a.document,
- b = c.documentElement,
- e = "ontouchmove" in c,
- f = "WebkitOverflowScrolling" in b.style || !e && 1200 < a.screen.width || function() {
- var b = a.navigator.userAgent,
- c = b.match(/AppleWebKit\/([0-9]+)/),
- d = c && c[1],
- e = c && 534 <= d;
- return b.match(/Android ([0-9]+)/) && 3 <= RegExp.$1 && e || b.match(/ Version\/([0-9]+)/) && 0 <= RegExp.$1 && a.blackberry && e || -1 < b.indexOf(/PlayBook/) && 0 <= RegExp.$1 && e || b.match(/Fennec\/([0-9]+)/) && 4 <= RegExp.$1 || b.match(/wOSBrowser\/([0-9]+)/) && 233 <= RegExp.$1 && e || b.match(/NokiaBrowser\/([0-9\.]+)/) &&
- 7.3 === parseFloat(RegExp.$1) && c && 533 <= d
- }(),
- h = function(a, b, c, d) {
- return c * ((a = a / d - 1) * a * a + 1) + b
- },
- g = !1,
- m, k = function(b, c) {
- var e = 0,
- f = b.scrollLeft,
- h = b.scrollTop,
- g = {
- top: "+0",
- left: "+0",
- duration: 100,
- easing: a.overthrow.easing
- },
- k, r;
- if (c)
- for (var B in g) c[B] !== d && (g[B] = c[B]);
- "string" === typeof g.left ? (g.left = parseFloat(g.left), k = g.left + f) : (k = g.left, g.left -= f);
- "string" === typeof g.top ? (g.top = parseFloat(g.top), r = g.top + h) : (r = g.top, g.top -= h);
- m = setInterval(function() {
- e++ < g.duration ? (b.scrollLeft = g.easing(e, f, g.left, g.duration),
- b.scrollTop = g.easing(e, h, g.top, g.duration)) : (k !== b.scrollLeft && (b.scrollLeft = k), r !== b.scrollTop && (b.scrollTop = r), q())
- }, 1);
- return {
- top: r,
- left: k,
- duration: g.duration,
- easing: g.easing
- }
- },
- n = function(a, b) {
- return !b && a.className && -1 < a.className.indexOf("overthrow") && a || n(a.parentNode)
- },
- q = function() {
- clearInterval(m)
- },
- l = function() {
- if (!g) {
- g = !0;
- if (f || e) b.className += " overthrow-enabled";
- a.overthrow.forget = function() {
- b.className = b.className.replace("overthrow-enabled", "");
- c.removeEventListener && c.removeEventListener("touchstart",
- B, !1);
- a.overthrow.easing = h;
- g = !1
- };
- if (!f && e) {
- var d, m = [],
- l = [],
- y, u, E = function() {
- var a = 8 * (m[0] - m[m.length - 1]),
- b = 8 * (l[0] - l[l.length - 1]),
- c = Math.max(Math.abs(b), Math.abs(a)) / 8,
- a = (0 < a ? "+" : "") + a,
- b = (0 < b ? "+" : "") + b;
- !isNaN(c) && 0 < c && (80 < Math.abs(b) || 80 < Math.abs(a)) && k(d, {
- left: b,
- top: a,
- duration: c
- })
- },
- A, r = function(a) {
- A = d.querySelectorAll("textarea, input");
- for (var b = 0, c = A.length; b < c; b++) A[b].style.pointerEvents = a
- },
- B = function(a) {
- q();
- m = [];
- y = null;
- l = [];
- u = null;
- if ((d = n(a.target)) && d !== b && !(1 < a.touches.length)) {
- r("none");
- var e = d.scrollTop,
- B = d.scrollLeft,
- f = d.offsetHeight,
- h = d.offsetWidth,
- g = a.touches[0].pageY,
- k = a.touches[0].pageX,
- I = d.scrollHeight,
- A = d.scrollWidth,
- z = function(b) {
- var r = e + g - b.touches[0].pageY,
- n = B + k - b.touches[0].pageX,
- q = r >= (m.length ? m[0] : 0),
- F = n >= (l.length ? l[0] : 0);
- if (0 < r && r < I - f || 0 < n && n < A - h) b.preventDefault();
- else if (c.createEvent) {
- b = d.parentNode || d.touchchild || d;
- var z;
- b !== d && (z = c.createEvent("HTMLEvents"), z.initEvent("touchend", !0, !0), d.dispatchEvent(z), b.touchchild = d, d = b, b.dispatchEvent(a))
- }
- y && q !== y && (m = [],
- y = null);
- u && F !== u && (l = [], u = null);
- y = q;
- u = F;
- d.scrollTop = r;
- d.scrollLeft = n;
- m.unshift(r);
- l.unshift(n);
- 3 < m.length && m.pop();
- 3 < l.length && l.pop()
- },
- F = function(a) {
- E();
- r("auto");
- setTimeout(function() {
- r("none")
- }, 450);
- d.removeEventListener("touchmove", z, !1);
- d.removeEventListener("touchend", F, !1)
- };
- d.addEventListener("touchmove", z, !1);
- d.addEventListener("touchend", F, !1)
- }
- };
- c.addEventListener("touchstart", B, !1)
- }
- }
- };
- a.overthrow = {
- set: l,
- forget: function() {},
- easing: h,
- toss: k,
- intercept: q,
- closest: n,
- support: f ? "native" : e && "polyfilled" ||
- "none"
- };
- l()
- })(this);
- (function(a, d) {
- "function" === typeof define && define.amd ? define("sifter", d) : "object" === typeof exports ? module.exports = d() : a.Sifter = d()
- })(this, function() {
- var a = function(a, b) {
- this.items = a;
- this.settings = b || {
- diacritics: !0
- }
- };
- a.prototype.tokenize = function(a) {
- a = (String(a || "").toLowerCase() + "").replace(/^\s+|\s+$|/g, "");
- if (!a || !a.length) return [];
- var b, c, d, f = [],
- q = a.split(/ +/);
- a = 0;
- for (b = q.length; a < b; a++) {
- c = (q[a] + "").replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
- if (this.settings.diacritics)
- for (d in e) e.hasOwnProperty(d) && (c =
- c.replace(new RegExp(d, "g"), e[d]));
- f.push({
- string: q[a],
- regex: new RegExp(c, "i")
- })
- }
- return f
- };
- a.prototype.iterator = function(a, c) {
- (b(a) ? Array.prototype.forEach || function(a) {
- for (var b = 0, c = this.length; b < c; b++) a(this[b], b, this)
- } : function(a) {
- for (var b in this) this.hasOwnProperty(b) && a(this[b], b, this)
- }).apply(a, [c])
- };
- a.prototype.getScoreFunction = function(a, b) {
- var c, d, e;
- a = this.prepareSearch(a, b);
- d = a.tokens;
- c = a.options.fields;
- e = d.length;
- var f = function(a, b) {
- var c, d;
- if (!a) return 0;
- a = String(a || "");
- d = a.search(b.regex);
- if (-1 === d) return 0;
- c = b.string.length / a.length;
- 0 === d && (c += .5);
- return c
- },
- l = function() {
- var a = c.length;
- return a ? 1 === a ? function(a, b) {
- return f(b[c[0]], a)
- } : function(b, d) {
- for (var e = 0, g = 0; e < a; e++) g += f(d[c[e]], b);
- return g / a
- } : function() {
- return 0
- }
- }();
- return e ? 1 === e ? function(a) {
- return l(d[0], a)
- } : "and" === a.options.conjunction ? function(a) {
- for (var b, c = 0, f = 0; c < e; c++) {
- b = l(d[c], a);
- if (0 >= b) return 0;
- f += b
- }
- return f / e
- } : function(a) {
- for (var b = 0, c = 0; b < e; b++) c += l(d[b], a);
- return c / e
- } : function() {
- return 0
- }
- };
- a.prototype.getSortFunction =
- function(a, b) {
- var c, e, f, q, l, p, D, v, y, u;
- f = this;
- a = f.prepareSearch(a, b);
- u = !a.query && b.sort_empty || b.sort;
- y = function(a, b) {
- return "$score" === a ? b.score : f.items[b.id][a]
- };
- l = [];
- if (u)
- for (c = 0, e = u.length; c < e; c++)(a.query || "$score" !== u[c].field) && l.push(u[c]);
- if (a.query) {
- u = !0;
- c = 0;
- for (e = l.length; c < e; c++)
- if ("$score" === l[c].field) {
- u = !1;
- break
- }
- u && l.unshift({
- field: "$score",
- direction: "desc"
- })
- } else
- for (c = 0, e = l.length; c < e; c++)
- if ("$score" === l[c].field) {
- l.splice(c, 1);
- break
- }
- v = [];
- c = 0;
- for (e = l.length; c < e; c++) v.push("desc" ===
- l[c].direction ? -1 : 1);
- return (p = l.length) ? 1 === p ? (q = l[0].field, D = v[0], function(a, b) {
- return D * d(y(q, a), y(q, b))
- }) : function(a, b) {
- var c, e;
- for (c = 0; c < p; c++)
- if (e = l[c].field, e = v[c] * d(y(e, a), y(e, b))) return e;
- return 0
- } : null
- };
- a.prototype.prepareSearch = function(a, d) {
- if ("object" === typeof a) return a;
- d = c({}, d);
- var e = d.fields,
- f = d.sort,
- n = d.sort_empty;
- e && !b(e) && (d.fields = [e]);
- f && !b(f) && (d.sort = [f]);
- n && !b(n) && (d.sort_empty = [n]);
- return {
- options: d,
- query: String(a || "").toLowerCase(),
- tokens: this.tokenize(a),
- total: 0,
- items: []
- }
- };
- a.prototype.search = function(a, b) {
- var c, d, e, f;
- d = this.prepareSearch(a, b);
- b = d.options;
- a = d.query;
- f = b.score || this.getScoreFunction(d);
- a.length ? this.iterator(this.items, function(a, e) {
- c = f(a);
- (!1 === b.filter || 0 < c) && d.items.push({
- score: c,
- id: e
- })
- }) : this.iterator(this.items, function(a, b) {
- d.items.push({
- score: 1,
- id: b
- })
- });
- (e = this.getSortFunction(d, b)) && d.items.sort(e);
- d.total = d.items.length;
- "number" === typeof b.limit && (d.items = d.items.slice(0, b.limit));
- return d
- };
- var d = function(a, b) {
- if ("number" === typeof a && "number" ===
- typeof b) return a > b ? 1 : a < b ? -1 : 0;
- a = f(String(a || ""));
- b = f(String(b || ""));
- return a > b ? 1 : b > a ? -1 : 0
- },
- c = function(a, b) {
- var c, d, e, f;
- c = 1;
- for (d = arguments.length; c < d; c++)
- if (f = arguments[c])
- for (e in f) f.hasOwnProperty(e) && (a[e] = f[e]);
- return a
- },
- b = Array.isArray || $ && $.isArray || function(a) {
- return "[object Array]" === Object.prototype.toString.call(a)
- },
- e = {
- a: "[a\u00c0\u00c1\u00c2\u00c3\u00c4\u00c5\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5\u0100\u0101\u0105\u0104]",
- c: "[c\u00c7\u00e7\u0107\u0106\u010d\u010c]",
- d: "[d\u0111\u0110\u010f\u010e]",
- e: "[e\u00c8\u00c9\u00ca\u00cb\u00e8\u00e9\u00ea\u00eb\u011b\u011a\u0112\u0113\u0119\u0118]",
- i: "[i\u00cc\u00cd\u00ce\u00cf\u00ec\u00ed\u00ee\u00ef\u012a\u012b]",
- l: "[l\u0142\u0141]",
- n: "[n\u00d1\u00f1\u0148\u0147\u0144\u0143]",
- o: "[o\u00d2\u00d3\u00d4\u00d5\u00d5\u00d6\u00d8\u00f2\u00f3\u00f4\u00f5\u00f6\u00f8\u014c\u014d]",
- r: "[r\u0159\u0158]",
- s: "[s\u0160\u0161\u015b\u015a]",
- t: "[t\u0165\u0164]",
- u: "[u\u00d9\u00da\u00db\u00dc\u00f9\u00fa\u00fb\u00fc\u016f\u016e\u016a\u016b]",
- y: "[y\u0178\u00ff\u00fd\u00dd]",
- z: "[z\u017d\u017e\u017c\u017b\u017a\u0179]"
- },
- f = function() {
- var a, b, c, d, f = "",
- q = {};
- for (c in e)
- if (e.hasOwnProperty(c))
- for (d = e[c].substring(2, e[c].length - 1), f += d, a = 0, b = d.length; a < b; a++) q[d.charAt(a)] = c;
- var l = new RegExp("[" + f + "]", "g");
- return function(a) {
- return a.replace(l, function(a) {
- return q[a]
- }).toLowerCase()
- }
- }();
- return a
- });
- (function(a, d) {
- "function" === typeof define && define.amd ? define("microplugin", d) : "object" === typeof exports ? module.exports = d() : a.MicroPlugin = d()
- })(this, function() {
- var a = {
- isArray: Array.isArray || function(a) {
- return "[object Array]" === Object.prototype.toString.call(a)
- }
- };
- return {
- mixin: function(d) {
- d.plugins = {};
- d.prototype.initializePlugins = function(c) {
- var b, d, f = [];
- this.plugins = {
- names: [],
- settings: {},
- requested: {},
- loaded: {}
- };
- if (a.isArray(c))
- for (b = 0, d = c.length; b < d; b++) "string" === typeof c[b] ? f.push(c[b]) : (this.plugins.settings[c[b].name] =
- c[b].options, f.push(c[b].name));
- else if (c)
- for (b in c) c.hasOwnProperty(b) && (this.plugins.settings[b] = c[b], f.push(b));
- for (; f.length;) this.require(f.shift())
- };
- d.prototype.loadPlugin = function(a) {
- var b = this.plugins,
- e = d.plugins[a];
- if (!d.plugins.hasOwnProperty(a)) throw Error('Unable to find "' + a + '" plugin');
- b.requested[a] = !0;
- b.loaded[a] = e.fn.apply(this, [this.plugins.settings[a] || {}]);
- b.names.push(a)
- };
- d.prototype.require = function(a) {
- var b = this.plugins;
- if (!this.plugins.loaded.hasOwnProperty(a)) {
- if (b.requested[a]) throw Error('Plugin has circular dependency ("' +
- a + '")');
- this.loadPlugin(a)
- }
- return b.loaded[a]
- };
- d.define = function(a, b) {
- d.plugins[a] = {
- name: a,
- fn: b
- }
- }
- }
- }
- });
- (function(a, d) {
- "function" === typeof define && define.amd ? define("selectize", ["jquery", "sifter", "microplugin"], d) : "object" === typeof exports ? module.exports = d(require("jquery"), require("sifter"), require("microplugin")) : a.Selectize = d(a.jQuery, a.Sifter, a.MicroPlugin)
- })(this, function(a, d, c) {
- var b = function(a, b) {
- if ("string" !== typeof b || b.length) {
- var c = "string" === typeof b ? new RegExp(b, "i") : b,
- d = function(a) {
- var b = 0;
- if (3 === a.nodeType) {
- var r = a.data.search(c);
- if (0 <= r && 0 < a.data.length) {
- var e = a.data.match(c),
- b = document.createElement("span");
- b.className = "highlight";
- a = a.splitText(r);
- a.splitText(e[0].length);
- r = a.cloneNode(!0);
- b.appendChild(r);
- a.parentNode.replaceChild(b, a);
- b = 1
- }
- } else if (1 === a.nodeType && a.childNodes && !/(script|style)/i.test(a.tagName))
- for (r = 0; r < a.childNodes.length; ++r) r += d(a.childNodes[r]);
- return b
- };
- return a.each(function() {
- d(this)
- })
- }
- },
- e = function() {};
- e.prototype = {
- on: function(a, b) {
- this._events = this._events || {};
- this._events[a] = this._events[a] || [];
- this._events[a].push(b)
- },
- off: function(a, b) {
- var c = arguments.length;
- if (0 === c) return delete this._events;
- if (1 === c) return delete this._events[a];
- this._events = this._events || {};
- !1 !== a in this._events && this._events[a].splice(this._events[a].indexOf(b), 1)
- },
- trigger: function(a) {
- this._events = this._events || {};
- if (!1 !== a in this._events)
- for (var b = 0; b < this._events[a].length; b++) this._events[a][b].apply(this, Array.prototype.slice.call(arguments, 1))
- }
- };
- e.mixin = function(a) {
- for (var b = ["on", "off", "trigger"], c = 0; c < b.length; c++) a.prototype[b[c]] = e.prototype[b[c]]
- };
- var f = /Mac/.test(navigator.userAgent),
- h = f ? 91 : 17,
- g = f ? 18 :
- 17,
- m = !/android/i.test(window.navigator.userAgent) && !!document.createElement("form").validity,
- k = function(a) {
- return "undefined" === typeof a || null === a ? null : "boolean" === typeof a ? a ? "1" : "0" : a + ""
- },
- n = function(a) {
- return (a + "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """)
- },
- q = function(a) {
- return (a + "").replace(/\$/g, "$$$$")
- },
- l = {
- before: function(a, b, c) {
- var d = a[b];
- a[b] = function() {
- c.apply(a, arguments);
- return d.apply(a, arguments)
- }
- },
- after: function(a, b, c) {
- var d = a[b];
- a[b] = function() {
- var b =
- d.apply(a, arguments);
- c.apply(a, arguments);
- return b
- }
- }
- },
- p = function(a) {
- var b = !1;
- return function() {
- b || (b = !0, a.apply(this, arguments))
- }
- },
- D = function(a, b) {
- var c;
- return function() {
- var d = this,
- e = arguments;
- window.clearTimeout(c);
- c = window.setTimeout(function() {
- a.apply(d, e)
- }, b)
- }
- },
- v = function(a, b, c) {
- var d, e = a.trigger,
- f = {};
- a.trigger = function() {
- var c = arguments[0];
- if (-1 !== b.indexOf(c)) f[c] = arguments;
- else return e.apply(a, arguments)
- };
- c.apply(a, []);
- a.trigger = e;
- for (d in f) f.hasOwnProperty(d) && e.apply(a, f[d])
- },
- y = function(a,
- b, c, d) {
- a.on(b, c, function(b) {
- for (var c = b.target; c && c.parentNode !== a[0];) c = c.parentNode;
- b.currentTarget = c;
- return d.apply(this, [b])
- })
- },
- u = function(a) {
- var b = {};
- if ("selectionStart" in a) b.start = a.selectionStart, b.length = a.selectionEnd - b.start;
- else if (document.selection) {
- a.focus();
- var c = document.selection.createRange(),
- d = document.selection.createRange().text.length;
- c.moveStart("character", -a.value.length);
- b.start = c.text.length - d;
- b.length = d
- }
- return b
- },
- E = function(b) {
- var c = null,
- d = function(d, e) {
- var f, g, w;
- d = d ||
- window.event || {};
- e = e || {};
- if (!d.metaKey && !d.altKey && (e.force || !1 !== b.data("grow"))) {
- f = b.val();
- d.type && "keydown" === d.type.toLowerCase() && (g = d.keyCode, w = 97 <= g && 122 >= g || 65 <= g && 90 >= g || 48 <= g && 57 >= g || 32 === g, 46 === g || 8 === g ? (w = u(b[0]), w.length ? f = f.substring(0, w.start) + f.substring(w.start + w.length) : 8 === g && w.start ? f = f.substring(0, w.start - 1) + f.substring(w.start + 1) : 46 === g && "undefined" !== typeof w.start && (f = f.substring(0, w.start) + f.substring(w.start + 1))) : w && (g = d.shiftKey, w = String.fromCharCode(d.keyCode), w = g ? w.toUpperCase() :
- w.toLowerCase(), f += w));
- g = b.attr("placeholder");
- !f && g && (f = g);
- if (f) {
- f = a("<test>").css({
- position: "absolute",
- top: -99999,
- left: -99999,
- width: "auto",
- padding: 0,
- whiteSpace: "pre"
- }).text(f).appendTo("body");
- g = ["letterSpacing", "fontSize", "fontFamily", "fontWeight", "textTransform"];
- var h, k = {};
- if (g)
- for (w = 0, h = g.length; w < h; w++) k[g[w]] = b.css(g[w]);
- else k = b.css();
- f.css(k);
- g = f.width();
- f.remove();
- f = g
- } else f = 0;
- f += 4;
- f !== c && (c = f, b.width(f), b.triggerHandler("resize"))
- }
- };
- b.on("keydown keyup update blur", d);
- d()
- },
- A = function(b,
- c) {
- var e, f;
- e = b[0];
- e.selectize = this;
- f = (f = (f = window.getComputedStyle && window.getComputedStyle(e, null)) ? f.getPropertyValue("direction") : e.currentStyle && e.currentStyle.direction) || b.parents("[dir]:first").attr("dir") || "";
- a.extend(this, {
- order: 0,
- settings: c,
- $input: b,
- tabIndex: b.attr("tabindex") || "",
- tagType: "select" === e.tagName.toLowerCase() ? 1 : 2,
- rtl: /rtl/i.test(f),
- eventNS: ".selectize" + ++A.count,
- highlightedValue: null,
- isOpen: !1,
- isDisabled: !1,
- isRequired: b.is("[required]"),
- isInvalid: !1,
- isLocked: !1,
- isFocused: !1,
- isInputHidden: !1,
- isSetup: !1,
- isShiftDown: !1,
- isCmdDown: !1,
- isCtrlDown: !1,
- ignoreFocus: !1,
- ignoreBlur: !1,
- ignoreHover: !1,
- hasOptions: !1,
- currentResults: null,
- lastValue: "",
- caretPos: 0,
- loading: 0,
- loadedSearches: {},
- $activeOption: null,
- $activeItems: [],
- optgroups: {},
- options: {},
- userOptions: {},
- items: [],
- renderCache: {},
- onSearchChange: null === c.loadThrottle ? this.onSearchChange : D(this.onSearchChange, c.loadThrottle)
- });
- this.sifter = new d(this.options, {
- diacritics: c.diacritics
- });
- if (this.settings.options) {
- e = 0;
- for (f = this.settings.options.length; e <
- f; e++) this.registerOption(this.settings.options[e]);
- delete this.settings.options
- }
- if (this.settings.optgroups) {
- e = 0;
- for (f = this.settings.optgroups.length; e < f; e++) this.registerOptionGroup(this.settings.optgroups[e]);
- delete this.settings.optgroups
- }
- this.settings.mode = this.settings.mode || (1 === this.settings.maxItems ? "single" : "multi");
- "boolean" !== typeof this.settings.hideSelected && (this.settings.hideSelected = "multi" === this.settings.mode);
- this.initializePlugins(this.settings.plugins);
- this.setupCallbacks();
- this.setupTemplates();
- this.setup()
- };
- e.mixin(A);
- c.mixin(A);
- a.extend(A.prototype, {
- setup: function() {
- var b = this,
- c = b.settings,
- d = b.eventNS,
- e = a(window),
- k = a(document),
- C = b.$input,
- l, H, n, p, q, z;
- q = b.settings.mode;
- z = C.attr("class") || "";
- l = a("<div>").addClass(c.wrapperClass).addClass(z).addClass(q);
- H = a("<div>").addClass(c.inputClass).addClass("items").appendTo(l);
- n = a('<input type="text" autocomplete="off" />').appendTo(H).attr("tabindex", C.is(":disabled") ? "-1" : b.tabIndex);
- p = a(c.dropdownParent || l);
- p = a("<div>").addClass(c.dropdownClass).addClass(q).hide().appendTo(p);
- q = a("<div>").addClass(c.dropdownContentClass).appendTo(p);
- b.settings.copyClassesToDropdown && p.addClass(z);
- l.css({
- width: C[0].style.width
- });
- b.plugins.names.length && (z = "plugin-" + b.plugins.names.join(" plugin-"), l.addClass(z), p.addClass(z));
- (null === c.maxItems || 1 < c.maxItems) && 1 === b.tagType && C.attr("multiple", "multiple");
- b.settings.placeholder && n.attr("placeholder", c.placeholder);
- !b.settings.splitOn && b.settings.delimiter && (z = b.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&"), b.settings.splitOn =
- new RegExp("\\s*" + z + "+\\s*"));
- C.attr("autocorrect") && n.attr("autocorrect", C.attr("autocorrect"));
- C.attr("autocapitalize") && n.attr("autocapitalize", C.attr("autocapitalize"));
- b.$wrapper = l;
- b.$control = H;
- b.$control_input = n;
- b.$dropdown = p;
- b.$dropdown_content = q;
- p.on("mouseenter", "[data-selectable]", function() {
- return b.onOptionHover.apply(b, arguments)
- });
- p.on("mousedown click", "[data-selectable]", function() {
- return b.onOptionSelect.apply(b, arguments)
- });
- y(H, "mousedown", "*:not(input)", function() {
- return b.onItemSelect.apply(b,
- arguments)
- });
- E(n);
- H.on({
- mousedown: function() {
- return b.onMouseDown.apply(b, arguments)
- },
- click: function() {
- return b.onClick.apply(b, arguments)
- }
- });
- n.on({
- mousedown: function(a) {
- a.stopPropagation()
- },
- keydown: function() {
- return b.onKeyDown.apply(b, arguments)
- },
- keyup: function() {
- return b.onKeyUp.apply(b, arguments)
- },
- keypress: function() {
- return b.onKeyPress.apply(b, arguments)
- },
- resize: function() {
- b.positionDropdown.apply(b, [])
- },
- blur: function() {
- return b.onBlur.apply(b, arguments)
- },
- focus: function() {
- b.ignoreBlur = !1;
- return b.onFocus.apply(b,
- arguments)
- },
- paste: function() {
- return b.onPaste.apply(b, arguments)
- }
- });
- k.on("keydown" + d, function(a) {
- b.isCmdDown = a[f ? "metaKey" : "ctrlKey"];
- b.isCtrlDown = a[f ? "altKey" : "ctrlKey"];
- b.isShiftDown = a.shiftKey
- });
- k.on("keyup" + d, function(a) {
- a.keyCode === g && (b.isCtrlDown = !1);
- 16 === a.keyCode && (b.isShiftDown = !1);
- a.keyCode === h && (b.isCmdDown = !1)
- });
- k.on("mousedown" + d, function(a) {
- if (b.isFocused) {
- if (a.target === b.$dropdown[0] || a.target.parentNode === b.$dropdown[0]) return !1;
- b.$control.has(a.target).length || a.target === b.$control[0] ||
- b.blur(a.target)
- }
- });
- e.on(["scroll" + d, "resize" + d].join(" "), function() {
- b.isOpen && b.positionDropdown.apply(b, arguments)
- });
- e.on("mousemove" + d, function() {
- b.ignoreHover = !1
- });
- this.revertSettings = {
- $children: C.children().detach(),
- tabindex: C.attr("tabindex")
- };
- C.attr("tabindex", -1).hide().after(b.$wrapper);
- a.isArray(c.items) && (b.setValue(c.items), delete c.items);
- if (m) C.on("invalid" + d, function(a) {
- a.preventDefault();
- b.isInvalid = !0;
- b.refreshState()
- });
- b.updateOriginalInput();
- b.refreshItems();
- b.refreshState();
- b.updatePlaceholder();
- b.isSetup = !0;
- C.is(":disabled") && b.disable();
- b.on("change", this.onChange);
- C.data("selectize", b);
- C.addClass("selectized");
- b.trigger("initialize");
- if (!0 === c.preload) b.onSearchChange("")
- },
- setupTemplates: function() {
- var b = this.settings.labelField,
- c = this.settings.optgroupLabelField;
- this.settings.render = a.extend({}, {
- optgroup: function(a) {
- return '<div class="optgroup">' + a.html + "</div>"
- },
- optgroup_header: function(a, b) {
- return '<div class="optgroup-header">' + b(a[c]) + "</div>"
- },
- option: function(a, c) {
- return '<div class="option">' +
- c(a[b]) + "</div>"
- },
- item: function(a, c) {
- return '<div class="item">' + c(a[b]) + "</div>"
- },
- option_create: function(a, b) {
- return '<div class="create">Add <strong>' + b(a.input) + "</strong>…</div>"
- }
- }, this.settings.render)
- },
- setupCallbacks: function() {
- var a, b, c = {
- initialize: "onInitialize",
- change: "onChange",
- item_add: "onItemAdd",
- item_remove: "onItemRemove",
- clear: "onClear",
- option_add: "onOptionAdd",
- option_remove: "onOptionRemove",
- option_clear: "onOptionClear",
- optgroup_add: "onOptionGroupAdd",
- optgroup_remove: "onOptionGroupRemove",
- optgroup_clear: "onOptionGroupClear",
- dropdown_open: "onDropdownOpen",
- dropdown_close: "onDropdownClose",
- type: "onType",
- load: "onLoad",
- focus: "onFocus",
- blur: "onBlur"
- };
- for (a in c)
- if (c.hasOwnProperty(a) && (b = this.settings[c[a]])) this.on(a, b)
- },
- onClick: function(a) {
- this.isFocused || (this.focus(), a.preventDefault())
- },
- onMouseDown: function(b) {
- var c = this,
- d = b.isDefaultPrevented();
- a(b.target);
- if (c.isFocused) {
- if (b.target !== c.$control_input[0]) return "single" === c.settings.mode ? c.isOpen ? c.close() : c.open() : d || c.setActiveItem(null), !1
- } else d || window.setTimeout(function() {
- c.focus()
- }, 0)
- },
- onChange: function() {
- this.$input.trigger("change")
- },
- onPaste: function(b) {
- var c = this;
- c.isFull() || c.isInputHidden || c.isLocked ? b.preventDefault() : c.settings.splitOn && setTimeout(function() {
- for (var b = a.trim(c.$control_input.val() || "").split(c.settings.splitOn), d = 0, e = b.length; d < e; d++) c.createItem(b[d])
- }, 0)
- },
- onKeyPress: function(a) {
- if (this.isLocked) return a && a.preventDefault();
- var b = String.fromCharCode(a.keyCode || a.which);
- if (this.settings.create && "multi" ===
- this.settings.mode && b === this.settings.delimiter) return this.createItem(), a.preventDefault(), !1
- },
- onKeyDown: function(a) {
- if (this.isLocked) 9 !== a.keyCode && a.preventDefault();
- else {
- switch (a.keyCode) {
- case 65:
- if (this.isCmdDown) {
- this.selectAll();
- return
- }
- break;
- case 27:
- this.isOpen && (a.preventDefault(), a.stopPropagation(), this.close());
- return;
- case 78:
- if (!a.ctrlKey || a.altKey) break;
- case 40:
- if (!this.isOpen && this.hasOptions) this.open();
- else if (this.$activeOption) {
- this.ignoreHover = !0;
- var b = this.getAdjacentOption(this.$activeOption,
- 1);
- b.length && this.setActiveOption(b, !0, !0)
- }
- a.preventDefault();
- return;
- case 80:
- if (!a.ctrlKey || a.altKey) break;
- case 38:
- this.$activeOption && (this.ignoreHover = !0, b = this.getAdjacentOption(this.$activeOption, -1), b.length && this.setActiveOption(b, !0, !0));
- a.preventDefault();
- return;
- case 13:
- this.isOpen && this.$activeOption && (this.onOptionSelect({
- currentTarget: this.$activeOption
- }), a.preventDefault());
- return;
- case 37:
- this.advanceSelection(-1, a);
- return;
- case 39:
- this.advanceSelection(1, a);
- return;
- case 9:
- this.settings.selectOnTab &&
- this.isOpen && this.$activeOption && (this.onOptionSelect({
- currentTarget: this.$activeOption
- }), this.isFull() || a.preventDefault());
- this.settings.create && this.createItem() && a.preventDefault();
- return;
- case 8:
- case 46:
- this.deleteSelection(a);
- return
- }!this.isFull() && !this.isInputHidden || (f ? a.metaKey : a.ctrlKey) || a.preventDefault()
- }
- },
- onKeyUp: function(a) {
- if (this.isLocked) return a && a.preventDefault();
- a = this.$control_input.val() || "";
- this.lastValue !== a && (this.lastValue = a, this.onSearchChange(a), this.refreshOptions(),
- this.trigger("type", a))
- },
- onSearchChange: function(a) {
- var b = this,
- c = b.settings.load;
- c && !b.loadedSearches.hasOwnProperty(a) && (b.loadedSearches[a] = !0, b.load(function(d) {
- c.apply(b, [a, d])
- }))
- },
- onFocus: function(a) {
- var b = this.isFocused;
- if (this.isDisabled) return this.blur(), a && a.preventDefault(), !1;
- if (!this.ignoreFocus) {
- this.isFocused = !0;
- if ("focus" === this.settings.preload) this.onSearchChange("");
- b || this.trigger("focus");
- this.$activeItems.length || (this.showInput(), this.setActiveItem(null), this.refreshOptions(!!this.settings.openOnFocus));
- this.refreshState()
- }
- },
- onBlur: function(a, b) {
- var c = this;
- if (c.isFocused && (c.isFocused = !1, !c.ignoreFocus))
- if (c.ignoreBlur || document.activeElement !== c.$dropdown_content[0]) {
- var d = function() {
- c.close();
- c.setTextboxValue("");
- c.setActiveItem(null);
- c.setActiveOption(null);
- c.setCaret(c.items.length);
- c.refreshState();
- (b || document.body).focus();
- c.ignoreFocus = !1;
- c.trigger("blur")
- };
- c.ignoreFocus = !0;
- c.settings.create && c.settings.createOnBlur ? c.createItem(null, !1, d) : d()
- } else c.ignoreBlur = !0, c.onFocus(a)
- },
- onOptionHover: function(a) {
- this.ignoreHover ||
- this.setActiveOption(a.currentTarget, !1)
- },
- onOptionSelect: function(b) {
- var c, d = this;
- b.preventDefault && (b.preventDefault(), b.stopPropagation());
- c = a(b.currentTarget);
- c.hasClass("create") ? d.createItem(null, function() {
- d.settings.closeAfterSelect && d.close()
- }) : (c = c.attr("data-value"), "undefined" !== typeof c && (d.lastQuery = null, d.setTextboxValue(""), d.addItem(c), d.settings.closeAfterSelect ? d.close() : !d.settings.hideSelected && b.type && /mouse/.test(b.type) && d.setActiveOption(d.getOption(c))))
- },
- onItemSelect: function(a) {
- this.isLocked ||
- "multi" !== this.settings.mode || (a.preventDefault(), this.setActiveItem(a.currentTarget, a))
- },
- load: function(a) {
- var b = this,
- c = b.$wrapper.addClass(b.settings.loadingClass);
- b.loading++;
- a.apply(b, [function(a) {
- b.loading = Math.max(b.loading - 1, 0);
- a && a.length && (b.addOption(a), b.refreshOptions(b.isFocused && !b.isInputHidden));
- b.loading || c.removeClass(b.settings.loadingClass);
- b.trigger("load", a)
- }])
- },
- setTextboxValue: function(a) {
- var b = this.$control_input;
- b.val() !== a && (b.val(a).triggerHandler("update"), this.lastValue =
- a)
- },
- getValue: function() {
- return 1 === this.tagType && this.$input.attr("multiple") ? this.items : this.items.join(this.settings.delimiter)
- },
- setValue: function(a, b) {
- v(this, b ? [] : ["change"], function() {
- this.clear();
- this.addItems(a, b)
- })
- },
- setActiveItem: function(b, c) {
- var d, e, f;
- if ("single" !== this.settings.mode)
- if (b = a(b), b.length) {
- d = c && c.type.toLowerCase();
- if ("mousedown" === d && this.isShiftDown && this.$activeItems.length) {
- d = this.$control.children(".active:last");
- e = Array.prototype.indexOf.apply(this.$control[0].childNodes, [d[0]]);
- d = Array.prototype.indexOf.apply(this.$control[0].childNodes, [b[0]]);
- e > d && (f = e, e = d, d = f);
- for (; e <= d; e++) f = this.$control[0].childNodes[e], -1 === this.$activeItems.indexOf(f) && (a(f).addClass("active"), this.$activeItems.push(f));
- c.preventDefault()
- } else "mousedown" === d && this.isCtrlDown || "keydown" === d && this.isShiftDown ? b.hasClass("active") ? (d = this.$activeItems.indexOf(b[0]), this.$activeItems.splice(d, 1), b.removeClass("active")) : this.$activeItems.push(b.addClass("active")[0]) : (a(this.$activeItems).removeClass("active"),
- this.$activeItems = [b.addClass("active")[0]]);
- this.hideInput();
- this.isFocused || this.focus()
- } else a(this.$activeItems).removeClass("active"), this.$activeItems = [], this.isFocused && this.showInput()
- },
- setActiveOption: function(b, c, d) {
- var e, f, g;
- this.$activeOption && this.$activeOption.removeClass("active");
- this.$activeOption = null;
- b = a(b);
- b.length && (this.$activeOption = b.addClass("active"), c || "undefined" === typeof c) && (b = this.$dropdown_content.height(), e = this.$activeOption.outerHeight(!0), c = this.$dropdown_content.scrollTop() ||
- 0, f = this.$activeOption.offset().top - this.$dropdown_content.offset().top + c, g = f - b + e, f + e > b + c ? this.$dropdown_content.stop().animate({
- scrollTop: g
- }, d ? this.settings.scrollDuration : 0) : f < c && this.$dropdown_content.stop().animate({
- scrollTop: f
- }, d ? this.settings.scrollDuration : 0))
- },
- selectAll: function() {
- "single" !== this.settings.mode && (this.$activeItems = Array.prototype.slice.apply(this.$control.children(":not(input)").addClass("active")), this.$activeItems.length && (this.hideInput(), this.close()), this.focus())
- },
- hideInput: function() {
- this.setTextboxValue("");
- this.$control_input.css({
- opacity: 0,
- position: "absolute",
- left: this.rtl ? 1E4 : -1E4
- });
- this.isInputHidden = !0
- },
- showInput: function() {
- this.$control_input.css({
- opacity: 1,
- position: "relative",
- left: 0
- });
- this.isInputHidden = !1
- },
- focus: function() {
- var a = this;
- a.isDisabled || (a.ignoreFocus = !0, a.$control_input[0].focus(), window.setTimeout(function() {
- a.ignoreFocus = !1;
- a.onFocus()
- }, 0))
- },
- blur: function(a) {
- this.$control_input[0].blur();
- this.onBlur(null, a)
- },
- getScoreFunction: function(a) {
- return this.sifter.getScoreFunction(a, this.getSearchOptions())
- },
- getSearchOptions: function() {
- var a = this.settings,
- b = a.sortField;
- "string" === typeof b && (b = [{
- field: b
- }]);
- return {
- fields: a.searchField,
- conjunction: a.searchConjunction,
- sort: b
- }
- },
- search: function(b) {
- var c, d;
- c = this.settings;
- var e = this.getSearchOptions();
- if (c.score && (d = this.settings.score.apply(this, [b]), "function" !== typeof d)) throw Error('Selectize "score" setting must be a function that returns a function');
- b !== this.lastQuery ? (this.lastQuery = b, this.currentResults = b = this.sifter.search(b, a.extend(e, {
- score: d
- }))) :
- b = a.extend(!0, {}, this.currentResults);
- if (c.hideSelected)
- for (c = b.items.length - 1; 0 <= c; c--) - 1 !== this.items.indexOf(k(b.items[c].id)) && b.items.splice(c, 1);
- return b
- },
- refreshOptions: function(c) {
- var d, e, f, g, h, m, l, n, p, q, z, F;
- "undefined" === typeof c && (c = !0);
- var t = this;
- z = a.trim(t.$control_input.val());
- var u = t.search(z),
- v = t.$dropdown_content,
- y = t.$activeOption && k(t.$activeOption.attr("data-value"));
- g = u.items.length;
- "number" === typeof t.settings.maxOptions && (g = Math.min(g, t.settings.maxOptions));
- h = {};
- m = [];
- for (d = 0; d <
- g; d++)
- for (l = t.options[u.items[d].id], n = t.render("option", l), l = l[t.settings.optgroupField] || "", p = a.isArray(l) ? l : [l], e = 0, f = p && p.length; e < f; e++) l = p[e], t.optgroups.hasOwnProperty(l) || (l = ""), h.hasOwnProperty(l) || (h[l] = [], m.push(l)), h[l].push(n);
- this.settings.lockOptgroupOrder && m.sort(function(a, b) {
- return (t.optgroups[a].$order || 0) - (t.optgroups[b].$order || 0)
- });
- n = [];
- d = 0;
- for (g = m.length; d < g; d++) l = m[d], t.optgroups.hasOwnProperty(l) && h[l].length ? (e = t.render("optgroup_header", t.optgroups[l]) || "", e += h[l].join(""),
- n.push(t.render("optgroup", a.extend({}, t.optgroups[l], {
- html: e
- })))) : n.push(h[l].join(""));
- v.html(n.join(""));
- if (t.settings.highlight && u.query.length && u.tokens.length)
- for (d = 0, g = u.tokens.length; d < g; d++) b(v, u.tokens[d].regex);
- if (!t.settings.hideSelected)
- for (d = 0, g = t.items.length; d < g; d++) t.getOption(t.items[d]).addClass("selected");
- if (d = t.canCreate(z)) v.prepend(t.render("option_create", {
- input: z
- })), F = a(v[0].childNodes[0]);
- t.hasOptions = 0 < u.items.length || d;
- t.hasOptions ? (0 < u.items.length ? ((z = y && t.getOption(y)) &&
- z.length ? q = z : "single" === t.settings.mode && t.items.length && (q = t.getOption(t.items[0])), q && q.length || (q = F && !t.settings.addPrecedence ? t.getAdjacentOption(F, 1) : v.find("[data-selectable]:first"))) : q = F, t.setActiveOption(q), c && !t.isOpen && t.open()) : (t.setActiveOption(null), c && t.isOpen && t.close())
- },
- addOption: function(b) {
- var c, d;
- if (a.isArray(b))
- for (c = 0, d = b.length; c < d; c++) this.addOption(b[c]);
- else if (c = this.registerOption(b)) this.userOptions[c] = !0, this.lastQuery = null, this.trigger("option_add", c, b)
- },
- registerOption: function(a) {
- var b =
- k(a[this.settings.valueField]);
- if (!b || this.options.hasOwnProperty(b)) return !1;
- a.$order = a.$order || ++this.order;
- this.options[b] = a;
- return b
- },
- registerOptionGroup: function(a) {
- var b = k(a[this.settings.optgroupValueField]);
- if (!b) return !1;
- a.$order = a.$order || ++this.order;
- this.optgroups[b] = a;
- return b
- },
- addOptionGroup: function(a, b) {
- b[this.settings.optgroupValueField] = a;
- (a = this.registerOptionGroup(b)) && this.trigger("optgroup_add", a, b)
- },
- removeOptionGroup: function(a) {
- this.optgroups.hasOwnProperty(a) && (delete this.optgroups[a],
- this.renderCache = {}, this.trigger("optgroup_remove", a))
- },
- clearOptionGroups: function() {
- this.optgroups = {};
- this.renderCache = {};
- this.trigger("optgroup_clear")
- },
- updateOption: function(b, c) {
- var d, e, f;
- b = k(b);
- d = k(c[this.settings.valueField]);
- if (null !== b && this.options.hasOwnProperty(b)) {
- if ("string" !== typeof d) throw Error("Value must be set in option data");
- f = this.options[b].$order;
- d !== b && (delete this.options[b], e = this.items.indexOf(b), -1 !== e && this.items.splice(e, 1, d));
- c.$order = c.$order || f;
- this.options[d] = c;
- e = this.renderCache.item;
- f = this.renderCache.option;
- e && (delete e[b], delete e[d]);
- f && (delete f[b], delete f[d]); - 1 !== this.items.indexOf(d) && (d = this.getItem(b), e = a(this.render("item", c)), d.hasClass("active") && e.addClass("active"), d.replaceWith(e));
- this.lastQuery = null;
- this.isOpen && this.refreshOptions(!1)
- }
- },
- removeOption: function(a, b) {
- a = k(a);
- var c = this.renderCache.item,
- d = this.renderCache.option;
- c && delete c[a];
- d && delete d[a];
- delete this.userOptions[a];
- delete this.options[a];
- this.lastQuery = null;
- this.trigger("option_remove",
- a);
- this.removeItem(a, b)
- },
- clearOptions: function() {
- this.loadedSearches = {};
- this.userOptions = {};
- this.renderCache = {};
- this.options = this.sifter.items = {};
- this.lastQuery = null;
- this.trigger("option_clear");
- this.clear()
- },
- getOption: function(a) {
- return this.getElementWithValue(a, this.$dropdown_content.find("[data-selectable]"))
- },
- getAdjacentOption: function(b, c) {
- var d = this.$dropdown.find("[data-selectable]"),
- e = d.index(b) + c;
- return 0 <= e && e < d.length ? d.eq(e) : a()
- },
- getElementWithValue: function(b, c) {
- b = k(b);
- if ("undefined" !==
- typeof b && null !== b)
- for (var d = 0, e = c.length; d < e; d++)
- if (c[d].getAttribute("data-value") === b) return a(c[d]);
- return a()
- },
- getItem: function(a) {
- return this.getElementWithValue(a, this.$control.children())
- },
- addItems: function(b, c) {
- for (var d = a.isArray(b) ? b : [b], e = 0, f = d.length; e < f; e++) this.isPending = e < f - 1, this.addItem(d[e], c)
- },
- addItem: function(b, c) {
- v(this, c ? [] : ["change"], function() {
- var d, e, f, g = this.settings.mode;
- b = k(b); - 1 !== this.items.indexOf(b) ? "single" === g && this.close() : this.options.hasOwnProperty(b) && ("single" ===
- g && this.clear(), "multi" === g && this.isFull() || (d = a(this.render("item", this.options[b])), f = this.isFull(), this.items.splice(this.caretPos, 0, b), this.insertAtCaret(d), (!this.isPending || !f && this.isFull()) && this.refreshState(), this.isSetup && (f = this.$dropdown_content.find("[data-selectable]"), this.isPending || (e = this.getOption(b), e = this.getAdjacentOption(e, 1).attr("data-value"), this.refreshOptions(this.isFocused && "single" !== g), e && this.setActiveOption(this.getOption(e))), !f.length || this.isFull() ? this.close() :
- this.positionDropdown(), this.updatePlaceholder(), this.trigger("item_add", b, d), this.updateOriginalInput({
- silent: c
- }))))
- })
- },
- removeItem: function(a, b) {
- var c, d, e;
- c = "object" === typeof a ? a : this.getItem(a);
- a = k(c.attr("data-value"));
- d = this.items.indexOf(a); - 1 !== d && (c.remove(), c.hasClass("active") && (e = this.$activeItems.indexOf(c[0]), this.$activeItems.splice(e, 1)), this.items.splice(d, 1), this.lastQuery = null, !this.settings.persist && this.userOptions.hasOwnProperty(a) && this.removeOption(a, b), d < this.caretPos && this.setCaret(this.caretPos -
- 1), this.refreshState(), this.updatePlaceholder(), this.updateOriginalInput({
- silent: b
- }), this.positionDropdown(), this.trigger("item_remove", a, c))
- },
- createItem: function(b, c) {
- var d = this,
- e = d.caretPos;
- b = b || a.trim(d.$control_input.val() || "");
- var f = arguments[arguments.length - 1];
- "function" !== typeof f && (f = function() {});
- "boolean" !== typeof c && (c = !0);
- if (!d.canCreate(b)) return f(), !1;
- d.lock();
- var g = "function" === typeof d.settings.create ? this.settings.create : function(a) {
- var b = {};
- b[d.settings.labelField] = a;
- b[d.settings.valueField] =
- a;
- return b
- },
- h = p(function(a) {
- d.unlock();
- if (!a || "object" !== typeof a) return f();
- var b = k(a[d.settings.valueField]);
- if ("string" !== typeof b) return f();
- d.setTextboxValue("");
- d.addOption(a);
- d.setCaret(e);
- d.addItem(b);
- d.refreshOptions(c && "single" !== d.settings.mode);
- f(a)
- }),
- g = g.apply(this, [b, h]);
- "undefined" !== typeof g && h(g);
- return !0
- },
- refreshItems: function() {
- this.lastQuery = null;
- this.isSetup && this.addItem(this.items);
- this.refreshState();
- this.updateOriginalInput()
- },
- refreshState: function() {
- this.isRequired && (this.items.length &&
- (this.isInvalid = !1), this.$control_input.prop("required", void 0));
- this.refreshClasses()
- },
- refreshClasses: function() {
- var b = this.isFull(),
- c = this.isLocked;
- this.$wrapper.toggleClass("rtl", this.rtl);
- this.$control.toggleClass("focus", this.isFocused).toggleClass("disabled", this.isDisabled).toggleClass("required", this.isRequired).toggleClass("invalid", this.isInvalid).toggleClass("locked", c).toggleClass("full", b).toggleClass("not-full", !b).toggleClass("input-active", this.isFocused && !this.isInputHidden).toggleClass("dropdown-active",
- this.isOpen).toggleClass("has-options", !a.isEmptyObject(this.options)).toggleClass("has-items", 0 < this.items.length);
- this.$control_input.data("grow", !b && !c)
- },
- isFull: function() {
- return null !== this.settings.maxItems && this.items.length >= this.settings.maxItems
- },
- updateOriginalInput: function(a) {
- var b, c, d, e;
- a = a || {};
- if (1 === this.tagType) {
- d = [];
- b = 0;
- for (c = this.items.length; b < c; b++) e = this.options[this.items[b]][this.settings.labelField] || "", d.push('<option value="' + n(this.items[b]) + '" selected="selected">' + n(e) +
- "</option>");
- d.length || this.$input.attr("multiple") || d.push('<option value="" selected="selected"></option>');
- this.$input.html(d.join(""))
- } else this.$input.val(this.getValue()), this.$input.attr("value", this.$input.val());
- this.isSetup && (a.silent || this.trigger("change", this.$input.val()))
- },
- updatePlaceholder: function() {
- if (this.settings.placeholder) {
- var a = this.$control_input;
- this.items.length ? a.removeAttr("placeholder") : a.attr("placeholder", this.settings.placeholder);
- a.triggerHandler("update", {
- force: !0
- })
- }
- },
- open: function() {
- this.isLocked || this.isOpen || "multi" === this.settings.mode && this.isFull() || (this.focus(), this.isOpen = !0, this.refreshState(), this.$dropdown.css({
- visibility: "hidden",
- display: "block"
- }), this.positionDropdown(), this.$dropdown.css({
- visibility: "visible"
- }), this.trigger("dropdown_open", this.$dropdown))
- },
- close: function() {
- var a = this.isOpen;
- "single" === this.settings.mode && this.items.length && this.hideInput();
- this.isOpen = !1;
- this.$dropdown.hide();
- this.setActiveOption(null);
- this.refreshState();
- a && this.trigger("dropdown_close",
- this.$dropdown)
- },
- positionDropdown: function() {
- var a = this.$control,
- b = "body" === this.settings.dropdownParent ? a.offset() : a.position();
- b.top += a.outerHeight(!0);
- this.$dropdown.css({
- width: a.outerWidth(),
- top: b.top,
- left: b.left
- })
- },
- clear: function(a) {
- this.items.length && (this.$control.children(":not(input)").remove(), this.items = [], this.lastQuery = null, this.setCaret(0), this.setActiveItem(null), this.updatePlaceholder(), this.updateOriginalInput({
- silent: a
- }), this.refreshState(), this.showInput(), this.trigger("clear"))
- },
- insertAtCaret: function(b) {
- var c = Math.min(this.caretPos, this.items.length);
- 0 === c ? this.$control.prepend(b) : a(this.$control[0].childNodes[c]).before(b);
- this.setCaret(c + 1)
- },
- deleteSelection: function(b) {
- var c, d, e, f, g;
- c = b && 8 === b.keyCode ? -1 : 1;
- d = u(this.$control_input[0]);
- this.$activeOption && !this.settings.hideSelected && (g = this.getAdjacentOption(this.$activeOption, -1).attr("data-value"));
- e = [];
- if (this.$activeItems.length) {
- f = this.$control.children(".active:" + (0 < c ? "last" : "first"));
- f = this.$control.children(":not(input)").index(f);
- 0 < c && f++;
- c = 0;
- for (d = this.$activeItems.length; c < d; c++) e.push(a(this.$activeItems[c]).attr("data-value"));
- b && (b.preventDefault(), b.stopPropagation())
- } else(this.isFocused || "single" === this.settings.mode) && this.items.length && (0 > c && 0 === d.start && 0 === d.length ? e.push(this.items[this.caretPos - 1]) : 0 < c && d.start === this.$control_input.val().length && e.push(this.items[this.caretPos]));
- if (!e.length || "function" === typeof this.settings.onDelete && !1 === this.settings.onDelete.apply(this, [e])) return !1;
- for ("undefined" !== typeof f &&
- this.setCaret(f); e.length;) this.removeItem(e.pop());
- this.showInput();
- this.positionDropdown();
- this.refreshOptions(!0);
- g && (b = this.getOption(g), b.length && this.setActiveOption(b));
- return !0
- },
- advanceSelection: function(a, b) {
- var c, d;
- 0 !== a && (this.rtl && (a *= -1), c = 0 < a ? "last" : "first", d = u(this.$control_input[0]), this.isFocused && !this.isInputHidden ? (c = this.$control_input.val().length, (d = 0 > a ? 0 === d.start && 0 === d.length : d.start === c) && !c && this.advanceCaret(a, b)) : (d = this.$control.children(".active:" + c), d.length && (d = this.$control.children(":not(input)").index(d),
- this.setActiveItem(null), this.setCaret(0 < a ? d + 1 : d))))
- },
- advanceCaret: function(a, b) {
- var c;
- 0 !== a && (c = 0 < a ? "next" : "prev", this.isShiftDown ? (c = this.$control_input[c](), c.length && (this.hideInput(), this.setActiveItem(c), b && b.preventDefault())) : this.setCaret(this.caretPos + a))
- },
- setCaret: function(b) {
- b = "single" === this.settings.mode ? this.items.length : Math.max(0, Math.min(this.items.length, b));
- if (!this.isPending) {
- var c, d, e, f;
- e = this.$control.children(":not(input)");
- c = 0;
- for (d = e.length; c < d; c++) f = a(e[c]).detach(), c < b ?
- this.$control_input.before(f) : this.$control.append(f)
- }
- this.caretPos = b
- },
- lock: function() {
- this.close();
- this.isLocked = !0;
- this.refreshState()
- },
- unlock: function() {
- this.isLocked = !1;
- this.refreshState()
- },
- disable: function() {
- this.$input.prop("disabled", !0);
- this.$control_input.prop("disabled", !0).prop("tabindex", -1);
- this.isDisabled = !0;
- this.lock()
- },
- enable: function() {
- this.$input.prop("disabled", !1);
- this.$control_input.prop("disabled", !1).prop("tabindex", this.tabIndex);
- this.isDisabled = !1;
- this.unlock()
- },
- destroy: function() {
- var b =
- this.eventNS,
- c = this.revertSettings;
- this.trigger("destroy");
- this.off();
- this.$wrapper.remove();
- this.$dropdown.remove();
- this.$input.html("").append(c.$children).removeAttr("tabindex").removeClass("selectized").attr({
- tabindex: c.tabindex
- }).show();
- this.$control_input.removeData("grow");
- this.$input.removeData("selectize");
- a(window).off(b);
- a(document).off(b);
- a(document.body).off(b);
- delete this.$input[0].selectize
- },
- render: function(a, b) {
- var c, d, e = "",
- f = !1,
- g = /^[\t \r\n]*<([a-z][a-z0-9\-_]*(?:\:[a-z][a-z0-9\-_]*)?)/i;
- if ("option" === a || "item" === a) c = k(b[this.settings.valueField]), f = !!c;
- if (f && ("undefined" === typeof this.renderCache[a] && (this.renderCache[a] = {}), this.renderCache[a].hasOwnProperty(c))) return this.renderCache[a][c];
- e = this.settings.render[a].apply(this, [b, n]);
- if ("option" === a || "option_create" === a) e = e.replace(g, "<$1 data-selectable");
- "optgroup" === a && (d = b[this.settings.optgroupValueField] || "", e = e.replace(g, '<$1 data-group="' + q(n(d)) + '"'));
- if ("option" === a || "item" === a) e = e.replace(g, '<$1 data-value="' + q(n(c ||
- "")) + '"');
- f && (this.renderCache[a][c] = e);
- return e
- },
- clearCache: function(a) {
- "undefined" === typeof a ? this.renderCache = {} : delete this.renderCache[a]
- },
- canCreate: function(a) {
- if (!this.settings.create) return !1;
- var b = this.settings.createFilter;
- return a.length && ("function" !== typeof b || b.apply(this, [a])) && ("string" !== typeof b || (new RegExp(b)).test(a)) && (!(b instanceof RegExp) || b.test(a))
- }
- });
- A.count = 0;
- A.defaults = {
- options: [],
- optgroups: [],
- plugins: [],
- delimiter: ",",
- splitOn: null,
- persist: !0,
- diacritics: !0,
- create: !1,
- createOnBlur: !1,
- createFilter: null,
- highlight: !0,
- openOnFocus: !0,
- maxOptions: 1E3,
- maxItems: null,
- hideSelected: null,
- addPrecedence: !1,
- selectOnTab: !1,
- preload: !1,
- allowEmptyOption: !1,
- closeAfterSelect: !1,
- scrollDuration: 60,
- loadThrottle: 300,
- loadingClass: "loading",
- dataAttr: "data-data",
- optgroupField: "optgroup",
- valueField: "value",
- labelField: "text",
- optgroupLabelField: "label",
- optgroupValueField: "value",
- lockOptgroupOrder: !1,
- sortField: "$order",
- searchField: ["text"],
- searchConjunction: "and",
- mode: null,
- wrapperClass: "selectize-control",
- inputClass: "selectize-input",
- dropdownClass: "selectize-dropdown",
- dropdownContentClass: "selectize-dropdown-content",
- dropdownParent: null,
- copyClassesToDropdown: !0,
- render: {}
- };
- a.fn.selectize = function(b) {
- var c = a.fn.selectize.defaults,
- d = a.extend({}, c, b),
- e = d.dataAttr,
- f = d.labelField,
- g = d.valueField,
- h = d.optgroupField,
- m = d.optgroupLabelField,
- l = d.optgroupValueField,
- n = {},
- p = function(b, c) {
- var r, p, B, q, u = c.options,
- v = function(a) {
- a = e && a.attr(e);
- return "string" === typeof a && a.length ? JSON.parse(a) : null
- },
- y = function(b, e) {
- b = a(b);
- var m = k(b.attr("value"));
- if (m || d.allowEmptyOption)
- if (n.hasOwnProperty(m)) {
- if (e) {
- var l = n[m][h];
- l ? a.isArray(l) ? l.push(e) : n[m][h] = [l, e] : n[m][h] = e
- }
- } else l = v(b) || {}, l[f] = l[f] || b.text(), l[g] = l[g] || m, l[h] = l[h] || e, n[m] = l, u.push(l), b.is(":selected") && c.items.push(m)
- },
- A = function(b) {
- var d, e, f;
- b = a(b);
- if (e = b.attr("label")) d = v(b) || {}, d[m] = e, d[l] = e, c.optgroups.push(d);
- f = a("option", b);
- b = 0;
- for (d = f.length; b < d; b++) y(f[b], e)
- };
- c.maxItems = b.attr("multiple") ? null : 1;
- q = b.children();
- r = 0;
- for (p = q.length; r < p; r++) B = q[r].tagName.toLowerCase(), "optgroup" ===
- B ? A(q[r]) : "option" === B && y(q[r])
- };
- return this.each(function() {
- if (!this.selectize) {
- var h = a(this),
- k = this.tagName.toLowerCase(),
- m = h.attr("placeholder") || h.attr("data-placeholder");
- m || d.allowEmptyOption || (m = h.children('option[value=""]').text());
- m = {
- placeholder: m,
- options: [],
- optgroups: [],
- items: []
- };
- if ("select" === k) p(h, m);
- else {
- var l, n, q;
- if (k = h.attr(e))
- for (m.options = JSON.parse(k), k = 0, l = m.options.length; k < l; k++) m.items.push(m.options[k][g]);
- else if (k = a.trim(h.val() || ""), d.allowEmptyOption || k.length) {
- n = k.split(d.delimiter);
- k = 0;
- for (l = n.length; k < l; k++) q = {}, q[f] = n[k], q[g] = n[k], m.options.push(q);
- m.items = n
- }
- }
- new A(h, a.extend(!0, {}, c, m, b))
- }
- })
- };
- a.fn.selectize.defaults = A.defaults;
- a.fn.selectize.support = {
- validity: m
- };
- A.define("drag_drop", function(b) {
- if (!a.fn.sortable) throw Error('The "drag_drop" plugin requires jQuery UI "sortable".');
- if ("multi" === this.settings.mode) {
- var c = this;
- c.lock = function() {
- var a = c.lock;
- return function() {
- var b = c.$control.data("sortable");
- b && b.disable();
- return a.apply(c, arguments)
- }
- }();
- c.unlock = function() {
- var a =
- c.unlock;
- return function() {
- var b = c.$control.data("sortable");
- b && b.enable();
- return a.apply(c, arguments)
- }
- }();
- c.setup = function() {
- var b = c.setup;
- return function() {
- b.apply(this, arguments);
- var d = c.$control.sortable({
- items: "[data-value]",
- forcePlaceholderSize: !0,
- disabled: c.isLocked,
- start: function(a, b) {
- b.placeholder.css("width", b.helper.css("width"));
- d.css({
- overflow: "visible"
- })
- },
- stop: function() {
- d.css({
- overflow: "hidden"
- });
- var b = c.$activeItems ? c.$activeItems.slice() : null,
- e = [];
- d.children("[data-value]").each(function() {
- e.push(a(this).attr("data-value"))
- });
- c.setValue(e);
- c.setActiveItem(b)
- }
- })
- }
- }()
- }
- });
- A.define("dropdown_header", function(b) {
- var c = this;
- b = a.extend({
- title: "Untitled",
- headerClass: "selectize-dropdown-header",
- titleRowClass: "selectize-dropdown-header-title",
- labelClass: "selectize-dropdown-header-label",
- closeClass: "selectize-dropdown-header-close",
- html: function(a) {
- return '<div class="' + a.headerClass + '"><div class="' + a.titleRowClass + '"><span class="' + a.labelClass + '">' + a.title + '</span><a href="javascript:void(0)" class="' + a.closeClass + '">×</a></div></div>'
- }
- },
- b);
- c.setup = function() {
- var d = c.setup;
- return function() {
- d.apply(c, arguments);
- c.$dropdown_header = a(b.html(b));
- c.$dropdown.prepend(c.$dropdown_header)
- }
- }()
- });
- A.define("optgroup_columns", function(b) {
- var c = this;
- b = a.extend({
- equalizeWidth: !0,
- equalizeHeight: !0
- }, b);
- this.getAdjacentOption = function(b, c) {
- var d = b.closest("[data-group]").find("[data-selectable]"),
- e = d.index(b) + c;
- return 0 <= e && e < d.length ? d.eq(e) : a()
- };
- this.onKeyDown = function() {
- var a = c.onKeyDown;
- return function(b) {
- var d, e;
- if (!this.isOpen || 37 !== b.keyCode &&
- 39 !== b.keyCode) return a.apply(this, arguments);
- c.ignoreHover = !0;
- e = this.$activeOption.closest("[data-group]");
- d = e.find("[data-selectable]").index(this.$activeOption);
- e = 37 === b.keyCode ? e.prev("[data-group]") : e.next("[data-group]");
- e = e.find("[data-selectable]");
- d = e.eq(Math.min(e.length - 1, d));
- d.length && this.setActiveOption(d)
- }
- }();
- var d = function() {
- var a, b = d.width,
- c = document;
- "undefined" === typeof b && (a = c.createElement("div"), a.innerHTML = '<div style="width:50px;height:50px;position:absolute;left:-50px;top:-50px;overflow:auto;"><div style="width:1px;height:100px;"></div></div>',
- a = a.firstChild, c.body.appendChild(a), b = d.width = a.offsetWidth - a.clientWidth, c.body.removeChild(a));
- return b
- },
- e = function() {
- var e, f, g, h;
- h = a("[data-group]", c.$dropdown_content);
- if ((f = h.length) && c.$dropdown_content.width()) {
- if (b.equalizeHeight) {
- for (e = g = 0; e < f; e++) g = Math.max(g, h.eq(e).height());
- h.css({
- height: g
- })
- }
- b.equalizeWidth && (g = c.$dropdown_content.innerWidth() - d(), e = Math.round(g / f), h.css({
- width: e
- }), 1 < f && (e = g - e * (f - 1), h.eq(f - 1).css({
- width: e
- })))
- }
- };
- if (b.equalizeHeight || b.equalizeWidth) l.after(this, "positionDropdown",
- e), l.after(this, "refreshOptions", e)
- });
- A.define("remove_button", function(b) {
- if ("single" !== this.settings.mode) {
- b = a.extend({
- label: "×",
- title: "Remove",
- className: "remove",
- append: !0
- }, b);
- var c = this,
- d = '<a href="javascript:void(0)" class="' + b.className + '" tabindex="-1" title="' + n(b.title) + '">' + b.label + "</a>";
- this.setup = function() {
- var e = c.setup;
- return function() {
- if (b.append) {
- var f = c.settings.render.item;
- c.settings.render.item = function(a) {
- var b = f.apply(this, arguments),
- c = b.search(/(<\/[^>]+>\s*)$/);
- return b.substring(0,
- c) + d + b.substring(c)
- }
- }
- e.apply(this, arguments);
- this.$control.on("click", "." + b.className, function(b) {
- b.preventDefault();
- c.isLocked || (b = a(b.currentTarget).parent(), c.setActiveItem(b), c.deleteSelection() && c.setCaret(c.items.length))
- })
- }
- }()
- }
- });
- A.define("restore_on_backspace", function(a) {
- var b = this;
- a.text = a.text || function(a) {
- return a[this.settings.labelField]
- };
- this.onKeyDown = function() {
- var c = b.onKeyDown;
- return function(b) {
- var d;
- if (8 === b.keyCode && "" === this.$control_input.val() && !this.$activeItems.length &&
- (d = this.caretPos - 1, 0 <= d && d < this.items.length)) {
- d = this.options[this.items[d]];
- this.deleteSelection(b) && (this.setTextboxValue(a.text.apply(this, [d])), this.refreshOptions(!0));
- b.preventDefault();
- return
- }
- return c.apply(this, arguments)
- }
- }()
- });
- return A
- });
- Moobot = function(a) {
- a.version = 47;
- a.username = "moobot";
- return a
- }(Moobot || {});
- Moobot = function(a) {
- var d = {};
- a.event = {
- trigger: function(a, b) {
- d[a] && $.each(d[a], function(e) {
- d[a][e](b)
- })
- },
- subscribe: function(a, b) {
- d[a] || (d[a] = []);
- d[a].push(b)
- }
- };
- return a
- }(Moobot || {});
- Moobot = function(a) {
- a.user = {
- username: function() {
- if ("undefined" !== typeof $.cookie("login") && "undefined" !== typeof $.cookie("token")) return $.cookie("login")
- },
- token: function() {
- if ("undefined" !== typeof $.cookie("token")) return $.cookie("token")
- },
- loggedin: function() {
- return "undefined" !== typeof Moobot.user.username()
- },
- login: function(a, c, b) {
- "undefined" !== typeof a && "undefined" !== typeof c && (b = "undefined" !== typeof b && (b instanceof Date || "number" === typeof b) ? new Date(b) : 29, $.cookie("login", a, {
- expires: b,
- path: "/"
- }),
- $.cookie("token", c, {
- expires: b,
- path: "/"
- }), $.cookie("welcome", !0, {
- expires: 365,
- path: "/"
- }), Moobot.event.trigger("User/login"))
- },
- logout: function() {
- if (Moobot.user.loggedin()) {
- var d = setTimeout(function() {
- Moobot.event.trigger("User/logout")
- }, 5E3);
- a.api.request("/user/logout", {
- callback: function() {
- clearTimeout(d);
- Moobot.event.trigger("User/logout")
- },
- error: function() {
- clearTimeout(d);
- Moobot.event.trigger("User/logout")
- }
- });
- $.removeCookie("login", {
- path: "/"
- });
- $.removeCookie("token", {
- path: "/"
- })
- }
- },
- regex: /^[a-zA-Z0-9_]{2,25}$/,
- valid: function(a) {
- return Moobot.user.regex.test(a)
- }
- };
- return a
- }(Moobot || {});
- Moobot = function(a) {
- a.dashboard = {
- dashboard: function() {
- return window.location.pathname.replace("/", "").toLowerCase()
- }
- };
- return a
- }(Moobot || {});
- Moobot = function(a) {
- var d = function(a) {
- try {
- "undefined" !== typeof a.abort && a.abort()
- } catch (b) {}
- };
- a.api = {
- abort: d,
- request: function(a, b) {
- b = $.extend({
- version: 1,
- params: {},
- timeout: 1E4,
- error: function(a) {
- Moobot.api.error(a)
- }
- }, b);
- b.params.auth_token = Moobot.user.token();
- var e = null,
- f = setTimeout(function() {
- null !== e && (d(e), b.error({
- message: "Could not connect to service, try again later",
- error: "API",
- status: 1
- }))
- }, b.timeout);
- return e = $.getJSON(location.protocol + "//api." + location.hostname + "/" + b.version + a + "?callback=?",
- b.params,
- function(a) {
- null !== f && clearTimeout(f);
- "undefined" !== typeof a && null !== a && "undefined" !== typeof a.error ? b.error(a) : "undefined" !== typeof b.callback && b.callback(a)
- }).fail(function() {
- null !== f && clearTimeout(f);
- "abort" !== e.statusText && b.error({
- message: "Could not connect to service, try again later",
- error: "API",
- status: 0
- })
- })
- },
- error: function(a) {
- a = $.extend({
- message: "An unknown error occured",
- error: "Error",
- status: 0
- }, $.isPlainObject(a) ? a : {});
- Moobot.event.trigger("Api/error", a)
- }
- };
- return a
- }(Moobot || {});
- Moobot.event.subscribe("Api/error", function(a) {
- "undefined" !== typeof _gaq && _gaq.push(["_trackEvent", "API", "Error", a.error])
- });
- Moobot = function(a) {
- a.misc = $.extend(a.misc || {}, {
- numberFormat: function(a) {
- x = (a + "").split(".");
- x1 = x[0];
- x2 = 1 < x.length ? "." + x[1] : "";
- for (a = /(\d+)(\d{3})/; a.test(x1);) x1 = x1.replace(a, "$1,$2");
- return x1 + x2
- },
- sentenceCase: function(a) {
- return a.charAt(0).toUpperCase() + a.substr(1)
- },
- regexEscape: function(a) {
- return String(a).replace(/([-()\[\]{}+?*.$\^|,:#<!\\])/g, "\\$1").replace(/\x08/g, "\\x08")
- }
- });
- return a
- }(Moobot || {});
- Moobot = function(a) {
- a.misc = $.extend(a.misc || {}, {
- scrollbar: {
- show: function() {
- $("body").css({
- "margin-left": "0",
- overflow: "auto"
- });
- $.each([".navbar-fixed-top .navbar-inner", ".subnavbar .subnavbar-inner", ".main .main-inner", "#footer"], function(a, c) {
- $(c).removeAttr("style")
- })
- },
- hide: function() {
- var a = $(document).outerHeight(!0) > $(window).outerHeight(!0),
- c = 979 < $(window).outerWidth(!0);
- if (a) {
- var b = function() {
- var a, b;
- void 0 === b && (a = $('<div style="width:50px;height:50px;overflow:auto"><div/></div>').appendTo("body"),
- b = a.children(), b = b.innerWidth() - b.height(99).innerWidth(), a.remove());
- return b
- }();
- c ? $("body").css("margin-left", -b) : $.each([".navbar-fixed-top .navbar-inner", ".subnavbar .subnavbar-inner", ".main .main-inner", "#footer"], function(a, c) {
- $(c).css("padding-right", parseInt($(c).css("padding-right"), 10) + b)
- })
- }
- $("body").css("overflow", "hidden")
- }
- }
- });
- return a
- }(Moobot || {});
- Moobot = function(a) {
- var d = function(a) {
- var b = function(a, b) {
- var c = a[b];
- "string" === typeof c ? a[b] = _.escape(c) : "object" === typeof c && d(c)
- };
- if (a instanceof Array) $.each(a, function(d, e) {
- b(a, d)
- });
- else if ("object" === typeof a)
- for (var e in a) b(a, e)
- };
- a.misc = $.extend(a.misc || {}, {
- escapeObject: d
- });
- return a
- }(Moobot || {});
- Moobot = function(a) {
- var d = [],
- c = function(a, b) {
- for (var c = 0; c < d.length; c++)
- if (d[c].name === a && d[c].type === b) return d[c]
- },
- b = function(a, b, d, e) {
- a = c(a, b);
- "undefined" === typeof a.callbacks && (a.callbacks = []);
- a.callbacks.push({
- callback: d || $.noop,
- error: e || $.noop
- })
- },
- e = function(a, b, d) {
- a = c(a, b);
- d || (a.loaded = !0);
- $.map(a.callbacks || [], function(a) {
- d ? a.error() : a.callback()
- });
- a.callbacks = [];
- delete a.request
- };
- a.resource = {
- add: function(a) {
- d.push($.extend(a, {
- loaded: !1
- }))
- },
- remove: function(a) {
- d = $.grep(d, function(b) {
- return b.name !==
- a
- })
- },
- fetch: function(a) {
- var d = c(a.name, a.type);
- if ("undefined" !== typeof d)
- if (d.loaded) "undefined" !== typeof a.callback && a.callback();
- else if ("undefined" === typeof d.request) {
- b(a.name, a.type, a.callback || $.noop, a.error || $.noop);
- var g;
- if ("js" === d.type) g = $.getScript(d.path, function() {
- e(a.name, a.type, !1)
- }).fail(function() {
- "abort" !== g.statusText ? e(a.name, a.type, !0) : (delete d.request, d.callbacks = [])
- });
- else if ("css" === d.type) g = $.get(d.path, function(b) {
- $("<style />").text(b).appendTo($("head"));
- e(a.name, a.type, !1)
- }).fail(function() {
- "abort" !== g.statusText ? e(a.name, a.type, !0) : (delete d.request, d.callbacks = [])
- });
- else if ("template" === d.type) g = $.get(d.path, function(b) {
- 0 < b.length && $("body").append(b);
- e(a.name, a.type, !1)
- }).fail(function() {
- "abort" !== g.statusText ? e(a.name, a.type, !0) : (delete d.request, d.callbacks = [])
- });
- else {
- e(a.name, a.type, !1);
- return
- }
- if ("undefined" !== typeof g) return d.request = g
- } else b(a.name, a.type, a.callback || $.noop, a.error || $.noop)
- }
- };
- return a
- }(Moobot || {});
- Moobot.resource.add({
- name: "localforage",
- type: "js",
- path: Moobot.paths.js + "ext/localforage.js"
- });
- Moobot = function(a) {
- var d = function() {
- return Modernizr.localstorage
- };
- a.storage = {
- support: d,
- get: function(a) {
- if (d() && null !== localStorage["moobot." + a]) return localStorage["moobot." + a]
- },
- set: function(a, b) {
- d() && (localStorage["moobot." + a] = b)
- }
- };
- return a
- }(Moobot || {});
- Moobot = function(a) {
- var d = {
- FAIL: "fail",
- FETCH: "fetch"
- },
- c = function() {
- var a = !1;
- try {
- new Blob([new Int8Array([17, -45.3])], {
- type: "image/jpeg"
- }), a = !0
- } catch (b) {}
- return Moobot.storage.support() && a
- },
- b = function(a) {
- c() ? Moobot.resource.fetch({
- name: "localforage",
- type: "js",
- callback: function() {
- localforage.config({
- name: "moobot_filestorage",
- version: 1,
- size: 4980736,
- description: "Moobot File Storage"
- });
- a(null)
- },
- error: function() {
- a(d.FETCH)
- }
- }) : a(d.FAIL)
- };
- a.storage = $.extend(a.storage || {}, {
- filestorage: {
- error: d,
- supported: c,
- init: b,
- set: function(a, f, h) {
- c() && "undefined" !== typeof a && "undefined" !== typeof f && f instanceof File ? b(function(b) {
- null === b ? (b = new FileReader, b.onloadend = function(b) {
- if (b.target.readyState == FileReader.DONE) try {
- localforage.setItem(a, {
- value: b.target.result,
- type: f.type
- }, function(a) {
- h(null)
- })
- } catch (c) {
- h(d.FAIL)
- }
- }, b.onerror = function() {
- h(d.FAIL)
- }, b.readAsArrayBuffer(f)) : h(b)
- }) : h(d.FAIL)
- },
- get: function(a, f) {
- c() ? b(function(b) {
- null === b ? localforage.getItem(a, function(a) {
- f(null, null !== a ? window.URL.createObjectURL(new Blob([a.value], {
- type: a.type
- })) : null)
- }) : f(b)
- }) : f(d.FAIL)
- },
- remove: function(a, f) {
- c() ? b(function(b) {
- null === b ? localforage.removeItem(a, function(a) {
- f(null)
- }) : f(b)
- }) : f(d.FAIL)
- }
- }
- });
- return a
- }(Moobot || {});
- Moobot = function(a) {
- a.widgets = {
- list: [],
- contains: function(a) {
- if ("undefined" !== typeof a)
- for (var c = 0; c < Moobot.widgets.list.length; c++)
- if (Moobot.widgets.list[c].id === a) return !0;
- return !1
- },
- get: function(a) {
- if ("undefined" !== typeof a)
- for (var c = 0; c < Moobot.widgets.list.length; c++)
- if (Moobot.widgets.list[c].id === a) return Moobot.widgets.list[c]
- },
- add: function(a, c, b, e) {
- Moobot.widgets.contains(a) || (c = {
- id: a,
- params: c,
- callback: function() {
- b(a)
- },
- populate: function() {
- Moobot.event.trigger("Widget/populating", a);
- e(a, function() {
- Moobot.event.trigger("Widget/populated",
- a)
- })
- }
- }, Moobot.widgets.list.push(c), Moobot.event.trigger("Widget/add", c))
- },
- populate: function(a) {
- a = Moobot.widgets.get(a);
- "undefined" !== typeof a && a.populate()
- },
- update: function(a, c) {
- if (Moobot.widgets.contains(a))
- for (var b = 0; b < Moobot.widgets.list.length; b++)
- if (Moobot.widgets.list[b].id === a) return $.extend(Moobot.widgets.list[b], c), !0;
- return !1
- },
- visible: function(a) {
- a = Moobot.widgets.get(a);
- return "undefined" === typeof a.visible || a.visible
- },
- show: function(a) {
- Moobot.widgets.update(a, {
- visible: !0
- }) && Moobot.event.trigger("Widget/toggle",
- a)
- },
- hide: function(a) {
- Moobot.widgets.update(a, {
- visible: !1
- }) && Moobot.event.trigger("Widget/toggle", a)
- }
- };
- return a
- }(Moobot || {});
- Moobot.event.subscribe("Widget/toggle", function(a) {
- Moobot.storage.set("widgets." + a + ".visible", Moobot.widgets.visible(a))
- });
- Moobot.event.subscribe("Widget/populated", function(a) {
- var d = Moobot.storage.get("widgets." + a + ".visible");
- "undefined" === typeof d || "true" !== d && Moobot.widgets.hide(a)
- });
- Moobot.event.subscribe("Widget/populated", function(a) {
- $("input, textarea").placeholder()
- });
- Moobot.event.subscribe("Widget/add", function(a) {
- "undefined" !== typeof a.params.after && 0 < $("." + a.params.after).length ? $(kite("#" + a.params.template, a)).insertAfter("." + a.params.after) : $(".widget-container-" + a.params.type).append(kite("#" + a.params.template, a));
- a.callback(a.id);
- a.populate()
- });
- Moobot.event.subscribe("Widget/populating", function(a) {
- $("." + a).find(".widget-content").addClass("widget-loading");
- $("." + a).find(".widget-content").empty()
- });
- Moobot.event.subscribe("Widget/populated", function(a) {
- $("." + a).find(".widget-content").removeClass("widget-loading")
- });
- Moobot.event.subscribe("Widget/toggle", function(a) {
- Moobot.widgets.visible(a) ? $("." + a).find(".widget-content").removeClass("hide") : $("." + a).find(".widget-content").addClass("hide")
- });
- Moobot = function(a) {
- a.widgets.data = function(a, c) {
- "" !== c && null !== c ? $("." + a + " .widget-content").html(c) : $("." + a + " .widget-content").empty()
- };
- return a
- }(Moobot || {});
- Moobot = function(a) {
- a.widgets.buttons = {
- disable: function(a) {
- a.addClass("disabled");
- setTimeout($.proxy(function() {
- $(this).removeClass("disabled")
- }, a), 5E3)
- },
- btnrefresh: function(a) {
- var c = $(kite("#template-widget-button", {
- class_name: "btn-refresh",
- icon: "icon-refresh"
- })).appendTo("." + a + " .widget-header .btn-group").click(function() {
- $(this).hasClass("disabled") || (Moobot.widgets.buttons.disable($(this)), Moobot.widgets.get(a).populate())
- });
- Modernizr.touch || c.tooltip({
- title: "Refresh"
- })
- },
- btncustom: function(a,
- c) {
- var b = $(kite("#template-widget-button", {
- class_name: c.class_name,
- icon: c.icon
- })).appendTo("." + a + " " + ("undefined" !== typeof c.container ? c.container : ".widget-header") + " .btn-group");
- Modernizr.touch || b.tooltip({
- title: c.tooltip
- });
- return b
- },
- btnleft: function(a) {
- return Moobot.widgets.buttons.btncustom(a, {
- class_name: "btn-nav btn-nav-left",
- icon: "icon-chevron-left",
- tooltip: "Previous"
- })
- },
- btnright: function(a) {
- return Moobot.widgets.buttons.btncustom(a, {
- class_name: "btn-nav btn-nav-right",
- icon: "icon-chevron-right",
- tooltip: "Next"
- })
- },
- btnpopout: function(a) {
- return Moobot.widgets.buttons.btncustom(a, {
- class_name: "btn-popout",
- icon: "icon-external-link",
- tooltip: "Pop-out"
- })
- },
- btnzoomin: function(a) {
- return Moobot.widgets.buttons.btncustom(a, {
- class_name: "btn-zoom-in",
- icon: "icon-zoom-in",
- tooltip: "Zoom-in"
- })
- },
- btnzoomout: function(a) {
- return Moobot.widgets.buttons.btncustom(a, {
- class_name: "btn-zoom-out",
- icon: "icon-zoom-out",
- tooltip: "Zoom-out"
- })
- },
- btntoggle: function(a) {
- var c = $(kite("#template-widget-button", {
- class_name: "btn-toggle",
- icon: "icon-minus"
- })).appendTo("." + a + " .widget-header .btn-group").click(function() {
- $(this).hasClass("disabled") || (Moobot.widgets.visible(a) ? Moobot.widgets.hide(a) : Moobot.widgets.show(a))
- });
- Modernizr.touch || c.tooltip({
- title: "Hide"
- });
- 0 < $("." + a + " .widget-header .btn-toggle").length && $("." + a).find(".widget-header").click(function() {
- Moobot.widgets.visible(a) ? Moobot.widgets.hide(a) : Moobot.widgets.show(a)
- }).children().click(function() {
- return $(this).is("h1, h2, h3, h4, h5, h6")
- })
- }
- };
- return a
- }(Moobot || {});
- Moobot.event.subscribe("Widget/toggle", function(a) {
- var d = function(a) {
- return a ? "icon-minus" : "icon-plus"
- },
- c = function(a) {
- return a ? "Hide" : "Show"
- },
- b = $("." + a + " .widget-header .btn-toggle");
- 0 < $(b).length && (Modernizr.touch || ($(b).tooltip("destroy"), $(b).tooltip({
- title: c(Moobot.widgets.visible(a))
- })), $(b).find("i").attr("class", d(Moobot.widgets.visible(a))))
- });
- Moobot = function(a) {
- var d = window.location.hash ? window.location.hash.substring(1) : null,
- c = function(a) {
- var c = Moobot.modals.current();
- $(".tooltip").remove();
- $(".popover").remove();
- "undefined" !== typeof c && $("#" + c).remove();
- "undefined" !== typeof a && a && ($(".modal-backdrop").remove(), "undefined" !== typeof c && $("body").removeClass("modal-open"));
- return c
- };
- a.modals = {
- hash: d,
- list: [],
- contains: function(a) {
- if ("undefined" !== typeof a)
- for (var c = 0; c < Moobot.modals.list.length; c++)
- if (Moobot.modals.list[c].id === a) return !0;
- return !1
- },
- get: function(a) {
- if ("undefined" !== typeof a)
- for (var c = 0; c < Moobot.modals.list.length; c++)
- if (Moobot.modals.list[c].id === a) return Moobot.modals.list[c]
- },
- add: function(a, c, d) {
- Moobot.modals.contains(a) || (c = {
- id: a,
- params: c,
- callback: function() {
- d(a)
- }
- }, Moobot.modals.list.push(c), Moobot.event.trigger("Modal/add", c))
- },
- update: function(a, c) {
- if (Moobot.modals.contains(a))
- for (var d = 0; d < Moobot.modals.list.length; d++)
- if (Moobot.modals.list[d].id === a) return $.extend(Moobot.modals.list[d], c), !0;
- return !1
- },
- current: function() {
- if (0 <
- $(".modal").length) return $(".modal").attr("id")
- },
- show: function(a) {
- Moobot.event.trigger("Modal/show", a)
- },
- hide: function(a) {
- Moobot.event.trigger("Modal/hide", a)
- },
- close: function(a) {
- Moobot.event.trigger("Modal/close", a)
- },
- clean: c,
- destroy: function() {
- "undefined" !== typeof c(!0) && Moobot.event.trigger("Modal/destroy")
- },
- backdrop: function() {
- $(".modal-backdrop.in").height() < $(document).height() && $(".modal-backdrop.in").height($(document).height())
- }
- };
- return a
- }(Moobot || {});
- Moobot = function(a) {
- var d = [];
- Moobot.event.subscribe("Modal/show", function(a) {
- 0 < d.length && d[d.length - 1] === a && d.pop();
- d.push(a)
- });
- Moobot.event.subscribe("Modal/hide", function(a) {
- d.pop()
- });
- Moobot.event.subscribe("Modal/destroy", function(a) {
- d = []
- });
- a.modals.open = function() {
- return d
- };
- return a
- }(Moobot || {});
- Moobot = function(a) {
- var d = [],
- c = function(a) {
- d = $.grep(d, function(b) {
- return b !== a
- })
- },
- b = function(a) {
- try {
- "undefined" !== typeof a.abort && a.abort()
- } catch (b) {}
- };
- a.modals.requests = {
- add: function(a) {
- d.push(a)
- },
- remove: c,
- abort: b,
- clear: function() {
- $.each(d, function(a, d) {
- b(d);
- c(d)
- })
- }
- };
- return a
- }(Moobot || {});
- Moobot.event.subscribe("Modal/show", function(a) {
- Moobot.modals.clean(!1);
- var d = Moobot.modals.get(a);
- $("body").append(kite("#" + d.params.template, {
- title: d.params.title,
- id: a
- }));
- $("#" + a).on("hidden", function() {
- Moobot.modals.hide(a)
- });
- d.callback();
- d = {};
- 0 === $(".modal-backdrop").length ? d.backdrop = "static" : d.backdrop = !1;
- $("#" + a).modal(d);
- d.backdrop && $(".modal-backdrop").click(function() {
- var a = Moobot.modals.current();
- 0 < $(".modal.fade.in").length && "undefined" !== typeof a && "undefined" === typeof Moobot.modals.get(a).params["static"] &&
- $(".modal").modal("hide")
- });
- Moobot.modals.backdrop();
- $("input, textarea").placeholder()
- });
- Moobot.event.subscribe("Modal/loaded", function(a) {
- $("input, textarea").placeholder()
- });
- Moobot.event.subscribe("Modal/show", function(a) {
- "undefined" !== typeof _gaq && _gaq.push(["_trackEvent", "Modal", "Show", a])
- });
- Moobot.event.subscribe("Modal/hide", function(a) {
- Moobot.modals.requests.clear();
- 0 < Moobot.modals.open().length ? Moobot.modals.show(Moobot.modals.open()[Moobot.modals.open().length - 1]) : Moobot.modals.destroy()
- });
- Moobot.event.subscribe("Modal/close", function(a) {
- Moobot.modals.requests.clear();
- $("#" + a).modal("hide")
- });
- $(window).resize(function() {
- $("body .modal-backdrop.in").length && Moobot.modals.backdrop()
- });
- Moobot.event.subscribe("Modal/show", function(a) {
- Moobot.misc.scrollbar.hide()
- });
- (function() {
- var a = function() {
- "undefined" === typeof Moobot.modals.get(Moobot.modals.current()) && Moobot.misc.scrollbar.show()
- };
- Moobot.event.subscribe("Modal/hide", a);
- Moobot.event.subscribe("Modal/destroy", a)
- })();
- Moobot.event.subscribe("Loaded", function() {
- null !== Moobot.modals.hash && $.map(Moobot.modals.list, function(a) {
- "undefined" !== typeof a.params.hash && a.params.hash === Moobot.modals.hash && Moobot.modals.show(a.id)
- })
- });
- Moobot.event.subscribe("Modal/show", function(a) {
- "undefined" !== typeof Moobot.modals.get(a).params.hash && setTimeout(function() {
- "undefined" !== typeof Moobot.modals.current() && Moobot.modals.current() === a && (window.location.hash = Moobot.modals.get(a).params.hash)
- }, 200)
- });
- Moobot.event.subscribe("Modal/hide", function() {
- window.location.hash = ""
- });
- Moobot.event.subscribe("Modal/destroy", function() {
- window.location.hash = ""
- });
- Moobot = function(a) {
- a.modals.search = function(a) {
- a = $.extend({
- placeholder: "Search",
- formatQuery: function(a) {
- return a
- },
- search: $.noop
- }, a);
- var c = $('<input id="inputSearch" class="span12" type="text" placeholder="' + a.placeholder + '">').bind("propertychange input paste", function() {
- var b = a.formatQuery($(this).val()).toLowerCase(),
- c = $(a.table).find("tbody tr");
- "" !== b && $.map(c, function(c) {
- var e = _.unescape($(c).data(a.key)).toLowerCase(),
- g = (new Levenshtein(b, e)).distance;
- e.substr(0, b.length) === b && 0 !== g && (g = 1);
- $(c).data("distance", g)
- });
- c.sort(function(c, e) {
- if ("" !== b) {
- var g = parseInt($(c).data("distance"), 10),
- m = parseInt($(e).data("distance"), 10);
- return g == m ? 0 : g > m ? 1 : -1
- }
- return _.unescape($(c).data(a.key)).toLowerCase() > _.unescape($(e).data(a.key)).toLowerCase() ? 1 : -1
- });
- c.detach().appendTo($(a.table).find("tbody"));
- a.search()
- });
- $(c).keypress(function(b) {
- 13 === b.which && (0 < $(this).val().length && 0 < $(a.table).find("tbody tr").length && "undefined" !== typeof a.action && a.action($($(a.table).find("tbody tr")[0])), b.preventDefault())
- });
- return c
- };
- return a
- }(Moobot || {});
- Moobot = function(a) {
- var d = !1;
- a.information = {
- send: function(a) {
- var b = "undefined" !== typeof a.append_type ? a.append_type : "appendTo",
- d = $(kite("#template-information", {
- type: a.type,
- body: ("undefined" !== typeof a.heading ? '<h4 class="alert-heading">' + a.heading + "</h4>" : "") + "<p>" + a.message + "</p>"
- }))[b]("undefined" === typeof a.container ? ".information-container" : a.container);
- d.hide();
- d.slideDown("slow", function() {
- if ("undefined" === typeof a.hide || a.hide) {
- $(d).addClass("alert-fade");
- var b = function() {
- return $('div[class*="alert-fade"]').length
- },
- h = function() {
- d.slideUp("slow", function() {
- d.remove()
- })
- },
- g = !1,
- m = !1,
- k = function() {
- Moobot.information.delay() ? setTimeout(k, 15E3 * (0 < b() ? b() : 1)) : (m || h(), g = !0)
- };
- setTimeout(k, 15E3 * (0 < b() ? b() : 1));
- d.mouseenter(function() {
- m = !0
- }).mouseleave(function() {
- m = !1;
- g && h()
- })
- }
- });
- "undefined" !== typeof a.silent && a.silent || (Moobot.modals.destroy(), ("undefined" === typeof a.scroll || a.scroll) && $("html, body").animate({
- scrollTop: $("body").offset().top
- }, 500))
- },
- warning: function(a, b) {
- Moobot.information.send({
- message: a,
- heading: b,
- hide: !1
- })
- },
- error: function(a, b) {
- Moobot.information.send({
- message: a,
- heading: b,
- type: "alert-error"
- })
- },
- success: function(a, b) {
- Moobot.information.send({
- message: a,
- heading: b,
- type: "alert-success"
- })
- },
- info: function(a, b) {
- Moobot.information.send({
- message: a,
- heading: b,
- type: "alert-info"
- })
- },
- delay: function(a) {
- "boolean" === typeof a && (d = a);
- return d
- }
- };
- return a
- }(Moobot || {});
- $.ajaxSetup({
- cache: !0
- });
- $.fn.typeahead.Constructor.prototype.lookup = function() {
- var a;
- this.query = this.$element.val() || "";
- return this.query.length < this.options.minLength ? this.shown ? this.hide() : this : (a = $.isFunction(this.source) ? this.source(this.query, $.proxy(this.process, this)) : this.source) ? this.process(a) : this
- };
- $.fn.typeahead.Constructor.prototype.highlighter = function(a) {
- var d = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
- return a.replace(new RegExp("(" + d + ")", "ig"), function(a, b) {
- return b
- })
- };
- $.fn.typeahead.Constructor.prototype.render = function(a) {
- var d = this;
- a = $(a).map(function(a, b) {
- a = $(d.options.item).attr("data-value", b);
- a.find("a").html(_.escape(d.highlighter(b)));
- return a[0]
- });
- a.first().addClass("active");
- this.$menu.html(a);
- return this
- };
- Moobot.event.subscribe("Api/error", function(a) {
- Moobot.information.error(a.message, "Oops!")
- });
- Moobot.event.subscribe("Api/error", function(a) {
- "Not authorized" === a.message && Moobot.user.logout()
- });
- Moobot = function(a) {
- a.dashboard.access = function() {
- return Moobot.user.username() === Moobot.dashboard.dashboard() || -1 !== $.inArray(Moobot.dashboard.dashboard(), Moobot.dashboard.list) || "undefined" !== typeof Moobot.dashboard.special && Moobot.dashboard.special
- };
- return a
- }(Moobot || {});
- Moobot = function(a) {
- a.dashboard.init = {
- any: function() {
- var a = Moobot.dashboard.access() ? "editor" : "guest",
- c = {
- templates: function(b) {
- $.get(Moobot.paths.templates + "dashboard." + a + ".php", function(a) {
- 0 < a.length ? ($("body").append(a), b(null)) : b("Fail")
- }).fail(function() {
- b("Fail")
- })
- },
- js: function(b) {
- $.getScript(Moobot.paths.js + "dashboard." + a + ".js", function() {
- b(null)
- }).fail(function() {
- b("Fail")
- })
- }
- };
- Moobot.dashboard.access() && (c.features_user = function(a) {
- Moobot.api.request("/user/features", {
- callback: function(c) {
- "undefined" !==
- typeof c.features && c.features instanceof Array ? a(null, c.features) : a("Fail")
- },
- error: function(c) {
- a("Fail", c)
- }
- })
- }, c.features_channel = function(a) {
- Moobot.api.request("/channel/features", {
- callback: function(c) {
- "undefined" !== typeof c.features && c.features instanceof Array ? a(null, c.features) : a("Fail")
- },
- params: {
- channel: Moobot.dashboard.dashboard()
- },
- error: function(c) {
- a("Fail", c)
- }
- })
- });
- async.parallel(c, function(b, c) {
- null === b && (Moobot.user.loggedin() ? (Moobot.dashboard.special && Moobot.information.info("Your user account has been detected as a special user, meaning you can access any dashboard by simply navigating to it",
- "Special user"), Moobot.widgets.add("widget-dashboard", {
- title: "Dashboard",
- icon: "icon-dashboard",
- type: "right",
- template: "template-widget"
- }, function(a) {
- Moobot.widgets.buttons.btntoggle(a)
- }, function(a, b) {
- Moobot.widgets.data(a, kite("#template-widget-dashboard", {}));
- if (Moobot.dashboard.special) $("." + a + " #inputWidgetDashboardNavigate").selectize({
- valueField: "name",
- labelField: "name",
- searchField: "name",
- options: [],
- create: !0,
- highlight: !1,
- loadThrottle: 100,
- addPrecedence: !0,
- render: {
- option: function(a, b) {
- return kite("#template-widget-dashboard-dropdown",
- $.extend(a, {
- img: "undefined" !== typeof a.logo && null !== a.logo ? a.logo.replace("300x300", "50x50") : Moobot.paths.img + "404_user_70x70.jpg",
- displayname: "undefined" !== typeof a.display_name ? a.display_name : Moobot.misc.sentenceCase(a.name)
- }))
- },
- option_create: function(a) {
- return '<div class="create">Navigate to <strong>' + _.escape(a.input) + "</strong>…</div>"
- }
- },
- load: function(a, b) {
- if (!a.length) return b();
- Twitch.api.request("/search/channels", {
- version: 3,
- callback: function(a) {
- b(a.channels)
- },
- error: function(a) {
- Twitch.api.error(a);
- b()
- },
- params: {
- q: a,
- limit: 10
- }
- })
- },
- create: function(a) {
- return {
- name: a
- }
- },
- onChange: function(a) {
- Moobot.user.valid(a) && ("undefined" !== typeof _gaq && _gaq.push(["_trackEvent", "Interaction", "DashboardNavigation"]), setTimeout(function() {
- window.location.href = "/" + encodeURIComponent(a.toLowerCase())
- }, 500))
- }
- });
- else {
- var c = 0,
- d = function(a) {
- c + 1E4 <= Date.now() ? (c = Date.now(), Moobot.api.request("/user/dashboards", {
- callback: function(b) {
- var c = [];
- $.each(b.dashboards, function(a, b) {
- b !== Moobot.dashboard.dashboard() && c.push({
- name: b
- })
- });
- Moobot.user.username() !== Moobot.dashboard.dashboard() && c.push({
- name: Moobot.user.username()
- });
- a(c)
- },
- error: function(b) {
- Moobot.api.error(b);
- a()
- }
- })) : a()
- };
- $("." + a + " #inputWidgetDashboardNavigate").selectize({
- loadThrottle: 100,
- valueField: "name",
- labelField: "name",
- searchField: "name",
- options: [],
- create: !1,
- highlight: !1,
- render: {
- option: function(a, b) {
- return kite("#template-widget-dashboard-dropdown", $.extend(a, {
- img: Moobot.paths.data + "/thumb/" + a.name,
- displayname: Moobot.misc.sentenceCase(a.name)
- }))
- }
- },
- load: function(a,
- b) {
- d(b)
- },
- onChange: function(a) {
- Moobot.user.valid(a) && ("undefined" !== typeof _gaq && _gaq.push(["_trackEvent", "Interaction", "DashboardNavigation"]), setTimeout(function() {
- window.location.href = "/" + encodeURIComponent(a.toLowerCase())
- }, 500))
- }
- });
- $("." + a + " #inputWidgetDashboardNavigate + .selectize-control .selectize-input input").blur(function() {
- c = 0;
- $("." + a + " #inputWidgetDashboardNavigate")[0].selectize.clearOptions()
- });
- $("." + a + " #inputWidgetDashboardNavigate + .selectize-control .selectize-input input").focus(function() {
- $("." +
- a + " #inputWidgetDashboardNavigate")[0].selectize.load(d)
- });
- 0 === Moobot.dashboard.list.length && $("." + a).addClass("hide")
- }
- b()
- })) : ($(".nav-login").click(function() {
- $.cookie("redirectusername", Moobot.dashboard.dashboard(), {
- expires: 1,
- path: "/"
- })
- }), $(".alert-connect .close").click(function(a) {
- $(this).parent(".alert").remove();
- a.preventDefault();
- return !1
- })), Moobot.resource.add({
- name: "chat-commands",
- type: "template",
- path: Moobot.paths.root + "commands"
- }), Moobot.modals.add("modal-chat-commands", {
- title: "Chat commands",
- template: "template-modal",
- hash: "commands"
- }, function(a) {
- $("#" + a + " .modal-body").addClass("modal-loading");
- var b = [];
- b.push(function(a) {
- var b = Moobot.resource.fetch({
- name: "chat-commands",
- type: "template",
- callback: function(c) {
- Moobot.modals.requests.remove(b);
- a(null)
- },
- error: function() {
- Moobot.modals.requests.remove(b);
- Moobot.information.error("Could not load chat command list", "Oops!");
- a("Fail")
- }
- });
- Moobot.modals.requests.add(b)
- });
- async.parallel(b, function(b) {
- $("#" + a + " .modal-body").removeClass("modal-loading");
- null !== b ? Moobot.modals.close(a) : ($("#" + a + " .modal-body").append(kite("#template-modal-commandlist", {})), $("#" + a + " .modal-body").append(kite("#template-chat-commands", {})), Moobot.event.trigger("Modal/loaded", a))
- })
- }), $(".nav-commands").click(function(a) {
- Moobot.modals.show("modal-chat-commands");
- a.preventDefault()
- }), Moobot.dashboard.init[a](), Moobot.dashboard.access() && $.map($.merge(c.features_user || [], c.features_channel || []), function(a) {
- Moobot.features.set(a)
- }))
- })
- }
- };
- return a
- }(Moobot || {});
- $(function() {
- $(".sticky-wrapper").addClass("page-loading");
- var a = {};
- Moobot.user.loggedin() && (a.dashboards = function(a) {
- Moobot.api.request("/user/dashboards", {
- callback: function(c) {
- c.dashboards instanceof Array ? (Moobot.dashboard.list = c.dashboards, Moobot.dashboard.special = c.special, a(null)) : a("Fail")
- },
- error: function(c) {
- a("Fail", c)
- }
- })
- });
- a.meta = function(a) {
- Moobot.api.request("/channel/meta", {
- callback: function(c) {
- Moobot.dashboard.meta = c;
- a(null)
- },
- params: {
- channel: Moobot.dashboard.dashboard()
- },
- error: function(c) {
- a("Fail",
- c)
- }
- })
- };
- $.isEmptyObject(a) ? Moobot.dashboard.init.any() : async.series(a, function(a, c) {
- $(".sticky-wrapper").removeClass("page-loading");
- null === a ? Moobot.dashboard.init.any() : "undefined" !== typeof c.dashboards && 0 === c.dashboards.status && "API" === c.dashboards.error ? Moobot.information.send({
- message: c.dashboards.message,
- heading: "Oops!",
- type: "alert-error",
- hide: !1
- }) : "undefined" !== typeof c.meta && "Could not find channel" === c.meta.message ? (Moobot.dashboard.special || (Moobot.information.send({
- message: "Are you <code>" +
- _.escape(Moobot.dashboard.dashboard()) + "</code>? Connect now to start using moobot.",
- heading: "Connect",
- type: "alert-info alert-connect",
- hide: !1
- }), $(".alert-connect").wrap("<a href=\"/r/login\" class=\"alert-link\" onClick=\"trackOutboundLink(this, {category: 'Login', action: 'Popup', label: 'New dashboard'}); return false;\" />"), $(".alert-connect .close").click(function(a) {
- $(this).parent(".alert").remove();
- a.preventDefault();
- return !1
- })), Moobot.user.loggedin() && Moobot.dashboard.special && (Moobot.information.send({
- message: "Since you're a special user, do you want to create the dashboard for <code>" +
- _.escape(Moobot.dashboard.dashboard()) + "</code>? Click this alert to start using this dashboard now.",
- heading: "Create",
- type: "alert-info alert-create",
- hide: !1
- }), $(".alert-create").wrap('<a href="#" class="alert-link" />'), $(".alert-create").click(function(a) {
- $.msgbox("Are you sure you want to create the dashboard for <code>" + _.escape(Moobot.dashboard.dashboard()) + "</code>?", {
- type: "confirm",
- buttons: [{
- type: "cancel",
- value: "Cancel"
- }, {
- type: "submit",
- value: "Create"
- }]
- }, function(a) {
- a && Moobot.api.request("/user/create", {
- callback: function(a) {
- null !== a && "undefined" !== typeof a.username && location.reload()
- },
- params: {
- channel: Moobot.dashboard.dashboard()
- }
- })
- });
- a.preventDefault()
- }), $(".alert-create .close").click(function(a) {
- $(this).parent(".alert").remove();
- a.preventDefault();
- return !1
- }))) : "undefined" !== typeof c.dashboards ? Moobot.api.error(c.dashboards) : "undefined" !== typeof c.meta ? Moobot.api.error(c.meta) : Moobot.information.send({
- message: "An unexpected error occured while trying to load the dashboard. Please contact support as soon as possible.",
- heading: "Error!",
- type: "alert-error",
- hide: !1
- })
- })
- });
- $(function() {
- Moobot.user.loggedin() ? ($(".nav-logout").removeClass("hide"), $(".nav-dashboard").removeClass("hide"), Moobot.dashboard.dashboard() === Moobot.user.username() && $(".nav-dashboard").addClass("active"), $(".nav-dashboard a").attr("href", "/" + Moobot.user.username()), $(".nav-logout").click(function() {
- Moobot.user.logout()
- })) : $(".nav-login").removeClass("hide");
- switch (window.location.pathname) {
- case "/":
- $(".nav-login").addClass("active");
- break;
- case "/r/about":
- $(".nav-about").addClass("active")
- }
- });
- Moobot.event.subscribe("User/logout", function() {
- window.location.replace("/.")
- });
- $(function() {
- $("input, textarea").placeholder();
- $(".nav-commands").removeClass("hide");
- $("a.dropdown-toggle, .dropdown-menu a").on("touchstart", function(a) {
- a.stopPropagation()
- })
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement