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