Commit 81a5c63f3d747ffbacbef1df1d0c67d074d3f743
1 parent
d9f417f7
Exists in
master
and in
8 other branches
Add: handle go-back at article-bar
Showing
4 changed files
with
25 additions
and
7 deletions
Show diff stats
src/app/components/programa/programa.html
| 1 | <div ng-if="vm.program"> | 1 | <div ng-if="vm.program"> |
| 2 | - <article ng-if="vm.isDisplayBox()" ng-click="vm.showContent()"> | ||
| 3 | - <div class="program-box {{::vm.getCategorySlug()}}"> | 2 | + <article class="program-box" ng-if="vm.isDisplayBox()" ng-click="vm.showContent()"> |
| 3 | + <div class="{{::vm.getCategorySlug()}}"> | ||
| 4 | <h2 class="program-box--category">{{::vm.getCategoryName()}}</h2> | 4 | <h2 class="program-box--category">{{::vm.getCategoryName()}}</h2> |
| 5 | <div class="program-box--image-wrapper"> | 5 | <div class="program-box--image-wrapper"> |
| 6 | <!-- <img class="program-box--image img-responsive" ng-src="{{::vm.getImageUrl()}}" alt="{{::vm.getImageAlt()}}" /> --> | 6 | <!-- <img class="program-box--image img-responsive" ng-src="{{::vm.getImageUrl()}}" alt="{{::vm.getImageAlt()}}" /> --> |
| @@ -18,7 +18,7 @@ | @@ -18,7 +18,7 @@ | ||
| 18 | </div> | 18 | </div> |
| 19 | </article> | 19 | </article> |
| 20 | 20 | ||
| 21 | - <article ng-if="vm.isDisplayPreview()"> | 21 | + <article ng-if="vm.isDisplayPreview()" class="program-preview"> |
| 22 | <header class="program-banner"> | 22 | <header class="program-banner"> |
| 23 | <img class="program-banner--image" ng-src="{{vm.getImageUrl()}}" alt="{{::vm.getImageAlt()}}"> | 23 | <img class="program-banner--image" ng-src="{{vm.getImageUrl()}}" alt="{{::vm.getImageAlt()}}"> |
| 24 | <div class="program-banner--strip"> | 24 | <div class="program-banner--strip"> |
src/app/components/programa/programa.scss
| @@ -4,7 +4,6 @@ $scale: 1.1; | @@ -4,7 +4,6 @@ $scale: 1.1; | ||
| 4 | $time: .2s; | 4 | $time: .2s; |
| 5 | $darken: 15%; | 5 | $darken: 15%; |
| 6 | 6 | ||
| 7 | -// sandbox | ||
| 8 | .program-box { | 7 | .program-box { |
| 9 | cursor: pointer; | 8 | cursor: pointer; |
| 10 | background-color: #fff; | 9 | background-color: #fff; |
| @@ -183,5 +182,10 @@ $darken: 15%; | @@ -183,5 +182,10 @@ $darken: 15%; | ||
| 183 | transform: scale($scale); | 182 | transform: scale($scale); |
| 184 | } | 183 | } |
| 185 | } | 184 | } |
| 185 | +} | ||
| 186 | 186 | ||
| 187 | +.program-preview { | ||
| 188 | + .program-banner { | ||
| 189 | + | ||
| 190 | + } | ||
| 187 | } | 191 | } |
src/app/index.run.js
| @@ -6,6 +6,7 @@ | @@ -6,6 +6,7 @@ | ||
| 6 | .module('dialoga') | 6 | .module('dialoga') |
| 7 | .run(runAuth) | 7 | .run(runAuth) |
| 8 | .run(runAccessibility) | 8 | .run(runAccessibility) |
| 9 | + .run(runHistory) | ||
| 9 | .run(runPath) | 10 | .run(runPath) |
| 10 | .run(runColorUtils) | 11 | .run(runColorUtils) |
| 11 | .run(runBlock); | 12 | .run(runBlock); |
| @@ -75,6 +76,13 @@ | @@ -75,6 +76,13 @@ | ||
| 75 | } | 76 | } |
| 76 | 77 | ||
| 77 | /** @ngInject */ | 78 | /** @ngInject */ |
| 79 | + function runHistory($rootScope, $log) { | ||
| 80 | + $rootScope.$on('$stateChangeSuccess', function(event, toState, toStateParams, fromState, fromStateParams) { | ||
| 81 | + $rootScope.$previousState = { state: fromState, params: fromStateParams}; | ||
| 82 | + }); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + /** @ngInject */ | ||
| 78 | function runPath($rootScope, api, $log) { | 86 | function runPath($rootScope, api, $log) { |
| 79 | var isProduction = (/^http:\/\/dialoga\.gov\.br\//.test(window.location.href)); | 87 | var isProduction = (/^http:\/\/dialoga\.gov\.br\//.test(window.location.href)); |
| 80 | $rootScope.basePath = isProduction ? api.hostProd : api.hostHom; | 88 | $rootScope.basePath = isProduction ? api.hostProd : api.hostHom; |
src/app/partials/programas/programa.controller.js
| @@ -6,15 +6,16 @@ | @@ -6,15 +6,16 @@ | ||
| 6 | .controller('ProgramaController', ProgramaController); | 6 | .controller('ProgramaController', ProgramaController); |
| 7 | 7 | ||
| 8 | /** @ngInject */ | 8 | /** @ngInject */ |
| 9 | - function ProgramaController(ArticleService, $state, $location, $scope, $log) { | 9 | + function ProgramaController(ArticleService, $state, $location, $scope, $rootScope, $log) { |
| 10 | $log.debug('ProgramaController'); | 10 | $log.debug('ProgramaController'); |
| 11 | 11 | ||
| 12 | var vm = this; | 12 | var vm = this; |
| 13 | 13 | ||
| 14 | vm.ArticleService = ArticleService; | 14 | vm.ArticleService = ArticleService; |
| 15 | - vm.$scope = $scope; | ||
| 16 | vm.$state = $state; | 15 | vm.$state = $state; |
| 17 | vm.$location = $location; | 16 | vm.$location = $location; |
| 17 | + vm.$scope = $scope; | ||
| 18 | + vm.$rootScope = $rootScope; | ||
| 18 | vm.$log = $log; | 19 | vm.$log = $log; |
| 19 | 20 | ||
| 20 | vm.init(); | 21 | vm.init(); |
| @@ -80,6 +81,11 @@ | @@ -80,6 +81,11 @@ | ||
| 80 | ProgramaController.prototype.goBack = function () { | 81 | ProgramaController.prototype.goBack = function () { |
| 81 | var vm = this; | 82 | var vm = this; |
| 82 | 83 | ||
| 83 | - vm.$log.warn('Not implemented yet!'); | 84 | + var prevState = vm.$rootScope.$previousState; |
| 85 | + if(prevState && prevState.state.name){ | ||
| 86 | + vm.$state.go(prevState.state.name, prevState.params); | ||
| 87 | + } else { | ||
| 88 | + vm.$state.go('inicio'); | ||
| 89 | + } | ||
| 84 | }; | 90 | }; |
| 85 | })(); | 91 | })(); |