diff --git a/app/scripts/app.coffee b/app/scripts/app.coffee index f10dd50..463f562 100644 --- a/app/scripts/app.coffee +++ b/app/scripts/app.coffee @@ -1,7 +1,7 @@ 'use strict' angular.module('slick', []) - .directive "slick", ($timeout) -> + .directive "slick", ($timeout,$compile) -> restrict: "AEC" scope: initOnload: "@" @@ -19,6 +19,7 @@ angular.module('slick', []) centerPadding: "@" cssEase: "@" customPaging: "&" + customPagingScope: '=' dots: "@" draggable: "@" easing: "@" @@ -65,7 +66,8 @@ angular.module('slick', []) currentIndex = scope.currentIndex if scope.currentIndex? customPaging = (slick, index) -> - scope.customPaging({ slick: slick, index: index }) + customPagingScope = scope.customPagingScope || scope; + $compile(scope.customPaging({ slick: slick, index: index }))(customPagingScope) slider.slick accessibility: scope.accessibility isnt "false" diff --git a/dist/slick.js b/dist/slick.js index e9da126..3fa3632 100644 --- a/dist/slick.js +++ b/dist/slick.js @@ -1,7 +1,8 @@ 'use strict'; angular.module('slick', []).directive('slick', [ '$timeout', - function ($timeout) { + '$compile', + function ($timeout, $compile) { return { restrict: 'AEC', scope: { @@ -20,6 +21,7 @@ angular.module('slick', []).directive('slick', [ centerPadding: '@', cssEase: '@', customPaging: '&', + customPagingScope: '=', dots: '@', draggable: '@', easing: '@', @@ -70,10 +72,12 @@ angular.module('slick', []).directive('slick', [ currentIndex = scope.currentIndex; } customPaging = function (slick, index) { - return scope.customPaging({ + var customPagingScope; + customPagingScope = scope.customPagingScope || scope; + return $compile(scope.customPaging({ slick: slick, index: index - }); + }))(customPagingScope); }; slider.slick({ accessibility: scope.accessibility !== 'false', diff --git a/dist/slick.min.js b/dist/slick.min.js index 0b74254..400b7ed 100644 --- a/dist/slick.min.js +++ b/dist/slick.min.js @@ -1,2 +1,2 @@ -/*! angular-slick v0.2.0 */ -"use strict";angular.module("slick",[]).directive("slick",["$timeout",function(a){return{restrict:"AEC",scope:{initOnload:"@",data:"=",currentIndex:"=",accessibility:"@",adaptiveHeight:"@",arrows:"@",asNavFor:"@",appendArrows:"@",appendDots:"@",autoplay:"@",autoplaySpeed:"@",centerMode:"@",centerPadding:"@",cssEase:"@",customPaging:"&",dots:"@",draggable:"@",easing:"@",fade:"@",focusOnSelect:"@",infinite:"@",initialSlide:"@",lazyLoad:"@",onBeforeChange:"&",onAfterChange:"&",onInit:"&",onReInit:"&",onSetPosition:"&",pauseOnHover:"@",pauseOnDotsHover:"@",responsive:"=",rtl:"@",slide:"@",slidesToShow:"@",slidesToScroll:"@",speed:"@",swipe:"@",swipeToSlide:"@",touchMove:"@",touchThreshold:"@",useCSS:"@",variableWidth:"@",vertical:"@",prevArrow:"@",nextArrow:"@"},link:function(b,c,d){var e,f,g;return e=function(){return a(function(){var a;return a=$(c),a.slick("unslick"),a.find(".slick-list").remove(),a})},f=function(){return a(function(){var a,e,f;return f=$(c),null!=b.currentIndex&&(a=b.currentIndex),e=function(a,c){return b.customPaging({slick:a,index:c})},f.slick({accessibility:"false"!==b.accessibility,adaptiveHeight:"true"===b.adaptiveHeight,arrows:"false"!==b.arrows,asNavFor:b.asNavFor?b.asNavFor:void 0,appendArrows:$(b.appendArrows?b.appendArrows:c),appendDots:$(b.appendDots?b.appendDots:c),autoplay:"true"===b.autoplay,autoplaySpeed:null!=b.autoplaySpeed?parseInt(b.autoplaySpeed,10):3e3,centerMode:"true"===b.centerMode,centerPadding:b.centerPadding||"50px",cssEase:b.cssEase||"ease",customPaging:d.customPaging?e:void 0,dots:"true"===b.dots,draggable:"false"!==b.draggable,easing:b.easing||"linear",fade:"true"===b.fade,focusOnSelect:"true"===b.focusOnSelect,infinite:"false"!==b.infinite,initialSlide:b.initialSlide||0,lazyLoad:b.lazyLoad||"ondemand",beforeChange:d.onBeforeChange?b.onBeforeChange:void 0,onReInit:d.onReInit?b.onReInit:void 0,onSetPosition:d.onSetPosition?b.onSetPosition:void 0,pauseOnHover:"false"!==b.pauseOnHover,responsive:b.responsive||void 0,rtl:"true"===b.rtl,slide:b.slide||"div",slidesToShow:null!=b.slidesToShow?parseInt(b.slidesToShow,10):1,slidesToScroll:null!=b.slidesToScroll?parseInt(b.slidesToScroll,10):1,speed:null!=b.speed?parseInt(b.speed,10):300,swipe:"false"!==b.swipe,swipeToSlide:"true"===b.swipeToSlide,touchMove:"false"!==b.touchMove,touchThreshold:b.touchThreshold?parseInt(b.touchThreshold,10):5,useCSS:"false"!==b.useCSS,variableWidth:"true"===b.variableWidth,vertical:"true"===b.vertical,prevArrow:b.prevArrow?$(b.prevArrow):void 0,nextArrow:b.nextArrow?$(b.nextArrow):void 0}),f.on("init",function(c){return d.onInit&&b.onInit(),null!=a?c.slideHandler(a):void 0}),f.on("afterChange",function(c,d,e){return b.onAfterChange&&b.onAfterChange(),null!=a?b.$apply(function(){return a=e,b.currentIndex=e}):void 0}),b.$watch("currentIndex",function(b){return null!=a&&null!=b&&b!==a?f.slick("slickGoTo",b):void 0})})},b.initOnload?(g=!1,b.$watch("data",function(a){return null!=a?(g&&e(),f(),g=!0):void 0})):f()}}}]); \ No newline at end of file +/*! angular-slick v0.2.1 */ +"use strict";angular.module("slick",[]).directive("slick",["$timeout","$compile",function(a,b){return{restrict:"AEC",scope:{initOnload:"@",data:"=",currentIndex:"=",accessibility:"@",adaptiveHeight:"@",arrows:"@",asNavFor:"@",appendArrows:"@",appendDots:"@",autoplay:"@",autoplaySpeed:"@",centerMode:"@",centerPadding:"@",cssEase:"@",customPaging:"&",customPagingScope:"=",dots:"@",draggable:"@",easing:"@",fade:"@",focusOnSelect:"@",infinite:"@",initialSlide:"@",lazyLoad:"@",onBeforeChange:"&",onAfterChange:"&",onInit:"&",onReInit:"&",onSetPosition:"&",pauseOnHover:"@",pauseOnDotsHover:"@",responsive:"=",rtl:"@",slide:"@",slidesToShow:"@",slidesToScroll:"@",speed:"@",swipe:"@",swipeToSlide:"@",touchMove:"@",touchThreshold:"@",useCSS:"@",variableWidth:"@",vertical:"@",prevArrow:"@",nextArrow:"@"},link:function(c,d,e){var f,g,h;return f=function(){return a(function(){var a;return a=$(d),a.slick("unslick"),a.find(".slick-list").remove(),a})},g=function(){return a(function(){var a,f,g;return g=$(d),null!=c.currentIndex&&(a=c.currentIndex),f=function(a,d){var e;return e=c.customPagingScope||c,b(c.customPaging({slick:a,index:d}))(e)},g.slick({accessibility:"false"!==c.accessibility,adaptiveHeight:"true"===c.adaptiveHeight,arrows:"false"!==c.arrows,asNavFor:c.asNavFor?c.asNavFor:void 0,appendArrows:c.appendArrows?$(c.appendArrows):$(d),appendDots:c.appendDots?$(c.appendDots):$(d),autoplay:"true"===c.autoplay,autoplaySpeed:null!=c.autoplaySpeed?parseInt(c.autoplaySpeed,10):3e3,centerMode:"true"===c.centerMode,centerPadding:c.centerPadding||"50px",cssEase:c.cssEase||"ease",customPaging:e.customPaging?f:void 0,dots:"true"===c.dots,draggable:"false"!==c.draggable,easing:c.easing||"linear",fade:"true"===c.fade,focusOnSelect:"true"===c.focusOnSelect,infinite:"false"!==c.infinite,initialSlide:c.initialSlide||0,lazyLoad:c.lazyLoad||"ondemand",beforeChange:e.onBeforeChange?c.onBeforeChange:void 0,onReInit:e.onReInit?c.onReInit:void 0,onSetPosition:e.onSetPosition?c.onSetPosition:void 0,pauseOnHover:"false"!==c.pauseOnHover,responsive:c.responsive||void 0,rtl:"true"===c.rtl,slide:c.slide||"div",slidesToShow:null!=c.slidesToShow?parseInt(c.slidesToShow,10):1,slidesToScroll:null!=c.slidesToScroll?parseInt(c.slidesToScroll,10):1,speed:null!=c.speed?parseInt(c.speed,10):300,swipe:"false"!==c.swipe,swipeToSlide:"true"===c.swipeToSlide,touchMove:"false"!==c.touchMove,touchThreshold:c.touchThreshold?parseInt(c.touchThreshold,10):5,useCSS:"false"!==c.useCSS,variableWidth:"true"===c.variableWidth,vertical:"true"===c.vertical,prevArrow:c.prevArrow?$(c.prevArrow):void 0,nextArrow:c.nextArrow?$(c.nextArrow):void 0}),g.on("init",function(b){return e.onInit&&c.onInit(),null!=a?b.slideHandler(a):void 0}),g.on("afterChange",function(b,d,e,f){return c.onAfterChange&&c.onAfterChange(),null!=a?c.$apply(function(){return a=e,c.currentIndex=e}):void 0}),c.$watch("currentIndex",function(b,c){return null!=a&&null!=b&&b!==a?g.slick("slickGoTo",b):void 0})})},c.initOnload?(h=!1,c.$watch("data",function(a,b){return null!=a?(h&&f(),g(),h=!0):void 0})):g()}}}]); \ No newline at end of file