/**
* @ngdoc directives
* @name Whatsapp
* @module s4c.directives.whatsapp.Whatsapp
*
* @description
* `Whatsapp` Controller do módulo de Whatsapp
*
*
*/
(function () {
'use strict';
whatsappController.$inject = [
'$scope',
'$timeout',
'Preset',
'$q',
'$sce'
];
function whatsappController(
$scope,
$timeout,
Preset,
$q,
$sce) {
$scope.res = $scope.$root.res;
$scope.link;
$scope.secao;
function updateLink(link, secao) {
//if (link.indexOf('http://') == -1 && link.indexOf('https://') == -1) {
//link = 'http://' + link;
//}
$scope.modulo.extras = { url: link };
$scope.link = $sce.trustAsResourceUrl(link);
$scope.secao = "persist:" + secao.replace(" ","");
Preset.salvar();
}
var modulos = Preset.obter().PresetModulos;
$scope.presetId = Preset.obter().id;
$timeout(function () {
for (var index in modulos) {
if ((modulos[index].template == 'app/components/modulos/modulo-whatsapp.html' ||
(modulos[index].Face && modulos[index].Face.template == 'app/components/modulos/modulo-whatsapp.html')) && !modulos[index].usado) {
modulos[index].usado = true;
$scope.modulo = modulos[index];
modulos[index].index = 2;
updateLink('https://web.whatsapp.com/', modulos[index].Face.name);
break;
}
}
}, 300);
angular.extend($scope, {
});
}
function s4cWhatsapp() {
return {
restrict: 'E',
templateUrl: 'app/directives/whatsapp/whatsapp.html',
scope: {},
controller: whatsappController
};
}
angular.module('s4c.components.whatsapp', [])
.directive('s4cWhatsapp', s4cWhatsapp);
})();