proposal-related.directive.js
2.47 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
(function() {
'use strict';
angular
.module('dialoga')
.directive('proposalRelated', proposalRelated);
/** @ngInject */
function proposalRelated() {
/** @ngInject */
function ProposalRelatedController(ArticleService, $scope, $element, $timeout, $log) {
$log.debug('ProposalRelatedController');
var vm = this;
vm.ArticleService = ArticleService;
vm.$scope = $scope;
vm.$element = $element;
vm.$timeout = $timeout;
vm.$log = $log;
vm.init();
}
ProposalRelatedController.prototype.init = function () {
// initial values
var vm = this;
vm.activeIndex = 1;
vm.loading = false;
if(angular.isDefined(vm.limit) && angular.isString(vm.limit)){
vm.limit = parseInt(vm.limit);
}else{
vm.limit = 3;
}
vm.loadData();
};
ProposalRelatedController.prototype.loadData = function () {
// async values
var vm = this;
vm.loading = true;
// simulate delay
vm.$timeout(function(){
vm.loading = false;
// Fake Data
// vm.proposals = vm.ArticleService.getProposals();
vm.proposals = [{
id: 4159,
abstract: 'Ut odio unde porro in. Aut fuga magni adipisci. Recusandae ipsum distinctio omnis ut illum.',
effective_support: 0.1572052401746725,
hits: 4159,
votes_against: 3779,
votes_for: 1780
},{
id: 935,
abstract: 'Magni sunt ut molestiae. A porro et quod saepe placeat amet nihil. Aut ut id voluptatem doloribus quia.',
effective_support: 0.1572052401746725,
hits: 8602,
votes_against: 7005,
votes_for: 8728
},{
id: 1008,
abstract: 'Cum quas assumenda nihil delectus eos. Minus fugit velit voluptatem nisi nam esse ut id.',
effective_support: 0.1572052401746725,
hits: 9181,
votes_against: 612,
votes_for: 1786
}];
if(vm.display === 'list'){
// wait until DOM be created
vm.$timeout(function(){
attachPopover.call(vm);
}, 20);
}
}, 2000);
};
var directive = {
restrict: 'E',
templateUrl: 'app/components/proposal-related/proposal-related.html',
scope: {
article: '='
},
controller: ProposalRelatedController,
controllerAs: 'vm',
bindToController: true
};
return directive;
}
})();