Skip to content

Commit a8f2366

Browse files
committed
feat(slide-box): New slide box.
1 parent 4ef9be5 commit a8f2366

File tree

13 files changed

+4993
-8
lines changed

13 files changed

+4993
-8
lines changed

Diff for: .eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
js/views/slidesView.js

Diff for: config/build.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ module.exports = {
6060
'js/views/modalView.js',
6161
'js/views/sideMenuView.js',
6262
'js/views/sliderView.js',
63+
'js/views/slidesView.js',
6364
'js/views/toggleView.js'
6465
],
6566

Diff for: gulpfile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ gulp.task('eslint', function() {
141141
return gulp.src(['js/**/*.js'])
142142
.pipe(eslint())
143143
.pipe(eslint.format())
144-
.pipe(eslint.failOnError());
144+
.pipe(eslint.failAfterError());
145145
});
146146

147147
gulp.task('ddescribe-iit', function() {

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* @ngdoc directive
44
* @name ionSlideBox
55
* @module ionic
6+
* @deprecated will be removed in the next Ionic release in favor of the new ion-slides component.
7+
* Don't depend on the internal behavior of this widget.
68
* @delegate ionic.service:$ionicSlideBoxDelegate
79
* @restrict E
810
* @description
@@ -187,7 +189,7 @@ function($animate, $timeout, $compile, $ionicSlideBoxDelegate, $ionicHistory, $i
187189
.directive('ionSlide', function() {
188190
return {
189191
restrict: 'E',
190-
require: '^ionSlideBox',
192+
require: '?^ionSlideBox',
191193
compile: function(element) {
192194
element.addClass('slider-slide');
193195
}

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

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
2+
/**
3+
* @ngdoc directive
4+
* @name ionSlides
5+
* @module ionic
6+
* @delegate ionic.service:$ionicSlideBoxDelegate
7+
* @restrict E
8+
* @description
9+
* The Slides component is a powerful multi-page container where each page can be swiped or dragged between.
10+
*
11+
* Note: this is a new version of the Ionic Slide Box based on the [Swiper](http://www.idangero.us/swiper/#.Vmc1J-ODFBc) widget from
12+
* [idangerous](http://www.idangero.us/).
13+
*
14+
* ![SlideBox](http://ionicframework.com.s3.amazonaws.com/docs/controllers/slideBox.gif)
15+
*
16+
* @usage
17+
* ```html
18+
* <ion-slides on-slide-changed="slideHasChanged($index)">
19+
* <ion-slide>
20+
* <div class="box blue"><h1>BLUE</h1></div>
21+
* </ion-slide>
22+
* <ion-slide>
23+
* <div class="box yellow"><h1>YELLOW</h1></div>
24+
* </ion-slide>
25+
* <ion-slide>
26+
* <div class="box pink"><h1>PINK</h1></div>
27+
* </ion-slide>
28+
* </ion-slides>
29+
* ```
30+
*
31+
* @param {string=} delegate-handle The handle used to identify this slideBox
32+
* with {@link ionic.service:$ionicSlideBoxDelegate}.
33+
* @param {object=} options to pass to the widget. See the full ist here: [http://www.idangero.us/swiper/api/](http://www.idangero.us/swiper/api/)
34+
*/
35+
IonicModule
36+
.directive('ionSlides', [
37+
'$animate',
38+
'$timeout',
39+
function($animate, $timeout) {
40+
return {
41+
restrict: 'E',
42+
transclude: true,
43+
scope: {
44+
options: '='
45+
},
46+
template: '<div class="swiper-container">' +
47+
'<div class="swiper-wrapper" ng-transclude>' +
48+
'</div>' +
49+
'<div ng-hide="!showPager" class="swiper-pagination"></div>' +
50+
'</div>',
51+
controller: ['$scope', '$element', function($scope, $element) {
52+
var _this = this;
53+
54+
this.update = function() {
55+
$timeout(function() {
56+
_this.__slider.update();
57+
58+
// Don't allow pager to show with > 10 slides
59+
if (_this.__slider.slides.length > 10) {
60+
$scope.showPager = false;
61+
}
62+
});
63+
};
64+
65+
var options = $scope.options || {};
66+
67+
var newOptions = angular.extend({
68+
pagination: '.swiper-pagination',
69+
paginationClickable: true,
70+
lazyLoading: true,
71+
preloadImages: false
72+
}, options);
73+
74+
$timeout(function() {
75+
var slider = new ionic.views.Swiper($element.children()[0], newOptions);
76+
77+
_this.__slider = slider;
78+
79+
$scope.$on('$destroy', function() {
80+
slider.destroy();
81+
});
82+
});
83+
84+
}],
85+
86+
87+
link: function($scope, $element) {
88+
$scope.showPager = true;
89+
// Disable ngAnimate for slidebox and its children
90+
$animate.enabled(false, $element);
91+
}
92+
};
93+
}])
94+
.directive('ionSlidePage', [function() {
95+
return {
96+
restrict: 'E',
97+
require: '?^ionSlides',
98+
transclude: true,
99+
replace: true,
100+
template: '<div class="swiper-slide" ng-transclude></div>'
101+
};
102+
}]);

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

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* @ngdoc directive
3+
* @name ionTitle
4+
* @module ionic
5+
* @restrict E
6+
*
7+
* Used for titles in header and nav bars. New in 1.2
8+
*
9+
* Identical to <div class="title"> but with future compatibility for Ionic 2
10+
*
11+
* @usage
12+
*
13+
* ```html
14+
* <ion-nav-bar>
15+
* <ion-title>Hello</ion-title>
16+
* <ion-nav-bar>
17+
* ```
18+
*/
19+
IonicModule
20+
.directive('ionTitle', [function() {
21+
return {
22+
restrict: 'E',
23+
compile: function(element) {
24+
element.addClass('title');
25+
}
26+
};
27+
}]);

0 commit comments

Comments
 (0)