proposal-list.directive.js
2.11 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
(function() {
'use strict';
angular
.module('dialoga')
.directive('proposalList', proposalList);
/** @ngInject */
function proposalList() {
/** @ngInject */
function ProposalListController($state, $element, $timeout, $log) {
$log.debug('ProposalListController');
var vm = this;
vm.$state = $state;
vm.$element = $element;
vm.$timeout = $timeout;
vm.$log = $log;
vm.init();
}
ProposalListController.prototype.init = function () {
// initial values
var vm = this;
if(!vm.proposals){
throw { name: 'NotDefined', message: 'The attribute "proposals" is undefined.'};
}
vm.$timeout(function(){
attachPopover.call(vm);
}, 0);
};
ProposalListController.prototype.showContent = function (proposal) {
var vm = this;
vm.$state.go('programa', {
slug: proposal.parent.slug,
proposal_id: proposal.id
}, {
location: true,
reload: true
});
};
function attachPopover(){
var vm = this;
vm.popover = angular.element(vm.$element.find('.btn-question'));
vm.popover.popover({
html: true,
placement: 'bottom',
animation: true,
title: 'Regra de posição das propostas',
content: '<p>É calculada pelo saldo de interações das propostas (curtidas - não curtidas) dividido pela diferença de exibições entre elas.</p><p>O objetivo dessa correção é compensar o saldo de interações e a diferença de exibições das propostas que não tiveram muitas oportunidades de visualização ou das propostas que tiveram mais oportunidades de visualização que a média.</p><p>Com essa correção, é possível comparar propostas que entraram em diferentes momentos, durante todo o período da consulta.</p>'
});
}
var directive = {
restrict: 'E',
templateUrl: 'app/components/proposal-list/proposal-list.html',
scope: {
proposals: '='
},
controller: ProposalListController,
controllerAs: 'vm',
bindToController: true
};
return directive;
}
})();