2014-10-12 20:11:41 +02:00
|
|
|
/*!
|
2015-04-20 16:34:23 +02:00
|
|
|
* Bootstrap v3.3.1 (http://getbootstrap.com)
|
|
|
|
* Copyright 2011-2014 Twitter, Inc.
|
2014-10-12 20:11:41 +02:00
|
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
|
|
|
*/
|
2015-04-20 16:34:23 +02:00
|
|
|
if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");+function(a){var b=a.fn.jquery.split(" ")[0].split(".");if(b[0]<2&&b[1]<9||1==b[0]&&9==b[1]&&b[2]<1)throw new Error("Bootstrap's JavaScript requires jQuery version 1.9.1 or higher")}(jQuery),+function(a){"use strict";function b(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var c in b)if(void 0!==a.style[c])return{end:b[c]};return!1}a.fn.emulateTransitionEnd=function(b){var c=!1,d=this;a(this).one("bsTransitionEnd",function(){c=!0});var e=function(){c||a(d).trigger(a.support.transition.end)};return setTimeout(e,b),this},a(function(){a.support.transition=b(),a.support.transition&&(a.event.special.bsTransitionEnd={bindType:a.support.transition.end,delegateType:a.support.transition.end,handle:function(b){return a(b.target).is(this)?b.handleObj.handler.apply(this,arguments):void 0}})})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var c=a(this),e=c.data("bs.alert");e||c.data("bs.alert",e=new d(this)),"string"==typeof b&&e[b].call(c)})}var c='[data-dismiss="alert"]',d=function(b){a(b).on("click",c,this.close)};d.VERSION="3.3.1",d.TRANSITION_DURATION=150,d.prototype.close=function(b){function c(){g.detach().trigger("closed.bs.alert").remove()}var e=a(this),f=e.attr("data-target");f||(f=e.attr("href"),f=f&&f.replace(/.*(?=#[^\s]*$)/,""));var g=a(f);b&&b.preventDefault(),g.length||(g=e.closest(".alert")),g.trigger(b=a.Event("close.bs.alert")),b.isDefaultPrevented()||(g.removeClass("in"),a.support.transition&&g.hasClass("fade")?g.one("bsTransitionEnd",c).emulateTransitionEnd(d.TRANSITION_DURATION):c())};var e=a.fn.alert;a.fn.alert=b,a.fn.alert.Constructor=d,a.fn.alert.noConflict=function(){return a.fn.alert=e,this},a(document).on("click.bs.alert.data-api",c,d.prototype.close)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.button"),f="object"==typeof b&&b;e||d.data("bs.button",e=new c(this,f)),"toggle"==b?e.toggle():b&&e.setState(b)})}var c=function(b,d){this.$element=a(b),this.options=a.extend({},c.DEFAULTS,d),this.isLoading=!1};c.VERSION="3.3.1",c.DEFAULTS={loadingText:"loading..."},c.prototype.setState=function(b){var c="disabled",d=this.$element,e=d.is("input")?"val":"html",f=d.data();b+="Text",null==f.resetText&&d.data("resetText",d[e]()),setTimeout(a.proxy(function(){d[e](null==f[b]?this.options[b]:f[b]),"loadingText"==b?(this.isLoading=!0,d.addClass(c).attr(c,c)):this.isLoading&&(this.isLoading=!1,d.removeClass(c).removeAttr(c))},this),0)},c.prototype.toggle=function(){var a=!0,b=this.$element.closest('[data-toggle="buttons"]');if(b.length){var c=this.$element.find("input");"radio"==c.prop("type")&&(c.prop("checked")&&this.$element.hasClass("active")?a=!1:b.find(".active").removeClass("active")),a&&c.prop("checked",!this.$element.hasClass("active")).trigger("change")}else this.$element.attr("aria-pressed",!this.$element.hasClass("active"));a&&this.$element.toggleClass("active")};var d=a.fn.button;a.fn.button=b,a.fn.button.Constructor=c,a.fn.button.noConflict=function(){return a.fn.button=d,this},a(document).on("click.bs.button.data-api",'[data-toggle^="button"]',function(c){var d=a(c.target);d.hasClass("btn")||(d=d.closest(".btn")),b.call(d,"toggle"),c.preventDefault()}).on("focus.bs.button.data-api blur.bs.button.data-api",'[data-toggle^="button"]',function(b){a(b.target).closest(".btn").toggleClass("focus",/^focus(in)?$/.test(b.type))})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.carousel"),f=a.extend({},c.DEFAULTS,d.data(),"object"==typeof b&&b),g="string"==typeof b?b:f.slide;e||d.data("bs.carousel",e=new c(this,f)),"number"==typeof b?e.to(b):g?e[g]():f.interval&&e.pause().cycle()})}var c=function(b,c){this.$element=a(b),this.$indicators=this.$element.find(".carousel-indicators"),this.options=c,this.paused=this.sliding=this.interval=this.$active=
|
2015-04-28 22:13:52 +02:00
|
|
|
})}}},c.prototype.activate=function(b,d,e){function f(){g.removeClass("active").find("> .dropdown-menu > .active").removeClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!1),b.addClass("active").find('[data-toggle="tab"]').attr("aria-expanded",!0),h?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu")&&b.closest("li.dropdown").addClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!0),e&&e()}var g=d.find("> .active"),h=e&&a.support.transition&&(g.length&&g.hasClass("fade")||!!d.find("> .fade").length);g.length&&h?g.one("bsTransitionEnd",f).emulateTransitionEnd(c.TRANSITION_DURATION):f(),g.removeClass("in")};var d=a.fn.tab;a.fn.tab=b,a.fn.tab.Constructor=c,a.fn.tab.noConflict=function(){return a.fn.tab=d,this};var e=function(c){c.preventDefault(),b.call(a(this),"show")};a(document).on("click.bs.tab.data-api",'[data-toggle="tab"]',e).on("click.bs.tab.data-api",'[data-toggle="pill"]',e)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.affix"),f="object"==typeof b&&b;e||d.data("bs.affix",e=new c(this,f)),"string"==typeof b&&e[b]()})}var c=function(b,d){this.options=a.extend({},c.DEFAULTS,d),this.$target=a(this.options.target).on("scroll.bs.affix.data-api",a.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",a.proxy(this.checkPositionWithEventLoop,this)),this.$element=a(b),this.affixed=this.unpin=this.pinnedOffset=null,this.checkPosition()};c.VERSION="3.3.1",c.RESET="affix affix-top affix-bottom",c.DEFAULTS={offset:0,target:window},c.prototype.getState=function(a,b,c,d){var e=this.$target.scrollTop(),f=this.$element.offset(),g=this.$target.height();if(null!=c&&"top"==this.affixed)return c>e?"top":!1;if("bottom"==this.affixed)return null!=c?e+this.unpin<=f.top?!1:"bottom":a-d>=e+g?!1:"bottom";var h=null==this.affixed,i=h?e:f.top,j=h?g:b;return null!=c&&c>=i?"top":null!=d&&i+j>=a-d?"bottom":!1},c.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$element.removeClass(c.RESET).addClass("affix");var a=this.$target.scrollTop(),b=this.$element.offset();return this.pinnedOffset=b.top-a},c.prototype.checkPositionWithEventLoop=function(){setTimeout(a.proxy(this.checkPosition,this),1)},c.prototype.checkPosition=function(){if(this.$element.is(":visible")){var b=this.$element.height(),d=this.options.offset,e=d.top,f=d.bottom,g=a("body").height();"object"!=typeof d&&(f=e=d),"function"==typeof e&&(e=d.top(this.$element)),"function"==typeof f&&(f=d.bottom(this.$element));var h=this.getState(g,b,e,f);if(this.affixed!=h){null!=this.unpin&&this.$element.css("top","");var i="affix"+(h?"-"+h:""),j=a.Event(i+".bs.affix");if(this.$element.trigger(j),j.isDefaultPrevented())return;this.affixed=h,this.unpin="bottom"==h?this.getPinnedOffset():null,this.$element.removeClass(c.RESET).addClass(i).trigger(i.replace("affix","affixed")+".bs.affix")}"bottom"==h&&this.$element.offset({top:g-b-f})}};var d=a.fn.affix;a.fn.affix=b,a.fn.affix.Constructor=c,a.fn.affix.noConflict=function(){return a.fn.affix=d,this},a(window).on("load",function(){a('[data-spy="affix"]').each(function(){var c=a(this),d=c.data();d.offset=d.offset||{},null!=d.offsetBottom&&(d.offset.bottom=d.offsetBottom),null!=d.offsetTop&&(d.offset.top=d.offsetTop),b.call(c,d)})})}(jQuery);
|
|
|
|
/* =============================================================
|
2015-10-18 19:19:29 +02:00
|
|
|
* bootstrap-combobox.js v1.1.5
|
2015-04-28 22:13:52 +02:00
|
|
|
* =============================================================
|
|
|
|
* Copyright 2012 Daniel Farrell
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
* ============================================================ */
|
|
|
|
|
|
|
|
!function( $ ) {
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/* COMBOBOX PUBLIC CLASS DEFINITION
|
|
|
|
* ================================ */
|
|
|
|
|
|
|
|
var Combobox = function ( element, options ) {
|
|
|
|
this.options = $.extend({}, $.fn.combobox.defaults, options);
|
|
|
|
this.$source = $(element);
|
|
|
|
this.$container = this.setup();
|
|
|
|
this.$element = this.$container.find('input[type=text]');
|
|
|
|
this.$target = this.$container.find('input[type=hidden]');
|
|
|
|
this.$button = this.$container.find('.dropdown-toggle');
|
|
|
|
this.$menu = $(this.options.menu).appendTo('body');
|
|
|
|
this.matcher = this.options.matcher || this.matcher;
|
|
|
|
this.sorter = this.options.sorter || this.sorter;
|
|
|
|
this.highlighter = this.options.highlighter || this.highlighter;
|
|
|
|
this.shown = false;
|
|
|
|
this.selected = false;
|
|
|
|
this.refresh();
|
|
|
|
this.transferAttributes();
|
|
|
|
this.listen();
|
|
|
|
};
|
|
|
|
|
|
|
|
Combobox.prototype = {
|
|
|
|
|
|
|
|
constructor: Combobox
|
|
|
|
|
|
|
|
, setup: function () {
|
2015-10-18 19:19:29 +02:00
|
|
|
var combobox = $(this.options.template);
|
2015-04-28 22:13:52 +02:00
|
|
|
this.$source.before(combobox);
|
|
|
|
this.$source.hide();
|
|
|
|
return combobox;
|
|
|
|
}
|
|
|
|
|
|
|
|
, parse: function () {
|
|
|
|
var that = this
|
|
|
|
, map = {}
|
|
|
|
, source = []
|
|
|
|
, selected = false
|
|
|
|
, selectedValue = '';
|
|
|
|
this.$source.find('option').each(function() {
|
|
|
|
var option = $(this);
|
|
|
|
if (option.val() === '') {
|
|
|
|
that.options.placeholder = option.text();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
map[option.text()] = option.val();
|
|
|
|
source.push(option.text());
|
|
|
|
if (option.prop('selected')) {
|
|
|
|
selected = option.text();
|
|
|
|
selectedValue = option.val();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
this.map = map;
|
|
|
|
if (selected) {
|
|
|
|
this.$element.val(selected);
|
|
|
|
this.$target.val(selectedValue);
|
|
|
|
this.$container.addClass('combobox-selected');
|
|
|
|
this.selected = true;
|
|
|
|
}
|
|
|
|
return source;
|
|
|
|
}
|
|
|
|
|
|
|
|
, transferAttributes: function() {
|
2015-10-18 19:19:29 +02:00
|
|
|
this.options.placeholder = this.$source.attr('data-placeholder') || this.options.placeholder;
|
|
|
|
this.$element.attr('placeholder', this.options.placeholder);
|
|
|
|
this.$target.prop('name', this.$source.prop('name'));
|
|
|
|
this.$target.val(this.$source.val());
|
|
|
|
this.$source.removeAttr('name'); // Remove from source otherwise form will pass parameter twice.
|
|
|
|
this.$element.attr('required', this.$source.attr('required'));
|
|
|
|
this.$element.attr('rel', this.$source.attr('rel'));
|
|
|
|
this.$element.attr('title', this.$source.attr('title'));
|
|
|
|
this.$element.attr('class', this.$source.attr('class'));
|
|
|
|
this.$element.attr('tabindex', this.$source.attr('tabindex'));
|
|
|
|
this.$source.removeAttr('tabindex');
|
|
|
|
this.$source.removeAttr('required');
|
|
|
|
}
|
|
|
|
|
|
|
|
, setSelected: function() {
|
|
|
|
this.selected = true;
|
2015-04-28 22:13:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
, select: function () {
|
|
|
|
var val = this.$menu.find('.active').attr('data-value');
|
2015-10-18 19:19:29 +02:00
|
|
|
this.$element.val(this.updater(val));
|
|
|
|
this.$target.val(this.map[val]);
|
|
|
|
this.$source.val(this.map[val]);
|
|
|
|
this.$element.trigger('change');
|
|
|
|
this.$target.trigger('change');
|
|
|
|
this.$source.trigger('change');
|
2015-04-28 22:13:52 +02:00
|
|
|
this.$container.addClass('combobox-selected');
|
|
|
|
this.selected = true;
|
|
|
|
return this.hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
, updater: function (item) {
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
, show: function () {
|
|
|
|
var pos = $.extend({}, this.$element.position(), {
|
|
|
|
height: this.$element[0].offsetHeight
|
|
|
|
});
|
|
|
|
|
|
|
|
this.$menu
|
|
|
|
.insertAfter(this.$element)
|
|
|
|
.css({
|
|
|
|
top: pos.top + pos.height
|
|
|
|
, left: pos.left
|
|
|
|
})
|
|
|
|
.show();
|
|
|
|
|
|
|
|
this.shown = true;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
, hide: function () {
|
|
|
|
this.$menu.hide();
|
|
|
|
this.shown = false;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
, lookup: function (event) {
|
|
|
|
this.query = this.$element.val();
|
|
|
|
return this.process(this.source);
|
|
|
|
}
|
|
|
|
|
|
|
|
, process: function (items) {
|
|
|
|
var that = this;
|
|
|
|
|
|
|
|
items = $.grep(items, function (item) {
|
|
|
|
return that.matcher(item);
|
|
|
|
})
|
|
|
|
|
|
|
|
items = this.sorter(items);
|
|
|
|
|
|
|
|
if (!items.length) {
|
|
|
|
return this.shown ? this.hide() : this;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.render(items.slice(0, this.options.items)).show();
|
|
|
|
}
|
|
|
|
|
|
|
|
, matcher: function (item) {
|
|
|
|
return ~item.toLowerCase().indexOf(this.query.toLowerCase());
|
|
|
|
}
|
|
|
|
|
|
|
|
, sorter: function (items) {
|
|
|
|
var beginswith = []
|
|
|
|
, caseSensitive = []
|
|
|
|
, caseInsensitive = []
|
|
|
|
, item;
|
|
|
|
|
|
|
|
while (item = items.shift()) {
|
|
|
|
if (!item.toLowerCase().indexOf(this.query.toLowerCase())) {beginswith.push(item);}
|
|
|
|
else if (~item.indexOf(this.query)) {caseSensitive.push(item);}
|
|
|
|
else {caseInsensitive.push(item);}
|
|
|
|
}
|
|
|
|
|
|
|
|
return beginswith.concat(caseSensitive, caseInsensitive);
|
|
|
|
}
|
|
|
|
|
|
|
|
, highlighter: function (item) {
|
|
|
|
var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&');
|
|
|
|
return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
|
|
|
|
return '<strong>' + match + '</strong>';
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
, render: function (items) {
|
|
|
|
var that = this;
|
|
|
|
|
|
|
|
items = $(items).map(function (i, item) {
|
|
|
|
i = $(that.options.item).attr('data-value', item);
|
|
|
|
i.find('a').html(that.highlighter(item));
|
|
|
|
return i[0];
|
|
|
|
})
|
|
|
|
|
|
|
|
items.first().addClass('active');
|
|
|
|
this.$menu.html(items);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
, next: function (event) {
|
|
|
|
var active = this.$menu.find('.active').removeClass('active')
|
|
|
|
, next = active.next();
|
|
|
|
|
|
|
|
if (!next.length) {
|
|
|
|
next = $(this.$menu.find('li')[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
next.addClass('active');
|
|
|
|
}
|
|
|
|
|
|
|
|
, prev: function (event) {
|
|
|
|
var active = this.$menu.find('.active').removeClass('active')
|
|
|
|
, prev = active.prev();
|
|
|
|
|
|
|
|
if (!prev.length) {
|
|
|
|
prev = this.$menu.find('li').last();
|
|
|
|
}
|
|
|
|
|
|
|
|
prev.addClass('active');
|
|
|
|
}
|
|
|
|
|
|
|
|
, toggle: function () {
|
2015-10-18 19:19:29 +02:00
|
|
|
if (this.$container.hasClass('combobox-selected')) {
|
|
|
|
this.clearTarget();
|
|
|
|
this.triggerChange();
|
|
|
|
this.clearElement();
|
|
|
|
} else {
|
|
|
|
if (this.shown) {
|
|
|
|
this.hide();
|
2015-10-18 19:12:23 +02:00
|
|
|
} else {
|
2015-10-18 19:19:29 +02:00
|
|
|
this.clearElement();
|
|
|
|
this.lookup();
|
2015-04-28 22:13:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-18 19:19:29 +02:00
|
|
|
this.$element.trigger('change');
|
|
|
|
this.$target.trigger('change');
|
|
|
|
this.$source.trigger('change');
|
2015-10-18 19:12:23 +02:00
|
|
|
}
|
2015-10-18 19:19:29 +02:00
|
|
|
|
2015-04-28 22:13:52 +02:00
|
|
|
, clearElement: function () {
|
|
|
|
this.$element.val('').focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
, clearTarget: function () {
|
|
|
|
this.$source.val('');
|
|
|
|
this.$target.val('');
|
|
|
|
this.$container.removeClass('combobox-selected');
|
|
|
|
this.selected = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
, triggerChange: function () {
|
|
|
|
this.$source.trigger('change');
|
|
|
|
}
|
|
|
|
|
|
|
|
, refresh: function () {
|
|
|
|
this.source = this.parse();
|
|
|
|
this.options.items = this.source.length;
|
|
|
|
}
|
|
|
|
|
|
|
|
, listen: function () {
|
|
|
|
this.$element
|
|
|
|
.on('focus', $.proxy(this.focus, this))
|
|
|
|
.on('blur', $.proxy(this.blur, this))
|
|
|
|
.on('keypress', $.proxy(this.keypress, this))
|
|
|
|
.on('keyup', $.proxy(this.keyup, this));
|
|
|
|
|
|
|
|
if (this.eventSupported('keydown')) {
|
|
|
|
this.$element.on('keydown', $.proxy(this.keydown, this));
|
|
|
|
}
|
|
|
|
|
|
|
|
this.$menu
|
|
|
|
.on('click', $.proxy(this.click, this))
|
|
|
|
.on('mouseenter', 'li', $.proxy(this.mouseenter, this))
|
|
|
|
.on('mouseleave', 'li', $.proxy(this.mouseleave, this));
|
|
|
|
|
|
|
|
this.$button
|
|
|
|
.on('click', $.proxy(this.toggle, this));
|
|
|
|
}
|
|
|
|
|
|
|
|
, eventSupported: function(eventName) {
|
|
|
|
var isSupported = eventName in this.$element;
|
|
|
|
if (!isSupported) {
|
|
|
|
this.$element.setAttribute(eventName, 'return;');
|
|
|
|
isSupported = typeof this.$element[eventName] === 'function';
|
|
|
|
}
|
|
|
|
return isSupported;
|
|
|
|
}
|
|
|
|
|
|
|
|
, move: function (e) {
|
|
|
|
if (!this.shown) {return;}
|
|
|
|
|
|
|
|
switch(e.keyCode) {
|
|
|
|
case 9: // tab
|
|
|
|
case 13: // enter
|
|
|
|
case 27: // escape
|
|
|
|
e.preventDefault();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 38: // up arrow
|
|
|
|
e.preventDefault();
|
|
|
|
this.prev();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 40: // down arrow
|
|
|
|
e.preventDefault();
|
|
|
|
this.next();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
e.stopPropagation();
|
|
|
|
}
|
|
|
|
|
|
|
|
, keydown: function (e) {
|
|
|
|
this.suppressKeyPressRepeat = ~$.inArray(e.keyCode, [40,38,9,13,27]);
|
|
|
|
this.move(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
, keypress: function (e) {
|
|
|
|
if (this.suppressKeyPressRepeat) {return;}
|
|
|
|
this.move(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
, keyup: function (e) {
|
|
|
|
switch(e.keyCode) {
|
|
|
|
case 40: // down arrow
|
|
|
|
case 39: // right arrow
|
|
|
|
case 38: // up arrow
|
|
|
|
case 37: // left arrow
|
|
|
|
case 36: // home
|
|
|
|
case 35: // end
|
2015-10-18 19:19:29 +02:00
|
|
|
case 33: // page up
|
|
|
|
case 34: // page down
|
2015-04-28 22:13:52 +02:00
|
|
|
case 16: // shift
|
|
|
|
case 17: // ctrl
|
|
|
|
case 18: // alt
|
2015-10-18 19:19:29 +02:00
|
|
|
case 20: // cap lock
|
2015-04-28 22:13:52 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 9: // tab
|
|
|
|
case 13: // enter
|
|
|
|
if (!this.shown) {return;}
|
|
|
|
this.select();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 27: // escape
|
|
|
|
if (!this.shown) {return;}
|
|
|
|
this.hide();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
this.clearTarget();
|
|
|
|
this.lookup();
|
|
|
|
}
|
|
|
|
|
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
|
|
|
|
, focus: function (e) {
|
|
|
|
this.focused = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
, blur: function (e) {
|
|
|
|
var that = this;
|
|
|
|
this.focused = false;
|
|
|
|
var val = this.$element.val();
|
|
|
|
if (!this.selected && val !== '' ) {
|
|
|
|
this.$element.val('');
|
|
|
|
this.$source.val('').trigger('change');
|
|
|
|
this.$target.val('').trigger('change');
|
|
|
|
}
|
|
|
|
if (!this.mousedover && this.shown) {setTimeout(function () { that.hide(); }, 200);}
|
|
|
|
}
|
|
|
|
|
|
|
|
, click: function (e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
|
|
|
this.select();
|
|
|
|
this.$element.focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
, mouseenter: function (e) {
|
|
|
|
this.mousedover = true;
|
|
|
|
this.$menu.find('.active').removeClass('active');
|
|
|
|
$(e.currentTarget).addClass('active');
|
|
|
|
}
|
|
|
|
|
|
|
|
, mouseleave: function (e) {
|
|
|
|
this.mousedover = false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* COMBOBOX PLUGIN DEFINITION
|
|
|
|
* =========================== */
|
2015-10-18 19:19:29 +02:00
|
|
|
|
2015-04-28 22:13:52 +02:00
|
|
|
$.fn.combobox = function ( option ) {
|
|
|
|
return this.each(function () {
|
|
|
|
var $this = $(this)
|
|
|
|
, data = $this.data('combobox')
|
|
|
|
, options = typeof option == 'object' && option;
|
|
|
|
if(!data) {$this.data('combobox', (data = new Combobox(this, options)));}
|
|
|
|
if (typeof option == 'string') {data[option]();}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.combobox.defaults = {
|
2015-10-18 19:19:29 +02:00
|
|
|
template: '<div class="combobox-container"> <input type="hidden" /> <div class="input-group"> <input type="text" autocomplete="off" /> <span class="input-group-addon dropdown-toggle" data-dropdown="dropdown"> <span class="caret" /> <i class="fa fa-times"></i> </span> </div> </div> '
|
2015-04-28 22:13:52 +02:00
|
|
|
, menu: '<ul class="typeahead typeahead-long dropdown-menu"></ul>'
|
|
|
|
, item: '<li><a href="#"></a></li>'
|
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.combobox.Constructor = Combobox;
|
|
|
|
|
2015-10-18 19:19:29 +02:00
|
|
|
}( window.jQuery );
|