sinatra-hexacta 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/sinatra/handlers/errors.rb +23 -0
- data/lib/sinatra/handlers/init.rb +3 -0
- data/lib/sinatra/handlers/notifications.rb +74 -0
- data/lib/sinatra/handlers/reports.rb +1 -0
- data/lib/sinatra/helpers/charts.rb +15 -0
- data/lib/sinatra/helpers/init.rb +5 -0
- data/lib/sinatra/helpers/inputs.rb +47 -0
- data/lib/sinatra/helpers/libraries.rb +25 -0
- data/lib/sinatra/helpers/subscriptions.rb +44 -0
- data/lib/sinatra/hexacta.rb +32 -0
- data/lib/sinatra/public/css/app.min.1.css +16231 -0
- data/lib/sinatra/public/css/app.min.2.css +3341 -0
- data/lib/sinatra/public/css/shell.css +65 -0
- data/lib/sinatra/public/fonts/montserrat/Montserrat-Black.otf +0 -0
- data/lib/sinatra/public/fonts/montserrat/Montserrat-ExtraLight.otf +0 -0
- data/lib/sinatra/public/fonts/montserrat/Montserrat-Light.otf +0 -0
- data/lib/sinatra/public/fonts/montserrat/Montserrat-SemiBold.otf +0 -0
- data/lib/sinatra/public/fonts/roboto/Roboto-Bold-webfont.eot +0 -0
- data/lib/sinatra/public/fonts/roboto/Roboto-Bold-webfont.svg +593 -0
- data/lib/sinatra/public/fonts/roboto/Roboto-Bold-webfont.ttf +0 -0
- data/lib/sinatra/public/fonts/roboto/Roboto-Bold-webfont.woff +0 -0
- data/lib/sinatra/public/fonts/roboto/Roboto-Light-webfont.eot +0 -0
- data/lib/sinatra/public/fonts/roboto/Roboto-Light-webfont.svg +641 -0
- data/lib/sinatra/public/fonts/roboto/Roboto-Light-webfont.ttf +0 -0
- data/lib/sinatra/public/fonts/roboto/Roboto-Light-webfont.woff +0 -0
- data/lib/sinatra/public/fonts/roboto/Roboto-Medium-webfont.eot +0 -0
- data/lib/sinatra/public/fonts/roboto/Roboto-Medium-webfont.svg +593 -0
- data/lib/sinatra/public/fonts/roboto/Roboto-Medium-webfont.ttf +0 -0
- data/lib/sinatra/public/fonts/roboto/Roboto-Medium-webfont.woff +0 -0
- data/lib/sinatra/public/fonts/roboto/Roboto-Regular-webfont.eot +0 -0
- data/lib/sinatra/public/fonts/roboto/Roboto-Regular-webfont.svg +621 -0
- data/lib/sinatra/public/fonts/roboto/Roboto-Regular-webfont.ttf +0 -0
- data/lib/sinatra/public/fonts/roboto/Roboto-Regular-webfont.woff +0 -0
- data/lib/sinatra/public/fonts/roboto/Roboto-Thin-webfont.eot +0 -0
- data/lib/sinatra/public/fonts/roboto/Roboto-Thin-webfont.svg +631 -0
- data/lib/sinatra/public/fonts/roboto/Roboto-Thin-webfont.ttf +0 -0
- data/lib/sinatra/public/fonts/roboto/Roboto-Thin-webfont.woff +0 -0
- data/lib/sinatra/public/img/select.png +0 -0
- data/lib/sinatra/public/img/select@2x.png +0 -0
- data/lib/sinatra/public/js/app.js +794 -0
- data/lib/sinatra/public/js/form_validator.js +29 -0
- data/lib/sinatra/public/vendors/animate.css/animate.min.css +7 -0
- data/lib/sinatra/public/vendors/bootstrap-validator/validator.js +405 -0
- data/lib/sinatra/public/vendors/bootstrap/bootstrap.min.js +7 -0
- data/lib/sinatra/public/vendors/chartist/chartist.min.css +1 -0
- data/lib/sinatra/public/vendors/chartist/chartist.min.js +10 -0
- data/lib/sinatra/public/vendors/chosen/chosen-sprite.png +0 -0
- data/lib/sinatra/public/vendors/chosen/chosen-sprite@2x.png +0 -0
- data/lib/sinatra/public/vendors/chosen/chosen.jquery.min.js +3 -0
- data/lib/sinatra/public/vendors/chosen/chosen.min.css +11 -0
- data/lib/sinatra/public/vendors/eonasdan-bootstrap-datetimepicker/bootstrap-datetimepicker.js +2051 -0
- data/lib/sinatra/public/vendors/eonasdan-bootstrap-datetimepicker/bootstrap-datetimepicker.min.css +5 -0
- data/lib/sinatra/public/vendors/jquery/jquery.min.js +5 -0
- data/lib/sinatra/public/vendors/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js +5 -0
- data/lib/sinatra/public/vendors/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.css +1267 -0
- data/lib/sinatra/public/vendors/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.js +2370 -0
- data/lib/sinatra/public/vendors/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.min.css +1 -0
- data/lib/sinatra/public/vendors/malihu-custom-scrollbar-plugin/mCSB_buttons.png +0 -0
- data/lib/sinatra/public/vendors/material-design-iconic-font/css/material-design-iconic-font.css +5166 -0
- data/lib/sinatra/public/vendors/material-design-iconic-font/css/material-design-iconic-font.min.css +1 -0
- data/lib/sinatra/public/vendors/material-design-iconic-font/fonts/Material-Design-Iconic-Font.eot +0 -0
- data/lib/sinatra/public/vendors/material-design-iconic-font/fonts/Material-Design-Iconic-Font.svg +787 -0
- data/lib/sinatra/public/vendors/material-design-iconic-font/fonts/Material-Design-Iconic-Font.ttf +0 -0
- data/lib/sinatra/public/vendors/material-design-iconic-font/fonts/Material-Design-Iconic-Font.woff +0 -0
- data/lib/sinatra/public/vendors/material-design-iconic-font/fonts/Material-Design-Iconic-Font.woff2 +0 -0
- data/lib/sinatra/public/vendors/moment/moment.min.js +7 -0
- data/lib/sinatra/public/vendors/typeahead.js/bloodhound.min.js +7 -0
- data/lib/sinatra/public/vendors/typeahead.js/handlebars.js +2610 -0
- data/lib/sinatra/public/vendors/typeahead.js/typeahead.bundle.min.js +8 -0
- data/lib/sinatra/public/vendors/waves/waves.min.css +8 -0
- data/lib/sinatra/public/vendors/waves/waves.min.js +10 -0
- data/lib/sinatra/views/charts/simple_line.slim +36 -0
- data/lib/sinatra/views/errors/403.slim +9 -0
- data/lib/sinatra/views/errors/404.slim +27 -0
- data/lib/sinatra/views/errors/500.slim +24 -0
- data/lib/sinatra/views/inputs/date.slim +12 -0
- data/lib/sinatra/views/inputs/input.slim +18 -0
- data/lib/sinatra/views/inputs/month.slim +13 -0
- data/lib/sinatra/views/inputs/multiple_select.slim +27 -0
- data/lib/sinatra/views/inputs/radio.slim +8 -0
- data/lib/sinatra/views/inputs/select.slim +26 -0
- data/lib/sinatra/views/inputs/textarea.slim +14 -0
- data/lib/sinatra/views/inputs/tick.slim +8 -0
- data/lib/sinatra/views/inputs/year.slim +12 -0
- data/lib/sinatra/views/libraries/include_css.slim +28 -0
- data/lib/sinatra/views/libraries/include_js_after.slim +53 -0
- data/lib/sinatra/views/libraries/include_js_before.slim +7 -0
- data/lib/sinatra/views/notifications.slim +98 -0
- data/lib/sinatra/views/notifications/form.slim +41 -0
- data/lib/sinatra/views/notifications/item.slim +11 -0
- data/lib/sinatra/views/notifications/modal.slim +29 -0
- data/lib/sinatra/views/notifications/new.slim +21 -0
- data/lib/sinatra/views/notifications/view.slim +80 -0
- data/lib/sinatra/views/notifications/widget.slim +33 -0
- metadata +136 -0
@@ -0,0 +1,2370 @@
|
|
1
|
+
/*
|
2
|
+
== malihu jquery custom scrollbar plugin ==
|
3
|
+
Version: 3.1.0
|
4
|
+
Plugin URI: http://manos.malihu.gr/jquery-custom-content-scroller
|
5
|
+
Author: malihu
|
6
|
+
Author URI: http://manos.malihu.gr
|
7
|
+
License: MIT License (MIT)
|
8
|
+
*/
|
9
|
+
|
10
|
+
/*
|
11
|
+
Copyright 2010 Manos Malihutsakis (email: manos@malihu.gr)
|
12
|
+
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
14
|
+
of this software and associated documentation files (the "Software"), to deal
|
15
|
+
in the Software without restriction, including without limitation the rights
|
16
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
17
|
+
copies of the Software, and to permit persons to whom the Software is
|
18
|
+
furnished to do so, subject to the following conditions:
|
19
|
+
|
20
|
+
The above copyright notice and this permission notice shall be included in
|
21
|
+
all copies or substantial portions of the Software.
|
22
|
+
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
24
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
26
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
27
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
28
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
29
|
+
THE SOFTWARE.
|
30
|
+
*/
|
31
|
+
|
32
|
+
/*
|
33
|
+
The code below is fairly long, fully commented and should be normally used in development.
|
34
|
+
For production, use either the minified jquery.mCustomScrollbar.min.js script or
|
35
|
+
the production-ready jquery.mCustomScrollbar.concat.min.js which contains the plugin
|
36
|
+
and dependencies (minified).
|
37
|
+
*/
|
38
|
+
|
39
|
+
(function(factory){
|
40
|
+
if(typeof module!=="undefined" && module.exports){
|
41
|
+
module.exports=factory;
|
42
|
+
}else{
|
43
|
+
factory(jQuery,window,document);
|
44
|
+
}
|
45
|
+
}(function($){
|
46
|
+
(function(init){
|
47
|
+
var _rjs=typeof define==="function" && define.amd, /* RequireJS */
|
48
|
+
_njs=typeof module !== "undefined" && module.exports, /* NodeJS */
|
49
|
+
_dlp=("https:"==document.location.protocol) ? "https:" : "http:", /* location protocol */
|
50
|
+
_url="cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js";
|
51
|
+
if(!_rjs){
|
52
|
+
if(_njs){
|
53
|
+
require("jquery-mousewheel")($);
|
54
|
+
}else{
|
55
|
+
/* load jquery-mousewheel plugin (via CDN) if it's not present or not loaded via RequireJS
|
56
|
+
(works when mCustomScrollbar fn is called on window load) */
|
57
|
+
$.event.special.mousewheel || $("head").append(decodeURI("%3Cscript src="+_dlp+"//"+_url+"%3E%3C/script%3E"));
|
58
|
+
}
|
59
|
+
}
|
60
|
+
init();
|
61
|
+
}(function(){
|
62
|
+
|
63
|
+
/*
|
64
|
+
----------------------------------------
|
65
|
+
PLUGIN NAMESPACE, PREFIX, DEFAULT SELECTOR(S)
|
66
|
+
----------------------------------------
|
67
|
+
*/
|
68
|
+
|
69
|
+
var pluginNS="mCustomScrollbar",
|
70
|
+
pluginPfx="mCS",
|
71
|
+
defaultSelector=".mCustomScrollbar",
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
/*
|
78
|
+
----------------------------------------
|
79
|
+
DEFAULT OPTIONS
|
80
|
+
----------------------------------------
|
81
|
+
*/
|
82
|
+
|
83
|
+
defaults={
|
84
|
+
/*
|
85
|
+
set element/content width/height programmatically
|
86
|
+
values: boolean, pixels, percentage
|
87
|
+
option default
|
88
|
+
-------------------------------------
|
89
|
+
setWidth false
|
90
|
+
setHeight false
|
91
|
+
*/
|
92
|
+
/*
|
93
|
+
set the initial css top property of content
|
94
|
+
values: string (e.g. "-100px", "10%" etc.)
|
95
|
+
*/
|
96
|
+
setTop:0,
|
97
|
+
/*
|
98
|
+
set the initial css left property of content
|
99
|
+
values: string (e.g. "-100px", "10%" etc.)
|
100
|
+
*/
|
101
|
+
setLeft:0,
|
102
|
+
/*
|
103
|
+
scrollbar axis (vertical and/or horizontal scrollbars)
|
104
|
+
values (string): "y", "x", "yx"
|
105
|
+
*/
|
106
|
+
axis:"y",
|
107
|
+
/*
|
108
|
+
position of scrollbar relative to content
|
109
|
+
values (string): "inside", "outside" ("outside" requires elements with position:relative)
|
110
|
+
*/
|
111
|
+
scrollbarPosition:"inside",
|
112
|
+
/*
|
113
|
+
scrolling inertia
|
114
|
+
values: integer (milliseconds)
|
115
|
+
*/
|
116
|
+
scrollInertia:950,
|
117
|
+
/*
|
118
|
+
auto-adjust scrollbar dragger length
|
119
|
+
values: boolean
|
120
|
+
*/
|
121
|
+
autoDraggerLength:true,
|
122
|
+
/*
|
123
|
+
auto-hide scrollbar when idle
|
124
|
+
values: boolean
|
125
|
+
option default
|
126
|
+
-------------------------------------
|
127
|
+
autoHideScrollbar false
|
128
|
+
*/
|
129
|
+
/*
|
130
|
+
auto-expands scrollbar on mouse-over and dragging
|
131
|
+
values: boolean
|
132
|
+
option default
|
133
|
+
-------------------------------------
|
134
|
+
autoExpandScrollbar false
|
135
|
+
*/
|
136
|
+
/*
|
137
|
+
always show scrollbar, even when there's nothing to scroll
|
138
|
+
values: integer (0=disable, 1=always show dragger rail and buttons, 2=always show dragger rail, dragger and buttons), boolean
|
139
|
+
*/
|
140
|
+
alwaysShowScrollbar:0,
|
141
|
+
/*
|
142
|
+
scrolling always snaps to a multiple of this number in pixels
|
143
|
+
values: integer
|
144
|
+
option default
|
145
|
+
-------------------------------------
|
146
|
+
snapAmount null
|
147
|
+
*/
|
148
|
+
/*
|
149
|
+
when snapping, snap with this number in pixels as an offset
|
150
|
+
values: integer
|
151
|
+
*/
|
152
|
+
snapOffset:0,
|
153
|
+
/*
|
154
|
+
mouse-wheel scrolling
|
155
|
+
*/
|
156
|
+
mouseWheel:{
|
157
|
+
/*
|
158
|
+
enable mouse-wheel scrolling
|
159
|
+
values: boolean
|
160
|
+
*/
|
161
|
+
enable:true,
|
162
|
+
/*
|
163
|
+
scrolling amount in pixels
|
164
|
+
values: "auto", integer
|
165
|
+
*/
|
166
|
+
scrollAmount:"auto",
|
167
|
+
/*
|
168
|
+
mouse-wheel scrolling axis
|
169
|
+
the default scrolling direction when both vertical and horizontal scrollbars are present
|
170
|
+
values (string): "y", "x"
|
171
|
+
*/
|
172
|
+
axis:"y",
|
173
|
+
/*
|
174
|
+
prevent the default behaviour which automatically scrolls the parent element(s) when end of scrolling is reached
|
175
|
+
values: boolean
|
176
|
+
option default
|
177
|
+
-------------------------------------
|
178
|
+
preventDefault null
|
179
|
+
*/
|
180
|
+
/*
|
181
|
+
the reported mouse-wheel delta value. The number of lines (translated to pixels) one wheel notch scrolls.
|
182
|
+
values: "auto", integer
|
183
|
+
"auto" uses the default OS/browser value
|
184
|
+
*/
|
185
|
+
deltaFactor:"auto",
|
186
|
+
/*
|
187
|
+
normalize mouse-wheel delta to -1 or 1 (disables mouse-wheel acceleration)
|
188
|
+
values: boolean
|
189
|
+
option default
|
190
|
+
-------------------------------------
|
191
|
+
normalizeDelta null
|
192
|
+
*/
|
193
|
+
/*
|
194
|
+
invert mouse-wheel scrolling direction
|
195
|
+
values: boolean
|
196
|
+
option default
|
197
|
+
-------------------------------------
|
198
|
+
invert null
|
199
|
+
*/
|
200
|
+
/*
|
201
|
+
the tags that disable mouse-wheel when cursor is over them
|
202
|
+
*/
|
203
|
+
disableOver:["select","option","keygen","datalist","textarea"]
|
204
|
+
},
|
205
|
+
/*
|
206
|
+
scrollbar buttons
|
207
|
+
*/
|
208
|
+
scrollButtons:{
|
209
|
+
/*
|
210
|
+
enable scrollbar buttons
|
211
|
+
values: boolean
|
212
|
+
option default
|
213
|
+
-------------------------------------
|
214
|
+
enable null
|
215
|
+
*/
|
216
|
+
/*
|
217
|
+
scrollbar buttons scrolling type
|
218
|
+
values (string): "stepless", "stepped"
|
219
|
+
*/
|
220
|
+
scrollType:"stepless",
|
221
|
+
/*
|
222
|
+
scrolling amount in pixels
|
223
|
+
values: "auto", integer
|
224
|
+
*/
|
225
|
+
scrollAmount:"auto"
|
226
|
+
/*
|
227
|
+
tabindex of the scrollbar buttons
|
228
|
+
values: false, integer
|
229
|
+
option default
|
230
|
+
-------------------------------------
|
231
|
+
tabindex null
|
232
|
+
*/
|
233
|
+
},
|
234
|
+
/*
|
235
|
+
keyboard scrolling
|
236
|
+
*/
|
237
|
+
keyboard:{
|
238
|
+
/*
|
239
|
+
enable scrolling via keyboard
|
240
|
+
values: boolean
|
241
|
+
*/
|
242
|
+
enable:true,
|
243
|
+
/*
|
244
|
+
keyboard scrolling type
|
245
|
+
values (string): "stepless", "stepped"
|
246
|
+
*/
|
247
|
+
scrollType:"stepless",
|
248
|
+
/*
|
249
|
+
scrolling amount in pixels
|
250
|
+
values: "auto", integer
|
251
|
+
*/
|
252
|
+
scrollAmount:"auto"
|
253
|
+
},
|
254
|
+
/*
|
255
|
+
enable content touch-swipe scrolling
|
256
|
+
values: boolean, integer, string (number)
|
257
|
+
integer values define the axis-specific minimum amount required for scrolling momentum
|
258
|
+
*/
|
259
|
+
contentTouchScroll:25,
|
260
|
+
/*
|
261
|
+
advanced option parameters
|
262
|
+
*/
|
263
|
+
advanced:{
|
264
|
+
/*
|
265
|
+
auto-expand content horizontally (for "x" or "yx" axis)
|
266
|
+
values: boolean, integer (the value 2 forces the non scrollHeight/scrollWidth method, the value 3 forces the scrollHeight/scrollWidth method)
|
267
|
+
option default
|
268
|
+
-------------------------------------
|
269
|
+
autoExpandHorizontalScroll null
|
270
|
+
*/
|
271
|
+
/*
|
272
|
+
auto-scroll to elements with focus
|
273
|
+
*/
|
274
|
+
autoScrollOnFocus:"input,textarea,select,button,datalist,keygen,a[tabindex],area,object,[contenteditable='true']",
|
275
|
+
/*
|
276
|
+
auto-update scrollbars on content, element or viewport resize
|
277
|
+
should be true for fluid layouts/elements, adding/removing content dynamically, hiding/showing elements, content with images etc.
|
278
|
+
values: boolean
|
279
|
+
*/
|
280
|
+
updateOnContentResize:true,
|
281
|
+
/*
|
282
|
+
auto-update scrollbars each time each image inside the element is fully loaded
|
283
|
+
values: "auto", boolean
|
284
|
+
*/
|
285
|
+
updateOnImageLoad:"auto",
|
286
|
+
/*
|
287
|
+
auto-update scrollbars based on the amount and size changes of specific selectors
|
288
|
+
useful when you need to update the scrollbar(s) automatically, each time a type of element is added, removed or changes its size
|
289
|
+
values: boolean, string (e.g. "ul li" will auto-update scrollbars each time list-items inside the element are changed)
|
290
|
+
a value of true (boolean) will auto-update scrollbars each time any element is changed
|
291
|
+
option default
|
292
|
+
-------------------------------------
|
293
|
+
updateOnSelectorChange null
|
294
|
+
*/
|
295
|
+
/*
|
296
|
+
extra selectors that'll release scrollbar dragging upon mouseup, pointerup, touchend etc. (e.g. "selector-1, selector-2")
|
297
|
+
option default
|
298
|
+
-------------------------------------
|
299
|
+
releaseDraggableSelectors null
|
300
|
+
*/
|
301
|
+
/*
|
302
|
+
auto-update timeout
|
303
|
+
values: integer (milliseconds)
|
304
|
+
*/
|
305
|
+
autoUpdateTimeout:60
|
306
|
+
},
|
307
|
+
/*
|
308
|
+
scrollbar theme
|
309
|
+
values: string (see CSS/plugin URI for a list of ready-to-use themes)
|
310
|
+
*/
|
311
|
+
theme:"light",
|
312
|
+
/*
|
313
|
+
user defined callback functions
|
314
|
+
*/
|
315
|
+
callbacks:{
|
316
|
+
/*
|
317
|
+
Available callbacks:
|
318
|
+
callback default
|
319
|
+
-------------------------------------
|
320
|
+
onCreate null
|
321
|
+
onInit null
|
322
|
+
onScrollStart null
|
323
|
+
onScroll null
|
324
|
+
onTotalScroll null
|
325
|
+
onTotalScrollBack null
|
326
|
+
whileScrolling null
|
327
|
+
onOverflowY null
|
328
|
+
onOverflowX null
|
329
|
+
onOverflowYNone null
|
330
|
+
onOverflowXNone null
|
331
|
+
onImageLoad null
|
332
|
+
onSelectorChange null
|
333
|
+
onBeforeUpdate null
|
334
|
+
onUpdate null
|
335
|
+
*/
|
336
|
+
onTotalScrollOffset:0,
|
337
|
+
onTotalScrollBackOffset:0,
|
338
|
+
alwaysTriggerOffsets:true
|
339
|
+
}
|
340
|
+
/*
|
341
|
+
add scrollbar(s) on all elements matching the current selector, now and in the future
|
342
|
+
values: boolean, string
|
343
|
+
string values: "on" (enable), "once" (disable after first invocation), "off" (disable)
|
344
|
+
liveSelector values: string (selector)
|
345
|
+
option default
|
346
|
+
-------------------------------------
|
347
|
+
live false
|
348
|
+
liveSelector null
|
349
|
+
*/
|
350
|
+
},
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
/*
|
357
|
+
----------------------------------------
|
358
|
+
VARS, CONSTANTS
|
359
|
+
----------------------------------------
|
360
|
+
*/
|
361
|
+
|
362
|
+
totalInstances=0, /* plugin instances amount */
|
363
|
+
liveTimers={}, /* live option timers */
|
364
|
+
oldIE=(window.attachEvent && !window.addEventListener) ? 1 : 0, /* detect IE < 9 */
|
365
|
+
touchActive=false,touchable, /* global touch vars (for touch and pointer events) */
|
366
|
+
/* general plugin classes */
|
367
|
+
classes=[
|
368
|
+
"mCSB_dragger_onDrag","mCSB_scrollTools_onDrag","mCS_img_loaded","mCS_disabled","mCS_destroyed","mCS_no_scrollbar",
|
369
|
+
"mCS-autoHide","mCS-dir-rtl","mCS_no_scrollbar_y","mCS_no_scrollbar_x","mCS_y_hidden","mCS_x_hidden","mCSB_draggerContainer",
|
370
|
+
"mCSB_buttonUp","mCSB_buttonDown","mCSB_buttonLeft","mCSB_buttonRight"
|
371
|
+
],
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
/*
|
378
|
+
----------------------------------------
|
379
|
+
METHODS
|
380
|
+
----------------------------------------
|
381
|
+
*/
|
382
|
+
|
383
|
+
methods={
|
384
|
+
|
385
|
+
/*
|
386
|
+
plugin initialization method
|
387
|
+
creates the scrollbar(s), plugin data object and options
|
388
|
+
----------------------------------------
|
389
|
+
*/
|
390
|
+
|
391
|
+
init:function(options){
|
392
|
+
|
393
|
+
var options=$.extend(true,{},defaults,options),
|
394
|
+
selector=_selector.call(this); /* validate selector */
|
395
|
+
|
396
|
+
/*
|
397
|
+
if live option is enabled, monitor for elements matching the current selector and
|
398
|
+
apply scrollbar(s) when found (now and in the future)
|
399
|
+
*/
|
400
|
+
if(options.live){
|
401
|
+
var liveSelector=options.liveSelector || this.selector || defaultSelector, /* live selector(s) */
|
402
|
+
$liveSelector=$(liveSelector); /* live selector(s) as jquery object */
|
403
|
+
if(options.live==="off"){
|
404
|
+
/*
|
405
|
+
disable live if requested
|
406
|
+
usage: $(selector).mCustomScrollbar({live:"off"});
|
407
|
+
*/
|
408
|
+
removeLiveTimers(liveSelector);
|
409
|
+
return;
|
410
|
+
}
|
411
|
+
liveTimers[liveSelector]=setTimeout(function(){
|
412
|
+
/* call mCustomScrollbar fn on live selector(s) every half-second */
|
413
|
+
$liveSelector.mCustomScrollbar(options);
|
414
|
+
if(options.live==="once" && $liveSelector.length){
|
415
|
+
/* disable live after first invocation */
|
416
|
+
removeLiveTimers(liveSelector);
|
417
|
+
}
|
418
|
+
},500);
|
419
|
+
}else{
|
420
|
+
removeLiveTimers(liveSelector);
|
421
|
+
}
|
422
|
+
|
423
|
+
/* options backward compatibility (for versions < 3.0.0) and normalization */
|
424
|
+
options.setWidth=(options.set_width) ? options.set_width : options.setWidth;
|
425
|
+
options.setHeight=(options.set_height) ? options.set_height : options.setHeight;
|
426
|
+
options.axis=(options.horizontalScroll) ? "x" : _findAxis(options.axis);
|
427
|
+
options.scrollInertia=options.scrollInertia>0 && options.scrollInertia<17 ? 17 : options.scrollInertia;
|
428
|
+
if(typeof options.mouseWheel!=="object" && options.mouseWheel==true){ /* old school mouseWheel option (non-object) */
|
429
|
+
options.mouseWheel={enable:true,scrollAmount:"auto",axis:"y",preventDefault:false,deltaFactor:"auto",normalizeDelta:false,invert:false}
|
430
|
+
}
|
431
|
+
options.mouseWheel.scrollAmount=!options.mouseWheelPixels ? options.mouseWheel.scrollAmount : options.mouseWheelPixels;
|
432
|
+
options.mouseWheel.normalizeDelta=!options.advanced.normalizeMouseWheelDelta ? options.mouseWheel.normalizeDelta : options.advanced.normalizeMouseWheelDelta;
|
433
|
+
options.scrollButtons.scrollType=_findScrollButtonsType(options.scrollButtons.scrollType);
|
434
|
+
|
435
|
+
_theme(options); /* theme-specific options */
|
436
|
+
|
437
|
+
/* plugin constructor */
|
438
|
+
return $(selector).each(function(){
|
439
|
+
|
440
|
+
var $this=$(this);
|
441
|
+
|
442
|
+
if(!$this.data(pluginPfx)){ /* prevent multiple instantiations */
|
443
|
+
|
444
|
+
/* store options and create objects in jquery data */
|
445
|
+
$this.data(pluginPfx,{
|
446
|
+
idx:++totalInstances, /* instance index */
|
447
|
+
opt:options, /* options */
|
448
|
+
scrollRatio:{y:null,x:null}, /* scrollbar to content ratio */
|
449
|
+
overflowed:null, /* overflowed axis */
|
450
|
+
contentReset:{y:null,x:null}, /* object to check when content resets */
|
451
|
+
bindEvents:false, /* object to check if events are bound */
|
452
|
+
tweenRunning:false, /* object to check if tween is running */
|
453
|
+
sequential:{}, /* sequential scrolling object */
|
454
|
+
langDir:$this.css("direction"), /* detect/store direction (ltr or rtl) */
|
455
|
+
cbOffsets:null, /* object to check whether callback offsets always trigger */
|
456
|
+
/*
|
457
|
+
object to check how scrolling events where last triggered
|
458
|
+
"internal" (default - triggered by this script), "external" (triggered by other scripts, e.g. via scrollTo method)
|
459
|
+
usage: object.data("mCS").trigger
|
460
|
+
*/
|
461
|
+
trigger:null,
|
462
|
+
/*
|
463
|
+
object to check for changes in elements in order to call the update method automatically
|
464
|
+
*/
|
465
|
+
poll:{size:{o:0,n:0},img:{o:0,n:0},change:{o:0,n:0}}
|
466
|
+
});
|
467
|
+
|
468
|
+
var d=$this.data(pluginPfx),o=d.opt,
|
469
|
+
/* HTML data attributes */
|
470
|
+
htmlDataAxis=$this.data("mcs-axis"),htmlDataSbPos=$this.data("mcs-scrollbar-position"),htmlDataTheme=$this.data("mcs-theme");
|
471
|
+
|
472
|
+
if(htmlDataAxis){o.axis=htmlDataAxis;} /* usage example: data-mcs-axis="y" */
|
473
|
+
if(htmlDataSbPos){o.scrollbarPosition=htmlDataSbPos;} /* usage example: data-mcs-scrollbar-position="outside" */
|
474
|
+
if(htmlDataTheme){ /* usage example: data-mcs-theme="minimal" */
|
475
|
+
o.theme=htmlDataTheme;
|
476
|
+
_theme(o); /* theme-specific options */
|
477
|
+
}
|
478
|
+
|
479
|
+
_pluginMarkup.call(this); /* add plugin markup */
|
480
|
+
|
481
|
+
if(d && o.callbacks.onCreate && typeof o.callbacks.onCreate==="function"){o.callbacks.onCreate.call(this);} /* callbacks: onCreate */
|
482
|
+
|
483
|
+
$("#mCSB_"+d.idx+"_container img:not(."+classes[2]+")").addClass(classes[2]); /* flag loaded images */
|
484
|
+
|
485
|
+
methods.update.call(null,$this); /* call the update method */
|
486
|
+
|
487
|
+
}
|
488
|
+
|
489
|
+
});
|
490
|
+
|
491
|
+
},
|
492
|
+
/* ---------------------------------------- */
|
493
|
+
|
494
|
+
|
495
|
+
|
496
|
+
/*
|
497
|
+
plugin update method
|
498
|
+
updates content and scrollbar(s) values, events and status
|
499
|
+
----------------------------------------
|
500
|
+
usage: $(selector).mCustomScrollbar("update");
|
501
|
+
*/
|
502
|
+
|
503
|
+
update:function(el,cb){
|
504
|
+
|
505
|
+
var selector=el || _selector.call(this); /* validate selector */
|
506
|
+
|
507
|
+
return $(selector).each(function(){
|
508
|
+
|
509
|
+
var $this=$(this);
|
510
|
+
|
511
|
+
if($this.data(pluginPfx)){ /* check if plugin has initialized */
|
512
|
+
|
513
|
+
var d=$this.data(pluginPfx),o=d.opt,
|
514
|
+
mCSB_container=$("#mCSB_"+d.idx+"_container"),
|
515
|
+
mCustomScrollBox=$("#mCSB_"+d.idx),
|
516
|
+
mCSB_dragger=[$("#mCSB_"+d.idx+"_dragger_vertical"),$("#mCSB_"+d.idx+"_dragger_horizontal")];
|
517
|
+
|
518
|
+
if(!mCSB_container.length){return;}
|
519
|
+
|
520
|
+
if(d.tweenRunning){_stop($this);} /* stop any running tweens while updating */
|
521
|
+
|
522
|
+
if(cb && d && o.callbacks.onBeforeUpdate && typeof o.callbacks.onBeforeUpdate==="function"){o.callbacks.onBeforeUpdate.call(this);} /* callbacks: onBeforeUpdate */
|
523
|
+
|
524
|
+
/* if element was disabled or destroyed, remove class(es) */
|
525
|
+
if($this.hasClass(classes[3])){$this.removeClass(classes[3]);}
|
526
|
+
if($this.hasClass(classes[4])){$this.removeClass(classes[4]);}
|
527
|
+
|
528
|
+
/* css flexbox fix, detect/set max-height */
|
529
|
+
if(mCustomScrollBox.height()!==$this.height()){mCustomScrollBox.css("max-height",$this.height());}
|
530
|
+
|
531
|
+
_expandContentHorizontally.call(this); /* expand content horizontally */
|
532
|
+
|
533
|
+
if(o.axis!=="y" && !o.advanced.autoExpandHorizontalScroll){
|
534
|
+
mCSB_container.css("width",_contentWidth(mCSB_container));
|
535
|
+
}
|
536
|
+
|
537
|
+
d.overflowed=_overflowed.call(this); /* determine if scrolling is required */
|
538
|
+
|
539
|
+
_scrollbarVisibility.call(this); /* show/hide scrollbar(s) */
|
540
|
+
|
541
|
+
/* auto-adjust scrollbar dragger length analogous to content */
|
542
|
+
if(o.autoDraggerLength){_setDraggerLength.call(this);}
|
543
|
+
|
544
|
+
_scrollRatio.call(this); /* calculate and store scrollbar to content ratio */
|
545
|
+
|
546
|
+
_bindEvents.call(this); /* bind scrollbar events */
|
547
|
+
|
548
|
+
/* reset scrolling position and/or events */
|
549
|
+
var to=[Math.abs(mCSB_container[0].offsetTop),Math.abs(mCSB_container[0].offsetLeft)];
|
550
|
+
if(o.axis!=="x"){ /* y/yx axis */
|
551
|
+
if(!d.overflowed[0]){ /* y scrolling is not required */
|
552
|
+
_resetContentPosition.call(this); /* reset content position */
|
553
|
+
if(o.axis==="y"){
|
554
|
+
_unbindEvents.call(this);
|
555
|
+
}else if(o.axis==="yx" && d.overflowed[1]){
|
556
|
+
_scrollTo($this,to[1].toString(),{dir:"x",dur:0,overwrite:"none"});
|
557
|
+
}
|
558
|
+
}else if(mCSB_dragger[0].height()>mCSB_dragger[0].parent().height()){
|
559
|
+
_resetContentPosition.call(this); /* reset content position */
|
560
|
+
}else{ /* y scrolling is required */
|
561
|
+
_scrollTo($this,to[0].toString(),{dir:"y",dur:0,overwrite:"none"});
|
562
|
+
d.contentReset.y=null;
|
563
|
+
}
|
564
|
+
}
|
565
|
+
if(o.axis!=="y"){ /* x/yx axis */
|
566
|
+
if(!d.overflowed[1]){ /* x scrolling is not required */
|
567
|
+
_resetContentPosition.call(this); /* reset content position */
|
568
|
+
if(o.axis==="x"){
|
569
|
+
_unbindEvents.call(this);
|
570
|
+
}else if(o.axis==="yx" && d.overflowed[0]){
|
571
|
+
_scrollTo($this,to[0].toString(),{dir:"y",dur:0,overwrite:"none"});
|
572
|
+
}
|
573
|
+
}else if(mCSB_dragger[1].width()>mCSB_dragger[1].parent().width()){
|
574
|
+
_resetContentPosition.call(this); /* reset content position */
|
575
|
+
}else{ /* x scrolling is required */
|
576
|
+
_scrollTo($this,to[1].toString(),{dir:"x",dur:0,overwrite:"none"});
|
577
|
+
d.contentReset.x=null;
|
578
|
+
}
|
579
|
+
}
|
580
|
+
|
581
|
+
/* callbacks: onImageLoad, onSelectorChange, onUpdate */
|
582
|
+
if(cb && d){
|
583
|
+
if(cb===2 && o.callbacks.onImageLoad && typeof o.callbacks.onImageLoad==="function"){
|
584
|
+
o.callbacks.onImageLoad.call(this);
|
585
|
+
}else if(cb===3 && o.callbacks.onSelectorChange && typeof o.callbacks.onSelectorChange==="function"){
|
586
|
+
o.callbacks.onSelectorChange.call(this);
|
587
|
+
}else if(o.callbacks.onUpdate && typeof o.callbacks.onUpdate==="function"){
|
588
|
+
o.callbacks.onUpdate.call(this);
|
589
|
+
}
|
590
|
+
}
|
591
|
+
|
592
|
+
_autoUpdate.call(this); /* initialize automatic updating (for dynamic content, fluid layouts etc.) */
|
593
|
+
|
594
|
+
}
|
595
|
+
|
596
|
+
});
|
597
|
+
|
598
|
+
},
|
599
|
+
/* ---------------------------------------- */
|
600
|
+
|
601
|
+
|
602
|
+
|
603
|
+
/*
|
604
|
+
plugin scrollTo method
|
605
|
+
triggers a scrolling event to a specific value
|
606
|
+
----------------------------------------
|
607
|
+
usage: $(selector).mCustomScrollbar("scrollTo",value,options);
|
608
|
+
*/
|
609
|
+
|
610
|
+
scrollTo:function(val,options){
|
611
|
+
|
612
|
+
/* prevent silly things like $(selector).mCustomScrollbar("scrollTo",undefined); */
|
613
|
+
if(typeof val=="undefined" || val==null){return;}
|
614
|
+
|
615
|
+
var selector=_selector.call(this); /* validate selector */
|
616
|
+
|
617
|
+
return $(selector).each(function(){
|
618
|
+
|
619
|
+
var $this=$(this);
|
620
|
+
|
621
|
+
if($this.data(pluginPfx)){ /* check if plugin has initialized */
|
622
|
+
|
623
|
+
var d=$this.data(pluginPfx),o=d.opt,
|
624
|
+
/* method default options */
|
625
|
+
methodDefaults={
|
626
|
+
trigger:"external", /* method is by default triggered externally (e.g. from other scripts) */
|
627
|
+
scrollInertia:o.scrollInertia, /* scrolling inertia (animation duration) */
|
628
|
+
scrollEasing:"mcsEaseInOut", /* animation easing */
|
629
|
+
moveDragger:false, /* move dragger instead of content */
|
630
|
+
timeout:60, /* scroll-to delay */
|
631
|
+
callbacks:true, /* enable/disable callbacks */
|
632
|
+
onStart:true,
|
633
|
+
onUpdate:true,
|
634
|
+
onComplete:true
|
635
|
+
},
|
636
|
+
methodOptions=$.extend(true,{},methodDefaults,options),
|
637
|
+
to=_arr.call(this,val),dur=methodOptions.scrollInertia>0 && methodOptions.scrollInertia<17 ? 17 : methodOptions.scrollInertia;
|
638
|
+
|
639
|
+
/* translate yx values to actual scroll-to positions */
|
640
|
+
to[0]=_to.call(this,to[0],"y");
|
641
|
+
to[1]=_to.call(this,to[1],"x");
|
642
|
+
|
643
|
+
/*
|
644
|
+
check if scroll-to value moves the dragger instead of content.
|
645
|
+
Only pixel values apply on dragger (e.g. 100, "100px", "-=100" etc.)
|
646
|
+
*/
|
647
|
+
if(methodOptions.moveDragger){
|
648
|
+
to[0]*=d.scrollRatio.y;
|
649
|
+
to[1]*=d.scrollRatio.x;
|
650
|
+
}
|
651
|
+
|
652
|
+
methodOptions.dur=dur;
|
653
|
+
|
654
|
+
setTimeout(function(){
|
655
|
+
/* do the scrolling */
|
656
|
+
if(to[0]!==null && typeof to[0]!=="undefined" && o.axis!=="x" && d.overflowed[0]){ /* scroll y */
|
657
|
+
methodOptions.dir="y";
|
658
|
+
methodOptions.overwrite="all";
|
659
|
+
_scrollTo($this,to[0].toString(),methodOptions);
|
660
|
+
}
|
661
|
+
if(to[1]!==null && typeof to[1]!=="undefined" && o.axis!=="y" && d.overflowed[1]){ /* scroll x */
|
662
|
+
methodOptions.dir="x";
|
663
|
+
methodOptions.overwrite="none";
|
664
|
+
_scrollTo($this,to[1].toString(),methodOptions);
|
665
|
+
}
|
666
|
+
},methodOptions.timeout);
|
667
|
+
|
668
|
+
}
|
669
|
+
|
670
|
+
});
|
671
|
+
|
672
|
+
},
|
673
|
+
/* ---------------------------------------- */
|
674
|
+
|
675
|
+
|
676
|
+
|
677
|
+
/*
|
678
|
+
plugin stop method
|
679
|
+
stops scrolling animation
|
680
|
+
----------------------------------------
|
681
|
+
usage: $(selector).mCustomScrollbar("stop");
|
682
|
+
*/
|
683
|
+
stop:function(){
|
684
|
+
|
685
|
+
var selector=_selector.call(this); /* validate selector */
|
686
|
+
|
687
|
+
return $(selector).each(function(){
|
688
|
+
|
689
|
+
var $this=$(this);
|
690
|
+
|
691
|
+
if($this.data(pluginPfx)){ /* check if plugin has initialized */
|
692
|
+
|
693
|
+
_stop($this);
|
694
|
+
|
695
|
+
}
|
696
|
+
|
697
|
+
});
|
698
|
+
|
699
|
+
},
|
700
|
+
/* ---------------------------------------- */
|
701
|
+
|
702
|
+
|
703
|
+
|
704
|
+
/*
|
705
|
+
plugin disable method
|
706
|
+
temporarily disables the scrollbar(s)
|
707
|
+
----------------------------------------
|
708
|
+
usage: $(selector).mCustomScrollbar("disable",reset);
|
709
|
+
reset (boolean): resets content position to 0
|
710
|
+
*/
|
711
|
+
disable:function(r){
|
712
|
+
|
713
|
+
var selector=_selector.call(this); /* validate selector */
|
714
|
+
|
715
|
+
return $(selector).each(function(){
|
716
|
+
|
717
|
+
var $this=$(this);
|
718
|
+
|
719
|
+
if($this.data(pluginPfx)){ /* check if plugin has initialized */
|
720
|
+
|
721
|
+
var d=$this.data(pluginPfx);
|
722
|
+
|
723
|
+
_autoUpdate.call(this,"remove"); /* remove automatic updating */
|
724
|
+
|
725
|
+
_unbindEvents.call(this); /* unbind events */
|
726
|
+
|
727
|
+
if(r){_resetContentPosition.call(this);} /* reset content position */
|
728
|
+
|
729
|
+
_scrollbarVisibility.call(this,true); /* show/hide scrollbar(s) */
|
730
|
+
|
731
|
+
$this.addClass(classes[3]); /* add disable class */
|
732
|
+
|
733
|
+
}
|
734
|
+
|
735
|
+
});
|
736
|
+
|
737
|
+
},
|
738
|
+
/* ---------------------------------------- */
|
739
|
+
|
740
|
+
|
741
|
+
|
742
|
+
/*
|
743
|
+
plugin destroy method
|
744
|
+
completely removes the scrollbar(s) and returns the element to its original state
|
745
|
+
----------------------------------------
|
746
|
+
usage: $(selector).mCustomScrollbar("destroy");
|
747
|
+
*/
|
748
|
+
destroy:function(){
|
749
|
+
|
750
|
+
var selector=_selector.call(this); /* validate selector */
|
751
|
+
|
752
|
+
return $(selector).each(function(){
|
753
|
+
|
754
|
+
var $this=$(this);
|
755
|
+
|
756
|
+
if($this.data(pluginPfx)){ /* check if plugin has initialized */
|
757
|
+
|
758
|
+
var d=$this.data(pluginPfx),o=d.opt,
|
759
|
+
mCustomScrollBox=$("#mCSB_"+d.idx),
|
760
|
+
mCSB_container=$("#mCSB_"+d.idx+"_container"),
|
761
|
+
scrollbar=$(".mCSB_"+d.idx+"_scrollbar");
|
762
|
+
|
763
|
+
if(o.live){removeLiveTimers(o.liveSelector || $(selector).selector);} /* remove live timers */
|
764
|
+
|
765
|
+
_autoUpdate.call(this,"remove"); /* remove automatic updating */
|
766
|
+
|
767
|
+
_unbindEvents.call(this); /* unbind events */
|
768
|
+
|
769
|
+
_resetContentPosition.call(this); /* reset content position */
|
770
|
+
|
771
|
+
$this.removeData(pluginPfx); /* remove plugin data object */
|
772
|
+
|
773
|
+
_delete(this,"mcs"); /* delete callbacks object */
|
774
|
+
|
775
|
+
/* remove plugin markup */
|
776
|
+
scrollbar.remove(); /* remove scrollbar(s) first (those can be either inside or outside plugin's inner wrapper) */
|
777
|
+
mCSB_container.find("img."+classes[2]).removeClass(classes[2]); /* remove loaded images flag */
|
778
|
+
mCustomScrollBox.replaceWith(mCSB_container.contents()); /* replace plugin's inner wrapper with the original content */
|
779
|
+
/* remove plugin classes from the element and add destroy class */
|
780
|
+
$this.removeClass(pluginNS+" _"+pluginPfx+"_"+d.idx+" "+classes[6]+" "+classes[7]+" "+classes[5]+" "+classes[3]).addClass(classes[4]);
|
781
|
+
|
782
|
+
}
|
783
|
+
|
784
|
+
});
|
785
|
+
|
786
|
+
}
|
787
|
+
/* ---------------------------------------- */
|
788
|
+
|
789
|
+
},
|
790
|
+
|
791
|
+
|
792
|
+
|
793
|
+
|
794
|
+
|
795
|
+
/*
|
796
|
+
----------------------------------------
|
797
|
+
FUNCTIONS
|
798
|
+
----------------------------------------
|
799
|
+
*/
|
800
|
+
|
801
|
+
/* validates selector (if selector is invalid or undefined uses the default one) */
|
802
|
+
_selector=function(){
|
803
|
+
return (typeof $(this)!=="object" || $(this).length<1) ? defaultSelector : this;
|
804
|
+
},
|
805
|
+
/* -------------------- */
|
806
|
+
|
807
|
+
|
808
|
+
/* changes options according to theme */
|
809
|
+
_theme=function(obj){
|
810
|
+
var fixedSizeScrollbarThemes=["rounded","rounded-dark","rounded-dots","rounded-dots-dark"],
|
811
|
+
nonExpandedScrollbarThemes=["rounded-dots","rounded-dots-dark","3d","3d-dark","3d-thick","3d-thick-dark","inset","inset-dark","inset-2","inset-2-dark","inset-3","inset-3-dark"],
|
812
|
+
disabledScrollButtonsThemes=["minimal","minimal-dark"],
|
813
|
+
enabledAutoHideScrollbarThemes=["minimal","minimal-dark"],
|
814
|
+
scrollbarPositionOutsideThemes=["minimal","minimal-dark"];
|
815
|
+
obj.autoDraggerLength=$.inArray(obj.theme,fixedSizeScrollbarThemes) > -1 ? false : obj.autoDraggerLength;
|
816
|
+
obj.autoExpandScrollbar=$.inArray(obj.theme,nonExpandedScrollbarThemes) > -1 ? false : obj.autoExpandScrollbar;
|
817
|
+
obj.scrollButtons.enable=$.inArray(obj.theme,disabledScrollButtonsThemes) > -1 ? false : obj.scrollButtons.enable;
|
818
|
+
obj.autoHideScrollbar=$.inArray(obj.theme,enabledAutoHideScrollbarThemes) > -1 ? true : obj.autoHideScrollbar;
|
819
|
+
obj.scrollbarPosition=$.inArray(obj.theme,scrollbarPositionOutsideThemes) > -1 ? "outside" : obj.scrollbarPosition;
|
820
|
+
},
|
821
|
+
/* -------------------- */
|
822
|
+
|
823
|
+
|
824
|
+
/* live option timers removal */
|
825
|
+
removeLiveTimers=function(selector){
|
826
|
+
if(liveTimers[selector]){
|
827
|
+
clearTimeout(liveTimers[selector]);
|
828
|
+
_delete(liveTimers,selector);
|
829
|
+
}
|
830
|
+
},
|
831
|
+
/* -------------------- */
|
832
|
+
|
833
|
+
|
834
|
+
/* normalizes axis option to valid values: "y", "x", "yx" */
|
835
|
+
_findAxis=function(val){
|
836
|
+
return (val==="yx" || val==="xy" || val==="auto") ? "yx" : (val==="x" || val==="horizontal") ? "x" : "y";
|
837
|
+
},
|
838
|
+
/* -------------------- */
|
839
|
+
|
840
|
+
|
841
|
+
/* normalizes scrollButtons.scrollType option to valid values: "stepless", "stepped" */
|
842
|
+
_findScrollButtonsType=function(val){
|
843
|
+
return (val==="stepped" || val==="pixels" || val==="step" || val==="click") ? "stepped" : "stepless";
|
844
|
+
},
|
845
|
+
/* -------------------- */
|
846
|
+
|
847
|
+
|
848
|
+
/* generates plugin markup */
|
849
|
+
_pluginMarkup=function(){
|
850
|
+
var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
|
851
|
+
expandClass=o.autoExpandScrollbar ? " "+classes[1]+"_expand" : "",
|
852
|
+
scrollbar=["<div id='mCSB_"+d.idx+"_scrollbar_vertical' class='mCSB_scrollTools mCSB_"+d.idx+"_scrollbar mCS-"+o.theme+" mCSB_scrollTools_vertical"+expandClass+"'><div class='"+classes[12]+"'><div id='mCSB_"+d.idx+"_dragger_vertical' class='mCSB_dragger' style='position:absolute;' oncontextmenu='return false;'><div class='mCSB_dragger_bar' /></div><div class='mCSB_draggerRail' /></div></div>","<div id='mCSB_"+d.idx+"_scrollbar_horizontal' class='mCSB_scrollTools mCSB_"+d.idx+"_scrollbar mCS-"+o.theme+" mCSB_scrollTools_horizontal"+expandClass+"'><div class='"+classes[12]+"'><div id='mCSB_"+d.idx+"_dragger_horizontal' class='mCSB_dragger' style='position:absolute;' oncontextmenu='return false;'><div class='mCSB_dragger_bar' /></div><div class='mCSB_draggerRail' /></div></div>"],
|
853
|
+
wrapperClass=o.axis==="yx" ? "mCSB_vertical_horizontal" : o.axis==="x" ? "mCSB_horizontal" : "mCSB_vertical",
|
854
|
+
scrollbars=o.axis==="yx" ? scrollbar[0]+scrollbar[1] : o.axis==="x" ? scrollbar[1] : scrollbar[0],
|
855
|
+
contentWrapper=o.axis==="yx" ? "<div id='mCSB_"+d.idx+"_container_wrapper' class='mCSB_container_wrapper' />" : "",
|
856
|
+
autoHideClass=o.autoHideScrollbar ? " "+classes[6] : "",
|
857
|
+
scrollbarDirClass=(o.axis!=="x" && d.langDir==="rtl") ? " "+classes[7] : "";
|
858
|
+
if(o.setWidth){$this.css("width",o.setWidth);} /* set element width */
|
859
|
+
if(o.setHeight){$this.css("height",o.setHeight);} /* set element height */
|
860
|
+
o.setLeft=(o.axis!=="y" && d.langDir==="rtl") ? "989999px" : o.setLeft; /* adjust left position for rtl direction */
|
861
|
+
$this.addClass(pluginNS+" _"+pluginPfx+"_"+d.idx+autoHideClass+scrollbarDirClass).wrapInner("<div id='mCSB_"+d.idx+"' class='mCustomScrollBox mCS-"+o.theme+" "+wrapperClass+"'><div id='mCSB_"+d.idx+"_container' class='mCSB_container' style='position:relative; top:"+o.setTop+"; left:"+o.setLeft+";' dir="+d.langDir+" /></div>");
|
862
|
+
var mCustomScrollBox=$("#mCSB_"+d.idx),
|
863
|
+
mCSB_container=$("#mCSB_"+d.idx+"_container");
|
864
|
+
if(o.axis!=="y" && !o.advanced.autoExpandHorizontalScroll){
|
865
|
+
mCSB_container.css("width",_contentWidth(mCSB_container));
|
866
|
+
}
|
867
|
+
if(o.scrollbarPosition==="outside"){
|
868
|
+
if($this.css("position")==="static"){ /* requires elements with non-static position */
|
869
|
+
$this.css("position","relative");
|
870
|
+
}
|
871
|
+
$this.css("overflow","visible");
|
872
|
+
mCustomScrollBox.addClass("mCSB_outside").after(scrollbars);
|
873
|
+
}else{
|
874
|
+
mCustomScrollBox.addClass("mCSB_inside").append(scrollbars);
|
875
|
+
mCSB_container.wrap(contentWrapper);
|
876
|
+
}
|
877
|
+
_scrollButtons.call(this); /* add scrollbar buttons */
|
878
|
+
/* minimum dragger length */
|
879
|
+
var mCSB_dragger=[$("#mCSB_"+d.idx+"_dragger_vertical"),$("#mCSB_"+d.idx+"_dragger_horizontal")];
|
880
|
+
mCSB_dragger[0].css("min-height",mCSB_dragger[0].height());
|
881
|
+
mCSB_dragger[1].css("min-width",mCSB_dragger[1].width());
|
882
|
+
},
|
883
|
+
/* -------------------- */
|
884
|
+
|
885
|
+
|
886
|
+
/* calculates content width */
|
887
|
+
_contentWidth=function(el){
|
888
|
+
var val=[el[0].scrollWidth,Math.max.apply(Math,el.children().map(function(){return $(this).outerWidth(true);}).get())],w=el.parent().width();
|
889
|
+
return val[0]>w ? val[0] : val[1]>w ? val[1] : "100%";
|
890
|
+
},
|
891
|
+
/* -------------------- */
|
892
|
+
|
893
|
+
|
894
|
+
/* expands content horizontally */
|
895
|
+
_expandContentHorizontally=function(){
|
896
|
+
var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
|
897
|
+
mCSB_container=$("#mCSB_"+d.idx+"_container");
|
898
|
+
if(o.advanced.autoExpandHorizontalScroll && o.axis!=="y"){
|
899
|
+
/* calculate scrollWidth */
|
900
|
+
mCSB_container.css({"width":"auto","min-width":0,"overflow-x":"scroll"});
|
901
|
+
var w=Math.ceil(mCSB_container[0].scrollWidth);
|
902
|
+
if(o.advanced.autoExpandHorizontalScroll===3 || (o.advanced.autoExpandHorizontalScroll!==2 && w>mCSB_container.parent().width())){
|
903
|
+
mCSB_container.css({"width":w,"min-width":"100%","overflow-x":"inherit"});
|
904
|
+
}else{
|
905
|
+
/*
|
906
|
+
wrap content with an infinite width div and set its position to absolute and width to auto.
|
907
|
+
Setting width to auto before calculating the actual width is important!
|
908
|
+
We must let the browser set the width as browser zoom values are impossible to calculate.
|
909
|
+
*/
|
910
|
+
mCSB_container.css({"overflow-x":"inherit","position":"absolute"})
|
911
|
+
.wrap("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />")
|
912
|
+
.css({ /* set actual width, original position and un-wrap */
|
913
|
+
/*
|
914
|
+
get the exact width (with decimals) and then round-up.
|
915
|
+
Using jquery outerWidth() will round the width value which will mess up with inner elements that have non-integer width
|
916
|
+
*/
|
917
|
+
"width":(Math.ceil(mCSB_container[0].getBoundingClientRect().right+0.4)-Math.floor(mCSB_container[0].getBoundingClientRect().left)),
|
918
|
+
"min-width":"100%",
|
919
|
+
"position":"relative"
|
920
|
+
}).unwrap();
|
921
|
+
}
|
922
|
+
}
|
923
|
+
},
|
924
|
+
/* -------------------- */
|
925
|
+
|
926
|
+
|
927
|
+
/* adds scrollbar buttons */
|
928
|
+
_scrollButtons=function(){
|
929
|
+
var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
|
930
|
+
mCSB_scrollTools=$(".mCSB_"+d.idx+"_scrollbar:first"),
|
931
|
+
tabindex=!_isNumeric(o.scrollButtons.tabindex) ? "" : "tabindex='"+o.scrollButtons.tabindex+"'",
|
932
|
+
btnHTML=[
|
933
|
+
"<a href='#' class='"+classes[13]+"' oncontextmenu='return false;' "+tabindex+" />",
|
934
|
+
"<a href='#' class='"+classes[14]+"' oncontextmenu='return false;' "+tabindex+" />",
|
935
|
+
"<a href='#' class='"+classes[15]+"' oncontextmenu='return false;' "+tabindex+" />",
|
936
|
+
"<a href='#' class='"+classes[16]+"' oncontextmenu='return false;' "+tabindex+" />"
|
937
|
+
],
|
938
|
+
btn=[(o.axis==="x" ? btnHTML[2] : btnHTML[0]),(o.axis==="x" ? btnHTML[3] : btnHTML[1]),btnHTML[2],btnHTML[3]];
|
939
|
+
if(o.scrollButtons.enable){
|
940
|
+
mCSB_scrollTools.prepend(btn[0]).append(btn[1]).next(".mCSB_scrollTools").prepend(btn[2]).append(btn[3]);
|
941
|
+
}
|
942
|
+
},
|
943
|
+
/* -------------------- */
|
944
|
+
|
945
|
+
|
946
|
+
/* auto-adjusts scrollbar dragger length */
|
947
|
+
_setDraggerLength=function(){
|
948
|
+
var $this=$(this),d=$this.data(pluginPfx),
|
949
|
+
mCustomScrollBox=$("#mCSB_"+d.idx),
|
950
|
+
mCSB_container=$("#mCSB_"+d.idx+"_container"),
|
951
|
+
mCSB_dragger=[$("#mCSB_"+d.idx+"_dragger_vertical"),$("#mCSB_"+d.idx+"_dragger_horizontal")],
|
952
|
+
ratio=[mCustomScrollBox.height()/mCSB_container.outerHeight(false),mCustomScrollBox.width()/mCSB_container.outerWidth(false)],
|
953
|
+
l=[
|
954
|
+
parseInt(mCSB_dragger[0].css("min-height")),Math.round(ratio[0]*mCSB_dragger[0].parent().height()),
|
955
|
+
parseInt(mCSB_dragger[1].css("min-width")),Math.round(ratio[1]*mCSB_dragger[1].parent().width())
|
956
|
+
],
|
957
|
+
h=oldIE && (l[1]<l[0]) ? l[0] : l[1],w=oldIE && (l[3]<l[2]) ? l[2] : l[3];
|
958
|
+
mCSB_dragger[0].css({
|
959
|
+
"height":h,"max-height":(mCSB_dragger[0].parent().height()-10)
|
960
|
+
}).find(".mCSB_dragger_bar").css({"line-height":l[0]+"px"});
|
961
|
+
mCSB_dragger[1].css({
|
962
|
+
"width":w,"max-width":(mCSB_dragger[1].parent().width()-10)
|
963
|
+
});
|
964
|
+
},
|
965
|
+
/* -------------------- */
|
966
|
+
|
967
|
+
|
968
|
+
/* calculates scrollbar to content ratio */
|
969
|
+
_scrollRatio=function(){
|
970
|
+
var $this=$(this),d=$this.data(pluginPfx),
|
971
|
+
mCustomScrollBox=$("#mCSB_"+d.idx),
|
972
|
+
mCSB_container=$("#mCSB_"+d.idx+"_container"),
|
973
|
+
mCSB_dragger=[$("#mCSB_"+d.idx+"_dragger_vertical"),$("#mCSB_"+d.idx+"_dragger_horizontal")],
|
974
|
+
scrollAmount=[mCSB_container.outerHeight(false)-mCustomScrollBox.height(),mCSB_container.outerWidth(false)-mCustomScrollBox.width()],
|
975
|
+
ratio=[
|
976
|
+
scrollAmount[0]/(mCSB_dragger[0].parent().height()-mCSB_dragger[0].height()),
|
977
|
+
scrollAmount[1]/(mCSB_dragger[1].parent().width()-mCSB_dragger[1].width())
|
978
|
+
];
|
979
|
+
d.scrollRatio={y:ratio[0],x:ratio[1]};
|
980
|
+
},
|
981
|
+
/* -------------------- */
|
982
|
+
|
983
|
+
|
984
|
+
/* toggles scrolling classes */
|
985
|
+
_onDragClasses=function(el,action,xpnd){
|
986
|
+
var expandClass=xpnd ? classes[0]+"_expanded" : "",
|
987
|
+
scrollbar=el.closest(".mCSB_scrollTools");
|
988
|
+
if(action==="active"){
|
989
|
+
el.toggleClass(classes[0]+" "+expandClass); scrollbar.toggleClass(classes[1]);
|
990
|
+
el[0]._draggable=el[0]._draggable ? 0 : 1;
|
991
|
+
}else{
|
992
|
+
if(!el[0]._draggable){
|
993
|
+
if(action==="hide"){
|
994
|
+
el.removeClass(classes[0]); scrollbar.removeClass(classes[1]);
|
995
|
+
}else{
|
996
|
+
el.addClass(classes[0]); scrollbar.addClass(classes[1]);
|
997
|
+
}
|
998
|
+
}
|
999
|
+
}
|
1000
|
+
},
|
1001
|
+
/* -------------------- */
|
1002
|
+
|
1003
|
+
|
1004
|
+
/* checks if content overflows its container to determine if scrolling is required */
|
1005
|
+
_overflowed=function(){
|
1006
|
+
var $this=$(this),d=$this.data(pluginPfx),
|
1007
|
+
mCustomScrollBox=$("#mCSB_"+d.idx),
|
1008
|
+
mCSB_container=$("#mCSB_"+d.idx+"_container"),
|
1009
|
+
contentHeight=d.overflowed==null ? mCSB_container.height() : mCSB_container.outerHeight(false),
|
1010
|
+
contentWidth=d.overflowed==null ? mCSB_container.width() : mCSB_container.outerWidth(false),
|
1011
|
+
h=mCSB_container[0].scrollHeight,w=mCSB_container[0].scrollWidth;
|
1012
|
+
if(h>contentHeight){contentHeight=h;}
|
1013
|
+
if(w>contentWidth){contentWidth=w;}
|
1014
|
+
return [contentHeight>mCustomScrollBox.height(),contentWidth>mCustomScrollBox.width()];
|
1015
|
+
},
|
1016
|
+
/* -------------------- */
|
1017
|
+
|
1018
|
+
|
1019
|
+
/* resets content position to 0 */
|
1020
|
+
_resetContentPosition=function(){
|
1021
|
+
var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
|
1022
|
+
mCustomScrollBox=$("#mCSB_"+d.idx),
|
1023
|
+
mCSB_container=$("#mCSB_"+d.idx+"_container"),
|
1024
|
+
mCSB_dragger=[$("#mCSB_"+d.idx+"_dragger_vertical"),$("#mCSB_"+d.idx+"_dragger_horizontal")];
|
1025
|
+
_stop($this); /* stop any current scrolling before resetting */
|
1026
|
+
if((o.axis!=="x" && !d.overflowed[0]) || (o.axis==="y" && d.overflowed[0])){ /* reset y */
|
1027
|
+
mCSB_dragger[0].add(mCSB_container).css("top",0);
|
1028
|
+
_scrollTo($this,"_resetY");
|
1029
|
+
}
|
1030
|
+
if((o.axis!=="y" && !d.overflowed[1]) || (o.axis==="x" && d.overflowed[1])){ /* reset x */
|
1031
|
+
var cx=dx=0;
|
1032
|
+
if(d.langDir==="rtl"){ /* adjust left position for rtl direction */
|
1033
|
+
cx=mCustomScrollBox.width()-mCSB_container.outerWidth(false);
|
1034
|
+
dx=Math.abs(cx/d.scrollRatio.x);
|
1035
|
+
}
|
1036
|
+
mCSB_container.css("left",cx);
|
1037
|
+
mCSB_dragger[1].css("left",dx);
|
1038
|
+
_scrollTo($this,"_resetX");
|
1039
|
+
}
|
1040
|
+
},
|
1041
|
+
/* -------------------- */
|
1042
|
+
|
1043
|
+
|
1044
|
+
/* binds scrollbar events */
|
1045
|
+
_bindEvents=function(){
|
1046
|
+
var $this=$(this),d=$this.data(pluginPfx),o=d.opt;
|
1047
|
+
if(!d.bindEvents){ /* check if events are already bound */
|
1048
|
+
_draggable.call(this);
|
1049
|
+
if(o.contentTouchScroll){_contentDraggable.call(this);}
|
1050
|
+
_selectable.call(this);
|
1051
|
+
if(o.mouseWheel.enable){ /* bind mousewheel fn when plugin is available */
|
1052
|
+
function _mwt(){
|
1053
|
+
mousewheelTimeout=setTimeout(function(){
|
1054
|
+
if(!$.event.special.mousewheel){
|
1055
|
+
_mwt();
|
1056
|
+
}else{
|
1057
|
+
clearTimeout(mousewheelTimeout);
|
1058
|
+
_mousewheel.call($this[0]);
|
1059
|
+
}
|
1060
|
+
},100);
|
1061
|
+
}
|
1062
|
+
var mousewheelTimeout;
|
1063
|
+
_mwt();
|
1064
|
+
}
|
1065
|
+
_draggerRail.call(this);
|
1066
|
+
_wrapperScroll.call(this);
|
1067
|
+
if(o.advanced.autoScrollOnFocus){_focus.call(this);}
|
1068
|
+
if(o.scrollButtons.enable){_buttons.call(this);}
|
1069
|
+
if(o.keyboard.enable){_keyboard.call(this);}
|
1070
|
+
d.bindEvents=true;
|
1071
|
+
}
|
1072
|
+
},
|
1073
|
+
/* -------------------- */
|
1074
|
+
|
1075
|
+
|
1076
|
+
/* unbinds scrollbar events */
|
1077
|
+
_unbindEvents=function(){
|
1078
|
+
var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
|
1079
|
+
namespace=pluginPfx+"_"+d.idx,
|
1080
|
+
sb=".mCSB_"+d.idx+"_scrollbar",
|
1081
|
+
sel=$("#mCSB_"+d.idx+",#mCSB_"+d.idx+"_container,#mCSB_"+d.idx+"_container_wrapper,"+sb+" ."+classes[12]+",#mCSB_"+d.idx+"_dragger_vertical,#mCSB_"+d.idx+"_dragger_horizontal,"+sb+">a"),
|
1082
|
+
mCSB_container=$("#mCSB_"+d.idx+"_container");
|
1083
|
+
if(o.advanced.releaseDraggableSelectors){sel.add($(o.advanced.releaseDraggableSelectors));}
|
1084
|
+
if(d.bindEvents){ /* check if events are bound */
|
1085
|
+
/* unbind namespaced events from document/selectors */
|
1086
|
+
$(document).unbind("."+namespace);
|
1087
|
+
sel.each(function(){
|
1088
|
+
$(this).unbind("."+namespace);
|
1089
|
+
});
|
1090
|
+
/* clear and delete timeouts/objects */
|
1091
|
+
clearTimeout($this[0]._focusTimeout); _delete($this[0],"_focusTimeout");
|
1092
|
+
clearTimeout(d.sequential.step); _delete(d.sequential,"step");
|
1093
|
+
clearTimeout(mCSB_container[0].onCompleteTimeout); _delete(mCSB_container[0],"onCompleteTimeout");
|
1094
|
+
d.bindEvents=false;
|
1095
|
+
}
|
1096
|
+
},
|
1097
|
+
/* -------------------- */
|
1098
|
+
|
1099
|
+
|
1100
|
+
/* toggles scrollbar visibility */
|
1101
|
+
_scrollbarVisibility=function(disabled){
|
1102
|
+
var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
|
1103
|
+
contentWrapper=$("#mCSB_"+d.idx+"_container_wrapper"),
|
1104
|
+
content=contentWrapper.length ? contentWrapper : $("#mCSB_"+d.idx+"_container"),
|
1105
|
+
scrollbar=[$("#mCSB_"+d.idx+"_scrollbar_vertical"),$("#mCSB_"+d.idx+"_scrollbar_horizontal")],
|
1106
|
+
mCSB_dragger=[scrollbar[0].find(".mCSB_dragger"),scrollbar[1].find(".mCSB_dragger")];
|
1107
|
+
if(o.axis!=="x"){
|
1108
|
+
if(d.overflowed[0] && !disabled){
|
1109
|
+
scrollbar[0].add(mCSB_dragger[0]).add(scrollbar[0].children("a")).css("display","block");
|
1110
|
+
content.removeClass(classes[8]+" "+classes[10]);
|
1111
|
+
}else{
|
1112
|
+
if(o.alwaysShowScrollbar){
|
1113
|
+
if(o.alwaysShowScrollbar!==2){mCSB_dragger[0].css("display","none");}
|
1114
|
+
content.removeClass(classes[10]);
|
1115
|
+
}else{
|
1116
|
+
scrollbar[0].css("display","none");
|
1117
|
+
content.addClass(classes[10]);
|
1118
|
+
}
|
1119
|
+
content.addClass(classes[8]);
|
1120
|
+
}
|
1121
|
+
}
|
1122
|
+
if(o.axis!=="y"){
|
1123
|
+
if(d.overflowed[1] && !disabled){
|
1124
|
+
scrollbar[1].add(mCSB_dragger[1]).add(scrollbar[1].children("a")).css("display","block");
|
1125
|
+
content.removeClass(classes[9]+" "+classes[11]);
|
1126
|
+
}else{
|
1127
|
+
if(o.alwaysShowScrollbar){
|
1128
|
+
if(o.alwaysShowScrollbar!==2){mCSB_dragger[1].css("display","none");}
|
1129
|
+
content.removeClass(classes[11]);
|
1130
|
+
}else{
|
1131
|
+
scrollbar[1].css("display","none");
|
1132
|
+
content.addClass(classes[11]);
|
1133
|
+
}
|
1134
|
+
content.addClass(classes[9]);
|
1135
|
+
}
|
1136
|
+
}
|
1137
|
+
if(!d.overflowed[0] && !d.overflowed[1]){
|
1138
|
+
$this.addClass(classes[5]);
|
1139
|
+
}else{
|
1140
|
+
$this.removeClass(classes[5]);
|
1141
|
+
}
|
1142
|
+
},
|
1143
|
+
/* -------------------- */
|
1144
|
+
|
1145
|
+
|
1146
|
+
/* returns input coordinates of pointer, touch and mouse events (relative to document) */
|
1147
|
+
_coordinates=function(e){
|
1148
|
+
var t=e.type;
|
1149
|
+
switch(t){
|
1150
|
+
case "pointerdown": case "MSPointerDown": case "pointermove": case "MSPointerMove": case "pointerup": case "MSPointerUp":
|
1151
|
+
return e.target.ownerDocument!==document ? [e.originalEvent.screenY,e.originalEvent.screenX,false] : [e.originalEvent.pageY,e.originalEvent.pageX,false];
|
1152
|
+
break;
|
1153
|
+
case "touchstart": case "touchmove": case "touchend":
|
1154
|
+
var touch=e.originalEvent.touches[0] || e.originalEvent.changedTouches[0],
|
1155
|
+
touches=e.originalEvent.touches.length || e.originalEvent.changedTouches.length;
|
1156
|
+
return e.target.ownerDocument!==document ? [touch.screenY,touch.screenX,touches>1] : [touch.pageY,touch.pageX,touches>1];
|
1157
|
+
break;
|
1158
|
+
default:
|
1159
|
+
return [e.pageY,e.pageX,false];
|
1160
|
+
}
|
1161
|
+
},
|
1162
|
+
/* -------------------- */
|
1163
|
+
|
1164
|
+
|
1165
|
+
/*
|
1166
|
+
SCROLLBAR DRAG EVENTS
|
1167
|
+
scrolls content via scrollbar dragging
|
1168
|
+
*/
|
1169
|
+
_draggable=function(){
|
1170
|
+
var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
|
1171
|
+
namespace=pluginPfx+"_"+d.idx,
|
1172
|
+
draggerId=["mCSB_"+d.idx+"_dragger_vertical","mCSB_"+d.idx+"_dragger_horizontal"],
|
1173
|
+
mCSB_container=$("#mCSB_"+d.idx+"_container"),
|
1174
|
+
mCSB_dragger=$("#"+draggerId[0]+",#"+draggerId[1]),
|
1175
|
+
draggable,dragY,dragX,
|
1176
|
+
rds=o.advanced.releaseDraggableSelectors ? mCSB_dragger.add($(o.advanced.releaseDraggableSelectors)) : mCSB_dragger;
|
1177
|
+
mCSB_dragger.bind("mousedown."+namespace+" touchstart."+namespace+" pointerdown."+namespace+" MSPointerDown."+namespace,function(e){
|
1178
|
+
e.stopImmediatePropagation();
|
1179
|
+
e.preventDefault();
|
1180
|
+
if(!_mouseBtnLeft(e)){return;} /* left mouse button only */
|
1181
|
+
touchActive=true;
|
1182
|
+
if(oldIE){document.onselectstart=function(){return false;}} /* disable text selection for IE < 9 */
|
1183
|
+
_iframe(false); /* enable scrollbar dragging over iframes by disabling their events */
|
1184
|
+
_stop($this);
|
1185
|
+
draggable=$(this);
|
1186
|
+
var offset=draggable.offset(),y=_coordinates(e)[0]-offset.top,x=_coordinates(e)[1]-offset.left,
|
1187
|
+
h=draggable.height()+offset.top,w=draggable.width()+offset.left;
|
1188
|
+
if(y<h && y>0 && x<w && x>0){
|
1189
|
+
dragY=y;
|
1190
|
+
dragX=x;
|
1191
|
+
}
|
1192
|
+
_onDragClasses(draggable,"active",o.autoExpandScrollbar);
|
1193
|
+
}).bind("touchmove."+namespace,function(e){
|
1194
|
+
e.stopImmediatePropagation();
|
1195
|
+
e.preventDefault();
|
1196
|
+
var offset=draggable.offset(),y=_coordinates(e)[0]-offset.top,x=_coordinates(e)[1]-offset.left;
|
1197
|
+
_drag(dragY,dragX,y,x);
|
1198
|
+
});
|
1199
|
+
$(document).bind("mousemove."+namespace+" pointermove."+namespace+" MSPointerMove."+namespace,function(e){
|
1200
|
+
if(draggable){
|
1201
|
+
var offset=draggable.offset(),y=_coordinates(e)[0]-offset.top,x=_coordinates(e)[1]-offset.left;
|
1202
|
+
if(dragY===y){return;} /* has it really moved? */
|
1203
|
+
_drag(dragY,dragX,y,x);
|
1204
|
+
}
|
1205
|
+
}).add(rds).bind("mouseup."+namespace+" touchend."+namespace+" pointerup."+namespace+" MSPointerUp."+namespace,function(e){
|
1206
|
+
if(draggable){
|
1207
|
+
_onDragClasses(draggable,"active",o.autoExpandScrollbar);
|
1208
|
+
draggable=null;
|
1209
|
+
}
|
1210
|
+
touchActive=false;
|
1211
|
+
if(oldIE){document.onselectstart=null;} /* enable text selection for IE < 9 */
|
1212
|
+
_iframe(true); /* enable iframes events */
|
1213
|
+
});
|
1214
|
+
function _iframe(evt){
|
1215
|
+
var el=mCSB_container.find("iframe");
|
1216
|
+
if(!el.length){return;} /* check if content contains iframes */
|
1217
|
+
var val=!evt ? "none" : "auto";
|
1218
|
+
el.css("pointer-events",val); /* for IE11, iframe's display property should not be "block" */
|
1219
|
+
}
|
1220
|
+
function _drag(dragY,dragX,y,x){
|
1221
|
+
mCSB_container[0].idleTimer=o.scrollInertia<233 ? 250 : 0;
|
1222
|
+
if(draggable.attr("id")===draggerId[1]){
|
1223
|
+
var dir="x",to=((draggable[0].offsetLeft-dragX)+x)*d.scrollRatio.x;
|
1224
|
+
}else{
|
1225
|
+
var dir="y",to=((draggable[0].offsetTop-dragY)+y)*d.scrollRatio.y;
|
1226
|
+
}
|
1227
|
+
_scrollTo($this,to.toString(),{dir:dir,drag:true});
|
1228
|
+
}
|
1229
|
+
},
|
1230
|
+
/* -------------------- */
|
1231
|
+
|
1232
|
+
|
1233
|
+
/*
|
1234
|
+
TOUCH SWIPE EVENTS
|
1235
|
+
scrolls content via touch swipe
|
1236
|
+
Emulates the native touch-swipe scrolling with momentum found in iOS, Android and WP devices
|
1237
|
+
*/
|
1238
|
+
_contentDraggable=function(){
|
1239
|
+
var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
|
1240
|
+
namespace=pluginPfx+"_"+d.idx,
|
1241
|
+
mCustomScrollBox=$("#mCSB_"+d.idx),
|
1242
|
+
mCSB_container=$("#mCSB_"+d.idx+"_container"),
|
1243
|
+
mCSB_dragger=[$("#mCSB_"+d.idx+"_dragger_vertical"),$("#mCSB_"+d.idx+"_dragger_horizontal")],
|
1244
|
+
draggable,dragY,dragX,touchStartY,touchStartX,touchMoveY=[],touchMoveX=[],startTime,runningTime,endTime,distance,speed,amount,
|
1245
|
+
durA=0,durB,overwrite=o.axis==="yx" ? "none" : "all",touchIntent=[],touchDrag,docDrag,
|
1246
|
+
iframe=mCSB_container.find("iframe"),
|
1247
|
+
events=[
|
1248
|
+
"touchstart."+namespace+" pointerdown."+namespace+" MSPointerDown."+namespace, //start
|
1249
|
+
"touchmove."+namespace+" pointermove."+namespace+" MSPointerMove."+namespace, //move
|
1250
|
+
"touchend."+namespace+" pointerup."+namespace+" MSPointerUp."+namespace //end
|
1251
|
+
],
|
1252
|
+
touchAction=document.body.style.touchAction!==undefined;
|
1253
|
+
mCSB_container.bind(events[0],function(e){
|
1254
|
+
_onTouchstart(e);
|
1255
|
+
}).bind(events[1],function(e){
|
1256
|
+
_onTouchmove(e);
|
1257
|
+
});
|
1258
|
+
mCustomScrollBox.bind(events[0],function(e){
|
1259
|
+
_onTouchstart2(e);
|
1260
|
+
}).bind(events[2],function(e){
|
1261
|
+
_onTouchend(e);
|
1262
|
+
});
|
1263
|
+
if(iframe.length){
|
1264
|
+
iframe.each(function(){
|
1265
|
+
$(this).load(function(){
|
1266
|
+
/* bind events on accessible iframes */
|
1267
|
+
if(_canAccessIFrame(this)){
|
1268
|
+
$(this.contentDocument || this.contentWindow.document).bind(events[0],function(e){
|
1269
|
+
_onTouchstart(e);
|
1270
|
+
_onTouchstart2(e);
|
1271
|
+
}).bind(events[1],function(e){
|
1272
|
+
_onTouchmove(e);
|
1273
|
+
}).bind(events[2],function(e){
|
1274
|
+
_onTouchend(e);
|
1275
|
+
});
|
1276
|
+
}
|
1277
|
+
});
|
1278
|
+
});
|
1279
|
+
}
|
1280
|
+
function _onTouchstart(e){
|
1281
|
+
if(!_pointerTouch(e) || touchActive || _coordinates(e)[2]){touchable=0; return;}
|
1282
|
+
touchable=1; touchDrag=0; docDrag=0; draggable=1;
|
1283
|
+
$this.removeClass("mCS_touch_action");
|
1284
|
+
var offset=mCSB_container.offset();
|
1285
|
+
dragY=_coordinates(e)[0]-offset.top;
|
1286
|
+
dragX=_coordinates(e)[1]-offset.left;
|
1287
|
+
touchIntent=[_coordinates(e)[0],_coordinates(e)[1]];
|
1288
|
+
}
|
1289
|
+
function _onTouchmove(e){
|
1290
|
+
if(!_pointerTouch(e) || touchActive || _coordinates(e)[2]){return;}
|
1291
|
+
e.stopImmediatePropagation();
|
1292
|
+
if(docDrag && !touchDrag){return;}
|
1293
|
+
if(draggable){
|
1294
|
+
runningTime=_getTime();
|
1295
|
+
var offset=mCustomScrollBox.offset(),y=_coordinates(e)[0]-offset.top,x=_coordinates(e)[1]-offset.left,
|
1296
|
+
easing="mcsLinearOut";
|
1297
|
+
touchMoveY.push(y);
|
1298
|
+
touchMoveX.push(x);
|
1299
|
+
touchIntent[2]=Math.abs(_coordinates(e)[0]-touchIntent[0]); touchIntent[3]=Math.abs(_coordinates(e)[1]-touchIntent[1]);
|
1300
|
+
if(d.overflowed[0]){
|
1301
|
+
var limit=mCSB_dragger[0].parent().height()-mCSB_dragger[0].height(),
|
1302
|
+
prevent=((dragY-y)>0 && (y-dragY)>-(limit*d.scrollRatio.y) && (touchIntent[3]*2<touchIntent[2] || o.axis==="yx"));
|
1303
|
+
}
|
1304
|
+
if(d.overflowed[1]){
|
1305
|
+
var limitX=mCSB_dragger[1].parent().width()-mCSB_dragger[1].width(),
|
1306
|
+
preventX=((dragX-x)>0 && (x-dragX)>-(limitX*d.scrollRatio.x) && (touchIntent[2]*2<touchIntent[3] || o.axis==="yx"));
|
1307
|
+
}
|
1308
|
+
if(prevent || preventX){ /* prevent native document scrolling */
|
1309
|
+
if(!touchAction){e.preventDefault();}
|
1310
|
+
touchDrag=1;
|
1311
|
+
}else{
|
1312
|
+
docDrag=1;
|
1313
|
+
$this.addClass("mCS_touch_action");
|
1314
|
+
}
|
1315
|
+
if(touchAction){e.preventDefault();}
|
1316
|
+
amount=o.axis==="yx" ? [(dragY-y),(dragX-x)] : o.axis==="x" ? [null,(dragX-x)] : [(dragY-y),null];
|
1317
|
+
mCSB_container[0].idleTimer=250;
|
1318
|
+
if(d.overflowed[0]){_drag(amount[0],durA,easing,"y","all",true);}
|
1319
|
+
if(d.overflowed[1]){_drag(amount[1],durA,easing,"x",overwrite,true);}
|
1320
|
+
}
|
1321
|
+
}
|
1322
|
+
function _onTouchstart2(e){
|
1323
|
+
if(!_pointerTouch(e) || touchActive || _coordinates(e)[2]){touchable=0; return;}
|
1324
|
+
touchable=1;
|
1325
|
+
e.stopImmediatePropagation();
|
1326
|
+
_stop($this);
|
1327
|
+
startTime=_getTime();
|
1328
|
+
var offset=mCustomScrollBox.offset();
|
1329
|
+
touchStartY=_coordinates(e)[0]-offset.top;
|
1330
|
+
touchStartX=_coordinates(e)[1]-offset.left;
|
1331
|
+
touchMoveY=[]; touchMoveX=[];
|
1332
|
+
}
|
1333
|
+
function _onTouchend(e){
|
1334
|
+
if(!_pointerTouch(e) || touchActive || _coordinates(e)[2]){return;}
|
1335
|
+
draggable=0;
|
1336
|
+
e.stopImmediatePropagation();
|
1337
|
+
touchDrag=0; docDrag=0;
|
1338
|
+
endTime=_getTime();
|
1339
|
+
var offset=mCustomScrollBox.offset(),y=_coordinates(e)[0]-offset.top,x=_coordinates(e)[1]-offset.left;
|
1340
|
+
if((endTime-runningTime)>30){return;}
|
1341
|
+
speed=1000/(endTime-startTime);
|
1342
|
+
var easing="mcsEaseOut",slow=speed<2.5,
|
1343
|
+
diff=slow ? [touchMoveY[touchMoveY.length-2],touchMoveX[touchMoveX.length-2]] : [0,0];
|
1344
|
+
distance=slow ? [(y-diff[0]),(x-diff[1])] : [y-touchStartY,x-touchStartX];
|
1345
|
+
var absDistance=[Math.abs(distance[0]),Math.abs(distance[1])];
|
1346
|
+
speed=slow ? [Math.abs(distance[0]/4),Math.abs(distance[1]/4)] : [speed,speed];
|
1347
|
+
var a=[
|
1348
|
+
Math.abs(mCSB_container[0].offsetTop)-(distance[0]*_m((absDistance[0]/speed[0]),speed[0])),
|
1349
|
+
Math.abs(mCSB_container[0].offsetLeft)-(distance[1]*_m((absDistance[1]/speed[1]),speed[1]))
|
1350
|
+
];
|
1351
|
+
amount=o.axis==="yx" ? [a[0],a[1]] : o.axis==="x" ? [null,a[1]] : [a[0],null];
|
1352
|
+
durB=[(absDistance[0]*4)+o.scrollInertia,(absDistance[1]*4)+o.scrollInertia];
|
1353
|
+
var md=parseInt(o.contentTouchScroll) || 0; /* absolute minimum distance required */
|
1354
|
+
amount[0]=absDistance[0]>md ? amount[0] : 0;
|
1355
|
+
amount[1]=absDistance[1]>md ? amount[1] : 0;
|
1356
|
+
if(d.overflowed[0]){_drag(amount[0],durB[0],easing,"y",overwrite,false);}
|
1357
|
+
if(d.overflowed[1]){_drag(amount[1],durB[1],easing,"x",overwrite,false);}
|
1358
|
+
}
|
1359
|
+
function _m(ds,s){
|
1360
|
+
var r=[s*1.5,s*2,s/1.5,s/2];
|
1361
|
+
if(ds>90){
|
1362
|
+
return s>4 ? r[0] : r[3];
|
1363
|
+
}else if(ds>60){
|
1364
|
+
return s>3 ? r[3] : r[2];
|
1365
|
+
}else if(ds>30){
|
1366
|
+
return s>8 ? r[1] : s>6 ? r[0] : s>4 ? s : r[2];
|
1367
|
+
}else{
|
1368
|
+
return s>8 ? s : r[3];
|
1369
|
+
}
|
1370
|
+
}
|
1371
|
+
function _drag(amount,dur,easing,dir,overwrite,drag){
|
1372
|
+
if(!amount){return;}
|
1373
|
+
_scrollTo($this,amount.toString(),{dur:dur,scrollEasing:easing,dir:dir,overwrite:overwrite,drag:drag});
|
1374
|
+
}
|
1375
|
+
},
|
1376
|
+
/* -------------------- */
|
1377
|
+
|
1378
|
+
|
1379
|
+
/*
|
1380
|
+
SELECT TEXT EVENTS
|
1381
|
+
scrolls content when text is selected
|
1382
|
+
*/
|
1383
|
+
_selectable=function(){
|
1384
|
+
var $this=$(this),d=$this.data(pluginPfx),o=d.opt,seq=d.sequential,
|
1385
|
+
namespace=pluginPfx+"_"+d.idx,
|
1386
|
+
mCSB_container=$("#mCSB_"+d.idx+"_container"),
|
1387
|
+
wrapper=mCSB_container.parent(),
|
1388
|
+
action;
|
1389
|
+
mCSB_container.bind("mousedown."+namespace,function(e){
|
1390
|
+
if(touchable){return;}
|
1391
|
+
if(!action){action=1; touchActive=true;}
|
1392
|
+
}).add(document).bind("mousemove."+namespace,function(e){
|
1393
|
+
if(!touchable && action && _sel()){
|
1394
|
+
var offset=mCSB_container.offset(),
|
1395
|
+
y=_coordinates(e)[0]-offset.top+mCSB_container[0].offsetTop,x=_coordinates(e)[1]-offset.left+mCSB_container[0].offsetLeft;
|
1396
|
+
if(y>0 && y<wrapper.height() && x>0 && x<wrapper.width()){
|
1397
|
+
if(seq.step){_seq("off",null,"stepped");}
|
1398
|
+
}else{
|
1399
|
+
if(o.axis!=="x" && d.overflowed[0]){
|
1400
|
+
if(y<0){
|
1401
|
+
_seq("on",38);
|
1402
|
+
}else if(y>wrapper.height()){
|
1403
|
+
_seq("on",40);
|
1404
|
+
}
|
1405
|
+
}
|
1406
|
+
if(o.axis!=="y" && d.overflowed[1]){
|
1407
|
+
if(x<0){
|
1408
|
+
_seq("on",37);
|
1409
|
+
}else if(x>wrapper.width()){
|
1410
|
+
_seq("on",39);
|
1411
|
+
}
|
1412
|
+
}
|
1413
|
+
}
|
1414
|
+
}
|
1415
|
+
}).bind("mouseup."+namespace+" dragend."+namespace,function(e){
|
1416
|
+
if(touchable){return;}
|
1417
|
+
if(action){action=0; _seq("off",null);}
|
1418
|
+
touchActive=false;
|
1419
|
+
});
|
1420
|
+
function _sel(){
|
1421
|
+
return window.getSelection ? window.getSelection().toString() :
|
1422
|
+
document.selection && document.selection.type!="Control" ? document.selection.createRange().text : 0;
|
1423
|
+
}
|
1424
|
+
function _seq(a,c,s){
|
1425
|
+
seq.type=s && action ? "stepped" : "stepless";
|
1426
|
+
seq.scrollAmount=10;
|
1427
|
+
_sequentialScroll($this,a,c,"mcsLinearOut",s ? 60 : null);
|
1428
|
+
}
|
1429
|
+
},
|
1430
|
+
/* -------------------- */
|
1431
|
+
|
1432
|
+
|
1433
|
+
/*
|
1434
|
+
MOUSE WHEEL EVENT
|
1435
|
+
scrolls content via mouse-wheel
|
1436
|
+
via mouse-wheel plugin (https://github.com/brandonaaron/jquery-mousewheel)
|
1437
|
+
*/
|
1438
|
+
_mousewheel=function(){
|
1439
|
+
if(!$(this).data(pluginPfx)){return;} /* Check if the scrollbar is ready to use mousewheel events (issue: #185) */
|
1440
|
+
var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
|
1441
|
+
namespace=pluginPfx+"_"+d.idx,
|
1442
|
+
mCustomScrollBox=$("#mCSB_"+d.idx),
|
1443
|
+
mCSB_dragger=[$("#mCSB_"+d.idx+"_dragger_vertical"),$("#mCSB_"+d.idx+"_dragger_horizontal")],
|
1444
|
+
iframe=$("#mCSB_"+d.idx+"_container").find("iframe");
|
1445
|
+
if(iframe.length){
|
1446
|
+
iframe.each(function(){
|
1447
|
+
$(this).load(function(){
|
1448
|
+
/* bind events on accessible iframes */
|
1449
|
+
if(_canAccessIFrame(this)){
|
1450
|
+
$(this.contentDocument || this.contentWindow.document).bind("mousewheel."+namespace,function(e,delta){
|
1451
|
+
_onMousewheel(e,delta);
|
1452
|
+
});
|
1453
|
+
}
|
1454
|
+
});
|
1455
|
+
});
|
1456
|
+
}
|
1457
|
+
mCustomScrollBox.bind("mousewheel."+namespace,function(e,delta){
|
1458
|
+
_onMousewheel(e,delta);
|
1459
|
+
});
|
1460
|
+
function _onMousewheel(e,delta){
|
1461
|
+
_stop($this);
|
1462
|
+
if(_disableMousewheel($this,e.target)){return;} /* disables mouse-wheel when hovering specific elements */
|
1463
|
+
var deltaFactor=o.mouseWheel.deltaFactor!=="auto" ? parseInt(o.mouseWheel.deltaFactor) : (oldIE && e.deltaFactor<100) ? 100 : e.deltaFactor || 100;
|
1464
|
+
if(o.axis==="x" || o.mouseWheel.axis==="x"){
|
1465
|
+
var dir="x",
|
1466
|
+
px=[Math.round(deltaFactor*d.scrollRatio.x),parseInt(o.mouseWheel.scrollAmount)],
|
1467
|
+
amount=o.mouseWheel.scrollAmount!=="auto" ? px[1] : px[0]>=mCustomScrollBox.width() ? mCustomScrollBox.width()*0.9 : px[0],
|
1468
|
+
contentPos=Math.abs($("#mCSB_"+d.idx+"_container")[0].offsetLeft),
|
1469
|
+
draggerPos=mCSB_dragger[1][0].offsetLeft,
|
1470
|
+
limit=mCSB_dragger[1].parent().width()-mCSB_dragger[1].width(),
|
1471
|
+
dlt=e.deltaX || e.deltaY || delta;
|
1472
|
+
}else{
|
1473
|
+
var dir="y",
|
1474
|
+
px=[Math.round(deltaFactor*d.scrollRatio.y),parseInt(o.mouseWheel.scrollAmount)],
|
1475
|
+
amount=o.mouseWheel.scrollAmount!=="auto" ? px[1] : px[0]>=mCustomScrollBox.height() ? mCustomScrollBox.height()*0.9 : px[0],
|
1476
|
+
contentPos=Math.abs($("#mCSB_"+d.idx+"_container")[0].offsetTop),
|
1477
|
+
draggerPos=mCSB_dragger[0][0].offsetTop,
|
1478
|
+
limit=mCSB_dragger[0].parent().height()-mCSB_dragger[0].height(),
|
1479
|
+
dlt=e.deltaY || delta;
|
1480
|
+
}
|
1481
|
+
if((dir==="y" && !d.overflowed[0]) || (dir==="x" && !d.overflowed[1])){return;}
|
1482
|
+
if(o.mouseWheel.invert || e.webkitDirectionInvertedFromDevice){dlt=-dlt;}
|
1483
|
+
if(o.mouseWheel.normalizeDelta){dlt=dlt<0 ? -1 : 1;}
|
1484
|
+
if((dlt>0 && draggerPos!==0) || (dlt<0 && draggerPos!==limit) || o.mouseWheel.preventDefault){
|
1485
|
+
e.stopImmediatePropagation();
|
1486
|
+
e.preventDefault();
|
1487
|
+
}
|
1488
|
+
_scrollTo($this,(contentPos-(dlt*amount)).toString(),{dir:dir});
|
1489
|
+
}
|
1490
|
+
},
|
1491
|
+
/* -------------------- */
|
1492
|
+
|
1493
|
+
|
1494
|
+
/* checks if iframe can be accessed */
|
1495
|
+
_canAccessIFrame=function(iframe){
|
1496
|
+
var html=null;
|
1497
|
+
try{
|
1498
|
+
var doc=iframe.contentDocument || iframe.contentWindow.document;
|
1499
|
+
html=doc.body.innerHTML;
|
1500
|
+
}catch(err){/* do nothing */}
|
1501
|
+
return(html!==null);
|
1502
|
+
},
|
1503
|
+
/* -------------------- */
|
1504
|
+
|
1505
|
+
|
1506
|
+
/* disables mouse-wheel when hovering specific elements like select, datalist etc. */
|
1507
|
+
_disableMousewheel=function(el,target){
|
1508
|
+
var tag=target.nodeName.toLowerCase(),
|
1509
|
+
tags=el.data(pluginPfx).opt.mouseWheel.disableOver,
|
1510
|
+
/* elements that require focus */
|
1511
|
+
focusTags=["select","textarea"];
|
1512
|
+
return $.inArray(tag,tags) > -1 && !($.inArray(tag,focusTags) > -1 && !$(target).is(":focus"));
|
1513
|
+
},
|
1514
|
+
/* -------------------- */
|
1515
|
+
|
1516
|
+
|
1517
|
+
/*
|
1518
|
+
DRAGGER RAIL CLICK EVENT
|
1519
|
+
scrolls content via dragger rail
|
1520
|
+
*/
|
1521
|
+
_draggerRail=function(){
|
1522
|
+
var $this=$(this),d=$this.data(pluginPfx),
|
1523
|
+
namespace=pluginPfx+"_"+d.idx,
|
1524
|
+
mCSB_container=$("#mCSB_"+d.idx+"_container"),
|
1525
|
+
wrapper=mCSB_container.parent(),
|
1526
|
+
mCSB_draggerContainer=$(".mCSB_"+d.idx+"_scrollbar ."+classes[12]);
|
1527
|
+
mCSB_draggerContainer.bind("touchstart."+namespace+" pointerdown."+namespace+" MSPointerDown."+namespace,function(e){
|
1528
|
+
touchActive=true;
|
1529
|
+
}).bind("touchend."+namespace+" pointerup."+namespace+" MSPointerUp."+namespace,function(e){
|
1530
|
+
touchActive=false;
|
1531
|
+
}).bind("click."+namespace,function(e){
|
1532
|
+
if($(e.target).hasClass(classes[12]) || $(e.target).hasClass("mCSB_draggerRail")){
|
1533
|
+
_stop($this);
|
1534
|
+
var el=$(this),mCSB_dragger=el.find(".mCSB_dragger");
|
1535
|
+
if(el.parent(".mCSB_scrollTools_horizontal").length>0){
|
1536
|
+
if(!d.overflowed[1]){return;}
|
1537
|
+
var dir="x",
|
1538
|
+
clickDir=e.pageX>mCSB_dragger.offset().left ? -1 : 1,
|
1539
|
+
to=Math.abs(mCSB_container[0].offsetLeft)-(clickDir*(wrapper.width()*0.9));
|
1540
|
+
}else{
|
1541
|
+
if(!d.overflowed[0]){return;}
|
1542
|
+
var dir="y",
|
1543
|
+
clickDir=e.pageY>mCSB_dragger.offset().top ? -1 : 1,
|
1544
|
+
to=Math.abs(mCSB_container[0].offsetTop)-(clickDir*(wrapper.height()*0.9));
|
1545
|
+
}
|
1546
|
+
_scrollTo($this,to.toString(),{dir:dir,scrollEasing:"mcsEaseInOut"});
|
1547
|
+
}
|
1548
|
+
});
|
1549
|
+
},
|
1550
|
+
/* -------------------- */
|
1551
|
+
|
1552
|
+
|
1553
|
+
/*
|
1554
|
+
FOCUS EVENT
|
1555
|
+
scrolls content via element focus (e.g. clicking an input, pressing TAB key etc.)
|
1556
|
+
*/
|
1557
|
+
_focus=function(){
|
1558
|
+
var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
|
1559
|
+
namespace=pluginPfx+"_"+d.idx,
|
1560
|
+
mCSB_container=$("#mCSB_"+d.idx+"_container"),
|
1561
|
+
wrapper=mCSB_container.parent();
|
1562
|
+
mCSB_container.bind("focusin."+namespace,function(e){
|
1563
|
+
var el=$(document.activeElement),
|
1564
|
+
nested=mCSB_container.find(".mCustomScrollBox").length,
|
1565
|
+
dur=0;
|
1566
|
+
if(!el.is(o.advanced.autoScrollOnFocus)){return;}
|
1567
|
+
_stop($this);
|
1568
|
+
clearTimeout($this[0]._focusTimeout);
|
1569
|
+
$this[0]._focusTimer=nested ? (dur+17)*nested : 0;
|
1570
|
+
$this[0]._focusTimeout=setTimeout(function(){
|
1571
|
+
var to=[_childPos(el)[0],_childPos(el)[1]],
|
1572
|
+
contentPos=[mCSB_container[0].offsetTop,mCSB_container[0].offsetLeft],
|
1573
|
+
isVisible=[
|
1574
|
+
(contentPos[0]+to[0]>=0 && contentPos[0]+to[0]<wrapper.height()-el.outerHeight(false)),
|
1575
|
+
(contentPos[1]+to[1]>=0 && contentPos[0]+to[1]<wrapper.width()-el.outerWidth(false))
|
1576
|
+
],
|
1577
|
+
overwrite=(o.axis==="yx" && !isVisible[0] && !isVisible[1]) ? "none" : "all";
|
1578
|
+
if(o.axis!=="x" && !isVisible[0]){
|
1579
|
+
_scrollTo($this,to[0].toString(),{dir:"y",scrollEasing:"mcsEaseInOut",overwrite:overwrite,dur:dur});
|
1580
|
+
}
|
1581
|
+
if(o.axis!=="y" && !isVisible[1]){
|
1582
|
+
_scrollTo($this,to[1].toString(),{dir:"x",scrollEasing:"mcsEaseInOut",overwrite:overwrite,dur:dur});
|
1583
|
+
}
|
1584
|
+
},$this[0]._focusTimer);
|
1585
|
+
});
|
1586
|
+
},
|
1587
|
+
/* -------------------- */
|
1588
|
+
|
1589
|
+
|
1590
|
+
/* sets content wrapper scrollTop/scrollLeft always to 0 */
|
1591
|
+
_wrapperScroll=function(){
|
1592
|
+
var $this=$(this),d=$this.data(pluginPfx),
|
1593
|
+
namespace=pluginPfx+"_"+d.idx,
|
1594
|
+
wrapper=$("#mCSB_"+d.idx+"_container").parent();
|
1595
|
+
wrapper.bind("scroll."+namespace,function(e){
|
1596
|
+
if(wrapper.scrollTop()!==0 || wrapper.scrollLeft()!==0){
|
1597
|
+
$(".mCSB_"+d.idx+"_scrollbar").css("visibility","hidden"); /* hide scrollbar(s) */
|
1598
|
+
}
|
1599
|
+
});
|
1600
|
+
},
|
1601
|
+
/* -------------------- */
|
1602
|
+
|
1603
|
+
|
1604
|
+
/*
|
1605
|
+
BUTTONS EVENTS
|
1606
|
+
scrolls content via up, down, left and right buttons
|
1607
|
+
*/
|
1608
|
+
_buttons=function(){
|
1609
|
+
var $this=$(this),d=$this.data(pluginPfx),o=d.opt,seq=d.sequential,
|
1610
|
+
namespace=pluginPfx+"_"+d.idx,
|
1611
|
+
sel=".mCSB_"+d.idx+"_scrollbar",
|
1612
|
+
btn=$(sel+">a");
|
1613
|
+
btn.bind("mousedown."+namespace+" touchstart."+namespace+" pointerdown."+namespace+" MSPointerDown."+namespace+" mouseup."+namespace+" touchend."+namespace+" pointerup."+namespace+" MSPointerUp."+namespace+" mouseout."+namespace+" pointerout."+namespace+" MSPointerOut."+namespace+" click."+namespace,function(e){
|
1614
|
+
e.preventDefault();
|
1615
|
+
if(!_mouseBtnLeft(e)){return;} /* left mouse button only */
|
1616
|
+
var btnClass=$(this).attr("class");
|
1617
|
+
seq.type=o.scrollButtons.scrollType;
|
1618
|
+
switch(e.type){
|
1619
|
+
case "mousedown": case "touchstart": case "pointerdown": case "MSPointerDown":
|
1620
|
+
if(seq.type==="stepped"){return;}
|
1621
|
+
touchActive=true;
|
1622
|
+
d.tweenRunning=false;
|
1623
|
+
_seq("on",btnClass);
|
1624
|
+
break;
|
1625
|
+
case "mouseup": case "touchend": case "pointerup": case "MSPointerUp":
|
1626
|
+
case "mouseout": case "pointerout": case "MSPointerOut":
|
1627
|
+
if(seq.type==="stepped"){return;}
|
1628
|
+
touchActive=false;
|
1629
|
+
if(seq.dir){_seq("off",btnClass);}
|
1630
|
+
break;
|
1631
|
+
case "click":
|
1632
|
+
if(seq.type!=="stepped" || d.tweenRunning){return;}
|
1633
|
+
_seq("on",btnClass);
|
1634
|
+
break;
|
1635
|
+
}
|
1636
|
+
function _seq(a,c){
|
1637
|
+
seq.scrollAmount=o.snapAmount || o.scrollButtons.scrollAmount;
|
1638
|
+
_sequentialScroll($this,a,c);
|
1639
|
+
}
|
1640
|
+
});
|
1641
|
+
},
|
1642
|
+
/* -------------------- */
|
1643
|
+
|
1644
|
+
|
1645
|
+
/*
|
1646
|
+
KEYBOARD EVENTS
|
1647
|
+
scrolls content via keyboard
|
1648
|
+
Keys: up arrow, down arrow, left arrow, right arrow, PgUp, PgDn, Home, End
|
1649
|
+
*/
|
1650
|
+
_keyboard=function(){
|
1651
|
+
var $this=$(this),d=$this.data(pluginPfx),o=d.opt,seq=d.sequential,
|
1652
|
+
namespace=pluginPfx+"_"+d.idx,
|
1653
|
+
mCustomScrollBox=$("#mCSB_"+d.idx),
|
1654
|
+
mCSB_container=$("#mCSB_"+d.idx+"_container"),
|
1655
|
+
wrapper=mCSB_container.parent(),
|
1656
|
+
editables="input,textarea,select,datalist,keygen,[contenteditable='true']",
|
1657
|
+
iframe=mCSB_container.find("iframe"),
|
1658
|
+
events=["blur."+namespace+" keydown."+namespace+" keyup."+namespace];
|
1659
|
+
if(iframe.length){
|
1660
|
+
iframe.each(function(){
|
1661
|
+
$(this).load(function(){
|
1662
|
+
/* bind events on accessible iframes */
|
1663
|
+
if(_canAccessIFrame(this)){
|
1664
|
+
$(this.contentDocument || this.contentWindow.document).bind(events[0],function(e){
|
1665
|
+
_onKeyboard(e);
|
1666
|
+
});
|
1667
|
+
}
|
1668
|
+
});
|
1669
|
+
});
|
1670
|
+
}
|
1671
|
+
mCustomScrollBox.attr("tabindex","0").bind(events[0],function(e){
|
1672
|
+
_onKeyboard(e);
|
1673
|
+
});
|
1674
|
+
function _onKeyboard(e){
|
1675
|
+
switch(e.type){
|
1676
|
+
case "blur":
|
1677
|
+
if(d.tweenRunning && seq.dir){_seq("off",null);}
|
1678
|
+
break;
|
1679
|
+
case "keydown": case "keyup":
|
1680
|
+
var code=e.keyCode ? e.keyCode : e.which,action="on";
|
1681
|
+
if((o.axis!=="x" && (code===38 || code===40)) || (o.axis!=="y" && (code===37 || code===39))){
|
1682
|
+
/* up (38), down (40), left (37), right (39) arrows */
|
1683
|
+
if(((code===38 || code===40) && !d.overflowed[0]) || ((code===37 || code===39) && !d.overflowed[1])){return;}
|
1684
|
+
if(e.type==="keyup"){action="off";}
|
1685
|
+
if(!$(document.activeElement).is(editables)){
|
1686
|
+
e.preventDefault();
|
1687
|
+
e.stopImmediatePropagation();
|
1688
|
+
_seq(action,code);
|
1689
|
+
}
|
1690
|
+
}else if(code===33 || code===34){
|
1691
|
+
/* PgUp (33), PgDn (34) */
|
1692
|
+
if(d.overflowed[0] || d.overflowed[1]){
|
1693
|
+
e.preventDefault();
|
1694
|
+
e.stopImmediatePropagation();
|
1695
|
+
}
|
1696
|
+
if(e.type==="keyup"){
|
1697
|
+
_stop($this);
|
1698
|
+
var keyboardDir=code===34 ? -1 : 1;
|
1699
|
+
if(o.axis==="x" || (o.axis==="yx" && d.overflowed[1] && !d.overflowed[0])){
|
1700
|
+
var dir="x",to=Math.abs(mCSB_container[0].offsetLeft)-(keyboardDir*(wrapper.width()*0.9));
|
1701
|
+
}else{
|
1702
|
+
var dir="y",to=Math.abs(mCSB_container[0].offsetTop)-(keyboardDir*(wrapper.height()*0.9));
|
1703
|
+
}
|
1704
|
+
_scrollTo($this,to.toString(),{dir:dir,scrollEasing:"mcsEaseInOut"});
|
1705
|
+
}
|
1706
|
+
}else if(code===35 || code===36){
|
1707
|
+
/* End (35), Home (36) */
|
1708
|
+
if(!$(document.activeElement).is(editables)){
|
1709
|
+
if(d.overflowed[0] || d.overflowed[1]){
|
1710
|
+
e.preventDefault();
|
1711
|
+
e.stopImmediatePropagation();
|
1712
|
+
}
|
1713
|
+
if(e.type==="keyup"){
|
1714
|
+
if(o.axis==="x" || (o.axis==="yx" && d.overflowed[1] && !d.overflowed[0])){
|
1715
|
+
var dir="x",to=code===35 ? Math.abs(wrapper.width()-mCSB_container.outerWidth(false)) : 0;
|
1716
|
+
}else{
|
1717
|
+
var dir="y",to=code===35 ? Math.abs(wrapper.height()-mCSB_container.outerHeight(false)) : 0;
|
1718
|
+
}
|
1719
|
+
_scrollTo($this,to.toString(),{dir:dir,scrollEasing:"mcsEaseInOut"});
|
1720
|
+
}
|
1721
|
+
}
|
1722
|
+
}
|
1723
|
+
break;
|
1724
|
+
}
|
1725
|
+
function _seq(a,c){
|
1726
|
+
seq.type=o.keyboard.scrollType;
|
1727
|
+
seq.scrollAmount=o.snapAmount || o.keyboard.scrollAmount;
|
1728
|
+
if(seq.type==="stepped" && d.tweenRunning){return;}
|
1729
|
+
_sequentialScroll($this,a,c);
|
1730
|
+
}
|
1731
|
+
}
|
1732
|
+
},
|
1733
|
+
/* -------------------- */
|
1734
|
+
|
1735
|
+
|
1736
|
+
/* scrolls content sequentially (used when scrolling via buttons, keyboard arrows etc.) */
|
1737
|
+
_sequentialScroll=function(el,action,trigger,e,s){
|
1738
|
+
var d=el.data(pluginPfx),o=d.opt,seq=d.sequential,
|
1739
|
+
mCSB_container=$("#mCSB_"+d.idx+"_container"),
|
1740
|
+
once=seq.type==="stepped" ? true : false,
|
1741
|
+
steplessSpeed=o.scrollInertia < 26 ? 26 : o.scrollInertia, /* 26/1.5=17 */
|
1742
|
+
steppedSpeed=o.scrollInertia < 1 ? 17 : o.scrollInertia;
|
1743
|
+
switch(action){
|
1744
|
+
case "on":
|
1745
|
+
seq.dir=[
|
1746
|
+
(trigger===classes[16] || trigger===classes[15] || trigger===39 || trigger===37 ? "x" : "y"),
|
1747
|
+
(trigger===classes[13] || trigger===classes[15] || trigger===38 || trigger===37 ? -1 : 1)
|
1748
|
+
];
|
1749
|
+
_stop(el);
|
1750
|
+
if(_isNumeric(trigger) && seq.type==="stepped"){return;}
|
1751
|
+
_on(once);
|
1752
|
+
break;
|
1753
|
+
case "off":
|
1754
|
+
_off();
|
1755
|
+
if(once || (d.tweenRunning && seq.dir)){
|
1756
|
+
_on(true);
|
1757
|
+
}
|
1758
|
+
break;
|
1759
|
+
}
|
1760
|
+
/* starts sequence */
|
1761
|
+
function _on(once){
|
1762
|
+
var c=seq.type!=="stepped", /* continuous scrolling */
|
1763
|
+
t=s ? s : !once ? 1000/60 : c ? steplessSpeed/1.5 : steppedSpeed, /* timer */
|
1764
|
+
m=!once ? 2.5 : c ? 7.5 : 40, /* multiplier */
|
1765
|
+
contentPos=[Math.abs(mCSB_container[0].offsetTop),Math.abs(mCSB_container[0].offsetLeft)],
|
1766
|
+
ratio=[d.scrollRatio.y>10 ? 10 : d.scrollRatio.y,d.scrollRatio.x>10 ? 10 : d.scrollRatio.x],
|
1767
|
+
amount=seq.dir[0]==="x" ? contentPos[1]+(seq.dir[1]*(ratio[1]*m)) : contentPos[0]+(seq.dir[1]*(ratio[0]*m)),
|
1768
|
+
px=seq.dir[0]==="x" ? contentPos[1]+(seq.dir[1]*parseInt(seq.scrollAmount)) : contentPos[0]+(seq.dir[1]*parseInt(seq.scrollAmount)),
|
1769
|
+
to=seq.scrollAmount!=="auto" ? px : amount,
|
1770
|
+
easing=e ? e : !once ? "mcsLinear" : c ? "mcsLinearOut" : "mcsEaseInOut",
|
1771
|
+
onComplete=!once ? false : true;
|
1772
|
+
if(once && t<17){
|
1773
|
+
to=seq.dir[0]==="x" ? contentPos[1] : contentPos[0];
|
1774
|
+
}
|
1775
|
+
_scrollTo(el,to.toString(),{dir:seq.dir[0],scrollEasing:easing,dur:t,onComplete:onComplete});
|
1776
|
+
if(once){
|
1777
|
+
seq.dir=false;
|
1778
|
+
return;
|
1779
|
+
}
|
1780
|
+
clearTimeout(seq.step);
|
1781
|
+
seq.step=setTimeout(function(){
|
1782
|
+
_on();
|
1783
|
+
},t);
|
1784
|
+
}
|
1785
|
+
/* stops sequence */
|
1786
|
+
function _off(){
|
1787
|
+
clearTimeout(seq.step);
|
1788
|
+
_delete(seq,"step");
|
1789
|
+
_stop(el);
|
1790
|
+
}
|
1791
|
+
},
|
1792
|
+
/* -------------------- */
|
1793
|
+
|
1794
|
+
|
1795
|
+
/* returns a yx array from value */
|
1796
|
+
_arr=function(val){
|
1797
|
+
var o=$(this).data(pluginPfx).opt,vals=[];
|
1798
|
+
if(typeof val==="function"){val=val();} /* check if the value is a single anonymous function */
|
1799
|
+
/* check if value is object or array, its length and create an array with yx values */
|
1800
|
+
if(!(val instanceof Array)){ /* object value (e.g. {y:"100",x:"100"}, 100 etc.) */
|
1801
|
+
vals[0]=val.y ? val.y : val.x || o.axis==="x" ? null : val;
|
1802
|
+
vals[1]=val.x ? val.x : val.y || o.axis==="y" ? null : val;
|
1803
|
+
}else{ /* array value (e.g. [100,100]) */
|
1804
|
+
vals=val.length>1 ? [val[0],val[1]] : o.axis==="x" ? [null,val[0]] : [val[0],null];
|
1805
|
+
}
|
1806
|
+
/* check if array values are anonymous functions */
|
1807
|
+
if(typeof vals[0]==="function"){vals[0]=vals[0]();}
|
1808
|
+
if(typeof vals[1]==="function"){vals[1]=vals[1]();}
|
1809
|
+
return vals;
|
1810
|
+
},
|
1811
|
+
/* -------------------- */
|
1812
|
+
|
1813
|
+
|
1814
|
+
/* translates values (e.g. "top", 100, "100px", "#id") to actual scroll-to positions */
|
1815
|
+
_to=function(val,dir){
|
1816
|
+
if(val==null || typeof val=="undefined"){return;}
|
1817
|
+
var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
|
1818
|
+
mCSB_container=$("#mCSB_"+d.idx+"_container"),
|
1819
|
+
wrapper=mCSB_container.parent(),
|
1820
|
+
t=typeof val;
|
1821
|
+
if(!dir){dir=o.axis==="x" ? "x" : "y";}
|
1822
|
+
var contentLength=dir==="x" ? mCSB_container.outerWidth(false) : mCSB_container.outerHeight(false),
|
1823
|
+
contentPos=dir==="x" ? mCSB_container[0].offsetLeft : mCSB_container[0].offsetTop,
|
1824
|
+
cssProp=dir==="x" ? "left" : "top";
|
1825
|
+
switch(t){
|
1826
|
+
case "function": /* this currently is not used. Consider removing it */
|
1827
|
+
return val();
|
1828
|
+
break;
|
1829
|
+
case "object": /* js/jquery object */
|
1830
|
+
var obj=val.jquery ? val : $(val);
|
1831
|
+
if(!obj.length){return;}
|
1832
|
+
return dir==="x" ? _childPos(obj)[1] : _childPos(obj)[0];
|
1833
|
+
break;
|
1834
|
+
case "string": case "number":
|
1835
|
+
if(_isNumeric(val)){ /* numeric value */
|
1836
|
+
return Math.abs(val);
|
1837
|
+
}else if(val.indexOf("%")!==-1){ /* percentage value */
|
1838
|
+
return Math.abs(contentLength*parseInt(val)/100);
|
1839
|
+
}else if(val.indexOf("-=")!==-1){ /* decrease value */
|
1840
|
+
return Math.abs(contentPos-parseInt(val.split("-=")[1]));
|
1841
|
+
}else if(val.indexOf("+=")!==-1){ /* inrease value */
|
1842
|
+
var p=(contentPos+parseInt(val.split("+=")[1]));
|
1843
|
+
return p>=0 ? 0 : Math.abs(p);
|
1844
|
+
}else if(val.indexOf("px")!==-1 && _isNumeric(val.split("px")[0])){ /* pixels string value (e.g. "100px") */
|
1845
|
+
return Math.abs(val.split("px")[0]);
|
1846
|
+
}else{
|
1847
|
+
if(val==="top" || val==="left"){ /* special strings */
|
1848
|
+
return 0;
|
1849
|
+
}else if(val==="bottom"){
|
1850
|
+
return Math.abs(wrapper.height()-mCSB_container.outerHeight(false));
|
1851
|
+
}else if(val==="right"){
|
1852
|
+
return Math.abs(wrapper.width()-mCSB_container.outerWidth(false));
|
1853
|
+
}else if(val==="first" || val==="last"){
|
1854
|
+
var obj=mCSB_container.find(":"+val);
|
1855
|
+
return dir==="x" ? _childPos(obj)[1] : _childPos(obj)[0];
|
1856
|
+
}else{
|
1857
|
+
if($(val).length){ /* jquery selector */
|
1858
|
+
return dir==="x" ? _childPos($(val))[1] : _childPos($(val))[0];
|
1859
|
+
}else{ /* other values (e.g. "100em") */
|
1860
|
+
mCSB_container.css(cssProp,val);
|
1861
|
+
methods.update.call(null,$this[0]);
|
1862
|
+
return;
|
1863
|
+
}
|
1864
|
+
}
|
1865
|
+
}
|
1866
|
+
break;
|
1867
|
+
}
|
1868
|
+
},
|
1869
|
+
/* -------------------- */
|
1870
|
+
|
1871
|
+
|
1872
|
+
/* calls the update method automatically */
|
1873
|
+
_autoUpdate=function(rem){
|
1874
|
+
var $this=$(this),d=$this.data(pluginPfx),o=d.opt,
|
1875
|
+
mCSB_container=$("#mCSB_"+d.idx+"_container");
|
1876
|
+
if(rem){
|
1877
|
+
/*
|
1878
|
+
removes autoUpdate timer
|
1879
|
+
usage: _autoUpdate.call(this,"remove");
|
1880
|
+
*/
|
1881
|
+
clearTimeout(mCSB_container[0].autoUpdate);
|
1882
|
+
_delete(mCSB_container[0],"autoUpdate");
|
1883
|
+
return;
|
1884
|
+
}
|
1885
|
+
upd();
|
1886
|
+
function upd(){
|
1887
|
+
clearTimeout(mCSB_container[0].autoUpdate);
|
1888
|
+
if($this.parents("html").length===0){
|
1889
|
+
/* check element in dom tree */
|
1890
|
+
$this=null;
|
1891
|
+
return;
|
1892
|
+
}
|
1893
|
+
mCSB_container[0].autoUpdate=setTimeout(function(){
|
1894
|
+
/* update on specific selector(s) length and size change */
|
1895
|
+
if(o.advanced.updateOnSelectorChange){
|
1896
|
+
d.poll.change.n=sizesSum();
|
1897
|
+
if(d.poll.change.n!==d.poll.change.o){
|
1898
|
+
d.poll.change.o=d.poll.change.n;
|
1899
|
+
doUpd(3);
|
1900
|
+
return;
|
1901
|
+
}
|
1902
|
+
}
|
1903
|
+
/* update on main element and scrollbar size changes */
|
1904
|
+
if(o.advanced.updateOnContentResize){
|
1905
|
+
d.poll.size.n=$this[0].scrollHeight+$this[0].scrollWidth+mCSB_container[0].offsetHeight+$this[0].offsetHeight;
|
1906
|
+
if(d.poll.size.n!==d.poll.size.o){
|
1907
|
+
d.poll.size.o=d.poll.size.n;
|
1908
|
+
doUpd(1);
|
1909
|
+
return;
|
1910
|
+
}
|
1911
|
+
}
|
1912
|
+
/* update on image load */
|
1913
|
+
if(o.advanced.updateOnImageLoad){
|
1914
|
+
if(!(o.advanced.updateOnImageLoad==="auto" && o.axis==="y")){ //by default, it doesn't run on vertical content
|
1915
|
+
d.poll.img.n=mCSB_container.find("img").length;
|
1916
|
+
if(d.poll.img.n!==d.poll.img.o){
|
1917
|
+
d.poll.img.o=d.poll.img.n;
|
1918
|
+
mCSB_container.find("img").each(function(){
|
1919
|
+
imgLoader(this);
|
1920
|
+
});
|
1921
|
+
return;
|
1922
|
+
}
|
1923
|
+
}
|
1924
|
+
}
|
1925
|
+
if(o.advanced.updateOnSelectorChange || o.advanced.updateOnContentResize || o.advanced.updateOnImageLoad){upd();}
|
1926
|
+
},o.advanced.autoUpdateTimeout);
|
1927
|
+
}
|
1928
|
+
/* a tiny image loader */
|
1929
|
+
function imgLoader(el){
|
1930
|
+
if($(el).hasClass(classes[2])){doUpd(); return;}
|
1931
|
+
var img=new Image();
|
1932
|
+
function createDelegate(contextObject,delegateMethod){
|
1933
|
+
return function(){return delegateMethod.apply(contextObject,arguments);}
|
1934
|
+
}
|
1935
|
+
function imgOnLoad(){
|
1936
|
+
this.onload=null;
|
1937
|
+
$(el).addClass(classes[2]);
|
1938
|
+
doUpd(2);
|
1939
|
+
}
|
1940
|
+
img.onload=createDelegate(img,imgOnLoad);
|
1941
|
+
img.src=el.src;
|
1942
|
+
}
|
1943
|
+
/* returns the total height and width sum of all elements matching the selector */
|
1944
|
+
function sizesSum(){
|
1945
|
+
if(o.advanced.updateOnSelectorChange===true){o.advanced.updateOnSelectorChange="*";}
|
1946
|
+
var total=0,sel=mCSB_container.find(o.advanced.updateOnSelectorChange);
|
1947
|
+
if(o.advanced.updateOnSelectorChange && sel.length>0){sel.each(function(){total+=this.offsetHeight+this.offsetWidth;});}
|
1948
|
+
return total;
|
1949
|
+
}
|
1950
|
+
/* calls the update method */
|
1951
|
+
function doUpd(cb){
|
1952
|
+
clearTimeout(mCSB_container[0].autoUpdate);
|
1953
|
+
methods.update.call(null,$this[0],cb);
|
1954
|
+
}
|
1955
|
+
},
|
1956
|
+
/* -------------------- */
|
1957
|
+
|
1958
|
+
|
1959
|
+
/* snaps scrolling to a multiple of a pixels number */
|
1960
|
+
_snapAmount=function(to,amount,offset){
|
1961
|
+
return (Math.round(to/amount)*amount-offset);
|
1962
|
+
},
|
1963
|
+
/* -------------------- */
|
1964
|
+
|
1965
|
+
|
1966
|
+
/* stops content and scrollbar animations */
|
1967
|
+
_stop=function(el){
|
1968
|
+
var d=el.data(pluginPfx),
|
1969
|
+
sel=$("#mCSB_"+d.idx+"_container,#mCSB_"+d.idx+"_container_wrapper,#mCSB_"+d.idx+"_dragger_vertical,#mCSB_"+d.idx+"_dragger_horizontal");
|
1970
|
+
sel.each(function(){
|
1971
|
+
_stopTween.call(this);
|
1972
|
+
});
|
1973
|
+
},
|
1974
|
+
/* -------------------- */
|
1975
|
+
|
1976
|
+
|
1977
|
+
/*
|
1978
|
+
ANIMATES CONTENT
|
1979
|
+
This is where the actual scrolling happens
|
1980
|
+
*/
|
1981
|
+
_scrollTo=function(el,to,options){
|
1982
|
+
var d=el.data(pluginPfx),o=d.opt,
|
1983
|
+
defaults={
|
1984
|
+
trigger:"internal",
|
1985
|
+
dir:"y",
|
1986
|
+
scrollEasing:"mcsEaseOut",
|
1987
|
+
drag:false,
|
1988
|
+
dur:o.scrollInertia,
|
1989
|
+
overwrite:"all",
|
1990
|
+
callbacks:true,
|
1991
|
+
onStart:true,
|
1992
|
+
onUpdate:true,
|
1993
|
+
onComplete:true
|
1994
|
+
},
|
1995
|
+
options=$.extend(defaults,options),
|
1996
|
+
dur=[options.dur,(options.drag ? 0 : options.dur)],
|
1997
|
+
mCustomScrollBox=$("#mCSB_"+d.idx),
|
1998
|
+
mCSB_container=$("#mCSB_"+d.idx+"_container"),
|
1999
|
+
wrapper=mCSB_container.parent(),
|
2000
|
+
totalScrollOffsets=o.callbacks.onTotalScrollOffset ? _arr.call(el,o.callbacks.onTotalScrollOffset) : [0,0],
|
2001
|
+
totalScrollBackOffsets=o.callbacks.onTotalScrollBackOffset ? _arr.call(el,o.callbacks.onTotalScrollBackOffset) : [0,0];
|
2002
|
+
d.trigger=options.trigger;
|
2003
|
+
if(wrapper.scrollTop()!==0 || wrapper.scrollLeft()!==0){ /* always reset scrollTop/Left */
|
2004
|
+
$(".mCSB_"+d.idx+"_scrollbar").css("visibility","visible");
|
2005
|
+
wrapper.scrollTop(0).scrollLeft(0);
|
2006
|
+
}
|
2007
|
+
if(to==="_resetY" && !d.contentReset.y){
|
2008
|
+
/* callbacks: onOverflowYNone */
|
2009
|
+
if(_cb("onOverflowYNone")){o.callbacks.onOverflowYNone.call(el[0]);}
|
2010
|
+
d.contentReset.y=1;
|
2011
|
+
}
|
2012
|
+
if(to==="_resetX" && !d.contentReset.x){
|
2013
|
+
/* callbacks: onOverflowXNone */
|
2014
|
+
if(_cb("onOverflowXNone")){o.callbacks.onOverflowXNone.call(el[0]);}
|
2015
|
+
d.contentReset.x=1;
|
2016
|
+
}
|
2017
|
+
if(to==="_resetY" || to==="_resetX"){return;}
|
2018
|
+
if((d.contentReset.y || !el[0].mcs) && d.overflowed[0]){
|
2019
|
+
/* callbacks: onOverflowY */
|
2020
|
+
if(_cb("onOverflowY")){o.callbacks.onOverflowY.call(el[0]);}
|
2021
|
+
d.contentReset.x=null;
|
2022
|
+
}
|
2023
|
+
if((d.contentReset.x || !el[0].mcs) && d.overflowed[1]){
|
2024
|
+
/* callbacks: onOverflowX */
|
2025
|
+
if(_cb("onOverflowX")){o.callbacks.onOverflowX.call(el[0]);}
|
2026
|
+
d.contentReset.x=null;
|
2027
|
+
}
|
2028
|
+
if(o.snapAmount){to=_snapAmount(to,o.snapAmount,o.snapOffset);} /* scrolling snapping */
|
2029
|
+
switch(options.dir){
|
2030
|
+
case "x":
|
2031
|
+
var mCSB_dragger=$("#mCSB_"+d.idx+"_dragger_horizontal"),
|
2032
|
+
property="left",
|
2033
|
+
contentPos=mCSB_container[0].offsetLeft,
|
2034
|
+
limit=[
|
2035
|
+
mCustomScrollBox.width()-mCSB_container.outerWidth(false),
|
2036
|
+
mCSB_dragger.parent().width()-mCSB_dragger.width()
|
2037
|
+
],
|
2038
|
+
scrollTo=[to,to===0 ? 0 : (to/d.scrollRatio.x)],
|
2039
|
+
tso=totalScrollOffsets[1],
|
2040
|
+
tsbo=totalScrollBackOffsets[1],
|
2041
|
+
totalScrollOffset=tso>0 ? tso/d.scrollRatio.x : 0,
|
2042
|
+
totalScrollBackOffset=tsbo>0 ? tsbo/d.scrollRatio.x : 0;
|
2043
|
+
break;
|
2044
|
+
case "y":
|
2045
|
+
var mCSB_dragger=$("#mCSB_"+d.idx+"_dragger_vertical"),
|
2046
|
+
property="top",
|
2047
|
+
contentPos=mCSB_container[0].offsetTop,
|
2048
|
+
limit=[
|
2049
|
+
mCustomScrollBox.height()-mCSB_container.outerHeight(false),
|
2050
|
+
mCSB_dragger.parent().height()-mCSB_dragger.height()
|
2051
|
+
],
|
2052
|
+
scrollTo=[to,to===0 ? 0 : (to/d.scrollRatio.y)],
|
2053
|
+
tso=totalScrollOffsets[0],
|
2054
|
+
tsbo=totalScrollBackOffsets[0],
|
2055
|
+
totalScrollOffset=tso>0 ? tso/d.scrollRatio.y : 0,
|
2056
|
+
totalScrollBackOffset=tsbo>0 ? tsbo/d.scrollRatio.y : 0;
|
2057
|
+
break;
|
2058
|
+
}
|
2059
|
+
if(scrollTo[1]<0 || (scrollTo[0]===0 && scrollTo[1]===0)){
|
2060
|
+
scrollTo=[0,0];
|
2061
|
+
}else if(scrollTo[1]>=limit[1]){
|
2062
|
+
scrollTo=[limit[0],limit[1]];
|
2063
|
+
}else{
|
2064
|
+
scrollTo[0]=-scrollTo[0];
|
2065
|
+
}
|
2066
|
+
if(!el[0].mcs){
|
2067
|
+
_mcs(); /* init mcs object (once) to make it available before callbacks */
|
2068
|
+
if(_cb("onInit")){o.callbacks.onInit.call(el[0]);} /* callbacks: onInit */
|
2069
|
+
}
|
2070
|
+
clearTimeout(mCSB_container[0].onCompleteTimeout);
|
2071
|
+
if(!d.tweenRunning && ((contentPos===0 && scrollTo[0]>=0) || (contentPos===limit[0] && scrollTo[0]<=limit[0]))){return;}
|
2072
|
+
_tweenTo(mCSB_dragger[0],property,Math.round(scrollTo[1]),dur[1],options.scrollEasing);
|
2073
|
+
_tweenTo(mCSB_container[0],property,Math.round(scrollTo[0]),dur[0],options.scrollEasing,options.overwrite,{
|
2074
|
+
onStart:function(){
|
2075
|
+
if(options.callbacks && options.onStart && !d.tweenRunning){
|
2076
|
+
/* callbacks: onScrollStart */
|
2077
|
+
if(_cb("onScrollStart")){_mcs(); o.callbacks.onScrollStart.call(el[0]);}
|
2078
|
+
d.tweenRunning=true;
|
2079
|
+
_onDragClasses(mCSB_dragger);
|
2080
|
+
d.cbOffsets=_cbOffsets();
|
2081
|
+
}
|
2082
|
+
},onUpdate:function(){
|
2083
|
+
if(options.callbacks && options.onUpdate){
|
2084
|
+
/* callbacks: whileScrolling */
|
2085
|
+
if(_cb("whileScrolling")){_mcs(); o.callbacks.whileScrolling.call(el[0]);}
|
2086
|
+
}
|
2087
|
+
},onComplete:function(){
|
2088
|
+
if(options.callbacks && options.onComplete){
|
2089
|
+
if(o.axis==="yx"){clearTimeout(mCSB_container[0].onCompleteTimeout);}
|
2090
|
+
var t=mCSB_container[0].idleTimer || 0;
|
2091
|
+
mCSB_container[0].onCompleteTimeout=setTimeout(function(){
|
2092
|
+
/* callbacks: onScroll, onTotalScroll, onTotalScrollBack */
|
2093
|
+
if(_cb("onScroll")){_mcs(); o.callbacks.onScroll.call(el[0]);}
|
2094
|
+
if(_cb("onTotalScroll") && scrollTo[1]>=limit[1]-totalScrollOffset && d.cbOffsets[0]){_mcs(); o.callbacks.onTotalScroll.call(el[0]);}
|
2095
|
+
if(_cb("onTotalScrollBack") && scrollTo[1]<=totalScrollBackOffset && d.cbOffsets[1]){_mcs(); o.callbacks.onTotalScrollBack.call(el[0]);}
|
2096
|
+
d.tweenRunning=false;
|
2097
|
+
mCSB_container[0].idleTimer=0;
|
2098
|
+
_onDragClasses(mCSB_dragger,"hide");
|
2099
|
+
},t);
|
2100
|
+
}
|
2101
|
+
}
|
2102
|
+
});
|
2103
|
+
/* checks if callback function exists */
|
2104
|
+
function _cb(cb){
|
2105
|
+
return d && o.callbacks[cb] && typeof o.callbacks[cb]==="function";
|
2106
|
+
}
|
2107
|
+
/* checks whether callback offsets always trigger */
|
2108
|
+
function _cbOffsets(){
|
2109
|
+
return [o.callbacks.alwaysTriggerOffsets || contentPos>=limit[0]+tso,o.callbacks.alwaysTriggerOffsets || contentPos<=-tsbo];
|
2110
|
+
}
|
2111
|
+
/*
|
2112
|
+
populates object with useful values for the user
|
2113
|
+
values:
|
2114
|
+
content: this.mcs.content
|
2115
|
+
content top position: this.mcs.top
|
2116
|
+
content left position: this.mcs.left
|
2117
|
+
dragger top position: this.mcs.draggerTop
|
2118
|
+
dragger left position: this.mcs.draggerLeft
|
2119
|
+
scrolling y percentage: this.mcs.topPct
|
2120
|
+
scrolling x percentage: this.mcs.leftPct
|
2121
|
+
scrolling direction: this.mcs.direction
|
2122
|
+
*/
|
2123
|
+
function _mcs(){
|
2124
|
+
var cp=[mCSB_container[0].offsetTop,mCSB_container[0].offsetLeft], /* content position */
|
2125
|
+
dp=[mCSB_dragger[0].offsetTop,mCSB_dragger[0].offsetLeft], /* dragger position */
|
2126
|
+
cl=[mCSB_container.outerHeight(false),mCSB_container.outerWidth(false)], /* content length */
|
2127
|
+
pl=[mCustomScrollBox.height(),mCustomScrollBox.width()]; /* content parent length */
|
2128
|
+
el[0].mcs={
|
2129
|
+
content:mCSB_container, /* original content wrapper as jquery object */
|
2130
|
+
top:cp[0],left:cp[1],draggerTop:dp[0],draggerLeft:dp[1],
|
2131
|
+
topPct:Math.round((100*Math.abs(cp[0]))/(Math.abs(cl[0])-pl[0])),leftPct:Math.round((100*Math.abs(cp[1]))/(Math.abs(cl[1])-pl[1])),
|
2132
|
+
direction:options.dir
|
2133
|
+
};
|
2134
|
+
/*
|
2135
|
+
this refers to the original element containing the scrollbar(s)
|
2136
|
+
usage: this.mcs.top, this.mcs.leftPct etc.
|
2137
|
+
*/
|
2138
|
+
}
|
2139
|
+
},
|
2140
|
+
/* -------------------- */
|
2141
|
+
|
2142
|
+
|
2143
|
+
/*
|
2144
|
+
CUSTOM JAVASCRIPT ANIMATION TWEEN
|
2145
|
+
Lighter and faster than jquery animate() and css transitions
|
2146
|
+
Animates top/left properties and includes easings
|
2147
|
+
*/
|
2148
|
+
_tweenTo=function(el,prop,to,duration,easing,overwrite,callbacks){
|
2149
|
+
if(!el._mTween){el._mTween={top:{},left:{}};}
|
2150
|
+
var callbacks=callbacks || {},
|
2151
|
+
onStart=callbacks.onStart || function(){},onUpdate=callbacks.onUpdate || function(){},onComplete=callbacks.onComplete || function(){},
|
2152
|
+
startTime=_getTime(),_delay,progress=0,from=el.offsetTop,elStyle=el.style,_request,tobj=el._mTween[prop];
|
2153
|
+
if(prop==="left"){from=el.offsetLeft;}
|
2154
|
+
var diff=to-from;
|
2155
|
+
tobj.stop=0;
|
2156
|
+
if(overwrite!=="none"){_cancelTween();}
|
2157
|
+
_startTween();
|
2158
|
+
function _step(){
|
2159
|
+
if(tobj.stop){return;}
|
2160
|
+
if(!progress){onStart.call();}
|
2161
|
+
progress=_getTime()-startTime;
|
2162
|
+
_tween();
|
2163
|
+
if(progress>=tobj.time){
|
2164
|
+
tobj.time=(progress>tobj.time) ? progress+_delay-(progress-tobj.time) : progress+_delay-1;
|
2165
|
+
if(tobj.time<progress+1){tobj.time=progress+1;}
|
2166
|
+
}
|
2167
|
+
if(tobj.time<duration){tobj.id=_request(_step);}else{onComplete.call();}
|
2168
|
+
}
|
2169
|
+
function _tween(){
|
2170
|
+
if(duration>0){
|
2171
|
+
tobj.currVal=_ease(tobj.time,from,diff,duration,easing);
|
2172
|
+
elStyle[prop]=Math.round(tobj.currVal)+"px";
|
2173
|
+
}else{
|
2174
|
+
elStyle[prop]=to+"px";
|
2175
|
+
}
|
2176
|
+
onUpdate.call();
|
2177
|
+
}
|
2178
|
+
function _startTween(){
|
2179
|
+
_delay=1000/60;
|
2180
|
+
tobj.time=progress+_delay;
|
2181
|
+
_request=(!window.requestAnimationFrame) ? function(f){_tween(); return setTimeout(f,0.01);} : window.requestAnimationFrame;
|
2182
|
+
tobj.id=_request(_step);
|
2183
|
+
}
|
2184
|
+
function _cancelTween(){
|
2185
|
+
if(tobj.id==null){return;}
|
2186
|
+
if(!window.requestAnimationFrame){clearTimeout(tobj.id);
|
2187
|
+
}else{window.cancelAnimationFrame(tobj.id);}
|
2188
|
+
tobj.id=null;
|
2189
|
+
}
|
2190
|
+
function _ease(t,b,c,d,type){
|
2191
|
+
switch(type){
|
2192
|
+
case "linear": case "mcsLinear":
|
2193
|
+
return c*t/d + b;
|
2194
|
+
break;
|
2195
|
+
case "mcsLinearOut":
|
2196
|
+
t/=d; t--; return c * Math.sqrt(1 - t*t) + b;
|
2197
|
+
break;
|
2198
|
+
case "easeInOutSmooth":
|
2199
|
+
t/=d/2;
|
2200
|
+
if(t<1) return c/2*t*t + b;
|
2201
|
+
t--;
|
2202
|
+
return -c/2 * (t*(t-2) - 1) + b;
|
2203
|
+
break;
|
2204
|
+
case "easeInOutStrong":
|
2205
|
+
t/=d/2;
|
2206
|
+
if(t<1) return c/2 * Math.pow( 2, 10 * (t - 1) ) + b;
|
2207
|
+
t--;
|
2208
|
+
return c/2 * ( -Math.pow( 2, -10 * t) + 2 ) + b;
|
2209
|
+
break;
|
2210
|
+
case "easeInOut": case "mcsEaseInOut":
|
2211
|
+
t/=d/2;
|
2212
|
+
if(t<1) return c/2*t*t*t + b;
|
2213
|
+
t-=2;
|
2214
|
+
return c/2*(t*t*t + 2) + b;
|
2215
|
+
break;
|
2216
|
+
case "easeOutSmooth":
|
2217
|
+
t/=d; t--;
|
2218
|
+
return -c * (t*t*t*t - 1) + b;
|
2219
|
+
break;
|
2220
|
+
case "easeOutStrong":
|
2221
|
+
return c * ( -Math.pow( 2, -10 * t/d ) + 1 ) + b;
|
2222
|
+
break;
|
2223
|
+
case "easeOut": case "mcsEaseOut": default:
|
2224
|
+
var ts=(t/=d)*t,tc=ts*t;
|
2225
|
+
return b+c*(0.499999999999997*tc*ts + -2.5*ts*ts + 5.5*tc + -6.5*ts + 4*t);
|
2226
|
+
}
|
2227
|
+
}
|
2228
|
+
},
|
2229
|
+
/* -------------------- */
|
2230
|
+
|
2231
|
+
|
2232
|
+
/* returns current time */
|
2233
|
+
_getTime=function(){
|
2234
|
+
if(window.performance && window.performance.now){
|
2235
|
+
return window.performance.now();
|
2236
|
+
}else{
|
2237
|
+
if(window.performance && window.performance.webkitNow){
|
2238
|
+
return window.performance.webkitNow();
|
2239
|
+
}else{
|
2240
|
+
if(Date.now){return Date.now();}else{return new Date().getTime();}
|
2241
|
+
}
|
2242
|
+
}
|
2243
|
+
},
|
2244
|
+
/* -------------------- */
|
2245
|
+
|
2246
|
+
|
2247
|
+
/* stops a tween */
|
2248
|
+
_stopTween=function(){
|
2249
|
+
var el=this;
|
2250
|
+
if(!el._mTween){el._mTween={top:{},left:{}};}
|
2251
|
+
var props=["top","left"];
|
2252
|
+
for(var i=0; i<props.length; i++){
|
2253
|
+
var prop=props[i];
|
2254
|
+
if(el._mTween[prop].id){
|
2255
|
+
if(!window.requestAnimationFrame){clearTimeout(el._mTween[prop].id);
|
2256
|
+
}else{window.cancelAnimationFrame(el._mTween[prop].id);}
|
2257
|
+
el._mTween[prop].id=null;
|
2258
|
+
el._mTween[prop].stop=1;
|
2259
|
+
}
|
2260
|
+
}
|
2261
|
+
},
|
2262
|
+
/* -------------------- */
|
2263
|
+
|
2264
|
+
|
2265
|
+
/* deletes a property (avoiding the exception thrown by IE) */
|
2266
|
+
_delete=function(c,m){
|
2267
|
+
try{delete c[m];}catch(e){c[m]=null;}
|
2268
|
+
},
|
2269
|
+
/* -------------------- */
|
2270
|
+
|
2271
|
+
|
2272
|
+
/* detects left mouse button */
|
2273
|
+
_mouseBtnLeft=function(e){
|
2274
|
+
return !(e.which && e.which!==1);
|
2275
|
+
},
|
2276
|
+
/* -------------------- */
|
2277
|
+
|
2278
|
+
|
2279
|
+
/* detects if pointer type event is touch */
|
2280
|
+
_pointerTouch=function(e){
|
2281
|
+
var t=e.originalEvent.pointerType;
|
2282
|
+
return !(t && t!=="touch" && t!==2);
|
2283
|
+
},
|
2284
|
+
/* -------------------- */
|
2285
|
+
|
2286
|
+
|
2287
|
+
/* checks if value is numeric */
|
2288
|
+
_isNumeric=function(val){
|
2289
|
+
return !isNaN(parseFloat(val)) && isFinite(val);
|
2290
|
+
},
|
2291
|
+
/* -------------------- */
|
2292
|
+
|
2293
|
+
|
2294
|
+
/* returns element position according to content */
|
2295
|
+
_childPos=function(el){
|
2296
|
+
var p=el.parents(".mCSB_container");
|
2297
|
+
return [el.offset().top-p.offset().top,el.offset().left-p.offset().left];
|
2298
|
+
};
|
2299
|
+
/* -------------------- */
|
2300
|
+
|
2301
|
+
|
2302
|
+
|
2303
|
+
|
2304
|
+
|
2305
|
+
/*
|
2306
|
+
----------------------------------------
|
2307
|
+
PLUGIN SETUP
|
2308
|
+
----------------------------------------
|
2309
|
+
*/
|
2310
|
+
|
2311
|
+
/* plugin constructor functions */
|
2312
|
+
$.fn[pluginNS]=function(method){ /* usage: $(selector).mCustomScrollbar(); */
|
2313
|
+
if(methods[method]){
|
2314
|
+
return methods[method].apply(this,Array.prototype.slice.call(arguments,1));
|
2315
|
+
}else if(typeof method==="object" || !method){
|
2316
|
+
return methods.init.apply(this,arguments);
|
2317
|
+
}else{
|
2318
|
+
$.error("Method "+method+" does not exist");
|
2319
|
+
}
|
2320
|
+
};
|
2321
|
+
$[pluginNS]=function(method){ /* usage: $.mCustomScrollbar(); */
|
2322
|
+
if(methods[method]){
|
2323
|
+
return methods[method].apply(this,Array.prototype.slice.call(arguments,1));
|
2324
|
+
}else if(typeof method==="object" || !method){
|
2325
|
+
return methods.init.apply(this,arguments);
|
2326
|
+
}else{
|
2327
|
+
$.error("Method "+method+" does not exist");
|
2328
|
+
}
|
2329
|
+
};
|
2330
|
+
|
2331
|
+
/*
|
2332
|
+
allow setting plugin default options.
|
2333
|
+
usage: $.mCustomScrollbar.defaults.scrollInertia=500;
|
2334
|
+
to apply any changed default options on default selectors (below), use inside document ready fn
|
2335
|
+
e.g.: $(document).ready(function(){ $.mCustomScrollbar.defaults.scrollInertia=500; });
|
2336
|
+
*/
|
2337
|
+
$[pluginNS].defaults=defaults;
|
2338
|
+
|
2339
|
+
/*
|
2340
|
+
add window object (window.mCustomScrollbar)
|
2341
|
+
usage: if(window.mCustomScrollbar){console.log("custom scrollbar plugin loaded");}
|
2342
|
+
*/
|
2343
|
+
window[pluginNS]=true;
|
2344
|
+
|
2345
|
+
$(window).load(function(){
|
2346
|
+
|
2347
|
+
$(defaultSelector)[pluginNS](); /* add scrollbars automatically on default selector */
|
2348
|
+
|
2349
|
+
/* extend jQuery expressions */
|
2350
|
+
$.extend($.expr[":"],{
|
2351
|
+
/* checks if element is within scrollable viewport */
|
2352
|
+
mcsInView:$.expr[":"].mcsInView || function(el){
|
2353
|
+
var $el=$(el),content=$el.parents(".mCSB_container"),wrapper,cPos;
|
2354
|
+
if(!content.length){return;}
|
2355
|
+
wrapper=content.parent();
|
2356
|
+
cPos=[content[0].offsetTop,content[0].offsetLeft];
|
2357
|
+
return cPos[0]+_childPos($el)[0]>=0 && cPos[0]+_childPos($el)[0]<wrapper.height()-$el.outerHeight(false) &&
|
2358
|
+
cPos[1]+_childPos($el)[1]>=0 && cPos[1]+_childPos($el)[1]<wrapper.width()-$el.outerWidth(false);
|
2359
|
+
},
|
2360
|
+
/* checks if element is overflowed having visible scrollbar(s) */
|
2361
|
+
mcsOverflow:$.expr[":"].mcsOverflow || function(el){
|
2362
|
+
var d=$(el).data(pluginPfx);
|
2363
|
+
if(!d){return;}
|
2364
|
+
return d.overflowed[0] || d.overflowed[1];
|
2365
|
+
}
|
2366
|
+
});
|
2367
|
+
|
2368
|
+
});
|
2369
|
+
|
2370
|
+
}))}));
|