PageSourceSearch

https://english-club.tv/wp-content/themes/New__ECTV/js/jssor.js

js english-club.tv collected 2026-10-01 15:19:34 UTC 88,450 bytes, 2,775 lines download raw bytes

1/*
2* Jssor 19.0
3* http://www.jssor.com/
4*
5* Licensed under the MIT license:
6* http://www.opensource.org/licenses/MIT
7* 
8* TERMS OF USE - Jssor
9* 
10* Copyright 2014 Jssor
11*
12* Permission is hereby granted, free of charge, to any person obtaining
13* a copy of this software and associated documentation files (the
14* "Software"), to deal in the Software without restriction, including
15* without limitation the rights to use, copy, modify, merge, publish,
16* distribute, sublicense, and/or sell copies of the Software, and to
17* permit persons to whom the Software is furnished to do so, subject to
18* the following conditions:
19* 
20* The above copyright notice and this permission notice shall be
21* included in all copies or substantial portions of the Software.
22* 
23* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30*/
31
32/*! Jssor */
33
34//$JssorDebug$
35var $JssorDebug$ = new function () {
36
37    this.$DebugMode = true;
38
39    // Methods
40
41    this.$Log = function (msg, important) {
42        var console = window.console || {};
43        var debug = this.$DebugMode;
44
45        if (debug && console.log) {
46            console.log(msg);
47        } else if (debug && important) {
48            alert(msg);
49        }
50    };
51
52    this.$Error = function (msg, e) {
53        var console = window.console || {};
54        var debug = this.$DebugMode;
55
56        if (debug && console.error) {
57            console.error(msg);
58        } else if (debug) {
59            alert(msg);
60        }
61
62        if (debug) {
63            // since we're debugging, fail fast by crashing
64            throw e || new Error(msg);
65        }
66    };
67
68    this.$Fail = function (msg) {
69        throw new Error(msg);
70    };
71
72    this.$Assert = function (value, msg) {
73        var debug = this.$DebugMode;
74        if (debug) {
75            if (!value)
76                throw new Error("Assert failed " + msg || "");
77        }
78    };
79
80    this.$Trace = function (msg) {
81        var console = window.console || {};
82        var debug = this.$DebugMode;
83
84        if (debug && console.log) {
85            console.log(msg);
86        }
87    };
88
89    this.$Execute = function (func) {
90        var debug = this.$DebugMode;
91        if (debug)
92            func();
93    };
94
95    this.$LiveStamp = function (obj, id) {
96        var debug = this.$DebugMode;
97        if (debug) {
98            var stamp = document.createElement("DIV");
99            stamp.setAttribute("id", id);
100
101            obj.$Live = stamp;
102        }
103    };
104
105    this.$C_AbstractProperty = function () {
106        ///	<summary>
107        ///		Tells compiler the property is abstract, it should be implemented by subclass.
108        ///	</summary>
109
110        throw new Error("The property is abstract, it should be implemented by subclass.");
111    };
112
113    this.$C_AbstractMethod = function () {
114        ///	<summary>
115        ///		Tells compiler the method is abstract, it should be implemented by subclass.
116        ///	</summary>
117
118        throw new Error("The method is abstract, it should be implemented by subclass.");
119    };
120
121    function C_AbstractClass(instance) {
122        ///	<summary>
123        ///		Tells compiler the class is abstract, it should be implemented by subclass.
124        ///	</summary>
125
126        if (instance.constructor === C_AbstractClass.caller)
127            throw new Error("Cannot create instance of an abstract class.");
128    }
129
130    this.$C_AbstractClass = C_AbstractClass;
131};
132
133//$JssorEasing$
134var $JssorEasing$ = window.$JssorEasing$ = {
135    $EaseSwing: function (t) {
136        return -Math.cos(t * Math.PI) / 2 + .5;
137    },
138    $EaseLinear: function (t) {
139        return t;
140    },
141    $EaseInQuad: function (t) {
142        return t * t;
143    },
144    $EaseOutQuad: function (t) {
145        return -t * (t - 2);
146    },
147    $EaseInOutQuad: function (t) {
148        return (t *= 2) < 1 ? 1 / 2 * t * t : -1 / 2 * (--t * (t - 2) - 1);
149    },
150    $EaseInCubic: function (t) {
151        return t * t * t;
152    },
153    $EaseOutCubic: function (t) {
154        return (t -= 1) * t * t + 1;
155    },
156    $EaseInOutCubic: function (t) {
157        return (t *= 2) < 1 ? 1 / 2 * t * t * t : 1 / 2 * ((t -= 2) * t * t + 2);
158    },
159    $EaseInQuart: function (t) {
160        return t * t * t * t;
161    },
162    $EaseOutQuart: function (t) {
163        return -((t -= 1) * t * t * t - 1);
164    },
165    $EaseInOutQuart: function (t) {
166        return (t *= 2) < 1 ? 1 / 2 * t * t * t * t : -1 / 2 * ((t -= 2) * t * t * t - 2);
167    },
168    $EaseInQuint: function (t) {
169        return t * t * t * t * t;
170    },
171    $EaseOutQuint: function (t) {
172        return (t -= 1) * t * t * t * t + 1;
173    },
174    $EaseInOutQuint: function (t) {
175        return (t *= 2) < 1 ? 1 / 2 * t * t * t * t * t : 1 / 2 * ((t -= 2) * t * t * t * t + 2);
176    },
177    $EaseInSine: function (t) {
178        return 1 - Math.cos(t * Math.PI / 2);
179    },
180    $EaseOutSine: function (t) {
181        return Math.sin(t * Math.PI / 2);
182    },
183    $EaseInOutSine: function (t) {
184        return -1 / 2 * (Math.cos(Math.PI * t) - 1);
185    },
186    $EaseInExpo: function (t) {
187        return t == 0 ? 0 : Math.pow(2, 10 * (t - 1));
188    },
189    $EaseOutExpo: function (t) {
190        return t == 1 ? 1 : -Math.pow(2, -10 * t) + 1;
191    },
192    $EaseInOutExpo: function (t) {
193        return t == 0 || t == 1 ? t : (t *= 2) < 1 ? 1 / 2 * Math.pow(2, 10 * (t - 1)) : 1 / 2 * (-Math.pow(2, -10 * --t) + 2);
194    },
195    $EaseInCirc: function (t) {
196        return -(Math.sqrt(1 - t * t) - 1);
197    },
198    $EaseOutCirc: function (t) {
199        return Math.sqrt(1 - (t -= 1) * t);
200    },
201    $EaseInOutCirc: function (t) {
202        return (t *= 2) < 1 ? -1 / 2 * (Math.sqrt(1 - t * t) - 1) : 1 / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1);
203    },
204    $EaseInElastic: function (t) {
205        if (!t || t == 1)
206            return t;
207        var p = .3, s = .075;
208        return -(Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * 2 * Math.PI / p));
209    },
210    $EaseOutElastic: function (t) {
211        if (!t || t == 1)
212            return t;
213        var p = .3, s = .075;
214        return Math.pow(2, -10 * t) * Math.sin((t - s) * 2 * Math.PI / p) + 1;
215    },
216    $EaseInOutElastic: function (t) {
217        if (!t || t == 1)
218            return t;
219        var p = .45, s = .1125;
220        return (t *= 2) < 1 ? -.5 * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * 2 * Math.PI / p) : Math.pow(2, -10 * (t -= 1)) * Math.sin((t - s) * 2 * Math.PI / p) * .5 + 1;
221    },
222    $EaseInBack: function (t) {
223        var s = 1.70158;
224        return t * t * ((s + 1) * t - s);
225    },
226    $EaseOutBack: function (t) {
227        var s = 1.70158;
228        return (t -= 1) * t * ((s + 1) * t + s) + 1;
229    },
230    $EaseInOutBack: function (t) {
231        var s = 1.70158;
232        return (t *= 2) < 1 ? 1 / 2 * t * t * (((s *= 1.525) + 1) * t - s) : 1 / 2 * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2);
233    },
234    $EaseInBounce: function (t) {
235        return 1 - $JssorEasing$.$EaseOutBounce(1 - t)
236    },
237    $EaseOutBounce: function (t) {
238        return t < 1 / 2.75 ? 7.5625 * t * t : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + .75 : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + .9375 : 7.5625 * (t -= 2.625 / 2.75) * t + .984375;
239    },
240    $EaseInOutBounce: function (t) {
241        return t < 1 / 2 ? $JssorEasing$.$EaseInBounce(t * 2) * .5 : $JssorEasing$.$EaseOutBounce(t * 2 - 1) * .5 + .5;
242    },
243    $EaseGoBack: function (t) {
244        return 1 - Math.abs((t *= 2) - 1);
245    },
246    $EaseInWave: function (t) {
247        return 1 - Math.cos(t * Math.PI * 2)
248    },
249    $EaseOutWave: function (t) {
250        return Math.sin(t * Math.PI * 2);
251    },
252    $EaseOutJump: function (t) {
253        return 1 - (((t *= 2) < 1) ? (t = 1 - t) * t * t : (t -= 1) * t * t);
254    },
255    $EaseInJump: function (t) {
256        return ((t *= 2) < 1) ? t * t * t : (t = 2 - t) * t * t;
257    }
258};
259
260var $JssorDirection$ = window.$JssorDirection$ = {
261    $TO_LEFT: 0x0001,
262    $TO_RIGHT: 0x0002,
263    $TO_TOP: 0x0004,
264    $TO_BOTTOM: 0x0008,
265    $HORIZONTAL: 0x0003,
266    $VERTICAL: 0x000C,
267    //$LEFTRIGHT: 0x0003,
268    //$TOPBOTOM: 0x000C,
269    //$TOPLEFT: 0x0005,
270    //$TOPRIGHT: 0x0006,
271    //$BOTTOMLEFT: 0x0009,
272    //$BOTTOMRIGHT: 0x000A,
273    //$AROUND: 0x000F,
274
275    $GetDirectionHorizontal: function (direction) {
276        return direction & 0x0003;
277    },
278    $GetDirectionVertical: function (direction) {
279        return direction & 0x000C;
280    },
281    //$ChessHorizontal: function (direction) {
282    //    return (~direction & 0x0003) + (direction & 0x000C);
283    //},
284    //$ChessVertical: function (direction) {
285    //    return (~direction & 0x000C) + (direction & 0x0003);
286    //},
287    //$IsToLeft: function (direction) {
288    //    return (direction & 0x0003) == 0x0001;
289    //},
290    //$IsToRight: function (direction) {
291    //    return (direction & 0x0003) == 0x0002;
292    //},
293    //$IsToTop: function (direction) {
294    //    return (direction & 0x000C) == 0x0004;
295    //},
296    //$IsToBottom: function (direction) {
297    //    return (direction & 0x000C) == 0x0008;
298    //},
299    $IsHorizontal: function (direction) {
300        return direction & 0x0003;
301    },
302    $IsVertical: function (direction) {
303        return direction & 0x000C;
304    }
305};
306
307var $JssorKeyCode$ = {
308    $BACKSPACE: 8,
309    $COMMA: 188,
310    $DELETE: 46,
311    $DOWN: 40,
312    $END: 35,
313    $ENTER: 13,
314    $ESCAPE: 27,
315    $HOME: 36,
316    $LEFT: 37,
317    $NUMPAD_ADD: 107,
318    $NUMPAD_DECIMAL: 110,
319    $NUMPAD_DIVIDE: 111,
320    $NUMPAD_ENTER: 108,
321    $NUMPAD_MULTIPLY: 106,
322    $NUMPAD_SUBTRACT: 109,
323    $PAGE_DOWN: 34,
324    $PAGE_UP: 33,
325    $PERIOD: 190,
326    $RIGHT: 39,
327    $SPACE: 32,
328    $TAB: 9,
329    $UP: 38
330};
331
332// $Jssor$ is a static class, so make it singleton instance
333var $Jssor$ = window.$Jssor$ = new function () {
334    var _This = this;
335
336    //#region Constants
337    var REGEX_WHITESPACE_GLOBAL = /\S+/g;
338    var ROWSER_OTHER = -1;
339    var ROWSER_UNKNOWN = 0;
340    var BROWSER_IE = 1;
341    var BROWSER_FIREFOX = 2;
342    var BROWSER_SAFARI = 3;
343    var BROWSER_CHROME = 4;
344    var BROWSER_OPERA = 5;
345    //var arrActiveX = ["Msxml2.XMLHTTP", "Msxml3.XMLHTTP", "Microsoft.XMLHTTP"];
346    //#endregion
347
348    //#region Variables
349    var _Device;
350    var _Browser = 0;
351    var _BrowserRuntimeVersion = 0;
352    var _BrowserEngineVersion = 0;
353    var _BrowserJavascriptVersion = 0;
354    var _WebkitVersion = 0;
355
356    var _Navigator = navigator;
357    var _AppName = _Navigator.appName;
358    var _AppVersion = _Navigator.appVersion;
359    var _UserAgent = _Navigator.userAgent;
360
361    var _DocElmt = document.documentElement;
362    var _TransformProperty;
363    //#endregion
364
365    function Device() {
366        if (!_Device) {
367            _Device = { $Touchable: "ontouchstart" in window || "createTouch" in document };
368
369            var msPrefix;
370            if ((_Navigator.pointerEnabled || (msPrefix = _Navigator.msPointerEnabled))) {
371                _Device.$TouchActionAttr = msPrefix ? "msTouchAction" : "touchAction";
372            }
373        }
374
375        return _Device;
376    }
377
378    function DetectBrowser(browser) {
379        if (!_Browser) {
380            _Browser = -1;
381
382            if (_AppName == "Microsoft Internet Explorer" &&
383                !!window.attachEvent && !!window.ActiveXObject) {
384
385                var ieOffset = _UserAgent.indexOf("MSIE");
386                _Browser = BROWSER_IE;
387                _BrowserEngineVersion = ParseFloat(_UserAgent.substring(ieOffset + 5, _UserAgent.indexOf(";", ieOffset)));
388
389                //check IE javascript version
390                /*@cc_on
391                _BrowserJavascriptVersion = @_jscript_version;
392                @*/
393
394                // update: for intranet sites and compat view list sites, IE sends
395                // an IE7 User-Agent to the server to be interoperable, and even if
396                // the page requests a later IE version, IE will still report the
397                // IE7 UA to JS. we should be robust to self
398                //var docMode = document.documentMode;
399                //if (typeof docMode !== "undefined") {
400                //    _BrowserRuntimeVersion = docMode;
401                //}
402
403                _BrowserRuntimeVersion = document.documentMode || _BrowserEngineVersion;
404
405            }
406            else if (_AppName == "Netscape" && !!window.addEventListener) {
407
408                var ffOffset = _UserAgent.indexOf("Firefox");
409                var saOffset = _UserAgent.indexOf("Safari");
410                var chOffset = _UserAgent.indexOf("Chrome");
411                var webkitOffset = _UserAgent.indexOf("AppleWebKit");
412
413                if (ffOffset >= 0) {
414                    _Browser = BROWSER_FIREFOX;
415                    _BrowserRuntimeVersion = ParseFloat(_UserAgent.substring(ffOffset + 8));
416                }
417                else if (saOffset >= 0) {
418                    var slash = _UserAgent.substring(0, saOffset).lastIndexOf("/");
419                    _Browser = (chOffset >= 0) ? BROWSER_CHROME : BROWSER_SAFARI;
420                    _BrowserRuntimeVersion = ParseFloat(_UserAgent.substring(slash + 1, saOffset));
421                }
422                else {
423                    //(/Trident.*rv[ :]*11\./i
424                    var match = /Trident\/.*rv:([0-9]{1,}[\.0-9]{0,})/i.exec(_UserAgent);
425                    if (match) {
426                        _Browser = BROWSER_IE;
427                        _BrowserRuntimeVersion = _BrowserEngineVersion = ParseFloat(match[1]);
428                    }
429                }
430
431                if (webkitOffset >= 0)
432                    _WebkitVersion = ParseFloat(_UserAgent.substring(webkitOffset + 12));
433            }
434            else {
435                var match = /(opera)(?:.*version|)[ \/]([\w.]+)/i.exec(_UserAgent);
436                if (match) {
437                    _Browser = BROWSER_OPERA;
438                    _BrowserRuntimeVersion = ParseFloat(match[2]);
439                }
440            }
441        }
442
443        return browser == _Browser;
444    }
445
446    function IsBrowserIE() {
447        return DetectBrowser(BROWSER_IE);
448    }
449
450    function IsBrowserIeQuirks() {
451        return IsBrowserIE() && (_BrowserRuntimeVersion < 6 || document.compatMode == "BackCompat");   //Composite to "CSS1Compat"
452    }
453
454    function IsBrowserFireFox() {
455        return DetectBrowser(BROWSER_FIREFOX);
456    }
457
458    function IsBrowserSafari() {
459        return DetectBrowser(BROWSER_SAFARI);
460    }
461
462    function IsBrowserChrome() {
463        return DetectBrowser(BROWSER_CHROME);
464    }
465
466    function IsBrowserOpera() {
467        return DetectBrowser(BROWSER_OPERA);
468    }
469
470    function IsBrowserBadTransform() {
471        return IsBrowserSafari() && (_WebkitVersion > 534) && (_WebkitVersion < 535);
472    }
473
474    function IsBrowserIe9Earlier() {
475        return IsBrowserIE() && _BrowserRuntimeVersion < 9;
476    }
477
478    function GetTransformProperty(elmt) {
479
480        if (!_TransformProperty) {
481            // Note that in some versions of IE9 it is critical that
482            // msTransform appear in this list before MozTransform
483
484            Each(['transform', 'WebkitTransform', 'msTransform', 'MozTransform', 'OTransform'], function (property) {
485                if (elmt.style[property] != undefined) {
486                    _TransformProperty = property;
487                    return true;
488                }
489            });
490
491            _TransformProperty = _TransformProperty || "transform";
492        }
493
494        return _TransformProperty;
495    }
496
497    // Helpers
498    function getOffsetParent(elmt, isFixed) {
499        // IE and Opera "fixed" position elements don't have offset parents.
500        // regardless, if it's fixed, its offset parent is the body.
501        if (isFixed && elmt != document.body) {
502            return document.body;
503        } else {
504            return elmt.offsetParent;
505        }
506    }
507
508    function toString(obj) {
509        return {}.toString.call(obj);
510    }
511
512    // [[Class]] -> type pairs
513    var _Class2type;
514
515    function GetClass2Type() {
516        if (!_Class2type) {
517            _Class2type = {};
518            Each(["Boolean", "Number", "String", "Function", "Array", "Date", "RegExp", "Object"], function (name) {
519                _Class2type["[object " + name + "]"] = name.toLowerCase();
520            });
521        }
522
523        return _Class2type;
524    }
525
526    function Each(obj, callback) {
527        if (toString(obj) == "[object Array]") {
528            for (var i = 0; i < obj.length; i++) {
529                if (callback(obj[i], i, obj)) {
530                    return true;
531                }
532            }
533        }
534        else {
535            for (var name in obj) {
536                if (callback(obj[name], name, obj)) {
537                    return true;
538                }
539            }
540        }
541    }
542
543    function Type(obj) {
544        return obj == null ? String(obj) : GetClass2Type()[toString(obj)] || "object";
545    }
546
547    function IsNotEmpty(obj) {
548        for(var name in obj)
549            return true;
550    }
551
552    function IsPlainObject(obj) {
553        // Not plain objects:
554        // - Any object or value whose internal [[Class]] property is not "[object Object]"
555        // - DOM nodes
556        // - window
557        try {
558            return Type(obj) == "object"
559                && !obj.nodeType
560                && obj != obj.window
561                && (!obj.constructor || { }.hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf"));
562        }
563        catch (e) { }
564    }
565
566    function Point(x, y) {
567        return { x: x, y: y };
568    }
569
570    function Delay(code, delay) {
571        setTimeout(code, delay || 0);
572    }
573
574    function RemoveByReg(str, reg) {
575        var m = reg.exec(str);
576
577        if (m) {
578            var header = str.substr(0, m.index);
579            var tailer = str.substr(m.lastIndex + 1, str.length - (m.lastIndex + 1));
580            str = header + tailer;
581        }
582
583        return str;
584    }
585
586    function BuildNewCss(oldCss, removeRegs, replaceValue) {
587        var css = (!oldCss || oldCss == "inherit") ? "" : oldCss;
588
589        Each(removeRegs, function (removeReg) {
590            var m = removeReg.exec(css);
591
592            if (m) {
593                var header = css.substr(0, m.index);
594                var tailer = css.substr(m.lastIndex + 1, css.length - (m.lastIndex + 1));
595                css = header + tailer;
596            }
597        });
598
599        css = replaceValue + (css.indexOf(" ") != 0 ? " " : "") + css;
600
601        return css;
602    }
603
604    function SetStyleFilterIE(elmt, value) {
605        if (_BrowserRuntimeVersion < 9) {
606            elmt.style.filter = value;
607        }
608    }
609
610    function SetStyleMatrixIE(elmt, matrix, offset) {
611        //matrix is not for ie9+ running in ie8- mode
612        if (_BrowserJavascriptVersion < 9) {
613            var oldFilterValue = elmt.style.filter;
614            var matrixReg = new RegExp(/[\s]*progid:DXImageTransform\.Microsoft\.Matrix\([^\)]*\)/g);
615            var matrixValue = matrix ? "progid:DXImageTransform.Microsoft.Matrix(" + "M11=" + matrix[0][0] + ", M12=" + matrix[0][1] + ", M21=" + matrix[1][0] + ", M22=" + matrix[1][1] + ", SizingMethod='auto expand')" : "";
616
617            var newFilterValue = BuildNewCss(oldFilterValue, [matrixReg], matrixValue);
618
619            SetStyleFilterIE(elmt, newFilterValue);
620
621            _This.$CssMarginTop(elmt, offset.y);
622            _This.$CssMarginLeft(elmt, offset.x);
623        }
624    }
625
626    // Methods
627
628    _This.$Device = Device;
629
630    _This.$IsBrowserIE = IsBrowserIE;
631
632    _This.$IsBrowserIeQuirks = IsBrowserIeQuirks;
633
634    _This.$IsBrowserFireFox = IsBrowserFireFox;
635
636    _This.$IsBrowserSafari = IsBrowserSafari;
637
638    _This.$IsBrowserChrome = IsBrowserChrome;
639
640    _This.$IsBrowserOpera = IsBrowserOpera;
641
642    _This.$IsBrowserBadTransform = IsBrowserBadTransform;
643
644    _This.$IsBrowserIe9Earlier = IsBrowserIe9Earlier;
645
646    _This.$BrowserVersion = function () {
647        return _BrowserRuntimeVersion;
648    };
649
650    _This.$BrowserEngineVersion = function () {
651        return _BrowserEngineVersion || _BrowserRuntimeVersion;
652    };
653
654    _This.$WebKitVersion = function () {
655        DetectBrowser();
656
657        return _WebkitVersion;
658    };
659
660    _This.$Delay = Delay;
661
662    _This.$Inherit = function (instance, baseClass) {
663        baseClass.call(instance);
664        return Extend({}, instance);
665    };
666
667    function Construct(instance) {
668        instance.constructor === Construct.caller && instance.$Construct && instance.$Construct.apply(instance, Construct.caller.arguments);
669    }
670
671    _This.$Construct = Construct;
672
673    _This.$GetElement = function (elmt) {
674        if (_This.$IsString(elmt)) {
675            elmt = document.getElementById(elmt);
676        }
677
678        return elmt;
679    };
680
681    function GetEvent(event) {
682        return event || window.event;
683    }
684
685    _This.$GetEvent = GetEvent;
686
687    _This.$EvtSrc = function (event) {
688        event = GetEvent(event);
689        return event.target || event.srcElement || document;
690    };
691
692    _This.$EvtTarget = function (event) {
693        event = GetEvent(event);
694        return event.relatedTarget || event.toElement;
695    };
696
697    _This.$EvtWhich = function (event) {
698        event = GetEvent(event);
699        return event.which || [0, 1, 3, 0, 2][event.button] || event.charCode || event.keyCode;
700    };
701
702    _This.$MousePosition = function (event) {
703        event = GetEvent(event);
704        //var body = document.body;
705
706        return {
707            x: event.pageX || event.clientX/* + (_DocElmt.scrollLeft || body.scrollLeft || 0) - (_DocElmt.clientLeft || body.clientLeft || 0)*/ || 0,
708            y: event.pageY || event.clientY/* + (_DocElmt.scrollTop || body.scrollTop || 0) - (_DocElmt.clientTop || body.clientTop || 0)*/ || 0
709        };
710    };
711
712    _This.$PageScroll = function () {
713        var body = document.body;
714
715        return {
716            x: (window.pageXOffset || _DocElmt.scrollLeft || body.scrollLeft || 0) - (_DocElmt.clientLeft || body.clientLeft || 0),
717            y: (window.pageYOffset || _DocElmt.scrollTop || body.scrollTop || 0) - (_DocElmt.clientTop || body.clientTop || 0)
718        };
719    };
720
721    _This.$WindowSize = function () {
722        var body = document.body;
723
724        return {
725            x: body.clientWidth || _DocElmt.clientWidth,
726            y: body.clientHeight || _DocElmt.clientHeight
727        };
728    };
729
730    //_This.$GetElementPosition = function (elmt) {
731    //    elmt = _This.$GetElement(elmt);
732    //    var result = Point();
733
734    //    // technique from:
735    //    // http://www.quirksmode.org/js/findpos.html
736    //    // with special check for "fixed" elements.
737
738    //    while (elmt) {
739    //        result.x += elmt.offsetLeft;
740    //        result.y += elmt.offsetTop;
741
742    //        var isFixed = _This.$GetElementStyle(elmt).position == "fixed";
743
744    //        if (isFixed) {
745    //            result = result.$Plus(_This.$PageScroll(window));
746    //        }
747
748    //        elmt = getOffsetParent(elmt, isFixed);
749    //    }
750
751    //    return result;
752    //};
753
754    //_This.$GetMouseScroll = function (event) {
755    //    event = GetEvent(event);
756    //    var delta = 0; // default value
757
758    //    // technique from:
759    //    // http://blog.paranoidferret.com/index.php/2007/10/31/javascript-tutorial-the-scroll-wheel/
760
761    //    if (typeof (event.wheelDelta) == "number") {
762    //        delta = event.wheelDelta;
763    //    } else if (typeof (event.detail) == "number") {
764    //        delta = event.detail * -1;
765    //    } else {
766    //        $JssorDebug$.$Fail("Unknown event mouse scroll, no known technique.");
767    //    }
768
769    //    // normalize value to [-1, 1]
770    //    return delta ? delta / Math.abs(delta) : 0;
771    //};
772
773    //_This.$MakeAjaxRequest = function (url, callback) {
774    //    var async = typeof (callback) == "function";
775    //    var req = null;
776
777    //    if (async) {
778    //        var actual = callback;
779    //        var callback = function () {
780    //            Delay($Jssor$.$CreateCallback(null, actual, req), 1);
781    //        };
782    //    }
783
784    //    if (window.ActiveXObject) {
785    //        for (var i = 0; i < arrActiveX.length; i++) {
786    //            try {
787    //                req = new ActiveXObject(arrActiveX[i]);
788    //                break;
789    //            } catch (e) {
790    //                continue;
791    //            }
792    //        }
793    //    } else if (window.XMLHttpRequest) {
794    //        req = new XMLHttpRequest();
795    //    }
796
797    //    if (!req) {
798    //        $JssorDebug$.$Fail("Browser doesn't support XMLHttpRequest.");
799    //    }
800
801    //    if (async) {
802    //        req.onreadystatechange = function () {
803    //            if (req.readyState == 4) {
804    //                // prevent memory leaks by breaking circular reference now
805    //                req.onreadystatechange = new Function();
806    //                callback();
807    //            }
808    //        };
809    //    }
810
811    //    try {
812    //        req.open("GET", url, async);
813    //        req.send(null);
814    //    } catch (e) {
815    //        $JssorDebug$.$Log(e.name + " while making AJAX request: " + e.message);
816
817    //        req.onreadystatechange = null;
818    //        req = null;
819
820    //        if (async) {
821    //            callback();
822    //        }
823    //    }
824
825    //    return async ? null : req;
826    //};
827
828    //_This.$ParseXml = function (string) {
829    //    var xmlDoc = null;
830
831    //    if (window.ActiveXObject) {
832    //        try {
833    //            xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
834    //            xmlDoc.async = false;
835    //            xmlDoc.loadXML(string);
836    //        } catch (e) {
837    //            $JssorDebug$.$Log(e.name + " while parsing XML (ActiveX): " + e.message);
838    //        }
839    //    } else if (window.DOMParser) {
840    //        try {
841    //            var parser = new DOMParser();
842    //            xmlDoc = parser.parseFromString(string, "text/xml");
843    //        } catch (e) {
844    //            $JssorDebug$.$Log(e.name + " while parsing XML (DOMParser): " + e.message);
845    //        }
846    //    } else {
847    //        $JssorDebug$.$Fail("Browser doesn't support XML DOM.");
848    //    }
849
850    //    return xmlDoc;
851    //};
852
853    function Css(elmt, name, value) {
854        ///	<summary>
855        ///		access css
856        ///     $Jssor$.$Css(elmt, name);         //get css value
857        ///     $Jssor$.$Css(elmt, name, value);  //set css value
858        ///	</summary>
859        ///	<param name="elmt" type="HTMLElement">
860        ///		the element to access css
861        ///	</param>
862        ///	<param name="name" type="String">
863        ///		the name of css property
864        ///	</param>
865        ///	<param name="value" optional="true">
866        ///		the value to set
867        ///	</param>
868        if (value != undefined) {
869            elmt.style[name] = value;
870        }
871        else {
872            var style = elmt.currentStyle || elmt.style;
873            value = style[name];
874
875            if (value == "" && window.getComputedStyle) {
876                style = elmt.ownerDocument.defaultView.getComputedStyle(elmt, null);
877
878                style && (value = style.getPropertyValue(name) || style[name]);
879            }
880
881            return value;
882        }
883    }
884
885    function CssN(elmt, name, value, isDimensional) {
886        ///	<summary>
887        ///		access css as numeric
888        ///     $Jssor$.$CssN(elmt, name);         //get css value
889        ///     $Jssor$.$CssN(elmt, name, value);  //set css value
890        ///	</summary>
891        ///	<param name="elmt" type="HTMLElement">
892        ///		the element to access css
893        ///	</param>
894        ///	<param name="name" type="String">
895        ///		the name of css property
896        ///	</param>
897        ///	<param name="value" type="Number" optional="true">
898        ///		the value to set
899        ///	</param>
900        if (value != undefined) {
901            isDimensional && (value += "px");
902            Css(elmt, name, value);
903        }
904        else {
905            return ParseFloat(Css(elmt, name));
906        }
907    }
908
909    function CssP(elmt, name, value) {
910        ///	<summary>
911        ///		access css in pixel as numeric, like 'top', 'left', 'width', 'height'
912        ///     $Jssor$.$CssP(elmt, name);         //get css value
913        ///     $Jssor$.$CssP(elmt, name, value);  //set css value
914        ///	</summary>
915        ///	<param name="elmt" type="HTMLElement">
916        ///		the element to access css
917        ///	</param>
918        ///	<param name="name" type="String">
919        ///		the name of css property
920        ///	</param>
921        ///	<param name="value" type="Number" optional="true">
922        ///		the value to set
923        ///	</param>
924        return CssN(elmt, name, value, true);
925    }
926
927    function CssProxy(name, numericOrDimension) {
928        ///	<summary>
929        ///		create proxy to access css, CssProxy(name[, numericOrDimension]);
930        ///	</summary>
931        ///	<param name="elmt" type="HTMLElement">
932        ///		the element to access css
933        ///	</param>
934        ///	<param name="numericOrDimension" type="Number" optional="true">
935        ///		not set: access original css, 1: access css as numeric, 2: access css in pixel as numeric
936        ///	</param>
937        var isDimensional = numericOrDimension & 2;
938        var cssAccessor = numericOrDimension ? CssN : Css;
939        return function (elmt, value) {
940            return cssAccessor(elmt, name, value, isDimensional);
941        };
942    }
943
944    function GetStyleOpacity(elmt) {
945        if (IsBrowserIE() && _BrowserEngineVersion < 9) {
946            var match = /opacity=([^)]*)/.exec(elmt.style.filter || "");
947            return match ? (ParseFloat(match[1]) / 100) : 1;
948        }
949        else
950            return ParseFloat(elmt.style.opacity || "1");
951    }
952
953    function SetStyleOpacity(elmt, opacity, ie9EarlierForce) {
954
955        if (IsBrowserIE() && _BrowserEngineVersion < 9) {
956            //var filterName = "filter"; // _BrowserEngineVersion < 8 ? "filter" : "-ms-filter";
957            var finalFilter = elmt.style.filter || "";
958
959            // for CSS filter browsers (IE), remove alpha filter if it's unnecessary.
960            // update: doing _This always since IE9 beta seems to have broken the
961            // behavior if we rely on the programmatic filters collection.
962            var alphaReg = new RegExp(/[\s]*alpha\([^\)]*\)/g);
963
964            // important: note the lazy star! _This protects against
965            // multiple filters; we don't want to delete the other ones.
966            // update: also trimming extra whitespace around filter.
967
968            var ieOpacity = Math.round(100 * opacity);
969            var alphaFilter = "";
970            if (ieOpacity < 100 || ie9EarlierForce) {
971                alphaFilter = "alpha(opacity=" + ieOpacity + ") ";
972            }
973
974            var newFilterValue = BuildNewCss(finalFilter, [alphaReg], alphaFilter);
975
976            SetStyleFilterIE(elmt, newFilterValue);
977        }
978        else {
979            elmt.style.opacity = opacity == 1 ? "" : Math.round(opacity * 100) / 100;
980        }
981    }
982
983    function SetStyleTransformInternal(elmt, transform) {
984        var rotate = transform.$Rotate || 0;
985        var scale = transform.$Scale == undefined ? 1 : transform.$Scale;
986
987        if (IsBrowserIe9Earlier()) {
988            var matrix = _This.$CreateMatrix(rotate / 180 * Math.PI, scale, scale);
989            SetStyleMatrixIE(elmt, (!rotate && scale == 1) ? null : matrix, _This.$GetMatrixOffset(matrix, transform.$OriginalWidth, transform.$OriginalHeight));
990        }
991        else {
992            //rotate(15deg) scale(.5) translateZ(0)
993            var transformProperty = GetTransformProperty(elmt);
994            if (transformProperty) {
995                var transformValue = "rotate(" + rotate % 360 + "deg) scale(" + scale + ")";
996
997                //needed for touch device, no need for desktop device
998                if (IsBrowserChrome() && _WebkitVersion > 535 && "ontouchstart" in window)
999                    transformValue += " perspective(2000px)";
1000
1001                elmt.style[transformProperty] = transformValue;
1002            }
1003        }
1004    }
1005
1006    _This.$SetStyleTransform = function (elmt, transform) {
1007        if (IsBrowserBadTransform()) {
1008            Delay(_This.$CreateCallback(null, SetStyleTransformInternal, elmt, transform));
1009        }
1010        else {
1011            SetStyleTransformInternal(elmt, transform);
1012        }
1013    };
1014
1015    _This.$SetStyleTransformOrigin = function (elmt, transformOrigin) {
1016        var transformProperty = GetTransformProperty(elmt);
1017
1018        if (transformProperty)
1019            elmt.style[transformProperty + "Origin"] = transformOrigin;
1020    };
1021
1022    _This.$CssScale = function (elmt, scale) {
1023
1024        if (IsBrowserIE() && _BrowserEngineVersion < 9 || (_BrowserEngineVersion < 10 && IsBrowserIeQuirks())) {
1025            elmt.style.zoom = (scale == 1) ? "" : scale;
1026        }
1027        else {
1028            var transformProperty = GetTransformProperty(elmt);
1029
1030            if (transformProperty) {
1031                //rotate(15deg) scale(.5)
1032                var transformValue = "scale(" + scale + ")";
1033
1034                var oldTransformValue = elmt.style[transformProperty];
1035                var scaleReg = new RegExp(/[\s]*scale\(.*?\)/g);
1036
1037                var newTransformValue = BuildNewCss(oldTransformValue, [scaleReg], transformValue);
1038
1039                elmt.style[transformProperty] = newTransformValue;
1040            }
1041        }
1042    };
1043
1044    _This.$EnableHWA = function (elmt) {
1045        if (!elmt.style[GetTransformProperty(elmt)] || elmt.style[GetTransformProperty(elmt)] == "none")
1046            elmt.style[GetTransformProperty(elmt)] = "perspective(2000px)";
1047    };
1048
1049    _This.$DisableHWA = function (elmt) {
1050        elmt.style[GetTransformProperty(elmt)] = "none";
1051    };
1052
1053    var ie8OffsetWidth = 0;
1054    var ie8OffsetHeight = 0;
1055
1056    _This.$WindowResizeFilter = function (window, handler) {
1057        return IsBrowserIe9Earlier() ? function () {
1058
1059            var trigger = true;
1060
1061            var checkElement = (IsBrowserIeQuirks() ? window.document.body : window.document.documentElement);
1062            if (checkElement) {
1063                var widthChange = checkElement.offsetWidth - ie8OffsetWidth;
1064                var heightChange = checkElement.offsetHeight - ie8OffsetHeight;
1065                if (widthChange || heightChange) {
1066                    ie8OffsetWidth += widthChange;
1067                    ie8OffsetHeight += heightChange;
1068                }
1069                else
1070                    trigger = false;
1071            }
1072
1073            trigger && handler();
1074
1075        } : handler;
1076    };
1077
1078    _This.$MouseOverOutFilter = function (handler, target) {
1079        ///	<param name="target" type="HTMLDomElement">
1080        ///		The target element to detect mouse over/out events. (for ie < 9 compatibility)
1081        ///	</param>
1082
1083        $JssorDebug$.$Execute(function () {
1084            if (!target) {
1085                throw new Error("Null reference, parameter \"target\".");
1086            }
1087        });
1088
1089        return function (event) {
1090            event = GetEvent(event);
1091
1092            var eventName = event.type;
1093            var related = event.relatedTarget || (eventName == "mouseout" ? event.toElement : event.fromElement);
1094
1095            if (!related || (related !== target && !_This.$IsChild(target, related))) {
1096                handler(event);
1097            }
1098        };
1099    };
1100
1101    _This.$AddEvent = function (elmt, eventName, handler, useCapture) {
1102        elmt = _This.$GetElement(elmt);
1103
1104        $JssorDebug$.$Execute(function () {
1105            if (!elmt) {
1106                $JssorDebug$.$Fail("Parameter 'elmt' not specified.");
1107            }
1108
1109            if (!handler) {
1110                $JssorDebug$.$Fail("Parameter 'handler' not specified.");
1111            }
1112
1113            if (!elmt.addEventListener && !elmt.attachEvent) {
1114                $JssorDebug$.$Fail("Unable to attach event handler, no known technique.");
1115            }
1116        });
1117
1118        // technique from:
1119        // http://blog.paranoidferret.com/index.php/2007/08/10/javascript-working-with-events/
1120
1121        if (elmt.addEventListener) {
1122            if (eventName == "mousewheel") {
1123                elmt.addEventListener("DOMMouseScroll", handler, useCapture);
1124            }
1125            // we are still going to add the mousewheel -- not a mistake!
1126            // _This is for opera, since it uses onmousewheel but needs addEventListener.
1127            elmt.addEventListener(eventName, handler, useCapture);
1128        }
1129        else if (elmt.attachEvent) {
1130            elmt.attachEvent("on" + eventName, handler);
1131            if (useCapture && elmt.setCapture) {
1132                elmt.setCapture();
1133            }
1134        }
1135    };
1136
1137    _This.$RemoveEvent = function (elmt, eventName, handler, useCapture) {
1138        elmt = _This.$GetElement(elmt);
1139
1140        // technique from:
1141        // http://blog.paranoidferret.com/index.php/2007/08/10/javascript-working-with-events/
1142
1143        if (elmt.removeEventListener) {
1144            if (eventName == "mousewheel") {
1145                elmt.removeEventListener("DOMMouseScroll", handler, useCapture);
1146            }
1147            // we are still going to remove the mousewheel -- not a mistake!
1148            // _This is for opera, since it uses onmousewheel but needs removeEventListener.
1149            elmt.removeEventListener(eventName, handler, useCapture);
1150        }
1151        else if (elmt.detachEvent) {
1152            elmt.detachEvent("on" + eventName, handler);
1153            if (useCapture && elmt.releaseCapture) {
1154                elmt.releaseCapture();
1155            }
1156        }
1157    };
1158
1159    _This.$FireEvent = function (elmt, eventName) {
1160        //var document = elmt.document;
1161
1162        $JssorDebug$.$Execute(function () {
1163            if (!document.createEvent && !document.createEventObject) {
1164                $JssorDebug$.$Fail("Unable to fire event, no known technique.");
1165            }
1166
1167            if (!elmt.dispatchEvent && !elmt.fireEvent) {
1168                $JssorDebug$.$Fail("Unable to fire event, no known technique.");
1169            }
1170        });
1171
1172        var evento;
1173
1174        if (document.createEvent) {
1175            evento = document.createEvent("HTMLEvents");
1176            evento.initEvent(eventName, false, false);
1177            elmt.dispatchEvent(evento);
1178        }
1179        else {
1180            var ieEventName = "on" + eventName;
1181            evento = document.createEventObject();
1182
1183            elmt.fireEvent(ieEventName, evento);
1184        }
1185    };
1186
1187    _This.$CancelEvent = function (event) {
1188        event = GetEvent(event);
1189
1190        // technique from:
1191        // http://blog.paranoidferret.com/index.php/2007/08/10/javascript-working-with-events/
1192
1193        if (event.preventDefault) {
1194            event.preventDefault();     // W3C for preventing default
1195        }
1196
1197        event.cancel = true;            // legacy for preventing default
1198        event.returnValue = false;      // IE for preventing default
1199    };
1200
1201    _This.$StopEvent = function (event) {
1202        event = GetEvent(event);
1203
1204        // technique from:
1205        // http://blog.paranoidferret.com/index.php/2007/08/10/javascript-working-with-events/
1206
1207        if (event.stopPropagation) {
1208            event.stopPropagation();    // W3C for stopping propagation
1209        }
1210
1211        event.cancelBubble = true;      // IE for stopping propagation
1212    };
1213
1214    _This.$CreateCallback = function (object, method) {
1215        // create callback args
1216        var initialArgs = [].slice.call(arguments, 2);
1217
1218        // create closure to apply method
1219        var callback = function () {
1220            // concatenate new args, but make a copy of initialArgs first
1221            var args = initialArgs.concat([].slice.call(arguments, 0));
1222
1223            return method.apply(object, args);
1224        };
1225
1226        //$JssorDebug$.$LiveStamp(callback, "callback_" + ($Jssor$.$GetNow() & 0xFFFFFF));
1227
1228        return callback;
1229    };
1230
1231    _This.$InnerText = function (elmt, text) {
1232        if (text == undefined)
1233            return elmt.textContent || elmt.innerText;
1234
1235        var textNode = document.createTextNode(text);
1236        _This.$Empty(elmt);
1237        elmt.appendChild(textNode);
1238    };
1239
1240    _This.$InnerHtml = function (elmt, html) {
1241        if (html == undefined)
1242            return elmt.innerHTML;
1243
1244        elmt.innerHTML = html;
1245    };
1246
1247    _This.$GetClientRect = function (elmt) {
1248        var rect = elmt.getBoundingClientRect();
1249
1250        return { x: rect.left, y: rect.top, w: rect.right - rect.left, h: rect.bottom - rect.top };
1251    };
1252
1253    _This.$ClearInnerHtml = function (elmt) {
1254        elmt.innerHTML = "";
1255    };
1256
1257    _This.$EncodeHtml = function (text) {
1258        var div = _This.$CreateDiv();
1259        _This.$InnerText(div, text);
1260        return _This.$InnerHtml(div);
1261    };
1262
1263    _This.$DecodeHtml = function (html) {
1264        var div = _This.$CreateDiv();
1265        _This.$InnerHtml(div, html);
1266        return _This.$InnerText(div);
1267    };
1268
1269    _This.$SelectElement = function (elmt) {
1270        var userSelection;
1271        if (window.getSelection) {
1272            //W3C default
1273            userSelection = window.getSelection();
1274        }
1275        var theRange = null;
1276        if (document.createRange) {
1277            theRange = document.createRange();
1278            theRange.selectNode(elmt);
1279        }
1280        else {
1281            theRange = document.body.createTextRange();
1282            theRange.moveToElementText(elmt);
1283            theRange.select();
1284        }
1285        //set user selection
1286        if (userSelection)
1287            userSelection.addRange(theRange);
1288    };
1289
1290    _This.$DeselectElements = function () {
1291        if (document.selection) {
1292            document.selection.empty();
1293        } else if (window.getSelection) {
1294            window.getSelection().removeAllRanges();
1295        }
1296    };
1297
1298    _This.$Children = function (elmt, includeAll) {
1299        var children = [];
1300
1301        for (var tmpEl = elmt.firstChild; tmpEl; tmpEl = tmpEl.nextSibling) {
1302            if (includeAll || tmpEl.nodeType == 1) {
1303                children.push(tmpEl);
1304            }
1305        }
1306
1307        return children;
1308    };
1309
1310    function FindChild(elmt, attrValue, noDeep, attrName) {
1311        attrName = attrName || "u";
1312
1313        for (elmt = elmt ? elmt.firstChild : null; elmt; elmt = elmt.nextSibling) {
1314            if (elmt.nodeType == 1) {
1315                if (AttributeEx(elmt, attrName) == attrValue)
1316                    return elmt;
1317
1318                if (!noDeep) {
1319                    var childRet = FindChild(elmt, attrValue, noDeep, attrName);
1320                    if (childRet)
1321                        return childRet;
1322                }
1323            }
1324        }
1325    }
1326
1327    _This.$FindChild = FindChild;
1328
1329    function FindChildren(elmt, attrValue, noDeep, attrName) {
1330        attrName = attrName || "u";
1331
1332        var ret = [];
1333
1334        for (elmt = elmt ? elmt.firstChild : null; elmt; elmt = elmt.nextSibling) {
1335            if (elmt.nodeType == 1) {
1336                if (AttributeEx(elmt, attrName) == attrValue)
1337                    ret.push(elmt);
1338
1339                if (!noDeep) {
1340                    var childRet = FindChildren(elmt, attrValue, noDeep, attrName);
1341                    if (childRet.length)
1342                        ret = ret.concat(childRet);
1343                }
1344            }
1345        }
1346
1347        return ret;
1348    }
1349
1350    _This.$FindChildren = FindChildren;
1351
1352    function FindChildByTag(elmt, tagName, noDeep) {
1353
1354        for (elmt = elmt ? elmt.firstChild : null; elmt; elmt = elmt.nextSibling) {
1355            if (elmt.nodeType == 1) {
1356                if (elmt.tagName == tagName)
1357                    return elmt;
1358
1359                if (!noDeep) {
1360                    var childRet = FindChildByTag(elmt, tagName, noDeep);
1361                    if (childRet)
1362                        return childRet;
1363                }
1364            }
1365        }
1366    }
1367
1368    _This.$FindChildByTag = FindChildByTag;
1369
1370    function FindChildrenByTag(elmt, tagName, noDeep) {
1371        var ret = [];
1372
1373        for (elmt = elmt ? elmt.firstChild : null; elmt; elmt = elmt.nextSibling) {
1374            if (elmt.nodeType == 1) {
1375                if (!tagName || elmt.tagName == tagName)
1376                    ret.push(elmt);
1377
1378                if (!noDeep) {
1379                    var childRet = FindChildrenByTag(elmt, tagName, noDeep);
1380                    if (childRet.length)
1381                        ret = ret.concat(childRet);
1382                }
1383            }
1384        }
1385
1386        return ret;
1387    }
1388
1389    _This.$FindChildrenByTag = FindChildrenByTag;
1390
1391    _This.$GetElementsByTag = function (elmt, tagName) {
1392        return elmt.getElementsByTagName(tagName);
1393    };
1394
1395    //function Extend() {
1396    //    var args = arguments;
1397    //    var target;
1398    //    var options;
1399    //    var propName;
1400    //    var propValue;
1401    //    var targetPropValue;
1402    //    var purpose = 7 & args[0];
1403    //    var deep = 1 & purpose;
1404    //    var unextend = 2 & purpose;
1405    //    var i = purpose ? 2 : 1;
1406    //    target = args[i - 1] || {};
1407
1408    //    for (; i < args.length; i++) {
1409    //        // Only deal with non-null/undefined values
1410    //        if (options = args[i]) {
1411    //            // Extend the base object
1412    //            for (propName in options) {
1413    //                propValue = options[propName];
1414
1415    //                if (propValue !== undefined) {
1416    //                    propValue = options[propName];
1417
1418    //                    if (unextend) {
1419    //                        targetPropValue = target[propName];
1420    //                        if (propValue === targetPropValue)
1421    //                            delete target[propName];
1422    //                        else if (deep && IsPlainObject(targetPropValue)) {
1423    //                            Extend(purpose, targetPropValue, propValue);
1424    //                        }
1425    //                    }
1426    //                    else {
1427    //                        target[propName] = (deep && IsPlainObject(target[propName])) ? Extend(purpose | 4, {}, propValue) : propValue;
1428    //                    }
1429    //                }
1430    //            }
1431    //        }
1432    //    }
1433
1434    //    // Return the modified object
1435    //    return target;
1436    //}
1437
1438    //function Unextend() {
1439    //    var args = arguments;
1440    //    var newArgs = [].slice.call(arguments);
1441    //    var purpose = 1 & args[0];
1442
1443    //    purpose && newArgs.shift();
1444    //    newArgs.unshift(purpose | 2);
1445
1446    //    return Extend.apply(null, newArgs);
1447    //}
1448
1449    function Extend() {
1450        var args = arguments;
1451        var target;
1452        var options;
1453        var propName;
1454        var propValue;
1455        var deep = 1 & args[0];
1456        var i = 1 + deep;
1457        target = args[i - 1] || {};
1458
1459        for (; i < args.length; i++) {
1460            // Only deal with non-null/undefined values
1461            if (options = args[i]) {
1462                // Extend the base object
1463                for (propName in options) {
1464                    propValue = options[propName];
1465
1466                    if (propValue !== undefined) {
1467                        propValue = options[propName];
1468                        target[propName] = (deep && IsPlainObject(target[propName])) ? Extend(deep, {}, propValue) : propValue;
1469                    }
1470                }
1471            }
1472        }
1473
1474        // Return the modified object
1475        return target;
1476    }
1477
1478    _This.$Extend = Extend;
1479
1480    function Unextend(target, option) {
1481        $JssorDebug$.$Assert(option);
1482
1483        var unextended = {};
1484        var name;
1485        var targetProp;
1486        var optionProp;
1487
1488        // Extend the base object
1489        for (name in target) {
1490            targetProp = target[name];
1491            optionProp = option[name];
1492
1493            if (targetProp !== optionProp) {
1494                var exclude;
1495
1496                if (IsPlainObject(targetProp) && IsPlainObject(optionProp)) {
1497                    targetProp = Unextend(optionProp);
1498                    exclude = !IsNotEmpty(targetProp);
1499                }
1500                
1501                !exclude && (unextended[name] = targetProp);
1502            }
1503        }
1504
1505        // Return the modified object
1506        return unextended;
1507    }
1508
1509    _This.$Unextend = Unextend;
1510
1511    _This.$IsFunction = function (obj) {
1512        return Type(obj) == "function";
1513    };
1514
1515    _This.$IsArray = function (obj) {
1516        return Type(obj) == "array";
1517    };
1518
1519    _This.$IsString = function (obj) {
1520        return Type(obj) == "string";
1521    };
1522
1523    _This.$IsNumeric = function (obj) {
1524        return !isNaN(ParseFloat(obj)) && isFinite(obj);
1525    };
1526
1527    _This.$Type = Type;
1528
1529    // args is for internal usage only
1530    _This.$Each = Each;
1531
1532    _This.$IsNotEmpty = IsNotEmpty;
1533
1534    _This.$IsPlainObject = IsPlainObject;
1535
1536    function CreateElement(tagName) {
1537        return document.createElement(tagName);
1538    }
1539
1540    _This.$CreateElement = CreateElement;
1541
1542    _This.$CreateDiv = function () {
1543        return CreateElement("DIV");
1544    };
1545
1546    _This.$CreateSpan = function () {
1547        return CreateElement("SPAN");
1548    };
1549
1550    _This.$EmptyFunction = function () { };
1551
1552    function Attribute(elmt, name, value) {
1553        if (value == undefined)
1554            return elmt.getAttribute(name);
1555
1556        elmt.setAttribute(name, value);
1557    }
1558
1559    function AttributeEx(elmt, name) {
1560        return Attribute(elmt, name) || Attribute(elmt, "data-" + name);
1561    }
1562
1563    _This.$Attribute = Attribute;
1564    _This.$AttributeEx = AttributeEx;
1565
1566    function ClassName(elmt, className) {
1567        if (className == undefined)
1568            return elmt.className;
1569
1570        elmt.className = className;
1571    }
1572
1573    _This.$ClassName = ClassName;
1574
1575    function ToHash(array) {
1576        var hash = {};
1577
1578        Each(array, function (item) {
1579            hash[item] = item;
1580        });
1581
1582        return hash;
1583    }
1584
1585    function Split(str, separator) {
1586        return str.match(separator || REGEX_WHITESPACE_GLOBAL);
1587    }
1588
1589    function StringToHashObject(str, regExp) {
1590        return ToHash(Split(str || "", regExp));
1591    }
1592
1593    _This.$ToHash = ToHash;
1594    _This.$Split = Split;
1595
1596    function Join(separator, strings) {
1597        ///	<param name="separator" type="String">
1598        ///	</param>
1599        ///	<param name="strings" type="Array" value="['1']">
1600        ///	</param>
1601
1602        var joined = "";
1603
1604        Each(strings, function (str) {
1605            joined && (joined += separator);
1606            joined += str;
1607        });
1608
1609        return joined;
1610    }
1611
1612    function ReplaceClass(elmt, oldClassName, newClassName) {
1613        ClassName(elmt, Join(" ", Extend(Unextend(StringToHashObject(ClassName(elmt)), StringToHashObject(oldClassName)), StringToHashObject(newClassName))));
1614    }
1615
1616    _This.$Join = Join;
1617
1618    _This.$AddClass = function (elmt, className) {
1619        ReplaceClass(elmt, null, className);
1620    };
1621
1622    _This.$RemoveClass = ReplaceClass;
1623
1624    _This.$ReplaceClass = ReplaceClass;
1625
1626    _This.$ParentNode = function (elmt) {
1627        return elmt.parentNode;
1628    };
1629
1630    _This.$HideElement = function (elmt) {
1631        _This.$CssDisplay(elmt, "none");
1632    };
1633
1634    _This.$EnableElement = function (elmt, notEnable) {
1635        if (notEnable) {
1636            _This.$Attribute(elmt, "disabled", true);
1637        }
1638        else {
1639            _This.$RemoveAttribute(elmt, "disabled");
1640        }
1641    };
1642
1643    _This.$HideElements = function (elmts) {
1644        for (var i = 0; i < elmts.length; i++) {
1645            _This.$HideElement(elmts[i]);
1646        }
1647    };
1648
1649    _This.$ShowElement = function (elmt, hide) {
1650        _This.$CssDisplay(elmt, hide ? "none" : "");
1651    };
1652
1653    _This.$ShowElements = function (elmts, hide) {
1654        for (var i = 0; i < elmts.length; i++) {
1655            _This.$ShowElement(elmts[i], hide);
1656        }
1657    };
1658
1659    _This.$RemoveAttribute = function (elmt, attrbuteName) {
1660        elmt.removeAttribute(attrbuteName);
1661    };
1662
1663    _This.$CanClearClip = function () {
1664        return IsBrowserIE() && _BrowserRuntimeVersion < 10;
1665    };
1666
1667    _This.$SetStyleClip = function (elmt, clip) {
1668        if (clip) {
1669            elmt.style.clip = "rect(" + Math.round(clip.$Top) + "px " + Math.round(clip.$Right) + "px " + Math.round(clip.$Bottom) + "px " + Math.round(clip.$Left) + "px)";
1670        }
1671        else {
1672            var cssText = elmt.style.cssText;
1673            var clipRegs = [
1674                new RegExp(/[\s]*clip: rect\(.*?\)[;]?/i),
1675                new RegExp(/[\s]*cliptop: .*?[;]?/i),
1676                new RegExp(/[\s]*clipright: .*?[;]?/i),
1677                new RegExp(/[\s]*clipbottom: .*?[;]?/i),
1678                new RegExp(/[\s]*clipleft: .*?[;]?/i)
1679            ];
1680
1681            var newCssText = BuildNewCss(cssText, clipRegs, "");
1682
1683            $Jssor$.$CssCssText(elmt, newCssText);
1684        }
1685    };
1686
1687    _This.$GetNow = function () {
1688        return new Date().getTime();
1689    };
1690
1691    _This.$AppendChild = function (elmt, child) {
1692        elmt.appendChild(child);
1693    };
1694
1695    _This.$AppendChildren = function (elmt, children) {
1696        Each(children, function (child) {
1697            _This.$AppendChild(elmt, child);
1698        });
1699    };
1700
1701    _This.$InsertBefore = function (newNode, refNode, pNode) {
1702        ///	<summary>
1703        ///		Insert a node before a reference node
1704        ///	</summary>
1705        ///	<param name="newNode" type="HTMLElement">
1706        ///		A new node to insert
1707        ///	</param>
1708        ///	<param name="refNode" type="HTMLElement">
1709        ///		The reference node to insert a new node before
1710        ///	</param>
1711        ///	<param name="pNode" type="HTMLElement" optional="true">
1712        ///		The parent node to insert node to
1713        ///	</param>
1714
1715        (pNode || refNode.parentNode).insertBefore(newNode, refNode);
1716    };
1717
1718    _This.$InsertAfter = function (newNode, refNode, pNode) {
1719        ///	<summary>
1720        ///		Insert a node after a reference node
1721        ///	</summary>
1722        ///	<param name="newNode" type="HTMLElement">
1723        ///		A new node to insert
1724        ///	</param>
1725        ///	<param name="refNode" type="HTMLElement">
1726        ///		The reference node to insert a new node after
1727        ///	</param>
1728        ///	<param name="pNode" type="HTMLElement" optional="true">
1729        ///		The parent node to insert node to
1730        ///	</param>
1731
1732        _This.$InsertBefore(newNode, refNode.nextSibling, pNode || refNode.parentNode);
1733    };
1734
1735    _This.$InsertAdjacentHtml = function (elmt, where, html) {
1736        elmt.insertAdjacentHTML(where, html);
1737    };
1738
1739    _This.$RemoveElement = function (elmt, pNode) {
1740        ///	<summary>
1741        ///		Remove element from parent node
1742        ///	</summary>
1743        ///	<param name="elmt" type="HTMLElement">
1744        ///		The element to remove
1745        ///	</param>
1746        ///	<param name="pNode" type="HTMLElement" optional="true">
1747        ///		The parent node to remove elment from
1748        ///	</param>
1749        (pNode || elmt.parentNode).removeChild(elmt);
1750    };
1751
1752    _This.$RemoveElements = function (elmts, pNode) {
1753        Each(elmts, function (elmt) {
1754            _This.$RemoveElement(elmt, pNode);
1755        });
1756    };
1757
1758    _This.$Empty = function (elmt) {
1759        _This.$RemoveElements(_This.$Children(elmt, true), elmt);
1760    };
1761
1762    _This.$ParseInt = function (str, radix) {
1763        return parseInt(str, radix || 10);
1764    };
1765
1766    var ParseFloat = parseFloat;
1767
1768    _This.$ParseFloat = ParseFloat;
1769
1770    _This.$IsChild = function (elmtA, elmtB) {
1771        var body = document.body;
1772
1773        while (elmtB && elmtA !== elmtB && body !== elmtB) {
1774            try {
1775                elmtB = elmtB.parentNode;
1776            } catch (e) {
1777                // Firefox sometimes fires events for XUL elements, which throws
1778                // a "permission denied" error. so this is not a child.
1779                return false;
1780            }
1781        }
1782
1783        return elmtA === elmtB;
1784    };
1785
1786    function CloneNode(elmt, noDeep, keepId) {
1787        var clone = elmt.cloneNode(!noDeep);
1788        if (!keepId) {
1789            _This.$RemoveAttribute(clone, "id");
1790        }
1791
1792        return clone;
1793    }
1794
1795    _This.$CloneNode = CloneNode;
1796
1797    _This.$LoadImage = function (src, callback) {
1798        var image = new Image();
1799
1800        function LoadImageCompleteHandler(event, abort) {
1801            _This.$RemoveEvent(image, "load", LoadImageCompleteHandler);
1802            _This.$RemoveEvent(image, "abort", ErrorOrAbortHandler);
1803            _This.$RemoveEvent(image, "error", ErrorOrAbortHandler);
1804
1805            if (callback)
1806                callback(image, abort);
1807        }
1808
1809        function ErrorOrAbortHandler(event) {
1810            LoadImageCompleteHandler(event, true);
1811        }
1812
1813        if (IsBrowserOpera() && _BrowserRuntimeVersion < 11.6 || !src) {
1814            LoadImageCompleteHandler(!src);
1815        }
1816        else {
1817
1818            _This.$AddEvent(image, "load", LoadImageCompleteHandler);
1819            _This.$AddEvent(image, "abort", ErrorOrAbortHandler);
1820            _This.$AddEvent(image, "error", ErrorOrAbortHandler);
1821
1822            image.src = src;
1823        }
1824    };
1825
1826    _This.$LoadImages = function (imageElmts, mainImageElmt, callback) {
1827
1828        var _ImageLoading = imageElmts.length + 1;
1829
1830        function LoadImageCompleteEventHandler(image, abort) {
1831
1832            _ImageLoading--;
1833            if (mainImageElmt && image && image.src == mainImageElmt.src)
1834                mainImageElmt = image;
1835            !_ImageLoading && callback && callback(mainImageElmt);
1836        }
1837
1838        Each(imageElmts, function (imageElmt) {
1839            _This.$LoadImage(imageElmt.src, LoadImageCompleteEventHandler);
1840        });
1841
1842        LoadImageCompleteEventHandler();
1843    };
1844
1845    _This.$BuildElement = function (template, tagName, replacer, createCopy) {
1846        if (createCopy)
1847            template = CloneNode(template);
1848
1849        var templateHolders = FindChildren(template, tagName);
1850        if (!templateHolders.length)
1851            templateHolders = $Jssor$.$GetElementsByTag(template, tagName);
1852
1853        for (var j = templateHolders.length - 1; j > -1; j--) {
1854            var templateHolder = templateHolders[j];
1855            var replaceItem = CloneNode(replacer);
1856            ClassName(replaceItem, ClassName(templateHolder));
1857            $Jssor$.$CssCssText(replaceItem, templateHolder.style.cssText);
1858
1859            $Jssor$.$InsertBefore(replaceItem, templateHolder);
1860            $Jssor$.$RemoveElement(templateHolder);
1861        }
1862
1863        return template;
1864    };
1865
1866    function JssorButtonEx(elmt) {
1867        var _Self = this;
1868
1869        var _OriginClassName = "";
1870        var _ToggleClassSuffixes = ["av", "pv", "ds", "dn"];
1871        var _ToggleClasses = [];
1872        var _ToggleClassName;
1873
1874        var _IsMouseDown = 0;   //class name 'dn'
1875        var _IsSelected = 0;    //class name 1(active): 'av', 2(passive): 'pv'
1876        var _IsDisabled = 0;    //class name 'ds'
1877
1878        function Highlight() {
1879            ReplaceClass(elmt, _ToggleClassName, _ToggleClasses[_IsDisabled || _IsMouseDown || (_IsSelected & 2) || _IsSelected]);
1880            $Jssor$.$Css(elmt, "pointer-events", _IsDisabled ? "none" : "");
1881        }
1882
1883        function MouseUpOrCancelEventHandler(event) {
1884            _IsMouseDown = 0;
1885
1886            Highlight();
1887
1888            _This.$RemoveEvent(document, "mouseup", MouseUpOrCancelEventHandler);
1889            _This.$RemoveEvent(document, "touchend", MouseUpOrCancelEventHandler);
1890            _This.$RemoveEvent(document, "touchcancel", MouseUpOrCancelEventHandler);
1891        }
1892
1893        function MouseDownEventHandler(event) {
1894            if (_IsDisabled) {
1895                _This.$CancelEvent(event);
1896            }
1897            else {
1898
1899                _IsMouseDown = 4;
1900
1901                Highlight();
1902
1903                _This.$AddEvent(document, "mouseup", MouseUpOrCancelEventHandler);
1904                _This.$AddEvent(document, "touchend", MouseUpOrCancelEventHandler);
1905                _This.$AddEvent(document, "touchcancel", MouseUpOrCancelEventHandler);
1906            }
1907        }
1908
1909        _Self.$Selected = function (activate) {
1910            if (activate != undefined) {
1911                _IsSelected = (activate & 2) || (activate & 1);
1912
1913                Highlight();
1914            }
1915            else {
1916                return _IsSelected;
1917            }
1918        };
1919
1920        _Self.$Enable = function (enable) {
1921            if (enable == undefined) {
1922                return !_IsDisabled;
1923            }
1924
1925            _IsDisabled = enable ? 0 : 3;
1926
1927            Highlight();
1928        };
1929
1930        //JssorButtonEx Constructor
1931        {
1932            elmt = _This.$GetElement(elmt);
1933
1934            var originalClassNameArray = $Jssor$.$Split(ClassName(elmt));
1935            if (originalClassNameArray)
1936                _OriginClassName = originalClassNameArray.shift();
1937
1938            Each(_ToggleClassSuffixes, function (toggleClassSuffix) {
1939                _ToggleClasses.push(_OriginClassName +toggleClassSuffix);
1940            });
1941
1942            _ToggleClassName = Join(" ", _ToggleClasses);
1943
1944            _ToggleClasses.unshift("");
1945
1946            _This.$AddEvent(elmt, "mousedown", MouseDownEventHandler);
1947            _This.$AddEvent(elmt, "touchstart", MouseDownEventHandler);
1948        }
1949    }
1950
1951    _This.$Buttonize = function (elmt) {
1952        return new JssorButtonEx(elmt);
1953    };
1954
1955    _This.$Css = Css;
1956    _This.$CssN = CssN;
1957    _This.$CssP = CssP;
1958
1959    _This.$CssOverflow = CssProxy("overflow");
1960
1961    _This.$CssTop = CssProxy("top", 2);
1962    _This.$CssLeft = CssProxy("left", 2);
1963    _This.$CssWidth = CssProxy("width", 2);
1964    _This.$CssHeight = CssProxy("height", 2);
1965    _This.$CssMarginLeft = CssProxy("marginLeft", 2);
1966    _This.$CssMarginTop = CssProxy("marginTop", 2);
1967    _This.$CssPosition = CssProxy("position");
1968    _This.$CssDisplay = CssProxy("display");
1969    _This.$CssZIndex = CssProxy("zIndex", 1);
1970    _This.$CssFloat = function (elmt, floatValue) {
1971        return Css(elmt, IsBrowserIE() ? "styleFloat" : "cssFloat", floatValue);
1972    };
1973    _This.$CssOpacity = function (elmt, opacity, ie9EarlierForce) {
1974        if (opacity != undefined) {
1975            SetStyleOpacity(elmt, opacity, ie9EarlierForce);
1976        }
1977        else {
1978            return GetStyleOpacity(elmt);
1979        }
1980    };
1981
1982    _This.$CssCssText = function (elmt, text) {
1983        if (text != undefined) {
1984            elmt.style.cssText = text;
1985        }
1986        else {
1987            return elmt.style.cssText;
1988        }
1989    };
1990
1991    var _StyleGetter = {
1992        $Opacity: _This.$CssOpacity,
1993        $Top: _This.$CssTop,
1994        $Left: _This.$CssLeft,
1995        $Width: _This.$CssWidth,
1996        $Height: _This.$CssHeight,
1997        $Position: _This.$CssPosition,
1998        $Display: _This.$CssDisplay,
1999        $ZIndex: _This.$CssZIndex
2000    };
2001
2002    var _StyleSetterReserved;
2003
2004    function StyleSetter() {
2005        if (!_StyleSetterReserved) {
2006            _StyleSetterReserved = Extend({
2007                $MarginTop: _This.$CssMarginTop,
2008                $MarginLeft: _This.$CssMarginLeft,
2009                $Clip: _This.$SetStyleClip,
2010                $Transform: _This.$SetStyleTransform
2011            }, _StyleGetter);
2012        }
2013        return _StyleSetterReserved;
2014    }
2015
2016    function StyleSetterEx() {
2017        StyleSetter();
2018
2019        //For Compression Only
2020        _StyleSetterReserved.$Transform = _StyleSetterReserved.$Transform;
2021
2022        return _StyleSetterReserved;
2023    }
2024
2025    _This.$StyleSetter = StyleSetter;
2026
2027    _This.$StyleSetterEx = StyleSetterEx;
2028
2029    _This.$GetStyles = function (elmt, originStyles) {
2030        StyleSetter();
2031
2032        var styles = {};
2033
2034        Each(originStyles, function (value, key) {
2035            if (_StyleGetter[key]) {
2036                styles[key] = _StyleGetter[key](elmt);
2037            }
2038        });
2039
2040        return styles;
2041    };
2042
2043    _This.$SetStyles = function (elmt, styles) {
2044        var styleSetter = StyleSetter();
2045
2046        Each(styles, function (value, key) {
2047            styleSetter[key] && styleSetter[key](elmt, value);
2048        });
2049    };
2050
2051    _This.$SetStylesEx = function (elmt, styles) {
2052        StyleSetterEx();
2053
2054        _This.$SetStyles(elmt, styles);
2055    };
2056
2057    var $JssorMatrix$ = new function () {
2058        var _ThisMatrix = this;
2059
2060        function Multiply(ma, mb) {
2061            var acs = ma[0].length;
2062            var rows = ma.length;
2063            var cols = mb[0].length;
2064
2065            var matrix = [];
2066
2067            for (var r = 0; r < rows; r++) {
2068                var row = matrix[r] = [];
2069                for (var c = 0; c < cols; c++) {
2070                    var unitValue = 0;
2071
2072                    for (var ac = 0; ac < acs; ac++) {
2073                        unitValue += ma[r][ac] * mb[ac][c];
2074                    }
2075
2076                    row[c] = unitValue;
2077                }
2078            }
2079
2080            return matrix;
2081        }
2082
2083        _ThisMatrix.$ScaleX = function (matrix, sx) {
2084            return _ThisMatrix.$ScaleXY(matrix, sx, 0);
2085        };
2086
2087        _ThisMatrix.$ScaleY = function (matrix, sy) {
2088            return _ThisMatrix.$ScaleXY(matrix, 0, sy);
2089        };
2090
2091        _ThisMatrix.$ScaleXY = function (matrix, sx, sy) {
2092            return Multiply(matrix, [[sx, 0], [0, sy]]);
2093        };
2094
2095        _ThisMatrix.$TransformPoint = function (matrix, p) {
2096            var pMatrix = Multiply(matrix, [[p.x], [p.y]]);
2097
2098            return Point(pMatrix[0][0], pMatrix[1][0]);
2099        };
2100    };
2101
2102    _This.$CreateMatrix = function (alpha, scaleX, scaleY) {
2103        var cos = Math.cos(alpha);
2104        var sin = Math.sin(alpha);
2105        //var r11 = cos;
2106        //var r21 = sin;
2107        //var r12 = -sin;
2108        //var r22 = cos;
2109
2110        //var m11 = cos * scaleX;
2111        //var m12 = -sin * scaleY;
2112        //var m21 = sin * scaleX;
2113        //var m22 = cos * scaleY;
2114
2115        return [[cos * scaleX, -sin * scaleY], [sin * scaleX, cos * scaleY]];
2116    };
2117
2118    _This.$GetMatrixOffset = function (matrix, width, height) {
2119        var p1 = $JssorMatrix$.$TransformPoint(matrix, Point(-width / 2, -height / 2));
2120        var p2 = $JssorMatrix$.$TransformPoint(matrix, Point(width / 2, -height / 2));
2121        var p3 = $JssorMatrix$.$TransformPoint(matrix, Point(width / 2, height / 2));
2122        var p4 = $JssorMatrix$.$TransformPoint(matrix, Point(-width / 2, height / 2));
2123
2124        return Point(Math.min(p1.x, p2.x, p3.x, p4.x) + width / 2, Math.min(p1.y, p2.y, p3.y, p4.y) + height / 2);
2125    };
2126
2127    _This.$Cast = function (fromStyles, difStyles, interPosition, easings, durings, rounds, options) {
2128
2129        var currentStyles = difStyles;
2130
2131        if (fromStyles) {
2132            currentStyles = {};
2133
2134            for (var key in difStyles) {
2135
2136                var round = rounds[key] || 1;
2137                var during = durings[key] || [0, 1];
2138                var propertyInterPosition = (interPosition - during[0]) / during[1];
2139                propertyInterPosition = Math.min(Math.max(propertyInterPosition, 0), 1);
2140                propertyInterPosition = propertyInterPosition * round;
2141                var floorPosition = Math.floor(propertyInterPosition);
2142                if (propertyInterPosition != floorPosition)
2143                    propertyInterPosition -= floorPosition;
2144
2145                var easing = easings[key] || easings.$Default || $JssorEasing$.$EaseSwing;
2146                var easingValue = easing(propertyInterPosition);
2147                var currentPropertyValue;
2148                var value = fromStyles[key];
2149                var toValue = difStyles[key];
2150                var difValue = difStyles[key];
2151
2152                if ($Jssor$.$IsNumeric(difValue)) {
2153                    currentPropertyValue = value + difValue * easingValue;
2154                }
2155                else {
2156                    currentPropertyValue = $Jssor$.$Extend({ $Offset: {} }, fromStyles[key]);
2157
2158                    $Jssor$.$Each(difValue.$Offset, function (rectX, n) {
2159                        var offsetValue = rectX * easingValue;
2160                        currentPropertyValue.$Offset[n] = offsetValue;
2161                        currentPropertyValue[n] += offsetValue;
2162                    });
2163                }
2164                currentStyles[key] = currentPropertyValue;
2165            }
2166
2167            if (difStyles.$Zoom || difStyles.$Rotate) {
2168                currentStyles.$Transform = { $Rotate: currentStyles.$Rotate || 0, $Scale: currentStyles.$Zoom, $OriginalWidth: options.$OriginalWidth, $OriginalHeight: options.$OriginalHeight };
2169            }
2170        }
2171
2172        if (difStyles.$Clip && options.$Move) {
2173            var styleFrameNClipOffset = currentStyles.$Clip.$Offset;
2174
2175            var offsetY = (styleFrameNClipOffset.$Top || 0) + (styleFrameNClipOffset.$Bottom || 0);
2176            var offsetX = (styleFrameNClipOffset.$Left || 0) + (styleFrameNClipOffset.$Right || 0
2176);
2177
2178            currentStyles.$Left = (currentStyles.$Left || 0) + offsetX;
2179            currentStyles.$Top = (currentStyles.$Top || 0) + offsetY;
2180            currentStyles.$Clip.$Left -= offsetX;
2181            currentStyles.$Clip.$Right -= offsetX;
2182            currentStyles.$Clip.$Top -= offsetY;
2183            currentStyles.$Clip.$Bottom -= offsetY;
2184        }
2185
2186        if (currentStyles.$Clip && $Jssor$.$CanClearClip() && !currentStyles.$Clip.$Top && !currentStyles.$Clip.$Left && (currentStyles.$Clip.$Right == options.$OriginalWidth) && (currentStyles.$Clip.$Bottom == options.$OriginalHeight))
2187            currentStyles.$Clip = null;
2188
2189        return currentStyles;
2190    };
2191};
2192
2193//$JssorObject$
2194function $JssorObject$() {
2195    var _ThisObject = this;
2196    // Fields
2197
2198    var _Listeners = []; // dictionary of eventName --> array of handlers
2199    var _Listenees = [];
2200
2201    // Private Methods
2202    function AddListener(eventName, handler) {
2203
2204        $JssorDebug$.$Execute(function () {
2205            if (eventName == undefined || eventName == null)
2206                throw new Error("param 'eventName' is null or empty.");
2207
2208            if (typeof (handler) != "function") {
2209                throw "param 'handler' must be a function.";
2210            }
2211
2212            $Jssor$.$Each(_Listeners, function (listener) {
2213                if (listener.$EventName == eventName && listener.$Handler === handler) {
2214                    throw new Error("The handler listened to the event already, cannot listen to the same event of the same object with the same handler twice.");
2215                }
2216            });
2217        });
2218
2219        _Listeners.push({ $EventName: eventName, $Handler: handler });
2220    }
2221
2222    function RemoveListener(eventName, handler) {
2223
2224        $JssorDebug$.$Execute(function () {
2225            if (eventName == undefined || eventName == null)
2226                throw new Error("param 'eventName' is null or empty.");
2227
2228            if (typeof (handler) != "function") {
2229                throw "param 'handler' must be a function.";
2230            }
2231        });
2232
2233        $Jssor$.$Each(_Listeners, function (listener, index) {
2234            if (listener.$EventName == eventName && listener.$Handler === handler) {
2235                _Listeners.splice(index, 1);
2236            }
2237        });
2238    }
2239
2240    function ClearListeners() {
2241        _Listeners = [];
2242    }
2243
2244    function ClearListenees() {
2245
2246        $Jssor$.$Each(_Listenees, function (listenee) {
2247            $Jssor$.$RemoveEvent(listenee.$Obj, listenee.$EventName, listenee.$Handler);
2248        });
2249
2250        _Listenees = [];
2251    }
2252
2253    //Protected Methods
2254    _ThisObject.$Listen = function (obj, eventName, handler, useCapture) {
2255
2256        $JssorDebug$.$Execute(function () {
2257            if (!obj)
2258                throw new Error("param 'obj' is null or empty.");
2259
2260            if (eventName == undefined || eventName == null)
2261                throw new Error("param 'eventName' is null or empty.");
2262
2263            if (typeof (handler) != "function") {
2264                throw "param 'handler' must be a function.";
2265            }
2266
2267            $Jssor$.$Each(_Listenees, function (listenee) {
2268                if (listenee.$Obj === obj && listenee.$EventName == eventName && listenee.$Handler === handler) {
2269                    throw new Error("The handler listened to the event already, cannot listen to the same event of the same object with the same handler twice.");
2270                }
2271            });
2272        });
2273
2274        $Jssor$.$AddEvent(obj, eventName, handler, useCapture);
2275        _Listenees.push({ $Obj: obj, $EventName: eventName, $Handler: handler });
2276    };
2277
2278    _ThisObject.$Unlisten = function (obj, eventName, handler) {
2279
2280        $JssorDebug$.$Execute(function () {
2281            if (!obj)
2282                throw new Error("param 'obj' is null or empty.");
2283
2284            if (eventName == undefined || eventName == null)
2285                throw new Error("param 'eventName' is null or empty.");
2286
2287            if (typeof (handler) != "function") {
2288                throw "param 'handler' must be a function.";
2289            }
2290        });
2291
2292        $Jssor$.$Each(_Listenees, function (listenee, index) {
2293            if (listenee.$Obj === obj && listenee.$EventName == eventName && listenee.$Handler === handler) {
2294                $Jssor$.$RemoveEvent(obj, eventName, handler);
2295                _Listenees.splice(index, 1);
2296            }
2297        });
2298    };
2299
2300    _ThisObject.$UnlistenAll = ClearListenees;
2301
2302    // Public Methods
2303    _ThisObject.$On = _ThisObject.addEventListener = AddListener;
2304
2305    _ThisObject.$Off = _ThisObject.removeEventListener = RemoveListener;
2306
2307    _ThisObject.$TriggerEvent = function (eventName) {
2308
2309        var args = [].slice.call(arguments, 1);
2310
2311        $Jssor$.$Each(_Listeners, function (listener) {
2312            listener.$EventName == eventName && listener.$Handler.apply(window, args);
2313        });
2314    };
2315
2316    _ThisObject.$Destroy = function () {
2317        ClearListenees();
2318        ClearListeners();
2319
2320        for (var name in _ThisObject)
2321            delete _ThisObject[name];
2322    };
2323
2324    $JssorDebug$.$C_AbstractClass(_ThisObject);
2325};
2326
2327function $JssorAnimator$(delay, duration, options, elmt, fromStyles, difStyles) {
2328    delay = delay || 0;
2329
2330    var _ThisAnimator = this;
2331    var _AutoPlay;
2332    var _Hiden;
2333    var _CombineMode;
2334    var _PlayToPosition;
2335    var _PlayDirection;
2336    var _NoStop;
2337    var _TimeStampLastFrame = 0;
2338
2339    var _SubEasings;
2340    var _SubRounds;
2341    var _SubDurings;
2342    var _Callback;
2343
2344    var _Shift = 0;
2345    var _Position_Current = 0;
2346    var _Position_Display = 0;
2347    var _Hooked;
2348
2349    var _Position_InnerBegin = delay;
2350    var _Position_InnerEnd = delay + duration;
2351    var _Position_OuterBegin;
2352    var _Position_OuterEnd;
2353    var _LoopLength;
2354
2355    var _NestedAnimators = [];
2356    var _StyleSetter;
2357
2358    function GetPositionRange(position, begin, end) {
2359        var range = 0;
2360
2361        if (position < begin)
2362            range = -1;
2363
2364        else if (position > end)
2365            range = 1;
2366
2367        return range;
2368    }
2369
2370    function GetInnerPositionRange(position) {
2371        return GetPositionRange(position, _Position_InnerBegin, _Position_InnerEnd);
2372    }
2373
2374    function GetOuterPositionRange(position) {
2375        return GetPositionRange(position, _Position_OuterBegin, _Position_OuterEnd);
2376    }
2377
2378    function Shift(offset) {
2379        _Position_OuterBegin += offset;
2380        _Position_OuterEnd += offset;
2381        _Position_InnerBegin += offset;
2382        _Position_InnerEnd += offset;
2383
2384        _Position_Current += offset;
2385        _Position_Display += offset;
2386
2387        _Shift = offset;
2388    }
2389
2390    function Locate(position, relative) {
2391        var offset = position - _Position_OuterBegin + delay * relative;
2392
2393        Shift(offset);
2394
2395        //$JssorDebug$.$Execute(function () {
2396        //    _ThisAnimator.$Position_InnerBegin = _Position_InnerBegin;
2397        //    _ThisAnimator.$Position_InnerEnd = _Position_InnerEnd;
2398        //    _ThisAnimator.$Position_OuterBegin = _Position_OuterBegin;
2399        //    _ThisAnimator.$Position_OuterEnd = _Position_OuterEnd;
2400        //});
2401
2402        return _Position_OuterEnd;
2403    }
2404
2405    function GoToPosition(positionOuter, force) {
2406        var trimedPositionOuter = positionOuter;
2407
2408        if (_LoopLength && (trimedPositionOuter >= _Position_OuterEnd || trimedPositionOuter <= _Position_OuterBegin)) {
2409            trimedPositionOuter = ((trimedPositionOuter - _Position_OuterBegin) % _LoopLength + _LoopLength) % _LoopLength + _Position_OuterBegin;
2410        }
2411
2412        if (!_Hooked || _NoStop || force || _Position_Current != trimedPositionOuter) {
2413
2414            var positionToDisplay = Math.min(trimedPositionOuter, _Position_OuterEnd);
2415            positionToDisplay = Math.max(positionToDisplay, _Position_OuterBegin);
2416
2417            if (!_Hooked || _NoStop || force || positionToDisplay != _Position_Display) {
2418
2419                if (difStyles) {
2420
2421                    var interPosition = (positionToDisplay - _Position_InnerBegin) / (duration || 1);
2422
2423                    if (options.$Reverse)
2424                        interPosition = 1 - interPosition;
2425
2426                    var currentStyles = $Jssor$.$Cast(fromStyles, difStyles, interPosition, _SubEasings, _SubDurings, _SubRounds, options);
2427
2428                    $Jssor$.$Each(currentStyles, function (value, key) {
2429                        _StyleSetter[key] && _StyleSetter[key](elmt, value);
2430                    });
2431                }
2432
2433                _ThisAnimator.$OnInnerOffsetChange(_Position_Display - _Position_InnerBegin, positionToDisplay - _Position_InnerBegin);
2434
2435                _Position_Display = positionToDisplay;
2436
2437                $Jssor$.$Each(_NestedAnimators, function (animator, i) {
2438                    var nestedAnimator = positionOuter < _Position_Current ? _NestedAnimators[_NestedAnimators.length - i - 1] : animator;
2439                    nestedAnimator.$GoToPosition(_Position_Display - _Shift, force);
2440                });
2441
2442                var positionOld = _Position_Current;
2443                var positionNew = _Position_Display;
2444
2445                _Position_Current = trimedPositionOuter;
2446                _Hooked = true;
2447
2448                _ThisAnimator.$OnPositionChange(positionOld, positionNew);
2449            }
2450        }
2451    }
2452
2453    function Join(animator, combineMode, noExpand) {
2454        ///	<summary>
2455        ///		Combine another animator as nested animator
2456        ///	</summary>
2457        ///	<param name="animator" type="$JssorAnimator$">
2458        ///		An instance of $JssorAnimator$
2459        ///	</param>
2460        ///	<param name="combineMode" type="int">
2461        ///		0: parallel - place the animator parallel to this animator.
2462        ///		1: chain - chain the animator at the _Position_InnerEnd of this animator.
2463        ///	</param>
2464        $JssorDebug$.$Execute(function () {
2465            if (combineMode !== 0 && combineMode !== 1)
2466                $JssorDebug$.$Fail("Argument out of range, the value of 'combineMode' should be either 0 or 1.");
2467        });
2468
2469        if (combineMode)
2470            animator.$Locate(_Position_OuterEnd, 1);
2471
2472        if (!noExpand) {
2473            _Position_OuterBegin = Math.min(_Position_OuterBegin, animator.$GetPosition_OuterBegin() + _Shift);
2474            _Position_OuterEnd = Math.max(_Position_OuterEnd, animator.$GetPosition_OuterEnd() + _Shift);
2475        }
2476        _NestedAnimators.push(animator);
2477    }
2478
2479    var RequestAnimationFrame = window.requestAnimationFrame
2480    || window.webkitRequestAnimationFrame
2481    || window.mozRequestAnimationFrame
2482    || window.msRequestAnimationFrame;
2483
2484    if ($Jssor$.$IsBrowserSafari() && $Jssor$.$BrowserVersion() < 7) {
2485        RequestAnimationFrame = null;
2486
2487        //$JssorDebug$.$Log("Custom animation frame for safari before 7.");
2488    }
2489
2490    RequestAnimationFrame = RequestAnimationFrame || function (callback) {
2491        $Jssor$.$Delay(callback, options.$Interval);
2492    };
2493
2494    function ShowFrame() {
2495        if (_AutoPlay) {
2496            var now = $Jssor$.$GetNow();
2497            var timeOffset = Math.min(now - _TimeStampLastFrame, options.$IntervalMax);
2498            var timePosition = _Position_Current + timeOffset * _PlayDirection;
2499            _TimeStampLastFrame = now;
2500
2501            if (timePosition * _PlayDirection >= _PlayToPosition * _PlayDirection)
2502                timePosition = _PlayToPosition;
2503
2504            GoToPosition(timePosition);
2505
2506            if (!_NoStop && timePosition * _PlayDirection >= _PlayToPosition * _PlayDirection) {
2507                Stop(_Callback);
2508            }
2509            else {
2510                RequestAnimationFrame(ShowFrame);
2511            }
2512        }
2513    }
2514
2515    function PlayToPosition(toPosition, callback, noStop) {
2516        if (!_AutoPlay) {
2517            _AutoPlay = true;
2518            _NoStop = noStop
2519            _Callback = callback;
2520            toPosition = Math.max(toPosition, _Position_OuterBegin);
2521            toPosition = Math.min(toPosition, _Position_OuterEnd);
2522            _PlayToPosition = toPosition;
2523            _PlayDirection = _PlayToPosition < _Position_Current ? -1 : 1;
2524            _ThisAnimator.$OnStart();
2525            _TimeStampLastFrame = $Jssor$.$GetNow();
2526            RequestAnimationFrame(ShowFrame);
2527        }
2528    }
2529
2530    function Stop(callback) {
2531        if (_AutoPlay) {
2532            _NoStop = _AutoPlay = _Callback = false;
2533            _ThisAnimator.$OnStop();
2534
2535            if (callback)
2536                callback();
2537        }
2538    }
2539
2540    _ThisAnimator.$Play = function (positionLength, callback, noStop) {
2541        PlayToPosition(positionLength ? _Position_Current + positionLength : _Position_OuterEnd, callback, noStop);
2542    };
2543
2544    _ThisAnimator.$PlayToPosition = PlayToPosition;
2545
2546    _ThisAnimator.$PlayToBegin = function (callback, noStop) {
2547        PlayToPosition(_Position_OuterBegin, callback, noStop);
2548    };
2549
2550    _ThisAnimator.$PlayToEnd = function (callback, noStop) {
2551        PlayToPosition(_Position_OuterEnd, callback, noStop);
2552    };
2553
2554    _ThisAnimator.$Stop = Stop;
2555
2556    _ThisAnimator.$Continue = function (toPosition) {
2557        PlayToPosition(toPosition);
2558    };
2559
2560    _ThisAnimator.$GetPosition = function () {
2561        return _Position_Current;
2562    };
2563
2564    _ThisAnimator.$GetPlayToPosition = function () {
2565        return _PlayToPosition;
2566    };
2567
2568    _ThisAnimator.$GetPosition_Display = function () {
2569        return _Position_Display;
2570    };
2571
2572    _ThisAnimator.$GoToPosition = GoToPosition;
2573
2574    _ThisAnimator.$GoToBegin = function () {
2575        GoToPosition(_Position_OuterBegin, true);
2576    };
2577
2578    _ThisAnimator.$GoToEnd = function () {
2579        GoToPosition(_Position_OuterEnd, true);
2580    };
2581
2582    _ThisAnimator.$Move = function (offset) {
2583        GoToPosition(_Position_Current + offset);
2584    };
2585
2586    _ThisAnimator.$CombineMode = function () {
2587        return _CombineMode;
2588    };
2589
2590    _ThisAnimator.$GetDuration = function () {
2591        return duration;
2592    };
2593
2594    _ThisAnimator.$IsPlaying = function () {
2595        return _AutoPlay;
2596    };
2597
2598    _ThisAnimator.$IsOnTheWay = function () {
2599        return _Position_Current > _Position_InnerBegin && _Position_Current <= _Position_InnerEnd;
2600    };
2601
2602    _ThisAnimator.$SetLoopLength = function (length) {
2603        _LoopLength = length;
2604    };
2605
2606    _ThisAnimator.$Locate = Locate;
2607
2608    _ThisAnimator.$Shift = Shift;
2609
2610    _ThisAnimator.$Join = Join;
2611
2612    _ThisAnimator.$Combine = function (animator) {
2613        ///	<summary>
2614        ///		Combine another animator parallel to this animator
2615        ///	</summary>
2616        ///	<param name="animator" type="$JssorAnimator$">
2617        ///		An instance of $JssorAnimator$
2618        ///	</param>
2619        Join(animator, 0);
2620    };
2621
2622    _ThisAnimator.$Chain = function (animator) {
2623        ///	<summary>
2624        ///		Chain another animator at the _Position_InnerEnd of this animator
2625        ///	</summary>
2626        ///	<param name="animator" type="$JssorAnimator$">
2627        ///		An instance of $JssorAnimator$
2628        ///	</param>
2629        Join(animator, 1);
2630    };
2631
2632    _ThisAnimator.$GetPosition_InnerBegin = function () {
2633        ///	<summary>
2634        ///		Internal member function, do not use it.
2635        ///	</summary>
2636        ///	<private />
2637        ///	<returns type="int" />
2638        return _Position_InnerBegin;
2639    };
2640
2641    _ThisAnimator.$GetPosition_InnerEnd = function () {
2642        ///	<summary>
2643        ///		Internal member function, do not use it.
2644        ///	</summary>
2645        ///	<private />
2646        ///	<returns type="int" />
2647        return _Position_InnerEnd;
2648    };
2649
2650    _ThisAnimator.$GetPosition_OuterBegin = function () {
2651        ///	<summary>
2652        ///		Internal member function, do not use it.
2653        ///	</summary>
2654        ///	<private />
2655        ///	<returns type="int" />
2656        return _Position_OuterBegin;
2657    };
2658
2659    _ThisAnimator.$GetPosition_OuterEnd = function () {
2660        ///	<summary>
2661        ///		Internal member function, do not use it.
2662        ///	</summary>
2663        ///	<private />
2664        ///	<returns type="int" />
2665        return _Position_OuterEnd;
2666    };
2667
2668    _ThisAnimator.$OnPositionChange = _ThisAnimator.$OnStart = _ThisAnimator.$OnStop = _ThisAnimator.$OnInnerOffsetChange = $Jssor$.$EmptyFunction;
2669    _ThisAnimator.$Version = $Jssor$.$GetNow();
2670
2671    //Constructor  1
2672    {
2673        options = $Jssor$.$Extend({
2674            $Interval: 16,
2675            $IntervalMax: 50
2676        }, options);
2677
2678        //Sodo statement, for development time intellisence only
2679        $JssorDebug$.$Execute(function () {
2680            options = $Jssor$.$Extend({
2681                $LoopLength: undefined,
2682                $Setter: undefined,
2683                $Easing: undefined
2684            }, options);
2685        });
2686
2687        _LoopLength = options.$LoopLength;
2688
2689        _StyleSetter = $Jssor$.$Extend({}, $Jssor$.$StyleSetter(), options.$Setter);
2690
2691        _Position_OuterBegin = _Position_InnerBegin = delay;
2692        _Position_OuterEnd = _Position_InnerEnd = delay + duration;
2693
2694        _SubRounds = options.$Round || {};
2695        _SubDurings = options.$During || {};
2696        _SubEasings = $Jssor$.$Extend({ $Default: $Jssor$.$IsFunction(options.$Easing) && options.$Easing || $JssorEasing$.$EaseSwing }, options.$Easing);
2697    }
2698};
2699
2700function $JssorPlayerClass$() {
2701
2702    var _ThisPlayer = this;
2703    var _PlayerControllers = [];
2704
2705    function PlayerController(playerElement) {
2706        var _SelfPlayerController = this;
2707        var _PlayerInstance;
2708        var _PlayerInstantces = [];
2709
2710        function OnPlayerInstanceDataAvailable(event) {
2711            var srcElement = $Jssor$.$EvtSrc(event);
2712            _PlayerInstance = srcElement.pInstance;
2713
2714            $Jssor$.$RemoveEvent(srcElement, "dataavailable", OnPlayerInstanceDataAvailable);
2715            $Jssor$.$Each(_PlayerInstantces, function (playerInstance) {
2716                if (playerInstance != _PlayerInstance) {
2717                    playerInstance.$Remove();
2718                }
2719            });
2720
2721            playerElement.pTagName = _PlayerInstance.tagName;
2722            _PlayerInstantces = null;
2723        }
2724
2725        function HandlePlayerInstance(playerInstanceElement) {
2726            var playerHandler;
2727
2728            if (!playerInstanceElement.pInstance) {
2729                var playerHandlerAttribute = $Jssor$.$AttributeEx(playerInstanceElement, "pHandler");
2730
2731                if ($JssorPlayer$[playerHandlerAttribute]) {
2732                    $Jssor$.$AddEvent(playerInstanceElement, "dataavailable", OnPlayerInstanceDataAvailable);
2733                    playerHandler = new $JssorPlayer$[playerHandlerAttribute](playerElement, playerInstanceElement);
2734                    _PlayerInstantces.push(playerHandler);
2735
2736                    $JssorDebug$.$Execute(function () {
2737                        if ($Jssor$.$Type(playerHandler.$Remove) != "function") {
2738                            $JssorDebug$.$Fail("'pRemove' interface not implemented for player handler '" + playerHandlerAttribute + "'.");
2739                        }
2740                    });
2741                }
2742            }
2743
2744            return playerHandler;
2745        }
2746
2747        _SelfPlayerController.$InitPlayerController = function () {
2748            if (!playerElement.pInstance && !HandlePlayerInstance(playerElement)) {
2749
2750                var playerInstanceElements = $Jssor$.$Children(playerElement);
2751
2752                $Jssor$.$Each(playerInstanceElements, function (playerInstanceElement) {
2753                    HandlePlayerInstance(playerInstanceElement);
2754                });
2755            }
2756        };
2757    }
2758
2759    _ThisPlayer.$EVT_SWITCH = 21;
2760
2761    _ThisPlayer.$FetchPlayers = function (elmt) {
2762        elmt = elmt || document.body;
2763
2764        var playerElements = $Jssor$.$FindChildren(elmt, "player");
2765
2766        $Jssor$.$Each(playerElements, function (playerElement) {
2767            if (!_PlayerControllers[playerElement.pId]) {
2768                playerElement.pId = _PlayerControllers.length;
2769                _PlayerControllers.push(new PlayerController(playerElement));
2770            }
2771            var playerController = _PlayerControllers[playerElement.pId];
2772            playerController.$InitPlayerController();
2773        });
2774    };
2775}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.