mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-09 20:52:56 +01:00
1 line
22 KiB
Plaintext
1 line
22 KiB
Plaintext
{"version":3,"sources":["bootstrap-combobox.js"],"names":["$","Combobox","element","options","this","extend","fn","combobox","defaults","template","$source","$container","setup","$element","find","$target","$button","$menu","menu","appendTo","matcher","sorter","highlighter","shown","selected","refresh","transferAttributes","listen","prototype","constructor","before","hide","disable","prop","attr","disabled","addClass","enable","removeClass","parse","that","map","source","selectedValue","each","option","val","placeholder","text","push","appendId","removeAttr","undefined","select","updater","trigger","item","show","pos","position","height","offsetHeight","insertAfter","css","top","left","on","proxy","scrollSafety","off","blur","lookup","event","query","process","items","grep","length","render","slice","bsVersion","toLowerCase","indexOf","beginswith","caseSensitive","caseInsensitive","shift","concat","replace","RegExp","$1","match","i","html","first","next","active","prev","last","toggle","hasClass","clearTarget","triggerChange","clearElement","e","target","tagName","focus","keypress","keyup","eventSupported","keydown","click","mouseenter","mouseleave","eventName","isSupported","setAttribute","move","keyCode","preventDefault","fixMenuScroll","stopPropagation","bottom","scrollTop","menuHeight","suppressKeyPressRepeat","inArray","focused","mousedover","setTimeout","currentTarget","$this","data","Constructor","window","jQuery"],"mappings":"CAkBA,SAAAA,GAEA,YAKA,IAAAC,GAAA,SAAAC,EAAAC,GACAC,KAAAD,QAAAH,EAAAK,UAAAL,EAAAM,GAAAC,SAAAC,SAAAL,GACAC,KAAAK,SAAAL,KAAAD,QAAAM,UAAAL,KAAAK,SACAL,KAAAM,QAAAV,EAAAE,GACAE,KAAAO,WAAAP,KAAAQ,QACAR,KAAAS,SAAAT,KAAAO,WAAAG,KAAA,oBACAV,KAAAW,QAAAX,KAAAO,WAAAG,KAAA,sBACAV,KAAAY,QAAAZ,KAAAO,WAAAG,KAAA,oBACAV,KAAAa,MAAAjB,EAAAI,KAAAD,QAAAe,MAAAC,SAAA,QACAf,KAAAgB,QAAAhB,KAAAD,QAAAiB,SAAAhB,KAAAgB,QACAhB,KAAAiB,O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UACAtC,EAAAwG,EAAA2B,eAAA/F,SAAA,WAGA8E,WAAA,SAAAV,GACApG,KAAA6H,YAAA,IAMAjI,EAAAM,GAAAC,SAAA,SAAAsC,GACA,MAAAzC,MAAAwC,KAAA,WACA,GAAAwF,GAAApI,EAAAI,MACAiI,EAAAD,EAAAC,KAAA,YACAlI,EAAA,gBAAA0C,IAAAA,CACAwF,IAAAD,EAAAC,KAAA,WAAAA,EAAA,GAAApI,GAAAG,KAAAD,IACA,gBAAA0C,IAAAwF,EAAAxF,QAIA7C,EAAAM,GAAAC,SAAAC,UACAwE,UAAA,IACA9D,KAAA,2DACAsC,KAAA,6BAGAxD,EAAAM,GAAAC,SAAA+H,YAAArI,GAEAsI,OAAAC","file":"bootstrap-combobox.min.js","sourcesContent":["/* =============================================================\n * bootstrap-combobox.js v1.1.7\n * =============================================================\n * Copyright 2012 Daniel Farrell\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n * ============================================================ */\n\n!function( $ ) {\n\n \"use strict\";\n\n /* COMBOBOX PUBLIC CLASS DEFINITION\n * ================================ */\n\n var Combobox = function ( element, options ) {\n this.options = $.extend({}, $.fn.combobox.defaults, options);\n this.template = this.options.template || this.template\n this.$source = $(element);\n this.$container = this.setup();\n this.$element = this.$container.find('input[type=text]');\n this.$target = this.$container.find('input[type=hidden]');\n this.$button = this.$container.find('.dropdown-toggle');\n this.$menu = $(this.options.menu).appendTo('body');\n this.matcher = this.options.matcher || this.matcher;\n this.sorter = this.options.sorter || this.sorter;\n this.highlighter = this.options.highlighter || this.highlighter;\n this.shown = false;\n this.selected = false;\n this.refresh();\n this.transferAttributes();\n this.listen();\n };\n\n Combobox.prototype = {\n\n constructor: Combobox\n\n , setup: function () {\n var combobox = $(this.template());\n this.$source.before(combobox);\n this.$source.hide();\n return combobox;\n }\n\n , disable: function() {\n this.$element.prop('disabled', true);\n this.$button.attr('disabled', true);\n this.disabled = true;\n this.$container.addClass('combobox-disabled');\n }\n\n , enable: function() {\n this.$element.prop('disabled', false);\n this.$button.attr('disabled', false);\n this.disabled = false;\n this.$container.removeClass('combobox-disabled');\n }\n , parse: function () {\n var that = this\n , map = {}\n , source = []\n , selected = false\n , selectedValue = '';\n this.$source.find('option').each(function() {\n var option = $(this);\n if (option.val() === '') {\n that.options.placeholder = option.text();\n return;\n }\n map[option.text()] = option.val();\n source.push(option.text());\n if (option.prop('selected')) {\n selected = option.text();\n selectedValue = option.val();\n }\n })\n this.map = map;\n if (selected) {\n this.$element.val(selected);\n this.$target.val(selectedValue);\n this.$container.addClass('combobox-selected');\n this.selected = true;\n }\n return source;\n }\n\n , transferAttributes: function() {\n this.options.placeholder = this.$source.attr('data-placeholder') || this.options.placeholder\n if(this.options.appendId !== \"undefined\") {\n \tthis.$element.attr('id', this.$source.attr('id') + this.options.appendId);\n }\n this.$element.attr('placeholder', this.options.placeholder)\n this.$target.prop('name', this.$source.prop('name'))\n this.$target.val(this.$source.val())\n this.$source.removeAttr('name') // Remove from source otherwise form will pass parameter twice.\n this.$element.attr('required', this.$source.attr('required'))\n this.$element.attr('rel', this.$source.attr('rel'))\n this.$element.attr('title', this.$source.attr('title'))\n this.$element.attr('class', this.$source.attr('class'))\n this.$element.attr('tabindex', this.$source.attr('tabindex'))\n this.$source.removeAttr('tabindex')\n if (this.$source.attr('disabled')!==undefined)\n this.disable();\n }\n\n , select: function () {\n var val = this.$menu.find('.active').attr('data-value');\n this.$element.val(this.updater(val)).trigger('change');\n this.$target.val(this.map[val]).trigger('change');\n this.$source.val(this.map[val]).trigger('change');\n this.$container.addClass('combobox-selected');\n this.selected = true;\n return this.hide();\n }\n\n , updater: function (item) {\n return item;\n }\n\n , show: function () {\n var pos = $.extend({}, this.$element.position(), {\n height: this.$element[0].offsetHeight\n });\n\n this.$menu\n .insertAfter(this.$element)\n .css({\n top: pos.top + pos.height\n , left: pos.left\n })\n .show();\n\n $('.dropdown-menu').on('mousedown', $.proxy(this.scrollSafety, this));\n\n this.shown = true;\n return this;\n }\n\n , hide: function () {\n this.$menu.hide();\n $('.dropdown-menu').off('mousedown', $.proxy(this.scrollSafety, this));\n this.$element.on('blur', $.proxy(this.blur, this));\n this.shown = false;\n return this;\n }\n\n , lookup: function (event) {\n this.query = this.$element.val();\n return this.process(this.source);\n }\n\n , process: function (items) {\n var that = this;\n\n items = $.grep(items, function (item) {\n return that.matcher(item);\n })\n\n items = this.sorter(items);\n\n if (!items.length) {\n return this.shown ? this.hide() : this;\n }\n\n return this.render(items.slice(0, this.options.items)).show();\n }\n\n , template: function() {\n if (this.options.bsVersion == '2') {\n return '<div class=\"combobox-container\"><input type=\"hidden\" /> <div class=\"input-append\"> <input type=\"text\" autocomplete=\"false\" /> <span class=\"add-on dropdown-toggle\" data-dropdown=\"dropdown\"> <span class=\"caret\"/> <i class=\"icon-remove\"/> </span> </div> </div>'\n } else {\n return '<div class=\"combobox-container\"> <input type=\"hidden\" /> <div class=\"input-group\"> <input type=\"text\" autocomplete=\"false\" /> <span class=\"input-group-addon dropdown-toggle\" data-dropdown=\"dropdown\"> <span class=\"caret\" /> <span class=\"glyphicon glyphicon-remove\" /> </span> </div> </div>'\n }\n }\n\n , matcher: function (item) {\n return ~item.toLowerCase().indexOf(this.query.toLowerCase());\n }\n\n , sorter: function (items) {\n var beginswith = []\n , caseSensitive = []\n , caseInsensitive = []\n , item;\n\n while (item = items.shift()) {\n if (!item.toLowerCase().indexOf(this.query.toLowerCase())) {beginswith.push(item);}\n else if (~item.indexOf(this.query)) {caseSensitive.push(item);}\n else {caseInsensitive.push(item);}\n }\n\n return beginswith.concat(caseSensitive, caseInsensitive);\n }\n\n , highlighter: function (item) {\n var query = this.query.replace(/[\\-\\[\\]{}()*+?.,\\\\\\^$|#\\s]/g, '\\\\$&');\n return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {\n return '<strong>' + match + '</strong>';\n })\n }\n\n , render: function (items) {\n var that = this;\n\n items = $(items).map(function (i, item) {\n i = $(that.options.item).attr('data-value', item);\n i.find('a').html(that.highlighter(item));\n return i[0];\n })\n\n items.first().addClass('active');\n this.$menu.html(items);\n return this;\n }\n\n , next: function (event) {\n var active = this.$menu.find('.active').removeClass('active')\n , next = active.next();\n\n if (!next.length) {\n next = $(this.$menu.find('li')[0]);\n }\n\n next.addClass('active');\n }\n\n , prev: function (event) {\n var active = this.$menu.find('.active').removeClass('active')\n , prev = active.prev();\n\n if (!prev.length) {\n prev = this.$menu.find('li').last();\n }\n\n prev.addClass('active');\n }\n\n , toggle: function () {\n if (!this.disabled) {\n if (this.$container.hasClass('combobox-selected')) {\n this.clearTarget();\n this.triggerChange();\n this.clearElement();\n } else {\n if (this.shown) {\n this.hide();\n } else {\n this.clearElement();\n this.lookup();\n }\n }\n }\n }\n\n , scrollSafety: function(e) {\n if (e.target.tagName == 'UL') {\n this.$element.off('blur');\n }\n }\n , clearElement: function () {\n this.$element.val('').focus();\n }\n\n , clearTarget: function () {\n this.$source.val('');\n this.$target.val('');\n this.$container.removeClass('combobox-selected');\n this.selected = false;\n }\n\n , triggerChange: function () {\n this.$source.trigger('change');\n }\n\n , refresh: function () {\n this.source = this.parse();\n this.options.items = this.source.length;\n }\n\n , listen: function () {\n this.$element\n .on('focus', $.proxy(this.focus, this))\n .on('blur', $.proxy(this.blur, this))\n .on('keypress', $.proxy(this.keypress, this))\n .on('keyup', $.proxy(this.keyup, this));\n\n if (this.eventSupported('keydown')) {\n this.$element.on('keydown', $.proxy(this.keydown, this));\n }\n\n this.$menu\n .on('click', $.proxy(this.click, this))\n .on('mouseenter', 'li', $.proxy(this.mouseenter, this))\n .on('mouseleave', 'li', $.proxy(this.mouseleave, this));\n\n this.$button\n .on('click', $.proxy(this.toggle, this));\n }\n\n , eventSupported: function(eventName) {\n var isSupported = eventName in this.$element;\n if (!isSupported) {\n this.$element.setAttribute(eventName, 'return;');\n isSupported = typeof this.$element[eventName] === 'function';\n }\n return isSupported;\n }\n\n , move: function (e) {\n if (!this.shown) {return;}\n\n switch(e.keyCode) {\n case 9: // tab\n case 13: // enter\n case 27: // escape\n e.preventDefault();\n break;\n\n case 38: // up arrow\n e.preventDefault();\n this.prev();\n this.fixMenuScroll();\n break;\n\n case 40: // down arrow\n e.preventDefault();\n this.next();\n this.fixMenuScroll();\n break;\n }\n\n e.stopPropagation();\n }\n\n , fixMenuScroll: function(){\n var active = this.$menu.find('.active');\n if(active.length){\n var top = active.position().top;\n var bottom = top + active.height();\n var scrollTop = this.$menu.scrollTop();\n var menuHeight = this.$menu.height();\n if(bottom > menuHeight){\n this.$menu.scrollTop(scrollTop + bottom - menuHeight);\n } else if(top < 0){\n this.$menu.scrollTop(scrollTop + top);\n }\n }\n }\n\n , keydown: function (e) {\n this.suppressKeyPressRepeat = ~$.inArray(e.keyCode, [40,38,9,13,27]);\n this.move(e);\n }\n\n , keypress: function (e) {\n if (this.suppressKeyPressRepeat) {return;}\n this.move(e);\n }\n\n , keyup: function (e) {\n switch(e.keyCode) {\n case 40: // down arrow\n if (!this.shown){\n this.toggle();\n }\n break;\n case 39: // right arrow\n case 38: // up arrow\n case 37: // left arrow\n case 36: // home\n case 35: // end\n case 16: // shift\n case 17: // ctrl\n case 18: // alt\n break;\n\n case 9: // tab\n case 13: // enter\n if (!this.shown) {return;}\n this.select();\n break;\n\n case 27: // escape\n if (!this.shown) {return;}\n this.hide();\n break;\n\n default:\n this.clearTarget();\n this.lookup();\n }\n\n e.stopPropagation();\n e.preventDefault();\n }\n\n , focus: function (e) {\n this.focused = true;\n }\n\n , blur: function (e) {\n var that = this;\n this.focused = false;\n var val = this.$element.val();\n if (!this.selected && val !== '' ) {\n this.$element.val('');\n this.$source.val('').trigger('change');\n this.$target.val('').trigger('change');\n }\n if (!this.mousedover && this.shown) {setTimeout(function () { that.hide(); }, 200);}\n }\n\n , click: function (e) {\n e.stopPropagation();\n e.preventDefault();\n this.select();\n this.$element.focus();\n }\n\n , mouseenter: function (e) {\n this.mousedover = true;\n this.$menu.find('.active').removeClass('active');\n $(e.currentTarget).addClass('active');\n }\n\n , mouseleave: function (e) {\n this.mousedover = false;\n }\n };\n\n /* COMBOBOX PLUGIN DEFINITION\n * =========================== */\n $.fn.combobox = function ( option ) {\n return this.each(function () {\n var $this = $(this)\n , data = $this.data('combobox')\n , options = typeof option == 'object' && option;\n if(!data) {$this.data('combobox', (data = new Combobox(this, options)));}\n if (typeof option == 'string') {data[option]();}\n });\n };\n\n $.fn.combobox.defaults = {\n bsVersion: '3'\n , menu: '<ul class=\"typeahead typeahead-long dropdown-menu\"></ul>'\n , item: '<li><a href=\"#\"></a></li>'\n };\n\n $.fn.combobox.Constructor = Combobox;\n\n}( window.jQuery );\n"],"sourceRoot":"/source/"} |