{ "version": 3, "sources": [ "../../../../../Foundation/JavascriptCommon/code/scripts/common/accordion.js", "DynamicMobileAccordion/main.js" ], "names": [], "mappings": "AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,AC5DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA", "file": "DynamicMobileAccordion.js", "sourcesContent": [ "define('common/accordion',[\r\n],\r\n function () {\r\n\r\n function init(selector) {\r\n $(selector + \" .custom-accordion-title,\" + selector + \" .custom-accordion-icon\").off(\"click\").on(\"click\", accordionClick);\r\n // auto expand custom-accordion-item if needed\r\n $(selector + \" .custom-accordion,\" + selector + \".custom-accordion\").each(function (index, element) {\r\n var expandItemId = $(element).data(\"expandItemId\");\r\n if (expandItemId) expandAccordionItem(selector, expandItemId);\r\n });\r\n }\r\n\r\n function accordionClick(event, clickedElement) {\r\n if (!clickedElement) clickedElement = this;\r\n // toggle accordion opened/closed\r\n $(clickedElement).toggleClass(\"open\");\r\n $(clickedElement).siblings(\".custom-accordion-content\").toggleClass(\"open\");\r\n $(clickedElement).siblings(\".custom-accordion-title\").toggleClass(\"open\");\r\n // dispatch appropriate event for other modules to use\r\n if ($(clickedElement).hasClass(\"open\")) dispatchEvent(clickedElement, \"accordionOpened\");\r\n else dispatchEvent(clickedElement, \"accordionClosed\");\r\n }\r\n\r\n function expandAccordionItem(selector, id) {\r\n var clickedElement = selector + \" .custom-accordion-item[data-item-id='\" + id + \"']\" + \" .custom-accordion-title\";\r\n if ($(clickedElement).length) {\r\n accordionClick(null, clickedElement);\r\n // scroll the accordion item into view if needed\r\n var pageTop = $(window).scrollTop();\r\n var pageBottom = pageTop + $(window).height();\r\n var elementTop = $(clickedElement).offset().top;\r\n var elementBottom = elementTop + $(clickedElement).height();\r\n if (elementTop < pageTop || elementBottom > pageBottom) {\r\n $(\"html,body\").animate({ scrollTop: $(clickedElement).offset().top - 80 });\r\n }\r\n }\r\n }\r\n\r\n function dispatchEvent(clickedElement, eventName) {\r\n var accordionItemElement = $(clickedElement).closest(\".custom-accordion-item\");\r\n var eventData = $(accordionItemElement).data(\"itemId\");\r\n var event;\r\n var trueTypeOf = function (obj) {\r\n return Object.prototype.toString.call(obj).slice(8, -1).toLowerCase();\r\n };\r\n if (trueTypeOf(window.CustomEvent) === 'function') {\r\n event = new CustomEvent(eventName, { bubbles: true, detail: eventData });\r\n } else {\r\n event = document.createEvent('CustomEvent');\r\n event.initCustomEvent(eventName, true, false, eventData);\r\n }\r\n $(accordionItemElement)[0].dispatchEvent(event);\r\n }\r\n\r\n return {\r\n init : init\r\n };\r\n });\r\n\n", "require([\r\n \"common/accordion\"\r\n],\r\nfunction (accordion) {\r\n\r\n function initEventHandlers() {\r\n $(window).off(\"resize.dynamicMobileAccordion\").on(\"resize.dynamicMobileAccordion\", windowResized);\r\n accordion.init(\".dynamic-mobile-accordion\");\r\n }\r\n\r\n var views = {\r\n desktop: 1,\r\n mobile: 2\r\n };\r\n\r\n var currentView = views.desktop;\r\n var mobileBreakpoint;\r\n\r\n function windowResized(event) {\r\n var width = $(window).width();\r\n if (!mobileBreakpoint) {\r\n mobileBreakpoint = $(\".dynamic-mobile-accordion\").data(\"mobileBreakpoint\");\r\n }\r\n\r\n if (width < mobileBreakpoint && currentView === views.desktop) {\r\n // SWITCH FROM DESKTOP TO MOBILE\r\n moveTitleText(\".desktop-accordion-title-X\", \".mobile-accordion-item-X > .custom-accordion-title\");\r\n moveContent(\".desktop-accordion-content-X\", \".mobile-accordion-item-X > .custom-accordion-content\",\r\n \".desktop-accordion-item-X\", \".dynamic-mobile-accordion\");\r\n currentView = views.mobile;\r\n } else if (width >= mobileBreakpoint && currentView === views.mobile) {\r\n // SWITCH FROM MOBILE TO DESKTOP\r\n moveTitleText(\".mobile-accordion-item-X > .custom-accordion-title\", \".desktop-accordion-title-X\");\r\n moveContent(\".mobile-accordion-item-X > .custom-accordion-content\", \".desktop-accordion-content-X\",\r\n \".dynamic-mobile-accordion\", \".desktop-accordion-item-X\");\r\n currentView = views.desktop;\r\n }\r\n }\r\n\r\n function moveTitleText(sourceSelector, targetSelector) {\r\n $(\".dynamic-mobile-accordion div[class*=mobile-accordion-item-]\").each(function (i, element) {\r\n var x = $(element).data(\"itemNumber\");\r\n var source = sourceSelector.replace(\"X\", x);\r\n var target = targetSelector.replace(\"X\", x);\r\n\r\n $(target).html($(source).html()); // this copies the DOM elements\r\n $(source).empty();\r\n\r\n // display the accordion element if it has a title, hide it otherwise\r\n if ($(target).html()) $(element).removeClass(\"d-none\");\r\n else $(element).addClass(\"d-none\");\r\n });\r\n }\r\n\r\n function moveContent(sourceSelector, targetSelector, hideSelector, showSelector) {\r\n $(\".dynamic-mobile-accordion div[class*=mobile-accordion-item-]\").each(function (i, element) {\r\n var x = $(element).data(\"itemNumber\");\r\n var source = sourceSelector.replace(\"X\", x);\r\n var target = targetSelector.replace(\"X\", x);\r\n\r\n // since target is unique, the appendTo will moves elements and preserve event handlers on them\r\n $(source).children().appendTo(target);\r\n\r\n if (hideSelector) {\r\n var hide = hideSelector.replace(\"X\", x);\r\n $(hide).addClass(\"d-none\");\r\n }\r\n if (showSelector) {\r\n var show = showSelector.replace(\"X\", x);\r\n $(show).removeClass(\"d-none\");\r\n }\r\n });\r\n }\r\n\r\n initEventHandlers();\r\n windowResized();\r\n});\r\n\ndefine(\"DynamicMobileAccordion/main\", function(){});\n\n" ] }