{"version":3,"sources":["webpack:///./LeLab.Gcv.Web/src/controller/ctrl-ajax-drawer/ctrl-ajax-drawer.chunk.js"],"names":["$","require","AjaxRefresh","Logger","UiElementsLocker","$document","document","AjaxDrawerContainer","container","Log","$targetDrawerContainer","Id","data","ContentView","RefreshUrl","RefreshTargetSelector","AjaxLoaded","is","instance","fadeIn","promise","done","LoadAjaxContentIfNeeded","fadeOut","trigger","jsLoadedCssClass","hasClass","LockElements","$target","refreshElement","AjaxRefreshUi","UnLockElements","addClass","AjaxDrawer","ajaxDrawerInstance","$container","targetDrawerContainerId","targetDrawerContainer","targetDrawerContainerSelector","eq","autoOpenOpenedClass","openedContainerCssClass","openedButtonCssClass","$drawerStateButton","$drawerActionButtons","off","on","e","preventDefault","ToggleDrawer","isAutoOpen","Open","isOpened","IsOpen","Close","closeText","html","attr","openText","removeClass","init","each","destroy"],"mappings":";;;;;;;;;;;;AAAA,IAAIA,IAAI,mBAAAC,CAAQ,CAAR,CAAR;AACA,IAAIC,cAAc,mBAAAD,CAAQ,EAAR,CAAlB;AACA,IAAIE,SAAS,mBAAAF,CAAQ,EAAR,CAAb;AACA,IAAIG,mBAAmB,mBAAAH,CAAQ,EAAR,CAAvB;AACA,IAAII,YAAYL,EAAEM,QAAF,CAAhB;;IAEMC,mB;AACF,iCAAYC,SAAZ,EAAuB;AAAA;;AACnB,YAAI,CAACA,SAAL,EAAgB;AACZ;AACH;;AAEDL,eAAOM,GAAP,CAAW,sCAAX,EAAmD,oBAAnD;;AAEA,aAAKC,sBAAL,GAA8BV,EAAEQ,SAAF,CAA9B;AACA,aAAKG,EAAL,GAAU,KAAKD,sBAAL,CAA4BE,IAA5B,CAAiC,gBAAjC,CAAV;AACA,aAAKC,WAAL,GAAmB,KAAKH,sBAAL,CAA4BE,IAA5B,CAAiC,0BAAjC,CAAnB;AACA,aAAKE,UAAL,GAAkB,KAAKJ,sBAAL,CAA4BE,IAA5B,CAAiC,SAAjC,CAAlB;AACA,aAAKG,qBAAL,GAA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KAAKf,kBAAL,CAAwB/B,IAAxB,CAA6B,YAA7B,CAAf;;AAEA,iBAAKuB,UAAL,CAAgBwB,WAAhB,CAA4B,KAAKlB,uBAAjC;AACA,iBAAKE,kBAAL,CAAwBgB,WAAxB,CAAoC,KAAKjB,oBAAzC;AACA,iBAAKC,kBAAL,CAAwBa,IAAxB,CAA6BE,QAA7B;AACA,iBAAKf,kBAAL,CAAwBc,IAAxB,CAA6B,OAA7B,EAAsCC,QAAtC;AACA,iBAAKrB,qBAAL,CAA2BiB,KAA3B;AACH;;;;;;AAGL;;;;;;AAMA,IAAIM,OAAO,SAAPA,IAAO,GAAY;AACnBzD,WAAOM,GAAP,CAAW,kBAAX,EAA+B,MAA/B;AACAT,MAAE,mEAAF,EAAuE6D,IAAvE,CAA4E,YAAY;AACpF,YAAI,KAAK3B,kBAAT,EAA6B;AACzB;AACH;;AAED,aAAKA,kBAAL,GAA0B,IAAID,UAAJ,CAAe,IAAf,CAA1B;AACH,KAND;AAOH,CATD;;AAWA,IAAI6B,UAAU,SAAVA,OAAU,GAAY;AACtB3D,WAAOM,GAAP,CAAW,kBAAX,EAA+B,SAA/B;AACAT,MAAE,mEAAF,EAAuE6D,IAAvE,CAA4E,YAAY;AACpF,YAAI,KAAK3B,kBAAT,EAA6B;AACzB,mBAAO,KAAKA,kBAAZ;AACH;AACJ,KAJD;AAKH,CAPD;;AASA0B;;AAEAvD,UAAUwC,GAAV,CAAc,8BAAd;AACAxC,UAAUyC,EAAV,CAAa,8BAAb,EAA6C,YAAY;AACrDgB;AACAF;AACH,CAHD,E","file":"ctrl-ajax-drawer.js","sourcesContent":["var $ = require(\"jquery\");\r\nvar AjaxRefresh = require(\"utils/ajax-refresh\");\r\nvar Logger = require(\"utils/log-utils\");\r\nvar UiElementsLocker = require(\"utils/ui-elements-locker\");\r\nvar $document = $(document);\r\n\r\nclass AjaxDrawerContainer {\r\n constructor(container) {\r\n if (!container) {\r\n return;\r\n }\r\n\r\n Logger.Log(\"ctrl-ajax-drawer-AjaxDrawerContainer\", \"Constructor called\");\r\n\r\n this.$targetDrawerContainer = $(container);\r\n this.Id = this.$targetDrawerContainer.data('ajax-drawer-id');\r\n this.ContentView = this.$targetDrawerContainer.data('ajax-drawer-content-view');\r\n this.RefreshUrl = this.$targetDrawerContainer.data('refresh');\r\n this.RefreshTargetSelector = this.$targetDrawerContainer.data('refresh-selector');\r\n this.AjaxLoaded = false;\r\n }\r\n\r\n IsOpen() {\r\n return this.$targetDrawerContainer.is(\":visible\");\r\n }\r\n\r\n Open() {\r\n Logger.Log(\"ctrl-ajax-drawer-AjaxDrawerContainer\", \"Open\");\r\n let instance = this;\r\n this.$targetDrawerContainer.fadeIn('fast').promise().done(function () {\r\n instance.LoadAjaxContentIfNeeded();\r\n });\r\n\r\n }\r\n\r\n Close() {\r\n Logger.Log(\"ctrl-ajax-drawer-AjaxDrawerContainer\", \"Close\");\r\n let instance = this;\r\n this.$targetDrawerContainer.fadeOut('fast').promise().done(function () {\r\n instance.$targetDrawerContainer.trigger(\"ajaxdrawercontainer:close\");\r\n });\r\n\r\n }\r\n\r\n LoadAjaxContentIfNeeded() {\r\n\r\n //todo: on pourrait retourner un promise...\r\n\r\n const jsLoadedCssClass = 'js-ajax-loaded';\r\n\r\n // S'il n'y a pas d'url de refresh, c'est qu'il n'y a pas de contenu Ajax à charger\r\n if (!this.RefreshUrl || this.$targetDrawerContainer.hasClass(jsLoadedCssClass)) {\r\n $document.trigger(\"ajaxdrawercontainer:open\", [this.$targetDrawerContainer]);\r\n return;\r\n }\r\n\r\n Logger.Log(\"ctrl-ajax-drawer-AjaxDrawerContainer\", \"LoadAjaxContentIfNeeded : LoadAjax\");\r\n\r\n UiElementsLocker.LockElements();\r\n\r\n Logger.Log(\"ctrl-ajax-drawer-LoadAjaxContentIfNeeded (RefreshUrl)\", this.RefreshUrl);\r\n Logger.Log(\"ctrl-ajax-drawer-LoadAjaxContentIfNeeded (RefreshTargetSelector)\", this.RefreshTargetSelector);\r\n\r\n let instance = this;\r\n let $target = $(this.RefreshTargetSelector, this.$targetDrawerContainer);\r\n let refreshElement =\r\n {\r\n \"Url\": this.RefreshUrl,\r\n \"Target\": $target\r\n };\r\n\r\n AjaxRefresh.AjaxRefreshUi([refreshElement], 60, () => {\r\n $document.trigger(\"jsInitAllScripts\");\r\n UiElementsLocker.UnLockElements();\r\n instance.$targetDrawerContainer.addClass(jsLoadedCssClass);\r\n $document.trigger(\"ajaxdrawercontainer:open\", [instance.$targetDrawerContainer]);\r\n });\r\n\r\n }\r\n}\r\n\r\nclass AjaxDrawer {\r\n constructor(container) {\r\n\r\n Logger.Log(\"ctrl-ajax-drawer-AjaxDrawer\", \"Constructor called\");\r\n\r\n var ajaxDrawerInstance = this;\r\n var $container = this.$container = $(container);\r\n\r\n this.targetDrawerContainerId = this.$container.data('ajax-drawer-target-container');\r\n\r\n if (this.targetDrawerContainer) {\r\n delete this.targetDrawerContainer;\r\n }\r\n if (!this.targetDrawerContainer) {\r\n let targetDrawerContainerSelector = \"[data-ajax-drawer-id='\" + this.targetDrawerContainerId + \"']\";\r\n let $targetDrawerContainer = $(targetDrawerContainerSelector);\r\n this.targetDrawerContainer = new AjaxDrawerContainer($targetDrawerContainer.eq(0));\r\n }\r\n\r\n this.autoOpenOpenedClass = 'js-was-auto-open';\r\n this.openedContainerCssClass = \"o-ajax-drawer--active\";\r\n this.openedButtonCssClass = \"a-btn-collapse--active\";\r\n\r\n this.$drawerStateButton = $('[data-ajax-drawer-state-button]', $container);\r\n\r\n // Setup Click Events\r\n this.$drawerActionButtons = $('[data-ajax-drawer-load-and-open-target-container]', $container);\r\n this.$drawerActionButtons.off(\"click.AjaxDrawer\");\r\n this.$drawerActionButtons.on(\"click.AjaxDrawer\", function (e) {\r\n e.preventDefault();\r\n ajaxDrawerInstance.ToggleDrawer();\r\n });\r\n\r\n var isAutoOpen = this.$container.data('ajax-drawer-target-container-auto-open') === 1;\r\n if (isAutoOpen && !this.$container.hasClass(this.autoOpenOpenedClass)) {\r\n Logger.Log(\"ctrl-ajax-drawer-AjaxDrawer\", \"Auto Open\");\r\n this.$container.addClass(this.autoOpenOpenedClass);\r\n ajaxDrawerInstance.Open();\r\n }\r\n\r\n }\r\n\r\n ToggleDrawer() {\r\n\r\n let isOpened = this.targetDrawerContainer.IsOpen();\r\n\r\n if (isOpened) {\r\n this.Close();\r\n } else {\r\n this.Open();\r\n }\r\n }\r\n\r\n Open() {\r\n\r\n if (this.$drawerStateButton.hasClass(this.openedButtonCssClass)) {\r\n return;\r\n }\r\n\r\n let closeText = this.$drawerStateButton.data(\"label-close\");\r\n\r\n this.$container.addClass(this.openedContainerCssClass);\r\n this.$drawerStateButton.addClass(this.openedButtonCssClass);\r\n this.$drawerStateButton.html(closeText);\r\n this.$drawerStateButton.attr(\"title\", closeText);\r\n this.targetDrawerContainer.Open();\r\n\r\n this.$drawerStateButton.trigger(\"ajaxdrawer:open\");\r\n\r\n }\r\n\r\n Close() {\r\n\r\n if (!this.$drawerStateButton.hasClass(this.openedButtonCssClass)) {\r\n return;\r\n }\r\n\r\n let openText = this.$drawerStateButton.data(\"label-open\");\r\n\r\n this.$container.removeClass(this.openedContainerCssClass);\r\n this.$drawerStateButton.removeClass(this.openedButtonCssClass);\r\n this.$drawerStateButton.html(openText);\r\n this.$drawerStateButton.attr(\"title\", openText);\r\n this.targetDrawerContainer.Close();\r\n }\r\n}\r\n\r\n/*\r\n--------------------------------------\r\n-- Controller, Init and Destroy section\r\n--------------------------------------\r\n*/\r\n\r\nvar init = function () {\r\n Logger.Log(\"ctrl-ajax-drawer\", \"Init\");\r\n $('[data-controller=\"ajax-drawer\"],[data-controller-2=\"ajax-drawer\"]').each(function () {\r\n if (this.ajaxDrawerInstance) {\r\n return;\r\n }\r\n\r\n this.ajaxDrawerInstance = new AjaxDrawer(this);\r\n });\r\n};\r\n\r\nvar destroy = function () {\r\n Logger.Log(\"ctrl-ajax-drawer\", \"Destroy\");\r\n $('[data-controller=\"ajax-drawer\"],[data-controller-2=\"ajax-drawer\"]').each(function () {\r\n if (this.ajaxDrawerInstance) {\r\n delete this.ajaxDrawerInstance;\r\n }\r\n });\r\n};\r\n\r\ninit();\r\n\r\n$document.off('jsInitAllScripts.ajax-drawer');\r\n$document.on('jsInitAllScripts.ajax-drawer', function () {\r\n destroy();\r\n init();\r\n});\n\n\n// WEBPACK FOOTER //\n// ./LeLab.Gcv.Web/src/controller/ctrl-ajax-drawer/ctrl-ajax-drawer.chunk.js"],"sourceRoot":""}