-
Notifications
You must be signed in to change notification settings - Fork 233
Expand file tree
/
Copy pathapp.coffee
More file actions
142 lines (131 loc) · 4.88 KB
/
app.coffee
File metadata and controls
142 lines (131 loc) · 4.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
'use strict'
angular.module('slick', [])
.directive "slick", ($timeout) ->
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: (scope, element, attrs) ->
destroySlick = () ->
$timeout(() ->
slider = $(element)
slider.slick('unslick')
slider.find('.slick-list').remove()
slider
)
initializeSlick = () ->
$timeout(() ->
slider = $(element)
currentIndex = scope.currentIndex if scope.currentIndex?
customPaging = (slick, index) ->
scope.customPaging({ slick: slick, index: index })
slider.on 'init', (sl) ->
scope.onInit() if attrs.onInit
if currentIndex?
sl.slideHandler(currentIndex)
slider.slick
accessibility: scope.accessibility isnt "false"
adaptiveHeight: scope.adaptiveHeight is "true"
arrows: scope.arrows isnt "false"
asNavFor: if scope.asNavFor then scope.asNavFor else undefined
appendArrows: if scope.appendArrows then $(scope.appendArrows) else $(element)
appendDots: if scope.appendDots then $(scope.appendDots) else $(element)
autoplay: scope.autoplay is "true"
autoplaySpeed: if scope.autoplaySpeed? then parseInt(scope.autoplaySpeed, 10) else 3000
centerMode: scope.centerMode is "true"
centerPadding: scope.centerPadding or "50px"
cssEase: scope.cssEase or "ease"
customPaging: if attrs.customPaging then customPaging else undefined
dots: scope.dots is "true"
draggable: scope.draggable isnt "false"
easing: scope.easing or "linear"
fade: scope.fade is "true"
focusOnSelect: scope.focusOnSelect is "true"
infinite: scope.infinite isnt "false"
initialSlide:scope.initialSlide or 0
lazyLoad: scope.lazyLoad or "ondemand"
beforeChange: if attrs.onBeforeChange then scope.onBeforeChange else undefined
onReInit: if attrs.onReInit then scope.onReInit else undefined
onSetPosition: if attrs.onSetPosition then scope.onSetPosition else undefined
pauseOnHover: scope.pauseOnHover isnt "false"
responsive: scope.responsive or undefined
rtl: scope.rtl is "true"
slide: scope.slide or "div"
slidesToShow: if scope.slidesToShow? then parseInt(scope.slidesToShow, 10) else 1
slidesToScroll: if scope.slidesToScroll? then parseInt(scope.slidesToScroll, 10) else 1
speed: if scope.speed? then parseInt(scope.speed, 10) else 300
swipe: scope.swipe isnt "false"
swipeToSlide: scope.swipeToSlide is "true"
touchMove: scope.touchMove isnt "false"
touchThreshold: if scope.touchThreshold then parseInt(scope.touchThreshold, 10) else 5
useCSS: scope.useCSS isnt "false"
variableWidth: scope.variableWidth is "true"
vertical: scope.vertical is "true"
prevArrow: if scope.prevArrow then $(scope.prevArrow) else undefined
nextArrow: if scope.nextArrow then $(scope.nextArrow) else undefined
slider.on 'afterChange', (event, slick, currentSlide, nextSlide) ->
scope.onAfterChange() if scope.onAfterChange
if currentIndex?
scope.$apply(->
currentIndex = currentSlide
scope.currentIndex = currentSlide
)
scope.$watch("currentIndex", (newVal, oldVal) ->
if currentIndex? and newVal? and newVal != currentIndex
slider.slick('slickGoTo', newVal)
)
)
if scope.initOnload
isInitialized = false
scope.$watch("data", (newVal, oldVal) ->
if newVal?
if isInitialized
destroySlick()
initializeSlick()
isInitialized = true
)
else
initializeSlick()