vendor: 4,399 bytes, lines 1-103
1/******/ (function(modules) { // webpackBootstrap 2/******/ // The module cache 3/******/ var installedModules = {}; 4/******/ 5/******/ // The require function 6/******/ function __webpack_require__(moduleId) { 7/******/ 8/******/ // Check if module is in cache 9/******/ if(installedModules[moduleId]) { 10/******/ return installedModules[moduleId].exports; 11/******/ } 12/******/ // Create a new module (and put it into the cache) 13/******/ var module = installedModules[moduleId] = { 14/******/ i: moduleId, 15/******/ l: false, 16/******/ exports: {} 17/******/ }; 18/******/ 19/******/ // Execute the module function 20/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 21/******/ 22/******/ // Flag the module as loaded 23/******/ module.l = true; 24/******/ 25/******/ // Return the exports of the module 26/******/ return module.exports; 27/******/ } 28/******/ 29/******/ 30/******/ // expose the modules object (__webpack_modules__) 31/******/ __webpack_require__.m = modules; 32/******/ 33/******/ // expose the module cache 34/******/ __webpack_require__.c = installedModules; 35/******/ 36/******/ // define getter function for harmony exports 37/******/ __webpack_require__.d = function(exports, name, getter) { 38/******/ if(!__webpack_require__.o(exports, name)) { 39/******/ Object.defineProperty(exports, name, { 40/******/ configurable: false, 41/******/ enumerable: true, 42/******/ get: getter 43/******/ }); 44/******/ } 45/******/ }; 46/******/ 47/******/ // getDefaultExport function for compatibility with non-harmony modules 48/******/ __webpack_require__.n = function(module) { 49/******/ var getter = module && module.__esModule ? 50/******/ function getDefault() { return module['default']; } : 51/******/ function getModuleExports() { return module; }; 52/******/ __webpack_require__.d(getter, 'a', getter); 53/******/ return getter; 54/******/ }; 55/******/ 56/******/ // Object.prototype.hasOwnProperty.call 57/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 58/******/ 59/******/ // __webpack_public_path__ 60/******/ __webpack_require__.p = ""; 61/******/ 62/******/ // Load entry module and return exports 63/******/ return __webpack_require__(__webpack_require__.s = 0); 64/******/ }) 65/************************************************************************/ 66/******/ ([ 67/* 0 */ 68/***/ (function(module, __webpack_exports__, __webpack_require__) { 69 70"use strict"; 71Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); 72/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__resolvers__ = __webpack_require__(1); 73/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__dropdown__ = __webpack_require__(2); 74/* ============================================================= 75 * bootstrap-autocomplete.js v2.0.0 76 * https://github.com/xcash/bootstrap-autocomplete 77 * ============================================================= 78 * Forked from bootstrap3-typeahead.js v3.1.0 79 * https://github.com/bassjobsen/Bootstrap-3-Typeahead 80 * ============================================================= 81 * Original written by @mdo and @fat 82 * ============================================================= 83 * Copyright 2018 Paolo Casciello @xcash666 and contributors 84 * 85 * Licensed under the MIT License (the 'License'); 86 * you may not use this file except in compliance with the License. 87 * 88 * Unless required by applicable law or agreed to in writing, software 89 * distributed under the License is distributed on an 'AS IS' BASIS, 90 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 91 * See the License for the specific language governing permissions and 92 * limitations under the License. 93 * ============================================================ */ 94 95 96var AutoCompleteNS; 97(function (AutoCompleteNS) { 98 var AutoComplete = /** @class */ (function () { 99 function AutoComplete(element, options) { 100 this._selectedItem = null; 101 this._defaultValue = null; 102 this._defaultText = null; 103 this._isSelectElement = false;
104 this._settings = { 105 resolver: 'ajax', 106 resolverSettings: {}, 107 minLength: 3, 108 valueKey: 'value', 109 formatResult: this.defaultFormatResult, 110 autoSelect: true, 111 noResultsText: 'No results', 112 events: { 113 typed: null, 114 searchPre: null, 115 search: null, 116 searchPost: null, 117 select: null, 118 focus: null, 119 } 120 }; 121 this._el = element; 122 this._$el = $(this._el); 123 // element type 124 if (this._$el.is('select')) { 125 this._isSelectElement = true; 126 } 127 // inline data attributes 128 this.manageInlineDataAttributes(); 129 // constructor options 130 if (typeof options === 'object') { 131 this._settings = $.extend(true, {}, this.getSettings(), options); 132 } 133 if (this._isSelectElement) { 134 this.convertSelectToText(); 135 } 136 // console.log('initializing', this._settings); 137 this.init(); 138 } 139 AutoComplete.prototype.manageInlineDataAttributes = function () { 140 // updates settings with data-* attributes 141 var s = this.getSettings(); 142 if (this._$el.data('url')) { 143 s['resolverSettings'].url = this._$el.data('url'); 144 } 145 if (this._$el.data('default-value')) { 146 this._defaultValue = this._$el.data('default-value'); 147 } 148 if (this._$el.data('default-text')) { 149 this._defaultText = this._$el.data('default-text'); 150 } 151 if (this._$el.data('noresults-text')) { 152 s['noResultsText'] = this._$el.data('noresults-text'); 153 } 154 }; 155 AutoComplete.prototype.getSettings = function () { 156 return this._settings; 157 }; 158 AutoComplete.prototype.getBootstrapVersion = function () { 159 var version_string = $.fn.button.Constructor.VERSION; 160 var version_array = version_string.split('.'); 161 return version_array; 162 }; 163 AutoComplete.prototype.convertSelectToText = function () { 164 // create hidden field 165 var hidField = $('<input>'); 166 hidField.attr('type', 'hidden'); 167 hidField.attr('name', this._$el.attr('name')); 168 if (this._defaultValue) { 169 hidField.val(this._defaultValue); 170 } 171 this._selectHiddenField = hidField; 172 hidField.insertAfter(this._$el); 173 // create search input element 174 var searchField = $('<input>'); 175 // copy all attributes 176 searchField.attr('type', 'text'); 177 searchField.attr('name', this._$el.attr('name') + '_text'); 178 searchField.attr('id', this._$el.attr('id')); 179 searchField.attr('disabled', this._$el.attr('disabled')); 180 searchField.attr('placeholder', this._$el.attr('placeholder')); 181 searchField.attr('autocomplete', 'off'); 182 searchField.addClass(this._$el.attr('class')); 183 if (this._defaultText) { 184 searchField.val(this._defaultText); 185 } 186 // attach class 187 searchField.data(AutoCompleteNS.AutoComplete.NAME, this); 188 // replace original with searchField 189 this._$el.replaceWith(searchField); 190 this._$el = searchField; 191 this._el = searchField.get(0); 192 }; 193 AutoComplete.prototype.init = function () { 194 // bind default events 195 this.bindDefaultEventListeners(); 196 // RESOLVER 197 if (this._settings.resolver === 'ajax') { 198 // configure default resolver 199 this.resolver = new __WEBPACK_IMPORTED_MODULE_0__resolvers__["a" /* AjaxResolver */](this._settings.resolverSettings); 200 } 201 // Dropdown 202 if (this.getBootstrapVersion()[0] == 4) { 203 // v4 204 this._dd = new __WEBPACK_IMPORTED_MODULE_1__dropdown__["b" /* DropdownV4 */](this._$el, this._settings.formatResult, this._settings.autoSelect, this._settings.noResultsText); 205 } 206 else { 207 this._dd = new __WEBPACK_IMPORTED_MODULE_1__dropdown__["a" /* Dropdown */](this._$el, this._settings.formatResult, this._settings.autoSelect, this._settings.noResultsText); 208 } 209 }; 210 AutoComplete.prototype.bindDefaultEventListeners = function () { 211 var _this = this; 212 this._$el.on('keydown', function (evt) { 213 switch (evt.which) { 214 case 40: 215 // arrow DOWN 216 evt.stopPropagation(); 217 evt.preventDefault(); 218 break; 219 case 38: // up arrow 220 evt.stopPropagation(); 221 evt.preventDefault(); 222 break; 223 case 9: // TAB 224 if (_this._settings.autoSelect) { 225 // if autoSelect enabled selects on blur the currently selected item 226 _this._dd.selectFocusItem(); 227 } 228 break; 229 } 230 }); 231 this._$el.on('focus keyup', function (evt) { 232 // check key 233 switch (evt.which) { 234 case 16: // shift 235 case 17: // ctrl 236 case 18: // alt 237 case 39: // right 238 case 37: // left 239 break; 240 case 40: 241 // arrow DOWN 242 _this._dd.focusNextItem(); 243 break; 244 case 38: // up arrow 245 _this._dd.focusPreviousItem(); 246 break; 247 case 13: // ENTER 248 _this._dd.selectFocusItem(); 249 evt.stopPropagation(); 250 evt.preventDefault(); 251 break; 252 case 27: 253 // ESC 254 _this._dd.hide(); 255 break; 256 default: 257 var newValue = _this._$el.val(); 258 _this.handlerTyped(newValue); 259 } 260 }); 261 this._$el.on('blur', function (evt) { 262 // console.log(evt); 263 if (!_this._dd.isMouseOver) { 264 if (_this._isSelectElement) { 265 // if it's a select element you must 266 if (_this._dd.isItemFocused) { 267 _this._dd.selectFocusItem(); 268 } 269 else if ((_this._selectedItem !== null) && (_this._$el.val() !== '')) { 270 // reselect it 271 _this._$el.trigger('autocomplete.select', _this._selectedItem); 272 } 273 else if ((_this._$el.val() !== '') && (_this._defaultValue !== null)) { 274 // select Default 275 _this._$el.val(_this._defaultText); 276 _this._selectHiddenField.val(_this._defaultValue); 277 _this._selectedItem = null; 278 } 279 else { 280 // empty the values 281 _this._$el.val(''); 282 _this._selectHiddenField.val(''); 283 _this._selectedItem = null; 284 } 285 } 286 else { 287 // It's a text element, we accept custom value. 288 // Developers may subscribe to `autocomplete.freevalue` to get notified of this 289 if ((_this._selectedItem === null) && (_this._$el.val() !== '')) { 290 _this._$el.trigger('autocomplete.freevalue', _this._$el.val()); 291 } 292 } 293 _this._dd.hide(); 294 } 295 }); 296 // selected event 297 this._$el.on('autocomplete.select', function (evt, item) { 298 _this._selectedItem = item; 299 _this.itemSelectedDefaultHandler(item); 300 }); 301 }; 302 AutoComplete.prototype.handlerTyped = function (newValue) { 303 // field value changed 304 // custom handler may change newValue 305 if (this._settings.events.typed !== null) { 306 newValue = this._settings.events.typed(newValue); 307 if (!newValue) 308 return; 309 } 310 // if value >= minLength, start autocomplete 311 if (newValue.length >= this._settings.minLength) { 312 this._searchText = newValue; 313 this.handlerPreSearch(); 314 } 315 else { 316 this._dd.hide(); 317 } 318 }; 319 AutoComplete.prototype.handlerPreSearch = function () { 320 // do nothing, start search 321 // custom handler may change newValue 322 if (this._settings.events.searchPre !== null) { 323 var newValue = this._settings.events.searchPre(this._searchText); 324 if (!newValue) 325 return; 326 this._searchText = newValue; 327 } 328 this.handlerDoSearch(); 329 }; 330 AutoComplete.prototype.handlerDoSearch = function () { 331 var _this = this; 332 // custom handler may change newValue 333 if (this._settings.events.search !== null) { 334 this._settings.events.search(this._searchText, function (results) { 335 _this.postSearchCallback(results); 336 }); 337 } 338 else { 339 // Default behaviour 340 // search using current resolver 341 if (this.resolver) { 342 this.resolver.search(this._searchText, function (results) { 343 _this.postSearchCallback(results); 344 }); 345 } 346 } 347 }; 348 AutoComplete.prototype.postSearchCallback = function (results) { 349 // console.log('callback called', results); 350 // custom handler may change newValue 351 if (this._settings.events.searchPost) { 352 results = this._settings.events.searchPost(results); 353 if ((typeof results === 'boolean') && !results) 354 return; 355 } 356 this.handlerStartShow(results); 357 }; 358 AutoComplete.prototype.handlerStartShow = function (results) { 359 // console.log("defaultEventStartShow", results); 360 // for every result, draw it 361 this._dd.updateItems(results, this._searchText); 362 this._dd.show(); 363 }; 364 AutoComplete.prototype.itemSelectedDefaultHandler = function (item) { 365 // console.log('itemSelectedDefaultHandler', item); 366 // default behaviour is set elment's .val() 367 var itemFormatted = this._settings.formatResult(item); 368 if (typeof itemFormatted === 'string') { 369 itemFormatted = { text: itemFormatted }; 370 } 371 this._$el.val(itemFormatted.text); 372 // if the element is a select 373 if (this._isSelectElement) { 374 this._selectHiddenField.val(itemFormatted.value); 375 } 376 // save selected item 377 this._selectedItem = item; 378 // and hide 379 this._dd.hide(); 380 }; 381 AutoComplete.prototype.defaultFormatResult = function (item) { 382 if (typeof item === 'string') { 383 return { text: item }; 384 } 385 else if (item.text) { 386 return item; 387 } 388 else { 389 // return a toString of the item as last resort 390 // console.error('No default formatter for item', item); 391 return { text: item.toString() }; 392 } 393 }; 394 AutoComplete.prototype.manageAPI = function (APICmd, params) { 395 // manages public API 396 if (APICmd === 'set') { 397 398 this.itemSelectedDefaultHandler(params); 399 400 } else if (APICmd === 'reinitInline') { 401 402 this.manageInlineDataAttributes(); 403 404 if (typeof options === 'object') { 405 this._settings = $.extend(true, {}
405, this.getSettings(), options); 406 } 407 408 this.init(); 409 } 410 }; 411 AutoComplete.NAME = 'autoComplete'; 412 return AutoComplete; 413 }()); 414 AutoCompleteNS.AutoComplete = AutoComplete; 415})(AutoCompleteNS || (AutoCompleteNS = {})); 416(function ($, window, document) { 417 $.fn[AutoCompleteNS.AutoComplete.NAME] = function (optionsOrAPI, optionalParams) { 418 return this.each(function () { 419 var pluginClass; 420 pluginClass = $(this).data(AutoCompleteNS.AutoComplete.NAME); 421 if (!pluginClass) { 422 pluginClass = new AutoCompleteNS.AutoComplete(this, optionsOrAPI); 423 $(this).data(AutoCompleteNS.AutoComplete.NAME, pluginClass); 424 } 425 pluginClass.manageAPI(optionsOrAPI, optionalParams); 426 }); 427 }; 428})(jQuery, window, document); 429 430 431/***/ }), 432/* 1 */ 433/***/ (function(module, __webpack_exports__, __webpack_require__) { 434 435"use strict"; 436/* unused harmony export BaseResolver */ 437/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return AjaxResolver; }); 438var __extends = (this && this.__extends) || (function () { 439 var extendStatics = Object.setPrototypeOf || 440 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 441 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 442 return function (d, b) { 443 extendStatics(d, b); 444 function __() { this.constructor = d; } 445 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 446 }; 447})(); 448var BaseResolver = /** @class */ (function () { 449 function BaseResolver(options) { 450 this._settings = $.extend(true, {}, this.getDefaults(), options); 451 } 452 BaseResolver.prototype.getDefaults = function () { 453 return {}; 454 }; 455 BaseResolver.prototype.getResults = function (limit, start, end) { 456 return this.results; 457 }; 458 BaseResolver.prototype.search = function (q, cbk) { 459 cbk(this.getResults()); 460 }; 461 return BaseResolver; 462}()); 463 464var AjaxResolver = /** @class */ (function (_super) { 465 __extends(AjaxResolver, _super); 466 function AjaxResolver(options) { 467 return _super.call(this, options) || this; 468 // console.log('resolver settings', this._settings); 469 } 470 AjaxResolver.prototype.getDefaults = function () { 471 return { 472 url: '', 473 method: 'get', 474 queryKey: 'q', 475 extraData: {}, 476 timeout: undefined, 477 }; 478 }; 479 AjaxResolver.prototype.search = function (q, cbk) { 480 var _this = this; 481 if (this.jqXHR != null) { 482 this.jqXHR.abort(); 483 } 484 var data = {}; 485 data[this._settings.queryKey] = q; 486 $.extend(data, this._settings.extraData); 487 this.jqXHR = $.ajax(this._settings.url, { 488 method: this._settings.method, 489 data: data, 490 timeout: this._settings.timeout 491 }); 492 this.jqXHR.done(function (result) { 493 cbk(result); 494 }); 495 this.jqXHR.fail(function (err) { 496 // console.log(err); 497 }); 498 this.jqXHR.always(function () { 499 _this.jqXHR = null; 500 }); 501 }; 502 return AjaxResolver; 503}(BaseResolver)); 504 505 506 507/***/ }), 508/* 2 */ 509/***/ (function(module, __webpack_exports__, __webpack_require__) { 510 511"use strict"; 512/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Dropdown; }); 513/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return DropdownV4; }); 514/* 515 * Dropdown class. Manages the dropdown drawing 516 */ 517var Dropdown = /** @class */ (function () { 518 function Dropdown(e, formatItemCbk, autoSelect, noResultsText) { 519 this.initialized = false; 520 this.shown = false; 521 this.items = []; 522 this._$el = e; 523 this.formatItem = formatItemCbk; 524 this.autoSelect = autoSelect; 525 this.noResultsText = noResultsText; 526 // initialize it in lazy mode to deal with glitches like modals 527 // this.init(); 528 } 529 Dropdown.prototype.init = function () { 530 var _this = this; 531 // Initialize dropdown 532 var pos = $.extend({}, this._$el.position(), { 533 height: this._$el[0].offsetHeight 534 }); 535 // create element 536 this._dd = $('<ul />'); 537 // add our class and basic dropdown-menu class 538 this._dd.addClass('bootstrap-autocomplete dropdown-menu'); 539 this._dd.insertAfter(this._$el); 540 this._dd.css({ top: pos.top + this._$el.outerHeight(), left: pos.left, width: this._$el.outerWidth() }); 541 // click event on items 542 this._dd.on('click', 'li', function (evt) { 543 // console.log('clicked', evt.currentTarget); 544 //console.log($(evt.currentTarget)); 545 var item = $(evt.currentTarget).data('item'); 546 _this.itemSelectedLaunchEvent(item); 547 }); 548 this._dd.on('keyup', function (evt) { 549 if (_this.shown) { 550 switch (evt.which) { 551 case 27: 552 // ESC 553 _this.hide(); 554 _this._$el.focus(); 555 break; 556 } 557 return false;
558 } 559 }); 560 this._dd.on('mouseenter', 'li', function (evt) { 561 if (_this.haveResults) { 562 $(evt.currentTarget).closest('ul').find('li.active').removeClass('active'); 563 $(evt.currentTarget).addClass('active'); 564 _this.mouseover = true; 565 } 566 }); 567 this._dd.on('mouseleave', 'li', function (evt) { 568 _this.mouseover = false; 569 }); 570 this.initialized = true; 571 }; 572 Dropdown.prototype.checkInitialized = function () { 573 // Lazy init 574 if (!this.initialized) { 575 // if not already initialized 576 this.init(); 577 } 578 }; 579 Object.defineProperty(Dropdown.prototype, "isMouseOver", { 580 get: function () { 581 return this.mouseover; 582 }, 583 enumerable: true, 584 configurable: true 585 }); 586 Object.defineProperty(Dropdown.prototype, "haveResults", { 587 get: function () { 588 return (this.items.length > 0); 589 }, 590 enumerable: true, 591 configurable: true 592 }); 593 Dropdown.prototype.focusNextItem = function (reversed) { 594 if (this.haveResults) { 595 // get selected 596 var currElem = this._dd.find('li.active'); 597 var nextElem = reversed ? currElem.prev() : currElem.next(); 598 if (nextElem.length == 0) { 599 // first 600 nextElem = reversed ? this._dd.find('li').last() : this._dd.find('li').first(); 601 } 602 currElem.removeClass('active'); 603 nextElem.addClass('active'); 604 } 605 }; 606 Dropdown.prototype.focusPreviousItem = function () { 607 this.focusNextItem(true); 608 }; 609 Dropdown.prototype.selectFocusItem = function () { 610 this._dd.find('li.active').trigger('click'); 611 }; 612 Object.defineProperty(Dropdown.prototype, "isItemFocused", { 613 get: function () { 614 if (this._dd.find('li.active').length > 0) { 615 return true; 616 } 617 return false; 618 }, 619 enumerable: true, 620 configurable: true 621 }); 622 Dropdown.prototype.show = function () { 623 if (!this.shown) { 624 this._dd.dropdown().show(); 625 this.shown = true; 626 } 627 }; 628 Dropdown.prototype.isShown = function () { 629 return this.shown; 630 }; 631 Dropdown.prototype.hide = function () { 632 if (this.shown) { 633 this._dd.dropdown().hide(); 634 this.shown = false; 635 } 636 }; 637 Dropdown.prototype.updateItems = function (items, searchText) { 638 // console.log('updateItems', items); 639 this.items = items; 640 this.searchText = searchText; 641 this.refreshItemList(); 642 }; 643 Dropdown.prototype.showMatchedText = function (text, qry) { 644 var startIndex = text.toLowerCase().indexOf(qry.toLowerCase()); 645 if (startIndex > -1) { 646 var endIndex = startIndex + qry.length; 647 return text.slice(0, startIndex) + '<b>' 648 + text.slice(startIndex, endIndex) + '</b>' 649 + text.slice(endIndex); 650 } 651 return text; 652 }; 653 Dropdown.prototype.refreshItemList = function () { 654 var _this = this; 655 this.checkInitialized(); 656 this._dd.empty(); 657 var liList = []; 658 if (this.items.length > 0) { 659 this.items.forEach(function (item) { 660 var itemFormatted = _this.formatItem(item); 661 if (typeof itemFormatted === 'string') { 662 itemFormatted = { text: itemFormatted }; 663 } 664 var itemText; 665 var itemHtml; 666 itemText = _this.showMatchedText(itemFormatted.text, _this.searchText); 667 if (itemFormatted.html !== undefined) { 668 itemHtml = itemFormatted.html; 669 } 670 else { 671 itemHtml = itemText; 672 } 673 var li = $('<li >'); 674 li.append($('<a>').attr('href', '#').html(itemHtml)) 675 .data('item', item); 676 liList.push(li); 677 }); 678 } 679 else { 680 // No results 681 var li = $('<li >'); 682 li.append($('<a>').attr('href', '#').html(this.noResultsText)) 683 .addClass('disabled'); 684 liList.push(li); 685 } 686 this._dd.append(liList); 687 }; 688 Dropdown.prototype.itemSelectedLaunchEvent = function (item) { 689 // launch selected event 690 // console.log('itemSelectedLaunchEvent', item); 691 this._$el.trigger('autocomplete.select', item); 692 }; 693 return Dropdown; 694}()); 695 696var DropdownV4 = /** @class */ (function () { 697 function DropdownV4(e, formatItemCbk, autoSelect, noResultsText) { 698 this.initialized = false;
699 this.shown = false; 700 this.items = []; 701 this._$el = e; 702 this.formatItem = formatItemCbk; 703 this.autoSelect = autoSelect; 704 this.noResultsText = noResultsText; 705 // initialize it in lazy mode to deal with glitches like modals 706 // this.init(); 707 } 708 DropdownV4.prototype.getElPos = function () { 709 var pos = $.extend({}, this._$el.position(), { 710 height: this._$el[0].offsetHeight 711 }); 712 return pos; 713 }; 714 DropdownV4.prototype.init = function () { 715 var _this = this; 716 // Initialize dropdown 717 var pos = this.getElPos(); 718 // create element 719 this._dd = $('<div />'); 720 // add our class and basic dropdown-menu class 721 this._dd.addClass('bootstrap-autocomplete dropdown-menu'); 722 this._dd.insertAfter(this._$el); 723 this._dd.css({ top: pos.top + this._$el.outerHeight(), left: pos.left, width: this._$el.outerWidth() }); 724 // click event on items 725 this._dd.on('click', '.dropdown-item', function (evt) { 726 // console.log('clicked', evt.currentTarget); 727 //console.log($(evt.currentTarget)); 728 var item = $(evt.currentTarget).data('item'); 729 _this.itemSelectedLaunchEvent(item); 730 }); 731 this._dd.on('keyup', function (evt) { 732 if (_this.shown) { 733 switch (evt.which) { 734 case 27: 735 // ESC 736 _this.hide(); 737 _this._$el.focus(); 738 break; 739 } 740 return false; 741 } 742 }); 743 this._dd.on('mouseenter', '.dropdown-item', function (evt) { 744 if (_this.haveResults) { 745 $(evt.currentTarget).closest('div').find('.dropdown-item.active').removeClass('active'); 746 $(evt.currentTarget).addClass('active'); 747 _this.mouseover = true; 748 } 749 }); 750 this._dd.on('mouseleave', '.dropdown-item', function (evt) { 751 _this.mouseover = false; 752 }); 753 this.initialized = true; 754 }; 755 DropdownV4.prototype.checkInitialized = function () { 756 // Lazy init 757 if (!this.initialized) { 758 // if not already initialized 759 this.init(); 760 } 761 }; 762 Object.defineProperty(DropdownV4.prototype, "isMouseOver", { 763 get: function () { 764 return this.mouseover; 765 }, 766 enumerable: true, 767 configurable: true 768 }); 769 Object.defineProperty(DropdownV4.prototype, "haveResults", { 770 get: function () { 771 return (this.items.length > 0); 772 }, 773 enumerable: true, 774 configurable: true 775 }); 776 DropdownV4.prototype.focusNextItem = function (reversed) { 777 if (this.haveResults) { 778 // get selected 779 var currElem = this._dd.find('.dropdown-item.active'); 780 var nextElem = reversed ? currElem.prev() : currElem.next(); 781 if (nextElem.length == 0) { 782 // first 783 nextElem = reversed ? this._dd.find('.dropdown-item').last() : this._dd.find('.dropdown-item').first(); 784 } 785 currElem.removeClass('active'); 786 nextElem.addClass('active'); 787 } 788 }; 789 DropdownV4.prototype.focusPreviousItem = function () { 790 this.focusNextItem(true); 791 }; 792 DropdownV4.prototype.selectFocusItem = function () { 793 this._dd.find('.dropdown-item.active').trigger('click'); 794 }; 795 Object.defineProperty(DropdownV4.prototype, "isItemFocused", { 796 get: function () { 797 if (this._dd.find('.dropdown-item.active').length > 0) { 798 return true; 799 } 800 return false; 801 }, 802 enumerable: true, 803 configurable: true 804 }); 805 DropdownV4.prototype.show = function () { 806 if (!this.shown) { 807 var pos = this.getElPos(); 808 // this._dd.css({ top: pos.top + this._$el.outerHeight(), left: pos.left, width: this._$el.outerWidth() }); 809 this._dd.addClass('show'); 810 this.shown = true; 811 } 812 }; 813 DropdownV4.prototype.isShown = function () { 814 return this.shown; 815 }; 816 DropdownV4.prototype.hide = function () { 817 if (this.shown) { 818 this._dd.removeClass('show'); 819 this.shown = false;
820 } 821 }; 822 DropdownV4.prototype.updateItems = function (items, searchText) { 823 // console.log('updateItems', items); 824 this.items = items; 825 this.searchText = searchText; 826 this.refreshItemList(); 827 }; 828 DropdownV4.prototype.showMatchedText = function (text, qry) { 829 var startIndex = text.toLowerCase().indexOf(qry.toLowerCase()); 830 if (startIndex > -1) { 831 var endIndex = startIndex + qry.length; 832 return text.slice(0, startIndex) + '<b>' 833 + text.slice(startIndex, endIndex) + '</b>' 834 + text.slice(endIndex); 835 } 836 return text; 837 }; 838 DropdownV4.prototype.refreshItemList = function () { 839 var _this = this; 840 this.checkInitialized(); 841 this._dd.empty(); 842 var liList = []; 843 if (this.items.length > 0) { 844 this.items.forEach(function (item) { 845 var itemFormatted = _this.formatItem(item); 846 if (typeof itemFormatted === 'string') { 847 itemFormatted = { text: itemFormatted }; 848 } 849 var itemText; 850 var itemHtml; 851 itemText = _this.showMatchedText(itemFormatted.text, _this.searchText); 852 if (itemFormatted.html !== undefined) { 853 itemHtml = itemFormatted.html; 854 } 855 else { 856 itemHtml = itemText; 857 } 858 var li = $('<a >'); 859 li.attr('href', '#') 860 .addClass('dropdown-item') 861 .html(itemHtml) 862 .data('item', item); 863 liList.push(li); 864 }); 865 } 866 else { 867 // No results 868 var li = $('<a >'); 869 li.attr('href', '#') 870 .addClass('dropdown-item disabled') 871 .html(this.noResultsText); 872 liList.push(li); 873 } 874 this._dd.append(liList); 875 }; 876 DropdownV4.prototype.itemSelectedLaunchEvent = function (item) { 877 // launch selected event 878 // console.log('itemSelectedLaunchEvent', item); 879 this._$el.trigger('autocomplete.select', item); 880 }; 881 return DropdownV4; 882}()); 883 884 885 886/***/ }) 887/******/ ]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.