14
(function (global, factory) {
15
if (typeof define === 'function' && define.amd)
16
define(function () { return factory(global, global.document, undefined); });
17
else if (typeof module === 'object' && typeof module.exports === 'object')
18
module.exports = factory(global, global.document, undefined);
20
factory(global, global.document, undefined);
21
}(typeof window !== 'undefined' ? window : this,
22
function (window, document, undefined) {
24
var PLUGINNAME = 'OverlayScrollbars';
52
hOP: 'hasOwnProperty',
53
bCR: 'getBoundingClientRect'
55
var VENDORS = (function () {
59
var cssPrefixes = ['-webkit-', '-moz-', '-o-', '-ms-'];
60
var jsPrefixes = ['WebKit', 'Moz', 'O', 'MS'];
61
function firstLetterToUpper(str) {
62
return str.charAt(0).toUpperCase() + str.slice(1);
66
_cssPrefixes: cssPrefixes,
67
_jsPrefixes: jsPrefixes,
68
_cssProperty: function (name) {
69
var result = cssCache[name];
71
if (cssCache[LEXICON.hOP](name))
74
var uppercasedName = firstLetterToUpper(name);
75
var elmStyle = document.createElement('div')[LEXICON.s];
76
var resultPossibilities;
79
var currVendorWithoutDashes;
81
for (; i < cssPrefixes.length; i++) {
82
currVendorWithoutDashes = cssPrefixes[i].replace(/-/g, '');
83
resultPossibilities = [
85
cssPrefixes[i] + name,
86
currVendorWithoutDashes + uppercasedName,
87
firstLetterToUpper(currVendorWithoutDashes) + uppercasedName
89
for (v = 0; v < resultPossibilities[LEXICON.l]; v++) {
90
if (elmStyle[resultPossibilities[v]] !== undefined) {
91
result = resultPossibilities[v];
97
cssCache[name] = result;
100
_cssPropertyValue: function (property, values, suffix) {
101
var name = property + ' ' + values;
102
var result = cssCache[name];
104
if (cssCache[LEXICON.hOP](name))
107
var dummyStyle = document.createElement('div')[LEXICON.s];
108
var possbleValues = values.split(' ');
109
var preparedSuffix = suffix || '';
114
for (; i < possbleValues[LEXICON.l]; i++) {
115
for (; v < VENDORS._cssPrefixes[LEXICON.l]; v++) {
116
prop = v < 0 ? possbleValues[i] : VENDORS._cssPrefixes[v] + possbleValues[i];
117
dummyStyle.cssText = property + ':' + prop + preparedSuffix;
118
if (dummyStyle[LEXICON.l]) {
125
cssCache[name] = result;
128
_jsAPI: function (name, isInterface, fallback) {
130
var result = jsCache[name];
132
if (!jsCache[LEXICON.hOP](name)) {
133
result = window[name];
134
for (; i < jsPrefixes[LEXICON.l]; i++)
135
result = result || window[(isInterface ? jsPrefixes[i] : jsPrefixes[i].toLowerCase()) + firstLetterToUpper(name)];
136
jsCache[name] = result;
138
return result || fallback;
142
var COMPATIBILITY = (function () {
143
function windowSize(x) {
144
return x ? window.innerWidth || document.documentElement[LEXICON.cW] || document.body[LEXICON.cW] : window.innerHeight || document.documentElement[LEXICON.cH] || document.body[LEXICON.cH];
146
function bind(func, thisObj) {
147
if (typeof func != TYPES.f) {
148
throw "Can't bind function!";
153
var proto = LEXICON.p;
154
var aArgs = Array[proto].slice.call(arguments, 2);
155
var fNOP = function () { };
156
var fBound = function () { return func.apply(this instanceof fNOP ? this : thisObj, aArgs.concat(Array[proto].slice.call(arguments))); };
159
fNOP[proto] = func[proto];
160
fBound[proto] = new fNOP();
170
wW: bind(windowSize, 0, true),
176
wH: bind(windowSize, 0),
182
mO: bind(VENDORS._jsAPI, 0, 'MutationObserver', true),
188
rO: bind(VENDORS._jsAPI, 0, 'ResizeObserver', true),
194
rAF: bind(VENDORS._jsAPI, 0, 'requestAnimationFrame', false, function (func) { return window.setTimeout(func, 1000 / 60); }),
200
cAF: bind(VENDORS._jsAPI, 0, 'cancelAnimationFrame', false, function (id) { return window.clearTimeout(id); }),
207
return Date.now && Date.now() || new Date().getTime();
214
stpP: function (event) {
215
if (event.stopPropagation)
216
event.stopPropagation();
218
event.cancelBubble = true;
225
prvD: function (event) {
226
if (event.preventDefault && event.cancelable)
227
event.preventDefault();
229
event.returnValue = false;
237
page: function (event) {
238
event = event.originalEvent || event;
240
var strPage = 'page';
241
var strClient = 'client';
244
var target = event.target || event.srcElement || document;
245
var eventDoc = target.ownerDocument || document;
246
var doc = eventDoc.documentElement;
247
var body = eventDoc.body;
250
if (event.touches !== undefined) {
251
var touch = event.touches[0];
253
x: touch[strPage + strX],
254
y: touch[strPage + strY]
259
if (!event[strPage + strX] && event[strClient + strX] && event[strClient + strX] != null) {
262
x: event[strClient + strX] +
263
(doc && doc.scrollLeft || body && body.scrollLeft || 0) -
264
(doc && doc.clientLeft || body && body.clientLeft || 0),
265
y: event[strClient + strY] +
266
(doc && doc.scrollTop || body && body.scrollTop || 0) -
267
(doc && doc.clientTop || body && body.clientTop || 0)
271
x: event[strPage + strX],
272
y: event[strPage + strY]
281
mBtn: function (event) {
282
var button = event.button;
283
if (!event.which && button !== undefined)
284
return (button & 1 ? 1 : (button & 2 ? 3 : (button & 4 ? 2 : 0)));
295
inA: function (item, arr) {
296
for (var i = 0; i < arr[LEXICON.l]; i++)
311
isA: function (arr) {
312
var def = Array.isArray;
313
return def ? def(arr) : this.type(arr) == TYPES.a;
321
type: function (obj) {
322
if (obj === undefined)
326
return Object[LEXICON.p].toString.call(obj).replace(/^\[object (.+)\]$/, '$1').toLowerCase();
349
var JQUERY = window.jQuery;
350
var EASING = (function () {
373
swing: function (x, t, b, c, d) {
374
return 0.5 - _easingsMath.c(x * _easingsMath.p) / 2;
376
linear: function (x, t, b, c, d) {
379
easeInQuad: function (x, t, b, c, d) {
380
return c * (t /= d) * t + b;
382
easeOutQuad: function (x, t, b, c, d) {
383
return -c * (t /= d) * (t - 2) + b;
385
easeInOutQuad: function (x, t, b, c, d) {
386
return ((t /= d / 2) < 1) ? c / 2 * t * t + b : -c / 2 * ((--t) * (t - 2) - 1) + b;
388
easeInCubic: function (x, t, b, c, d) {
389
return c * (t /= d) * t * t + b;
391
easeOutCubic: function (x, t, b, c, d) {
392
return c * ((t = t / d - 1) * t * t + 1) + b;
394
easeInOutCubic: function (x, t, b, c, d) {
395
return ((t /= d / 2) < 1) ? c / 2 * t * t * t + b : c / 2 * ((t -= 2) * t * t + 2) + b;
397
easeInQuart: function (x, t, b, c, d) {
398
return c * (t /= d) * t * t * t + b;
400
easeOutQuart: function (x, t, b, c, d) {
401
return -c * ((t = t / d - 1) * t * t * t - 1) + b;
403
easeInOutQuart: function (x, t, b, c, d) {
404
return ((t /= d / 2) < 1) ? c / 2 * t * t * t * t + b : -c / 2 * ((t -= 2) * t * t * t - 2) + b;
406
easeInQuint: function (x, t, b, c, d) {
407
return c * (t /= d) * t * t * t * t + b;
409
easeOutQuint: function (x, t, b, c, d) {
410
return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
412
easeInOutQuint: function (x, t, b, c, d) {
413
return ((t /= d / 2) < 1) ? c / 2 * t * t * t * t * t + b : c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
415
easeInSine: function (x, t, b, c, d) {
416
return -c * _easingsMath.c(t / d * (_easingsMath.p / 2)) + c + b;
418
easeOutSine: function (x, t, b, c, d) {
419
return c * _easingsMath.s(t / d * (_easingsMath.p / 2)) + b;
421
easeInOutSine: function (x, t, b, c, d) {
422
return -c / 2 * (_easingsMath.c(_easingsMath.p * t / d) - 1) + b;
424
easeInExpo: function (x, t, b, c, d) {
425
return (t == 0) ? b : c * _easingsMath.w(2, 10 * (t / d - 1)) + b;
427
easeOutExpo: function (x, t, b, c, d) {
428
return (t == d) ? b + c : c * (-_easingsMath.w(2, -10 * t / d) + 1) + b;
430
easeInOutExpo: function (x, t, b, c, d) {
431
if (t == 0) return b;
432
if (t == d) return b + c;
433
if ((t /= d / 2) < 1) return c / 2 * _easingsMath.w(2, 10 * (t - 1)) + b;
434
return c / 2 * (-_easingsMath.w(2, -10 * --t) + 2) + b;
436
easeInCirc: function (x, t, b, c, d) {
437
return -c * (_easingsMath.t(1 - (t /= d) * t) - 1) + b;
439
easeOutCirc: function (x, t, b, c, d) {
440
return c * _easingsMath.t(1 - (t = t / d - 1) * t) + b;
442
easeInOutCirc: function (x, t, b, c, d) {
443
return ((t /= d / 2) < 1) ? -c / 2 * (_easingsMath.t(1 - t * t) - 1) + b : c / 2 * (_easingsMath.t(1 - (t -= 2) * t) + 1) + b;
445
easeInElastic: function (x, t, b, c, d) {
446
var s = _easingsMath.o; var p = 0; var a = c;
447
if (t == 0) return b; if ((t /= d) == 1) return b + c; if (!p) p = d * .3;
448
if (a < _easingsMath.a(c)) { a = c; s = p / 4; }
449
else s = p / (2 * _easingsMath.p) * _easingsMath.n(c / a);
450
return -(a * _easingsMath.w(2, 10 * (t -= 1)) * _easingsMath.s((t * d - s) * (2 * _easingsMath.p) / p)) + b;
452
easeOutElastic: function (x, t, b, c, d) {
453
var s = _easingsMath.o; var p = 0; var a = c;
454
if (t == 0) return b;
455
if ((t /= d) == 1) return b + c;
457
if (a < _easingsMath.a(c)) { a = c; s = p / 4; }
458
else s = p / (2 * _easingsMath.p) * _easingsMath.n(c / a);
459
return a * _easingsMath.w(2, -10 * t) * _easingsMath.s((t * d - s) * (2 * _easingsMath.p) / p) + c + b;
461
easeInOutElastic: function (x, t, b, c, d) {
462
var s = _easingsMath.o; var p = 0; var a = c;
463
if (t == 0) return b;
464
if ((t /= d / 2) == 2) return b + c;
465
if (!p) p = d * (.3 * 1.5);
466
if (a < _easingsMath.a(c)) { a = c; s = p / 4; }
467
else s = p / (2 * _easingsMath.p) * _easingsMath.n(c / a);
468
if (t < 1) return -.5 * (a * _easingsMath.w(2, 10 * (t -= 1)) * _easingsMath.s((t * d - s) * (2 * _easingsMath.p) / p)) + b;
469
return a * _easingsMath.w(2, -10 * (t -= 1)) * _easingsMath.s((t * d - s) * (2 * _easingsMath.p) / p) * .5 + c + b;
471
easeInBack: function (x, t, b, c, d, s) {
472
s = s || _easingsMath.o;
473
return c * (t /= d) * t * ((s + 1) * t - s) + b;
475
easeOutBack: function (x, t, b, c, d, s) {
476
s = s || _easingsMath.o;
477
return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
479
easeInOutBack: function (x, t, b, c, d, s) {
480
s = s || _easingsMath.o;
481
return ((t /= d / 2) < 1) ? c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b : c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
483
easeInBounce: function (x, t, b, c, d) {
484
return c - this.easeOutBounce(x, d - t, 0, c, d) + b;
486
easeOutBounce: function (x, t, b, c, d) {
488
if ((t /= d) < (1 / 2.75)) {
489
return c * (o * t * t) + b;
490
} else if (t < (2 / 2.75)) {
491
return c * (o * (t -= (1.5 / 2.75)) * t + .75) + b;
492
} else if (t < (2.5 / 2.75)) {
493
return c * (o * (t -= (2.25 / 2.75)) * t + .9375) + b;
495
return c * (o * (t -= (2.625 / 2.75)) * t + .984375) + b;
498
easeInOutBounce: function (x, t, b, c, d) {
499
return (t < d / 2) ? this.easeInBounce(x, t * 2, 0, c, d) * .5 + b : this.easeOutBounce(x, t * 2 - d, 0, c, d) * .5 + c * .5 + b;
535
var FRAMEWORK = (function () {
536
var _rnothtmlwhite = (/[^\x20\t\r\n\f]+/g);
539
var _strScrollLeft = 'scrollLeft';
540
var _strScrollTop = 'scrollTop';
541
var _animations = [];
542
var _type = COMPATIBILITY.type;
544
animationIterationCount: true,
560
var src, copyIsArray, copy, name, options, clone, target = arguments[0] || {},
562
length = arguments[LEXICON.l],
566
if (_type(target) == TYPES.b) {
568
target = arguments[1] || {};
574
if (_type(target) != TYPES.o && !_type(target) == TYPES.f) {
584
for (; i < length; i++) {
586
if ((options = arguments[i]) != null) {
588
for (name in options) {
590
copy = options[name];
593
if (target === copy) {
598
if (deep && copy && (isPlainObject(copy) || (copyIsArray = COMPATIBILITY.isA(copy)))) {
601
clone = src && COMPATIBILITY.isA(src) ? src : [];
604
clone = src && isPlainObject(src) ? src : {};
608
target[name] = extend(deep, clone, copy);
611
} else if (copy !== undefined) {
622
function inArray(item, arr, fromIndex) {
623
for (var i = fromIndex || 0; i < arr[LEXICON.l]; i++)
629
function isFunction(obj) {
630
return _type(obj) == TYPES.f;
633
function isEmptyObject(obj) {
634
for (var name in obj)
639
function isPlainObject(obj) {
640
if (!obj || _type(obj) != TYPES.o)
644
var proto = LEXICON.p;
645
var hasOwnProperty = Object[proto].hasOwnProperty;
646
var hasOwnConstructor = hasOwnProperty.call(obj, 'constructor');
647
var hasIsPrototypeOf = obj.constructor && obj.constructor[proto] && hasOwnProperty.call(obj.constructor[proto], 'isPrototypeOf');
649
if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {
656
return _type(key) == TYPES.u || hasOwnProperty.call(obj, key);
659
function each(obj, callback) {
662
if (isArrayLike(obj)) {
663
for (; i < obj[LEXICON.l]; i++) {
664
if (callback.call(obj[i], i, obj[i]) === false)
670
if (callback.call(obj[i], i, obj[i]) === false)
678
function isArrayLike(obj) {
679
var length = !!obj && [LEXICON.l] in obj && obj[LEXICON.l];
681
return isFunction(t) ? false : (t == TYPES.a || length === 0 || _type(length) == TYPES.n && length > 0 && (length - 1) in obj);
684
function stripAndCollapse(value) {
685
var tokens = value.match(_rnothtmlwhite) || [];
686
return tokens.join(_strSpace);
689
function matches(elem, selector) {
690
var nodeList = (elem.parentNode || document).querySelectorAll(selector) || [];
691
var i = nodeList[LEXICON.l];
694
if (nodeList[i] == elem)
700
function insertAdjacentElement(el, strategy, child) {
701
if (COMPATIBILITY.isA(child)) {
702
for (var i = 0; i < child[LEXICON.l]; i++)
703
insertAdjacentElement(el, strategy, child[i]);
705
else if (_type(child) == TYPES.s)
706
el.insertAdjacentHTML(strategy, child);
708
el.insertAdjacentElement(strategy, child.nodeType ? child : child[0]);
711
function setCSSVal(el, prop, val) {
713
if (el[LEXICON.s][prop] !== undefined)
714
el[LEXICON.s][prop] = parseCSSVal(prop, val);
718
function parseCSSVal(prop, val) {
719
if (!_cssNumber[prop.toLowerCase()] && _type(val) == TYPES.n)
724
function startNextAnimationInQ(animObj, removeFromQ) {
727
if (removeFromQ !== false)
728
animObj.q.splice(0, 1);
729
if (animObj.q[LEXICON.l] > 0) {
730
nextAnim = animObj.q[0];
731
animate(animObj.el, nextAnim.props, nextAnim.duration, nextAnim.easing, nextAnim.complete, true);
734
index = inArray(animObj, _animations);
736
_animations.splice(index, 1);
740
function setAnimationValue(el, prop, value) {
741
if (prop === _strScrollLeft || prop === _strScrollTop)
744
setCSSVal(el, prop, value);
747
function animate(el, props, options, easing, complete, guaranteedNext) {
748
var hasOptions = isPlainObject(options);
760
easing = options.easing;
761
start = options.start;
762
progress = options.progress;
764
specialEasing = options.specialEasing;
765
complete = options.complete;
766
duration = options.duration;
770
specialEasing = specialEasing || {};
771
duration = duration || 400;
772
easing = easing || 'swing';
773
guaranteedNext = guaranteedNext || false;
775
for (; i < _animations[LEXICON.l]; i++) {
776
if (_animations[i].el === el) {
777
animObj = _animations[i];
787
_animations.push(animObj);
791
if (key === _strScrollLeft || key === _strScrollTop)
794
from[key] = FakejQuery(el).css(key);
798
if (from[key] !== props[key] && props[key] !== undefined)
799
to[key] = props[key];
802
if (!isEmptyObject(to)) {
812
var qPos = guaranteedNext ? 0 : inArray(qObj, animObj.q);
815
duration: hasOptions ? options : duration,
820
qPos = animObj.q[LEXICON.l];
821
animObj.q.push(qObj);
826
timeStart = COMPATIBILITY.now();
827
frame = function () {
828
timeNow = COMPATIBILITY.now();
829
elapsed = (timeNow - timeStart);
830
end = qObj.stop || elapsed >= duration;
831
percent = 1 - ((MATH.max(0, timeStart + duration - timeNow) / duration) || 0);
834
fromVal = parseFloat(from[key]);
835
toVal = parseFloat(to[key]);
836
easedVal = (toVal - fromVal) * EASING[specialEasing[key] || easing](percent, percent * duration, 0, 1, duration) + fromVal;
837
setAnimationValue(el, key, easedVal);
838
if (isFunction(step)) {
848
speacialEasing: specialEasing,
858
if (isFunction(progress))
859
progress({}, percent, MATH.max(0, duration - elapsed));
862
startNextAnimationInQ(animObj);
863
if (isFunction(complete))
867
qObj.frame = COMPATIBILITY.rAF()(frame);
869
qObj.frame = COMPATIBILITY.rAF()(frame);
873
setAnimationValue(el, key, to[key]);
874
startNextAnimationInQ(animObj);
878
else if (guaranteedNext)
879
startNextAnimationInQ(animObj);
882
function stop(el, clearQ, jumpToEnd) {
887
for (; i < _animations[LEXICON.l]; i++) {
888
animObj = _animations[i];
889
if (animObj.el === el) {
890
if (animObj.q[LEXICON.l] > 0) {
893
COMPATIBILITY.cAF()(qObj.frame);
894
animObj.q.splice(0, 1);
897
for (key in qObj.props)
898
setAnimationValue(el, key, qObj.props[key]);
903
startNextAnimationInQ(animObj, false);
910
function elementIsVisible(el) {
911
return !!(el[LEXICON.oW] || el[LEXICON.oH] || el.getClientRects()[LEXICON.l]);
914
function FakejQuery(selector) {
915
if (arguments[LEXICON.l] === 0)
918
var base = new FakejQuery();
919
var elements = selector;
924
if (_type(selector) == TYPES.s) {
926
if (selector.charAt(0) === '<') {
927
el = document.createElement('div');
928
el.innerHTML = selector;
932
elms = document.querySelectorAll(selector);
935
for (; i < elms[LEXICON.l]; i++)
936
elements.push(elms[i]);
940
if (_type(elements) != TYPES.s && (!isArrayLike(elements) || elements === window || elements === elements.self))
941
elements = [elements];
943
for (i = 0; i < elements[LEXICON.l]; i++)
944
base[i] = elements[i];
946
base[LEXICON.l] = elements[LEXICON.l];
952
FakejQuery[LEXICON.p] = {
956
on: function (eventName, handler) {
957
eventName = (eventName || _strEmpty).match(_rnothtmlwhite) || [_strEmpty];
959
var eventNameLength = eventName[LEXICON.l];
962
return this.each(function () {
965
if (el.addEventListener) {
966
for (; i < eventNameLength; i++)
967
el.addEventListener(eventName[i], handler);
969
else if (el.detachEvent) {
970
for (; i < eventNameLength; i++)
971
el.attachEvent('on' + eventName[i], handler);
977
off: function (eventName, handler) {
978
eventName = (eventName || _strEmpty).match(_rnothtmlwhite) || [_strEmpty];
980
var eventNameLength = eventName[LEXICON.l];
983
return this.each(function () {
986
if (el.removeEventListener) {
987
for (; i < eventNameLength; i++)
988
el.removeEventListener(eventName[i], handler);
990
else if (el.detachEvent) {
991
for (; i < eventNameLength; i++)
992
el.detachEvent('on' + eventName[i], handler);
998
one: function (eventName, handler) {
999
eventName = (eventName || _strEmpty).match(_rnothtmlwhite) || [_strEmpty];
1000
return this.each(function () {
1001
var el = FakejQuery(this);
1002
FakejQuery.each(eventName, function (i, oneEventName) {
1003
var oneHandler = function (e) {
1004
handler.call(this, e);
1005
el.off(oneEventName, oneHandler);
1007
el.on(oneEventName, oneHandler);
1012
trigger: function (eventName) {
1015
return this.each(function () {
1017
if (document.createEvent) {
1018
event = document.createEvent('HTMLEvents');
1019
event.initEvent(eventName, true, false);
1020
el.dispatchEvent(event);
1023
el.fireEvent('on' + eventName);
1030
append: function (child) {
1031
return this.each(function () { insertAdjacentElement(this, 'beforeend', child); });
1034
prepend: function (child) {
1035
return this.each(function () { insertAdjacentElement(this, 'afterbegin', child); });
1038
before: function (child) {
1039
return this.each(function () { insertAdjacentElement(this, 'beforebegin', child); });
1042
after: function (child) {
1043
return this.each(function () { insertAdjacentElement(this, 'afterend', child); });
1046
remove: function () {
1047
return this.each(function () {
1049
var parentNode = el.parentNode;
1050
if (parentNode != null)
1051
parentNode.removeChild(el);
1055
unwrap: function () {
1061
this.each(function () {
1062
parent = this.parentNode;
1063
if (inArray(parent, parents) === - 1)
1064
parents.push(parent);
1067
for (i = 0; i < parents[LEXICON.l]; i++) {
1069
parent = el.parentNode;
1070
while (el.firstChild)
1071
parent.insertBefore(el.firstChild, el);
1072
parent.removeChild(el);
1078
wrapAll: function (wrapperHTML) {
1081
var wrapper = FakejQuery(wrapperHTML)[0];
1082
var deepest = wrapper;
1083
var parent = nodes[0].parentNode;
1084
var previousSibling = nodes[0].previousSibling;
1085
while (deepest.childNodes[LEXICON.l] > 0)
1086
deepest = deepest.childNodes[0];
1088
for (i = 0; nodes[LEXICON.l] - i; deepest.firstChild === nodes[0] && i++)
1089
deepest.appendChild(nodes[i]);
1091
var nextSibling = previousSibling ? previousSibling.nextSibling : parent.firstChild;
1092
parent.insertBefore(wrapper, nextSibling);
1097
wrapInner: function (wrapperHTML) {
1098
return this.each(function () {
1099
var el = FakejQuery(this);
1100
var contents = el.contents();
1102
if (contents[LEXICON.l])
1103
contents.wrapAll(wrapperHTML);
1105
el.append(wrapperHTML);
1109
wrap: function (wrapperHTML) {
1110
return this.each(function () { FakejQuery(this).wrapAll(wrapperHTML); });
1116
css: function (styles, val) {
1120
var getCptStyle = window.getComputedStyle;
1121
if (_type(styles) == TYPES.s) {
1122
if (val === undefined) {
1124
cptStyle = getCptStyle ? getCptStyle(el, null) : el.currentStyle[styles];
1127
return getCptStyle ? cptStyle != null ? cptStyle.getPropertyValue(styles) : el[LEXICON.s][styles] : cptStyle;
1130
return this.each(function () {
1131
setCSSVal(this, styles, val);
1136
return this.each(function () {
1138
setCSSVal(this, key, styles[key]);
1143
hasClass: function (className) {
1145
var classNamePrepared = _strSpace + className + _strSpace;
1148
while ((elem = this[i++])) {
1149
classList = elem.classList;
1150
if (classList && classList.contains(className))
1152
else if (elem.nodeType === 1 && (_strSpace + stripAndCollapse(elem.className + _strEmpty) + _strSpace).indexOf(classNamePrepared) > -1)
1159
addClass: function (className) {
1166
var supportClassList;
1172
classes = className.match(_rnothtmlwhite) || [];
1174
while ((elem = this[i++])) {
1175
elmClassList = elem.classList;
1176
if (supportClassList === undefined)
1177
supportClassList = elmClassList !== undefined;
1179
if (supportClassList) {
1180
while ((clazz = classes[v++]))
1181
elmClassList.add(clazz);
1184
curValue = elem.className + _strEmpty;
1185
cur = elem.nodeType === 1 && (_strSpace + stripAndCollapse(curValue) + _strSpace);
1188
while ((clazz = classes[v++]))
1189
if (cur.indexOf(_strSpace + clazz + _strSpace) < 0)
1190
cur += clazz + _strSpace;
1192
finalValue = stripAndCollapse(cur);
1193
if (curValue !== finalValue)
1194
elem.className = finalValue;
1203
removeClass: function (className) {
1210
var supportClassList;
1216
classes = className.match(_rnothtmlwhite) || [];
1218
while ((elem = this[i++])) {
1219
elmClassList = elem.classList;
1220
if (supportClassList === undefined)
1221
supportClassList = elmClassList !== undefined;
1223
if (supportClassList) {
1224
while ((clazz = classes[v++]))
1225
elmClassList.remove(clazz);
1228
curValue = elem.className + _strEmpty;
1229
cur = elem.nodeType === 1 && (_strSpace + stripAndCollapse(curValue) + _strSpace);
1232
while ((clazz = classes[v++]))
1233
while (cur.indexOf(_strSpace + clazz + _strSpace) > -1)
1234
cur = cur.replace(_strSpace + clazz + _strSpace, _strSpace);
1236
finalValue = stripAndCollapse(cur);
1237
if (curValue !== finalValue)
1238
elem.className = finalValue;
1248
return this.each(function () { this[LEXICON.s].display = 'none'; });
1252
return this.each(function () { this[LEXICON.s].display = 'block'; });
1255
attr: function (attrName, value) {
1258
while (el = this[i++]) {
1259
if (value === undefined)
1260
return el.getAttribute(attrName);
1261
el.setAttribute(attrName, value);
1266
removeAttr: function (attrName) {
1267
return this.each(function () { this.removeAttribute(attrName); });
1270
offset: function () {
1272
var rect = el[LEXICON.bCR]();
1273
var scrollLeft = window.pageXOffset || document.documentElement[_strScrollLeft];
1274
var scrollTop = window.pageYOffset || document.documentElement[_strScrollTop];
1276
top: rect.top + scrollTop,
1277
left: rect.left + scrollLeft
1281
position: function () {
1289
scrollLeft: function (value) {
1292
while (el = this[i++]) {
1293
if (value === undefined)
1294
return el[_strScrollLeft];
1295
el[_strScrollLeft] = value;
1300
scrollTop: function (value) {
1303
while (el = this[i++]) {
1304
if (value === undefined)
1305
return el[_strScrollTop];
1306
el[_strScrollTop] = value;
1311
val: function (value) {
1322
first: function () {
1330
eq: function (index) {
1331
return FakejQuery(this[index >= 0 ? index : this[LEXICON.l] + index]);
1334
find: function (selector) {
1337
this.each(function () {
1339
var ch = el.querySelectorAll(selector);
1340
for (i = 0; i < ch[LEXICON.l]; i++)
1341
children.push(ch[i]);
1343
return FakejQuery(children);
1346
children: function (selector) {
1352
this.each(function () {
1354
for (i = 0; i < ch[LEXICON.l]; i++) {
1357
if ((el.matches && el.matches(selector)) || matches(el, selector))
1364
return FakejQuery(children);
1367
parent: function (selector) {
1370
this.each(function () {
1371
parent = this.parentNode;
1372
if (selector ? FakejQuery(parent).is(selector) : true)
1373
parents.push(parent);
1375
return FakejQuery(parents);
1378
is: function (selector) {
1382
for (i = 0; i < this[LEXICON.l]; i++) {
1384
if (selector === ':visible')
1385
return elementIsVisible(el);
1386
if (selector === ':hidden')
1387
return !elementIsVisible(el);
1388
if ((el.matches && el.matches(selector)) || matches(el, selector))
1394
contents: function () {
1399
this.each(function () {
1400
childs = this.childNodes;
1401
for (i = 0; i < childs[LEXICON.l]; i++)
1402
contents.push(childs[i]);
1405
return FakejQuery(contents);
1408
each: function (callback) {
1409
return each(this, callback);
1415
animate: function (props, duration, easing, complete) {
1416
return this.each(function () { animate(this, props, duration, easing, complete); });
1419
stop: function (clearQ, jump) {
1420
return this.each(function () { stop(this, clearQ, jump); });
1424
extend(FakejQuery, {
1427
isEmptyObject: isEmptyObject,
1428
isPlainObject: isPlainObject,
1434
var INSTANCES = (function () {
1436
var _instancePropertyString = '__overlayScrollbars__';
1448
return function (target, instance) {
1449
var argLen = arguments[LEXICON.l];
1457
target[_instancePropertyString] = instance;
1458
_targets.push(target);
1461
var index = COMPATIBILITY.inA(target, _targets);
1465
delete target[_instancePropertyString];
1466
_targets.splice(index, 1);
1470
return _targets[index][_instancePropertyString];
1477
var PLUGIN = (function () {
1479
var _pluginsGlobals;
1480
var _pluginsAutoUpdateLoop;
1481
var _pluginsExtensions = [];
1482
var _pluginsOptions = (function () {
1483
var type = COMPATIBILITY.type;
1484
var possibleTemplateTypes = [
1493
var restrictedStringsSplit = ' ';
1494
var restrictedStringsPossibilitiesSplit = ':';
1495
var classNameAllowedValues = [TYPES.z, TYPES.s];
1496
var numberAllowedValues = TYPES.n;
1497
var booleanNullAllowedValues = [TYPES.z, TYPES.b];
1498
var booleanTrueTemplate = [true, TYPES.b];
1499
var booleanFalseTemplate = [false, TYPES.b];
1500
var callbackTemplate = [null, [TYPES.z, TYPES.f]];
1501
var updateOnLoadTemplate = [['img'], [TYPES.s, TYPES.a, TYPES.z]];
1502
var inheritedAttrsTemplate = [['style', 'class'], [TYPES.s, TYPES.a, TYPES.z]];
1503
var resizeAllowedValues = 'n:none b:both h:horizontal v:vertical';
1504
var overflowBehaviorAllowedValues = 'v-h:visible-hidden v-s:visible-scroll s:scroll h:hidden';
1505
var scrollbarsVisibilityAllowedValues = 'v:visible h:hidden a:auto';
1506
var scrollbarsAutoHideAllowedValues = 'n:never s:scroll l:leave m:move';
1507
var optionsDefaultsAndTemplate = {
1508
className: ['os-theme-dark', classNameAllowedValues],
1509
resize: ['none', resizeAllowedValues],
1510
sizeAutoCapable: booleanTrueTemplate,
1511
clipAlways: booleanTrueTemplate,
1512
normalizeRTL: booleanTrueTemplate,
1513
paddingAbsolute: booleanFalseTemplate,
1514
autoUpdate: [null, booleanNullAllowedValues],
1515
autoUpdateInterval: [33, numberAllowedValues],
1516
updateOnLoad: updateOnLoadTemplate,
1517
nativeScrollbarsOverlaid: {
1518
showNativeScrollbars: booleanFalseTemplate,
1519
initialize: booleanTrueTemplate
1522
x: ['scroll', overflowBehaviorAllowedValues],
1523
y: ['scroll', overflowBehaviorAllowedValues]
1526
visibility: ['auto', scrollbarsVisibilityAllowedValues],
1527
autoHide: ['never', scrollbarsAutoHideAllowedValues],
1528
autoHideDelay: [800, numberAllowedValues],
1529
dragScrolling: booleanTrueTemplate,
1530
clickScrolling: booleanFalseTemplate,
1531
touchSupport: booleanTrueTemplate,
1532
snapHandle: booleanFalseTemplate
1535
dynWidth: booleanFalseTemplate,
1536
dynHeight: booleanFalseTemplate,
1537
inheritedAttrs: inheritedAttrsTemplate
1540
onInitialized: callbackTemplate,
1541
onInitializationWithdrawn: callbackTemplate,
1542
onDestroyed: callbackTemplate,
1543
onScrollStart: callbackTemplate,
1544
onScroll: callbackTemplate,
1545
onScrollStop: callbackTemplate,
1546
onOverflowChanged: callbackTemplate,
1547
onOverflowAmountChanged: callbackTemplate,
1548
onDirectionChanged: callbackTemplate,
1549
onContentSizeChanged: callbackTemplate,
1550
onHostSizeChanged: callbackTemplate,
1551
onUpdated: callbackTemplate
1554
var convert = function (template) {
1555
var recursive = function (obj) {
1560
if (!obj[LEXICON.hOP](key))
1563
valType = type(val);
1564
if (valType == TYPES.a)
1565
obj[key] = val[template ? 1 : 0];
1566
else if (valType == TYPES.o)
1567
obj[key] = recursive(val);
1571
return recursive(FRAMEWORK.extend(true, {}, optionsDefaultsAndTemplate));
1575
_defaults: convert(),
1577
_template: convert(true),
1587
_validate: function (obj, template, writeErrors, diffObj) {
1588
var validatedOptions = {};
1589
var validatedOptionsPrepared = {};
1590
var objectCopy = FRAMEWORK.extend(true, {}, obj);
1591
var inArray = FRAMEWORK.inArray;
1592
var isEmptyObj = FRAMEWORK.isEmptyObject;
1593
var checkObjectProps = function (data, template, diffData, validatedOptions, validatedOptionsPrepared, prevPropName) {
1594
for (var prop in template) {
1595
if (template[LEXICON.hOP](prop) && data[LEXICON.hOP](prop)) {
1596
var isValid = false;
1598
var templateValue = template[prop];
1599
var templateValueType = type(templateValue);
1600
var templateIsComplex = templateValueType == TYPES.o;
1601
var templateTypes = !COMPATIBILITY.isA(templateValue) ? [templateValue] : templateValue;
1602
var dataDiffValue = diffData[prop];
1603
var dataValue = data[prop];
1604
var dataValueType = type(dataValue);
1605
var propPrefix = prevPropName ? prevPropName + '.' : '';
1606
var error = "The option \"" + propPrefix + prop + "\" wasn't set, because";
1607
var errorPossibleTypes = [];
1608
var errorRestrictedStrings = [];
1609
var restrictedStringValuesSplit;
1610
var restrictedStringValuesPossibilitiesSplit;
1611
var isRestrictedValue;
1612
var mainPossibility;
1618
dataDiffValue = dataDiffValue === undefined ? {} : dataDiffValue;
1621
if (templateIsComplex && dataValueType == TYPES.o) {
1622
validatedOptions[prop] = {};
1623
validatedOptionsPrepared[prop] = {};
1624
checkObjectProps(dataValue, templateValue, dataDiffValue, validatedOptions[prop], validatedOptionsPrepared[prop], propPrefix + prop);
1625
FRAMEWORK.each([data, validatedOptions, validatedOptionsPrepared], function (index, value) {
1626
if (isEmptyObj(value[prop])) {
1631
else if (!templateIsComplex) {
1632
for (i = 0; i < templateTypes[LEXICON.l]; i++) {
1633
currType = templateTypes[i];
1634
templateValueType = type(currType);
1636
isRestrictedValue = templateValueType == TYPES.s && inArray(currType, possibleTemplateTypes) === -1;
1637
if (isRestrictedValue) {
1638
errorPossibleTypes.push(TYPES.s);
1641
restrictedStringValuesSplit = currType.split(restrictedStringsSplit);
1642
errorRestrictedStrings = errorRestrictedStrings.concat(restrictedStringValuesSplit);
1643
for (v = 0; v < restrictedStringValuesSplit[LEXICON.l]; v++) {
1645
restrictedStringValuesPossibilitiesSplit = restrictedStringValuesSplit[v].split(restrictedStringsPossibilitiesSplit);
1646
mainPossibility = restrictedStringValuesPossibilitiesSplit[0];
1647
for (j = 0; j < restrictedStringValuesPossibilitiesSplit[LEXICON.l]; j++) {
1649
if (dataValue === restrictedStringValuesPossibilitiesSplit[j]) {
1659
errorPossibleTypes.push(currType);
1661
if (dataValueType === currType) {
1669
isDiff = dataValue !== dataDiffValue;
1672
validatedOptions[prop] = dataValue;
1674
if (isRestrictedValue ? inArray(dataDiffValue, restrictedStringValuesPossibilitiesSplit) < 0 : isDiff)
1675
validatedOptionsPrepared[prop] = isRestrictedValue ? mainPossibility : dataValue;
1677
else if (writeErrors) {
1678
console.warn(error + " it doesn't accept the type [ " + dataValueType.toUpperCase() + " ] with the value of \"" + dataValue + "\".\r\n" +
1679
"Accepted types are: [ " + errorPossibleTypes.join(', ').toUpperCase() + " ]." +
1680
(errorRestrictedStrings[length] > 0 ? "\r\nValid strings are: [ " + errorRestrictedStrings.join(', ').split(restrictedStringsPossibilitiesSplit).join(', ') + " ]." : ''));
1687
checkObjectProps(objectCopy, template, diffObj || {}, validatedOptions, validatedOptionsPrepared);
1697
if (!isEmptyObj(objectCopy) && writeErrors)
1698
console.warn('The following options are discarded due to invalidity:\r\n' + window.JSON.stringify(objectCopy, null, 2));
1701
_default: validatedOptions,
1702
_prepared: validatedOptionsPrepared
1711
function initOverlayScrollbarsStatics() {
1712
if (!_pluginsGlobals)
1713
_pluginsGlobals = new OverlayScrollbarsGlobals(_pluginsOptions._defaults);
1714
if (!_pluginsAutoUpdateLoop)
1715
_pluginsAutoUpdateLoop = new OverlayScrollbarsAutoUpdateLoop(_pluginsGlobals);
1723
function OverlayScrollbarsGlobals(defaultOptions) {
1725
var strOverflow = 'overflow';
1726
var strHidden = 'hidden';
1727
var strScroll = 'scroll';
1728
var bodyElement = FRAMEWORK('body');
1729
var scrollbarDummyElement = FRAMEWORK('<div id="os-dummy-scrollbar-size"><div></div></div>');
1730
var scrollbarDummyElement0 = scrollbarDummyElement[0];
1731
var dummyContainerChild = FRAMEWORK(scrollbarDummyElement.children('div').eq(0));
1733
bodyElement.append(scrollbarDummyElement);
1734
scrollbarDummyElement.hide().show();
1736
var nativeScrollbarSize = calcNativeScrollbarSize(scrollbarDummyElement0);
1737
var nativeScrollbarIsOverlaid = {
1738
x: nativeScrollbarSize.x === 0,
1739
y: nativeScrollbarSize.y === 0
1741
var msie = (function () {
1742
var ua = window.navigator.userAgent;
1743
var strIndexOf = 'indexOf';
1744
var strSubString = 'substring';
1745
var msie = ua[strIndexOf]('MSIE ');
1746
var trident = ua[strIndexOf]('Trident/');
1747
var edge = ua[strIndexOf]('Edge/');
1748
var rv = ua[strIndexOf]('rv:');
1750
var parseIntFunc = parseInt;
1754
result = parseIntFunc(ua[strSubString](msie + 5, ua[strIndexOf]('.', msie)), 10);
1757
else if (trident > 0)
1758
result = parseIntFunc(ua[strSubString](rv + 3, ua[strIndexOf]('.', rv)), 10);
1762
result = parseIntFunc(ua[strSubString](edge + 5, ua[strIndexOf]('.', edge)), 10);
1768
FRAMEWORK.extend(_base, {
1769
defaultOptions: defaultOptions,
1771
autoUpdateLoop: false,
1772
autoUpdateRecommended: !COMPATIBILITY.mO(),
1773
nativeScrollbarSize: nativeScrollbarSize,
1774
nativeScrollbarIsOverlaid: nativeScrollbarIsOverlaid,
1775
nativeScrollbarStyling: (function () {
1777
scrollbarDummyElement.addClass('os-viewport-native-scrollbars-invisible');
1779
result = (scrollbarDummyElement.css('scrollbar-width') === 'none' && (msie > 9 || !msie)) || window.getComputedStyle(scrollbarDummyElement0, '::-webkit-scrollbar').getPropertyValue('display') === 'none';
1789
overlayScrollbarDummySize: { x: 30, y: 30 },
1790
cssCalc: VENDORS._cssPropertyValue('width', 'calc', '(1px)') || null,
1791
restrictedMeasuring: (function () {
1794
scrollbarDummyElement.css(strOverflow, strHidden);
1796
w: scrollbarDummyElement0[LEXICON.sW],
1797
h: scrollbarDummyElement0[LEXICON.sH]
1799
scrollbarDummyElement.css(strOverflow, 'visible');
1801
w: scrollbarDummyElement0[LEXICON.sW],
1802
h: scrollbarDummyElement0[LEXICON.sH]
1804
return (scrollSize.w - scrollSize2.w) !== 0 || (scrollSize.h - scrollSize2.h) !== 0;
1806
rtlScrollBehavior: (function () {
1807
scrollbarDummyElement.css({ 'overflow-y': strHidden, 'overflow-x': strScroll, 'direction': 'rtl' }).scrollLeft(0);
1808
var dummyContainerOffset = scrollbarDummyElement.offset();
1809
var dummyContainerChildOffset = dummyContainerChild.offset();
1811
scrollbarDummyElement.scrollLeft(-999);
1812
var dummyContainerChildOffsetAfterScroll = dummyContainerChild.offset();
1818
i: dummyContainerOffset.left === dummyContainerChildOffset.left,
1823
n: dummyContainerChildOffset.left !== dummyContainerChildOffsetAfterScroll.left
1826
supportTransform: !!VENDORS._cssProperty('transform'),
1827
supportTransition: !!VENDORS._cssProperty('transition'),
1828
supportPassiveEvents: (function () {
1829
var supportsPassive = false;
1831
window.addEventListener('test', null, Object.defineProperty({}, 'passive', {
1833
supportsPassive = true;
1837
return supportsPassive;
1839
supportResizeObserver: !!COMPATIBILITY.rO(),
1840
supportMutationObserver: !!COMPATIBILITY.mO()
1843
scrollbarDummyElement.removeAttr(LEXICON.s).remove();
1847
if (nativeScrollbarIsOverlaid.x && nativeScrollbarIsOverlaid.y)
1851
var windowWidth = COMPATIBILITY.wW();
1852
var windowHeight = COMPATIBILITY.wH();
1853
var windowDpr = getWindowDPR();
1854
var onResize = function () {
1855
if (INSTANCES().length > 0) {
1856
var newW = COMPATIBILITY.wW();
1857
var newH = COMPATIBILITY.wH();
1858
var deltaW = newW - windowWidth;
1859
var deltaH = newH - windowHeight;
1861
if (deltaW === 0 && deltaH === 0)
1864
var deltaWRatio = MATH.round(newW / (windowWidth / 100.0));
1865
var deltaHRatio = MATH.round(newH / (windowHeight / 100.0));
1866
var absDeltaW = abs(deltaW);
1867
var absDeltaH = abs(deltaH);
1868
var absDeltaWRatio = abs(deltaWRatio);
1869
var absDeltaHRatio = abs(deltaHRatio);
1870
var newDPR = getWindowDPR();
1872
var deltaIsBigger = absDeltaW > 2 && absDeltaH > 2;
1873
var difference = !differenceIsBiggerThanOne(absDeltaWRatio, absDeltaHRatio);
1874
var dprChanged = newDPR !== windowDpr && windowDpr > 0;
1875
var isZoom = deltaIsBigger && difference && dprChanged;
1876
var oldScrollbarSize = _base.nativeScrollbarSize;
1877
var newScrollbarSize;
1880
bodyElement.append(scrollbarDummyElement);
1881
newScrollbarSize = _base.nativeScrollbarSize = calcNativeScrollbarSize(scrollbarDummyElement[0]);
1882
scrollbarDummyElement.remove();
1883
if (oldScrollbarSize.x !== newScrollbarSize.x || oldScrollbarSize.y !== newScrollbarSize.y) {
1884
FRAMEWORK.each(INSTANCES(), function () {
1885
if (INSTANCES(this))
1886
INSTANCES(this).update('zoom');
1892
windowHeight = newH;
1897
function differenceIsBiggerThanOne(valOne, valTwo) {
1898
var absValOne = abs(valOne);
1899
var absValTwo = abs(valTwo);
1900
return !(absValOne === absValTwo || absValOne + 1 === absValTwo || absValOne - 1 === absValTwo);
1903
function getWindowDPR() {
1904
var dDPI = window.screen.deviceXDPI || 0;
1905
var sDPI = window.screen.logicalXDPI || 1;
1906
return window.devicePixelRatio || (dDPI / sDPI);
1909
FRAMEWORK(window).on('resize', onResize);
1912
function calcNativeScrollbarSize(measureElement) {
1914
x: measureElement[LEXICON.oH] - measureElement[LEXICON.cH],
1915
y: measureElement[LEXICON.oW] - measureElement[LEXICON.cW]
1924
function OverlayScrollbarsAutoUpdateLoop(globals) {
1926
var _inArray = FRAMEWORK.inArray;
1927
var _getNow = COMPATIBILITY.now;
1928
var _strAutoUpdate = 'autoUpdate';
1929
var _strAutoUpdateInterval = _strAutoUpdate + 'Interval';
1930
var _strLength = LEXICON.l;
1931
var _loopingInstances = [];
1932
var _loopingInstancesIntervalCache = [];
1933
var _loopIsActive = false;
1934
var _loopIntervalDefault = 33;
1935
var _loopInterval = _loopIntervalDefault;
1936
var _loopTimeOld = _getNow();
1943
var loop = function () {
1944
if (_loopingInstances[_strLength] > 0 && _loopIsActive) {
1945
_loopID = COMPATIBILITY.rAF()(function () {
1948
var timeNew = _getNow();
1949
var timeDelta = timeNew - _loopTimeOld;
1952
var instanceOptions;
1953
var instanceAutoUpdateAllowed;
1954
var instanceAutoUpdateInterval;
1957
if (timeDelta > _loopInterval) {
1958
_loopTimeOld = timeNew - (timeDelta % _loopInterval);
1959
lowestInterval = _loopIntervalDefault;
1960
for (var i = 0; i < _loopingInstances[_strLength]; i++) {
1961
instance = _loopingInstances[i];
1962
if (instance !== undefined) {
1963
instanceOptions = instance.options();
1964
instanceAutoUpdateAllowed = instanceOptions[_strAutoUpdate];
1965
instanceAutoUpdateInterval = MATH.max(1, instanceOptions[_strAutoUpdateInterval]);
1968
if ((instanceAutoUpdateAllowed === true || instanceAutoUpdateAllowed === null) && (now - _loopingInstancesIntervalCache[i]) > instanceAutoUpdateInterval) {
1969
instance.update('auto');
1970
_loopingInstancesIntervalCache[i] = new Date(now += instanceAutoUpdateInterval);
1973
lowestInterval = MATH.max(1, MATH.min(lowestInterval, instanceAutoUpdateInterval));
1976
_loopInterval = lowestInterval;
1979
_loopInterval = _loopIntervalDefault;
1987
_base.add = function (instance) {
1988
if (_inArray(instance, _loopingInstances) === -1) {
1989
_loopingInstances.push(instance);
1990
_loopingInstancesIntervalCache.push(_getNow());
1991
if (_loopingInstances[_strLength] > 0 && !_loopIsActive) {
1992
_loopIsActive = true;
1993
globals.autoUpdateLoop = _loopIsActive;
2003
_base.remove = function (instance) {
2004
var index = _inArray(instance, _loopingInstances);
2007
_loopingInstancesIntervalCache.splice(index, 1);
2008
_loopingInstances.splice(index, 1);
2011
if (_loopingInstances[_strLength] === 0 && _loopIsActive) {
2012
_loopIsActive = false;
2013
globals.autoUpdateLoop = _loopIsActive;
2014
if (_loopID !== undefined) {
2015
COMPATIBILITY.cAF()(_loopID);
2033
function OverlayScrollbarsInstance(pluginTargetElement, options, extensions, globals, autoUpdateLoop) {
2035
var type = COMPATIBILITY.type;
2036
var inArray = FRAMEWORK.inArray;
2037
var each = FRAMEWORK.each;
2040
var _base = new _plugin();
2041
var _frameworkProto = FRAMEWORK[LEXICON.p];
2044
if (!isHTMLElement(pluginTargetElement))
2048
if (INSTANCES(pluginTargetElement)) {
2049
var inst = INSTANCES(pluginTargetElement);
2050
inst.options(options);
2055
var _nativeScrollbarIsOverlaid;
2056
var _overlayScrollbarDummySize;
2057
var _rtlScrollBehavior;
2058
var _autoUpdateRecommended;
2060
var _nativeScrollbarStyling;
2062
var _nativeScrollbarSize;
2063
var _supportTransition;
2064
var _supportTransform;
2065
var _supportPassiveEvents;
2066
var _supportResizeObserver;
2067
var _supportMutationObserver;
2068
var _restrictedMeasuring;
2080
var _sizeAutoObserverAdded;
2089
var _contentBorderSize = {};
2090
var _scrollHorizontalInfo = {};
2091
var _scrollVerticalInfo = {};
2092
var _viewportSize = {};
2093
var _nativeScrollbarMinSize = {};
2096
var _strMinusHidden = '-hidden';
2097
var _strMarginMinus = 'margin-';
2098
var _strPaddingMinus = 'padding-';
2099
var _strBorderMinus = 'border-';
2100
var _strTop = 'top';
2101
var _strRight = 'right';
2102
var _strBottom = 'bottom';
2103
var _strLeft = 'left';
2104
var _strMinMinus = 'min-';
2105
var _strMaxMinus = 'max-';
2106
var _strWidth = 'width';
2107
var _strHeight = 'height';
2108
var _strFloat = 'float';
2110
var _strAuto = 'auto';
2111
var _strSync = 'sync';
2112
var _strScroll = 'scroll';
2113
var _strHundredPercent = '100%';
2117
var _strSpace = ' ';
2118
var _strScrollbar = 'scrollbar';
2119
var _strMinusHorizontal = '-horizontal';
2120
var _strMinusVertical = '-vertical';
2121
var _strScrollLeft = _strScroll + 'Left';
2122
var _strScrollTop = _strScroll + 'Top';
2123
var _strMouseTouchDownEvent = 'mousedown touchstart';
2124
var _strMouseTouchUpEvent = 'mouseup touchend touchcancel';
2125
var _strMouseTouchMoveEvent = 'mousemove touchmove';
2126
var _strMouseEnter = 'mouseenter';
2127
var _strMouseLeave = 'mouseleave';
2128
var _strKeyDownEvent = 'keydown';
2129
var _strKeyUpEvent = 'keyup';
2130
var _strSelectStartEvent = 'selectstart';
2131
var _strTransitionEndEvent = 'transitionend webkitTransitionEnd oTransitionEnd';
2132
var _strResizeObserverProperty = '__overlayScrollbarsRO__';
2135
var _cassNamesPrefix = 'os-';
2136
var _classNameHTMLElement = _cassNamesPrefix + 'html';
2137
var _classNameHostElement = _cassNamesPrefix + 'host';
2138
var _classNameHostElementForeign = _classNameHostElement + '-foreign';
2139
var _classNameHostTextareaElement = _classNameHostElement + '-textarea';
2140
var _classNameHostScrollbarHorizontalHidden = _classNameHostElement + '-' + _strScrollbar + _strMinusHorizontal + _strMinusHidden;
2141
var _classNameHostScrollbarVerticalHidden = _classNameHostElement + '-' + _strScrollbar + _strMinusVertical + _strMinusHidden;
2142
var _classNameHostTransition = _classNameHostElement + '-transition';
2143
var _classNameHostRTL = _classNameHostElement + '-rtl';
2144
var _classNameHostResizeDisabled = _classNameHostElement + '-resize-disabled';
2145
var _classNameHostScrolling = _classNameHostElement + '-scrolling';
2146
var _classNameHostOverflow = _classNameHostElement + '-overflow';
2147
var _classNameHostOverflow = _classNameHostElement + '-overflow';
2148
var _classNameHostOverflowX = _classNameHostOverflow + '-x';
2149
var _classNameHostOverflowY = _classNameHostOverflow + '-y';
2150
var _classNameTextareaElement = _cassNamesPrefix + 'textarea';
2151
var _classNameTextareaCoverElement = _classNameTextareaElement + '-cover';
2152
var _classNamePaddingElement = _cassNamesPrefix + 'padding';
2153
var _classNameViewportElement = _cassNamesPrefix + 'viewport';
2154
var _classNameViewportNativeScrollbarsInvisible = _classNameViewportElement + '-native-scrollbars-invisible';
2155
var _classNameViewportNativeScrollbarsOverlaid = _classNameViewportElement + '-native-scrollbars-overlaid';
2156
var _classNameContentElement = _cassNamesPrefix + 'content';
2157
var _classNameContentArrangeElement = _cassNamesPrefix + 'content-arrange';
2158
var _classNameContentGlueElement = _cassNamesPrefix + 'content-glue';
2159
var _classNameSizeAutoObserverElement = _cassNamesPrefix + 'size-auto-observer';
2160
var _classNameResizeObserverElement = _cassNamesPrefix + 'resize-observer';
2161
var _classNameResizeObserverItemElement = _cassNamesPrefix + 'resize-observer-item';
2162
var _classNameResizeObserverItemFinalElement = _classNameResizeObserverItemElement + '-final';
2163
var _classNameTextInherit = _cassNamesPrefix + 'text-inherit';
2164
var _classNameScrollbar = _cassNamesPrefix + _strScrollbar;
2165
var _classNameScrollbarTrack = _classNameScrollbar + '-track';
2166
var _classNameScrollbarTrackOff = _classNameScrollbarTrack + '-off';
2167
var _classNameScrollbarHandle = _classNameScrollbar + '-handle';
2168
var _classNameScrollbarHandleOff = _classNameScrollbarHandle + '-off';
2169
var _classNameScrollbarUnusable = _classNameScrollbar + '-unusable';
2170
var _classNameScrollbarAutoHidden = _classNameScrollbar + '-' + _strAuto + _strMinusHidden;
2171
var _classNameScrollbarCorner = _classNameScrollbar + '-corner';
2172
var _classNameScrollbarCornerResize = _classNameScrollbarCorner + '-resize';
2173
var _classNameScrollbarCornerResizeB = _classNameScrollbarCornerResize + '-both';
2174
var _classNameScrollbarCornerResizeH = _classNameScrollbarCornerResize + _strMinusHorizontal;
2175
var _classNameScrollbarCornerResizeV = _classNameScrollbarCornerResize + _strMinusVertical;
2176
var _classNameScrollbarHorizontal = _classNameScrollbar + _strMinusHorizontal;
2177
var _classNameScrollbarVertical = _classNameScrollbar + _strMinusVertical;
2178
var _classNameDragging = _cassNamesPrefix + 'dragging';
2179
var _classNameThemeNone = _cassNamesPrefix + 'theme-none';
2180
var _classNamesDynamicDestroy = [
2181
_classNameViewportNativeScrollbarsInvisible,
2182
_classNameViewportNativeScrollbarsOverlaid,
2183
_classNameScrollbarTrackOff,
2184
_classNameScrollbarHandleOff,
2185
_classNameScrollbarUnusable,
2186
_classNameScrollbarAutoHidden,
2187
_classNameScrollbarCornerResize,
2188
_classNameScrollbarCornerResizeB,
2189
_classNameScrollbarCornerResizeH,
2190
_classNameScrollbarCornerResizeV,
2191
_classNameDragging].join(_strSpace);
2194
var _callbacksInitQeueue = [];
2197
var _viewportAttrsFromTarget = [LEXICON.ti];
2200
var _defaultOptions;
2201
var _currentOptions;
2202
var _currentPreparedOptions;
2205
var _extensions = {};
2206
var _extensionsPrivateMethods = 'added removed on contract';
2209
var _lastUpdateTime;
2210
var _swallowedUpdateHints = {};
2211
var _swallowedUpdateTimeout;
2212
var _swallowUpdateLag = 42;
2213
var _updateOnLoadEventName = 'load';
2214
var _updateOnLoadElms = [];
2218
var _documentElement;
2223
var _sizeAutoObserverElement;
2224
var _sizeObserverElement;
2225
var _paddingElement;
2226
var _viewportElement;
2227
var _contentElement;
2228
var _contentArrangeElement;
2229
var _contentGlueElement;
2230
var _textareaCoverElement;
2231
var _scrollbarCornerElement;
2232
var _scrollbarHorizontalElement;
2233
var _scrollbarHorizontalTrackElement;
2234
var _scrollbarHorizontalHandleElement;
2235
var _scrollbarVerticalElement;
2236
var _scrollbarVerticalTrackElement;
2237
var _scrollbarVerticalHandleElement;
2238
var _windowElementNative;
2239
var _documentElementNative;
2240
var _targetElementNative;
2241
var _hostElementNative;
2242
var _sizeAutoObserverElementNative;
2243
var _sizeObserverElementNative;
2244
var _paddingElementNative;
2245
var _viewportElementNative;
2246
var _contentElementNative;
2250
var _contentScrollSizeCache;
2251
var _arrangeContentSizeCache;
2252
var _hasOverflowCache;
2253
var _hideOverflowCache;
2254
var _widthAutoCache;
2255
var _heightAutoCache;
2256
var _cssBoxSizingCache;
2257
var _cssPaddingCache;
2258
var _cssBorderCache;
2259
var _cssMarginCache;
2260
var _cssDirectionCache;
2261
var _cssDirectionDetectedCache;
2262
var _paddingAbsoluteCache;
2263
var _clipAlwaysCache;
2264
var _contentGlueSizeCache;
2265
var _overflowBehaviorCache;
2266
var _overflowAmountCache;
2267
var _ignoreOverlayScrollbarHidingCache;
2268
var _autoUpdateCache;
2269
var _sizeAutoCapableCache;
2270
var _contentElementScrollSizeChangeDetectedCache;
2271
var _hostElementSizeChangeDetectedCache;
2272
var _scrollbarsVisibilityCache;
2273
var _scrollbarsAutoHideCache;
2274
var _scrollbarsClickScrollingCache;
2275
var _scrollbarsDragScrollingCache;
2277
var _normalizeRTLCache;
2278
var _classNameCache;
2280
var _textareaAutoWrappingCache;
2281
var _textareaInfoCache;
2282
var _textareaSizeCache;
2283
var _textareaDynHeightCache;
2284
var _textareaDynWidthCache;
2285
var _bodyMinSizeCache;
2286
var _updateAutoCache = {};
2289
var _mutationObserverHost;
2290
var _mutationObserverContent;
2291
var _mutationObserverHostCallback;
2292
var _mutationObserverContentCallback;
2293
var _mutationObserversConnected;
2294
var _mutationObserverAttrsTextarea = ['wrap', 'cols', 'rows'];
2295
var _mutationObserverAttrsHost = [LEXICON.i, LEXICON.c, LEXICON.s, 'open'].concat(_viewportAttrsFromTarget);
2298
var _destroyEvents = [];
2301
var _textareaHasFocus;
2304
var _scrollbarsAutoHideTimeoutId;
2305
var _scrollbarsAutoHideMoveTimeoutId;
2306
var _scrollbarsAutoHideDelay;
2307
var _scrollbarsAutoHideNever;
2308
var _scrollbarsAutoHideScroll;
2309
var _scrollbarsAutoHideMove;
2310
var _scrollbarsAutoHideLeave;
2311
var _scrollbarsHandleHovered;
2312
var _scrollbarsHandlesDefineScrollPos;
2317
var _resizeHorizontal;
2318
var _resizeVertical;
2331
function setupResponsiveEventListener(element, eventNames, listener, remove, passiveOrOptions) {
2332
var collected = COMPATIBILITY.isA(eventNames) && COMPATIBILITY.isA(listener);
2333
var method = remove ? 'removeEventListener' : 'addEventListener';
2334
var onOff = remove ? 'off' : 'on';
2335
var events = collected ? false : eventNames.split(_strSpace)
2338
var passiveOrOptionsIsObj = FRAMEWORK.isPlainObject(passiveOrOptions);
2339
var passive = (_supportPassiveEvents && (passiveOrOptionsIsObj ? (passiveOrOptions._passive) : passiveOrOptions)) || false;
2340
var capture = passiveOrOptionsIsObj && (passiveOrOptions._capture || false);
2341
var nativeParam = _supportPassiveEvents ? {
2347
for (; i < eventNames[LEXICON.l]; i++)
2348
setupResponsiveEventListener(element, eventNames[i], listener[i], remove, passiveOrOptions);
2351
for (; i < events[LEXICON.l]; i++) {
2352
if(_supportPassiveEvents) {
2353
element[0][method](events[i], listener, nativeParam);
2356
element[onOff](events[i], listener);
2363
function addDestroyEventListener(element, eventNames, listener, passive) {
2364
setupResponsiveEventListener(element, eventNames, listener, false, passive);
2365
_destroyEvents.push(COMPATIBILITY.bind(setupResponsiveEventListener, 0, element, eventNames, listener, true, passive));
2375
function setupResizeObserver(targetElement, onElementResizedCallback) {
2376
if (targetElement) {
2377
var resizeObserver = COMPATIBILITY.rO();
2378
var strAnimationStartEvent = 'animationstart mozAnimationStart webkitAnimationStart MSAnimationStart';
2379
var strChildNodes = 'childNodes';
2380
var constScroll = 3333333;
2381
var callback = function () {
2382
targetElement[_strScrollTop](constScroll)[_strScrollLeft](_isRTL ? _rtlScrollBehavior.n ? -constScroll : _rtlScrollBehavior.i ? 0 : constScroll : constScroll);
2383
onElementResizedCallback();
2386
if (onElementResizedCallback) {
2387
if (_supportResizeObserver) {
2388
var element = targetElement.addClass('observed').append(generateDiv(_classNameResizeObserverElement)).contents()[0];
2389
var observer = element[_strResizeObserverProperty] = new resizeObserver(callback);
2390
observer.observe(element);
2393
if (_msieVersion > 9 || !_autoUpdateRecommended) {
2394
targetElement.prepend(
2395
generateDiv(_classNameResizeObserverElement,
2396
generateDiv({ c: _classNameResizeObserverItemElement, dir: 'ltr' },
2397
generateDiv(_classNameResizeObserverItemElement,
2398
generateDiv(_classNameResizeObserverItemFinalElement)
2400
generateDiv(_classNameResizeObserverItemElement,
2401
generateDiv({ c: _classNameResizeObserverItemFinalElement, style: 'width: 200%; height: 200%' })
2407
var observerElement = targetElement[0][strChildNodes][0][strChildNodes][0];
2408
var shrinkElement = FRAMEWORK(observerElement[strChildNodes][1]);
2409
var expandElement = FRAMEWORK(observerElement[strChildNodes][0]);
2410
var expandElementChild = FRAMEWORK(expandElement[0][strChildNodes][0]);
2411
var widthCache = observerElement[LEXICON.oW];
2412
var heightCache = observerElement[LEXICON.oH];
2418
var nativeScrollbarSize = globals.nativeScrollbarSize;
2419
var reset = function () {
2432
expandElement[_strScrollLeft](constScroll)[_strScrollTop](constScroll);
2433
shrinkElement[_strScrollLeft](constScroll)[_strScrollTop](constScroll);
2435
var onResized = function () {
2440
widthCache = currWidth;
2441
heightCache = currHeight;
2444
var onScroll = function (event) {
2445
currWidth = observerElement[LEXICON.oW];
2446
currHeight = observerElement[LEXICON.oH];
2447
isDirty = currWidth != widthCache || currHeight != heightCache;
2449
if (event && isDirty && !rAFId) {
2450
COMPATIBILITY.cAF()(rAFId);
2451
rAFId = COMPATIBILITY.rAF()(onResized);
2458
COMPATIBILITY.prvD(event);
2459
COMPATIBILITY.stpP(event);
2463
var expandChildCSS = {};
2464
var observerElementCSS = {};
2466
setTopRightBottomLeft(observerElementCSS, _strEmpty, [
2467
-((nativeScrollbarSize.y + 1) * factor),
2468
nativeScrollbarSize.x * -factor,
2469
nativeScrollbarSize.y * -factor,
2470
-((nativeScrollbarSize.x + 1) * factor)
2473
FRAMEWORK(observerElement).css(observerElementCSS);
2474
expandElement.on(_strScroll, onScroll);
2475
shrinkElement.on(_strScroll, onScroll);
2476
targetElement.on(strAnimationStartEvent, function () {
2480
expandChildCSS[_strWidth] = constScroll;
2481
expandChildCSS[_strHeight] = constScroll;
2482
expandElementChild.css(expandChildCSS);
2487
var attachEvent = _documentElementNative.attachEvent;
2488
var isIE = _msieVersion !== undefined;
2490
targetElement.prepend(generateDiv(_classNameResizeObserverElement));
2491
findFirst(targetElement, _strDot + _classNameResizeObserverElement)[0].attachEvent('onresize', callback);
2494
var obj = _documentElementNative.createElement(TYPES.o);
2495
obj.setAttribute(LEXICON.ti, '-1');
2496
obj.setAttribute(LEXICON.c, _classNameResizeObserverElement);
2497
obj.onload = function () {
2498
var wnd = this.contentDocument.defaultView;
2499
wnd.addEventListener('resize', callback);
2500
wnd.document.documentElement.style.display = 'none';
2502
obj.type = 'text/html';
2504
targetElement.prepend(obj);
2505
obj.data = 'about:blank';
2507
targetElement.prepend(obj);
2508
targetElement.on(strAnimationStartEvent, callback);
2513
if (targetElement[0] === _sizeObserverElementNative) {
2514
var directionChanged = function () {
2515
var dir = _hostElement.css('direction');
2517
var scrollLeftValue = 0;
2519
if (dir !== _cssDirectionDetectedCache) {
2520
if (dir === 'ltr') {
2522
css[_strRight] = _strAuto;
2523
scrollLeftValue = constScroll;
2526
css[_strLeft] = _strAuto;
2528
scrollLeftValue = _rtlScrollBehavior.n ? -constScroll : _rtlScrollBehavior.i ? 0 : constScroll;
2531
_sizeObserverElement.children().eq(0).css(css);
2532
_sizeObserverElement[_strScrollLeft](scrollLeftValue)[_strScrollTop](constScroll);
2533
_cssDirectionDetectedCache = dir;
2539
addDestroyEventListener(targetElement, _strScroll, function (event) {
2540
if (directionChanged())
2542
COMPATIBILITY.prvD(event);
2543
COMPATIBILITY.stpP(event);
2550
if (_supportResizeObserver) {
2551
var element = targetElement.contents()[0];
2552
var resizeObserverObj = element[_strResizeObserverProperty];
2553
if (resizeObserverObj) {
2554
resizeObserverObj.disconnect();
2555
delete element[_strResizeObserverProperty];
2559
remove(targetElement.children(_strDot + _classNameResizeObserverElement).eq(0));
2609
function createMutationObservers() {
2610
if (_supportMutationObserver) {
2611
var mutationObserverContentLag = 11;
2612
var mutationObserver = COMPATIBILITY.mO();
2613
var contentLastUpdate = COMPATIBILITY.now();
2615
var mutationAttrName;
2616
var mutationIsClass;
2619
var hostClassNameRegex;
2625
_mutationObserverHostCallback = function (mutations) {
2627
var doUpdate = false;
2628
var doUpdateForce = false;
2630
var mutatedAttrs = [];
2632
if (_initialized && !_sleeping) {
2633
each(mutations, function () {
2635
mutationTarget = mutation.target;
2636
mutationAttrName = mutation.attributeName;
2637
mutationIsClass = mutationAttrName === LEXICON.c;
2638
oldMutationVal = mutation.oldValue;
2639
newClassVal = mutationTarget.className;
2641
if (_domExists && mutationIsClass && !doUpdateForce) {
2643
if (oldMutationVal.indexOf(_classNameHostElementForeign) > -1 && newClassVal.indexOf(_classNameHostElementForeign) < 0) {
2644
hostClassNameRegex = createHostClassNameRegExp(true);
2645
_hostElementNative.className = newClassVal.split(_strSpace).concat(oldMutationVal.split(_strSpace).filter(function (name) {
2646
return name.match(hostClassNameRegex);
2647
})).join(_strSpace);
2648
doUpdate = doUpdateForce = true;
2653
doUpdate = mutationIsClass
2654
? hostClassNamesChanged(oldMutationVal, newClassVal)
2655
: mutationAttrName === LEXICON.s
2656
? oldMutationVal !== mutationTarget[LEXICON.s].cssText
2660
mutatedAttrs.push(mutationAttrName);
2663
updateViewportAttrsFromTarget(mutatedAttrs);
2666
_base.update(doUpdateForce || _strAuto);
2670
_mutationObserverContentCallback = function (mutations) {
2671
var doUpdate = false;
2674
if (_initialized && !_sleeping) {
2675
each(mutations, function () {
2677
doUpdate = isUnknownMutation(mutation);
2682
now = COMPATIBILITY.now();
2683
sizeAuto = (_heightAutoCache || _widthAutoCache);
2684
action = function () {
2686
contentLastUpdate = now;
2695
_base.update(_strAuto);
2698
clearTimeout(contentTimeout);
2699
if (mutationObserverContentLag <= 0 || now - contentLastUpdate > mutationObserverContentLag || !sizeAuto)
2702
contentTimeout = setTimeout(action, mutationObserverContentLag);
2708
_mutationObserverHost = new mutationObserver(_mutationObserverHostCallback);
2709
_mutationObserverContent = new mutationObserver(_mutationObserverContentCallback);
2716
function connectMutationObservers() {
2717
if (_supportMutationObserver && !_mutationObserversConnected) {
2718
_mutationObserverHost.observe(_hostElementNative, {
2720
attributeOldValue: true,
2721
attributeFilter: _mutationObserverAttrsHost
2724
_mutationObserverContent.observe(_isTextarea ? _targetElementNative : _contentElementNative, {
2726
attributeOldValue: true,
2727
subtree: !_isTextarea,
2728
childList: !_isTextarea,
2729
characterData: !_isTextarea,
2730
attributeFilter: _isTextarea ? _mutationObserverAttrsTextarea : _mutationObserverAttrsHost
2733
_mutationObserversConnected = true;
2740
function disconnectMutationObservers() {
2741
if (_supportMutationObserver && _mutationObserversConnected) {
2742
_mutationObserverHost.disconnect();
2743
_mutationObserverContent.disconnect();
2745
_mutationObserversConnected = false;
2757
function hostOnResized() {
2761
w: _sizeObserverElementNative[LEXICON.sW],
2762
h: _sizeObserverElementNative[LEXICON.sH]
2765
changed = checkCache(hostSize, _hostElementSizeChangeDetectedCache);
2766
_hostElementSizeChangeDetectedCache = hostSize;
2768
update({ _hostSizeChanged: true });
2775
function hostOnMouseEnter() {
2776
if (_scrollbarsAutoHideLeave)
2777
refreshScrollbarsAutoHide(true);
2783
function hostOnMouseLeave() {
2784
if (_scrollbarsAutoHideLeave && !_bodyElement.hasClass(_classNameDragging))
2785
refreshScrollbarsAutoHide(false);
2791
function hostOnMouseMove() {
2792
if (_scrollbarsAutoHideMove) {
2793
refreshScrollbarsAutoHide(true);
2794
clearTimeout(_scrollbarsAutoHideMoveTimeoutId);
2795
_scrollbarsAutoHideMoveTimeoutId = setTimeout(function () {
2796
if (_scrollbarsAutoHideMove && !_destroyed)
2797
refreshScrollbarsAutoHide(false);
2806
function documentOnSelectStart(event) {
2807
COMPATIBILITY.prvD(event);
2814
function updateOnLoadCallback(event) {
2815
var elm = FRAMEWORK(event.target);
2817
eachUpdateOnLoad(function (i, updateOnLoadSelector) {
2818
if (elm.is(updateOnLoadSelector)) {
2819
update({ _contentSizeChanged: true });
2828
function setupHostMouseTouchEvents(destroy) {
2830
setupHostMouseTouchEvents(true);
2832
setupResponsiveEventListener(_hostElement,
2833
_strMouseTouchMoveEvent.split(_strSpace)[0],
2835
(!_scrollbarsAutoHideMove || destroy), true);
2836
setupResponsiveEventListener(_hostElement,
2837
[_strMouseEnter, _strMouseLeave],
2838
[hostOnMouseEnter, hostOnMouseLeave],
2839
(!_scrollbarsAutoHideLeave || destroy), true);
2842
if (!_initialized && !destroy)
2843
_hostElement.one('mouseover', hostOnMouseEnter);
2853
function bodyMinSizeChanged() {
2854
var bodyMinSize = {};
2855
if (_isBody && _contentArrangeElement) {
2856
bodyMinSize.w = parseToZeroOrNumber(_contentArrangeElement.css(_strMinMinus + _strWidth));
2857
bodyMinSize.h = parseToZeroOrNumber(_contentArrangeElement.css(_strMinMinus + _strHeight));
2858
bodyMinSize.c = checkCache(bodyMinSize, _bodyMinSizeCache);
2859
bodyMinSize.f = true;
2861
_bodyMinSizeCache = bodyMinSize;
2862
return !!bodyMinSize.c;
2871
function hostClassNamesChanged(oldClassNames, newClassNames) {
2872
var currClasses = typeof newClassNames == TYPES.s ? newClassNames.split(_strSpace) : [];
2873
var oldClasses = typeof oldClassNames == TYPES.s ? oldClassNames.split(_strSpace) : [];
2874
var diff = getArrayDifferences(oldClasses, currClasses);
2877
var idx = inArray(_classNameThemeNone, diff);
2882
diff.splice(idx, 1);
2884
if (diff[LEXICON.l] > 0) {
2885
regex = createHostClassNameRegExp(true, true);
2886
for (i = 0; i < diff.length; i++) {
2887
if (!diff[i].match(regex)) {
2900
function isUnknownMutation(mutation) {
2901
var attributeName = mutation.attributeName;
2902
var mutationTarget = mutation.target;
2903
var mutationType = mutation.type;
2904
var strClosest = 'closest';
2906
if (mutationTarget === _contentElementNative)
2907
return attributeName === null;
2908
if (mutationType === 'attributes' && (attributeName === LEXICON.c || attributeName === LEXICON.s) && !_isTextarea) {
2910
if (attributeName === LEXICON.c && FRAMEWORK(mutationTarget).hasClass(_classNameHostElement))
2911
return hostClassNamesChanged(mutation.oldValue, mutationTarget.className);
2914
if (typeof mutationTarget[strClosest] != TYPES.f)
2916
if (mutationTarget[strClosest](_strDot + _classNameResizeObserverElement) !== null ||
2917
mutationTarget[strClosest](_strDot + _classNameScrollbar) !== null ||
2918
mutationTarget[strClosest](_strDot + _classNameScrollbarCorner) !== null)
2928
function updateAutoContentSizeChanged() {
2932
var contentMeasureElement = getContentMeasureElement();
2933
var textareaValueLength = _isTextarea && _widthAutoCache && !_textareaAutoWrappingCache ? _targetElement.val().length : 0;
2934
var setCSS = !_mutationObserversConnected && _widthAutoCache && !_isTextarea;
2939
var contentElementScrollSize;
2942
float = _contentElement.css(_strFloat);
2943
css[_strFloat] = _isRTL ? _strRight : _strLeft;
2944
css[_strWidth] = _strAuto;
2945
_contentElement.css(css);
2947
contentElementScrollSize = {
2948
w: contentMeasureElement[LEXICON.sW] + textareaValueLength,
2949
h: contentMeasureElement[LEXICON.sH] + textareaValueLength
2952
css[_strFloat] = float;
2953
css[_strWidth] = _strHundredPercent;
2954
_contentElement.css(css);
2957
bodyMinSizeC = bodyMinSizeChanged();
2958
changed = checkCache(contentElementScrollSize, _contentElementScrollSizeChangeDetectedCache);
2960
_contentElementScrollSizeChangeDetectedCache = contentElementScrollSize;
2962
return changed || bodyMinSizeC;
2969
function meaningfulAttrsChanged() {
2970
if (_sleeping || _mutationObserversConnected)
2976
var changedAttrs = [];
2979
_elem: _hostElement,
2980
_attrs: _mutationObserverAttrsHost.concat(':visible')
2983
_elem: _isTextarea ? _targetElement : undefined,
2984
_attrs: _mutationObserverAttrsTextarea
2988
each(checks, function (index, check) {
2991
each(check._attrs, function (index, attr) {
2992
curr = attr.charAt(0) === ':' ? elem.is(attr) : elem.attr(attr);
2993
cache = _updateAutoCache[attr];
2995
if (checkCache(curr, cache)) {
2996
changedAttrs.push(attr);
2999
_updateAutoCache[attr] = curr;
3004
updateViewportAttrsFromTarget(changedAttrs);
3006
return changedAttrs[LEXICON.l] > 0;
3014
function isSizeAffectingCSSProperty(propertyName) {
3017
var flexGrow = 'flex-grow';
3018
var flexShrink = 'flex-shrink';
3019
var flexBasis = 'flex-basis';
3020
var affectingPropsX = [
3022
_strMinMinus + _strWidth,
3023
_strMaxMinus + _strWidth,
3024
_strMarginMinus + _strLeft,
3025
_strMarginMinus + _strRight,
3034
var affectingPropsXContentBox = [
3035
_strPaddingMinus + _strLeft,
3036
_strPaddingMinus + _strRight,
3037
_strBorderMinus + _strLeft + _strWidth,
3038
_strBorderMinus + _strRight + _strWidth
3040
var affectingPropsY = [
3042
_strMinMinus + _strHeight,
3043
_strMaxMinus + _strHeight,
3044
_strMarginMinus + _strTop,
3045
_strMarginMinus + _strBottom,
3053
var affectingPropsYContentBox = [
3054
_strPaddingMinus + _strTop,
3055
_strPaddingMinus + _strBottom,
3056
_strBorderMinus + _strTop + _strWidth,
3057
_strBorderMinus + _strBottom + _strWidth
3061
var checkX = _overflowBehaviorCache.x === _strS || _overflowBehaviorCache.x === _strVS;
3062
var checkY = _overflowBehaviorCache.y === _strS || _overflowBehaviorCache.y === _strVS;
3063
var sizeIsAffected = false;
3064
var checkPropertyName = function (arr, name) {
3065
for (var i = 0; i < arr[LEXICON.l]; i++) {
3066
if (arr[i] === name)
3073
sizeIsAffected = checkPropertyName(affectingPropsY, propertyName);
3074
if (!sizeIsAffected && !_isBorderBox)
3075
sizeIsAffected = checkPropertyName(affectingPropsYContentBox, propertyName);
3077
if (checkX && !sizeIsAffected) {
3078
sizeIsAffected = checkPropertyName(affectingPropsX, propertyName);
3079
if (!sizeIsAffected && !_isBorderBox)
3080
sizeIsAffected = checkPropertyName(affectingPropsXContentBox, propertyName);
3082
return sizeIsAffected;
3093
function updateViewportAttrsFromTarget(attrs) {
3094
attrs = attrs || _viewportAttrsFromTarget;
3095
each(attrs, function (index, attr) {
3096
if (COMPATIBILITY.inA(attr, _viewportAttrsFromTarget) > -1) {
3097
var targetAttr = _targetElement.attr(attr);
3098
if (type(targetAttr) == TYPES.s) {
3099
_viewportElement.attr(attr, targetAttr);
3102
_viewportElement.removeAttr(attr);
3111
function textareaUpdate() {
3113
var wrapAttrOff = !_textareaAutoWrappingCache;
3114
var minWidth = _viewportSize.w;
3115
var minHeight = _viewportSize.h;
3117
var doMeasure = _widthAutoCache || wrapAttrOff;
3124
css[_strMinMinus + _strWidth] = _strEmpty;
3125
css[_strMinMinus + _strHeight] = _strEmpty;
3128
css[_strWidth] = _strAuto;
3129
_targetElement.css(css);
3132
origWidth = _targetElementNative[LEXICON.oW];
3133
width = doMeasure ? MATH.max(origWidth, _targetElementNative[LEXICON.sW] - 1) : 1;
3137
css[_strWidth] = _widthAutoCache ? _strAuto : _strHundredPercent;
3138
css[_strMinMinus + _strWidth] = _strHundredPercent;
3141
css[_strHeight] = _strAuto;
3142
_targetElement.css(css);
3145
origHeight = _targetElementNative[LEXICON.oH];
3146
height = MATH.max(origHeight, _targetElementNative[LEXICON.sH] - 1);
3149
css[_strWidth] = width;
3150
css[_strHeight] = height;
3151
_textareaCoverElement.css(css);
3154
css[_strMinMinus + _strWidth] = minWidth ;
3155
css[_strMinMinus + _strHeight] = minHeight ;
3156
_targetElement.css(css);
3159
_originalWidth: origWidth,
3160
_originalHeight: origHeight,
3161
_dynamicWidth: width,
3162
_dynamicHeight: height
3178
function update(updateHints) {
3179
clearTimeout(_swallowedUpdateTimeout);
3180
updateHints = updateHints || {};
3181
_swallowedUpdateHints._hostSizeChanged |= updateHints._hostSizeChanged;
3182
_swallowedUpdateHints._contentSizeChanged |= updateHints._contentSizeChanged;
3183
_swallowedUpdateHints._force |= updateHints._force;
3185
var now = COMPATIBILITY.now();
3186
var hostSizeChanged = !!_swallowedUpdateHints._hostSizeChanged;
3187
var contentSizeChanged = !!_swallowedUpdateHints._contentSizeChanged;
3188
var force = !!_swallowedUpdateHints._force;
3189
var changedOptions = updateHints._changedOptions;
3190
var swallow = _swallowUpdateLag > 0 && _initialized && !_destroyed && !force && !changedOptions && (now - _lastUpdateTime) < _swallowUpdateLag && (!_heightAutoCache && !_widthAutoCache);
3191
var displayIsHidden;
3194
_swallowedUpdateTimeout = setTimeout(update, _swallowUpdateLag);
3201
if (_destroyed || swallow || (_sleeping && !changedOptions) || (_initialized && !force && (displayIsHidden = _hostElement.is(':hidden'))) || _hostElement.css('display') === 'inline')
3204
_lastUpdateTime = now;
3205
_swallowedUpdateHints = {};
3208
if (_nativeScrollbarStyling && !(_nativeScrollbarIsOverlaid.x && _nativeScrollbarIsOverlaid.y)) {
3210
_nativeScrollbarSize.x = 0;
3211
_nativeScrollbarSize.y = 0;
3215
_nativeScrollbarSize = extendDeep({}, globals.nativeScrollbarSize);
3222
_nativeScrollbarMinSize = {
3223
x: (_nativeScrollbarSize.x + (_nativeScrollbarIsOverlaid.x ? 0 : 3)) * 3,
3224
y: (_nativeScrollbarSize.y + (_nativeScrollbarIsOverlaid.y ? 0 : 3)) * 3
3227
changedOptions = changedOptions || {};
3231
var checkCacheAutoForce = function () {
3232
return checkCache.apply(this, [].slice.call(arguments).concat([force]));
3237
x: _viewportElement[_strScrollLeft](),
3238
y: _viewportElement[_strScrollTop]()
3241
var currentPreparedOptionsScrollbars = _currentPreparedOptions.scrollbars;
3242
var currentPreparedOptionsTextarea = _currentPreparedOptions.textarea;
3245
var scrollbarsVisibility = currentPreparedOptionsScrollbars.visibility;
3246
var scrollbarsVisibilityChanged = checkCacheAutoForce(scrollbarsVisibility, _scrollbarsVisibilityCache);
3249
var scrollbarsAutoHide = currentPreparedOptionsScrollbars.autoHide;
3250
var scrollbarsAutoHideChanged = checkCacheAutoForce(scrollbarsAutoHide, _scrollbarsAutoHideCache);
3253
var scrollbarsClickScrolling = currentPreparedOptionsScrollbars.clickScrolling;
3254
var scrollbarsClickScrollingChanged = checkCacheAutoForce(scrollbarsClickScrolling, _scrollbarsClickScrollingCache);
3257
var scrollbarsDragScrolling = currentPreparedOptionsScrollbars.dragScrolling;
3258
var scrollbarsDragScrollingChanged = checkCacheAutoForce(scrollbarsDragScrolling, _scrollbarsDragScrollingCache);
3261
var className = _currentPreparedOptions.className;
3262
var classNameChanged = checkCacheAutoForce(className, _classNameCache);
3265
var resize = _currentPreparedOptions.resize;
3266
var resizeChanged = checkCacheAutoForce(resize, _resizeCache) && !_isBody;
3269
var paddingAbsolute = _currentPreparedOptions.paddingAbsolute;
3270
var paddingAbsoluteChanged = checkCacheAutoForce(paddingAbsolute, _paddingAbsoluteCache);
3273
var clipAlways = _currentPreparedOptions.clipAlways;
3274
var clipAlwaysChanged = checkCacheAutoForce(clipAlways, _clipAlwaysCache);
3277
var sizeAutoCapable = _currentPreparedOptions.sizeAutoCapable && !_isBody;
3278
var sizeAutoCapableChanged = checkCacheAutoForce(sizeAutoCapable, _sizeAutoCapableCache);
3281
var ignoreOverlayScrollbarHiding = _currentPreparedOptions.nativeScrollbarsOverlaid.showNativeScrollbars;
3282
var ignoreOverlayScrollbarHidingChanged = checkCacheAutoForce(ignoreOverlayScrollbarHiding, _ignoreOverlayScrollbarHidingCache);
3285
var autoUpdate = _currentPreparedOptions.autoUpdate;
3286
var autoUpdateChanged = checkCacheAutoForce(autoUpdate, _autoUpdateCache);
3289
var overflowBehavior = _currentPreparedOptions.overflowBehavior;
3290
var overflowBehaviorChanged = checkCacheAutoForce(overflowBehavior, _overflowBehaviorCache, force);
3293
var textareaDynWidth = currentPreparedOptionsTextarea.dynWidth;
3294
var textareaDynWidthChanged = checkCacheAutoForce(_textareaDynWidthCache, textareaDynWidth);
3297
var textareaDynHeight = currentPreparedOptionsTextarea.dynHeight;
3298
var textareaDynHeightChanged = checkCacheAutoForce(_textareaDynHeightCache, textareaDynHeight);
3301
_scrollbarsAutoHideNever = scrollbarsAutoHide === 'n';
3302
_scrollbarsAutoHideScroll = scrollbarsAutoHide === 's';
3303
_scrollbarsAutoHideMove = scrollbarsAutoHide === 'm';
3304
_scrollbarsAutoHideLeave = scrollbarsAutoHide === 'l';
3307
_scrollbarsAutoHideDelay = currentPreparedOptionsScrollbars.autoHideDelay;
3310
_oldClassName = _classNameCache;
3313
_resizeNone = resize === 'n';
3314
_resizeBoth = resize === 'b';
3315
_resizeHorizontal = resize === 'h';
3316
_resizeVertical = resize === 'v';
3319
_normalizeRTLCache = _currentPreparedOptions.normalizeRTL;
3322
ignoreOverlayScrollbarHiding = ignoreOverlayScrollbarHiding && (_nativeScrollbarIsOverlaid.x && _nativeScrollbarIsOverlaid.y);
3325
_scrollbarsVisibilityCache = scrollbarsVisibility;
3326
_scrollbarsAutoHideCache = scrollbarsAutoHide;
3327
_scrollbarsClickScrollingCache = scrollbarsClickScrolling;
3328
_scrollbarsDragScrollingCache = scrollbarsDragScrolling;
3329
_classNameCache = className;
3330
_resizeCache = resize;
3331
_paddingAbsoluteCache = paddingAbsolute;
3332
_clipAlwaysCache = clipAlways;
3333
_sizeAutoCapableCache = sizeAutoCapable;
3334
_ignoreOverlayScrollbarHidingCache = ignoreOverlayScrollbarHiding;
3335
_autoUpdateCache = autoUpdate;
3336
_overflowBehaviorCache = extendDeep({}, overflowBehavior);
3337
_textareaDynWidthCache = textareaDynWidth;
3338
_textareaDynHeightCache = textareaDynHeight;
3339
_hasOverflowCache = _hasOverflowCache || { x: false, y: false };
3342
if (classNameChanged) {
3343
removeClass(_hostElement, _oldClassName + _strSpace + _classNameThemeNone);
3344
addClass(_hostElement, className !== undefined && className !== null && className.length > 0 ? className : _classNameThemeNone);
3348
if (autoUpdateChanged) {
3349
if (autoUpdate === true || (autoUpdate === null && _autoUpdateRecommended)) {
3350
disconnectMutationObservers();
3351
autoUpdateLoop.add(_base);
3354
autoUpdateLoop.remove(_base);
3355
connectMutationObservers();
3360
if (sizeAutoCapableChanged) {
3361
if (sizeAutoCapable) {
3362
if (_contentGlueElement) {
3363
_contentGlueElement.show();
3366
_contentGlueElement = FRAMEWORK(generateDiv(_classNameContentGlueElement));
3367
_paddingElement.before(_contentGlueElement);
3369
if (_sizeAutoObserverAdded) {
3370
_sizeAutoObserverElement.show();
3373
_sizeAutoObserverElement = FRAMEWORK(generateDiv(_classNameSizeAutoObserverElement));
3374
_sizeAutoObserverElementNative = _sizeAutoObserverElement[0];
3376
_contentGlueElement.before(_sizeAutoObserverElement);
3377
var oldSize = { w: -1, h: -1 };
3378
setupResizeObserver(_sizeAutoObserverElement, function () {
3380
w: _sizeAutoObserverElementNative[LEXICON.oW],
3381
h: _sizeAutoObserverElementNative[LEXICON.oH]
3383
if (checkCache(newSize, oldSize)) {
3384
if (_initialized && (_heightAutoCache && newSize.h > 0) || (_widthAutoCache && newSize.w > 0)) {
3387
else if (_initialized && (!_heightAutoCache && newSize.h === 0) || (!_widthAutoCache && newSize.w === 0)) {
3393
_sizeAutoObserverAdded = true;
3396
if (_cssCalc !== null)
3397
_sizeAutoObserverElement.css(_strHeight, _cssCalc + '(100% + 1px)');
3401
if (_sizeAutoObserverAdded)
3402
_sizeAutoObserverElement.hide();
3403
if (_contentGlueElement)
3404
_contentGlueElement.hide();
3410
_sizeObserverElement.find('*').trigger(_strScroll);
3411
if (_sizeAutoObserverAdded)
3412
_sizeAutoObserverElement.find('*').trigger(_strScroll);
3416
displayIsHidden = displayIsHidden === undefined ? _hostElement.is(':hidden') : displayIsHidden;
3419
var textareaAutoWrapping = _isTextarea ? _targetElement.attr('wrap') !== 'off' : false;
3420
var textareaAutoWrappingChanged = checkCacheAutoForce(textareaAutoWrapping, _textareaAutoWrappingCache);
3423
var cssDirection = _hostElement.css('direction');
3424
var cssDirectionChanged = checkCacheAutoForce(cssDirection, _cssDirectionCache);
3427
var boxSizing = _hostElement.css('box-sizing');
3428
var boxSizingChanged = checkCacheAutoForce(boxSizing, _cssBoxSizingCache);
3431
var padding = getTopRightBottomLeftHost(_strPaddingMinus);
3434
var sizeAutoObserverElementBCRect;
3437
sizeAutoObserverElementBCRect = _sizeAutoObserverAdded ? _sizeAutoObserverElementNative[LEXICON.bCR]() : null;
3442
_isRTL = cssDirection === 'rtl';
3443
_isBorderBox = (boxSizing === 'border-box');
3444
var isRTLLeft = _isRTL ? _strLeft : _strRight;
3445
var isRTLRight = _isRTL ? _strRight : _strLeft;
3448
var widthAutoResizeDetection = false;
3449
var widthAutoObserverDetection = (_sizeAutoObserverAdded && (_hostElement.css(_strFloat) !== 'none' )) ? (MATH.round(sizeAutoObserverElementBCRect.right - sizeAutoObserverElementBCRect.left) === 0) && (!paddingAbsolute ? (_hostElementNative[LEXICON.cW] - _paddingX) > 0 : true) : false;
3450
if (sizeAutoCapable && !widthAutoObserverDetection) {
3451
var tmpCurrHostWidth = _hostElementNative[LEXICON.oW];
3452
var tmpCurrContentGlueWidth = _contentGlueElement.css(_strWidth);
3453
_contentGlueElement.css(_strWidth, _strAuto);
3455
var tmpNewHostWidth = _hostElementNative[LEXICON.oW];
3456
_contentGlueElement.css(_strWidth, tmpCurrContentGlueWidth);
3457
widthAutoResizeDetection = tmpCurrHostWidth !== tmpNewHostWidth;
3458
if (!widthAutoResizeDetection) {
3459
_contentGlueElement.css(_strWidth, tmpCurrHostWidth + 1);
3460
tmpNewHostWidth = _hostElementNative[LEXICON.oW];
3461
_contentGlueElement.css(_strWidth, tmpCurrContentGlueWidth);
3462
widthAutoResizeDetection = tmpCurrHostWidth !== tmpNewHostWidth;
3465
var widthAuto = (widthAutoObserverDetection || widthAutoResizeDetection) && sizeAutoCapable && !displayIsHidden;
3466
var widthAutoChanged = checkCacheAutoForce(widthAuto, _widthAutoCache);
3467
var wasWidthAuto = !widthAuto && _widthAutoCache;
3470
var heightAuto = _sizeAutoObserverAdded && sizeAutoCapable && !displayIsHidden ? (MATH.round(sizeAutoObserverElementBCRect.bottom - sizeAutoObserverElementBCRect.top) === 0) : false;
3471
var heightAutoChanged = checkCacheAutoForce(heightAuto, _heightAutoCache);
3472
var wasHeightAuto = !heightAuto && _heightAutoCache;
3476
var updateBorderX = (widthAuto && _isBorderBox) || !_isBorderBox;
3477
var updateBorderY = (heightAuto && _isBorderBox) || !_isBorderBox;
3478
var border = getTopRightBottomLeftHost(_strBorderMinus, '-' + _strWidth, !updateBorderX, !updateBorderY)
3481
var margin = getTopRightBottomLeftHost(_strMarginMinus);
3484
var contentElementCSS = {};
3485
var contentGlueElementCSS = {};
3488
var getHostSize = function () {
3491
w: _hostElementNative[LEXICON.cW],
3492
h: _hostElementNative[LEXICON.cH]
3495
var getViewportSize = function () {
3500
w: _paddingElementNative[LEXICON.oW] + MATH.max(0, _contentElementNative[LEXICON.cW] - _contentElementNative[LEXICON.sW]),
3501
h: _paddingElementNative[LEXICON.oH] + MATH.max(0, _contentElementNative[LEXICON.cH] - _contentElementNative[LEXICON.sH])
3506
var paddingAbsoluteX = _paddingX = padding.l + padding.r;
3507
var paddingAbsoluteY = _paddingY = padding.t + padding.b;
3508
paddingAbsoluteX *= paddingAbsolute ? 1 : 0;
3509
paddingAbsoluteY *= paddingAbsolute ? 1 : 0;
3510
padding.c = checkCacheAutoForce(padding, _cssPaddingCache);
3513
_borderX = border.l + border.r;
3514
_borderY = border.t + border.b;
3515
border.c = checkCacheAutoForce(border, _cssBorderCache);
3518
_marginX = margin.l + margin.r;
3519
_marginY = margin.t + margin.b;
3520
margin.c = checkCacheAutoForce(margin, _cssMarginCache);
3523
_textareaAutoWrappingCache = textareaAutoWrapping;
3524
_cssDirectionCache = cssDirection;
3525
_cssBoxSizingCache = boxSizing;
3526
_widthAutoCache = widthAuto;
3527
_heightAutoCache = heightAuto;
3528
_cssPaddingCache = padding;
3529
_cssBorderCache = border;
3530
_cssMarginCache = margin;
3533
if (cssDirectionChanged && _sizeAutoObserverAdded)
3534
_sizeAutoObserverElement.css(_strFloat, isRTLRight);
3537
if (padding.c || cssDirectionChanged || paddingAbsoluteChanged || widthAutoChanged || heightAutoChanged || boxSizingChanged || sizeAutoCapableChanged) {
3538
var paddingElementCSS = {};
3539
var textareaCSS = {};
3540
var paddingValues = [padding.t, padding.r, padding.b, padding.l];
3542
setTopRightBottomLeft(contentGlueElementCSS, _strMarginMinus, [-padding.t, -padding.r, -padding.b, -padding.l]);
3543
if (paddingAbsolute) {
3544
setTopRightBottomLeft(paddingElementCSS, _strEmpty, paddingValues);
3545
setTopRightBottomLeft(_isTextarea ? textareaCSS : contentElementCSS, _strPaddingMinus);
3548
setTopRightBottomLeft(paddingElementCSS, _strEmpty);
3549
setTopRightBottomLeft(_isTextarea ? textareaCSS : contentElementCSS, _strPaddingMinus, paddingValues);
3552
_paddingElement.css(paddingElementCSS);
3553
_targetElement.css(textareaCSS);
3557
_viewportSize = getViewportSize();
3560
var textareaSize = _isTextarea ? textareaUpdate() : false;
3561
var textareaSizeChanged = _isTextarea && checkCacheAutoForce(textareaSize, _textareaSizeCache);
3562
var textareaDynOrigSize = _isTextarea && textareaSize ? {
3563
w: textareaDynWidth ? textareaSize._dynamicWidth : textareaSize._originalWidth,
3564
h: textareaDynHeight ? textareaSize._dynamicHeight : textareaSize._originalHeight
3566
_textareaSizeCache = textareaSize;
3569
if (heightAuto && (heightAutoChanged || paddingAbsoluteChanged || boxSizingChanged || padding.c || border.c)) {
3570
contentElementCSS[_strHeight] = _strAuto;
3572
else if (heightAutoChanged || paddingAbsoluteChanged) {
3573
contentElementCSS[_strHeight] = _strHundredPercent;
3575
if (widthAuto && (widthAutoChanged || paddingAbsoluteChanged || boxSizingChanged || padding.c || border.c || cssDirectionChanged)) {
3576
contentElementCSS[_strWidth] = _strAuto;
3577
contentGlueElementCSS[_strMaxMinus + _strWidth] = _strHundredPercent;
3579
else if (widthAutoChanged || paddingAbsoluteChanged) {
3580
contentElementCSS[_strWidth] = _strHundredPercent;
3581
contentElementCSS[_strFloat] = _strEmpty;
3582
contentGlueElementCSS[_strMaxMinus + _strWidth] = _strEmpty;
3586
contentGlueElementCSS[_strWidth] = _strAuto;
3588
contentElementCSS[_strWidth] = VENDORS._cssPropertyValue(_strWidth, 'max-content intrinsic') || _strAuto;
3589
contentElementCSS[_strFloat] = isRTLRight;
3592
contentGlueElementCSS[_strWidth] = _strEmpty;
3596
contentGlueElementCSS[_strHeight] = textareaDynOrigSize.h || _contentElementNative[LEXICON.cH];
3599
contentGlueElementCSS[_strHeight] = _strEmpty;
3601
if (sizeAutoCapable)
3602
_contentGlueElement.css(contentGlueElementCSS);
3603
_contentElement.css(contentElementCSS);
3606
contentElementCSS = {};
3607
contentGlueElementCSS = {};
3610
if (hostSizeChanged || contentSizeChanged || textareaSizeChanged || cssDirectionChanged || boxSizingChanged || paddingAbsoluteChanged || widthAutoChanged || widthAuto || heightAutoChanged || heightAuto || ignoreOverlayScrollbarHidingChanged || overflowBehaviorChanged || clipAlwaysChanged || resizeChanged || scrollbarsVisibilityChanged || scrollbarsAutoHideChanged || scrollbarsDragScrollingChanged || scrollbarsClickScrollingChanged || textareaDynWidthChanged || textareaDynHeightChanged || textareaAutoWrappingChanged) {
3611
var strOverflow = 'overflow';
3612
var strOverflowX = strOverflow + '-x';
3613
var strOverflowY = strOverflow + '-y';
3614
var strHidden = 'hidden';
3615
var strVisible = 'visible';
3619
if (!_nativeScrollbarStyling) {
3620
var viewportElementResetCSS = {};
3621
var resetXTmp = _hasOverflowCache.y && _hideOverflowCache.ys && !ignoreOverlayScrollbarHiding ? (_nativeScrollbarIsOverlaid.y ? _viewportElement.css(isRTLLeft) : -_nativeScrollbarSize.y) : 0;
3622
var resetBottomTmp = _hasOverflowCache.x && _hideOverflowCache.xs && !ignoreOverlayScrollbarHiding ? (_nativeScrollbarIsOverlaid.x ? _viewportElement.css(_strBottom) : -_nativeScrollbarSize.x) : 0;
3623
setTopRightBottomLeft(viewportElementResetCSS, _strEmpty);
3624
_viewportElement.css(viewportElementResetCSS);
3628
var contentMeasureElement = getContentMeasureElement();
3632
w: textareaDynOrigSize.w || contentMeasureElement[LEXICON.cW],
3633
h: textareaDynOrigSize.h || contentMeasureElement[LEXICON.cH]
3636
w: contentMeasureElement[LEXICON.sW],
3637
h: contentMeasureElement[LEXICON.sH]
3641
if (!_nativeScrollbarStyling) {
3642
viewportElementResetCSS[_strBottom] = wasHeightAuto ? _strEmpty : resetBottomTmp;
3643
viewportElementResetCSS[isRTLLeft] = wasWidthAuto ? _strEmpty : resetXTmp;
3644
_viewportElement.css(viewportElementResetCSS);
3646
_viewportSize = getViewportSize();
3649
var hostSize = getHostSize();
3650
var hostAbsoluteRectSize = {
3651
w: hostSize.w - _marginX - _borderX - (_isBorderBox ? 0 : _paddingX),
3652
h: hostSize.h - _marginY - _borderY - (_isBorderBox ? 0 : _paddingY)
3654
var contentGlueSize = {
3657
w: MATH.max((widthAuto ? contentSize.w : scrollSize.w) + paddingAbsoluteX, hostAbsoluteRectSize.w),
3658
h: MATH.max((heightAuto ? contentSize.h : scrollSize.h) + paddingAbsoluteY, hostAbsoluteRectSize.h)
3660
contentGlueSize.c = checkCacheAutoForce(contentGlueSize, _contentGlueSizeCache);
3661
_contentGlueSizeCache = contentGlueSize;
3664
if (sizeAutoCapable) {
3666
if (contentGlueSize.c || (heightAuto || widthAuto)) {
3667
contentGlueElementCSS[_strWidth] = contentGlueSize.w;
3668
contentGlueElementCSS[_strHeight] = contentGlueSize.h;
3674
w: contentMeasureElement[LEXICON.cW],
3675
h: contentMeasureElement[LEXICON.cH]
3679
var textareaCoverCSS = {};
3680
var setContentGlueElementCSSfunction = function (horizontal) {
3681
var scrollbarVars = getScrollbarVars(horizontal);
3682
var wh = scrollbarVars._w_h;
3683
var strWH = scrollbarVars._width_height;
3684
var autoSize = horizontal ? widthAuto : heightAuto;
3685
var borderSize = horizontal ? _borderX : _borderY;
3686
var paddingSize = horizontal ? _paddingX : _paddingY;
3687
var marginSize = horizontal ? _marginX : _marginY;
3688
var viewportSize = _viewportSize[wh] - borderSize - marginSize - (_isBorderBox ? 0 : paddingSize);
3691
if (!autoSize || (!autoSize && border.c))
3692
contentGlueElementCSS[strWH] = hostAbsoluteRectSize[wh] - 1;
3695
if (autoSize && (contentSize[wh] < viewportSize) && (horizontal && _isTextarea ? !textareaAutoWrapping : true)) {
3697
textareaCoverCSS[strWH] = parseToZeroOrNumber(_textareaCoverElement.css(strWH)) - 1;
3698
contentGlueElementCSS[strWH] -= 1;
3702
if (contentSize[wh] > 0)
3703
contentGlueElementCSS[strWH] = MATH.max(1, contentGlueElementCSS[strWH]);
3705
setContentGlueElementCSSfunction(true);
3706
setContentGlueElementCSSfunction(false);
3709
_textareaCoverElement.css(textareaCoverCSS);
3710
_contentGlueElement.css(contentGlueElementCSS);
3713
contentElementCSS[_strWidth] = _strHundredPercent;
3714
if (widthAuto && !_isBorderBox && !_mutationObserversConnected)
3715
contentElementCSS[_strFloat] = 'none';
3718
_contentElement.css(contentElementCSS);
3719
contentElementCSS = {};
3722
var contentScrollSize = {
3723
w: contentMeasureElement[LEXICON.sW],
3724
h: contentMeasureElement[LEXICON.sH],
3726
contentScrollSize.c = contentSizeChanged = checkCacheAutoForce(contentScrollSize, _contentScrollSizeCache);
3727
_contentScrollSizeCache = contentScrollSize;
3730
_viewportSize = getViewportSize();
3732
hostSize = getHostSize();
3733
hostSizeChanged = checkCacheAutoForce(hostSize, _hostSizeCache);
3734
_hostSizeCache = hostSize;
3736
var hideOverflowForceTextarea = _isTextarea && (_viewportSize.w === 0 || _viewportSize.h === 0);
3737
var previousOverflowAmount = _overflowAmountCache;
3738
var overflowBehaviorIsVS = {};
3739
var overflowBehaviorIsVH = {};
3740
var overflowBehaviorIsS = {};
3741
var overflowAmount = {};
3742
var hasOverflow = {};
3743
var hideOverflow = {};
3745
var viewportRect = _paddingElementNative[LEXICON.bCR]();
3746
var setOverflowVariables = function (horizontal) {
3747
var scrollbarVars = getScrollbarVars(horizontal);
3748
var scrollbarVarsInverted = getScrollbarVars(!horizontal);
3749
var xyI = scrollbarVarsInverted._x_y;
3750
var xy = scrollbarVars._x_y;
3751
var wh = scrollbarVars._w_h;
3752
var widthHeight = scrollbarVars._width_height;
3753
var scrollMax = _strScroll + scrollbarVars._Left_Top + 'Max';
3754
var fractionalOverflowAmount = viewportRect[widthHeight] ? MATH.abs(viewportRect[widthHeight] - _viewportSize[wh]) : 0;
3755
var checkFractionalOverflowAmount = previousOverflowAmount && previousOverflowAmount[xy] > 0 && _viewportElementNative[scrollMax] === 0;
3756
overflowBehaviorIsVS[xy] = overflowBehavior[xy] === 'v-s';
3757
overflowBehaviorIsVH[xy] = overflowBehavior[xy] === 'v-h';
3758
overflowBehaviorIsS[xy] = overflowBehavior[xy] === 's';
3759
overflowAmount[xy] = MATH.max(0, MATH.round((contentScrollSize[wh] - _viewportSize[wh]) * 100) / 100);
3760
overflowAmount[xy] *= (hideOverflowForceTextarea || (checkFractionalOverflowAmount && fractionalOverflowAmount > 0 && fractionalOverflowAmount < 1)) ? 0 : 1;
3761
hasOverflow[xy] = overflowAmount[xy] > 0;
3766
hideOverflow[xy] = overflowBehaviorIsVS[xy] || overflowBehaviorIsVH[xy] ? (hasOverflow[xyI] && !overflowBehaviorIsVS[xyI] && !overflowBehaviorIsVH[xyI]) : hasOverflow[xy];
3767
hideOverflow[xy + 's'] = hideOverflow[xy] ? (overflowBehaviorIsS[xy] || overflowBehaviorIsVS[xy]) : false;
3769
canScroll[xy] = hasOverflow[xy] && hideOverflow[xy + 's'];
3771
setOverflowVariables(true);
3772
setOverflowVariables(false);
3774
overflowAmount.c = checkCacheAutoForce(overflowAmount, _overflowAmountCache);
3775
_overflowAmountCache = overflowAmount;
3776
hasOverflow.c = checkCacheAutoForce(hasOverflow, _hasOverflowCache);
3777
_hasOverflowCache = hasOverflow;
3778
hideOverflow.c = checkCacheAutoForce(hideOverflow, _hideOverflowCache);
3779
_hideOverflowCache = hideOverflow;
3782
if (_nativeScrollbarIsOverlaid.x || _nativeScrollbarIsOverlaid.y) {
3783
var borderDesign = 'px solid transparent';
3784
var contentArrangeElementCSS = {};
3785
var arrangeContent = {};
3786
var arrangeChanged = force;
3787
var setContentElementCSS;
3789
if (hasOverflow.x || hasOverflow.y) {
3790
arrangeContent.w = _nativeScrollbarIsOverlaid.y && hasOverflow.y ? contentScrollSize.w + _overlayScrollbarDummySize.y : _strEmpty;
3791
arrangeContent.h = _nativeScrollbarIsOverlaid.x && hasOverflow.x ? contentScrollSize.h + _overlayScrollbarDummySize.x : _strEmpty;
3792
arrangeChanged = checkCacheAutoForce(arrangeContent, _arrangeContentSizeCache);
3793
_arrangeContentSizeCache = arrangeContent;
3796
if (hasOverflow.c || hideOverflow.c || contentScrollSize.c || cssDirectionChanged || widthAutoChanged || heightAutoChanged || widthAuto || heightAuto || ignoreOverlayScrollbarHidingChanged) {
3797
contentElementCSS[_strMarginMinus + isRTLRight] = contentElementCSS[_strBorderMinus + isRTLRight] = _strEmpty;
3798
setContentElementCSS = function (horizontal) {
3799
var scrollbarVars = getScrollbarVars(horizontal);
3800
var scrollbarVarsInverted = getScrollbarVars(!horizontal);
3801
var xy = scrollbarVars._x_y;
3802
var strDirection = horizontal ? _strBottom : isRTLLeft;
3803
var invertedAutoSize = horizontal ? heightAuto : widthAuto;
3805
if (_nativeScrollbarIsOverlaid[xy] && hasOverflow[xy] && hideOverflow[xy + 's']) {
3806
contentElementCSS[_strMarginMinus + strDirection] = invertedAutoSize ? (ignoreOverlayScrollbarHiding ? _strEmpty : _overlayScrollbarDummySize[xy]) : _strEmpty;
3807
contentElementCSS[_strBorderMinus + strDirection] = ((horizontal ? !invertedAutoSize : true) && !ignoreOverlayScrollbarHiding) ? (_overlayScrollbarDummySize[xy] + borderDesign) : _strEmpty;
3810
arrangeContent[scrollbarVarsInverted._w_h] =
3811
contentElementCSS[_strMarginMinus + strDirection] =
3812
contentElementCSS[_strBorderMinus + strDirection] = _strEmpty;
3813
arrangeChanged = true;
3817
if (_nativeScrollbarStyling) {
3818
addRemoveClass(_viewportElement, _classNameViewportNativeScrollbarsInvisible, !ignoreOverlayScrollbarHiding)
3821
setContentElementCSS(true);
3822
setContentElementCSS(false);
3825
if (ignoreOverlayScrollbarHiding) {
3826
arrangeContent.w = arrangeContent.h = _strEmpty;
3827
arrangeChanged = true;
3829
if (arrangeChanged && !_nativeScrollbarStyling) {
3830
contentArrangeElementCSS[_strWidth] = hideOverflow.y ? arrangeContent.w : _strEmpty;
3831
contentArrangeElementCSS[_strHeight] = hideOverflow.x ? arrangeContent.h : _strEmpty;
3833
if (!_contentArrangeElement) {
3834
_contentArrangeElement = FRAMEWORK(generateDiv(_classNameContentArrangeElement));
3835
_viewportElement.prepend(_contentArrangeElement);
3837
_contentArrangeElement.css(contentArrangeElementCSS);
3839
_contentElement.css(contentElementCSS);
3842
var viewportElementCSS = {};
3843
var paddingElementCSS = {};
3845
if (hostSizeChanged || hasOverflow.c || hideOverflow.c || contentScrollSize.c || overflowBehaviorChanged || boxSizingChanged || ignoreOverlayScrollbarHidingChanged || cssDirectionChanged || clipAlwaysChanged || heightAutoChanged) {
3846
viewportElementCSS[isRTLRight] = _strEmpty;
3847
setViewportCSS = function (horizontal) {
3848
var scrollbarVars = getScrollbarVars(horizontal);
3849
var scrollbarVarsInverted = getScrollbarVars(!horizontal);
3850
var xy = scrollbarVars._x_y;
3851
var XY = scrollbarVars._X_Y;
3852
var strDirection = horizontal ? _strBottom : isRTLLeft;
3854
var reset = function () {
3855
viewportElementCSS[strDirection] = _strEmpty;
3856
_contentBorderSize[scrollbarVarsInverted._w_h] = 0;
3858
if (hasOverflow[xy] && hideOverflow[xy + 's']) {
3859
viewportElementCSS[strOverflow + XY] = _strScroll;
3860
if (ignoreOverlayScrollbarHiding || _nativeScrollbarStyling) {
3864
viewportElementCSS[strDirection] = -(_nativeScrollbarIsOverlaid[xy] ? _overlayScrollbarDummySize[xy] : _nativeScrollbarSize[xy]);
3865
_contentBorderSize[scrollbarVarsInverted._w_h] = _nativeScrollbarIsOverlaid[xy] ? _overlayScrollbarDummySize[scrollbarVarsInverted._x_y] : 0;
3868
viewportElementCSS[strOverflow + XY] = _strEmpty;
3872
setViewportCSS(true);
3873
setViewportCSS(false);
3880
if (!_nativeScrollbarStyling
3881
&& (_viewportSize.h < _nativeScrollbarMinSize.x || _viewportSize.w < _nativeScrollbarMinSize.y)
3882
&& ((hasOverflow.x && hideOverflow.x && !_nativeScrollbarIsOverlaid.x) || (hasOverflow.y && hideOverflow.y && !_nativeScrollbarIsOverlaid.y))) {
3883
viewportElementCSS[_strPaddingMinus + _strTop] = _nativeScrollbarMinSize.x;
3884
viewportElementCSS[_strMarginMinus + _strTop] = -_nativeScrollbarMinSize.x;
3886
viewportElementCSS[_strPaddingMinus + isRTLRight] = _nativeScrollbarMinSize.y;
3887
viewportElementCSS[_strMarginMinus + isRTLRight] = -_nativeScrollbarMinSize.y;
3890
viewportElementCSS[_strPaddingMinus + _strTop] =
3891
viewportElementCSS[_strMarginMinus + _strTop] =
3892
viewportElementCSS[_strPaddingMinus + isRTLRight] =
3893
viewportElementCSS[_strMarginMinus + isRTLRight] = _strEmpty;
3895
viewportElementCSS[_strPaddingMinus + isRTLLeft] =
3896
viewportElementCSS[_strMarginMinus + isRTLLeft] = _strEmpty;
3899
if ((hasOverflow.x && hideOverflow.x) || (hasOverflow.y && hideOverflow.y) || hideOverflowForceTextarea) {
3901
if (_isTextarea && hideOverflowForceTextarea) {
3902
paddingElementCSS[strOverflowX] =
3903
paddingElementCSS[strOverflowY] = strHidden;
3907
if (!clipAlways || (overflowBehaviorIsVH.x || overflowBehaviorIsVS.x || overflowBehaviorIsVH.y || overflowBehaviorIsVS.y)) {
3910
paddingElementCSS[strOverflowX] =
3911
paddingElementCSS[strOverflowY] = _strEmpty;
3913
viewportElementCSS[strOverflowX] =
3914
viewportElementCSS[strOverflowY] = strVisible;
3918
_paddingElement.css(paddingElementCSS);
3919
_viewportElement.css(viewportElementCSS);
3920
viewportElementCSS = {};
3923
if ((hasOverflow.c || boxSizingChanged || widthAutoChanged || heightAutoChanged) && !(_nativeScrollbarIsOverlaid.x && _nativeScrollbarIsOverlaid.y)) {
3924
var elementStyle = _contentElementNative[LEXICON.s];
3926
elementStyle.webkitTransform = 'scale(1)';
3927
elementStyle.display = 'run-in';
3928
dump = _contentElementNative[LEXICON.oH];
3929
elementStyle.display = _strEmpty;
3930
elementStyle.webkitTransform = _strEmpty;
3944
contentElementCSS = {};
3945
if (cssDirectionChanged || widthAutoChanged || heightAutoChanged) {
3946
if (_isRTL && widthAuto) {
3947
var floatTmp = _contentElement.css(_strFloat);
3948
var posLeftWithoutFloat = MATH.round(_contentElement.css(_strFloat, _strEmpty).css(_strLeft, _strEmpty).position().left);
3949
_contentElement.css(_strFloat, floatTmp);
3950
var posLeftWithFloat = MATH.round(_contentElement.position().left);
3952
if (posLeftWithoutFloat !== posLeftWithFloat)
3953
contentElementCSS[_strLeft] = posLeftWithoutFloat;
3956
contentElementCSS[_strLeft] = _strEmpty;
3959
_contentElement.css(contentElementCSS);
3962
if (_isTextarea && contentSizeChanged) {
3963
var textareaInfo = getTextareaInfo();
3965
var textareaRowsChanged = _textareaInfoCache === undefined ? true : textareaInfo._rows !== _textareaInfoCache._rows;
3966
var cursorRow = textareaInfo._cursorRow;
3967
var cursorCol = textareaInfo._cursorColumn;
3968
var widestRow = textareaInfo._widestRow;
3969
var lastRow = textareaInfo._rows;
3970
var lastCol = textareaInfo._columns;
3971
var cursorPos = textareaInfo._cursorPosition;
3972
var cursorMax = textareaInfo._cursorMax;
3973
var cursorIsLastPosition = (cursorPos >= cursorMax && _textareaHasFocus);
3974
var textareaScrollAmount = {
3975
x: (!textareaAutoWrapping && (cursorCol === lastCol && cursorRow === widestRow)) ? _overflowAmountCache.x : -1,
3976
y: (textareaAutoWrapping ? cursorIsLastPosition || textareaRowsChanged && (previousOverflowAmount ? (currScroll.y === previousOverflowAmount.y) : false) : (cursorIsLastPosition || textareaRowsChanged) && cursorRow === lastRow) ? _overflowAmountCache.y : -1
3978
currScroll.x = textareaScrollAmount.x > -1 ? (_isRTL && _normalizeRTLCache && _rtlScrollBehavior.i ? 0 : textareaScrollAmount.x) : currScroll.x;
3979
currScroll.y = textareaScrollAmount.y > -1 ? textareaScrollAmount.y : currScroll.y;
3981
_textareaInfoCache = textareaInfo;
3983
if (_isRTL && _rtlScrollBehavior.i && _nativeScrollbarIsOverlaid.y && hasOverflow.x && _normalizeRTLCache)
3984
currScroll.x += _contentBorderSize.w || 0;
3986
_hostElement[_strScrollLeft](0);
3988
_hostElement[_strScrollTop](0);
3989
_viewportElement[_strScrollLeft](currScroll.x)[_strScrollTop](currScroll.y);
3992
var scrollbarsVisibilityVisible = scrollbarsVisibility === 'v';
3993
var scrollbarsVisibilityHidden = scrollbarsVisibility === 'h';
3994
var scrollbarsVisibilityAuto = scrollbarsVisibility === 'a';
3995
var refreshScrollbarsVisibility = function (showX, showY) {
3996
showY = showY === undefined ? showX : showY;
3997
refreshScrollbarAppearance(true, showX, canScroll.x)
3998
refreshScrollbarAppearance(false, showY, canScroll.y)
4002
addRemoveClass(_hostElement, _classNameHostOverflow, hideOverflow.x || hideOverflow.y);
4003
addRemoveClass(_hostElement, _classNameHostOverflowX, hideOverflow.x);
4004
addRemoveClass(_hostElement, _classNameHostOverflowY, hideOverflow.y);
4007
if (cssDirectionChanged && !_isBody) {
4008
addRemoveClass(_hostElement, _classNameHostRTL, _isRTL);
4013
addClass(_hostElement, _classNameHostResizeDisabled);
4014
if (resizeChanged) {
4015
addRemoveClass(_hostElement, _classNameHostResizeDisabled, _resizeNone);
4016
addRemoveClass(_scrollbarCornerElement, _classNameScrollbarCornerResize, !_resizeNone);
4017
addRemoveClass(_scrollbarCornerElement, _classNameScrollbarCornerResizeB, _resizeBoth);
4018
addRemoveClass(_scrollbarCornerElement, _classNameScrollbarCornerResizeH, _resizeHorizontal);
4019
addRemoveClass(_scrollbarCornerElement, _classNameScrollbarCornerResizeV, _resizeVertical);
4023
if (scrollbarsVisibilityChanged || overflowBehaviorChanged || hideOverflow.c || hasOverflow.c || ignoreOverlayScrollbarHidingChanged) {
4024
if (ignoreOverlayScrollbarHiding) {
4025
if (ignoreOverlayScrollbarHidingChanged) {
4026
removeClass(_hostElement, _classNameHostScrolling);
4027
if (ignoreOverlayScrollbarHiding) {
4028
refreshScrollbarsVisibility(false);
4032
else if (scrollbarsVisibilityAuto) {
4033
refreshScrollbarsVisibility(canScroll.x, canScroll.y);
4035
else if (scrollbarsVisibilityVisible) {
4036
refreshScrollbarsVisibility(true);
4038
else if (scrollbarsVisibilityHidden) {
4039
refreshScrollbarsVisibility(false);
4044
if (scrollbarsAutoHideChanged || ignoreOverlayScrollbarHidingChanged) {
4045
setupHostMouseTouchEvents(!_scrollbarsAutoHideLeave && !_scrollbarsAutoHideMove);
4046
refreshScrollbarsAutoHide(_scrollbarsAutoHideNever, !_scrollbarsAutoHideNever);
4050
if (hostSizeChanged || overflowAmount.c || heightAutoChanged || widthAutoChanged || resizeChanged || boxSizingChanged || paddingAbsoluteChanged || ignoreOverlayScrollbarHidingChanged || cssDirectionChanged) {
4051
refreshScrollbarHandleLength(true);
4052
refreshScrollbarHandleOffset(true);
4053
refreshScrollbarHandleLength(false);
4054
refreshScrollbarHandleOffset(false);
4058
if (scrollbarsClickScrollingChanged)
4059
refreshScrollbarsInteractive(true, scrollbarsClickScrolling);
4060
if (scrollbarsDragScrollingChanged)
4061
refreshScrollbarsInteractive(false, scrollbarsDragScrolling);
4064
dispatchCallback('onDirectionChanged', {
4067
}, cssDirectionChanged);
4068
dispatchCallback('onHostSizeChanged', {
4069
width: _hostSizeCache.w,
4070
height: _hostSizeCache.h
4071
}, hostSizeChanged);
4072
dispatchCallback('onContentSizeChanged', {
4073
width: _contentScrollSizeCache.w,
4074
height: _contentScrollSizeCache.h
4075
}, contentSizeChanged);
4076
dispatchCallback('onOverflowChanged', {
4079
xScrollable: hideOverflow.xs,
4080
yScrollable: hideOverflow.ys,
4081
clipped: hideOverflow.x || hideOverflow.y
4082
}, hasOverflow.c || hideOverflow.c);
4083
dispatchCallback('onOverflowAmountChanged', {
4084
x: overflowAmount.x,
4086
}, overflowAmount.c);
4090
if (_isBody && _bodyMinSizeCache && (_hasOverflowCache.c || _bodyMinSizeCache.c)) {
4092
if (!_bodyMinSizeCache.f)
4093
bodyMinSizeChanged();
4094
if (_nativeScrollbarIsOverlaid.y && _hasOverflowCache.x)
4095
_contentElement.css(_strMinMinus + _strWidth, _bodyMinSizeCache.w + _overlayScrollbarDummySize.y);
4096
if (_nativeScrollbarIsOverlaid.x && _hasOverflowCache.y)
4097
_contentElement.css(_strMinMinus + _strHeight, _bodyMinSizeCache.h + _overlayScrollbarDummySize.x);
4098
_bodyMinSizeCache.c = false;
4101
if (_initialized && changedOptions.updateOnLoad) {
4102
updateElementsOnLoad();
4108
dispatchCallback('onUpdated', { forced: force });
4114
function updateElementsOnLoad() {
4116
eachUpdateOnLoad(function (i, updateOnLoadSelector) {
4117
_contentElement.find(updateOnLoadSelector).each(function (i, el) {
4119
if (COMPATIBILITY.inA(el, _updateOnLoadElms) < 0) {
4120
_updateOnLoadElms.push(el);
4122
.off(_updateOnLoadEventName, updateOnLoadCallback)
4123
.on(_updateOnLoadEventName, updateOnLoadCallback);
4137
function setOptions(newOptions) {
4138
var validatedOpts = _pluginsOptions._validate(newOptions, _pluginsOptions._template, true, _currentOptions)
4140
_currentOptions = extendDeep({}, _currentOptions, validatedOpts._default);
4141
_currentPreparedOptions = extendDeep({}, _currentPreparedOptions, validatedOpts._prepared);
4143
return validatedOpts._prepared;
4157
function setupStructureDOM(destroy) {
4158
var strParent = 'parent';
4159
var classNameResizeObserverHost = 'os-resize-observer-host';
4160
var classNameTextareaElementFull = _classNameTextareaElement + _strSpace + _classNameTextInherit;
4161
var textareaClass = _isTextarea ? _strSpace + _classNameTextInherit : _strEmpty;
4162
var adoptAttrs = _currentPreparedOptions.textarea.inheritedAttrs;
4163
var adoptAttrsMap = {};
4164
var applyAdoptedAttrs = function () {
4165
var applyAdoptedAttrsElm = destroy ? _targetElement : _hostElement;
4166
each(adoptAttrsMap, function (key, value) {
4167
if (type(value) == TYPES.s) {
4168
if (key == LEXICON.c)
4169
applyAdoptedAttrsElm.addClass(value);
4171
applyAdoptedAttrsElm.attr(key, value);
4175
var hostElementClassNames = [
4176
_classNameHostElement,
4177
_classNameHostElementForeign,
4178
_classNameHostTextareaElement,
4179
_classNameHostResizeDisabled,
4181
_classNameHostScrollbarHorizontalHidden,
4182
_classNameHostScrollbarVerticalHidden,
4183
_classNameHostTransition,
4184
_classNameHostScrolling,
4185
_classNameHostOverflow,
4186
_classNameHostOverflowX,
4187
_classNameHostOverflowY,
4188
_classNameThemeNone,
4189
_classNameTextareaElement,
4190
_classNameTextInherit,
4191
_classNameCache].join(_strSpace);
4192
var hostElementCSS = {};
4195
_hostElement = _hostElement || (_isTextarea ? (_domExists ? _targetElement[strParent]()[strParent]()[strParent]()[strParent]() : FRAMEWORK(generateDiv(_classNameHostTextareaElement))) : _targetElement);
4196
_contentElement = _contentElement || selectOrGenerateDivByClass(_classNameContentElement + textareaClass);
4197
_viewportElement = _viewportElement || selectOrGenerateDivByClass(_classNameViewportElement + textareaClass);
4198
_paddingElement = _paddingElement || selectOrGenerateDivByClass(_classNamePaddingElement + textareaClass);
4199
_sizeObserverElement = _sizeObserverElement || selectOrGenerateDivByClass(classNameResizeObserverHost);
4200
_textareaCoverElement = _textareaCoverElement || (_isTextarea ? selectOrGenerateDivByClass(_classNameTextareaCoverElement) : undefined);
4204
addClass(_hostElement, _classNameHostElementForeign);
4209
removeClass(_hostElement, hostElementClassNames);
4212
adoptAttrs = type(adoptAttrs) == TYPES.s ? adoptAttrs.split(_strSpace) : adoptAttrs;
4213
if (COMPATIBILITY.isA(adoptAttrs) && _isTextarea) {
4214
each(adoptAttrs, function (i, v) {
4215
if (type(v) == TYPES.s) {
4216
adoptAttrsMap[v] = destroy ? _hostElement.attr(v) : _targetElement.attr(v);
4223
if (!_currentPreparedOptions.sizeAutoCapable) {
4224
hostElementCSS[_strWidth] = _targetElement.css(_strWidth);
4225
hostElementCSS[_strHeight] = _targetElement.css(_strHeight);
4229
_targetElement.addClass(_classNameTextInherit).wrap(_hostElement);
4232
_hostElement = _targetElement[strParent]().css(hostElementCSS);
4237
addClass(_targetElement, _isTextarea ? classNameTextareaElementFull : _classNameHostElement);
4240
_hostElement.wrapInner(_contentElement)
4241
.wrapInner(_viewportElement)
4242
.wrapInner(_paddingElement)
4243
.prepend(_sizeObserverElement);
4246
_contentElement = findFirst(_hostElement, _strDot + _classNameContentElement);
4247
_viewportElement = findFirst(_hostElement, _strDot + _classNameViewportElement);
4248
_paddingElement = findFirst(_hostElement, _strDot + _classNamePaddingElement);
4251
_contentElement.prepend(_textareaCoverElement);
4252
applyAdoptedAttrs();
4256
if (_nativeScrollbarStyling)
4257
addClass(_viewportElement, _classNameViewportNativeScrollbarsInvisible);
4258
if (_nativeScrollbarIsOverlaid.x && _nativeScrollbarIsOverlaid.y)
4259
addClass(_viewportElement, _classNameViewportNativeScrollbarsOverlaid);
4261
addClass(_htmlElement, _classNameHTMLElement);
4263
_sizeObserverElementNative = _sizeObserverElement[0];
4264
_hostElementNative = _hostElement[0];
4265
_paddingElementNative = _paddingElement[0];
4266
_viewportElementNative = _viewportElement[0];
4267
_contentElementNative = _contentElement[0];
4269
updateViewportAttrsFromTarget();
4272
if (_domExists && _initialized) {
4274
_sizeObserverElement.children().remove();
4277
each([_paddingElement, _viewportElement, _contentElement, _textareaCoverElement], function (i, elm) {
4279
removeClass(elm.removeAttr(LEXICON.s), _classNamesDynamicDestroy);
4284
addClass(_hostElement, _isTextarea ? _classNameHostTextareaElement : _classNameHostElement);
4288
remove(_sizeObserverElement);
4291
_contentElement.contents()
4297
_targetElement.unwrap();
4298
remove(_hostElement);
4299
remove(_textareaCoverElement);
4300
applyAdoptedAttrs();
4305
_targetElement.removeAttr(LEXICON.s);
4308
removeClass(_htmlElement, _classNameHTMLElement);
4316
function setupStructureEvents() {
4317
var textareaKeyDownRestrictedKeyCodes = [
4318
112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 123,
4321
16, 17, 18, 19, 20, 144
4323
var textareaKeyDownKeyCodesList = [];
4324
var textareaUpdateIntervalID;
4325
var scrollStopTimeoutId;
4326
var scrollStopDelay = 175;
4327
var strFocus = 'focus';
4329
function updateTextarea(doClearInterval) {
4331
_base.update(_strAuto);
4332
if (doClearInterval && _autoUpdateRecommended)
4333
clearInterval(textareaUpdateIntervalID);
4335
function textareaOnScroll(event) {
4336
_targetElement[_strScrollLeft](_rtlScrollBehavior.i && _normalizeRTLCache ? 9999999 : 0);
4337
_targetElement[_strScrollTop](0);
4338
COMPATIBILITY.prvD(event);
4339
COMPATIBILITY.stpP(event);
4342
function textareaOnDrop(event) {
4343
setTimeout(function () {
4348
function textareaOnFocus() {
4349
_textareaHasFocus = true;
4350
addClass(_hostElement, strFocus);
4352
function textareaOnFocusout() {
4353
_textareaHasFocus = false;
4354
textareaKeyDownKeyCodesList = [];
4355
removeClass(_hostElement, strFocus);
4356
updateTextarea(true);
4358
function textareaOnKeyDown(event) {
4359
var keyCode = event.keyCode;
4361
if (inArray(keyCode, textareaKeyDownRestrictedKeyCodes) < 0) {
4362
if (!textareaKeyDownKeyCodesList[LEXICON.l]) {
4364
textareaUpdateIntervalID = setInterval(updateTextarea, 1000 / 60);
4366
if (inArray(keyCode, textareaKeyDownKeyCodesList) < 0)
4367
textareaKeyDownKeyCodesList.push(keyCode);
4370
function textareaOnKeyUp(event) {
4371
var keyCode = event.keyCode;
4372
var index = inArray(keyCode, textareaKeyDownKeyCodesList);
4374
if (inArray(keyCode, textareaKeyDownRestrictedKeyCodes) < 0) {
4376
textareaKeyDownKeyCodesList.splice(index, 1);
4377
if (!textareaKeyDownKeyCodesList[LEXICON.l])
4378
updateTextarea(true);
4381
function contentOnTransitionEnd(event) {
4382
if (_autoUpdateCache === true)
4384
event = event.originalEvent || event;
4385
if (isSizeAffectingCSSProperty(event.propertyName))
4386
_base.update(_strAuto);
4388
function viewportOnScroll(event) {
4390
if (scrollStopTimeoutId !== undefined)
4391
clearTimeout(scrollStopTimeoutId);
4393
if (_scrollbarsAutoHideScroll || _scrollbarsAutoHideMove)
4394
refreshScrollbarsAutoHide(true);
4396
if (!nativeOverlayScrollbarsAreActive())
4397
addClass(_hostElement, _classNameHostScrolling);
4399
dispatchCallback('onScrollStart', event);
4405
if (!_scrollbarsHandlesDefineScrollPos) {
4406
refreshScrollbarHandleOffset(true);
4407
refreshScrollbarHandleOffset(false);
4409
dispatchCallback('onScroll', event);
4411
scrollStopTimeoutId = setTimeout(function () {
4414
clearTimeout(scrollStopTimeoutId);
4415
scrollStopTimeoutId = undefined;
4417
if (_scrollbarsAutoHideScroll || _scrollbarsAutoHideMove)
4418
refreshScrollbarsAutoHide(false);
4420
if (!nativeOverlayScrollbarsAreActive())
4421
removeClass(_hostElement, _classNameHostScrolling);
4423
dispatchCallback('onScrollStop', event);
4425
}, scrollStopDelay);
4431
if (_msieVersion > 9 || !_autoUpdateRecommended) {
4432
addDestroyEventListener(_targetElement, 'input', updateTextarea);
4435
addDestroyEventListener(_targetElement,
4436
[_strKeyDownEvent, _strKeyUpEvent],
4437
[textareaOnKeyDown, textareaOnKeyUp]);
4440
addDestroyEventListener(_targetElement,
4441
[_strScroll, 'drop', strFocus, strFocus + 'out'],
4442
[textareaOnScroll, textareaOnDrop, textareaOnFocus, textareaOnFocusout]);
4445
addDestroyEventListener(_contentElement, _strTransitionEndEvent, contentOnTransitionEnd);
4447
addDestroyEventListener(_viewportElement, _strScroll, viewportOnScroll, true);
4457
function setupScrollbarsDOM(destroy) {
4458
var selectOrGenerateScrollbarDOM = function (isHorizontal) {
4459
var scrollbarClassName = isHorizontal ? _classNameScrollbarHorizontal : _classNameScrollbarVertical;
4460
var scrollbar = selectOrGenerateDivByClass(_classNameScrollbar + _strSpace + scrollbarClassName, true);
4461
var track = selectOrGenerateDivByClass(_classNameScrollbarTrack, scrollbar);
4462
var handle = selectOrGenerateDivByClass(_classNameScrollbarHandle, scrollbar);
4464
if (!_domExists && !destroy) {
4465
scrollbar.append(track);
4466
track.append(handle);
4470
_scrollbar: scrollbar,
4475
function resetScrollbarDOM(isHorizontal) {
4476
var scrollbarVars = getScrollbarVars(isHorizontal);
4477
var scrollbar = scrollbarVars._scrollbar;
4478
var track = scrollbarVars._track;
4479
var handle = scrollbarVars._handle;
4481
if (_domExists && _initialized) {
4482
each([scrollbar, track, handle], function (i, elm) {
4483
removeClass(elm.removeAttr(LEXICON.s), _classNamesDynamicDestroy);
4487
remove(scrollbar || selectOrGenerateScrollbarDOM(isHorizontal)._scrollbar);
4490
var horizontalElements;
4491
var verticalElements;
4494
horizontalElements = selectOrGenerateScrollbarDOM(true);
4495
verticalElements = selectOrGenerateScrollbarDOM();
4497
_scrollbarHorizontalElement = horizontalElements._scrollbar;
4498
_scrollbarHorizontalTrackElement = horizontalElements._track;
4499
_scrollbarHorizontalHandleElement = horizontalElements._handle;
4500
_scrollbarVerticalElement = verticalElements._scrollbar;
4501
_scrollbarVerticalTrackElement = verticalElements._track;
4502
_scrollbarVerticalHandleElement = verticalElements._handle;
4505
_paddingElement.after(_scrollbarVerticalElement);
4506
_paddingElement.after(_scrollbarHorizontalElement);
4510
resetScrollbarDOM(true);
4511
resetScrollbarDOM();
4519
function setupScrollbarEvents(isHorizontal) {
4520
var scrollbarVars = getScrollbarVars(isHorizontal);
4521
var scrollbarVarsInfo = scrollbarVars._info;
4522
var insideIFrame = _windowElementNative.top !== _windowElementNative;
4523
var xy = scrollbarVars._x_y;
4524
var XY = scrollbarVars._X_Y;
4525
var scroll = _strScroll + scrollbarVars._Left_Top;
4526
var strActive = 'active';
4527
var strSnapHandle = 'snapHandle';
4528
var strClickEvent = 'click';
4529
var scrollDurationFactor = 1;
4530
var increaseDecreaseScrollAmountKeyCodes = [16, 17];
4532
var mouseDownScroll;
4533
var mouseDownOffset;
4534
var mouseDownInvertedScale;
4536
function getPointerPosition(event) {
4537
return _msieVersion && insideIFrame ? event['screen' + XY] : COMPATIBILITY.page(event)[xy];
4539
function getPreparedScrollbarsOption(name) {
4540
return _currentPreparedOptions.scrollbars[name];
4542
function increaseTrackScrollAmount() {
4543
scrollDurationFactor = 0.5;
4545
function decreaseTrackScrollAmount() {
4546
scrollDurationFactor = 1;
4548
function stopClickEventPropagation(event) {
4549
COMPATIBILITY.stpP(event);
4551
function documentKeyDown(event) {
4552
if (inArray(event.keyCode, increaseDecreaseScrollAmountKeyCodes) > -1)
4553
increaseTrackScrollAmount();
4555
function documentKeyUp(event) {
4556
if (inArray(event.keyCode, increaseDecreaseScrollAmountKeyCodes) > -1)
4557
decreaseTrackScrollAmount();
4559
function onMouseTouchDownContinue(event) {
4560
var originalEvent = event.originalEvent || event;
4561
var isTouchEvent = originalEvent.touches !== undefined;
4562
return _sleeping || _destroyed || nativeOverlayScrollbarsAreActive() || !_scrollbarsDragScrollingCache || (isTouchEvent && !getPreparedScrollbarsOption('touchSupport')) ? false : COMPATIBILITY.mBtn(event) === 1 || isTouchEvent;
4564
function documentDragMove(event) {
4565
if (onMouseTouchDownContinue(event)) {
4566
var trackLength = scrollbarVarsInfo._trackLength;
4567
var handleLength = scrollbarVarsInfo._handleLength;
4568
var scrollRange = scrollbarVarsInfo._maxScroll;
4569
var scrollRaw = (getPointerPosition(event) - mouseDownOffset) * mouseDownInvertedScale;
4570
var scrollDeltaPercent = scrollRaw / (trackLength - handleLength);
4571
var scrollDelta = (scrollRange * scrollDeltaPercent);
4572
scrollDelta = isFinite(scrollDelta) ? scrollDelta : 0;
4573
if (_isRTL && isHorizontal && !_rtlScrollBehavior.i)
4576
_viewportElement[scroll](MATH.round(mouseDownScroll + scrollDelta));
4578
if (_scrollbarsHandlesDefineScrollPos)
4579
refreshScrollbarHandleOffset(isHorizontal, mouseDownScroll + scrollDelta);
4581
if (!_supportPassiveEvents)
4582
COMPATIBILITY.prvD(event);
4585
documentMouseTouchUp(event);
4587
function documentMouseTouchUp(event) {
4588
event = event || event.originalEvent;
4590
setupResponsiveEventListener(_documentElement,
4591
[_strMouseTouchMoveEvent, _strMouseTouchUpEvent, _strKeyDownEvent, _strKeyUpEvent, _strSelectStartEvent],
4592
[documentDragMove, documentMouseTouchUp, documentKeyDown, documentKeyUp, documentOnSelectStart],
4594
COMPATIBILITY.rAF()(function() {
4595
setupResponsiveEventListener(_documentElement, strClickEvent, stopClickEventPropagation, true, { _capture: true });
4599
if (_scrollbarsHandlesDefineScrollPos)
4600
refreshScrollbarHandleOffset(isHorizontal, true);
4602
_scrollbarsHandlesDefineScrollPos = false;
4603
removeClass(_bodyElement, _classNameDragging);
4604
removeClass(scrollbarVars._handle, strActive);
4605
removeClass(scrollbarVars._track, strActive);
4606
removeClass(scrollbarVars._scrollbar, strActive);
4608
mouseDownScroll = undefined;
4609
mouseDownOffset = undefined;
4610
mouseDownInvertedScale = 1;
4612
decreaseTrackScrollAmount();
4614
if (trackTimeout !== undefined) {
4616
clearTimeout(trackTimeout);
4617
trackTimeout = undefined;
4621
var rect = _hostElementNative[LEXICON.bCR]();
4622
var mouseInsideHost = event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
4625
if (!mouseInsideHost)
4628
if (_scrollbarsAutoHideScroll || _scrollbarsAutoHideMove)
4629
refreshScrollbarsAutoHide(false);
4632
function onHandleMouseTouchDown(event) {
4633
if (onMouseTouchDownContinue(event))
4634
onHandleMouseTouchDownAction(event);
4636
function onHandleMouseTouchDownAction(event) {
4637
mouseDownScroll = _viewportElement[scroll]();
4638
mouseDownScroll = isNaN(mouseDownScroll) ? 0 : mouseDownScroll;
4639
if (_isRTL && isHorizontal && !_rtlScrollBehavior.n || !_isRTL)
4640
mouseDownScroll = mouseDownScroll < 0 ? 0 : mouseDownScroll;
4642
mouseDownInvertedScale = getHostElementInvertedScale()[xy];
4643
mouseDownOffset = getPointerPosition(event);
4645
_scrollbarsHandlesDefineScrollPos = !getPreparedScrollbarsOption(strSnapHandle);
4646
addClass(_bodyElement, _classNameDragging);
4647
addClass(scrollbarVars._handle, strActive);
4648
addClass(scrollbarVars._scrollbar, strActive);
4650
setupResponsiveEventListener(_documentElement,
4651
[_strMouseTouchMoveEvent, _strMouseTouchUpEvent, _strSelectStartEvent],
4652
[documentDragMove, documentMouseTouchUp, documentOnSelectStart]);
4653
COMPATIBILITY.rAF()(function() {
4654
setupResponsiveEventListener(_documentElement, strClickEvent, stopClickEventPropagation, false, { _capture: true });
4658
if (_msieVersion || !_documentMixed)
4659
COMPATIBILITY.prvD(event);
4660
COMPATIBILITY.stpP(event);
4662
function onTrackMouseTouchDown(event) {
4663
if (onMouseTouchDownContinue(event)) {
4664
var handleToViewportRatio = scrollbarVars._info._handleLength / Math.round(MATH.min(1, _viewportSize[scrollbarVars._w_h] / _contentScrollSizeCache[scrollbarVars._w_h]) * scrollbarVars._info._trackLength);
4665
var scrollDistance = MATH.round(_viewportSize[scrollbarVars._w_h] * handleToViewportRatio);
4666
var scrollBaseDuration = 270 * handleToViewportRatio;
4667
var scrollFirstIterationDelay = 400 * handleToViewportRatio;
4668
var trackOffset = scrollbarVars._track.offset()[scrollbarVars._left_top];
4669
var ctrlKey = event.ctrlKey;
4670
var instantScroll = event.shiftKey;
4671
var instantScrollTransition = instantScroll && ctrlKey;
4672
var isFirstIteration = true;
4673
var easing = 'linear';
4675
var finishedCondition;
4676
var scrollActionFinsished = function (transition) {
4677
if (_scrollbarsHandlesDefineScrollPos)
4678
refreshScrollbarHandleOffset(isHorizontal, transition);
4680
var scrollActionInstantFinished = function () {
4681
scrollActionFinsished();
4682
onHandleMouseTouchDownAction(event);
4684
var scrollAction = function () {
4686
var mouseOffset = (mouseDownOffset - trackOffset) * mouseDownInvertedScale;
4687
var handleOffset = scrollbarVarsInfo._handleOffset;
4688
var trackLength = scrollbarVarsInfo._trackLength;
4689
var handleLength = scrollbarVarsInfo._handleLength;
4690
var scrollRange = scrollbarVarsInfo._maxScroll;
4691
var currScroll = scrollbarVarsInfo._currentScroll;
4692
var scrollDuration = scrollBaseDuration * scrollDurationFactor;
4693
var timeoutDelay = isFirstIteration ? MATH.max(scrollFirstIterationDelay, scrollDuration) : scrollDuration;
4694
var instantScrollPosition = scrollRange * ((mouseOffset - (handleLength / 2)) / (trackLength - handleLength));
4695
var rtlIsNormal = _isRTL && isHorizontal && ((!_rtlScrollBehavior.i && !_rtlScrollBehavior.n) || _normalizeRTLCache);
4696
var decreaseScrollCondition = rtlIsNormal ? handleOffset < mouseOffset : handleOffset > mouseOffset;
4698
var animationObj = {
4700
step: function (now) {
4701
if (_scrollbarsHandlesDefineScrollPos) {
4702
_viewportElement[scroll](now);
4703
refreshScrollbarHandleOffset(isHorizontal, now);
4707
instantScrollPosition = isFinite(instantScrollPosition) ? instantScrollPosition : 0;
4708
instantScrollPosition = _isRTL && isHorizontal && !_rtlScrollBehavior.i ? (scrollRange - instantScrollPosition) : instantScrollPosition;
4712
if (instantScroll) {
4713
_viewportElement[scroll](instantScrollPosition);
4714
if (instantScrollTransition) {
4717
instantScrollPosition = _viewportElement[scroll]();
4719
_viewportElement[scroll](currScroll);
4721
instantScrollPosition = rtlIsNormal && _rtlScrollBehavior.i ? (scrollRange - instantScrollPosition) : instantScrollPosition;
4722
instantScrollPosition = rtlIsNormal && _rtlScrollBehavior.n ? -instantScrollPosition : instantScrollPosition;
4724
scrollObj[xy] = instantScrollPosition;
4725
_base.scroll(scrollObj, extendDeep(animationObj, {
4727
complete: scrollActionInstantFinished
4731
scrollActionInstantFinished();
4734
decreaseScroll = isFirstIteration ? decreaseScrollCondition : decreaseScroll;
4735
finishedCondition = rtlIsNormal
4736
? (decreaseScroll ? handleOffset + handleLength >= mouseOffset : handleOffset <= mouseOffset)
4737
: (decreaseScroll ? handleOffset <= mouseOffset : handleOffset + handleLength >= mouseOffset);
4739
if (finishedCondition) {
4740
clearTimeout(trackTimeout);
4742
trackTimeout = undefined;
4743
scrollActionFinsished(true);
4746
trackTimeout = setTimeout(scrollAction, timeoutDelay);
4748
scrollObj[xy] = (decreaseScroll ? '-=' : '+=') + scrollDistance;
4749
_base.scroll(scrollObj, extendDeep(animationObj, {
4750
duration: scrollDuration
4753
isFirstIteration = false;
4758
increaseTrackScrollAmount();
4760
mouseDownInvertedScale = getHostElementInvertedScale()[xy];
4761
mouseDownOffset = COMPATIBILITY.page(event)[xy];
4763
_scrollbarsHandlesDefineScrollPos = !getPreparedScrollbarsOption(strSnapHandle);
4764
addClass(_bodyElement, _classNameDragging);
4765
addClass(scrollbarVars._track, strActive);
4766
addClass(scrollbarVars._scrollbar, strActive);
4768
setupResponsiveEventListener(_documentElement,
4769
[_strMouseTouchUpEvent, _strKeyDownEvent, _strKeyUpEvent, _strSelectStartEvent],
4770
[documentMouseTouchUp, documentKeyDown, documentKeyUp, documentOnSelectStart]);
4773
COMPATIBILITY.prvD(event);
4774
COMPATIBILITY.stpP(event);
4777
function onTrackMouseTouchEnter(event) {
4779
_scrollbarsHandleHovered = true;
4780
if (_scrollbarsAutoHideScroll || _scrollbarsAutoHideMove)
4781
refreshScrollbarsAutoHide(true);
4783
function onTrackMouseTouchLeave(event) {
4784
_scrollbarsHandleHovered = false;
4785
if (_scrollbarsAutoHideScroll || _scrollbarsAutoHideMove)
4786
refreshScrollbarsAutoHide(false);
4788
function onScrollbarMouseTouchDown(event) {
4789
COMPATIBILITY.stpP(event);
4792
addDestroyEventListener(scrollbarVars._handle,
4793
_strMouseTouchDownEvent,
4794
onHandleMouseTouchDown);
4795
addDestroyEventListener(scrollbarVars._track,
4796
[_strMouseTouchDownEvent, _strMouseEnter, _strMouseLeave],
4797
[onTrackMouseTouchDown, onTrackMouseTouchEnter, onTrackMouseTouchLeave]);
4798
addDestroyEventListener(scrollbarVars._scrollbar,
4799
_strMouseTouchDownEvent,
4800
onScrollbarMouseTouchDown);
4802
if (_supportTransition) {
4803
addDestroyEventListener(scrollbarVars._scrollbar, _strTransitionEndEvent, function (event) {
4804
if (event.target !== scrollbarVars._scrollbar[0])
4806
refreshScrollbarHandleLength(isHorizontal);
4807
refreshScrollbarHandleOffset(isHorizontal);
4818
function refreshScrollbarAppearance(isHorizontal, shallBeVisible, canScroll) {
4819
var scrollbarHiddenClassName = isHorizontal ? _classNameHostScrollbarHorizontalHidden : _classNameHostScrollbarVerticalHidden;
4820
var scrollbarElement = isHorizontal ? _scrollbarHorizontalElement : _scrollbarVerticalElement;
4822
addRemoveClass(_hostElement, scrollbarHiddenClassName, !shallBeVisible);
4823
addRemoveClass(scrollbarElement, _classNameScrollbarUnusable, !canScroll);
4831
function refreshScrollbarsAutoHide(shallBeVisible, delayfree) {
4832
clearTimeout(_scrollbarsAutoHideTimeoutId);
4833
if (shallBeVisible) {
4835
removeClass(_scrollbarHorizontalElement, _classNameScrollbarAutoHidden);
4837
removeClass(_scrollbarVerticalElement, _classNameScrollbarAutoHidden);
4841
var strActive = 'active';
4842
var hide = function () {
4843
if (!_scrollbarsHandleHovered && !_destroyed) {
4844
anyActive = _scrollbarHorizontalHandleElement.hasClass(strActive) || _scrollbarVerticalHandleElement.hasClass(strActive);
4845
if (!anyActive && (_scrollbarsAutoHideScroll || _scrollbarsAutoHideMove || _scrollbarsAutoHideLeave))
4846
addClass(_scrollbarHorizontalElement, _classNameScrollbarAutoHidden);
4847
if (!anyActive && (_scrollbarsAutoHideScroll || _scrollbarsAutoHideMove || _scrollbarsAutoHideLeave))
4848
addClass(_scrollbarVerticalElement, _classNameScrollbarAutoHidden);
4851
if (_scrollbarsAutoHideDelay > 0 && delayfree !== true)
4852
_scrollbarsAutoHideTimeoutId = setTimeout(hide, _scrollbarsAutoHideDelay);
4862
function refreshScrollbarHandleLength(isHorizontal) {
4864
var scrollbarVars = getScrollbarVars(isHorizontal);
4865
var scrollbarVarsInfo = scrollbarVars._info;
4866
var digit = 1000000;
4868
var handleRatio = MATH.min(1, _viewportSize[scrollbarVars._w_h] / _contentScrollSizeCache[scrollbarVars._w_h]);
4869
handleCSS[scrollbarVars._width_height] = (MATH.floor(handleRatio * 100 * digit) / digit) + '%';
4871
if (!nativeOverlayScrollbarsAreActive())
4872
scrollbarVars._handle.css(handleCSS);
4875
scrollbarVarsInfo._handleLength = scrollbarVars._handle[0]['offset' + scrollbarVars._Width_Height];
4876
scrollbarVarsInfo._handleLengthRatio = handleRatio;
4884
function refreshScrollbarHandleOffset(isHorizontal, scrollOrTransition) {
4885
var transition = type(scrollOrTransition) == TYPES.b;
4886
var transitionDuration = 250;
4887
var isRTLisHorizontal = _isRTL && isHorizontal;
4888
var scrollbarVars = getScrollbarVars(isHorizontal);
4889
var scrollbarVarsInfo = scrollbarVars._info;
4890
var strTranslateBrace = 'translate(';
4891
var strTransform = VENDORS._cssProperty('transform');
4892
var strTransition = VENDORS._cssProperty('transition');
4893
var nativeScroll = isHorizontal ? _viewportElement[_strScrollLeft]() : _viewportElement[_strScrollTop]();
4894
var currentScroll = scrollOrTransition === undefined || transition ? nativeScroll : scrollOrTransition;
4897
var handleLength = scrollbarVarsInfo._handleLength;
4898
var trackLength = scrollbarVars._track[0]['offset' + scrollbarVars._Width_Height];
4899
var handleTrackDiff = trackLength - handleLength;
4901
var transformOffset;
4907
var maxScroll = (_viewportElementNative[_strScroll + scrollbarVars._Width_Height] - _viewportElementNative['client' + scrollbarVars._Width_Height]) * (_rtlScrollBehavior.n && isRTLisHorizontal ? -1 : 1);
4908
var getScrollRatio = function (base) {
4909
return isNaN(base / maxScroll) ? 0 : MATH.max(0, MATH.min(1, base / maxScroll));
4911
var getHandleOffset = function (scrollRatio) {
4912
var offset = handleTrackDiff * scrollRatio;
4913
offset = isNaN(offset) ? 0 : offset;
4914
offset = (isRTLisHorizontal && !_rtlScrollBehavior.i) ? (trackLength - handleLength - offset) : offset;
4915
offset = MATH.max(0, offset);
4918
var scrollRatio = getScrollRatio(nativeScroll);
4919
var unsnappedScrollRatio = getScrollRatio(currentScroll);
4920
var handleOffset = getHandleOffset(unsnappedScrollRatio);
4921
var snappedHandleOffset = getHandleOffset(scrollRatio);
4923
scrollbarVarsInfo._maxScroll = maxScroll;
4924
scrollbarVarsInfo._currentScroll = nativeScroll;
4925
scrollbarVarsInfo._currentScrollRatio = scrollRatio;
4927
if (_supportTransform) {
4928
transformOffset = isRTLisHorizontal ? -(trackLength - handleLength - handleOffset) : handleOffset;
4930
translateValue = isHorizontal ? strTranslateBrace + transformOffset + 'px, 0)' : strTranslateBrace + '0, ' + transformOffset + 'px)';
4932
handleCSS[strTransform] = translateValue;
4935
if (_supportTransition)
4936
handleCSS[strTransition] = transition && MATH.abs(handleOffset - scrollbarVarsInfo._handleOffset) > 1 ? getCSSTransitionString(scrollbarVars._handle) + ', ' + (strTransform + _strSpace + transitionDuration + 'ms') : _strEmpty;
4939
handleCSS[scrollbarVars._left_top] = handleOffset;
4943
if (!nativeOverlayScrollbarsAreActive()) {
4944
scrollbarVars._handle.css(handleCSS);
4947
if (_supportTransform && _supportTransition && transition) {
4948
scrollbarVars._handle.one(_strTransitionEndEvent, function () {
4950
scrollbarVars._handle.css(strTransition, _strEmpty);
4955
scrollbarVarsInfo._handleOffset = handleOffset;
4956
scrollbarVarsInfo._snappedHandleOffset = snappedHandleOffset;
4957
scrollbarVarsInfo._trackLength = trackLength;
4965
function refreshScrollbarsInteractive(isTrack, value) {
4966
var action = value ? 'removeClass' : 'addClass';
4967
var element1 = isTrack ? _scrollbarHorizontalTrackElement : _scrollbarHorizontalHandleElement;
4968
var element2 = isTrack ? _scrollbarVerticalTrackElement : _scrollbarVerticalHandleElement;
4969
var className = isTrack ? _classNameScrollbarTrackOff : _classNameScrollbarHandleOff;
4971
element1[action](className);
4972
element2[action](className);
4980
function getScrollbarVars(isHorizontal) {
4982
_width_height: isHorizontal ? _strWidth : _strHeight,
4983
_Width_Height: isHorizontal ? 'Width' : 'Height',
4984
_left_top: isHorizontal ? _strLeft : _strTop,
4985
_Left_Top: isHorizontal ? 'Left' : 'Top',
4986
_x_y: isHorizontal ? _strX : _strY,
4987
_X_Y: isHorizontal ? 'X' : 'Y',
4988
_w_h: isHorizontal ? 'w' : 'h',
4989
_l_t: isHorizontal ? 'l' : 't',
4990
_track: isHorizontal ? _scrollbarHorizontalTrackElement : _scrollbarVerticalTrackElement,
4991
_handle: isHorizontal ? _scrollbarHorizontalHandleElement : _scrollbarVerticalHandleElement,
4992
_scrollbar: isHorizontal ? _scrollbarHorizontalElement : _scrollbarVerticalElement,
4993
_info: isHorizontal ? _scrollHorizontalInfo : _scrollVerticalInfo
5004
function setupScrollbarCornerDOM(destroy) {
5005
_scrollbarCornerElement = _scrollbarCornerElement || selectOrGenerateDivByClass(_classNameScrollbarCorner, true);
5009
_hostElement.append(_scrollbarCornerElement);
5013
if (_domExists && _initialized) {
5014
removeClass(_scrollbarCornerElement.removeAttr(LEXICON.s), _classNamesDynamicDestroy);
5017
remove(_scrollbarCornerElement);
5025
function setupScrollbarCornerEvents() {
5026
var insideIFrame = _windowElementNative.top !== _windowElementNative;
5027
var mouseDownPosition = {};
5028
var mouseDownSize = {};
5029
var mouseDownInvertedScale = {};
5030
var reconnectMutationObserver;
5032
function documentDragMove(event) {
5033
if (onMouseTouchDownContinue(event)) {
5034
var pageOffset = getCoordinates(event);
5035
var hostElementCSS = {};
5036
if (_resizeHorizontal || _resizeBoth)
5037
hostElementCSS[_strWidth] = (mouseDownSize.w + (pageOffset.x - mouseDownPosition.x) * mouseDownInvertedScale.x);
5038
if (_resizeVertical || _resizeBoth)
5039
hostElementCSS[_strHeight] = (mouseDownSize.h + (pageOffset.y - mouseDownPosition.y) * mouseDownInvertedScale.y);
5040
_hostElement.css(hostElementCSS);
5041
COMPATIBILITY.stpP(event);
5044
documentMouseTouchUp(event);
5047
function documentMouseTouchUp(event) {
5048
var eventIsTrusted = event !== undefined;
5050
setupResponsiveEventListener(_documentElement,
5051
[_strSelectStartEvent, _strMouseTouchMoveEvent, _strMouseTouchUpEvent],
5052
[documentOnSelectStart, documentDragMove, documentMouseTouchUp],
5055
removeClass(_bodyElement, _classNameDragging);
5056
if (_scrollbarCornerElement.releaseCapture)
5057
_scrollbarCornerElement.releaseCapture();
5059
if (eventIsTrusted) {
5060
if (reconnectMutationObserver)
5061
connectMutationObservers();
5062
_base.update(_strAuto);
5064
reconnectMutationObserver = false;
5066
function onMouseTouchDownContinue(event) {
5067
var originalEvent = event.originalEvent || event;
5068
var isTouchEvent = originalEvent.touches !== undefined;
5069
return _sleeping || _destroyed ? false : COMPATIBILITY.mBtn(event) === 1 || isTouchEvent;
5071
function getCoordinates(event) {
5072
return _msieVersion && insideIFrame ? { x: event.screenX, y: event.screenY } : COMPATIBILITY.page(event);
5075
addDestroyEventListener(_scrollbarCornerElement, _strMouseTouchDownEvent, function (event) {
5076
if (onMouseTouchDownContinue(event) && !_resizeNone) {
5077
if (_mutationObserversConnected) {
5078
reconnectMutationObserver = true;
5079
disconnectMutationObservers();
5082
mouseDownPosition = getCoordinates(event);
5084
mouseDownSize.w = _hostElementNative[LEXICON.oW] - (!_isBorderBox ? _paddingX : 0);
5085
mouseDownSize.h = _hostElementNative[LEXICON.oH] - (!_isBorderBox ? _paddingY : 0);
5086
mouseDownInvertedScale = getHostElementInvertedScale();
5088
setupResponsiveEventListener(_documentElement,
5089
[_strSelectStartEvent, _strMouseTouchMoveEvent, _strMouseTouchUpEvent],
5090
[documentOnSelectStart, documentDragMove, documentMouseTouchUp]);
5092
addClass(_bodyElement, _classNameDragging);
5093
if (_scrollbarCornerElement.setCapture)
5094
_scrollbarCornerElement.setCapture();
5096
COMPATIBILITY.prvD(event);
5097
COMPATIBILITY.stpP(event);
5111
function dispatchCallback(name, args, dependent) {
5112
if (dependent === false)
5115
var callback = _currentPreparedOptions.callbacks[name];
5116
var extensionOnName = name;
5119
if (extensionOnName.substr(0, 2) === 'on')
5120
extensionOnName = extensionOnName.substr(2, 1).toLowerCase() + extensionOnName.substr(3);
5122
if (type(callback) == TYPES.f)
5123
callback.call(_base, args);
5125
each(_extensions, function () {
5127
if (type(ext.on) == TYPES.f)
5128
ext.on(extensionOnName, args);
5131
else if (!_destroyed)
5132
_callbacksInitQeueue.push({ n: name, a: args });
5142
function setTopRightBottomLeft(targetCSSObject, prefix, values) {
5143
prefix = prefix || _strEmpty;
5144
values = values || [_strEmpty, _strEmpty, _strEmpty, _strEmpty];
5146
targetCSSObject[prefix + _strTop] = values[0];
5147
targetCSSObject[prefix + _strRight] = values[1];
5148
targetCSSObject[prefix + _strBottom] = values[2];
5149
targetCSSObject[prefix + _strLeft] = values[3];
5160
function getTopRightBottomLeftHost(prefix, suffix, zeroX, zeroY) {
5161
suffix = suffix || _strEmpty;
5162
prefix = prefix || _strEmpty;
5164
t: zeroY ? 0 : parseToZeroOrNumber(_hostElement.css(prefix + _strTop + suffix)),
5165
r: zeroX ? 0 : parseToZeroOrNumber(_hostElement.css(prefix + _strRight + suffix)),
5166
b: zeroY ? 0 : parseToZeroOrNumber(_hostElement.css(prefix + _strBottom + suffix)),
5167
l: zeroX ? 0 : parseToZeroOrNumber(_hostElement.css(prefix + _strLeft + suffix))
5176
function getCSSTransitionString(element) {
5177
var transitionStr = VENDORS._cssProperty('transition');
5178
var assembledValue = element.css(transitionStr);
5180
return assembledValue;
5181
var regExpString = '\\s*(' + '([^,(]+(\\(.+?\\))?)+' + ')[\\s,]*';
5182
var regExpMain = new RegExp(regExpString);
5183
var regExpValidate = new RegExp('^(' + regExpString + ')+$');
5184
var properties = 'property duration timing-function delay'.split(' ');
5190
var splitCssStyleByComma = function (str) {
5192
if (!str.match(regExpValidate))
5194
while (str.match(regExpMain)) {
5195
strResult.push(RegExp.$1);
5196
str = str.replace(regExpMain, _strEmpty);
5201
for (; i < properties[LEXICON.l]; i++) {
5202
valueArray = splitCssStyleByComma(element.css(transitionStr + '-' + properties[i]));
5203
for (j = 0; j < valueArray[LEXICON.l]; j++)
5204
result[j] = (result[j] ? result[j] + _strSpace : _strEmpty) + valueArray[j];
5206
return result.join(', ');
5214
function createHostClassNameRegExp(withCurrClassNameOption, withOldClassNameOption) {
5218
var appendClasses = function (classes, condition) {
5220
if (condition && typeof classes == TYPES.s) {
5221
split = classes.split(_strSpace);
5222
for (i = 0; i < split[LEXICON.l]; i++)
5223
appendix += '|' + split[i] + '$';
5230
'(^' + _classNameHostElement + '([-_].+|)$)' +
5231
appendClasses(_classNameCache, withCurrClassNameOption) +
5232
appendClasses(_oldClassName, withOldClassNameOption), 'g');
5239
function getHostElementInvertedScale() {
5240
var rect = _paddingElementNative[LEXICON.bCR]();
5242
x: _supportTransform ? 1 / (MATH.round(rect.width) / _paddingElementNative[LEXICON.oW]) || 1 : 1,
5243
y: _supportTransform ? 1 / (MATH.round(rect.height) / _paddingElementNative[LEXICON.oH]) || 1 : 1
5252
function isHTMLElement(o) {
5253
var strOwnerDocument = 'ownerDocument';
5254
var strHTMLElement = 'HTMLElement';
5255
var wnd = o && o[strOwnerDocument] ? (o[strOwnerDocument].parentWindow || window) : window;
5257
typeof wnd[strHTMLElement] == TYPES.o ? o instanceof wnd[strHTMLElement] :
5258
o && typeof o == TYPES.o && o !== null && o.nodeType === 1 && typeof o.nodeName == TYPES.s
5268
function getArrayDifferences(a1, a2) {
5273
for (i = 0; i < a1.length; i++)
5275
for (i = 0; i < a2.length; i++) {
5291
function parseToZeroOrNumber(value, toFloat) {
5292
var num = toFloat ? parseFloat(value) : parseInt(value, 10);
5293
return isNaN(num) ? 0 : num;
5300
function getTextareaInfo() {
5302
var textareaCursorPosition = _targetElementNative.selectionStart;
5303
if (textareaCursorPosition === undefined)
5306
var textareaValue = _targetElement.val();
5307
var textareaLength = textareaValue[LEXICON.l];
5308
var textareaRowSplit = textareaValue.split('\n');
5309
var textareaLastRow = textareaRowSplit[LEXICON.l];
5310
var textareaCurrentCursorRowSplit = textareaValue.substr(0, textareaCursorPosition).split('\n');
5312
var textareaLastCol = 0;
5313
var cursorRow = textareaCurrentCursorRowSplit[LEXICON.l];
5314
var cursorCol = textareaCurrentCursorRowSplit[textareaCurrentCursorRowSplit[LEXICON.l] - 1][LEXICON.l];
5319
for (i = 0; i < textareaRowSplit[LEXICON.l]; i++) {
5320
rowCols = textareaRowSplit[i][LEXICON.l];
5321
if (rowCols > textareaLastCol) {
5323
textareaLastCol = rowCols;
5328
_cursorRow: cursorRow,
5329
_cursorColumn: cursorCol,
5330
_rows: textareaLastRow,
5331
_columns: textareaLastCol,
5332
_widestRow: widestRow,
5333
_cursorPosition: textareaCursorPosition,
5334
_cursorMax: textareaLength
5342
function nativeOverlayScrollbarsAreActive() {
5343
return (_ignoreOverlayScrollbarHidingCache && (_nativeScrollbarIsOverlaid.x && _nativeScrollbarIsOverlaid.y));
5350
function getContentMeasureElement() {
5351
return _isTextarea ? _textareaCoverElement[0] : _contentElementNative;
5360
function generateDiv(classesOrAttrs, content) {
5361
return '<div ' + (classesOrAttrs ? type(classesOrAttrs) == TYPES.s ?
5362
'class="' + classesOrAttrs + '"' :
5365
var attrs = _strEmpty;
5366
if (FRAMEWORK.isPlainObject(classesOrAttrs)) {
5367
for (key in classesOrAttrs)
5368
attrs += (key === 'c' ? 'class' : key) + '="' + classesOrAttrs[key] + '" ';
5374
(content || _strEmpty) +
5385
function selectOrGenerateDivByClass(className, selectParentOrOnlyChildren) {
5386
var onlyChildren = type(selectParentOrOnlyChildren) == TYPES.b;
5387
var selectParent = onlyChildren ? _hostElement : (selectParentOrOnlyChildren || _hostElement);
5389
return (_domExists && !selectParent[LEXICON.l])
5392
? selectParent[onlyChildren ? 'children' : 'find'](_strDot + className.replace(/\s/g, _strDot)).eq(0)
5393
: FRAMEWORK(generateDiv(className))
5402
function getObjectPropVal(obj, path) {
5403
var splits = path.split(_strDot);
5406
for (; i < splits.length; i++) {
5407
if (!obj[LEXICON.hOP](splits[i]))
5409
val = obj[splits[i]];
5410
if (i < splits.length && type(val) == TYPES.o)
5422
function setObjectPropVal(obj, path, val) {
5423
var splits = path.split(_strDot);
5424
var splitsLength = splits.length;
5427
var extendObjRoot = extendObj;
5428
for (; i < splitsLength; i++)
5429
extendObj = extendObj[splits[i]] = i + 1 < splitsLength ? {} : val;
5430
FRAMEWORK.extend(obj, extendObjRoot, true);
5437
function eachUpdateOnLoad(action) {
5438
var updateOnLoad = _currentPreparedOptions.updateOnLoad;
5439
updateOnLoad = type(updateOnLoad) == TYPES.s ? updateOnLoad.split(_strSpace) : updateOnLoad;
5441
if (COMPATIBILITY.isA(updateOnLoad) && !_destroyed) {
5442
each(updateOnLoad, action);
5456
function checkCache(current, cache, force) {
5459
if (type(current) == TYPES.o && type(cache) == TYPES.o) {
5460
for (var prop in current) {
5462
if (current[LEXICON.hOP](prop) && cache[LEXICON.hOP](prop)) {
5463
if (checkCache(current[prop], cache[prop]))
5473
return current !== cache;
5484
function extendDeep() {
5485
return FRAMEWORK.extend.apply(this, [true].concat([].slice.call(arguments)));
5491
function addClass(el, classes) {
5492
return _frameworkProto.addClass.call(el, classes);
5498
function removeClass(el, classes) {
5499
return _frameworkProto.removeClass.call(el, classes);
5505
function addRemoveClass(el, classes, doAdd) {
5506
return doAdd ? addClass(el, classes) : removeClass(el, classes);
5512
function remove(el) {
5513
return _frameworkProto.remove.call(el);
5522
function findFirst(el, selector) {
5523
return _frameworkProto.find.call(el, selector).eq(0);
5533
_base.sleep = function () {
5550
_base.update = function (force) {
5556
var isString = type(force) == TYPES.s;
5562
if (force === _strAuto) {
5563
attrsChanged = meaningfulAttrsChanged();
5564
contentSizeC = updateAutoContentSizeChanged();
5565
doUpdateAuto = attrsChanged || contentSizeC;
5568
_contentSizeChanged: contentSizeC,
5569
_changedOptions: _initialized ? undefined : _currentPreparedOptions
5573
else if (force === _strSync) {
5574
if (_mutationObserversConnected) {
5575
mutHost = _mutationObserverHostCallback(_mutationObserverHost.takeRecords());
5576
mutContent = _mutationObserverContentCallback(_mutationObserverContent.takeRecords());
5579
mutHost = _base.update(_strAuto);
5582
else if (force === 'zoom') {
5584
_hostSizeChanged: true,
5585
_contentSizeChanged: true
5590
force = _sleeping || force;
5592
if (!_base.update(_strSync) || force)
5593
update({ _force: force });
5596
updateElementsOnLoad();
5598
return doUpdateAuto || mutHost || mutContent;
5607
_base.options = function (newOptions, value) {
5612
if (FRAMEWORK.isEmptyObject(newOptions) || !FRAMEWORK.isPlainObject(newOptions)) {
5613
if (type(newOptions) == TYPES.s) {
5614
if (arguments.length > 1) {
5615
setObjectPropVal(option, newOptions, value);
5616
changedOps = setOptions(option);
5619
return getObjectPropVal(_currentOptions, newOptions);
5622
return _currentOptions;
5625
changedOps = setOptions(newOptions);
5628
if (!FRAMEWORK.isEmptyObject(changedOps)) {
5629
update({ _changedOptions: changedOps });
5636
_base.destroy = function () {
5641
autoUpdateLoop.remove(_base);
5644
disconnectMutationObservers();
5647
setupResizeObserver(_sizeObserverElement);
5648
setupResizeObserver(_sizeAutoObserverElement);
5651
for (var extName in _extensions)
5652
_base.removeExt(extName);
5655
while (_destroyEvents[LEXICON.l] > 0)
5656
_destroyEvents.pop()();
5659
setupHostMouseTouchEvents(true);
5662
if (_contentGlueElement)
5663
remove(_contentGlueElement);
5664
if (_contentArrangeElement)
5665
remove(_contentArrangeElement);
5666
if (_sizeAutoObserverAdded)
5667
remove(_sizeAutoObserverElement);
5670
setupScrollbarsDOM(true);
5671
setupScrollbarCornerDOM(true);
5672
setupStructureDOM(true);
5675
for (var i = 0; i < _updateOnLoadElms[LEXICON.l]; i++)
5676
FRAMEWORK(_updateOnLoadElms[i]).off(_updateOnLoadEventName, updateOnLoadCallback);
5677
_updateOnLoadElms = undefined;
5683
INSTANCES(pluginTargetElement, 0);
5684
dispatchCallback('onDestroyed');
5761
_base.scroll = function (coordinates, duration, easing, complete) {
5762
if (arguments.length === 0 || coordinates === undefined) {
5763
var infoX = _scrollHorizontalInfo;
5764
var infoY = _scrollVerticalInfo;
5765
var normalizeInvert = _normalizeRTLCache && _isRTL && _rtlScrollBehavior.i;
5766
var normalizeNegate = _normalizeRTLCache && _isRTL && _rtlScrollBehavior.n;
5767
var scrollX = infoX._currentScroll;
5768
var scrollXRatio = infoX._currentScrollRatio;
5769
var maxScrollX = infoX._maxScroll;
5770
scrollXRatio = normalizeInvert ? 1 - scrollXRatio : scrollXRatio;
5771
scrollX = normalizeInvert ? maxScrollX - scrollX : scrollX;
5772
scrollX *= normalizeNegate ? -1 : 1;
5773
maxScrollX *= normalizeNegate ? -1 : 1;
5778
y: infoY._currentScroll
5782
y: infoY._currentScrollRatio
5789
x: infoX._handleOffset,
5790
y: infoY._handleOffset
5793
x: infoX._handleLength,
5794
y: infoY._handleLength
5796
handleLengthRatio: {
5797
x: infoX._handleLengthRatio,
5798
y: infoY._handleLengthRatio
5801
x: infoX._trackLength,
5802
y: infoY._trackLength
5804
snappedHandleOffset: {
5805
x: infoX._snappedHandleOffset,
5806
y: infoY._snappedHandleOffset
5809
isRTLNormalized: _normalizeRTLCache
5813
_base.update(_strSync);
5815
var normalizeRTL = _normalizeRTLCache;
5816
var coordinatesXAxisProps = [_strX, _strLeft, 'l'];
5817
var coordinatesYAxisProps = [_strY, _strTop, 't'];
5818
var coordinatesOperators = ['+=', '-=', '*=', '/='];
5819
var durationIsObject = type(duration) == TYPES.o;
5820
var completeCallback = durationIsObject ? duration.complete : complete;
5822
var finalScroll = {};
5823
var specialEasing = {};
5826
var animationOptions;
5828
var strBegin = 'begin';
5829
var strCenter = 'center';
5830
var strNearest = 'nearest';
5831
var strAlways = 'always';
5832
var strNever = 'never';
5833
var strIfNeeded = 'ifneeded';
5834
var strLength = LEXICON.l;
5840
var elementObjSettingsAxisValues = [_strX, _strY, 'xy', 'yx'];
5841
var elementObjSettingsBlockValues = [strBegin, strEnd, strCenter, strNearest];
5842
var elementObjSettingsScrollValues = [strAlways, strNever, strIfNeeded];
5843
var coordinatesIsElementObj = coordinates[LEXICON.hOP]('el');
5844
var possibleElement = coordinatesIsElementObj ? coordinates.el : coordinates;
5845
var possibleElementIsJQuery = possibleElement instanceof FRAMEWORK || JQUERY ? possibleElement instanceof JQUERY : false;
5846
var possibleElementIsHTMLElement = possibleElementIsJQuery ? false : isHTMLElement(possibleElement);
5847
var updateScrollbarInfos = function () {
5849
refreshScrollbarHandleOffset(true);
5851
refreshScrollbarHandleOffset(false);
5853
var proxyCompleteCallback = type(completeCallback) != TYPES.f ? undefined : function () {
5854
updateScrollbarInfos();
5857
function checkSettingsStringValue(currValue, allowedValues) {
5858
for (i = 0; i < allowedValues[strLength]; i++) {
5859
if (currValue === allowedValues[i])
5864
function getRawScroll(isX, coordinates) {
5865
var coordinateProps = isX ? coordinatesXAxisProps : coordinatesYAxisProps;
5866
coordinates = type(coordinates) == TYPES.s || type(coordinates) == TYPES.n ? [coordinates, coordinates] : coordinates;
5868
if (COMPATIBILITY.isA(coordinates))
5869
return isX ? coordinates[0] : coordinates[1];
5870
else if (type(coordinates) == TYPES.o) {
5873
for (i = 0; i < coordinateProps[strLength]; i++)
5874
if (coordinateProps[i] in coordinates)
5875
return coordinates[coordinateProps[i]];
5878
function getFinalScroll(isX, rawScroll) {
5879
var isString = type(rawScroll) == TYPES.s;
5882
var scrollInfo = isX ? _scrollHorizontalInfo : _scrollVerticalInfo;
5883
var currScroll = scrollInfo._currentScroll;
5884
var maxScroll = scrollInfo._maxScroll;
5887
var isRTLisX = _isRTL && isX;
5888
var normalizeShortcuts = isRTLisX && _rtlScrollBehavior.n && !normalizeRTL;
5889
var strReplace = 'replace';
5890
var evalFunc = eval;
5891
var possibleOperator;
5894
if (rawScroll[strLength] > 2) {
5895
possibleOperator = rawScroll.substr(0, 2);
5896
if (inArray(possibleOperator, coordinatesOperators) > -1)
5897
operator = possibleOperator;
5901
rawScroll = operator ? rawScroll.substr(2) : rawScroll;
5902
rawScroll = rawScroll
5903
[strReplace](/min/g, 0)
5904
[strReplace](/</g, 0)
5905
[strReplace](/max/g, (normalizeShortcuts ? '-' : _strEmpty) + _strHundredPercent)
5906
[strReplace](/>/g, (normalizeShortcuts ? '-' : _strEmpty) + _strHundredPercent)
5907
[strReplace](/px/g, _strEmpty)
5908
[strReplace](/%/g, mult + (maxScroll * (isRTLisX && _rtlScrollBehavior.n ? -1 : 1) / 100.0))
5909
[strReplace](/vw/g, mult + _viewportSize.w)
5910
[strReplace](/vh/g, mult + _viewportSize.h);
5911
amount = parseToZeroOrNumber(isNaN(rawScroll) ? parseToZeroOrNumber(evalFunc(rawScroll), true).toFixed() : rawScroll);
5917
if (amount !== undefined && !isNaN(amount) && type(amount) == TYPES.n) {
5918
var normalizeIsRTLisX = normalizeRTL && isRTLisX;
5919
var operatorCurrScroll = currScroll * (normalizeIsRTLisX && _rtlScrollBehavior.n ? -1 : 1);
5920
var invert = normalizeIsRTLisX && _rtlScrollBehavior.i;
5921
var negate = normalizeIsRTLisX && _rtlScrollBehavior.n;
5922
operatorCurrScroll = invert ? (maxScroll - operatorCurrScroll) : operatorCurrScroll;
5925
finalValue = operatorCurrScroll + amount;
5928
finalValue = operatorCurrScroll - amount;
5931
finalValue = operatorCurrScroll * amount;
5934
finalValue = operatorCurrScroll / amount;
5937
finalValue = amount;
5940
finalValue = invert ? maxScroll - finalValue : finalValue;
5941
finalValue *= negate ? -1 : 1;
5942
finalValue = isRTLisX && _rtlScrollBehavior.n ? MATH.min(0, MATH.max(maxScroll, finalValue)) : MATH.max(0, MATH.min(maxScroll, finalValue));
5944
return finalValue === currScroll ? undefined : finalValue;
5946
function getPerAxisValue(value, valueInternalType, defaultValue, allowedValues) {
5947
var resultDefault = [defaultValue, defaultValue];
5948
var valueType = type(value);
5953
if (valueType == valueInternalType) {
5954
value = [value, value];
5956
else if (valueType == TYPES.a) {
5957
valueArrLength = value[strLength];
5958
if (valueArrLength > 2 || valueArrLength < 1)
5959
value = resultDefault;
5961
if (valueArrLength === 1)
5962
value[1] = defaultValue;
5963
for (i = 0; i < valueArrLength; i++) {
5964
valueArrItem = value[i];
5965
if (type(valueArrItem) != valueInternalType || !checkSettingsStringValue(valueArrItem, allowedValues)) {
5966
value = resultDefault;
5972
else if (valueType == TYPES.o)
5973
value = [value[_strX] || defaultValue, value[_strY] || defaultValue];
5975
value = resultDefault;
5976
return { x: value[0], y: value[1] };
5978
function generateMargin(marginTopRightBottomLeftArray) {
5982
var valueDirections = [_strTop, _strRight, _strBottom, _strLeft];
5983
for (i = 0; i < marginTopRightBottomLeftArray[strLength]; i++) {
5984
if (i === valueDirections[strLength])
5986
currValue = marginTopRightBottomLeftArray[i];
5987
currValueType = type(currValue);
5988
if (currValueType == TYPES.b)
5989
result.push(currValue ? parseToZeroOrNumber(finalElement.css(_strMarginMinus + valueDirections[i])) : 0);
5991
result.push(currValueType == TYPES.n ? currValue : 0);
5996
if (possibleElementIsJQuery || possibleElementIsHTMLElement) {
5998
var margin = coordinatesIsElementObj ? coordinates.margin : 0;
5999
var axis = coordinatesIsElementObj ? coordinates.axis : 0;
6000
var scroll = coordinatesIsElementObj ? coordinates.scroll : 0;
6001
var block = coordinatesIsElementObj ? coordinates.block : 0;
6002
var marginDefault = [0, 0, 0, 0];
6003
var marginType = type(margin);
6005
finalElement = possibleElementIsJQuery ? possibleElement : FRAMEWORK(possibleElement);
6007
if (finalElement[strLength] > 0) {
6009
if (marginType == TYPES.n || marginType == TYPES.b)
6010
margin = generateMargin([margin, margin, margin, margin]);
6011
else if (marginType == TYPES.a) {
6012
marginLength = margin[strLength];
6013
if (marginLength === 2)
6014
margin = generateMargin([margin[0], margin[1], margin[0], margin[1]]);
6015
else if (marginLength >= 4)
6016
margin = generateMargin(margin);
6018
margin = marginDefault;
6020
else if (marginType == TYPES.o)
6021
margin = generateMargin([margin[_strTop], margin[_strRight], margin[_strBottom], margin[_strLeft]]);
6023
margin = marginDefault;
6026
settingsAxis = checkSettingsStringValue(axis, elementObjSettingsAxisValues) ? axis : 'xy';
6027
settingsScroll = getPerAxisValue(scroll, TYPES.s, strAlways, elementObjSettingsScrollValues);
6028
settingsBlock = getPerAxisValue(block, TYPES.s, strBegin, elementObjSettingsBlockValues);
6029
settingsMargin = margin;
6031
var viewportScroll = {
6032
l: _scrollHorizontalInfo._currentScroll,
6033
t: _scrollVerticalInfo._currentScroll
6036
var viewportOffset = _paddingElement.offset();
6039
var elementOffset = finalElement.offset();
6041
x: settingsScroll.x == strNever || settingsAxis == _strY,
6042
y: settingsScroll.y == strNever || settingsAxis == _strX
6044
elementOffset[_strTop] -= settingsMargin[0];
6045
elementOffset[_strLeft] -= settingsMargin[3];
6046
var elementScrollCoordinates = {
6047
x: MATH.round(elementOffset[_strLeft] - viewportOffset[_strLeft] + viewportScroll.l),
6048
y: MATH.round(elementOffset[_strTop] - viewportOffset[_strTop] + viewportScroll.t)
6051
if (!_rtlScrollBehavior.n && !_rtlScrollBehavior.i)
6052
elementScrollCoordinates.x = MATH.round(viewportOffset[_strLeft] - elementOffset[_strLeft] + viewportScroll.l);
6053
if (_rtlScrollBehavior.n && normalizeRTL)
6054
elementScrollCoordinates.x *= -1;
6055
if (_rtlScrollBehavior.i && normalizeRTL)
6056
elementScrollCoordinates.x = MATH.round(viewportOffset[_strLeft] - elementOffset[_strLeft] + (_scrollHorizontalInfo._maxScroll - viewportScroll.l));
6060
if (settingsBlock.x != strBegin || settingsBlock.y != strBegin || settingsScroll.x == strIfNeeded || settingsScroll.y == strIfNeeded || _isRTL) {
6061
var measuringElm = finalElement[0];
6062
var rawElementSize = _supportTransform ? measuringElm[LEXICON.bCR]() : {
6063
width: measuringElm[LEXICON.oW],
6064
height: measuringElm[LEXICON.oH]
6067
w: rawElementSize[_strWidth] + settingsMargin[3] + settingsMargin[1],
6068
h: rawElementSize[_strHeight] + settingsMargin[0] + settingsMargin[2]
6070
var finalizeBlock = function (isX) {
6071
var vars = getScrollbarVars(isX);
6073
var lt = vars._left_top;
6075
var blockIsEnd = settingsBlock[xy] == (isX ? _isRTL ? strBegin : strEnd : strEnd);
6076
var blockIsCenter = settingsBlock[xy] == strCenter;
6077
var blockIsNearest = settingsBlock[xy] == strNearest;
6078
var scrollNever = settingsScroll[xy] == strNever;
6079
var scrollIfNeeded = settingsScroll[xy] == strIfNeeded;
6080
var vpSize = _viewportSize[wh];
6081
var vpOffset = viewportOffset[lt];
6082
var elSize = elementSize[wh];
6083
var elOffset = elementOffset[lt];
6084
var divide = blockIsCenter ? 2 : 1;
6085
var elementCenterOffset = elOffset + (elSize / 2);
6086
var viewportCenterOffset = vpOffset + (vpSize / 2);
6089
&& elOffset >= vpOffset
6090
&& elOffset + elSize <= vpOffset + vpSize;
6093
doNotScroll[xy] = true;
6094
else if (!doNotScroll[xy]) {
6095
if (blockIsNearest || scrollIfNeeded) {
6096
doNotScroll[xy] = scrollIfNeeded ? isInView : false;
6097
blockIsEnd = elSize < vpSize ? elementCenterOffset > viewportCenterOffset : elementCenterOffset < viewportCenterOffset;
6099
elementScrollCoordinates[xy] -= blockIsEnd || blockIsCenter ? ((vpSize / divide) - (elSize / divide)) * (isX && _isRTL && normalizeRTL ? -1 : 1) : 0;
6102
finalizeBlock(true);
6103
finalizeBlock(false);
6107
delete elementScrollCoordinates.y;
6109
delete elementScrollCoordinates.x;
6111
coordinates = elementScrollCoordinates;
6115
finalScroll[_strScrollLeft] = getFinalScroll(true, getRawScroll(true, coordinates));
6116
finalScroll[_strScrollTop] = getFinalScroll(false, getRawScroll(false, coordinates));
6117
doScrollLeft = finalScroll[_strScrollLeft] !== undefined;
6118
doScrollTop = finalScroll[_strScrollTop] !== undefined;
6120
if ((doScrollLeft || doScrollTop) && (duration > 0 || durationIsObject)) {
6121
if (durationIsObject) {
6122
duration.complete = proxyCompleteCallback;
6123
_viewportElement.animate(finalScroll, duration);
6126
animationOptions = {
6128
complete: proxyCompleteCallback
6130
if (COMPATIBILITY.isA(easing) || FRAMEWORK.isPlainObject(easing)) {
6131
specialEasing[_strScrollLeft] = easing[0] || easing.x;
6132
specialEasing[_strScrollTop] = easing[1] || easing.y;
6133
animationOptions.specialEasing = specialEasing;
6136
animationOptions.easing = easing;
6138
_viewportElement.animate(finalScroll, animationOptions);
6143
_viewportElement[_strScrollLeft](finalScroll[_strScrollLeft]);
6145
_viewportElement[_strScrollTop](finalScroll[_strScrollTop]);
6146
updateScrollbarInfos();
6154
_base.scrollStop = function (param1, param2, param3) {
6155
_viewportElement.stop(param1, param2, param3);
6164
_base.getElements = function (elementName) {
6166
target: _targetElementNative,
6167
host: _hostElementNative,
6168
padding: _paddingElementNative,
6169
viewport: _viewportElementNative,
6170
content: _contentElementNative,
6171
scrollbarHorizontal: {
6172
scrollbar: _scrollbarHorizontalElement[0],
6173
track: _scrollbarHorizontalTrackElement[0],
6174
handle: _scrollbarHorizontalHandleElement[0]
6176
scrollbarVertical: {
6177
scrollbar: _scrollbarVerticalElement[0],
6178
track: _scrollbarVerticalTrackElement[0],
6179
handle: _scrollbarVerticalHandleElement[0]
6181
scrollbarCorner: _scrollbarCornerElement[0]
6183
return type(elementName) == TYPES.s ? getObjectPropVal(obj, elementName) : obj;
6191
_base.getState = function (stateProperty) {
6192
function prepare(obj) {
6193
if (!FRAMEWORK.isPlainObject(obj))
6195
var extended = extendDeep({}, obj);
6196
var changePropertyName = function (from, to) {
6197
if (extended[LEXICON.hOP](from)) {
6198
extended[to] = extended[from];
6199
delete extended[from];
6202
changePropertyName('w', _strWidth);
6203
changePropertyName('h', _strHeight);
6208
destroyed: !!prepare(_destroyed),
6209
sleeping: !!prepare(_sleeping),
6210
autoUpdate: prepare(!_mutationObserversConnected),
6211
widthAuto: prepare(_widthAutoCache),
6212
heightAuto: prepare(_heightAutoCache),
6213
padding: prepare(_cssPaddingCache),
6214
overflowAmount: prepare(_overflowAmountCache),
6215
hideOverflow: prepare(_hideOverflowCache),
6216
hasOverflow: prepare(_hasOverflowCache),
6217
contentScrollSize: prepare(_contentScrollSizeCache),
6218
viewportSize: prepare(_viewportSize),
6219
hostSize: prepare(_hostSizeCache),
6220
documentMixed: prepare(_documentMixed)
6222
return type(stateProperty) == TYPES.s ? getObjectPropVal(obj, stateProperty) : obj;
6230
_base.ext = function (extName) {
6232
var privateMethods = _extensionsPrivateMethods.split(' ');
6234
if (type(extName) == TYPES.s) {
6235
if (_extensions[LEXICON.hOP](extName)) {
6236
result = extendDeep({}, _extensions[extName]);
6237
for (; i < privateMethods.length; i++)
6238
delete result[privateMethods[i]];
6243
for (i in _extensions)
6244
result[i] = extendDeep({}, _base.ext(i));
6255
_base.addExt = function (extName, extensionOptions) {
6256
var registeredExtensionObj = _plugin.extension(extName);
6259
var instanceContract;
6261
var contractFulfilled = true;
6262
if (registeredExtensionObj) {
6263
if (!_extensions[LEXICON.hOP](extName)) {
6264
instance = registeredExtensionObj.extensionFactory.call(_base,
6265
extendDeep({}, registeredExtensionObj.defaultOptions),
6270
instanceContract = instance.contract;
6271
if (type(instanceContract) == TYPES.f) {
6272
contractResult = instanceContract(window);
6273
contractFulfilled = type(contractResult) == TYPES.b ? contractResult : contractFulfilled;
6275
if (contractFulfilled) {
6276
_extensions[extName] = instance;
6277
instanceAdded = instance.added;
6278
if (type(instanceAdded) == TYPES.f)
6279
instanceAdded(extensionOptions);
6281
return _base.ext(extName);
6286
return _base.ext(extName);
6289
console.warn("A extension with the name \"" + extName + "\" isn't registered.");
6297
_base.removeExt = function (extName) {
6298
var instance = _extensions[extName];
6299
var instanceRemoved;
6301
delete _extensions[extName];
6303
instanceRemoved = instance.removed;
6304
if (type(instanceRemoved) == TYPES.f)
6319
function construct(targetElement, options, extensions) {
6320
_defaultOptions = globals.defaultOptions;
6321
_nativeScrollbarStyling = globals.nativeScrollbarStyling;
6322
_nativeScrollbarSize = extendDeep({}, globals.nativeScrollbarSize);
6323
_nativeScrollbarIsOverlaid = extendDeep({}, globals.nativeScrollbarIsOverlaid);
6324
_overlayScrollbarDummySize = extendDeep({}, globals.overlayScrollbarDummySize);
6325
_rtlScrollBehavior = extendDeep({}, globals.rtlScrollBehavior);
6328
setOptions(extendDeep({}, _defaultOptions, options));
6330
_cssCalc = globals.cssCalc;
6331
_msieVersion = globals.msie;
6332
_autoUpdateRecommended = globals.autoUpdateRecommended;
6333
_supportTransition = globals.supportTransition;
6334
_supportTransform = globals.supportTransform;
6335
_supportPassiveEvents = globals.supportPassiveEvents;
6336
_supportResizeObserver = globals.supportResizeObserver;
6337
_supportMutationObserver = globals.supportMutationObserver;
6338
_restrictedMeasuring = globals.restrictedMeasuring;
6339
_documentElement = FRAMEWORK(targetElement.ownerDocument);
6340
_documentElementNative = _documentElement[0];
6341
_windowElement = FRAMEWORK(_documentElementNative.defaultView || _documentElementNative.parentWindow);
6342
_windowElementNative = _windowElement[0];
6343
_htmlElement = findFirst(_documentElement, 'html');
6344
_bodyElement = findFirst(_htmlElement, 'body');
6345
_targetElement = FRAMEWORK(targetElement);
6346
_targetElementNative = _targetElement[0];
6347
_isTextarea = _targetElement.is('textarea');
6348
_isBody = _targetElement.is('body');
6349
_documentMixed = _documentElementNative !== document;
6410
_domExists = _isTextarea
6411
? _targetElement.hasClass(_classNameTextareaElement) && _targetElement.parent().hasClass(_classNameContentElement)
6412
: _targetElement.hasClass(_classNameHostElement) && _targetElement.children(_strDot + _classNamePaddingElement)[LEXICON.l];
6415
var bodyMouseTouchDownListener;
6418
if (_nativeScrollbarIsOverlaid.x && _nativeScrollbarIsOverlaid.y && !_currentPreparedOptions.nativeScrollbarsOverlaid.initialize) {
6419
dispatchCallback('onInitializationWithdrawn');
6421
setupStructureDOM(true);
6422
setupScrollbarsDOM(true);
6423
setupScrollbarCornerDOM(true);
6433
initBodyScroll = {};
6434
initBodyScroll.l = MATH.max(_targetElement[_strScrollLeft](), _htmlElement[_strScrollLeft](), _windowElement[_strScrollLeft]());
6435
initBodyScroll.t = MATH.max(_targetElement[_strScrollTop](), _htmlElement[_strScrollTop](), _windowElement[_strScrollTop]());
6437
bodyMouseTouchDownListener = function () {
6438
_viewportElement.removeAttr(LEXICON.ti);
6439
setupResponsiveEventListener(_viewportElement, _strMouseTouchDownEvent, bodyMouseTouchDownListener, true, true);
6444
setupStructureDOM();
6445
setupScrollbarsDOM();
6446
setupScrollbarCornerDOM();
6449
setupStructureEvents();
6450
setupScrollbarEvents(true);
6451
setupScrollbarEvents(false);
6452
setupScrollbarCornerEvents();
6455
createMutationObservers();
6458
setupResizeObserver(_sizeObserverElement, hostOnResized);
6462
_viewportElement[_strScrollLeft](initBodyScroll.l)[_strScrollTop](initBodyScroll.t);
6465
if (document.activeElement == targetElement && _viewportElementNative.focus) {
6467
_viewportElement.attr(LEXICON.ti, '-1');
6468
_viewportElementNative.focus();
6474
setupResponsiveEventListener(_viewportElement, _strMouseTouchDownEvent, bodyMouseTouchDownListener, false, true);
6479
_base.update(_strAuto);
6482
_initialized = true;
6483
dispatchCallback('onInitialized');
6486
each(_callbacksInitQeueue, function (index, value) { dispatchCallback(value.n, value.a); });
6487
_callbacksInitQeueue = [];
6490
if (type(extensions) == TYPES.s)
6491
extensions = [extensions];
6492
if (COMPATIBILITY.isA(extensions))
6493
each(extensions, function (index, value) { _base.addExt(value); });
6494
else if (FRAMEWORK.isPlainObject(extensions))
6495
each(extensions, function (key, value) { _base.addExt(key, value); });
6498
setTimeout(function () {
6499
if (_supportTransition && !_destroyed)
6500
addClass(_hostElement, _classNameHostTransition);
6506
if (_plugin.valid(construct(pluginTargetElement, options, extensions))) {
6507
INSTANCES(pluginTargetElement, _base);
6520
_plugin = window[PLUGINNAME] = function (pluginTargetElements, options, extensions) {
6521
if (arguments[LEXICON.l] === 0)
6525
var optsIsPlainObj = FRAMEWORK.isPlainObject(options);
6530
if (!pluginTargetElements)
6531
return optsIsPlainObj || !options ? result : arr;
6540
pluginTargetElements = pluginTargetElements[LEXICON.l] != undefined ? pluginTargetElements : [pluginTargetElements[0] || pluginTargetElements];
6541
initOverlayScrollbarsStatics();
6543
if (pluginTargetElements[LEXICON.l] > 0) {
6544
if (optsIsPlainObj) {
6545
FRAMEWORK.each(pluginTargetElements, function (i, v) {
6547
if (inst !== undefined)
6548
arr.push(OverlayScrollbarsInstance(inst, options, extensions, _pluginsGlobals, _pluginsAutoUpdateLoop));
6552
FRAMEWORK.each(pluginTargetElements, function (i, v) {
6553
inst = INSTANCES(v);
6554
if ((options === '!' && _plugin.valid(inst)) || (COMPATIBILITY.type(options) == TYPES.f && options(v, inst)))
6556
else if (options === undefined)
6560
result = arr[LEXICON.l] === 1 ? arr[0] : arr;
6569
_plugin.globals = function () {
6570
initOverlayScrollbarsStatics();
6571
var globals = FRAMEWORK.extend(true, {}, _pluginsGlobals);
6572
delete globals['msie'];
6580
_plugin.defaultOptions = function (newDefaultOptions) {
6581
initOverlayScrollbarsStatics();
6582
var currDefaultOptions = _pluginsGlobals.defaultOptions;
6583
if (newDefaultOptions === undefined)
6584
return FRAMEWORK.extend(true, {}, currDefaultOptions);
6587
_pluginsGlobals.defaultOptions = FRAMEWORK.extend(true, {}, currDefaultOptions, _pluginsOptions._validate(newDefaultOptions, _pluginsOptions._template, true, currDefaultOptions)._default);
6595
_plugin.valid = function (osInstance) {
6596
return osInstance instanceof _plugin && !osInstance.getState().destroyed;
6609
_plugin.extension = function (extensionName, extension, defaultOptions) {
6610
var extNameTypeString = COMPATIBILITY.type(extensionName) == TYPES.s;
6611
var argLen = arguments[LEXICON.l];
6613
if (argLen < 1 || !extNameTypeString) {
6615
return FRAMEWORK.extend(true, { length: _pluginsExtensions[LEXICON.l] }, _pluginsExtensions);
6617
else if (extNameTypeString) {
6618
if (COMPATIBILITY.type(extension) == TYPES.f) {
6620
_pluginsExtensions.push({
6621
name: extensionName,
6622
extensionFactory: extension,
6623
defaultOptions: defaultOptions
6627
for (; i < _pluginsExtensions[LEXICON.l]; i++) {
6628
if (_pluginsExtensions[i].name === extensionName) {
6630
_pluginsExtensions.splice(i, 1);
6632
return FRAMEWORK.extend(true, {}, _pluginsExtensions[i]);
6642
if (JQUERY && JQUERY.fn) {
6649
JQUERY.fn.overlayScrollbars = function (options, extensions) {
6650
var _elements = this;
6651
if (JQUERY.isPlainObject(options)) {
6652
JQUERY.each(_elements, function () { PLUGIN(this, options, extensions); });
6656
return PLUGIN(_elements, options);