1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00
invoiceninja/public/js/bootstrap-combobox.min.js.map
2016-07-20 23:49:02 +03:00

1 line
16 KiB
Plaintext

{"version":3,"sources":["bootstrap-combobox.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","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/"}