removed navigation when only once announcement is present

This commit is contained in:
Alex Wolfe 2016-10-14 20:26:02 -07:00 committed by Naomi Black
parent 3c6621bbf1
commit a44c5ea685
2 changed files with 6 additions and 4 deletions

View File

@ -8,6 +8,6 @@ header(class="background-sky l-relative")
announcement-bar announcement-bar
.announcement-bar-slide.clearfix .announcement-bar-slide.clearfix
img(src="/resources/images/logos/anglebrackets/anglebrackets.png") img(src="/resources/images/logos/anglebrackets/anglebrackets.png" width="64")
p Join us for <strong>Anglebrackets in Las Vegas</strong> Oct 25-28! p Join us for <strong>Anglebrackets in Las Vegas</strong> Oct 25-28!
a(href="https://anglebrackets.org/#!/" target="_blank" class="button md-button") Register now a(href="https://anglebrackets.org/#!/" target="_blank" class="button md-button") Register now

View File

@ -15,16 +15,18 @@ angularIO.directive('announcementBar', ['$interval', function($interval) {
replace: true, replace: true,
template: template:
'<div class="announcement-bar">' + '<div class="announcement-bar">' +
'<em>{{scope.slides.length}}</em>' +
'<div class="announcement-bar-slides" ng-transclude></div>' + '<div class="announcement-bar-slides" ng-transclude></div>' +
'<nav class="announcement-bar-nav">'+ '<nav class="announcement-bar-nav" ng-if="slides.length > 1">'+
'<button ng-class="{ selected: currentSlide === key }" ng-repeat="(key, slide) in slides" ng-click="changeSlide($event, key)">{{key}}</button>' + '<button ng-class="{ selected: currentSlide === key }" ng-repeat="(key, slide) in slides" ng-click="changeSlide($event, key)">{{key}}</button>' +
'</nav>' + '</nav>' +
'</div>', '</div>',
link: function(scope, element, attrs) { link: function(scope, element, attrs) {
// REGISTER ELEMENTS // REGISTER ELEMENTS
var $ctrl = this;
scope.slides = angular.element(element[0].getElementsByClassName('announcement-bar-slide')); scope.slides = angular.element(element[0].getElementsByClassName('announcement-bar-slide'));
var slideLenth = scope.slides.length; var slideLength = scope.slides.length;
// SHOW FIRST SLIDE // SHOW FIRST SLIDE
scope.currentSlide = 0; scope.currentSlide = 0;
@ -58,7 +60,7 @@ angularIO.directive('announcementBar', ['$interval', function($interval) {
scope.slides.removeClass('is-visible'); scope.slides.removeClass('is-visible');
// RESET ON LAST SLIDE // RESET ON LAST SLIDE
if((scope.currentSlide) > (slideLenth - 1)) { if((scope.currentSlide) > (slideLength - 1)) {
scope.currentSlide = 0; scope.currentSlide = 0;
} }