{"version":3,"sources":["webpack:////Users/owenli/Documents/workspace/awi-wool-fe/src/views/widgets/siteHeaderBottomSubMenuWidget/js/siteHeaderBottomSubMenuWidget.js"],"names":["CLS","SiteHeaderBottomSubMenuWidget","element","_this","this","_classCallCheck","$element","$","itemPadding","$siteHeaderBottomSubMenuItemsWidget","children","defineDepth","initActiveElement","on","concat","trigger","key","value","$initialActiveElement","find","activateDropdown","length","parent","animate","$parentElement","parents","first","hasClass","$dropdownElement","depth","attr","multiplier","indentPadding","paddingStyle","css","padding","$children","innerDepth"],"mappings":"y4BAAA,IACMA,EAAM,gCAECC,EAA6B,WAgBzC,SAfA,SAAAA,EAAYC,GAAS,IAAAC,EAAAC,kGAAAC,CAAAD,KAAAH,GACpBG,KAAKF,QAAUA,EACfE,KAAKE,SAAWC,EAAEL,GAClBE,KAAKI,YAAc,GAEnBJ,KAAKK,oCAAsCL,KAAKE,SAASI,SAAQ,kDACjEN,KAAKO,YAAYP,KAAKK,oCAAqC,GAE3DL,KAAKQ,oBAELR,KAAKE,SAASO,GAAE,GAAAC,OAAId,EAAG,wBAAwB,WAC9CG,EAAKM,oCAAoCM,QAAO,qEAIlDC,IAAA,oBAAAC,MAGA,WACC,IAAIC,EAAwBd,KAAKE,SAASa,KAAK,wBAG3CC,EAAmB,SAACd,GACvB,GAAGA,GAAYA,EAASe,OAAS,EAAG,CACnCf,EAASgB,OAAO,uCAAuCP,QAAQ,wDAC9Db,QAASI,EACTiB,SAAS,IAGV,IAAIC,EAAiBlB,EAASgB,OAAO,uCAAuCG,QAAQ,gDAAgDC,QACpIN,EAAiBI,KAInB,GAAGN,GAA0D,IAAjCA,EAAsBG,OAEjD,GAAGH,EAAsBS,SAAS,2CAA4C,CAC7E,IAAIC,EAAmBV,EAAsBI,OAAO,uCAAuCG,QAAQ,gDAAgDC,QACnJN,EAAiBQ,QAGVV,EAAsBS,SAAS,gDACtCP,EAAiBF,QAGXA,GAAyBA,EAAsBG,UAKxDL,IAAA,cAAAC,MACA,SAAYX,EAAUuB,GACrBvB,EAASwB,KAAK,aAAcD,GAE5B,IAAIE,EAAuB,IAAVF,EAAczB,KAAKI,YAAcJ,KAAKI,YAAcqB,EAEjEG,EAAiB5B,KAAKI,YAAeuB,EACrCE,EAAY,KAAAnB,OAAQV,KAAKI,YAAW,SAAAM,OAAQkB,EAAa,MAE7D1B,EAASI,SAAS,4CAA4CwB,KAC7DC,QAASF,IAGV3B,EAASI,SAAS,gDAAgDA,SAAS,4CAA4CwB,KACtHC,QAASF,IAGV,IAAIG,EAAY9B,EAASI,SAAS,gDAAgDA,SAAS,wDAAwDA,SAAS,8DAA8DA,SAAS,kDACnO,GAAG0B,GAAaA,EAAUf,OAAS,EAAG,CACrC,IAAIgB,EAAaR,EAAQ,EACzBzB,KAAKO,YAAYyB,EAAWC,mGAvEW","file":"widget-31.430117f348aedc9992ce.js","sourcesContent":["const NS = 'SiteHeaderBottomSubMenuWidget';\nconst CLS = 'siteHeaderBottomSubMenuWidget';\n\nexport class SiteHeaderBottomSubMenuWidget {\n\tconstructor(element) {\n\t\tthis.element = element;\n\t\tthis.$element = $(element);\n\t\tthis.itemPadding = 16; // Left/right padding\n\n\t\tthis.$siteHeaderBottomSubMenuItemsWidget = this.$element.children(`[data-wg=\"SiteHeaderBottomSubMenuItemsWidget\"]`);\n\t\tthis.defineDepth(this.$siteHeaderBottomSubMenuItemsWidget, 0);\n\n\t\tthis.initActiveElement();\n\n\t\tthis.$element.on(`${CLS}.dropdown.deactivate`, () => {\n\t\t\tthis.$siteHeaderBottomSubMenuItemsWidget.trigger(`siteHeaderBottomSubMenuItemsWidget.dropdown.deactivate`, {});\n\t\t});\n\t}\n\n\t/**\n\t * Displays the active item (by opening its respective parent dropdowns)\n\t */\n\tinitActiveElement() {\n\t\tlet $initialActiveElement = this.$element.find('[data-active=\"true\"]');\n\n\t\t// Recursive loop to all parent dropdowns\n\t\tlet activateDropdown = ($element) => {\n\t\t\tif($element && $element.length > 0) {\n\t\t\t\t$element.parent('.siteHeaderBottomSubMenuItemsWidget').trigger('siteHeaderBottomSubMenuItemsWidget.dropdown.activate', {\n\t\t\t\t\telement: $element,\n\t\t\t\t\tanimate: false\n\t\t\t\t});\n\n\t\t\t\tlet $parentElement = $element.parent('.siteHeaderBottomSubMenuItemsWidget').parents('.siteHeaderBottomSubMenuItemsWidget-dropdown').first();\n\t\t\t\tactivateDropdown($parentElement);\n\t\t\t}\n\t\t};\n\n\t\tif($initialActiveElement && $initialActiveElement.length === 1) {\n\t\t\t// If the item is a link\n\t\t\tif($initialActiveElement.hasClass('siteHeaderBottomSubMenuItemsWidget-link')) {\n\t\t\t\tlet $dropdownElement = $initialActiveElement.parent('.siteHeaderBottomSubMenuItemsWidget').parents('.siteHeaderBottomSubMenuItemsWidget-dropdown').first();\n\t\t\t\tactivateDropdown($dropdownElement);\n\t\t\t}\n\t\t\t// If the item is a dropdown\n\t\t\telse if($initialActiveElement.hasClass('siteHeaderBottomSubMenuItemsWidget-dropdown')) {\n\t\t\t\tactivateDropdown($initialActiveElement);\n\t\t\t}\n\t\t}\n\t\telse if($initialActiveElement && $initialActiveElement.length > 1) {\n\t\t\tconsole.error(`${NS}::Error`, 'Please ensure there is only a single item link/dropdown) that has the attribute of [data-active=\"true\"].');\n\t\t}\n\t}\n\n\t// Recursive function that defines the depth of the siteHeaderBottomSubMenuItemsWidget\n\tdefineDepth($element, depth) {\n\t\t$element.attr('data-depth', depth);\n\n\t\tlet multiplier = depth === 2 ? this.itemPadding : this.itemPadding * depth;\n\n\t\tlet indentPadding = (this.itemPadding) + multiplier;\n\t\tlet paddingStyle = `0 ${this.itemPadding}px 0 ${indentPadding}px`;\n\n\t\t$element.children('.siteHeaderBottomSubMenuItemsWidget-item').css({\n\t\t\tpadding: paddingStyle\n\t\t});\n\n\t\t$element.children('.siteHeaderBottomSubMenuItemsWidget-dropdown').children('.siteHeaderBottomSubMenuItemsWidget-item').css({\n\t\t\tpadding: paddingStyle\n\t\t});\n\n\t\tlet $children = $element.children('.siteHeaderBottomSubMenuItemsWidget-dropdown').children('.siteHeaderBottomSubMenuItemsWidget-dropdown-content').children('.siteHeaderBottomSubMenuItemsWidget-dropdown-content-inner').children('[data-wg=\"SiteHeaderBottomSubMenuItemsWidget\"]');\n\t\tif($children && $children.length > 0) {\n\t\t\tlet innerDepth = depth + 1;\n\t\t\tthis.defineDepth($children, innerDepth);\n\t\t}\n\t}\n}\n"],"sourceRoot":""}