Skip to content

Commit 95688d6

Browse files
committed
fix(slidebox): show-pager defaults to true
1 parent 73c3de6 commit 95688d6

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

Diff for: js/angular/directive/slideBox.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* @param {boolean=} does-continue Whether the slide box should loop.
3131
* @param {boolean=} auto-play Whether the slide box should automatically slide. Default true if does-continue is true.
3232
* @param {number=} slide-interval How many milliseconds to wait to change slides (if does-continue is true). Defaults to 4000.
33-
* @param {boolean=} show-pager Whether a pager should be shown for this slide box. Accepts expressions via `show-pager="{{shouldShow()}}"`.
33+
* @param {boolean=} show-pager Whether a pager should be shown for this slide box. Accepts expressions via `show-pager="{{shouldShow()}}"`. Defaults to true.
3434
* @param {expression=} pager-click Expression to call when a pager is clicked (if show-pager is true). Is passed the 'index' variable.
3535
* @param {expression=} on-slide-changed Expression called whenever the slide is changed. Is passed an '$index' variable.
3636
* @param {expression=} active-slide Model to bind the current slide to.
@@ -133,6 +133,12 @@ function($timeout, $compile, $ionicSlideBoxDelegate, $ionicHistory) {
133133
'</div>',
134134

135135
link: function($scope, $element, $attr, slideBoxCtrl) {
136+
// if showPager is undefined, show the pager
137+
if (!isDefined($attr.showPager)) {
138+
$scope.showPager = true;
139+
getPager().toggleClass('hide', !true);
140+
}
141+
136142
$attr.$observe('showPager', function(show) {
137143
show = $scope.$eval(show);
138144
getPager().toggleClass('hide', !show);

Diff for: test/unit/angular/directive/slideBox.unit.js

+37
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,41 @@ describe('ionSlideBox with active slide', function() {
7070
scope.$apply();
7171
expect($ionicSlideBoxDelegate.currentIndex()).toBe(2);
7272
}));
73+
it('Should create and show pager unless told not to', inject(function($rootScope, $compile, $timeout) {
74+
el = $compile('<ion-slide-box>' +
75+
'<ion-slide>' +
76+
'<div class="box blue">' +
77+
'<h1>BLUE {{slideBox.slideIndex}}</h1>' +
78+
'</div>' +
79+
'</ion-slide>' +
80+
'<ion-slide>' +
81+
'<div class="box yellow">' +
82+
'<h1>YELLOW {{slideBox.slideIndex}}</h1>' +
83+
'</div>' +
84+
'</ion-slide>' +
85+
'</ion-slide-box>')($rootScope.$new());
86+
87+
var scope = el.scope();
88+
scope.$apply();
89+
expect(el.find('.slider-pager').length).toBe(1);
90+
expect(el.find('.slider-pager.hide').length).toBe(0);
91+
}));
92+
it('Should create and show pager unless told not to', inject(function($rootScope, $compile, $timeout) {
93+
el = $compile('<ion-slide-box show-pager="false">' +
94+
'<ion-slide>' +
95+
'<div class="box blue">' +
96+
'<h1>BLUE {{slideBox.slideIndex}}</h1>' +
97+
'</div>' +
98+
'</ion-slide>' +
99+
'<ion-slide>' +
100+
'<div class="box yellow">' +
101+
'<h1>YELLOW {{slideBox.slideIndex}}</h1>' +
102+
'</div>' +
103+
'</ion-slide>' +
104+
'</ion-slide-box>')($rootScope.$new());
105+
106+
var scope = el.scope();
107+
scope.$apply();
108+
expect(el.find('.slider-pager.hide').length).toBe(1);
109+
}));
73110
});

0 commit comments

Comments
 (0)