diff --git a/src/app/components/articleBar/articleBar.directive.js b/src/app/components/articleBar/articleBar.directive.js new file mode 100644 index 0000000..1cccf94 --- /dev/null +++ b/src/app/components/articleBar/articleBar.directive.js @@ -0,0 +1,68 @@ +(function() { + 'use strict'; + + angular + .module('dialoga') + .directive('articleBar', articleBar); + + /** @ngInject */ + function articleBar() { + var directive = { + restrict: 'E', + templateUrl: 'app/components/articleBar/articleBar.html', + scope: { + category: '=', + categories: '=' + }, + controller: ArticleBarController, + controllerAs: 'vm', + bindToController: true + }; + + return directive; + + /** @ngInject */ + function ArticleBarController($scope, $rootScope, $state, $log) { + $log.debug('ArticleBarController'); + + var vm = this; + + vm.$scope = $scope; + vm.$rootScope = $rootScope; + vm.$state = $state; + vm.theme = 'blue'; + + // if(!vm.category) { + // throw 'article bar without category'; + // } + + // if(!vm.categories) { + // throw 'article bar without categories list'; + // } + + vm.currentCategory = vm.category; + + vm.$scope.$watch('vm.currentCategory', function(newValue, oldValue){ + if(newValue !== oldValue){ + vm.$state.go('inicio', { + tema: newValue.slug + }, { + location: true + }); + } + }); + + vm.goBack = function (){ + var vm = this; + var prevState = vm.$rootScope.$previousState; + if(prevState && prevState.state.name){ + vm.$state.go(prevState.state.name, prevState.params); + } else { + vm.$state.go('inicio'); + } + }; + } + + } + +})(); diff --git a/src/app/components/articleBar/articleBar.html b/src/app/components/articleBar/articleBar.html new file mode 100644 index 0000000..e62b637 --- /dev/null +++ b/src/app/components/articleBar/articleBar.html @@ -0,0 +1,23 @@ +
+ diff --git a/src/app/components/articleBar/articleBar.scss b/src/app/components/articleBar/articleBar.scss new file mode 100644 index 0000000..99ddc70 --- /dev/null +++ b/src/app/components/articleBar/articleBar.scss @@ -0,0 +1,53 @@ +.article-bar { + position: relative; + background-color: #0042b1; + + .btn { + color: #fff; + font-weight: bold; + } + + &--item { + margin: 8px 0; + + @media (max-width: $screen-xs) { + margin: 8px; + } + + } + + &--category-button { + position: relative; + width: 125px; + text-align: right; + margin-left: 10px; + font-size: 24px; + line-height: 20px; + font-family: 'Open Sans'; + + .icon { + position: absolute; + top: -34px; + left: -34px; + transform: scale(.37); + } + } + + .navbar { + margin-bottom: 0; + } + + .navbar-right { + margin-right: 15px; + } + + @each $category, $color in $categories { + &.#{$category} { + background-color: $color; + } + } + + .contraste & { + background-color: #262626; + } +} diff --git a/src/app/components/programa/programa.directive.js b/src/app/components/programa/programa.directive.js index f4f6fa0..3dea1c9 100644 --- a/src/app/components/programa/programa.directive.js +++ b/src/app/components/programa/programa.directive.js @@ -9,11 +9,12 @@ function programaBox($rootScope) { /** @ngInject */ - function ProgramaController(ArticleService, $state, Slug, $log) { + function ProgramaController(ArticleService, $scope, $state, Slug, $log) { $log.debug('ProgramaController'); var vm = this; vm.ArticleService = ArticleService; + vm.$scope = $scope; vm.$state = $state; vm.Slug = Slug; vm.$log = $log; @@ -28,6 +29,17 @@ vm.program.slug = vm.Slug.slugify(vm.program.title); } + if(!vm.category){ + vm.category = vm.program.categories[0]; + } + + if(!vm.banner){ + vm.banner = { + src: $rootScope.basePath + vm.program.image.url, + alt: 'Imagem de destaque do programa' + }; + } + vm.displayType = vm.display; // if(vm.program.color && !vm.program.bgColor){ @@ -36,33 +48,6 @@ // } }; - ProgramaController.prototype.getCategory = function () { - var vm = this; - - return vm.program.categories[0]; - }; - - ProgramaController.prototype.getCategoryName = function () { - return this.getCategory().name; - }; - - ProgramaController.prototype.getCategorySlug = function () { - return this.getCategory().slug; - }; - - ProgramaController.prototype.getImageUrl = function () { - var vm = this; - - return $rootScope.basePath + vm.program.image.url; - }; - - ProgramaController.prototype.getImageAlt = function () { - var vm = this; - - vm.$log.warn('image is not accessible.'); - return 'TODO: create image alt on server-side.'; - }; - ProgramaController.prototype.isDisplay = function (display) { return this.display === display; }; @@ -75,10 +60,6 @@ return this.isDisplay('preview'); }; - ProgramaController.prototype.isDisplayContent = function () { - return this.isDisplay('content'); - }; - ProgramaController.prototype.showContent = function () { var vm = this; diff --git a/src/app/components/programa/programa.html b/src/app/components/programa/programa.html index 2a1f8bc..d959f9d 100644 --- a/src/app/components/programa/programa.html +++ b/src/app/components/programa/programa.html @@ -1,10 +1,10 @@ -