"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; } (function () { "use strict"; /** * AgpFooter Allows the construction of the footer */ var AgpFooter = /*#__PURE__*/function () { /** * constructor Footer constructor * @param {Object} $timeout AngularJS timeout service */ function AgpFooter($timeout, $document, NewCompModal) { _classCallCheck(this, AgpFooter); this.$timeout = $timeout; this.$document = $document; this.newCompModal = NewCompModal; this.defaultInitialConfig = { configsList: { footerBackgroundColor: '#20282b', footerTextColor: '#ffffff', clientName: 'Agoraplus.' } }; } _createClass(AgpFooter, [{ key: "$onInit", value: function $onInit() {} }, { key: "$onChanges", value: function $onChanges() { if (typeof this.initialConfig === "undefined" || !this.initialConfig) { this.initialConfig = {}; } if (typeof this.initialConfig.configsList === "undefined" || !this.initialConfig.configsList) { this.initialConfig.configsList = {}; } this.initBasicConfig(); } /** * initBasicConfig Initialize basic configurations for the footer, * in particular (in this version - v0.0.1), the footer background color. */ }, { key: "initBasicConfig", value: function initBasicConfig() { var _this = this; this.$timeout(function () { var elem = document.querySelector("md-toolbar.custom-footer-toolbar"); if (elem) { _this.clientName = _this.initialConfig.configsList.hasOwnProperty("municipalityName") && _this.initialConfig.configsList.municipalityName ? _this.initialConfig.configsList.municipalityName + "." : _this.defaultInitialConfig.configsList.clientName; if (sessionHandler.sessionStorage.get("showBridge") != null && sessionHandler.sessionStorage.get("showBridge") != true) { _this.footerBackgroundColor = _this.initialConfig.configsList.hasOwnProperty("footerBackgroundColor") && _this.initialConfig.configsList.footerBackgroundColor ? _this.initialConfig.configsList.footerBackgroundColor + ";" : _this.defaultInitialConfig.configsList.footerBackgroundColor + ";"; _this.footerTextColor = _this.initialConfig.configsList.hasOwnProperty("footerTextColor") && _this.initialConfig.configsList.footerTextColor ? _this.initialConfig.configsList.footerTextColor + ";" : _this.defaultInitialConfig.configsList.footerTextColor + ";"; } else { _this.footerBackgroundColor = "#1f282b"; _this.footerTextColor = "#ffffff"; } } }); } /** * getFooterColor Get footer text color */ }, { key: "getFooterTextColor", value: function getFooterTextColor() { if (this.footerTextColor && this.footerTextColor.indexOf(";") >= 0 && this.footerTextColor.indexOf(";") === this.footerTextColor.length - 1) { return this.footerTextColor.substring(0, this.footerTextColor.length - 1); } return this.footerTextColor; } /** * openFooterDialog Handle the clicks that are done in footer items and * open a dialog with the correct template. * @param {Object} ev The event triggered */ }, { key: "openFooterDialog", value: function openFooterDialog(ev) { var _self = this, bodyRef = angular.element(this.$document[0].body); this.newCompModal.show("AgpFooterDialogController", getFooterTemplateName(ev), { parent: angular.element(bodyRef), disableClose: true, targetEvent: null, escapeToClose: false, controllerAs: "$ctrl", bindToController: true, locals: { initialConfig: this.initialConfig } }).then(function (response) {})["catch"](function () {}); } }]); return AgpFooter; }(); // Component definition var agpFooter = { bindings: { initialConfig: "<", params: "=?" }, controller: AgpFooter, templateUrl: "transversalModule/template/agp_footer_component_view.html" }; var mapper = { "chrome": "google chrome", "firefox": "firefox", "internet-explorer": "internet explorer" }; /** * AgpFooterDialogCtrl Controller used to manage the dialog that is triggered * when clicking in a footer item. */ var AgpFooterDialogCtrl = /*#__PURE__*/function () { function AgpFooterDialogCtrl(initialConfig, constant, $mdDialog) { _classCallCheck(this, AgpFooterDialogCtrl); this.initialConfig = initialConfig; this.imgPath = constant.imgPath; this.$mdDialog = $mdDialog; } /** * getIcon Given a browser name and by using the mapper defined, get the * icon name. * @param {String} browserName The bowser name that was returned by the WS * that returns the initial configuration * @return {String} The icon name to display */ _createClass(AgpFooterDialogCtrl, [{ key: "getIcon", value: function getIcon(browserName) { var iconName = "browser"; angular.forEach(mapper, function (value, key) { if (browserName.toLowerCase().indexOf(value) >= 0) { iconName = key; return; } }); return iconName; } /** * cancel Close the footer dialogs by trigering a cancel using * Angular Material $mdDialog service */ }, { key: "cancel", value: function cancel() { this.$mdDialog.cancel(); } }]); return AgpFooterDialogCtrl; }(); /****** Private Functions ******/ /** * getFooterTemplateName Get the correct view when a footer item is clicked, * by using the triggered event and fetching the element id. * @param {Object} selectedFooterItem Triggered event when clicking in a * footer item * @return {String} Returns the full template path */ function getFooterTemplateName(selectedFooterItem) { return PCK_GLOBAL_VARIABLES.agp_footer_dynamic_template_name.replace("$$template_placeholder$$", selectedFooterItem.currentTarget.id + "_view"); } angular.module("agp.transversal.footer", []).component("agpFooter", agpFooter).controller("AgpFooterDialogController", AgpFooterDialogCtrl); }).call();