"use strict"; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } /* eslint-disable no-undef */ (function () { "use strict"; /** * ContentCtrl Controller for the basic pages skeleto{'landing-page-sub-title-small': $ctrl.$mdMedia('xs')}n * that will be used across the application */ var ContentCtrl = /*#__PURE__*/function () { /** * constructor Content comonent constructor * @param {Object} constant JSON object with reusable constants * @param {Object} HomeLoginService Login related service */ function ContentCtrl(constant, HomeLoginService, HomeService, $mdMedia, backofficeConfigService, $timeout, $route, $location) { _classCallCheck(this, ContentCtrl); this.homeService = HomeService; this.$timeout = $timeout; this.imgPath = constant.imgPath; this.isLoggedIn = HomeLoginService.isLoggedIn; this.initialConfig = null; this.$mdMedia = $mdMedia; this.backofficeConfigService = backofficeConfigService; this.$route = $route; this.$location = $location; this.currentLang = sessionHandler.sessionStorage.get("currentLang") === null || sessionHandler.sessionStorage.get("currentLang") === undefined ? CONFIGS.DEFAULT_LANGUAGE : sessionHandler.sessionStorage.get("currentLang"); this.defaultInitialConfig = { configsList: { showPortalBackgroundImage: 0, portalBackgroundColor: "#ffffff", portalBackgroundImage: this.imgPath + "assets/img/background-dashboard.jpg", browserImage: null } }; this.newsContainerMaxWidth = null; this.viewsContainerMaxWidth = null; this.isNewsContainerToggled = false; //List of places to add overlay this.addOverlay = ["my-profile", "invoices", "kids", "activities-prices", "contacts", "dashboard"]; this._600To768 = false; if (window.hasOwnProperty("home")) { this.backofficeConfigService.setShowBridge(false); } else { this.backofficeConfigService.setShowBridge(sessionHandler.sessionStorage.get("showBridge") === null ? true : sessionHandler.sessionStorage.get("showBridge")); } } /** * $onInit executed on component initialization */ _createClass(ContentCtrl, [{ key: "$onInit", value: function $onInit() { var initialConfig = sessionHandler.sessionStorage.get("initialConfig"), _self = this; /* if (initialConfig === null) { */ this.homeService.getInitialConfig(this.currentLang).then(function (response) { initialConfig = response; })["finally"](function () { try { // Set initial config in session storage initialConfig.configsList = _self.convertInitalConfigObjects(initialConfig.configsList); if ("logoImage" in initialConfig.configsList && initialConfig.configsList.logoImage.trim() === '') { initialConfig.configsList.logoImage = PCK_GLOBAL_VARIABLES.LOGO_PATH; } sessionHandler.sessionStorage.set("initialConfig", initialConfig); _self.initialConfig = initialConfig; _self.initBasicConfig(); } catch (error) {//console.error("Initial config error", error); } }); /* } else { _self.initialConfig = initialConfig; _self.initBasicConfig(); } */ } /** * $onChanges Executed when one way bindings (<) and string bindings (@) * change */ }, { key: "$onChanges", value: function $onChanges() { this.displayFooter = typeof this.hasFooter === "boolean" && this.hasFooter; this.fullHeight = typeof this.isFullHeight === "boolean" && this.isFullHeight; } }, { key: "$doCheck", value: function $doCheck() { this._600To768 = this.$mdMedia("(min-width: 600px) and (max-width: 768px)"); var curNewsMaxWidth = angular.element("#news-container").css("max-width"), curViewsMaxWidth = angular.element("#views-container").css("max-width"); if (curNewsMaxWidth !== "none" && !this.newsContainerMaxWidth) { this.newsContainerMaxWidth = curNewsMaxWidth; } if (curViewsMaxWidth !== "none" && !this.viewsContainerMaxWidth) { this.viewsContainerMaxWidth = curViewsMaxWidth; } var fabButtonContainer = angular.element(".fab-button-container"); if (angular.element(document).find(".md-scroll-mask").length > 0) { fabButtonContainer.css("visibility", "hidden"); } else { fabButtonContainer.css("visibility", "visible"); } } /** * hasOverlay Based on a property setted on localStorage, decide if an overlay should be displayed. */ }, { key: "hasOverlay", value: function hasOverlay() { if (this.$route && this.$route.hasOwnProperty("current") && this.$route.current.hasOwnProperty("$$route") && this.$route.current.$$route.originalPath !== "/payments") { return sessionHandler.localStorage.get("hasOverlay") != null && sessionHandler.localStorage.get("hasOverlay") === "true"; } return false; } /** * isRightColumnVisible Define if the right column in the layout should be visible or not, based on the route visited */ }, { key: "isRightColumnVisible", value: function isRightColumnVisible() { return this.$route && this.$route.hasOwnProperty("current") && this.$route.current.hasOwnProperty("$$route") && this.$route.current.$$route.originalPath !== "/payments"; } /** * initBasicConfig Initialize basic configuration * @param {Object} initialConfig Retrieved initial configuration from a WS */ }, { key: "initBasicConfig", value: function initBasicConfig() { var _this = this; this.$timeout(function () { _this.showPortalBackgroundImage = _this.initialConfig.configsList.hasOwnProperty("showPortalBackgroundImage") && _this.initialConfig.configsList.showPortalBackgroundImage ? _this.initialConfig.configsList.showPortalBackgroundImage : _this.defaultInitialConfig.configsList.showPortalBackgroundImage; _this.portalBackgroundImage = _this.initialConfig.configsList.hasOwnProperty("portalBackgroundImage") && _this.initialConfig.configsList.portalBackgroundImage && _this.initialConfig.configsList.portalBackgroundImage != " " ? _this.initialConfig.configsList.portalBackgroundImage : _this.defaultInitialConfig.configsList.portalBackgroundImage; _this.portalBackgroundColor = _this.initialConfig.configsList.hasOwnProperty("portalBackgroundColor") && _this.initialConfig.configsList.portalBackgroundColor ? _this.initialConfig.configsList.portalBackgroundColor + ";" : _this.defaultInitialConfig.configsList.portalBackgroundColor; _this.initialConfig.configsList.hasOwnProperty("browserImage") && _this.initialConfig.configsList.browserImage ? angular.element("#browser-image").attr("href", _this.initialConfig.configsList.browserImage) : angular.element("#browser-image").attr("href", _this.defaultInitialConfig.configsList.browserImage); }); } /** * Convert objects from the initialConfig * @param objectInitialConfig * @return convertedObject */ }, { key: "convertInitalConfigObjects", value: function convertInitalConfigObjects(objectInitialConfig) { var convertedObject = {}; for (var j = 0; j < objectInitialConfig.length; j++) { switch (objectInitialConfig[j].Value) { case "0": convertedObject[objectInitialConfig[j].Key] = 0; break; case "1": convertedObject[objectInitialConfig[j].Key] = 1; break; default: convertedObject[objectInitialConfig[j].Key] = objectInitialConfig[j].Value; } } return convertedObject; } /** * toggleNewsContainerVisibility - show/hide the news container */ }, { key: "toggleNewsContainerVisibility", value: function toggleNewsContainerVisibility() { var newsContainer = angular.element("#news-container"), viewsContainer = angular.element("#views-container"), calendarToolbarElem = angular.element(".calendar-toolbar-container"), self = this; if (newsContainer.length) { if (!this.isNewsContainerToggled) { newsContainer.animate({ maxWidth: "0" }, 50, function () { viewsContainer.animate({ maxWidth: "100%" }, 100, function () { if (calendarToolbarElem.length) { calendarToolbarElem.width(viewsContainer.innerWidth() + "px"); viewsContainer.css("overflow-y", "hidden"); } }); }); this.isNewsContainerToggled = true; } else { viewsContainer.animate({ maxWidth: self.viewsContainerMaxWidth }, 50, function () { newsContainer.animate({ maxWidth: self.newsContainerMaxWidth }, 100); if (calendarToolbarElem.length) { calendarToolbarElem.width(viewsContainer.innerWidth() + "px"); viewsContainer.css("overflow-y", "hidden"); } }); this.isNewsContainerToggled = false; } } } }]); return ContentCtrl; }(); // component definition var Content = { bindings: { hasFooter: "=?", isFullHeight: "=?", moduleName: "@" }, controller: ContentCtrl, // templateUrl: "transversalModule/template/content_comp_view.html" templateUrl: PCK_GLOBAL_VARIABLES.content_component_view }; angular.module("agp.transversal.content", []).component("content", Content); }).call();