1
- ( function ( window , angular , undefined ) {
1
+ ( function ( window , angular ) {
2
2
3
3
'use strict' ;
4
4
21
21
return uuid ;
22
22
}
23
23
24
+ function swiperController ( $scope , $element , $timeout ) {
25
+ var uuid = createUUID ( ) ;
26
+
27
+ $scope . swiper_uuid = uuid ;
28
+
29
+ // directive defaults
30
+ var params = {
31
+ slidesPerView : $scope . slidesPerView || 1 ,
32
+ slidesPerColumn : $scope . slidesPerColumn || 1 ,
33
+ spaceBetween : $scope . spaceBetween || 0 ,
34
+ direction : $scope . direction || 'horizontal' ,
35
+ loop : $scope . loop || false ,
36
+ initialSlide : $scope . initialSlide || 0 ,
37
+ showNavButtons : false
38
+ } ;
39
+
40
+ if ( ! angular . isUndefined ( $scope . autoplay ) && typeof $scope . autoplay === 'number' ) {
41
+ params = angular . extend ( { } , params , {
42
+ autoplay : $scope . autoplay
43
+ } ) ;
44
+ }
45
+
46
+ if ( $scope . paginationIsActive === true ) {
47
+ params = angular . extend ( { } , params , {
48
+ paginationClickable : $scope . paginationClickable || true ,
49
+ pagination : '#paginator-' + $scope . swiper_uuid
50
+ } ) ;
51
+ }
52
+
53
+ if ( $scope . showNavButtons === true ) {
54
+ params . nextButton = '#nextButton-' + $scope . swiper_uuid ;
55
+ params . prevButton = '#prevButton-' + $scope . swiper_uuid ;
56
+ }
57
+
58
+ if ( $scope . showScrollBar === true ) {
59
+ params . scrollbar = '#scrollBar-' + $scope . swiper_uuid ;
60
+ }
61
+
62
+ if ( $scope . overrideParameters ) {
63
+ params = angular . extend ( { } , params , $scope . overrideParameters ) ;
64
+ }
65
+
66
+ $timeout ( function ( ) {
67
+ var swiper = null ;
68
+
69
+ if ( angular . isObject ( $scope . swiper ) ) {
70
+ $scope . swiper = new Swiper ( $element [ 0 ] . firstChild , params ) ;
71
+ swiper = $scope . swiper ;
72
+ } else {
73
+ swiper = new Swiper ( $element [ 0 ] . firstChild , params ) ;
74
+ }
75
+
76
+ //If specified, calls this function when the swiper object is available
77
+ if ( ! angular . isUndefined ( $scope . onReady ) ) {
78
+ $scope . onReady ( {
79
+ swiper : swiper
80
+ } ) ;
81
+ }
82
+ } ) ;
83
+ }
84
+ angularSwiperController . $inject = [ "$scope" , "$element" , "$timeout" ] ;
85
+
86
+
24
87
/* @ngInject */
25
88
function SwiperContainer ( ) {
26
89
return {
48
111
swiper : '=' ,
49
112
overrideParameters : '='
50
113
} ,
51
- controller : function ( $scope , $element , $timeout ) {
52
- var uuid = createUUID ( ) ;
53
-
54
- $scope . swiper_uuid = uuid ;
55
-
56
- // directive defaults
57
- var params = {
58
- slidesPerView : $scope . slidesPerView || 1 ,
59
- slidesPerColumn : $scope . slidesPerColumn || 1 ,
60
- spaceBetween : $scope . spaceBetween || 0 ,
61
- direction : $scope . direction || 'horizontal' ,
62
- loop : $scope . loop || false ,
63
- initialSlide : $scope . initialSlide || 0 ,
64
- showNavButtons : false
65
- } ;
66
-
67
- if ( ! angular . isUndefined ( $scope . autoplay ) && typeof $scope . autoplay === 'number' ) {
68
- params = angular . extend ( { } , params , {
69
- autoplay : $scope . autoplay
70
- } ) ;
71
- }
72
-
73
- if ( $scope . paginationIsActive === true ) {
74
- params = angular . extend ( { } , params , {
75
- paginationClickable : $scope . paginationClickable || true ,
76
- pagination : '#paginator-' + $scope . swiper_uuid
77
- } ) ;
78
- }
79
-
80
- if ( $scope . showNavButtons === true ) {
81
- params . nextButton = '#nextButton-' + $scope . swiper_uuid ;
82
- params . prevButton = '#prevButton-' + $scope . swiper_uuid ;
83
- }
84
-
85
- if ( $scope . showScrollBar === true ) {
86
- params . scrollbar = '#scrollBar-' + $scope . swiper_uuid ;
87
- }
88
-
89
- if ( $scope . overrideParameters ) {
90
- params = angular . extend ( { } , params , $scope . overrideParameters ) ;
91
- }
92
-
93
- $timeout ( function ( ) {
94
- var swiper = null ;
95
-
96
- if ( angular . isObject ( $scope . swiper ) ) {
97
- $scope . swiper = new Swiper ( $element [ 0 ] . firstChild , params ) ;
98
- swiper = $scope . swiper ;
99
- } else {
100
- swiper = new Swiper ( $element [ 0 ] . firstChild , params ) ;
101
- }
102
-
103
- //If specified, calls this function when the swiper object is available
104
- if ( ! angular . isUndefined ( $scope . onReady ) ) {
105
- $scope . onReady ( {
106
- swiper : swiper
107
- } ) ;
108
- }
109
- } ) ;
110
- } ,
111
-
114
+ controller : swiperController ,
112
115
link : function ( scope , element ) {
113
116
114
117
var uuid = scope . swiper_uuid ;
155
158
} ;
156
159
}
157
160
158
- } ) ( window , angular , undefined ) ;
161
+ } ) ( window , window . angular ) ;
0 commit comments