Commit caf125e6f5d59729f44083f05f1cbaec88a2939c
1 parent
267f930e
Exists in
master
and in
6 other branches
Fixes #46
Showing
2 changed files
with
45 additions
and
1 deletions
Show diff stats
src/app/pages/duvidas/duvidas.controller.js
... | ... | @@ -6,16 +6,19 @@ |
6 | 6 | .controller('DuvidasPageController', DuvidasPageController); |
7 | 7 | |
8 | 8 | /** @ngInject */ |
9 | - function DuvidasPageController(DialogaService, $log) { | |
9 | + function DuvidasPageController(DialogaService, $interval, $window, $log) { | |
10 | 10 | $log.debug('DuvidasPageController'); |
11 | 11 | |
12 | 12 | var vm = this; |
13 | 13 | |
14 | 14 | vm.DialogaService = DialogaService; |
15 | + vm.$interval = $interval; | |
16 | + vm.$window = $window; | |
15 | 17 | vm.$log = $log; |
16 | 18 | |
17 | 19 | vm.init(); |
18 | 20 | vm.loadData(); |
21 | + vm.attachListeners(); | |
19 | 22 | } |
20 | 23 | |
21 | 24 | DuvidasPageController.prototype.init = function () { |
... | ... | @@ -29,14 +32,39 @@ |
29 | 32 | answer: 'Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven`t heard of them accusamus labore sustainable VHS.' |
30 | 33 | } |
31 | 34 | ]; |
35 | + | |
32 | 36 | vm.loading = true; |
33 | 37 | vm.error = false; |
38 | + vm.sendingContactForm = false; | |
39 | + | |
34 | 40 | }; |
35 | 41 | |
36 | 42 | DuvidasPageController.prototype.loadData = function () { |
37 | 43 | // var vm = this; |
38 | 44 | }; |
39 | 45 | |
46 | + DuvidasPageController.prototype.attachListeners = function () { | |
47 | + var vm = this; | |
48 | + | |
49 | + vm._attachCaptcha(); | |
50 | + }; | |
51 | + | |
52 | + DuvidasPageController.prototype._attachCaptcha = function() { | |
53 | + var vm = this; | |
54 | + | |
55 | + var stop = null; | |
56 | + stop = vm.$interval(function(){ | |
57 | + var $el = angular.element('#serpro_captcha'); | |
58 | + | |
59 | + if ($el && $el.length > 0 ){ | |
60 | + vm.$window.initCaptcha($el[0]); | |
61 | + vm.$interval.cancel(stop); | |
62 | + stop = undefined; | |
63 | + } | |
64 | + | |
65 | + }, 200); | |
66 | + }; | |
67 | + | |
40 | 68 | DuvidasPageController.prototype.submitContactForm = function ($event, contactForm) { |
41 | 69 | var vm = this; |
42 | 70 | |
... | ... | @@ -49,6 +77,11 @@ |
49 | 77 | subject: contactForm.inputSubject.$modelValue, |
50 | 78 | message: contactForm.inputMessage.$modelValue |
51 | 79 | }; |
80 | + | |
81 | + var target = $event.target; | |
82 | + var $target = angular.element(target); | |
83 | + var $captcha = $target.find('[name="txtToken_captcha_serpro_gov_br"]'); | |
84 | + data.txtToken_captcha_serpro_gov_br = $captcha.val(); | |
52 | 85 | |
53 | 86 | vm.DialogaService.sendContactForm(data) |
54 | 87 | .then(function(response){ | ... | ... |
src/app/pages/duvidas/duvidas.html
... | ... | @@ -75,9 +75,20 @@ |
75 | 75 | <textarea id="inputMessage" name="inputMessage" class="mensagem-text-area form-control light-input" ng-class="{ 'has-error' : contactForm.inputMessage.$invalid && contactForm.inputMessage.$touched }" ng-model="inputMessage" required ></textarea> |
76 | 76 | <validation-messages field="contactForm.inputMessage"></validation-messages> |
77 | 77 | </div> |
78 | + | |
78 | 79 | <span class="pull-left">*Dados obrigatórios</span> |
79 | 80 | <div class="row"> |
80 | 81 | <div class="col-sm-4 form-group pull-right"> |
82 | + | |
83 | + <div class="form-group"> | |
84 | + <div id="serpro_captcha" class="captcha"></div> | |
85 | + <div class="captcha">Digite os caracteres acima:</div> | |
86 | + <div class="captcha"> | |
87 | + <input type="text" name="captcha_text" id="captcha_text" aria-label="Escreva os caracteres do captcha aqui" ng-model="pageSignin.signup.captcha_text" ng-minlength="" ng-maxlength="" required> | |
88 | + <validation-messages field="contactForm.captcha_text"></validation-messages> | |
89 | + </div> | |
90 | + </div> | |
91 | + | |
81 | 92 | <div class="row" ng-show="pageDuvidas.sendingContactForm"> |
82 | 93 | <div class="col-sm-12"> |
83 | 94 | <div class="alert alert-info" role="alert">Enviando formulário...</div> | ... | ... |