diff --git a/README.md b/README.md index 107f8c5..2afc36d 100644 --- a/README.md +++ b/README.md @@ -161,3 +161,10 @@ angular.module('swiperApp') }); ``` + + +## CHANGELOG +# 2016-May-04 (PRDeving) + * explicit injection + * argument 'window.angular' instead 'angular' + * removed argument 'undefined' -WTF??- diff --git a/dist/angular-swiper.js b/dist/angular-swiper.js index 9d086c4..dde266f 100644 --- a/dist/angular-swiper.js +++ b/dist/angular-swiper.js @@ -1 +1 @@ -!function(e,i,r){"use strict";function t(){for(var e=[],i="0123456789abcdef",r=0;36>r;r++)e[r]=i.substr(Math.floor(16*Math.random()),1);e[14]="4",e[19]=i.substr(3&e[19]|8,1),e[8]=e[13]=e[18]=e[23]="-";var t=e.join("");return t}function a(){return{restrict:"E",transclude:!0,scope:{onReady:"&",slidesPerView:"=",slidesPerColumn:"=",spaceBetween:"=",parallax:"=",parallaxTransition:"@",paginationIsActive:"=",paginationClickable:"=",showNavButtons:"=",showScrollBar:"=",loop:"=",autoplay:"=",initialSlide:"=",containerCls:"@",wrapperCls:"@",paginationCls:"@",slideCls:"@",direction:"@",swiper:"=",overrideParameters:"="},controller:["$scope","$element","$timeout",function(e,r,a){var n=t();e.swiper_uuid=n;var s={slidesPerView:e.slidesPerView||1,slidesPerColumn:e.slidesPerColumn||1,spaceBetween:e.spaceBetween||0,direction:e.direction||"horizontal",loop:e.loop||!1,initialSlide:e.initialSlide||0,showNavButtons:!1};i.isUndefined(e.autoplay)||"number"!=typeof e.autoplay||(s=i.extend({},s,{autoplay:e.autoplay})),e.paginationIsActive===!0&&(s=i.extend({},s,{paginationClickable:e.paginationClickable||!0,pagination:"#paginator-"+e.swiper_uuid})),e.showNavButtons===!0&&(s.nextButton="#nextButton-"+e.swiper_uuid,s.prevButton="#prevButton-"+e.swiper_uuid),e.showScrollBar===!0&&(s.scrollbar="#scrollBar-"+e.swiper_uuid),e.overrideParameters&&(s=i.extend({},s,e.overrideParameters)),a(function(){var t=null;i.isObject(e.swiper)?(e.swiper=new Swiper(r[0].firstChild,s),t=e.swiper):t=new Swiper(r[0].firstChild,s),i.isUndefined(e.onReady)||e.onReady({swiper:t})})}],link:function(e,r){var t=e.swiper_uuid,a="paginator-"+t,n="prevButton-"+t,s="nextButton-"+t,o="scrollBar-"+t,l=r[0];i.element(l.querySelector(".swiper-pagination")).attr("id",a),i.element(l.querySelector(".swiper-button-next")).attr("id",s),i.element(l.querySelector(".swiper-button-prev")).attr("id",n),i.element(r[0].querySelector(".swiper-scrollbar")).attr("id",o)},template:'
'}}function n(){return{restrict:"E",require:"^ksSwiperContainer",transclude:!0,template:'
',replace:!0}}i.module("ksSwiper",[]).directive("ksSwiperContainer",a).directive("ksSwiperSlide",n)}(window,angular,void 0); \ No newline at end of file +!function(e,i){"use strict";function r(){for(var e=[],i="0123456789abcdef",r=0;36>r;r++)e[r]=i.substr(Math.floor(16*Math.random()),1);e[14]="4",e[19]=i.substr(3&e[19]|8,1),e[8]=e[13]=e[18]=e[23]="-";var t=e.join("");return t}function t(e,t,a){var n=r();e.swiper_uuid=n;var s={slidesPerView:e.slidesPerView||1,slidesPerColumn:e.slidesPerColumn||1,spaceBetween:e.spaceBetween||0,direction:e.direction||"horizontal",loop:e.loop||!1,initialSlide:e.initialSlide||0,showNavButtons:!1};i.isUndefined(e.autoplay)||"number"!=typeof e.autoplay||(s=i.extend({},s,{autoplay:e.autoplay})),e.paginationIsActive===!0&&(s=i.extend({},s,{paginationClickable:e.paginationClickable||!0,pagination:"#paginator-"+e.swiper_uuid})),e.showNavButtons===!0&&(s.nextButton="#nextButton-"+e.swiper_uuid,s.prevButton="#prevButton-"+e.swiper_uuid),e.showScrollBar===!0&&(s.scrollbar="#scrollBar-"+e.swiper_uuid),e.overrideParameters&&(s=i.extend({},s,e.overrideParameters)),a(function(){var r=null;i.isObject(e.swiper)?(e.swiper=new Swiper(t[0].firstChild,s),r=e.swiper):r=new Swiper(t[0].firstChild,s),i.isUndefined(e.onReady)||e.onReady({swiper:r})})}function a(){return{restrict:"E",transclude:!0,scope:{onReady:"&",slidesPerView:"=",slidesPerColumn:"=",spaceBetween:"=",parallax:"=",parallaxTransition:"@",paginationIsActive:"=",paginationClickable:"=",showNavButtons:"=",showScrollBar:"=",loop:"=",autoplay:"=",initialSlide:"=",containerCls:"@",wrapperCls:"@",paginationCls:"@",slideCls:"@",direction:"@",swiper:"=",overrideParameters:"="},controller:t,link:function(e,r){var t=e.swiper_uuid,a="paginator-"+t,n="prevButton-"+t,s="nextButton-"+t,o="scrollBar-"+t,l=r[0];i.element(l.querySelector(".swiper-pagination")).attr("id",a),i.element(l.querySelector(".swiper-button-next")).attr("id",s),i.element(l.querySelector(".swiper-button-prev")).attr("id",n),i.element(r[0].querySelector(".swiper-scrollbar")).attr("id",o)},template:'
'}}function n(){return{restrict:"E",require:"^ksSwiperContainer",transclude:!0,template:'
',replace:!0}}i.module("ksSwiper",[]).directive("ksSwiperContainer",a).directive("ksSwiperSlide",n),t.$inject=["$scope","$element","$timeout"],angularSwiperController.$inject=["$scope","$element","$timeout"]}(window,window.angular); \ No newline at end of file diff --git a/src/angular-swiper.js b/src/angular-swiper.js index e57492e..93fdd18 100644 --- a/src/angular-swiper.js +++ b/src/angular-swiper.js @@ -1,4 +1,4 @@ -(function(window, angular, undefined) { +(function(window, angular) { 'use strict'; @@ -21,6 +21,69 @@ return uuid; } + function swiperController($scope, $element, $timeout) { + var uuid = createUUID(); + + $scope.swiper_uuid = uuid; + + // directive defaults + var params = { + slidesPerView: $scope.slidesPerView || 1, + slidesPerColumn: $scope.slidesPerColumn || 1, + spaceBetween: $scope.spaceBetween || 0, + direction: $scope.direction || 'horizontal', + loop: $scope.loop || false, + initialSlide: $scope.initialSlide || 0, + showNavButtons: false + }; + + if (!angular.isUndefined($scope.autoplay) && typeof $scope.autoplay === 'number') { + params = angular.extend({}, params, { + autoplay: $scope.autoplay + }); + } + + if ($scope.paginationIsActive === true) { + params = angular.extend({}, params, { + paginationClickable: $scope.paginationClickable || true, + pagination: '#paginator-' + $scope.swiper_uuid + }); + } + + if ($scope.showNavButtons === true) { + params.nextButton = '#nextButton-' + $scope.swiper_uuid; + params.prevButton = '#prevButton-' + $scope.swiper_uuid; + } + + if ($scope.showScrollBar === true) { + params.scrollbar = '#scrollBar-' + $scope.swiper_uuid; + } + + if ($scope.overrideParameters) { + params = angular.extend({}, params, $scope.overrideParameters); + } + + $timeout(function() { + var swiper = null; + + if (angular.isObject($scope.swiper)) { + $scope.swiper = new Swiper($element[0].firstChild, params); + swiper = $scope.swiper; + } else { + swiper = new Swiper($element[0].firstChild, params); + } + + //If specified, calls this function when the swiper object is available + if (!angular.isUndefined($scope.onReady)) { + $scope.onReady({ + swiper: swiper + }); + } + }); + } + angularSwiperController.$inject = ["$scope", "$element", "$timeout"]; + + /* @ngInject */ function SwiperContainer() { return { @@ -48,67 +111,7 @@ swiper: '=', overrideParameters: '=' }, - controller: function($scope, $element, $timeout) { - var uuid = createUUID(); - - $scope.swiper_uuid = uuid; - - // directive defaults - var params = { - slidesPerView: $scope.slidesPerView || 1, - slidesPerColumn: $scope.slidesPerColumn || 1, - spaceBetween: $scope.spaceBetween || 0, - direction: $scope.direction || 'horizontal', - loop: $scope.loop || false, - initialSlide: $scope.initialSlide || 0, - showNavButtons: false - }; - - if (!angular.isUndefined($scope.autoplay) && typeof $scope.autoplay === 'number') { - params = angular.extend({}, params, { - autoplay: $scope.autoplay - }); - } - - if ($scope.paginationIsActive === true) { - params = angular.extend({}, params, { - paginationClickable: $scope.paginationClickable || true, - pagination: '#paginator-' + $scope.swiper_uuid - }); - } - - if ($scope.showNavButtons === true) { - params.nextButton = '#nextButton-' + $scope.swiper_uuid; - params.prevButton = '#prevButton-' + $scope.swiper_uuid; - } - - if ($scope.showScrollBar === true) { - params.scrollbar = '#scrollBar-' + $scope.swiper_uuid; - } - - if ($scope.overrideParameters) { - params = angular.extend({}, params, $scope.overrideParameters); - } - - $timeout(function() { - var swiper = null; - - if (angular.isObject($scope.swiper)) { - $scope.swiper = new Swiper($element[0].firstChild, params); - swiper = $scope.swiper; - } else { - swiper = new Swiper($element[0].firstChild, params); - } - - //If specified, calls this function when the swiper object is available - if (!angular.isUndefined($scope.onReady)) { - $scope.onReady({ - swiper: swiper - }); - } - }); - }, - + controller: swiperController, link: function(scope, element) { var uuid = scope.swiper_uuid; @@ -155,4 +158,4 @@ }; } -})(window, angular, undefined); \ No newline at end of file +})(window, window.angular);