article-box.directive.js
1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
(function() {
'use strict';
angular
.module('dialoga')
.directive('articleBox', articleBox);
/** @ngInject */
function articleBox($rootScope) {
/** @ngInject */
function ArticleBoxController(ArticleService, $scope, $state, Slug, $log) {
$log.debug('ArticleBoxController');
var vm = this;
vm.ArticleService = ArticleService;
vm.$scope = $scope;
vm.$state = $state;
vm.Slug = Slug;
vm.$log = $log;
vm.init();
}
ArticleBoxController.prototype.init = function () {
var vm = this;
if(!vm.article.slug){
vm.article.slug = vm.Slug.slugify(vm.article.title);
}
if(!vm.category){
vm.category = vm.article.categories[0];
}
if(!vm.banner){
vm.banner = {
src: $rootScope.basePath + vm.article.image.url,
alt: 'Imagem de destaque do conteúdo'
};
}
// if(vm.article.color && !vm.article.bgColor){
// // 15% more darker
// vm.article.colorDarker = window.ColorLuminance(vm.article.color, 0.15);
// }
};
ArticleBoxController.prototype.showContent = function () {
var vm = this;
vm.$state.go('programa-conheca', {
slug: vm.article.slug
}, {
location: true
});
};
ArticleBoxController.prototype.showPreview = function () {
var vm = this;
vm.$state.go('programa-conteudo', {
slug: vm.article.slug
}, {
location: true
});
};
var directive = {
restrict: 'E',
templateUrl: 'app/components/article-box/article-box.html',
scope: {
article: '='
},
controller: ArticleBoxController,
controllerAs: 'vm',
bindToController: true
};
return directive;
}
})();