mirror of
https://github.com/tim-krehan/shopping-list.git
synced 2024-11-24 06:40:01 +01:00
1 line
33 KiB
JavaScript
1 line
33 KiB
JavaScript
|
!function(n){var i={};function s(e){if(i[e])return i[e].exports;var t=i[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,s),t.l=!0,t.exports}s.m=n,s.c=i,s.d=function(e,t,n){s.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.t=function(t,e){if(1&e&&(t=s(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(s.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)s.d(n,i,function(e){return t[e]}.bind(null,i));return n},s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,"a",t),t},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.p="",s(s.s="./src/main.ts")}({"./src/dropdown.ts":function(module,__webpack_exports__,__webpack_require__){"use strict";eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"Dropdown\", function() { return Dropdown; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"DropdownV4\", function() { return DropdownV4; });\n/*\n *\tDropdown class. Manages the dropdown drawing\n */\nvar Dropdown = /** @class */ (function () {\n function Dropdown(e, formatItemCbk, autoSelect, noResultsText) {\n this.initialized = false;\n this.shown = false;\n this.items = [];\n this._$el = e;\n this.formatItem = formatItemCbk;\n this.autoSelect = autoSelect;\n this.noResultsText = noResultsText;\n // initialize it in lazy mode to deal with glitches like modals\n // this.init();\n }\n Dropdown.prototype.init = function () {\n var _this = this;\n // Initialize dropdown\n var pos = $.extend({}, this._$el.position(), {\n height: this._$el[0].offsetHeight\n });\n // create element\n this._dd = $('<ul />');\n // add our class and basic dropdown-menu class\n this._dd.addClass('bootstrap-autocomplete dropdown-menu');\n this._dd.insertAfter(this._$el);\n this._dd.css({ top: pos.top + this._$el.outerHeight(), left: pos.left, width: this._$el.outerWidth() });\n // click event on items\n this._dd.on('click', 'li', function (evt) {\n // console.log('clicked', evt.currentTarget);\n //console.log($(evt.currentTarget));\n var item = $(evt.currentTarget).data('item');\n _this.itemSelectedLaunchEvent(item);\n });\n this._dd.on('keyup', function (evt) {\n if (_this.shown) {\n switch (evt.which) {\n case 27:\n // ESC\n _this.hide();\n _this._$el.focus();\n break;\n }\n return false;\n }\n });\n this._dd.on('mouseenter', 'li', function (evt) {\n if (_this.haveResults) {\n $(evt.currentTarget).closest('ul').find('li.active').removeClass('active');\n $(evt.currentTarget).addClass('active');\n _this.mouseover = true;\n }\n });\n this._dd.on('mouseleave', 'li', function (evt) {\n _this.mouseover = false;\n });\n this.initialized = true;\n };\n Dropdown.prototype.checkInitialized = function () {\n // Lazy init\n if (!this.initialized) {\n // if not already initialized\n this.init();\n }\n };\n Object.defineProperty(Dropdown.prototype, \"isMouseOver\", {\n get: function () {\n return this.mouseover;\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(Dropdown.prototype, \"haveResults\", {\n get: function () {\n return (this.items.length > 0
|