Commit 5fb246689031b6e0362747f9718709f59c59bc98
1 parent
c89da349
Exists in
master
and in
8 other branches
Add contrast handler (with )
Showing
3 changed files
with
19 additions
and
18 deletions
Show diff stats
src/app/index.run.js
@@ -8,10 +8,23 @@ | @@ -8,10 +8,23 @@ | ||
8 | .run(runBlock); | 8 | .run(runBlock); |
9 | 9 | ||
10 | /** @ngInject */ | 10 | /** @ngInject */ |
11 | - function handleAccessibility($rootScope, $timeout, $log) { | ||
12 | - | 11 | + function handleAccessibility($rootScope, $timeout, $cookies, $log) { |
13 | $log.debug('handleAccessibility'); | 12 | $log.debug('handleAccessibility'); |
14 | 13 | ||
14 | + var contrast = $cookies.get('dialoga_contraste'); | ||
15 | + adjustContrast(contrast); | ||
16 | + | ||
17 | + function adjustContrast(state){ | ||
18 | + var bodyEl = angular.element(document).find('body'); | ||
19 | + angular.element(bodyEl).toggleClass('contraste', !!state); | ||
20 | + } | ||
21 | + | ||
22 | + $rootScope.toggleContrast = function () { | ||
23 | + contrast = !contrast; | ||
24 | + $cookies.put('dialoga_contraste', contrast); | ||
25 | + adjustContrast(contrast); | ||
26 | + }; | ||
27 | + | ||
15 | $rootScope.focusMainContent = function ($event) { | 28 | $rootScope.focusMainContent = function ($event) { |
16 | 29 | ||
17 | // prevent skip link from redirecting | 30 | // prevent skip link from redirecting |
@@ -31,8 +44,7 @@ | @@ -31,8 +44,7 @@ | ||
31 | 44 | ||
32 | /** @ngInject */ | 45 | /** @ngInject */ |
33 | function runBlock($log) { | 46 | function runBlock($log) { |
34 | - | ||
35 | - $log.debug('runBlock end'); | 47 | + $log.debug('runBlock'); |
36 | } | 48 | } |
37 | 49 | ||
38 | })(); | 50 | })(); |
src/app/partials/header/header.controller.js
@@ -6,22 +6,11 @@ | @@ -6,22 +6,11 @@ | ||
6 | .controller('HeaderController', HeaderController); | 6 | .controller('HeaderController', HeaderController); |
7 | 7 | ||
8 | /** @ngInject */ | 8 | /** @ngInject */ |
9 | - function HeaderController($timeout, $log) { | ||
10 | - $log.debug('HeaderController'); | ||
11 | - | 9 | + function HeaderController($log) { |
12 | var vm = this; | 10 | var vm = this; |
13 | 11 | ||
14 | - vm.$timeout = $timeout; | ||
15 | vm.$log = $log; | 12 | vm.$log = $log; |
16 | - | ||
17 | - vm.contrast = false; | 13 | + vm.$log.debug('HeaderController'); |
18 | } | 14 | } |
19 | 15 | ||
20 | - HeaderController.prototype.toggleContrast = function () { | ||
21 | - var vm = this; | ||
22 | - | ||
23 | - vm.contrast = !vm.contrast; | ||
24 | - vm.$log.debug('contrast', vm.contrast); | ||
25 | - }; | ||
26 | - | ||
27 | })(); | 16 | })(); |
src/app/partials/header/header.html
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | 2 | ||
3 | <div class="row"> | 3 | <div class="row"> |
4 | <div class="accessibility-wrapper"> | 4 | <div class="accessibility-wrapper"> |
5 | - <button type="button" id="display-contrast" class="btn btn-link" ng-click="header.toggleContrast()"> | 5 | + <button type="button" id="display-contrast" class="btn btn-link" ng-click="toggleContrast()"> |
6 | <span class="glyphicon glyphicon-adjust" aria-hidden="true"></span> Alto Contraste | 6 | <span class="glyphicon glyphicon-adjust" aria-hidden="true"></span> Alto Contraste |
7 | </button> | 7 | </button> |
8 | </div> | 8 | </div> |