{"version":3,"sources":["webpack:///./LeLab.Gcv.Web/src/controller/ctrl-overlay/ctrl-overlay.chunk.js"],"names":["$","require","overlayClassOpen","overlayOpened","$document","document","Logger","AjaxRefresh","scrollTo","body","querySelector","ygap","onModalMount","window","pageYOffset","documentElement","scrollTop","style","position","top","onModalDismount","isSmoothScrollSupported","opts","behavior","jQuery","isOverlayOpened","setOverlayOpened","setOverlayClosed","getOpenOverlayCtaElements","$openOverlayElements","closeAllOverlays","$openOverlayCtaElements","each","$openOverlayCtaElement","targetOverlayId","attr","$targetOverlay","closeOverlay","trigger","loadOverlayContentIfNeeded","$overlayElement","data","asyncUrl","refreshElement","GetRefreshElement","AjaxRefreshUi","openOverlay","$overlayParent","parent","is","find","length","prependTo","overlayType","overlayId","addClass","eventName","removeClass","on","e","defaultPrevented","$targetOverlayElement","$tabSection","closest","Log","$tempTargetOverlayElement","off","preventDefault","$overlayItemToClose","target","init","$autoOpenItem"],"mappings":";;;;;;;;AAAA,IAAIA,IAAI,mBAAAC,CAAQ,CAAR,CAAR;AAAA,IACIC,mBAAmB,iBADvB;AAAA,IAEIC,gBAAgB,KAFpB;AAAA,IAGIC,YAAYJ,EAAEK,QAAF,CAHhB;AAAA,IAIIC,SAAS,mBAAAL,CAAQ,EAAR,CAJb;AAAA,IAKIM,cAAc,mBAAAN,CAAQ,EAAR,CALlB;AAAA,IAMIO,QANJ;;AAQA;AACA,IAAMC,OAAOJ,SAASK,aAAT,CAAuB,MAAvB,CAAb,C,CAA6C;AAC7C,IAAIC,OAAO,CAAC,CAAZ,C,CAAe;;AAEf;AACA,IAAIC,eAAe,SAAfA,YAAe,GAAY;;AAE3B;AACAD,WAAOE,OAAOC,WAAP,IAAsBT,SAASU,eAAT,CAAyBC,SAAtD;;AAEA;AACAP,SAAKQ,KAAL,CAAWC,QAAX,GAAsB,OAAtB;;AAEA;AACAT,SAAKQ,KAAL,CAAWE,GAAX,GAAoB,CAACR,IAArB;AAEH,CAXD;;AAaA;AACA,IAAIS,kB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IuE,cAAcpB,MAAd,GAAuB,CAA3B,EAA8B;AAC1B7C,eAAO0D,GAAP,CAAW,cAAX,EAA2B,mBAA3B;AACAlB,oBAAYyB,aAAZ;AACH;AACJ,CATD;;AAWAD,O","file":"ctrl-overlay.js","sourcesContent":["var $ = require(\"jquery\"),\r\n overlayClassOpen = \"o-overlay--open\",\r\n overlayOpened = false,\r\n $document = $(document),\r\n Logger = require(\"utils/log-utils\"),\r\n AjaxRefresh = require(\"utils/ajax-refresh\"),\r\n scrollTo;\r\n\r\n// Fix and unfix body on open and close overlay (to fix iPad input focus bug)\r\nconst body = document.querySelector('body'); // Body.\r\nlet ygap = -1; // Y Offset.\r\n\r\n// On Mount (Call When Mounting).\r\nlet onModalMount = function () {\r\n\r\n // Y Gap.\r\n ygap = window.pageYOffset || document.documentElement.scrollTop;\r\n\r\n // Fix Body.\r\n body.style.position = 'fixed';\r\n\r\n // Apply Y Offset To Body Top.\r\n body.style.top = `${-ygap}px`;\r\n\r\n};\r\n\r\n// On Dismount (Call When Dismounting).\r\nlet onModalDismount = function () {\r\n\r\n // Unfix Body.\r\n body.style.position = 'static';\r\n\r\n // Reset Top Offset.\r\n body.style.top = 'auto';\r\n\r\n // On ne doit pas scroller si le ygap n'a jamais été setté.\r\n if (ygap < 0) {\r\n return;\r\n }\r\n\r\n // Reset scroll.\r\n var isSmoothScrollSupported = 'scrollBehavior' in document.documentElement.style;\r\n\r\n if (isSmoothScrollSupported) {\r\n\r\n // Fix pour retirer l'animation du scroll: https://sigmund.leankit.com/card/662252894\r\n var opts = {\r\n top: ygap,\r\n behavior: \"instant\"\r\n };\r\n\r\n // Native smooth scrolling\r\n window.scrollTo(opts);\r\n } else if (window.jQuery && jQuery.scrollTo) {\r\n // jQuery scrollTo (you can change to your plugin/realization)\r\n window.scrollTo(0, ygap);\r\n } else {\r\n // Old way scrolling without effects\r\n window.scrollTo(0, ygap);\r\n }\r\n};\r\n\r\nvar isOverlayOpened = function () {\r\n return overlayOpened;\r\n};\r\n\r\nvar setOverlayOpened = function () {\r\n overlayOpened = true;\r\n};\r\n\r\nvar setOverlayClosed = function () {\r\n overlayOpened = false;\r\n};\r\n\r\nvar getOpenOverlayCtaElements = function () {\r\n var $openOverlayElements = $('[data-open-overlay]');\r\n return $openOverlayElements;\r\n};\r\n\r\nvar closeAllOverlays = function () {\r\n var $openOverlayCtaElements = getOpenOverlayCtaElements();\r\n\r\n $openOverlayCtaElements.each(function () {\r\n\r\n var $openOverlayCtaElement = $(this);\r\n var targetOverlayId = $openOverlayCtaElement.attr('data-open-overlay');\r\n var $targetOverlay = $('[data-overlay=\"' + targetOverlayId + '\"]');\r\n closeOverlay($targetOverlay);\r\n\r\n });\r\n\r\n $document.trigger('ticketPassCloseDialog');\r\n};\r\n\r\nvar loadOverlayContentIfNeeded = function ($overlayElement) {\r\n if ($overlayElement.data(\"overlay-loaded\")) return;\r\n\r\n let asyncUrl = $overlayElement.data(\"refresh\");\r\n if (!asyncUrl) return;\r\n\r\n var refreshElement = AjaxRefresh.GetRefreshElement($overlayElement);\r\n AjaxRefresh.AjaxRefreshUi([refreshElement], 60, () => {\r\n $document.trigger(\"jsInitAllScripts\");\r\n $overlayElement.data(\"overlay-loaded\", true);\r\n });\r\n\r\n /*$.get(asyncUrl)\r\n .success(function(result) {\r\n $overlayElement.find(\"[data-overlay-content]\").html(result);\r\n $overlayElement.data(\"overlay-loaded\", true);\r\n\r\n $(document).trigger(\"jsInitAllScripts\");\r\n });*/\r\n}\r\n\r\nvar openOverlay = function ($overlayElement) {\r\n if (!$overlayElement)\r\n return;\r\n\r\n //Move the overlay to the top of the body\r\n var $overlayParent = $overlayElement.parent();\r\n if (!$overlayParent.is(\"body\") && $overlayElement.find(\"[data-prepend-to-body]\").length) {\r\n $overlayElement.prependTo(\"body\");\r\n }\r\n\r\n let overlayType = $overlayElement.data('overlay-type');\r\n let overlayId = $overlayElement.data('overlay');\r\n\r\n loadOverlayContentIfNeeded($overlayElement);\r\n\r\n $overlayElement.addClass(overlayClassOpen);\r\n onModalMount();\r\n\r\n setOverlayOpened();\r\n let eventName = 'overlay' + overlayType + 'Opened';\r\n $document.trigger(eventName, [overlayId]);\r\n $document.trigger('overlayOpened', [overlayId]);\r\n}\r\n\r\nvar closeOverlay = function ($overlayElement) {\r\n\r\n if (!$overlayElement) {\r\n return;\r\n }\r\n\r\n let overlayType = $overlayElement.data('overlay-type');\r\n let overlayId = $overlayElement.data('overlay');\r\n\r\n $document.trigger('overlayClosing', [overlayId]);\r\n\r\n $overlayElement.removeClass(overlayClassOpen);\r\n onModalDismount();\r\n\r\n setOverlayClosed();\r\n let eventName = 'overlay' + overlayType + 'Closed';\r\n $document.trigger(eventName, [overlayId]);\r\n $document.trigger('overlayClosed', [overlayId]);\r\n}\r\n\r\n$document.on(\"click.overlay\", \"[data-open-overlay]\", function (e) {\r\n\r\n if (e.defaultPrevented) {\r\n return;\r\n }\r\n let $openOverlayCtaElement = $(this);\r\n let targetOverlayId = $openOverlayCtaElement.attr('data-open-overlay');\r\n let $targetOverlayElement = $('[data-overlay=\"' + targetOverlayId + '\"]');\r\n\r\n if ($targetOverlayElement.length > 1) {\r\n // Normalement, il devrait n'y avoir qu'un seul target. Par contre, dans le cas de certaines \r\n // pages avec onglets, il se pourrait qu'un popup ait le même \"id\" entre 2 onglets. Dans ce cas\r\n // on tente d'ouvrir le popup de l'onglet actif seulement.\r\n let $tabSection = $openOverlayCtaElement.closest('[data-tab-section]');\r\n if ($tabSection.length > 0) {\r\n Logger.Log('Il y a plus d\\'un overlay comme target', $tabSection);\r\n let $tempTargetOverlayElement = $('[data-overlay=\"' + targetOverlayId + '\"]', $tabSection);\r\n if ($tempTargetOverlayElement.length === 1) {\r\n Logger.Log('Sélection automatique d\\'un target unique', $tempTargetOverlayElement);\r\n $targetOverlayElement = $tempTargetOverlayElement;\r\n }\r\n }\r\n }\r\n\r\n if (isOverlayOpened()) {\r\n closeOverlay($targetOverlayElement);\r\n }\r\n\r\n openOverlay($targetOverlayElement);\r\n});\r\n\r\n$document.on(\"overlay-close.overlay\", \".o-overlay\", function () {\r\n closeOverlay($(this));\r\n});\r\n// close overlay when click on close button\r\n$document.on(\"click.overlay\", \".o-overlay__close\", function (e) {\r\n if (e.defaultPrevented) return;\r\n closeOverlay($(this).closest(\"[data-overlay]\"));\r\n});\r\n$(\"[data-overlay-close]\").off(\"click.overlay\");\r\n$(\"[data-overlay-close]\").on(\"click.overlay\", function (e) {\r\n e.preventDefault();\r\n let $overlayItemToClose = $(this).closest(\"[data-overlay]\");\r\n closeOverlay($overlayItemToClose);\r\n});\r\n\r\n// Not working\r\n// close overlay when click in background but not in overlay content\r\n/*$document.on(\"click.overlay\", \".o-overlay\", function (e) {\r\n if (!$(e.target).closest('.o-overlay__content').length) {\r\n closeOverlay($(this).closest('o-overlay'));\r\n }\r\n});*/\r\n\r\n// Working\r\n// close overlay when click in background but not in overlay content\r\n$document.on(\"click.overlay\", \".o-overlay\", function (e) {\r\n if (!$(e.target).closest('.o-overlay__content').length) {\r\n closeOverlay($(this));\r\n }\r\n});\r\n\r\n$document.off('overlayCloseAll.overlay');\r\n$document.on('overlayCloseAll.overlay', function () {\r\n closeAllOverlays();\r\n});\r\n\r\nvar init = function () {\r\n //Logger.Log('ctrl-overlay', 'init');\r\n\r\n // Verify if auto open overlay exists\r\n let $autoOpenItem = $('[data-auto-open=\"1\"]');\r\n if ($autoOpenItem.length > 0) {\r\n Logger.Log('ctrl-overlay', 'auto open overlay');\r\n openOverlay($autoOpenItem);\r\n }\r\n};\r\n\r\ninit();\r\n\n\n\n// WEBPACK FOOTER //\n// ./LeLab.Gcv.Web/src/controller/ctrl-overlay/ctrl-overlay.chunk.js"],"sourceRoot":""}