"use strict"; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } // Typeahead Demo // ============================================================= var TypeaheadDemo = /*#__PURE__*/ function () { function TypeaheadDemo() { _classCallCheck(this, TypeaheadDemo); this.init(); } _createClass(TypeaheadDemo, [ { key: "init", value: function init() { // event handlers this.stockList(); } }, { key: "stockList", value: function stockList() { var nasdaq = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.obj.whitespace(['sym','sname']), queryTokenizer: Bloodhound.tokenizers.whitespace, prefetch: '/static/data/nasdaq.json', sorter : function(a,b) {if (a.sym.lengthb.sym.length) {return 1;} return 0;}, }); var nyse = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.obj.whitespace(['sym','sname']), queryTokenizer: Bloodhound.tokenizers.whitespace, prefetch: '/static/data/nyse.json', sorter : function(a,b) {if (a.sym.lengthb.sym.length) {return 1;} return 0;}, }); $('#symbols').typeahead({ highlight: true }, { name: 'nasdaqs', display: 'sym', source: nasdaq, templates: { suggestion: Handlebars.compile('
{{sym}} - {{sname}}
'), header: '

NASDAQ

' } }, { name: 'nyses', display: 'sym', source: nyse, templates: { suggestion: Handlebars.compile('
{{sym}} - {{sname}}
'), header: '

NYSE

' } }); } } ]); return TypeaheadDemo; }(); /** * Keep in mind that your scripts may not always be executed after the theme is completely ready, * you might need to observe the `theme:load` event to make sure your scripts are executed after the theme is ready. */ $(document).on('theme:init', function () { new TypeaheadDemo(); });