FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
fork-QuantStack-quantstack.github.io/js/owl.navigation.js at master · AntoinePrv/fork-QuantStack-quantstack.github.io · GitHub
AntoinePrv
fork-QuantStack-quantstack.github.io
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
fork-QuantStack-quantstack.github.io
/
js
/
owl.navigation.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
406 lines (359 loc) · 10.9 KB
Breadcrumbs
fork-QuantStack-quantstack.github.io
/
js
/
owl.navigation.js
Copy path
File metadata and controls
executable file
·
406 lines (359 loc) · 10.9 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
/**
* Navigation Plugin
*
@version
2.3.4
*
@author
Artus Kolanowski
*
@author
David Deutsch
*
@license
The MIT License (MIT)
*/
;
(
function
(
$
,
window
,
document
,
undefined
)
{
'use strict'
;
/**
* Creates the navigation plugin.
*
@class
The Navigation Plugin
*
@param
{
Owl
} carousel - The Owl Carousel.
*/
var
Navigation
=
function
(
carousel
)
{
/**
* Reference to the core.
*
@protected
*
@type
{
Owl
}
*/
this
.
_core
=
carousel
;
/**
* Indicates whether the plugin is initialized or not.
*
@protected
*
@type
{
Boolean
}
*/
this
.
_initialized
=
false
;
/**
* The current paging indexes.
*
@protected
*
@type
{
Array
}
*/
this
.
_pages
=
[
]
;
/**
* All DOM elements of the user interface.
*
@protected
*
@type
{
Object
}
*/
this
.
_controls
=
{
}
;
/**
* Markup for an indicator.
*
@protected
*
@type
{
Array.<String>
}
*/
this
.
_templates
=
[
]
;
/**
* The carousel element.
*
@type
{
jQuery
}
*/
this
.
$element
=
this
.
_core
.
$element
;
/**
* Overridden methods of the carousel.
*
@protected
*
@type
{
Object
}
*/
this
.
_overrides
=
{
next
:
this
.
_core
.
next
,
prev
:
this
.
_core
.
prev
,
to
:
this
.
_core
.
to
}
;
/**
* All event handlers.
*
@protected
*
@type
{
Object
}
*/
this
.
_handlers
=
{
'prepared.owl.carousel'
:
$
.
proxy
(
function
(
e
)
{
if
(
e
.
namespace
&&
this
.
_core
.
settings
.
dotsData
)
{
this
.
_templates
.
push
(
'<div class="'
+
this
.
_core
.
settings
.
dotClass
+
'">'
+
$
(
e
.
content
)
.
find
(
'[data-dot]'
)
.
addBack
(
'[data-dot]'
)
.
attr
(
'data-dot'
)
+
'</div>'
)
;
}
}
,
this
)
,
'added.owl.carousel'
:
$
.
proxy
(
function
(
e
)
{
if
(
e
.
namespace
&&
this
.
_core
.
settings
.
dotsData
)
{
this
.
_templates
.
splice
(
e
.
position
,
0
,
this
.
_templates
.
pop
(
)
)
;
}
}
,
this
)
,
'remove.owl.carousel'
:
$
.
proxy
(
function
(
e
)
{
if
(
e
.
namespace
&&
this
.
_core
.
settings
.
dotsData
)
{
this
.
_templates
.
splice
(
e
.
position
,
1
)
;
}
}
,
this
)
,
'changed.owl.carousel'
:
$
.
proxy
(
function
(
e
)
{
if
(
e
.
namespace
&&
e
.
property
.
name
==
'position'
)
{
this
.
draw
(
)
;
}
}
,
this
)
,
'initialized.owl.carousel'
:
$
.
proxy
(
function
(
e
)
{
if
(
e
.
namespace
&&
!
this
.
_initialized
)
{
this
.
_core
.
trigger
(
'initialize'
,
null
,
'navigation'
)
;
this
.
initialize
(
)
;
this
.
update
(
)
;
this
.
draw
(
)
;
this
.
_initialized
=
true
;
this
.
_core
.
trigger
(
'initialized'
,
null
,
'navigation'
)
;
}
}
,
this
)
,
'refreshed.owl.carousel'
:
$
.
proxy
(
function
(
e
)
{
if
(
e
.
namespace
&&
this
.
_initialized
)
{
this
.
_core
.
trigger
(
'refresh'
,
null
,
'navigation'
)
;
this
.
update
(
)
;
this
.
draw
(
)
;
this
.
_core
.
trigger
(
'refreshed'
,
null
,
'navigation'
)
;
}
}
,
this
)
}
;
// set default options
this
.
_core
.
options
=
$
.
extend
(
{
}
,
Navigation
.
Defaults
,
this
.
_core
.
options
)
;
// register event handlers
this
.
$element
.
on
(
this
.
_handlers
)
;
}
;
/**
* Default options.
*
@public
*
@todo
Rename `slideBy` to `navBy`
*/
Navigation
.
Defaults
=
{
nav
:
false
,
navText
:
[
'<span aria-label="'
+
'Previous'
+
'">‹</span>'
,
'<span aria-label="'
+
'Next'
+
'">›</span>'
]
,
navSpeed
:
false
,
navElement
:
'button type="button" role="presentation"'
,
navContainer
:
false
,
navContainerClass
:
'owl-nav'
,
navClass
:
[
'owl-prev'
,
'owl-next'
]
,
slideBy
:
1
,
dotClass
:
'owl-dot'
,
dotsClass
:
'owl-dots'
,
dots
:
true
,
dotsEach
:
false
,
dotsData
:
false
,
dotsSpeed
:
false
,
dotsContainer
:
false
}
;
/**
* Initializes the layout of the plugin and extends the carousel.
*
@protected
*/
Navigation
.
prototype
.
initialize
=
function
(
)
{
var
override
,
settings
=
this
.
_core
.
settings
;
// create DOM structure for relative navigation
this
.
_controls
.
$relative
=
(
settings
.
navContainer
?
$
(
settings
.
navContainer
)
:
$
(
'<div>'
)
.
addClass
(
settings
.
navContainerClass
)
.
appendTo
(
this
.
$element
)
)
.
addClass
(
'disabled'
)
;
this
.
_controls
.
$previous
=
$
(
'<'
+
settings
.
navElement
+
'>'
)
.
addClass
(
settings
.
navClass
[
0
]
)
.
html
(
settings
.
navText
[
0
]
)
.
prependTo
(
this
.
_controls
.
$relative
)
.
on
(
'click'
,
$
.
proxy
(
function
(
e
)
{
this
.
prev
(
settings
.
navSpeed
)
;
}
,
this
)
)
;
this
.
_controls
.
$next
=
$
(
'<'
+
settings
.
navElement
+
'>'
)
.
addClass
(
settings
.
navClass
[
1
]
)
.
html
(
settings
.
navText
[
1
]
)
.
appendTo
(
this
.
_controls
.
$relative
)
.
on
(
'click'
,
$
.
proxy
(
function
(
e
)
{
this
.
next
(
settings
.
navSpeed
)
;
}
,
this
)
)
;
// create DOM structure for absolute navigation
if
(
!
settings
.
dotsData
)
{
this
.
_templates
=
[
$
(
'<button role="button">'
)
.
addClass
(
settings
.
dotClass
)
.
append
(
$
(
'<span>'
)
)
.
prop
(
'outerHTML'
)
]
;
}
this
.
_controls
.
$absolute
=
(
settings
.
dotsContainer
?
$
(
settings
.
dotsContainer
)
:
$
(
'<div>'
)
.
addClass
(
settings
.
dotsClass
)
.
appendTo
(
this
.
$element
)
)
.
addClass
(
'disabled'
)
;
this
.
_controls
.
$absolute
.
on
(
'click'
,
'button'
,
$
.
proxy
(
function
(
e
)
{
var
index
=
$
(
e
.
target
)
.
parent
(
)
.
is
(
this
.
_controls
.
$absolute
)
?
$
(
e
.
target
)
.
index
(
)
:
$
(
e
.
target
)
.
parent
(
)
.
index
(
)
;
e
.
preventDefault
(
)
;
this
.
to
(
index
,
settings
.
dotsSpeed
)
;
}
,
this
)
)
;
/*$el.on('focusin', function() {
$(document).off(".carousel");
$(document).on('keydown.carousel', function(e) {
if(e.keyCode == 37) {
$el.trigger('prev.owl')
}
if(e.keyCode == 39) {
$el.trigger('next.owl')
}
});
});*/
// override public methods of the carousel
for
(
override
in
this
.
_overrides
)
{
this
.
_core
[
override
]
=
$
.
proxy
(
this
[
override
]
,
this
)
;
}
}
;
/**
* Destroys the plugin.
*
@protected
*/
Navigation
.
prototype
.
destroy
=
function
(
)
{
var
handler
,
control
,
property
,
override
,
settings
;
settings
=
this
.
_core
.
settings
;
for
(
handler
in
this
.
_handlers
)
{
this
.
$element
.
off
(
handler
,
this
.
_handlers
[
handler
]
)
;
}
for
(
control
in
this
.
_controls
)
{
if
(
control
===
'$relative'
&&
settings
.
navContainer
)
{
this
.
_controls
[
control
]
.
html
(
''
)
;
}
else
{
this
.
_controls
[
control
]
.
remove
(
)
;
}
}
for
(
override
in
this
.
overides
)
{
this
.
_core
[
override
]
=
this
.
_overrides
[
override
]
;
}
for
(
property
in
Object
.
getOwnPropertyNames
(
this
)
)
{
typeof
this
[
property
]
!=
'function'
&&
(
this
[
property
]
=
null
)
;
}
}
;
/**
* Updates the internal state.
*
@protected
*/
Navigation
.
prototype
.
update
=
function
(
)
{
var
i
,
j
,
k
,
lower
=
this
.
_core
.
clones
(
)
.
length
/
2
,
upper
=
lower
+
this
.
_core
.
items
(
)
.
length
,
maximum
=
this
.
_core
.
maximum
(
true
)
,
settings
=
this
.
_core
.
settings
,
size
=
settings
.
center
||
settings
.
autoWidth
||
settings
.
dotsData
?
1
:
settings
.
dotsEach
||
settings
.
items
;
if
(
settings
.
slideBy
!==
'page'
)
{
settings
.
slideBy
=
Math
.
min
(
settings
.
slideBy
,
settings
.
items
)
;
}
if
(
settings
.
dots
||
settings
.
slideBy
==
'page'
)
{
this
.
_pages
=
[
]
;
for
(
i
=
lower
,
j
=
0
,
k
=
0
;
i
<
upper
;
i
++
)
{
if
(
j
>=
size
||
j
===
0
)
{
this
.
_pages
.
push
(
{
start
:
Math
.
min
(
maximum
,
i
-
lower
)
,
end
:
i
-
lower
+
size
-
1
}
)
;
if
(
Math
.
min
(
maximum
,
i
-
lower
)
===
maximum
)
{
break
;
}
j
=
0
,
++
k
;
}
j
+=
this
.
_core
.
mergers
(
this
.
_core
.
relative
(
i
)
)
;
}
}
}
;
/**
* Draws the user interface.
*
@todo
The option `dotsData` wont work.
*
@protected
*/
Navigation
.
prototype
.
draw
=
function
(
)
{
var
difference
,
settings
=
this
.
_core
.
settings
,
disabled
=
this
.
_core
.
items
(
)
.
length
<=
settings
.
items
,
index
=
this
.
_core
.
relative
(
this
.
_core
.
current
(
)
)
,
loop
=
settings
.
loop
||
settings
.
rewind
;
this
.
_controls
.
$relative
.
toggleClass
(
'disabled'
,
!
settings
.
nav
||
disabled
)
;
if
(
settings
.
nav
)
{
this
.
_controls
.
$previous
.
toggleClass
(
'disabled'
,
!
loop
&&
index
<=
this
.
_core
.
minimum
(
true
)
)
;
this
.
_controls
.
$next
.
toggleClass
(
'disabled'
,
!
loop
&&
index
>=
this
.
_core
.
maximum
(
true
)
)
;
}
this
.
_controls
.
$absolute
.
toggleClass
(
'disabled'
,
!
settings
.
dots
||
disabled
)
;
if
(
settings
.
dots
)
{
difference
=
this
.
_pages
.
length
-
this
.
_controls
.
$absolute
.
children
(
)
.
length
;
if
(
settings
.
dotsData
&&
difference
!==
0
)
{
this
.
_controls
.
$absolute
.
html
(
this
.
_templates
.
join
(
''
)
)
;
}
else
if
(
difference
>
0
)
{
this
.
_controls
.
$absolute
.
append
(
new
Array
(
difference
+
1
)
.
join
(
this
.
_templates
[
0
]
)
)
;
}
else
if
(
difference
<
0
)
{
this
.
_controls
.
$absolute
.
children
(
)
.
slice
(
difference
)
.
remove
(
)
;
}
this
.
_controls
.
$absolute
.
find
(
'.active'
)
.
removeClass
(
'active'
)
;
this
.
_controls
.
$absolute
.
children
(
)
.
eq
(
$
.
inArray
(
this
.
current
(
)
,
this
.
_pages
)
)
.
addClass
(
'active'
)
;
}
}
;
/**
* Extends event data.
*
@protected
*
@param
{
Event
} event - The event object which gets thrown.
*/
Navigation
.
prototype
.
onTrigger
=
function
(
event
)
{
var
settings
=
this
.
_core
.
settings
;
event
.
page
=
{
index
:
$
.
inArray
(
this
.
current
(
)
,
this
.
_pages
)
,
count
:
this
.
_pages
.
length
,
size
:
settings
&&
(
settings
.
center
||
settings
.
autoWidth
||
settings
.
dotsData
?
1
:
settings
.
dotsEach
||
settings
.
items
)
}
;
}
;
/**
* Gets the current page position of the carousel.
*
@protected
*
@returns
{
Number
}
*/
Navigation
.
prototype
.
current
=
function
(
)
{
var
current
=
this
.
_core
.
relative
(
this
.
_core
.
current
(
)
)
;
return
$
.
grep
(
this
.
_pages
,
$
.
proxy
(
function
(
page
,
index
)
{
return
page
.
start
<=
current
&&
page
.
end
>=
current
;
}
,
this
)
)
.
pop
(
)
;
}
;
/**
* Gets the current succesor/predecessor position.
*
@protected
*
@returns
{
Number
}
*/
Navigation
.
prototype
.
getPosition
=
function
(
successor
)
{
var
position
,
length
,
settings
=
this
.
_core
.
settings
;
if
(
settings
.
slideBy
==
'page'
)
{
position
=
$
.
inArray
(
this
.
current
(
)
,
this
.
_pages
)
;
length
=
this
.
_pages
.
length
;
successor
?
++
position
:
--
position
;
position
=
this
.
_pages
[
(
(
position
%
length
)
+
length
)
%
length
]
.
start
;
}
else
{
position
=
this
.
_core
.
relative
(
this
.
_core
.
current
(
)
)
;
length
=
this
.
_core
.
items
(
)
.
length
;
successor
?
position
+=
settings
.
slideBy
:
position
-=
settings
.
slideBy
;
}
return
position
;
}
;
/**
* Slides to the next item or page.
*
@public
*
@param
{
Number
} [speed=false] - The time in milliseconds for the transition.
*/
Navigation
.
prototype
.
next
=
function
(
speed
)
{
$
.
proxy
(
this
.
_overrides
.
to
,
this
.
_core
)
(
this
.
getPosition
(
true
)
,
speed
)
;
}
;
/**
* Slides to the previous item or page.
*
@public
*
@param
{
Number
} [speed=false] - The time in milliseconds for the transition.
*/
Navigation
.
prototype
.
prev
=
function
(
speed
)
{
$
.
proxy
(
this
.
_overrides
.
to
,
this
.
_core
)
(
this
.
getPosition
(
false
)
,
speed
)
;
}
;
/**
* Slides to the specified item or page.
*
@public
*
@param
{
Number
} position - The position of the item or page.
*
@param
{
Number
} [speed] - The time in milliseconds for the transition.
*
@param
{
Boolean
} [standard=false] - Whether to use the standard behaviour or not.
*/
Navigation
.
prototype
.
to
=
function
(
position
,
speed
,
standard
)
{
var
length
;
if
(
!
standard
&&
this
.
_pages
.
length
)
{
length
=
this
.
_pages
.
length
;
$
.
proxy
(
this
.
_overrides
.
to
,
this
.
_core
)
(
this
.
_pages
[
(
(
position
%
length
)
+
length
)
%
length
]
.
start
,
speed
)
;
}
else
{
$
.
proxy
(
this
.
_overrides
.
to
,
this
.
_core
)
(
position
,
speed
)
;
}
}
;
$
.
fn
.
owlCarousel
.
Constructor
.
Plugins
.
Navigation
=
Navigation
;
}
)
(
window
.
Zepto
||
window
.
jQuery
,
window
,
document
)
;
Back
|
FazBrowse Home
|
New Git URL