{"version":3,"sources":["webpack:///./LeLab.Gcv.Web/src/atomic/molecule/m-filter-hotel/m-filter-hotel.chunk.js","webpack:///./LeLab.Gcv.Web/src/atomic/molecule/m-filter-hotel/m-filter-hotel.scss"],"names":["require","$","FilterHotelHandler","element","$element","showChildrenAges","getCurrentChildCount","bindEvents","self","on","selectChoice","continue","values","instance","NumberOfAdults","choiceButton","find","NumberOfChildren","ChildrenAges","each","index","$childAge","val","attr","clearErrors","group","data","container","removeClass","addClass","parseInt","prop","childCount","slideUp","$this","toggle","slideDown","params","getCurrentParams","validate","trigger","closest","GroupCode","getCurrentGroupCode","getCurrentNumberOfAdults","getCurrentChildrenAges","getCurrentGroupCodeElement","getChoiceElement","getChoiceValue","getChildrenAgesElements","map","get","name","err","elem","toggleError","shouldDisplayError","formControlElement","errorLabel","hasClass","show","hide","length","childrenAgesIsSelected","isNaN","maxNumberOfPersons","nbOfPersons","getNbOfSelectedPersons","getNumberOfAdultsElement","getChildCountElement","msg","alert","init","document","off"],"mappings":";;;;;;;;;;;;AAAA,mBAAAA,CAAQ,GAAR;;AAEA,IAAIC,IAAI,mBAAAD,CAAQ,CAAR,CAAR;;IAEME,kB;AACF,gCAAYC,OAAZ,EAAqB;AAAA;;AAEjB,aAAKC,QAAL,GAAgBH,EAAEE,OAAF,CAAhB;;AAEA,aAAKE,gBAAL,CAAsB,KAAKC,oBAAL,EAAtB;AACA,aAAKC,UAAL;AACH;;;;qCAEY;AACT,gBAAMC,OAAO,IAAb;;AAEA,iBAAKJ,QAAL,CAAcK,EAAd,CAAiB,oBAAjB,EACI,sBADJ,EAEI,YAAY;AACRD,qBAAKE,YAAL,CAAkB,IAAlB;AACH,aAJL;AAKA,iBAAKN,QAAL,CAAcK,EAAd,CAAiB,qBAAjB,gCAEI,YAAY;AACRD,qBAAKG,QAAL;AACH,aAJL;AAKH;;;wCAEeC,M,EAAQ;;AAEpB;;AAEA;;;;;;;;;AASA,gBAAIC,WAAW,IAAf;;AAEA,gBAAI,OAAOD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C,WAAL,CAAiB,KAAjB,EAAwB/C,KAAK6D,oBAAL,EAAxB;AACH;;AAGD,mBAAO,IAAP;AACH;;;;;;AAGL,SAASG,IAAT,GAAgB;AACZvE,MAAE,iBAAF,EAAqBkB,IAArB,CAA0B,YAAY;AAClC,YAAI,KAAKjB,kBAAT,EACI;AACJ,aAAKA,kBAAL,GAA0B,IAAIA,kBAAJ,CAAuB,IAAvB,CAA1B;AACH,KAJD;AAKH;;AAEDsE;;AAEAvE,EAAEwE,QAAF,EAAYC,GAAZ,CAAgB,+BAAhB;AACAzE,EAAEwE,QAAF,EAAYhE,EAAZ,CAAe,+BAAf,EACI,YAAY;AACR+D;AACH,CAHL,E;;;;;;;AC9OA,yC","file":"m-filter-hotel.js","sourcesContent":["require(\"./m-filter-hotel.scss\");\r\n\r\nvar $ = require('jquery');\r\n\r\nclass FilterHotelHandler {\r\n constructor(element) {\r\n\r\n this.$element = $(element);\r\n\r\n this.showChildrenAges(this.getCurrentChildCount());\r\n this.bindEvents();\r\n }\r\n\r\n bindEvents() {\r\n const self = this;\r\n\r\n this.$element.on(\"click.mFilterHotel\",\r\n \"[data-choice-button]\",\r\n function () {\r\n self.selectChoice(this);\r\n });\r\n this.$element.on(\"click..mFilterHotel\",\r\n `[data-action=\"continue\"]`,\r\n function () {\r\n self.continue();\r\n });\r\n }\r\n\r\n setManualValues(values) {\r\n\r\n // Normalement appel� via LeLab.Gcv.Web\\src\\controller\\ctrl-product-search-form\\ctrl-product-search-form.chunk.js\r\n\r\n /*\r\n Exemple de valeur de values :\r\n { \r\n \"NumberOfChildren\": 2,\r\n \"NumberOfAdults\": 1,\r\n \"ChildrenAges\": [1,2]\r\n };\r\n */\r\n\r\n let instance = this;\r\n\r\n if (typeof values.NumberOfAdults !== 'undefined') {\r\n let choiceButton = this.$element.find('[data-choice-button=\"adultes\"][value=\"' + values.NumberOfAdults + '\"]')[0];\r\n this.selectChoice(choiceButton);\r\n }\r\n\r\n if (typeof values.NumberOfChildren !== 'undefined') {\r\n let choiceButton = this.$element.find('[data-choice-button=\"enfants\"][value=\"' + values.NumberOfChildren + '\"]')[0];\r\n this.selectChoice(choiceButton);\r\n }\r\n\r\n if (typeof values.ChildrenAges !== 'undefined') {\r\n $.each(values.ChildrenAges, function (index, element) {\r\n let $childAge = instance.$element.find('#enfant-' + (index + 1));\r\n if ($childAge) {\r\n $childAge.val(element);\r\n $('option[value=' + element + ']', $childAge).attr('selected', 'selected');\r\n }\r\n });\r\n }\r\n\r\n }\r\n\r\n selectChoice(choiceButton) {\r\n\r\n this.clearErrors();\r\n\r\n choiceButton = $(choiceButton);\r\n const group = choiceButton.data(\"choice-button\");\r\n const container = this.$element.find(`[data-choice-container=\"${group}\"]`);\r\n\r\n container.find(\".a-btn-tile--selected\").removeClass(\"a-btn-tile--selected\");\r\n choiceButton.addClass(\"a-btn-tile--selected\");\r\n\r\n if (group === \"enfants\") {\r\n this.showChildrenAges(parseInt(choiceButton.prop(\"value\")));\r\n }\r\n }\r\n\r\n showChildrenAges(childCount) {\r\n if (childCount === 0) {\r\n $('.m-filter-hotel__children').slideUp();\r\n } else {\r\n $(\"[data-child-age]\").each(function () {\r\n const $this = $(this);\r\n $this.toggle($this.data(\"child-age\") <= childCount);\r\n });\r\n\r\n $('.m-filter-hotel__children').slideDown();\r\n }\r\n }\r\n\r\n continue() {\r\n const params = this.getCurrentParams();\r\n if (!this.validate(params)) return;\r\n\r\n this.$element.trigger(\"params-selected\", params);\r\n this.$element.closest(\"[data-overlay]\").trigger(\"overlay-close\");\r\n }\r\n\r\n getCurrentParams() {\r\n return {\r\n GroupCode: this.getCurrentGroupCode(),\r\n NumberOfAdults: this.getCurrentNumberOfAdults(),\r\n NumberOfChildren: this.getCurrentChildCount(),\r\n ChildrenAges: this.getCurrentChildrenAges()\r\n };\r\n }\r\n\r\n getNumberOfNightsElement() {\r\n return this.$element.find(`[data-field=\"NumberOfNights\"] input`)\r\n }\r\n\r\n getCurrentGroupCodeElement() {\r\n return this.$element.find(`[data-field=\"GroupCode\"] input`);\r\n }\r\n\r\n getCurrentGroupCode() {\r\n return this.getCurrentGroupCodeElement().val();\r\n }\r\n\r\n getNumberOfAdultsElement() {\r\n return this.getChoiceElement(\"adultes\");\r\n }\r\n\r\n getCurrentNumberOfAdults() {\r\n return this.getChoiceValue(\"adultes\");\r\n }\r\n\r\n getChildCountElement() {\r\n return this.getChoiceElement(\"enfants\");\r\n }\r\n\r\n getCurrentChildCount() {\r\n return this.getChoiceValue(\"enfants\");\r\n }\r\n\r\n getChildrenAgesElements() {\r\n return this.$element.find(\"[data-child-age]:visible\");\r\n }\r\n\r\n getCurrentChildrenAges() {\r\n return this.getChildrenAgesElements().map(function () {\r\n return parseInt($(this).find(\"select\").val());\r\n }).get();\r\n }\r\n\r\n getChoiceElement(name) {\r\n return this.$element.find(`[data-choice-button=\"${name}\"].a-btn-tile--selected`);\r\n }\r\n\r\n getChoiceValue(name) {\r\n return parseInt(this.getChoiceElement(name).prop(\"value\"));\r\n }\r\n\r\n getNbOfSelectedPersons() {\r\n try {\r\n return this.getCurrentNumberOfAdults() + this.getCurrentChildCount();\r\n } catch (err) {\r\n return 0;\r\n }\r\n }\r\n\r\n clearErrors() {\r\n var self = this;\r\n $(\".m-form-group--error\").each(function () {\r\n var elem = $(this);\r\n self.toggleError(false, elem);\r\n });\r\n }\r\n\r\n toggleError(shouldDisplayError, element) {\r\n var formControlElement = element.find(\".a-form-control\");\r\n var errorLabel = element.find(\"[data-error-label]\");\r\n\r\n if (shouldDisplayError && !element.hasClass(\"m-form-group--error\")) {\r\n formControlElement.addClass(\"a-form-control--error\");\r\n element.addClass(\"m-form-group--error\");\r\n errorLabel.show();\r\n } else if (!shouldDisplayError) {\r\n formControlElement.removeClass(\"a-form-control--error\");\r\n element.removeClass(\"m-form-group--error\");\r\n errorLabel.hide();\r\n }\r\n }\r\n\r\n validate(params) {\r\n var self = this;\r\n\r\n // TODO Afficher des messages d'erreur\r\n if (params.NumberOfChildren !== params.ChildrenAges.length)\r\n return false;\r\n\r\n var childrenAgesIsSelected = true;\r\n this.getChildrenAgesElements().each(function () {\r\n var elem = $(this);\r\n if (isNaN(parseInt(elem.find(\"select\").val()))) {\r\n self.toggleError(true, elem);\r\n childrenAgesIsSelected = false;\r\n } else {\r\n self.toggleError(false, elem);\r\n }\r\n });\r\n if (!childrenAgesIsSelected)\r\n return false;\r\n\r\n var maxNumberOfPersons = parseInt(self.$element.data(\"max-nb-of-persons\"));\r\n var nbOfPersons = self.getNbOfSelectedPersons();\r\n if (nbOfPersons > maxNumberOfPersons) {\r\n self.toggleError(true, self.getNumberOfAdultsElement());\r\n self.toggleError(true, self.getChildCountElement());\r\n var msg = self.$element.data(\"max-nb-of-persons-error\");\r\n if (msg)\r\n alert(msg);\r\n return false;\r\n } else {\r\n self.toggleError(false, self.getNumberOfAdultsElement());\r\n self.toggleError(false, self.getChildCountElement());\r\n }\r\n\r\n\r\n return true;\r\n }\r\n}\r\n\r\nfunction init() {\r\n $(\".m-filter-hotel\").each(function () {\r\n if (this.FilterHotelHandler)\r\n return;\r\n this.FilterHotelHandler = new FilterHotelHandler(this);\r\n });\r\n}\r\n\r\ninit();\r\n\r\n$(document).off('jsInitAllScripts.mFilterHotel');\r\n$(document).on('jsInitAllScripts.mFilterHotel',\r\n function () {\r\n init();\r\n });\n\n\n// WEBPACK FOOTER //\n// ./LeLab.Gcv.Web/src/atomic/molecule/m-filter-hotel/m-filter-hotel.chunk.js","// removed by extract-text-webpack-plugin\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./LeLab.Gcv.Web/src/atomic/molecule/m-filter-hotel/m-filter-hotel.scss\n// module id = 391\n// module chunks = 138"],"sourceRoot":""}