{"version":3,"sources":["webpack:///36.52f5a0f9.bundle.js","webpack:///./src/js/components/search-listing/PredictiveSearch.js"],"names":["webpackJsonp","275","module","exports","__webpack_require__","$","_interopRequireDefault","obj","__esModule","default","_asyncToGenerator","fn","gen","apply","this","arguments","Promise","resolve","reject","step","key","arg","info","value","error","done","then","err","_classCallCheck","instance","Constructor","TypeError","_possibleConstructorReturn","self","call","ReferenceError","_inherits","subClass","superClass","prototype","Object","create","constructor","enumerable","writable","configurable","setPrototypeOf","__proto__","defineProperty","_createClass","defineProperties","target","props","i","length","descriptor","protoProps","staticProps","_component2","_component","_debounce3","_debounce2","_template3","_template2","_remove3","_remove2","_isEmpty3","_isEmpty2","_predictiveSearchItem2","_predictiveSearchItem","PredictiveSearch","el","config","_Component","dom","$container","$el","$serchBox","find","$input","$searchBtn","$results","cssClasses","searchGroup","endpoint","predictiveEndpoint","ENDPOINT","getKeywordSearch","currentRequest","on","e","onInputUp","onSearch","bind","onHeadingClick","keyword","contenttype","requestIndex","addClass","ajax","url","data","beforeSend","abort","renderResults","_x","_ref","regeneratorRuntime","mark","_callee","items","noResults","noResultsString","wrap","_context","prev","next","all","getResults","SEARCH_GROUPS","n","removeClass","trigger","forEach","item","predictiveTmpl","html","remove","hasClass","TweenLite","set","height","ease","Expo","easeOut","from","easeInOut","stop","to","onComplete","val","trim","destroyResults","which","catch","statusText","console","$target","currentTarget","$searchGroup","parents","searchViewAllType","searchGroupLabel","substring","log","window","open","encodeURIComponent","preventDefault","Component"],"mappings":"AAAAA,cAAc,KAERC,IACA,SAAUC,EAAQC,EAASC,GAEjC,cAC4B,SAASC,GAoCrC,QAASC,GAAuBC,GAAO,MAAOA,IAAOA,EAAIC,WAAaD,GAAQE,QAASF,GAEvF,QAASG,GAAkBC,GAAM,MAAO,YAAc,GAAIC,GAAMD,EAAGE,MAAMC,KAAMC,UAAY,OAAO,IAAIC,SAAQ,SAAUC,EAASC,GAAU,QAASC,GAAKC,EAAKC,GAAO,IAAM,GAAIC,GA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xCmD,EAAmBH,EAAahD,KAAK,0BAGlB,eAArBmD,GACqB,cAArBA,GACqB,YAArBA,IAEAA,EAAmBA,EAAiBC,UAClC,EACAD,EAAiBlG,OAAS,GAI9B,IAAMyC,GAAUjF,KAAK4D,IAAIK,OAAO6D,MAAMC,MACtCK,SAAQQ,IAAI,sBACZC,OAAOC,KACF9I,KAAK4D,IAAIG,UAAUwB,KAAK,cAD7B,UAEIkD,EACIM,mBAAmBN,GACnBM,mBAAmBL,IAJ3B,YAKcK,mBAAmB9D,GAC/B,aD0DF3E,IAAK,WACLG,MAAO,SCvDAmE,GACPA,EAAEoE,gBAEF,IAAMvI,GAAQT,KAAK4D,IAAIK,OAAO6D,MAAMC,MAEpC/H,MAAK8D,IAAI8C,QAAQ,eAAgBnG,GAEjCT,KAAKgI,qBD2DAxE,GCnPsByF,UDsP/B5J,GAAQM,QC1DO6D,ID2DcpC,KAAK/B,EAASC,EAAoB","file":"36.52f5a0f9.bundle.js","sourcesContent":["webpackJsonp([36],{\n\n/***/ 275:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n/* WEBPACK VAR INJECTION */(function($) {\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _component = __webpack_require__(33);\n\nvar _component2 = _interopRequireDefault(_component);\n\nvar _debounce2 = __webpack_require__(206);\n\nvar _debounce3 = _interopRequireDefault(_debounce2);\n\nvar _template2 = __webpack_require__(91);\n\nvar _template3 = _interopRequireDefault(_template2);\n\nvar _remove2 = __webpack_require__(209);\n\nvar _remove3 = _interopRequireDefault(_remove2);\n\nvar _isEmpty2 = __webpack_require__(208);\n\nvar _isEmpty3 = _interopRequireDefault(_isEmpty2);\n\nvar _predictiveSearchItem = __webpack_require__(214);\n\nvar _predictiveSearchItem2 = _interopRequireDefault(_predictiveSearchItem);\n\nvar _constants = __webpack_require__(92);\n\nvar _gsap = __webpack_require__(90);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step(\"next\", value); }, function (err) { step(\"throw\", err); }); } } return step(\"next\"); }); }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar PredictiveSearch = function (_Component) {\n _inherits(PredictiveSearch, _Component);\n\n function PredictiveSearch(el, config) {\n _classCallCheck(this, PredictiveSearch);\n\n return _possibleConstructorReturn(this, (PredictiveSearch.__proto__ || Object.getPrototypeOf(PredictiveSearch)).call(this, el, config));\n }\n\n _createClass(PredictiveSearch, [{\n key: 'setupDefaults',\n value: function setupDefaults() {\n this.dom = {\n $container: this.$el,\n $serchBox: this.$el.find('.wh-search-box'),\n $input: this.$el.find('.wh-search-box__field'),\n $searchBtn: this.$el.find('.wh-search-box__button'),\n $results: this.$el.find('.wh-predictive-search')\n };\n\n this.cssClasses = {\n searchGroup: 'wh-predictive-search-group'\n };\n\n this.endpoint = this.config.predictiveEndpoint ? this.config.predictiveEndpoint : _constants.ENDPOINT.getKeywordSearch;\n this.currentRequest = [];\n }\n }, {\n key: 'addListeners',\n value: function addListeners() {\n var _this2 = this;\n\n this.dom.$input.on('keyup', (0, _debounce3.default)(function (e) {\n _this2.onInputUp(e);\n }, 100));\n\n this.dom.$searchBtn.on('click touch', this.onSearch.bind(this));\n this.$el.on('click touch', '.wh-predictive-search-group__title', this.onHeadingClick.bind(this));\n }\n }, {\n key: 'getResults',\n value: function getResults(keyword, contenttype, requestIndex) {\n var _this3 = this;\n\n this.dom.$serchBox.addClass('loading');\n\n return $.ajax({\n url: this.endpoint,\n data: { keyword: keyword, contenttype: contenttype },\n beforeSend: function beforeSend() {\n if (_this3.currentRequest[requestIndex] && _this3.currentRequest[requestIndex] !== null) {\n _this3.currentRequest[requestIndex].abort();\n }\n }\n });\n }\n }, {\n key: 'renderResults',\n value: function () {\n var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(value) {\n var data, items, noResults, noResultsString;\n return regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return Promise.all([this.currentRequest[0] = this.getResults(value, _constants.SEARCH_GROUPS[0], 0), this.currentRequest[1] = this.getResults(value, _constants.SEARCH_GROUPS[1], 1), this.currentRequest[2] = this.getResults(value, _constants.SEARCH_GROUPS[2], 2), this.currentRequest[3] = this.getResults(value, _constants.SEARCH_GROUPS[3], 3), this.currentRequest[4] = this.getResults(value, _constants.SEARCH_GROUPS[4], 4), this.currentRequest[4] = this.getResults(value, _constants.SEARCH_GROUPS[5], 5), this.currentRequest[5] = this.getResults(value, _constants.SEARCH_GROUPS[6], 6), this.currentRequest[5] = this.getResults(value, _constants.SEARCH_GROUPS[7], 7)]);\n\n case 2:\n data = _context.sent;\n\n\n (0, _remove3.default)(data, function (n) {\n return (0, _isEmpty3.default)(n);\n });\n\n this.dom.$serchBox.removeClass('loading');\n this.$el.trigger('search:keyword', data);\n\n items = '';\n\n\n if (data.length > 0) {\n data.forEach(function (item) {\n items += (0, _template3.default)(_predictiveSearchItem2.default)(item);\n });\n\n this.dom.$results.html(items);\n } else {\n noResults = this.dom.$results.data('no-results-txt');\n noResultsString = '
  • ' + noResults + '
  • ';\n\n\n this.dom.$results.find('li').remove();\n this.dom.$results.html(noResultsString);\n }\n\n this.dom.$results.removeClass('loading');\n\n if (!this.dom.$results.hasClass('expanded')) {\n this.dom.$results.addClass('expanded');\n _gsap.TweenLite.set(this.dom.$results, { height: 'auto', ease: _gsap.Expo.easeOut });\n _gsap.TweenLite.from(this.dom.$results, 0.4, {\n height: 0,\n ease: _gsap.Expo.easeInOut\n });\n }\n\n case 10:\n case 'end':\n return _context.stop();\n }\n }\n }, _callee, this);\n }));\n\n function renderResults(_x) {\n return _ref.apply(this, arguments);\n }\n\n return renderResults;\n }()\n }, {\n key: 'destroyResults',\n value: function destroyResults() {\n var _this4 = this;\n\n _gsap.TweenLite.to(this.dom.$results, 0.5, {\n height: 0,\n ease: _gsap.Expo.easeOut,\n onComplete: function onComplete() {\n _this4.dom.$results.removeClass('expanded');\n _this4.dom.$results.find('li').remove();\n }\n });\n }\n }, {\n key: 'onInputUp',\n value: function onInputUp(e) {\n var value = this.dom.$input.val().trim();\n if (value.length > 1) {\n this.dom.$searchBtn.addClass('enabled');\n } else {\n this.dom.$searchBtn.removeClass('enabled');\n }\n\n if (value.length < 2) {\n this.destroyResults();\n\n if (value.length === 0) {\n this.$el.trigger('search:clear');\n }\n return;\n }\n\n if (e.which === 13) {\n this.$el.trigger('search:value', value);\n this.destroyResults();\n return;\n }\n\n this.renderResults(value).catch(function (err) {\n if (err.statusText !== 'abort') {\n console.error('There was an error getting your results', err);\n }\n });\n }\n }, {\n key: 'onHeadingClick',\n value: function onHeadingClick(e) {\n var $target = $(e.currentTarget);\n if ($target.hasClass('wh-predictive-search-group__title--false')) {\n return;\n }\n\n var $searchGroup = $target.parents('.' + this.cssClasses.searchGroup);\n var searchViewAllType = $searchGroup.data('predictive-view-all-type');\n var searchGroupLabel = $searchGroup.data('predictive-search-group');\n\n if (searchGroupLabel === 'Solutions' || searchGroupLabel === 'Locations' || searchGroupLabel === 'Careers') {\n searchGroupLabel = searchGroupLabel.substring(0, searchGroupLabel.length - 1);\n }\n\n var keyword = this.dom.$input.val().trim();\n console.log('se llama el golba?');\n window.open(this.dom.$serchBox.data('search-url') + '?area=' + (searchViewAllType ? encodeURIComponent(searchViewAllType) : encodeURIComponent(searchGroupLabel)) + '&keyword=' + encodeURIComponent(keyword), '_self');\n }\n }, {\n key: 'onSearch',\n value: function onSearch(e) {\n e.preventDefault();\n\n var value = this.dom.$input.val().trim();\n\n this.$el.trigger('search:value', value);\n\n this.destroyResults();\n }\n }]);\n\n return PredictiveSearch;\n}(_component2.default);\n\nexports.default = PredictiveSearch;\n/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10)))\n\n/***/ })\n\n});\n\n\n// WEBPACK FOOTER //\n// 36.52f5a0f9.bundle.js","import Component from 'component';\nimport _debounce from 'lodash/debounce';\nimport _template from 'lodash/template';\nimport _remove from 'lodash/remove';\nimport _isEmpty from 'lodash/isEmpty';\nimport predictiveTmpl from 'templates/predictive-search-item';\nimport { ENDPOINT, SEARCH_GROUPS } from '../../constants';\nimport { Expo, TweenLite } from 'gsap';\n\nclass PredictiveSearch extends Component {\n constructor(el, config) {\n super(el, config);\n }\n\n setupDefaults() {\n this.dom = {\n $container: this.$el,\n $serchBox: this.$el.find('.wh-search-box'),\n $input: this.$el.find('.wh-search-box__field'),\n $searchBtn: this.$el.find('.wh-search-box__button'),\n $results: this.$el.find('.wh-predictive-search')\n };\n\n this.cssClasses = {\n searchGroup: 'wh-predictive-search-group'\n };\n\n this.endpoint = this.config.predictiveEndpoint\n ? this.config.predictiveEndpoint\n : ENDPOINT.getKeywordSearch;\n this.currentRequest = [];\n }\n\n addListeners() {\n this.dom.$input.on(\n 'keyup',\n _debounce(e => {\n this.onInputUp(e);\n }, 100)\n );\n\n this.dom.$searchBtn.on('click touch', this.onSearch.bind(this));\n this.$el.on(\n 'click touch',\n '.wh-predictive-search-group__title',\n this.onHeadingClick.bind(this)\n );\n }\n\n getResults(keyword, contenttype, requestIndex) {\n this.dom.$serchBox.addClass('loading');\n\n return $.ajax({\n url: this.endpoint,\n data: { keyword, contenttype },\n beforeSend: () => {\n if (\n this.currentRequest[requestIndex] &&\n this.currentRequest[requestIndex] !== null\n ) {\n this.currentRequest[requestIndex].abort();\n }\n }\n });\n }\n\n async renderResults(value) {\n const data = await Promise.all([\n (this.currentRequest[0] = this.getResults(value, SEARCH_GROUPS[0], 0)),\n (this.currentRequest[1] = this.getResults(value, SEARCH_GROUPS[1], 1)),\n (this.currentRequest[2] = this.getResults(value, SEARCH_GROUPS[2], 2)),\n (this.currentRequest[3] = this.getResults(value, SEARCH_GROUPS[3], 3)),\n (this.currentRequest[4] = this.getResults(value, SEARCH_GROUPS[4], 4)),\n (this.currentRequest[4] = this.getResults(value, SEARCH_GROUPS[5], 5)),\n (this.currentRequest[5] = this.getResults(value, SEARCH_GROUPS[6], 6)),\n (this.currentRequest[5] = this.getResults(value, SEARCH_GROUPS[7], 7))\n ]);\n\n _remove(data, n => _isEmpty(n));\n\n this.dom.$serchBox.removeClass('loading');\n this.$el.trigger('search:keyword', data);\n\n let items = '';\n\n if (data.length > 0) {\n data.forEach(item => {\n items += _template(predictiveTmpl)(item);\n });\n\n this.dom.$results.html(items);\n } else {\n const noResults = this.dom.$results.data('no-results-txt');\n const noResultsString =\n '
  • ' + noResults + '
  • ';\n\n this.dom.$results.find('li').remove();\n this.dom.$results.html(noResultsString);\n }\n\n this.dom.$results.removeClass('loading');\n\n if (!this.dom.$results.hasClass('expanded')) {\n this.dom.$results.addClass('expanded');\n TweenLite.set(this.dom.$results, { height: 'auto', ease: Expo.easeOut });\n TweenLite.from(this.dom.$results, 0.4, {\n height: 0,\n ease: Expo.easeInOut\n });\n }\n }\n\n destroyResults() {\n TweenLite.to(this.dom.$results, 0.5, {\n height: 0,\n ease: Expo.easeOut,\n onComplete: () => {\n this.dom.$results.removeClass('expanded');\n this.dom.$results.find('li').remove();\n }\n });\n }\n\n onInputUp(e) {\n const value = this.dom.$input.val().trim();\n if (value.length > 1) {\n this.dom.$searchBtn.addClass('enabled');\n } else {\n this.dom.$searchBtn.removeClass('enabled');\n }\n\n if (value.length < 2) {\n this.destroyResults();\n\n if (value.length === 0) {\n this.$el.trigger('search:clear');\n }\n return;\n }\n\n if (e.which === 13) {\n this.$el.trigger('search:value', value);\n this.destroyResults();\n return;\n }\n\n this.renderResults(value).catch(err => {\n if (err.statusText !== 'abort') {\n console.error('There was an error getting your results', err);\n }\n });\n }\n\n onHeadingClick(e) {\n const $target = $(e.currentTarget);\n if ($target.hasClass('wh-predictive-search-group__title--false')) {\n return;\n }\n\n const $searchGroup = $target.parents(`.${this.cssClasses.searchGroup}`);\n const searchViewAllType = $searchGroup.data('predictive-view-all-type');\n let searchGroupLabel = $searchGroup.data('predictive-search-group');\n\n if (\n searchGroupLabel === 'Solutions' ||\n searchGroupLabel === 'Locations' ||\n searchGroupLabel === 'Careers'\n ) {\n searchGroupLabel = searchGroupLabel.substring(\n 0,\n searchGroupLabel.length - 1\n );\n }\n\n const keyword = this.dom.$input.val().trim();\n console.log('se llama el golba?');\n window.open(\n `${this.dom.$serchBox.data('search-url')}?area=${\n searchViewAllType\n ? encodeURIComponent(searchViewAllType)\n : encodeURIComponent(searchGroupLabel)\n }&keyword=${encodeURIComponent(keyword)}`,\n '_self'\n );\n }\n\n onSearch(e) {\n e.preventDefault();\n\n const value = this.dom.$input.val().trim();\n\n this.$el.trigger('search:value', value);\n\n this.destroyResults();\n }\n}\n\nexport default PredictiveSearch;\n\n\n\n// WEBPACK FOOTER //\n// ./src/js/components/search-listing/PredictiveSearch.js"],"sourceRoot":""}