1/// <reference path="Jssor.Core.js" /> 2/// <reference path="Jssor.Utils.js" /> 3 4/* 5* Jssor.Slider 17.0 6* http://www.jssor.com/ 7* 8* TERMS OF USE - Jssor.Slider 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 32var $JssorSlider$; 33var $JssorSlideshowFormations$ = window.$JssorSlideshowFormations$ = {}; 34var $JssorSlideshowRunner$; 35 36new function () { 37 //Constants +++++++ 38 39 var COLUMN_INCREASE = 0; 40 var COLUMN_DECREASE = 1; 41 var ROW_INCREASE = 2; 42 var ROW_DECREASE = 3; 43 44 var DIRECTION_HORIZONTAL = 0x0003; 45 var DIRECTION_VERTICAL = 0x000C; 46 47 var TO_LEFT = 0x0001; 48 var TO_RIGHT = 0x0002; 49 var TO_TOP = 0x0004; 50 var TO_BOTTOM = 0x0008; 51 52 var FROM_LEFT = 0x0100; 53 var FROM_TOP = 0x0200; 54 var FROM_RIGHT = 0x0400; 55 var FROM_BOTTOM = 0x0800; 56 57 var ASSEMBLY_BOTTOM_LEFT = FROM_BOTTOM + TO_LEFT; 58 var ASSEMBLY_BOTTOM_RIGHT = FROM_BOTTOM + TO_RIGHT; 59 var ASSEMBLY_TOP_LEFT = FROM_TOP + TO_LEFT; 60 var ASSEMBLY_TOP_RIGHT = FROM_TOP + TO_RIGHT; 61 var ASSEMBLY_LEFT_TOP = FROM_LEFT + TO_TOP; 62 var ASSEMBLY_LEFT_BOTTOM = FROM_LEFT + TO_BOTTOM; 63 var ASSEMBLY_RIGHT_TOP = FROM_RIGHT + TO_TOP; 64 var ASSEMBLY_RIGHT_BOTTOM = FROM_RIGHT + TO_BOTTOM; 65 66 //Constants ------- 67 68 //Formation Definition +++++++ 69 function isToLeft(roadValue) { 70 return (roadValue & TO_LEFT) == TO_LEFT; 71 } 72 73 function isToRight(roadValue) { 74 return (roadValue & TO_RIGHT) == TO_RIGHT; 75 } 76 77 function isToTop(roadValue) { 78 return (roadValue & TO_TOP) == TO_TOP; 79 } 80 81 function isToBottom(roadValue) { 82 return (roadValue & TO_BOTTOM) == TO_BOTTOM; 83 } 84 85 function PushFormationOrder(arr, order, formationItem) { 86 formationItem.push(order); 87 arr[order] = arr[order] || []; 88 arr[order].push(formationItem); 89 } 90 91 $JssorSlideshowFormations$.$FormationStraight = function (transition) { 92 var cols = transition.$Cols; 93 var rows = transition.$Rows; 94 var formationDirection = transition.$Assembly; 95 var count = transition.$Count; 96 var a = []; 97 var i = 0; 98 var col = 0; 99 var r = 0; 100 var cl = cols - 1; 101 var rl = rows - 1; 102 var il = count - 1; 103 var cr; 104 var order; 105 for (r = 0; r < rows; r++) { 106 for (col = 0; col < cols; col++) { 107 cr = r + ',' + col; 108 switch (formationDirection) { 109 case ASSEMBLY_BOTTOM_LEFT: 110 order = il - (col * rows + (rl - r)); 111 break; 112 case ASSEMBLY_RIGHT_TOP: 113 order = il - (r * cols + (cl - col)); 114 break; 115 case ASSEMBLY_TOP_LEFT: 116 order = il - (col * rows + r); 117 case ASSEMBLY_LEFT_TOP: 118 order = il - (r * cols + col); 119 break; 120 case ASSEMBLY_BOTTOM_RIGHT: 121 order = col * rows + r; 122 break; 123 case ASSEMBLY_LEFT_BOTTOM: 124 order = r * cols + (cl - col); 125 break; 126 case ASSEMBLY_TOP_RIGHT: 127 order = col * rows + (rl - r); 128 break; 129 default: 130 order = r * cols + col; 131 break; //ASSEMBLY_RIGHT_BOTTOM 132 } 133 PushFormationOrder(a, order, [r, col]); 134 } 135 } 136 137 return a; 138 }; 139 140 $JssorSlideshowFormations$.$FormationSwirl = function (transition) { 141 var cols = transition.$Cols; 142 var rows = transition.$Rows; 143 var formationDirection = transition.$Assembly; 144 var count = transition.$Count; 145 var a = []; 146 var hit = []; 147 var i = 0; 148 var col = 0; 149 var r = 0; 150 var cl = cols - 1; 151 var rl = rows - 1; 152 var il = count - 1; 153 var cr; 154 var courses; 155 var course = 0; 156 switch (formationDirection) { 157 case ASSEMBLY_BOTTOM_LEFT: 158 col = cl; 159 r = 0;
160 courses = [ROW_INCREASE, COLUMN_DECREASE, ROW_DECREASE, COLUMN_INCREASE]; 161 break; 162 case ASSEMBLY_RIGHT_TOP: 163 col = 0; 164 r = rl; 165 courses = [COLUMN_INCREASE, ROW_DECREASE, COLUMN_DECREASE, ROW_INCREASE]; 166 break; 167 case ASSEMBLY_TOP_LEFT: 168 col = cl; 169 r = rl; 170 courses = [ROW_DECREASE, COLUMN_DECREASE, ROW_INCREASE, COLUMN_INCREASE]; 171 break; 172 case ASSEMBLY_LEFT_TOP: 173 col = cl; 174 r = rl; 175 courses = [COLUMN_DECREASE, ROW_DECREASE, COLUMN_INCREASE, ROW_INCREASE]; 176 break; 177 case ASSEMBLY_BOTTOM_RIGHT: 178 col = 0; 179 r = 0; 180 courses = [ROW_INCREASE, COLUMN_INCREASE, ROW_DECREASE, COLUMN_DECREASE]; 181 break; 182 case ASSEMBLY_LEFT_BOTTOM: 183 col = cl; 184 r = 0; 185 courses = [COLUMN_DECREASE, ROW_INCREASE, COLUMN_INCREASE, ROW_DECREASE]; 186 break; 187 case ASSEMBLY_TOP_RIGHT: 188 col = 0; 189 r = rl; 190 courses = [ROW_DECREASE, COLUMN_INCREASE, ROW_INCREASE, COLUMN_DECREASE]; 191 break; 192 default: 193 col = 0; 194 r = 0; 195 courses = [COLUMN_INCREASE, ROW_INCREASE, COLUMN_DECREASE, ROW_DECREASE]; 196 break; //ASSEMBLY_RIGHT_BOTTOM 197 } 198 i = 0; 199 while (i < count) { 200 cr = r + ',' + col; 201 if (col >= 0 && col < cols && r >= 0 && r < rows && !hit[cr]) { 202 //a[cr] = i++; 203 hit[cr] = true; 204 PushFormationOrder(a, i++, [r, col]); 205 } 206 else { 207 switch (courses[course++ % courses.length]) { 208 case COLUMN_INCREASE: 209 col--; 210 break; 211 case ROW_INCREASE: 212 r--; 213 break; 214 case COLUMN_DECREASE: 215 col++; 216 break; 217 case ROW_DECREASE: 218 r++; 219 break; 220 } 221 } 222 223 switch (courses[course % courses.length]) { 224 case COLUMN_INCREASE: 225 col++; 226 break; 227 case ROW_INCREASE: 228 r++; 229 break; 230 case COLUMN_DECREASE: 231 col--; 232 break; 233 case ROW_DECREASE: 234 r--; 235 break; 236 } 237 } 238 return a; 239 }; 240 241 $JssorSlideshowFormations$.$FormationZigZag = function (transition) { 242 var cols = transition.$Cols; 243 var rows = transition.$Rows; 244 var formationDirection = transition.$Assembly; 245 var count = transition.$Count; 246 var a = []; 247 var i = 0; 248 var col = 0; 249 var r = 0; 250 var cl = cols - 1; 251 var rl = rows - 1; 252 var il = count - 1; 253 var cr; 254 var courses; 255 var course = 0; 256 switch (formationDirection) { 257 case ASSEMBLY_BOTTOM_LEFT: 258 col = cl; 259 r = 0; 260 courses = [ROW_INCREASE, COLUMN_DECREASE, ROW_DECREASE, COLUMN_DECREASE]; 261 break; 262 case ASSEMBLY_RIGHT_TOP: 263 col = 0; 264 r = rl; 265 courses = [COLUMN_INCREASE, ROW_DECREASE, COLUMN_DECREASE, ROW_DECREASE]; 266 break; 267 case ASSEMBLY_TOP_LEFT: 268 col = cl; 269 r = rl; 270 courses = [ROW_DECREASE, COLUMN_DECREASE, ROW_INCREASE, COLUMN_DECREASE]; 271 break; 272 case ASSEMBLY_LEFT_TOP: 273 col = cl; 274 r = rl; 275 courses = [COLUMN_DECREASE, ROW_DECREASE, COLUMN_INCREASE, ROW_DECREASE]; 276 break; 277 case ASSEMBLY_BOTTOM_RIGHT: 278 col = 0; 279 r = 0;
280 courses = [ROW_INCREASE, COLUMN_INCREASE, ROW_DECREASE, COLUMN_INCREASE]; 281 break; 282 case ASSEMBLY_LEFT_BOTTOM: 283 col = cl; 284 r = 0; 285 courses = [COLUMN_DECREASE, ROW_INCREASE, COLUMN_INCREASE, ROW_INCREASE]; 286 break; 287 case ASSEMBLY_TOP_RIGHT: 288 col = 0; 289 r = rl; 290 courses = [ROW_DECREASE, COLUMN_INCREASE, ROW_INCREASE, COLUMN_INCREASE]; 291 break; 292 default: 293 col = 0; 294 r = 0; 295 courses = [COLUMN_INCREASE, ROW_INCREASE, COLUMN_DECREASE, ROW_INCREASE]; 296 break; //ASSEMBLY_RIGHT_BOTTOM 297 } 298 i = 0; 299 while (i < count) { 300 cr = r + ',' + col; 301 if (col >= 0 && col < cols && r >= 0 && r < rows && typeof (a[cr]) == 'undefined') { 302 PushFormationOrder(a, i++, [r, col]); 303 //a[cr] = i++; 304 switch (courses[course % courses.length]) { 305 case COLUMN_INCREASE: 306 col++; 307 break; 308 case ROW_INCREASE: 309 r++; 310 break; 311 case COLUMN_DECREASE: 312 col--; 313 break; 314 case ROW_DECREASE: 315 r--; 316 break; 317 } 318 } 319 else { 320 switch (courses[course++ % courses.length]) { 321 case COLUMN_INCREASE: 322 col--; 323 break; 324 case ROW_INCREASE: 325 r--; 326 break; 327 case COLUMN_DECREASE: 328 col++; 329 break; 330 case ROW_DECREASE: 331 r++; 332 break; 333 } 334 switch (courses[course++ % courses.length]) { 335 case COLUMN_INCREASE: 336 col++; 337 break; 338 case ROW_INCREASE: 339 r++; 340 break; 341 case COLUMN_DECREASE: 342 col--; 343 break; 344 case ROW_DECREASE: 345 r--; 346 break; 347 } 348 } 349 } 350 return a; 351 }; 352 353 $JssorSlideshowFormations$.$FormationStraightStairs = function (transition) { 354 var cols = transition.$Cols; 355 var rows = transition.$Rows; 356 var formationDirection = transition.$Assembly; 357 var count = transition.$Count; 358 var a = []; 359 var i = 0; 360 var col = 0; 361 var r = 0; 362 var cl = cols - 1; 363 var rl = rows - 1; 364 var il = count - 1; 365 var cr; 366 switch (formationDirection) { 367 case ASSEMBLY_BOTTOM_LEFT: 368 case ASSEMBLY_TOP_RIGHT: 369 case ASSEMBLY_TOP_LEFT: 370 case ASSEMBLY_BOTTOM_RIGHT: 371 var C = 0; 372 var R = 0; 373 break; 374 case ASSEMBLY_LEFT_BOTTOM: 375 case ASSEMBLY_RIGHT_TOP: 376 case ASSEMBLY_LEFT_TOP: 377 case ASSEMBLY_RIGHT_BOTTOM: 378 var C = cl; 379 var R = 0; 380 break; 381 default: 382 formationDirection = ASSEMBLY_RIGHT_BOTTOM; 383 var C = cl; 384 var R = 0; 385 break; 386 } 387 col = C; 388 r = R; 389 while (i < count) { 390 cr = r + ',' + col; 391 if (isToTop(formationDirection) || isToRight(formationDirection)) { 392 PushFormationOrder(a, il - i++, [r, col]); 393 //a[cr] = il - i++; 394 } 395 else { 396 PushFormationOrder(a, i++, [r, col]); 397 //a[cr] = i++; 398 } 399 switch (formationDirection) { 400 case ASSEMBLY_BOTTOM_LEFT: 401 case ASSEMBLY_TOP_RIGHT: 402 col--; 403 r++; 404 break; 405 case ASSEMBLY_TOP_LEFT: 406 case ASSEMBLY_BOTTOM_RIGHT: 407 col++; 408 r--; 409 break; 410 case ASSEMBLY_LEFT_BOTTOM: 411 case ASSEMBLY_RIGHT_TOP: 412 col--; 413 r--; 414 break; 415 case ASSEMBLY_RIGHT_BOTTOM: 416 case ASSEMBLY_LEFT_TOP: 417 default: 418 col++; 419 r++; 420 break; 421 } 422 if (col < 0 || r < 0 || col > cl || r > rl) { 423 switch (formationDirection) { 424 case ASSEMBLY_BOTTOM_LEFT: 425 case ASSEMBLY_TOP_RIGHT: 426 C++; 427 break; 428 case ASSEMBLY_LEFT_BOTTOM: 429 case ASSEMBLY_RIGHT_TOP: 430 case ASSEMBLY_TOP_LEFT: 431 case ASSEMBLY_BOTTOM_RIGHT: 432 R++; 433 break; 434 case ASSEMBLY_RIGHT_BOTTOM: 435 case ASSEMBLY_LEFT_TOP: 436 default: 437 C--; 438 break; 439 } 440 if (C < 0 || R < 0 || C > cl || R > rl) { 441 switch (formationDirection) { 442 case ASSEMBLY_BOTTOM_LEFT: 443 case ASSEMBLY_TOP_RIGHT: 444 C = cl; 445 R++; 446 break; 447 case ASSEMBLY_TOP_LEFT: 448 case ASSEMBLY_BOTTOM_RIGHT: 449 R = rl; 450 C++; 451 break; 452 case ASSEMBLY_LEFT_BOTTOM: 453 case ASSEMBLY_RIGHT_TOP: R = rl; C--; 454 break; 455 case ASSEMBLY_RIGHT_BOTTOM: 456 case ASSEMBLY_LEFT_TOP: 457 default: 458 C = 0; 459 R++; 460 break; 461 } 462 if (R > rl) 463 R = rl; 464 else if (R < 0) 465 R = 0; 466 else if (C > cl) 467 C = cl; 468 else if (C < 0) 469 C = 0; 470 } 471 r = R; 472 col = C; 473 } 474 } 475 return a; 476 }; 477 478 $JssorSlideshowFormations$.$FormationSquare = function (transition) { 479 var cols = transition.$Cols || 1; 480 var rows = transition.$Rows || 1; 481 var arr = []; 482 var i = 0; 483 var col; 484 var r; 485 var dc; 486 var dr; 487 var cr; 488 dc = cols < rows ? (rows - cols) / 2 : 0; 489 dr = cols > rows ? (cols - rows) / 2 : 0; 490 cr = Math.round(Math.max(cols / 2, rows / 2)) + 1; 491 for (col = 0; col < cols; col++) { 492 for (r = 0; r < rows; r++) 493 PushFormationOrder(arr, cr - Math.min(col + 1 + dc, r + 1 + dr, cols - col + dc, rows - r + dr), [r, col]); 494 } 495 return arr; 496 }; 497 498 $JssorSlideshowFormations$.$FormationRectangle = function (transition) { 499 var cols = transition.$Cols || 1; 500 var rows = transition.$Rows || 1; 501 var arr = []; 502 var i = 0; 503 var col; 504 var r; 505 var cr; 506 cr = Math.round(Math.min(cols / 2, rows / 2)) + 1; 507 for (col = 0; col < cols; col++) { 508 for (r = 0; r < rows; r++) 509 PushFormationOrder(arr, cr - Math.min(col + 1, r + 1, cols - col, rows - r), [r, col]); 510 } 511 return arr; 512 }; 513 514 $JssorSlideshowFormations$.$FormationRandom = function (transition) { 515 var a = []; 516 var r, col, i; 517 for (r = 0; r < transition.$Rows; r++) { 518 for (col = 0; col < transition.$Cols; col++) 519 PushFormationOrder(a, Math.ceil(100000 * Math.random()) % 13, [r, col]); 520 } 521 522 return a; 523 }; 524 525 $JssorSlideshowFormations$.$FormationCircle = function (transition) { 526 var cols = transition.$Cols || 1; 527 var rows = transition.$Rows || 1; 528 var arr = []; 529 var i = 0; 530 var col; 531 var r; 532 var hc = cols / 2 - 0.5; 533 var hr = rows / 2 - 0.5; 534 for (col = 0; col < cols; col++) { 535 for (r = 0; r < rows; r++) 536 PushFormationOrder(arr, Math.round(Math.sqrt(Math.pow(col - hc, 2) + Math.pow(r - hr, 2))), [r, col]); 537 } 538 return arr; 539 }; 540 541 $JssorSlideshowFormations$.$FormationCross = function (transition) { 542 var cols = transition.$Cols || 1; 543 var rows = transition.$Rows || 1; 544 var arr = []; 545 var i = 0; 546 var col; 547 var r; 548 var hc = cols / 2 - 0.5; 549 var hr = rows / 2 - 0.5; 550 for (col = 0; col < cols; col++) { 551 for (r = 0; r < rows; r++) 552 PushFormationOrder(arr, Math.round(Math.min(Math.abs(col - hc), Math.abs(r - hr))), [r, col]); 553 } 554 return arr; 555 }; 556 557 $JssorSlideshowFormations$.$FormationRectangleCross = function (transition) { 558 var cols = transition.$Cols || 1; 559 var rows = transition.$Rows || 1; 560 var arr = []; 561 var i = 0; 562 var col; 563 var r; 564 var hc = cols / 2 - 0.5; 565 var hr = rows / 2 - 0.5; 566 var cr = Math.max(hc, hr) + 1; 567 for (col = 0; col < cols; col++) { 568 for (r = 0; r < rows; r++) 569 PushFormationOrder(arr, Math.round(cr - Math.max(hc - Math.abs(col - hc), hr - Math.abs(r - hr))) - 1, [r, col]); 570 } 571 return arr; 572 }; 573 574 function GetFormation(transition) { 575 576 var formationInstance = transition.$Formation(transition); 577 578 return transition.$Reverse ? formationInstance.reverse() : formationInstance; 579 580 } //GetFormation 581 582 //var _PrototypeTransitions = []; 583 function EnsureTransitionInstance(options, slideshowInterval) { 584 585 var _SlideshowTransition = { 586 $Interval: slideshowInterval, //Delay to play next frame 587 $Duration: 1, //Duration to finish the entire transition 588 $Delay: 0, //Delay to assembly blocks 589 $Cols: 1, //Number of columns 590 $Rows: 1, //Number of rows 591 $Opacity: 0, //Fade block or not 592 $Zoom: 0, //Zoom block or not 593 $Clip: 0, //Clip block or not 594 $Move: false, //Move block or not 595 $SlideOut: false, //Slide the previous slide out to display next slide instead 596 $FlyDirection: 0, //Specify fly transform with direction 597 $Reverse: false, //Reverse the assembly or not 598 $Formation: $JssorSlideshowFormations$.$FormationRandom, //Shape that assembly blocks as 599 $Assembly: ASSEMBLY_RIGHT_BOTTOM, //The way to assembly blocks 600 $ChessMode: { $Column: 0, $Row: 0 }, //Chess move or fly direction 601 $Easing: $JssorEasing$.$EaseSwing, //Specify variation of speed during transition 602 $Round: {}, 603 $Blocks: [], 604 $During: {} 605 }; 606 607 $JssorUtils$.$Extend(_SlideshowTransition, options); 608 609 _SlideshowTransition.$Count = _SlideshowTransition.$Cols * _SlideshowTransition.$Rows; 610 if ($JssorUtils$.$IsFunction(_SlideshowTransition.$Easing)) 611 _SlideshowTransition.$Easing = { $Default: _SlideshowTransition.$Easing }; 612
613 _SlideshowTransition.$FramesCount = Math.ceil(_SlideshowTransition.$Duration / _SlideshowTransition.$Interval); 614 _SlideshowTransition.$EasingInstance = GetEasing(_SlideshowTransition); 615 616 _SlideshowTransition.$GetBlocks = function (width, height) { 617 width /= _SlideshowTransition.$Cols; 618 height /= _SlideshowTransition.$Rows; 619 var wh = width + 'x' + height; 620 if (!_SlideshowTransition.$Blocks[wh]) { 621 _SlideshowTransition.$Blocks[wh] = { $Width: width, $Height: height }; 622 for (var col = 0; col < _SlideshowTransition.$Cols; col++) { 623 for (var r = 0; r < _SlideshowTransition.$Rows; r++) 624 _SlideshowTransition.$Blocks[wh][r + ',' + col] = { $Top: r * height, $Right: col * width + width, $Bottom: r * height + height, $Left: col * width }; 625 } 626 } 627 628 return _SlideshowTransition.$Blocks[wh]; 629 }; 630 631 if (_SlideshowTransition.$Brother) { 632 _SlideshowTransition.$Brother = EnsureTransitionInstance(_SlideshowTransition.$Brother, slideshowInterval); 633 _SlideshowTransition.$SlideOut = true; 634 } 635 636 return _SlideshowTransition; 637 } 638 639 function GetEasing(transition) { 640 var easing = transition.$Easing; 641 if (!easing.$Default) 642 easing.$Default = $JssorEasing$.$EaseSwing; 643 644 var duration = transition.$FramesCount; 645 646 var cache = easing.$Cache; 647 if (!cache) { 648 var enumerator = $JssorUtils$.$Extend({}, transition.$Easing, transition.$Round); 649 cache = easing.$Cache = {}; 650 651 $JssorUtils$.$Each(enumerator, function (v, easingName) { 652 var easingFunction = easing[easingName] || easing.$Default; 653 var round = transition.$Round[easingName] || 1; 654 655 if (!$JssorUtils$.$IsArray(easingFunction.$Cache)) 656 easingFunction.$Cache = []; 657 658 var easingFunctionCache = easingFunction.$Cache[duration] = easingFunction.$Cache[duration] || []; 659 660 if (!easingFunctionCache[round]) { 661 easingFunctionCache[round] = [0]; 662 for (var t = 1; t <= duration; t++) { 663 var tRound = t / duration * round; 664 var tRoundFloor = Math.floor(tRound); 665 if (tRound != tRoundFloor) 666 tRound -= tRoundFloor; 667 easingFunctionCache[round][t] = easingFunction(tRound); 668 } 669 } 670 671 cache[easingName] = easingFunctionCache; 672 673 }); 674 } 675 676 return cache; 677 } //GetEasing 678 679 //Formation Definition ------- 680 681 function JssorSlideshowPlayer(slideContainer, slideElement, slideTransition, beginTime, slideContainerWidth, slideContainerHeight) { 682 var _Self = this; 683 684 var _Block; 685 var _StartStylesArr = {}; 686 var _AnimationStylesArrs = {}; 687 var _AnimationBlockItems = []; 688 var _StyleStart; 689 var _StyleEnd; 690 var _StyleDif; 691 var _ChessModeColumn = slideTransition.$ChessMode.$Column || 0; 692 var _ChessModeRow = slideTransition.$ChessMode.$Row || 0; 693 694 var _Blocks = slideTransition.$GetBlocks(slideContainerWidth, slideContainerHeight); 695 var _FormationInstance = GetFormation(slideTransition); 696 var _MaxOrder = _FormationInstance.length - 1; 697 var _Period = slideTransition.$Duration + slideTransition.$Delay * _MaxOrder; 698 var _EndTime = beginTime + _Period; 699 700 var _SlideOut = slideTransition.$SlideOut; 701 var _IsIn; 702 703 _EndTime += $JssorUtils$.$IsBrowserChrome() ? 260 : 50; 704 705 _Self.$EndTime = _EndTime; 706 707 _Self.$ShowFrame = function (time) { 708 time -= beginTime; 709 710 var isIn = time < _Period; 711 712 if (isIn || _IsIn) { 713 _IsIn = isIn; 714 715 if (!_SlideOut) 716 time = _Period - time; 717 718 var frameIndex = Math.ceil(time / slideTransition.$Interval); 719 720 $JssorUtils$.$Each(_AnimationStylesArrs, function (value, index) { 721 722 var itemFrameIndex = Math.max(frameIndex, value.$Min); 723 itemFrameIndex = Math.min(itemFrameIndex, value.length - 1); 724 725 if (value.$LastFrameIndex != itemFrameIndex) { 726 if (!value.$LastFrameIndex && !_SlideOut) { 727 $JssorUtils$.$ShowElement(_AnimationBlockItems[index]); 728 } 729 else if (itemFrameIndex == value.$Max && _SlideOut) { 730 $JssorUtils$.$HideElement(_AnimationBlockItems[index]); 731 } 732 value.$LastFrameIndex = itemFrameIndex; 733 $JssorUtils$.$SetStylesEx(_AnimationBlockItems[index], value[itemFrameIndex]); 734 } 735 }); 736 } 737 }; 738 739 function DisableHWA(elmt) { 740 $JssorUtils$.$DisableHWA(elmt); 741 742 var children = $JssorUtils$.$GetChildren(elmt); 743 744 $JssorUtils$.$Each(children, function (child) { 745 DisableHWA(child); 746 }); 747 } 748 749 //constructor 750 { 751 slideElement = $JssorUtils$.$CloneNode(slideElement, true); 752 DisableHWA(slideElement); 753 if ($JssorUtils$.$IsBrowserIe9Earlier()) { 754 var hasImage = !slideElement["no-image"]; 755 var slideChildElements = $JssorUtils$.$FindChildrenByTag(slideElement, null, true);
756 $JssorUtils$.$Each(slideChildElements, function (slideChildElement) { 757 if (hasImage || slideChildElement["jssor-slider"]) 758 $JssorUtils$.$CssOpacity(slideChildElement, $JssorUtils$.$CssOpacity(slideChildElement), true); 759 }); 760 } 761 762 $JssorUtils$.$Each(_FormationInstance, function (formationItems, order) { 763 $JssorUtils$.$Each(formationItems, function (formationItem) { 764 var row = formationItem[0]; 765 var col = formationItem[1]; 766 { 767 var columnRow = row + ',' + col; 768 769 var chessHorizontal = false; 770 var chessVertical = false; 771 var chessRotate = false; 772 773 if (_ChessModeColumn && col % 2) { 774 if ($JssorDirection$.$IsHorizontal(_ChessModeColumn)) { 775 chessHorizontal = !chessHorizontal; 776 } 777 if ($JssorDirection$.$IsVertical(_ChessModeColumn)) { 778 chessVertical = !chessVertical; 779 } 780 781 if (_ChessModeColumn & 16) 782 chessRotate = !chessRotate; 783 } 784 785 if (_ChessModeRow && row % 2) { 786 if ($JssorDirection$.$IsHorizontal(_ChessModeRow)) { 787 chessHorizontal = !chessHorizontal; 788 } 789 if ($JssorDirection$.$IsVertical(_ChessModeRow)) { 790 chessVertical = !chessVertical; 791 } 792 if (_ChessModeRow & 16) 793 chessRotate = !chessRotate; 794 } 795 796 slideTransition.$Top = slideTransition.$Top || (slideTransition.$Clip & 4); 797 slideTransition.$Bottom = slideTransition.$Bottom || (slideTransition.$Clip & 8); 798 slideTransition.$Left = slideTransition.$Left || (slideTransition.$Clip & 1); 799 slideTransition.$Right = slideTransition.$Right || (slideTransition.$Clip & 2); 800 801 var topBenchmark = chessVertical ? slideTransition.$Bottom : slideTransition.$Top; 802 var bottomBenchmark = chessVertical ? slideTransition.$Top : slideTransition.$Bottom; 803 var leftBenchmark = chessHorizontal ? slideTransition.$Right : slideTransition.$Left; 804 var rightBenchmark = chessHorizontal ? slideTransition.$Left : slideTransition.$Right; 805 806 //$JssorDebug$.$Execute(function () { 807 // topBenchmark = bottomBenchmark = leftBenchmark = rightBenchmark = false; 808 //}); 809 810 slideTransition.$Clip = topBenchmark || bottomBenchmark || leftBenchmark || rightBenchmark; 811 812 _StyleDif = {}; 813 _StyleEnd = { $Top: 0, $Left: 0, $Opacity: 1, $Width: slideContainerWidth, $Height: slideContainerHeight }; 814 _StyleStart = $JssorUtils$.$Extend({}, _StyleEnd); 815 _Block = $JssorUtils$.$Extend({}, _Blocks[columnRow]); 816 817 if (slideTransition.$Opacity) { 818 _StyleEnd.$Opacity = 2 - slideTransition.$Opacity; 819 } 820 821 if (slideTransition.$ZIndex) { 822 _StyleEnd.$ZIndex = slideTransition.$ZIndex; 823 _StyleStart.$ZIndex = 0; 824 } 825 826 var allowClip = slideTransition.$Cols * slideTransition.$Rows > 1 || slideTransition.$Clip; 827 828 if (slideTransition.$Zoom || slideTransition.$Rotate) { 829 var allowRotate = true; 830 if ($JssorUtils$.$IsBrowserIE() && $JssorUtils$.$GetBrowserEngineVersion() < 9) { 831 if (slideTransition.$Cols * slideTransition.$Rows > 1) 832 allowRotate = false;
833 else 834 allowClip = false; 835 } 836 837 if (allowRotate) { 838 _StyleEnd.$Zoom = slideTransition.$Zoom ? slideTransition.$Zoom - 1 : 1; 839 _StyleStart.$Zoom = 1; 840 841 if ($JssorUtils$.$IsBrowserIe9Earlier() || $JssorUtils$.$IsBrowserOpera()) 842 _StyleEnd.$Zoom = Math.min(_StyleEnd.$Zoom, 2); 843 844 var rotate = slideTransition.$Rotate; 845 if (rotate == true) 846 rotate = 1; 847 848 _StyleEnd.$Rotate = rotate * 360 * ((chessRotate) ? -1 : 1); 849 _StyleStart.$Rotate = 0; 850 } 851 } 852 853 if (allowClip) { 854 if (slideTransition.$Clip) { 855 var clipScale = slideTransition.$ScaleClip || 1; 856 var blockOffset = _Block.$Offset = {}; 857 if (topBenchmark && bottomBenchmark) { 858 blockOffset.$Top = _Blocks.$Height / 2 * clipScale; 859 blockOffset.$Bottom = -blockOffset.$Top; 860 } 861 else if (topBenchmark) { 862 blockOffset.$Bottom = -_Blocks.$Height * clipScale; 863 } 864 else if (bottomBenchmark) { 865 blockOffset.$Top = _Blocks.$Height * clipScale; 866 } 867 868 if (leftBenchmark && rightBenchmark) { 869 blockOffset.$Left = _Blocks.$Width / 2 * clipScale; 870 blockOffset.$Right = -blockOffset.$Left; 871 } 872 else if (leftBenchmark) { 873 blockOffset.$Right = -_Blocks.$Width * clipScale; 874 } 875 else if (rightBenchmark) { 876 blockOffset.$Left = _Blocks.$Width * clipScale; 877 } 878 } 879 880 _StyleDif.$Clip = _Block; 881 _StyleStart.$Clip = _Blocks[columnRow]; 882 } 883 884 if (slideTransition.$FlyDirection) { 885 886 var direction = slideTransition.$FlyDirection; 887 888 if (!chessHorizontal) 889 direction = $JssorDirection$.$ChessHorizontal(direction); 890 891 if (!chessVertical) 892 direction = $JssorDirection$.$ChessVertical(direction); 893 894 var scaleHorizontal = slideTransition.$ScaleHorizontal || 1; 895 var scaleVertical = slideTransition.$ScaleVertical || 1; 896 897 if ($JssorDirection$.$IsToLeft(direction)) { 898 _StyleEnd.$Left += slideContainerWidth * scaleHorizontal; 899 } 900 else if ($JssorDirection$.$IsToRight(direction)) { 901 _StyleEnd.$Left -= slideContainerWidth * scaleHorizontal; 902 } 903 if ($JssorDirection$.$IsToTop(direction)) { 904 _StyleEnd.$Top += slideContainerHeight * scaleVertical; 905 } 906 else if ($JssorDirection$.$IsToBottom(direction)) { 907 _StyleEnd.$Top -= slideContainerHeight * scaleVertical; 908 } 909 } 910 911 $JssorUtils$.$Each(_StyleEnd, function (propertyEnd, property) { 912 if ($JssorUtils$.$IsNumeric(propertyEnd)) { 913 if (propertyEnd != _StyleStart[property]) { 914 _StyleDif[property] = propertyEnd - _StyleStart[property]; 915 } 916 } 917 }); 918 919 _StartStylesArr[columnRow] = _SlideOut ? _StyleStart : _StyleEnd; 920 921 var animationStylesArr = []; 922 var virtualFrameCount = Math.round(order * slideTransition.$Delay / slideTransition.$Interval); 923 _AnimationStylesArrs[columnRow] = new Array(virtualFrameCount); 924 _AnimationStylesArrs[columnRow].$Min = virtualFrameCount; 925 926 var framesCount = slideTransition.$FramesCount; 927 for (var frameN = 0; frameN <= framesCount; frameN++) { 928 var styleFrameN = {}; 929 930 $JssorUtils$.$Each(_StyleDif, function (propertyDiff, property) { 931 var propertyEasings = slideTransition.$EasingInstance[property] || slideTransition.$EasingInstance.$Default; 932 var propertyEasingArray = propertyEasings[slideTransition.$Round[property] || 1]; 933 934 var propertyDuring = slideTransition.$During[property] || [0, 1]; 935 var propertyFrameN = (frameN / framesCount - propertyDuring[0]) / propertyDuring[1] * framesCount; 936 propertyFrameN = Math.round(Math.min(framesCount, Math.max(propertyFrameN, 0))); 937 938 var propertyEasingValue = propertyEasingArray[propertyFrameN]; 939 940 if ($JssorUtils$.$IsNumeric(propertyDiff)) { 941 styleFrameN[property] = _StyleStart[property] + propertyDiff * propertyEasingValue; 942 } 943 else { 944 var value = styleFrameN[property] = $JssorUtils$.$Extend({}, _StyleStart[property]); 945 value.$Offset = []; 946 $JssorUtils$.$Each(propertyDiff.$Offset, function (rectX, n) { 947 var offsetValue = rectX * propertyEasingValue; 948 value.$Offset[n] = offsetValue; 949 value[n] += offsetValue; 950 }); 951 } 952 }); 953 954 if (_StyleStart.$Zoom) { 955 styleFrameN.$Transform = { $Rotate: styleFrameN.$Rotate || 0, $Scale: styleFrameN.$Zoom, $OriginalWidth: slideContainerWidth, $OriginalHeight: slideContainerHeight }; 956 } 957 if (styleFrameN.$Clip && slideTransition.$Move) { 958 var styleFrameNClipOffset = styleFrameN.$Clip.$Offset; 959 var offsetY = (styleFrameNClipOffset.$Top || 0) + (styleFrameNClipOffset.$Bottom || 0); 960 var offsetX = (styleFrameNClipOffset.$Left || 0) + (styleFrameNClipOffset.$Right || 0
960); 961 962 styleFrameN.$Left = (styleFrameN.$Left || 0) + offsetX; 963 styleFrameN.$Top = (styleFrameN.$Top || 0) + offsetY; 964 styleFrameN.$Clip.$Left -= offsetX; 965 styleFrameN.$Clip.$Right -= offsetX; 966 styleFrameN.$Clip.$Top -= offsetY; 967 styleFrameN.$Clip.$Bottom -= offsetY; 968 } 969 970 styleFrameN.$ZIndex = styleFrameN.$ZIndex || 1; 971 972 _AnimationStylesArrs[columnRow].push(styleFrameN); 973 } 974 975 } //for 976 }); 977 }); 978 979 _FormationInstance.reverse(); 980 $JssorUtils$.$Each(_FormationInstance, function (formationItems) { 981 $JssorUtils$.$Each(formationItems, function (formationItem) { 982 var row = formationItem[0]; 983 var col = formationItem[1]; 984 985 var columnRow = row + ',' + col; 986 987 var image = slideElement; 988 if (col || row) 989 image = $JssorUtils$.$CloneNode(slideElement, true); 990 991 $JssorUtils$.$SetStyles(image, _StartStylesArr[columnRow]); 992 $JssorUtils$.$CssOverflow(image, "hidden"); 993 994 $JssorUtils$.$CssPosition(image, "absolute"); 995 slideContainer.$AddClipElement(image); 996 _AnimationBlockItems[columnRow] = image; 997 $JssorUtils$.$ShowElement(image, _SlideOut); 998 }); 999 }); 1000 } 1001 } 1002 1003 //JssorSlideshowRunner++++++++ 1004 var _SlideshowRunnerCount = 1; 1005 $JssorSlideshowRunner$ = window.$JssorSlideshowRunner$ = function (slideContainer, slideContainerWidth, slideContainerHeight, slideshowOptions, handleTouchEventOnly) { 1006 1007 var _SelfSlideshowRunner = this; 1008 1009 //var _State = 0; //-1 fullfill, 0 clean, 1 initializing, 2 stay, 3 playing 1010 var _EndTime; 1011 1012 var _SliderFrameCount; 1013 1014 var _SlideshowPlayerBelow; 1015 var _SlideshowPlayerAbove; 1016 1017 var _PrevItem; 1018 var _SlideItem; 1019 1020 var _TransitionIndex = 0; 1021 var _TransitionsOrder = slideshowOptions.$TransitionsOrder; 1022 1023 var _SlideshowTransition; 1024 1025 var _SlideshowPerformance = 16; 1026 1027 function SlideshowProcessor() { 1028 var _SelfSlideshowProcessor = this; 1029 var _CurrentTime = 0; 1030 1031 $JssorAnimator$.call(_SelfSlideshowProcessor, 0, _EndTime); 1032 1033 _SelfSlideshowProcessor.$OnPositionChange = function (oldPosition, newPosition) { 1034 if ((newPosition - _CurrentTime) > _SlideshowPerformance) { 1035 _CurrentTime = newPosition; 1036 1037 _SlideshowPlayerAbove && _SlideshowPlayerAbove.$ShowFrame(newPosition); 1038 _SlideshowPlayerBelow && _SlideshowPlayerBelow.$ShowFrame(newPosition); 1039 } 1040 }; 1041 1042 _SelfSlideshowProcessor.$Transition = _SlideshowTransition; 1043 } 1044 1045 //member functions 1046 _SelfSlideshowRunner.$GetTransition = function (slideCount) { 1047 var n = 0; 1048 1049 var transitions = slideshowOptions.$Transitions; 1050 1051 var transitionCount = transitions.length; 1052 1053 if (_TransitionsOrder) { /*Sequence*/ 1054 if (transitionCount > slideCount && ($JssorUtils$.$IsBrowserChrome() || $JssorUtils$.$IsBrowserSafari() || $JssorUtils$.$IsBrowserFireFox())) { 1055 transitionCount -= transitionCount % slideCount; 1056 } 1057 n = _TransitionIndex++ % transitionCount; 1058 } 1059 else { /*Random*/ 1060 n = Math.floor(Math.random() * transitionCount); 1061 } 1062 1063 transitions[n] && (transitions[n].$Index = n); 1064 1065 return transitions[n]; 1066 }; 1067 1068 _SelfSlideshowRunner.$Initialize = function (slideIndex, prevIndex, slideItem, prevItem, slideshowTransition) { 1069 $JssorDebug$.$Execute(function () { 1070 if (_SlideshowPlayerBelow) { 1071 $JssorDebug$.$Fail("slideshow runner has not been cleared."); 1072 } 1073 }); 1074 1075 _SlideshowTransition = slideshowTransition; 1076 1077 slideshowTransition = EnsureTransitionInstance(slideshowTransition, _SlideshowPerformance); 1078 1079 _SlideItem = slideItem; 1080 _PrevItem = prevItem; 1081 1082 var prevSlideElement = prevItem.$Item; 1083 var currentSlideElement = slideItem.$Item; 1084 prevSlideElement["no-image"] = !prevItem.$Image;
1085 currentSlideElement["no-image"] = !slideItem.$Image; 1086 1087 var slideElementAbove = prevSlideElement; 1088 var slideElementBelow = currentSlideElement; 1089 1090 var slideTransitionAbove = slideshowTransition; 1091 var slideTransitionBelow = slideshowTransition.$Brother || EnsureTransitionInstance({}, _SlideshowPerformance); 1092 1093 if (!slideshowTransition.$SlideOut) { 1094 slideElementAbove = currentSlideElement; 1095 slideElementBelow = prevSlideElement; 1096 } 1097 1098 var shift = slideTransitionBelow.$Shift || 0; 1099 1100 _SlideshowPlayerBelow = new JssorSlideshowPlayer(slideContainer, slideElementBelow, slideTransitionBelow, Math.max(shift - slideTransitionBelow.$Interval, 0), slideContainerWidth, slideContainerHeight); 1101 _SlideshowPlayerAbove = new JssorSlideshowPlayer(slideContainer, slideElementAbove, slideTransitionAbove, Math.max(slideTransitionBelow.$Interval - shift, 0), slideContainerWidth, slideContainerHeight); 1102 1103 _SlideshowPlayerBelow.$ShowFrame(0); 1104 _SlideshowPlayerAbove.$ShowFrame(0); 1105 1106 _EndTime = Math.max(_SlideshowPlayerBelow.$EndTime, _SlideshowPlayerAbove.$EndTime); 1107 1108 _SelfSlideshowRunner.$Index = slideIndex; 1109 }; 1110 1111 _SelfSlideshowRunner.$Clear = function () { 1112 slideContainer.$Clear(); 1113 _SlideshowPlayerBelow = null; 1114 _SlideshowPlayerAbove = null; 1115 }; 1116 1117 _SelfSlideshowRunner.$GetProcessor = function () { 1118 var slideshowProcessor = null; 1119 1120 if (_SlideshowPlayerAbove) 1121 slideshowProcessor = new SlideshowProcessor(); 1122 1123 return slideshowProcessor; 1124 }; 1125 1126 //Constructor 1127 { 1128 if ($JssorUtils$.$IsBrowserIe9Earlier() || $JssorUtils$.$IsBrowserOpera() || (handleTouchEventOnly && $JssorUtils$.$GetWebKitVersion < 537)) { 1129 _SlideshowPerformance = 32; 1130 } 1131 1132 $JssorEventManager$.call(_SelfSlideshowRunner); 1133 $JssorAnimator$.call(_SelfSlideshowRunner, -10000000, 10000000); 1134 1135 $JssorDebug$.$LiveStamp(_SelfSlideshowRunner, "slideshow_runner_" + _SlideshowRunnerCount++); 1136 } 1137 }; 1138 //JssorSlideshowRunner-------- 1139 1140 //JssorSlider 1141 function JssorSlider(elmt, options) { 1142 var _SelfSlider = this; 1143 1144 //private classes 1145 function Conveyor() { 1146 var _SelfConveyor = this; 1147 $JssorAnimator$.call(_SelfConveyor, -100000000, 200000000); 1148 1149 _SelfConveyor.$GetCurrentSlideInfo = function () { 1150 var positionDisplay = _SelfConveyor.$GetPosition_Display(); 1151 var virtualIndex = Math.floor(positionDisplay); 1152 var slideIndex = GetRealIndex(virtualIndex); 1153 var slidePosition = positionDisplay - Math.floor(positionDisplay); 1154 1155 return { $Index: slideIndex, $VirtualIndex: virtualIndex, $Position: slidePosition }; 1156 }; 1157 1158 _SelfConveyor.$OnPositionChange = function (oldPosition, newPosition) { 1159 var index = Math.floor(newPosition); 1160 if (index != newPosition && newPosition > oldPosition) 1161 index++; 1162 1163 ResetNavigator(index, true); 1164 1165 _SelfSlider.$TriggerEvent(JssorSlider.$EVT_POSITION_CHANGE, GetRealIndex(newPosition), GetRealIndex(oldPosition), newPosition, oldPosition); 1166 }; 1167 } 1168 1169 //Carousel 1170 function Carousel() { 1171 var _SelfCarousel = this; 1172 1173 $JssorAnimator$.call(_SelfCarousel, 0, 0, { $LoopLength: _SlideCount }); 1174 1175 //Carousel Constructor 1176 { 1177 $JssorUtils$.$Each(_SlideItems, function (slideItem) { 1178 (_Loop & 1) && slideItem.$SetLoopLength(_SlideCount); 1179 _SelfCarousel.$Chain(slideItem); 1180 slideItem.$Shift(_ParkingPosition / _StepLength); 1181 }); 1182 } 1183 } 1184 //Carousel 1185 1186 //Slideshow 1187 function Slideshow() { 1188 var _SelfSlideshow = this; 1189 var _Wrapper = _SlideContainer.$Elmt; 1190 1191 $JssorAnimator$.call(_SelfSlideshow, -1, 2, { $Easing: $JssorEasing$.$EaseLinear, $Setter: { $Position: SetPosition }, $LoopLength: _SlideCount }, _Wrapper, { $Position: 1 }, { $Position: -1 }); 1192 1193 _SelfSlideshow.$Wrapper = _Wrapper; 1194 1195 //Slideshow Constructor 1196 { 1197 $JssorDebug$.$Execute(function () { 1198 $JssorUtils$.$SetAttribute(_SlideContainer.$Elmt, "debug
1198-id", "slide_container"); 1199 }); 1200 } 1201 } 1202 //Slideshow 1203 1204 //CarouselPlayer 1205 function CarouselPlayer(carousel, slideshow) { 1206 var _SelfCarouselPlayer = this; 1207 var _FromPosition; 1208 var _ToPosition; 1209 var _Duration; 1210 var _StandBy; 1211 var _StandByPosition; 1212 1213 $JssorAnimator$.call(_SelfCarouselPlayer, -100000000, 200000000); 1214 1215 _SelfCarouselPlayer.$OnStart = function () { 1216 _IsSliding = true; 1217 _LoadingTicket = null; 1218 1219 //EVT_SWIPE_START 1220 _SelfSlider.$TriggerEvent(JssorSlider.$EVT_SWIPE_START, GetRealIndex(_Conveyor.$GetPosition()), _Conveyor.$GetPosition()); 1221 }; 1222 1223 _SelfCarouselPlayer.$OnStop = function () { 1224 1225 _IsSliding = false; 1226 _StandBy = false; 1227 1228 var currentSlideInfo = _Conveyor.$GetCurrentSlideInfo(); 1229 1230 //EVT_SWIPE_END 1231 _SelfSlider.$TriggerEvent(JssorSlider.$EVT_SWIPE_END, GetRealIndex(_Conveyor.$GetPosition()), _Conveyor.$GetPosition()); 1232 1233 if (!currentSlideInfo.$Position) { 1234 OnPark(currentSlideInfo.$VirtualIndex, _CurrentSlideIndex); 1235 } 1236 }; 1237 1238 _SelfCarouselPlayer.$OnPositionChange = function (oldPosition, newPosition) { 1239 var toPosition; 1240 1241 if (_StandBy) 1242 toPosition = _StandByPosition; 1243 else { 1244 toPosition = _ToPosition; 1245 1246 if (_Duration) 1247 toPosition = _Options.$SlideEasing(newPosition / _Duration) * (_ToPosition - _FromPosition) + _FromPosition; 1248 } 1249 1250 _Conveyor.$GoToPosition(toPosition); 1251 }; 1252 1253 _SelfCarouselPlayer.$PlayCarousel = function (fromPosition, toPosition, duration, callback) { 1254 $JssorDebug$.$Execute(function () { 1255 if (_SelfCarouselPlayer.$IsPlaying()) 1256 $JssorDebug$.$Fail("The carousel is already playing."); 1257 }); 1258 1259 _FromPosition = fromPosition; 1260 _ToPosition = toPosition; 1261 _Duration = duration; 1262 1263 _Conveyor.$GoToPosition(fromPosition); 1264 _SelfCarouselPlayer.$GoToPosition(0); 1265 1266 _SelfCarouselPlayer.$PlayToPosition(duration, callback); 1267 }; 1268 1269 _SelfCarouselPlayer.$StandBy = function (standByPosition) { 1270 _StandBy = true; 1271 _StandByPosition = standByPosition; 1272 _SelfCarouselPlayer.$Play(standByPosition, null, true); 1273 }; 1274 1275 _SelfCarouselPlayer.$SetStandByPosition = function (standByPosition) { 1276 _StandByPosition = standByPosition; 1277 }; 1278 1279 _SelfCarouselPlayer.$MoveCarouselTo = function (position) { 1280 _Conveyor.$GoToPosition(position); 1281 }; 1282 1283 //CarouselPlayer Constructor 1284 { 1285 _Conveyor = new Conveyor(); 1286 1287 _Conveyor.$Combine(carousel); 1288 _Conveyor.$Combine(slideshow); 1289 } 1290 } 1291 //CarouselPlayer 1292 1293 //SlideContainer 1294 function SlideContainer() { 1295 var _Self = this; 1296 var elmt = CreatePanel(); 1297 1298 $JssorUtils$.$CssZIndex(elmt, 0); 1299 1300 _Self.$Elmt = elmt; 1301 1302 _Self.$AddClipElement = function (clipElement) { 1303 $JssorUtils$.$AppendChild(elmt, clipElement); 1304 $JssorUtils$.$ShowElement(elmt); 1305 }; 1306 1307 _Self.$Clear = function () { 1308 $JssorUtils$.$HideElement(elmt); 1309 $JssorUtils$.$ClearInnerHtml(elmt); 1310 }; 1311 } 1312 //SlideContainer 1313 1314 //SlideItem 1315 function SlideItem(slideElmt, slideIndex) { 1316 1317 var _SelfSlideItem = this; 1318 1319 var _CaptionSliderIn; 1320 var _CaptionSliderOut; 1321 var _CaptionSliderCurrent; 1322 var _IsCaptionSliderPlayingWhenDragStart; 1323 1324 var _Wrapper; 1325 var _BaseElement = slideElmt; 1326 1327 var _LoadingScreen; 1328 1329 var _ImageItem; 1330 var _ImageElmts = []; 1331 var _LinkItemOrigin; 1332 var _LinkItem; 1333 var _ImageLoading; 1334 var _ImageLoaded; 1335 var _ImageLazyLoading; 1336 var _ContentRefreshed; 1337 1338 var _Processor; 1339 1340 var _PlayerInstanceElement; 1341 var _PlayerInstance; 1342 1343 var _SequenceNumber; //for debug only 1344 1345 $JssorAnimator$.call(_SelfSlideItem, -_DisplayPieces, _DisplayPieces + 1, { $SlideItemAnimator: true }); 1346 1347 function ResetCaptionSlider(fresh) { 1348 _CaptionSliderOut && _CaptionSliderOut.$Revert(); 1349 _CaptionSliderIn && _CaptionSliderIn.$Revert(); 1350 1351 RefreshContent(slideElmt, fresh); 1352 _ContentRefreshed = true; 1353 1354 _CaptionSliderIn = new _CaptionSliderOptions.$Class(slideElmt, _CaptionSliderOptions, 1);
1355 $JssorDebug$.$LiveStamp(_CaptionSliderIn, "caption_slider_" + _CaptionSliderCount + "_in"); 1356 _CaptionSliderOut = new _CaptionSliderOptions.$Class(slideElmt, _CaptionSliderOptions); 1357 $JssorDebug$.$LiveStamp(_CaptionSliderOut, "caption_slider_" + _CaptionSliderCount + "_out"); 1358 1359 $JssorDebug$.$Execute(function () { 1360 _CaptionSliderCount++; 1361 }); 1362 1363 _CaptionSliderOut.$GoToBegin(); 1364 _CaptionSliderIn.$GoToBegin(); 1365 } 1366 1367 function EnsureCaptionSliderVersion() { 1368 if (_CaptionSliderIn.$Version < _CaptionSliderOptions.$Version) { 1369 ResetCaptionSlider(); 1370 } 1371 } 1372 1373 //event handling begin 1374 function LoadImageCompleteEventHandler(completeCallback, loadingScreen, image) { 1375 if (!_ImageLoaded) { 1376 _ImageLoaded = true; 1377 1378 if (_ImageItem && image) { 1379 var imageWidth = image.width; 1380 var imageHeight = image.height; 1381 var fillWidth = imageWidth; 1382 var fillHeight = imageHeight; 1383 1384 if (imageWidth && imageHeight && _Options.$FillMode) { 1385 1386 //0 stretch, 1 contain (keep aspect ratio and put all inside slide), 2 cover (keep aspect ratio and cover whole slide), 4 actual size, 5 contain for large image, actual size for small image, default value is 0 1387 if (_Options.$FillMode & 3 && (!(_Options.$FillMode & 4) || imageWidth > _SlideWidth || imageHeight > _SlideHeight)) { 1388 var fitHeight = false; 1389 var ratio = _SlideWidth / _SlideHeight * imageHeight / imageWidth; 1390 1391 if (_Options.$FillMode & 1) { 1392 fitHeight = (ratio > 1); 1393 } 1394 else if (_Options.$FillMode & 2) { 1395 fitHeight = (ratio < 1); 1396 } 1397 fillWidth = fitHeight ? imageWidth * _SlideHeight / imageHeight : _SlideWidth; 1398 fillHeight = fitHeight ? _SlideHeight : imageHeight * _SlideWidth / imageWidth; 1399 } 1400 1401 $JssorUtils$.$CssWidth(_ImageItem, fillWidth); 1402 $JssorUtils$.$CssHeight(_ImageItem, fillHeight); 1403 $JssorUtils$.$CssTop(_ImageItem, (_SlideHeight - fillHeight) / 2); 1404 $JssorUtils$.$CssLeft(_ImageItem, (_SlideWidth - fillWidth) / 2); 1405 } 1406 1407 $JssorUtils$.$CssPosition(_ImageItem, "absolute"); 1408 1409 _SelfSlider.$TriggerEvent(JssorSlider.$EVT_LOAD_END, slideItem); 1410 } 1411 } 1412 1413 $JssorUtils$.$HideElement(loadingScreen); 1414 completeCallback && completeCallback(_SelfSlideItem); 1415 } 1416 1417 function LoadSlideshowImageCompleteEventHandler(nextIndex, nextItem, slideshowTransition, loadingTicket) { 1418 if (loadingTicket == _LoadingTicket && _CurrentSlideIndex == slideIndex && _AutoPlay) { 1419 if (!_Frozen) { 1420 var nextRealIndex = GetRealIndex(nextIndex); 1421 _SlideshowRunner.$Initialize(nextRealIndex, slideIndex, nextItem, _SelfSlideItem, slideshowTransition); 1422 nextItem.$HideContentForSlideshow(); 1423 _Slideshow.$Locate(nextRealIndex, 1); 1424 _Slideshow.$GoToPosition(nextRealIndex); 1425 _CarouselPlayer.$PlayCarousel(nextIndex, nextIndex, 0); 1426 } 1427 } 1428 } 1429 1430 function SlideReadyEventHandler(loadingTicket) { 1431 if (loadingTicket == _LoadingTicket && _CurrentSlideIndex == slideIndex) { 1432 1433 if (!_Processor) { 1434 var slideshowProcessor = null; 1435 if (_SlideshowRunner) { 1436 if (_SlideshowRunner.$Index == slideIndex) 1437 slideshowProcessor = _SlideshowRunner.$GetProcessor(); 1438 else 1439 _SlideshowRunner.$Clear(); 1440 } 1441 1442 EnsureCaptionSliderVersion(); 1443 1444 _Processor = new Processor(slideIndex, slideshowProcessor, _SelfSlideItem.$GetCaptionSliderIn(), _SelfSlideItem.$GetCaptionSliderOut()); 1445 _Processor.$SetPlayer(_PlayerInstance); 1446 } 1447 1448 !_Processor.$IsPlaying() && _Processor.$Replay(); 1449 } 1450 } 1451 1452 function ParkEventHandler(currentIndex, previousIndex) { 1453 if (currentIndex == slideIndex) { 1454 1455 if (currentIndex != previousIndex) 1456 _SlideItems[previousIndex] && _SlideItems[previousIndex].$ParkOut(); 1457 1458 _PlayerInstance && _PlayerInstance.$Enable(); 1459 1460 //park in 1461 var loadingTicket = _LoadingTicket = $JssorUtils$.$GetNow(); 1462 _SelfSlideItem.$LoadImage($JssorUtils$.$CreateCallback(null, SlideReadyEventHandler, loadingTicket)); 1463 } 1464 else { 1465 var distance = Math.abs(slideIndex - currentIndex); 1466 var loadRange = _DisplayPieces + _Options.$LazyLoading; 1467 if (!_ImageLazyLoading || distance <= loadRange || _SlideCount - distance <= loadRange) { 1468 _SelfSlideItem.$LoadImage(); 1469 } 1470 } 1471 } 1472 1473 function SwipeStartEventHandler() { 1474 if (_CurrentSlideIndex == slideIndex && _Processor) { 1475 _Processor.$Stop(); 1476 _PlayerInstance && _PlayerInstance.$Quit(); 1477 _PlayerInstance && _PlayerInstance.$Disable(); 1478 _Processor.$OpenSlideshowPanel(); 1479 } 1480 } 1481 1482 function DragStartEventHandler() { 1483 if (_CurrentSlideIndex == slideIndex && _Processor) { 1484 _Processor.$Stop(); 1485 } 1486 } 1487 1488 function LinkClickEventHandler(event) { 1489 if (_LastDragSucceded) { 1490 $JssorUtils$.$CancelEvent(event); 1491 } 1492 else { 1493 _SelfSlider.$TriggerEvent(JssorSlider.$EVT_CLICK, slideIndex, event); 1494 } 1495 } 1496 1497 function PlayerAvailableEventHandler() { 1498 _PlayerInstance = _PlayerInstanceElement.pInstance; 1499 _Processor && _Processor.$SetPlayer(_PlayerInstance); 1500 } 1501 1502 _SelfSlideItem.$LoadImage = function (completeCallback, loadingScreen) { 1503 loadingScreen = loadingScreen || _LoadingScreen; 1504 1505 if (_ImageElmts.length && !_ImageLoaded) { 1506 1507 $JssorUtils$.$ShowElement(loadingScreen); 1508 1509 if (!_ImageLoading) { 1510 _ImageLoading = true; 1511 _SelfSlider.$TriggerEvent(JssorSlider.$EVT_LOAD_START); 1512 1513 $JssorUtils$.$Each(_ImageElmts, function (imageElmt) { 1514 1515 if (!imageElmt.src) { 1516 imageElmt.src = $JssorUtils$.$GetAttributeEx(imageElmt, "src2"); 1517 $JssorUtils$.$CssDisplay(imageElmt, imageElmt["display-origin"]); 1518 } 1519 }); 1520 } 1521 $JssorUtils$.$LoadImages(_ImageElmts, _ImageItem, $JssorUtils$.$CreateCallback(null, LoadImageCompleteEventHandler, completeCallback, loadingScreen)); 1522 } 1523 else { 1524 LoadImageCompleteEventHandler(completeCallback, loadingScreen); 1525 } 1526 }; 1527 1528 _SelfSlideItem.$GoForNextSlide = function () { 1529 if (_SlideshowRunner) { 1530 var slideshowTransition = _SlideshowRunner.$GetTransition(_SlideCount); 1531 1532 if (slideshowTransition) { 1533 var loadingTicket = _LoadingTicket = $JssorUtils$.$GetNow(); 1534 1535 var nextIndex = slideIndex + 1 * _PlayReverse;
1536 var nextItem = _SlideItems[GetRealIndex(nextIndex)]; 1537 return nextItem.$LoadImage($JssorUtils$.$CreateCallback(null, LoadSlideshowImageCompleteEventHandler, nextIndex, nextItem, slideshowTransition, loadingTicket), _LoadingScreen); 1538 } 1539 } 1540 1541 PlayTo(_CurrentSlideIndex + _Options.$AutoPlaySteps * _PlayReverse); 1542 }; 1543 1544 _SelfSlideItem.$TryActivate = function () { 1545 ParkEventHandler(slideIndex, slideIndex); 1546 }; 1547 1548 _SelfSlideItem.$ParkOut = function () { 1549 //park out 1550 _PlayerInstance && _PlayerInstance.$Quit(); 1551 _PlayerInstance && _PlayerInstance.$Disable(); 1552 _SelfSlideItem.$UnhideContentForSlideshow(); 1553 _Processor && _Processor.$Abort(); 1554 _Processor = null; 1555 ResetCaptionSlider(); 1556 }; 1557 1558 //for debug only 1559 _SelfSlideItem.$StampSlideItemElements = function (stamp) { 1560 stamp = _SequenceNumber + "_" + stamp; 1561 1562 $JssorDebug$.$Execute(function () { 1563 if (_ImageItem) 1564 $JssorUtils$.$SetAttribute(_ImageItem, "debug-id", stamp + "_slide_item_image_id"); 1565 1566 $JssorUtils$.$SetAttribute(slideElmt, "debug-id", stamp + "_slide_item_item_id"); 1567 }); 1568 1569 $JssorDebug$.$Execute(function () { 1570 $JssorUtils$.$SetAttribute(_Wrapper, "debug-id", stamp + "_slide_item_wrapper_id"); 1571 }); 1572 1573 $JssorDebug$.$Execute(function () { 1574 $JssorUtils$.$SetAttribute(_LoadingScreen, "debug-id", stamp + "_loading_container_id"); 1575 }); 1576 }; 1577 1578 _SelfSlideItem.$HideContentForSlideshow = function () { 1579 $JssorUtils$.$HideElement(slideElmt); 1580 }; 1581 1582 _SelfSlideItem.$UnhideContentForSlideshow = function () { 1583 $JssorUtils$.$ShowElement(slideElmt); 1584 }; 1585 1586 _SelfSlideItem.$EnablePlayer = function () { 1587 _PlayerInstance && _PlayerInstance.$Enable(); 1588 }; 1589 1590 function RefreshContent(elmt, fresh, level) { 1591 if (elmt["jssor-slider"]) 1592 return; 1593 1594 level = level || 0; 1595 1596 if (!_ContentRefreshed) { 1597 if (elmt.tagName == "IMG") { 1598 _ImageElmts.push(elmt); 1599 1600 if (!elmt.src) { 1601 _ImageLazyLoading = true; 1602 elmt["display-origin"] = $JssorUtils$.$CssDisplay(elmt); 1603 $JssorUtils$.$HideElement(elmt); 1604 } 1605 } 1606 if ($JssorUtils$.$IsBrowserIe9Earlier()) { 1607 $JssorUtils$.$CssZIndex(elmt, ($JssorUtils$.$CssZIndex(elmt) || 0) + 1); 1608 } 1609 if (_Options.$HWA && $JssorUtils$.$GetWebKitVersion() > 0) { 1610 //if ((_HandleTouchEventOnly && ($JssorUtils$.$GetWebKitVersion() < 534 || !_SlideshowEnabled)) || (!_HandleTouchEventOnly && $JssorUtils$.$GetWebKitVersion() < 535)) { 1611 // $JssorUtils$.$EnableHWA(elmt); 1612 //} 1613 if (!_HandleTouchEventOnly || ($JssorUtils$.$GetWebKitVersion() < 534 || !_SlideshowEnabled)) { 1614 $JssorUtils$.$EnableHWA(elmt); 1615 } 1616 } 1617 } 1618 1619 var childElements = $JssorUtils$.$GetChildren(elmt); 1620 1621 $JssorUtils$.$Each(childElements, function (childElement, i) { 1622 1623 var uAttribute = $JssorUtils$.$GetAttributeEx(childElement, "u"); 1624 if (uAttribute == "player" && !_PlayerInstanceElement) { 1625 _PlayerInstanceElement = childElement; 1626 if (_PlayerInstanceElement.pInstance) { 1627 PlayerAvailableEventHandler(); 1628 } 1629 else { 1630 $JssorUtils$.$AddEvent(_PlayerInstanceElement, "dataavailable", PlayerAvailableEventHandler); 1631 } 1632 } 1633 1634 if (uAttribute == "caption") { 1635 if (!$JssorUtils$.$IsBrowserIE() && !fresh) { 1636 var captionElement = $JssorUtils$.$CloneNode(childElement, true); 1637 $JssorUtils$.$InsertBefore(elmt, captionElement, childElement); 1638 $JssorUtils$.$RemoveChild(elmt, childElement); 1639 childElement = captionElement; 1640 1641 fresh = true; 1642 } 1643 } 1644 else if (!_ContentRefreshed && !level && !_ImageItem && $JssorUtils$.$GetAttributeEx(childElement, "u") == "image") { 1645 _ImageItem = childElement; 1646 1647 if (_ImageItem) { 1648 if (_ImageItem.tagName == "A") { 1649 _LinkItemOrigin = _ImageItem; 1650 $JssorUtils$.$SetStyles(_LinkItemOrigin, _StyleDef); 1651 1652 _LinkItem = $JssorUtils$.$CloneNode(_ImageItem, false); 1653 //cancel click event on <A> element when a drag of slide succeeded 1654 $JssorUtils$.$AddEvent(_LinkItem, "click", LinkClickEventHandler); 1655 1656 $JssorUtils$.$SetStyles(_LinkItem, _StyleDef); 1657 $JssorUtils$.$CssDisplay(_LinkItem, "block"); 1658 $JssorUtils$.$CssOpacity(_LinkItem, 0); 1659 $JssorUtils$.$Css(_LinkItem, "backgroundColor", "#000"); 1660 1661 _ImageItem = $JssorUtils$.$FindFirstChildByTag(_ImageItem, "IMG"); 1662 1663 $JssorDebug$.$Execute(function () { 1664 if (!_ImageItem) { 1665 $JssorDebug$.$Error("slide html code definition error, no 'IMG' found in a 'image with link' slide.\r\n" + elmt.outerHTML); 1666 } 1667 }); 1668 } 1669 _ImageItem.border = 0; 1670 1671 $JssorUtils$.$SetStyles(_ImageItem, _StyleDef); 1672 } 1673 } 1674
1675 RefreshContent(childElement, fresh, level + 1); 1676 }); 1677 } 1678 1679 _SelfSlideItem.$OnInnerOffsetChange = function (oldOffset, newOffset) { 1680 var slidePosition = _DisplayPieces - newOffset; 1681 1682 SetPosition(_Wrapper, slidePosition); 1683 1684 //following lines are for future usage, not ready yet 1685 //if (!_IsDragging || !_IsCaptionSliderPlayingWhenDragStart) { 1686 // var _DealWithParallax; 1687 // if (IsCurrentSlideIndex(slideIndex)) { 1688 // if (_CaptionSliderOptions.$PlayOutMode == 2) 1689 // _DealWithParallax = true; 1690 // } 1691 // else { 1692 // if (!_CaptionSliderOptions.$PlayInMode) { 1693 // //PlayInMode: 0 none 1694 // _CaptionSliderIn.$GoToEnd(); 1695 // } 1696 // //else if (_CaptionSliderOptions.$PlayInMode == 1) { 1697 // // //PlayInMode: 1 chain 1698 // // _CaptionSliderIn.$GoToBegin(); 1699 // //} 1700 // else if (_CaptionSliderOptions.$PlayInMode == 2) { 1701 // //PlayInMode: 2 parallel 1702 // _DealWithParallax = true; 1703 // } 1704 // } 1705 1706 // if (_DealWithParallax) { 1707 // _CaptionSliderIn.$GoToPosition((_CaptionSliderIn.$GetPosition_OuterEnd() - _CaptionSliderIn.$GetPosition_OuterBegin()) * Math.abs(newOffset - 1) * .8 + _CaptionSliderIn.$GetPosition_OuterBegin()); 1708 // } 1709 //} 1710 }; 1711 1712 _SelfSlideItem.$GetCaptionSliderIn = function () { 1713 return _CaptionSliderIn; 1714 }; 1715 1716 _SelfSlideItem.$GetCaptionSliderOut = function () { 1717 return _CaptionSliderOut; 1718 }; 1719 1720 _SelfSlideItem.$Index = slideIndex; 1721 1722 $JssorEventManager$.call(_SelfSlideItem); 1723 1724 //SlideItem Constructor 1725 { 1726 1727 var thumb = $JssorUtils$.$FindFirstChildByAttribute(slideElmt, "thumb"); 1728 if (thumb) { 1729 _SelfSlideItem.$Thumb = $JssorUtils$.$CloneNode(thumb, true); 1730 $JssorUtils$.$RemoveAttribute(thumb, "id"); 1731 $JssorUtils$.$HideElement(thumb); 1732 } 1733 $JssorUtils$.$ShowElement(slideElmt); 1734 1735 _LoadingScreen = $JssorUtils$.$CloneNode(_LoadingContainer, true); 1736 $JssorUtils$.$CssZIndex(_LoadingScreen, 1000); 1737 1738 //cancel click event on <A> element when a drag of slide succeeded 1739 $JssorUtils$.$AddEvent(slideElmt, "click", LinkClickEventHandler); 1740 1741 ResetCaptionSlider(true); 1742 1743 _SelfSlideItem.$Image = _ImageItem; 1744 _SelfSlideItem.$Link = _LinkItem; 1745 1746 _SelfSlideItem.$Item = slideElmt; 1747 1748 _SelfSlideItem.$Wrapper = _Wrapper = slideElmt; 1749 $JssorUtils$.$AppendChild(_Wrapper, _LoadingScreen); 1750 1751 _SelfSlider.$On(203, ParkEventHandler); 1752 _SelfSlider.$On(22, DragStartEventHandler); 1753 _SelfSlider.$On(24, SwipeStartEventHandler); 1754 1755 $JssorDebug$.$Execute(function () { 1756 _SequenceNumber = _SlideItemCreatedCount++; 1757 }); 1758 1759 $JssorDebug$.$Execute(function () { 1760 $JssorUtils$.$SetAttribute(_Wrapper, "debug-id", "slide-" + slideIndex); 1761 }); 1762 } 1763 } 1764 //SlideItem 1765 1766 //Processor 1767 function Processor(slideIndex, slideshowProcessor, captionSliderIn, captionSliderOut) { 1768 1769 var _SelfProcessor = this; 1770 1771 var _ProgressBegin = 0; 1772 var _SlideshowBegin = 0; 1773 var _SlideshowEnd; 1774 var _CaptionInBegin; 1775 var _IdleBegin; 1776 var _IdleEnd; 1777 var _ProgressEnd; 1778 1779 var _IsSlideshowRunning; 1780 var _IsRollingBack; 1781 1782 var _PlayerInstance; 1783 var _IsPlayerOnService; 1784 1785 var slideItem = _SlideItems[slideIndex]; 1786
1787 $JssorAnimator$.call(_SelfProcessor, 0, 0); 1788 1789 function UpdateLink() { 1790 1791 $JssorUtils$.$ClearChildren(_LinkContainer); 1792 1793 if (_ShowLink && _IsSlideshowRunning && slideItem.$Link) { 1794 $JssorUtils$.$AppendChild(_LinkContainer, slideItem.$Link); 1795 } 1796 1797 $JssorUtils$.$ShowElement(_LinkContainer, _IsSlideshowRunning || !slideItem.$Image); 1798 } 1799 1800 function ProcessCompleteEventHandler() { 1801 1802 if (_IsRollingBack) { 1803 _IsRollingBack = false; 1804 _SelfSlider.$TriggerEvent(JssorSlider.$EVT_ROLLBACK_END, slideIndex, _IdleEnd, _ProgressBegin, _IdleBegin, _IdleEnd, _ProgressEnd); 1805 _SelfProcessor.$GoToPosition(_IdleBegin); 1806 } 1807 1808 _SelfProcessor.$Replay(); 1809 } 1810 1811 function PlayerSwitchEventHandler(isOnService) { 1812 _IsPlayerOnService = isOnService; 1813 1814 _SelfProcessor.$Stop(); 1815 _SelfProcessor.$Replay(); 1816 } 1817 1818 _SelfProcessor.$Replay = function () { 1819 1820 var currentPosition = _SelfProcessor.$GetPosition_Display(); 1821 1822 if (!_IsDragging && !_IsSliding && !_IsPlayerOnService && _CurrentSlideIndex == slideIndex) { 1823 1824 if (!currentPosition) { 1825 if (_SlideshowEnd && !_IsSlideshowRunning) { 1826 _IsSlideshowRunning = true; 1827 1828 _SelfProcessor.$OpenSlideshowPanel(true); 1829 1830 _SelfSlider.$TriggerEvent(JssorSlider.$EVT_SLIDESHOW_START, slideIndex, _ProgressBegin, _SlideshowBegin, _SlideshowEnd, _ProgressEnd); 1831 } 1832 1833 UpdateLink(); 1834 } 1835 1836 var toPosition; 1837 var stateEvent = JssorSlider.$EVT_STATE_CHANGE; 1838 1839 if (currentPosition != _ProgressEnd) { 1840 if (currentPosition == _IdleEnd) { 1841 toPosition = _ProgressEnd; 1842 } 1843 else if (currentPosition == _IdleBegin) { 1844 toPosition = _IdleEnd; 1845 } 1846 else if (!currentPosition) { 1847 toPosition = _IdleBegin; 1848 } 1849 else if (currentPosition > _IdleEnd) { 1850 _IsRollingBack = true; 1851 toPosition = _IdleEnd; 1852 stateEvent = JssorSlider.$EVT_ROLLBACK_START; 1853 } 1854 else { 1855 //continue from break (by drag or lock) 1856 toPosition = _SelfProcessor.$GetPlayToPosition(); 1857 } 1858 } 1859 1860 _SelfSlider.$TriggerEvent(stateEvent, slideIndex, currentPosition, _ProgressBegin, _IdleBegin, _IdleEnd, _ProgressEnd); 1861 1862 var allowAutoPlay = _AutoPlay && (!_HoverToPau
1862se || _HoverStatus); 1863 1864 if (currentPosition == _ProgressEnd) { 1865 allowAutoPlay && slideItem.$GoForNextSlide(); 1866 } 1867 else if (allowAutoPlay || currentPosition != _IdleEnd) { 1868 _SelfProcessor.$PlayToPosition(toPosition, ProcessCompleteEventHandler); 1869 } 1870 } 1871 }; 1872 1873 _SelfProcessor.$Abort = function () { 1874 _SlideshowRunner && _SlideshowRunner.$Index == slideIndex && _SlideshowRunner.$Clear(); 1875 1876 var currentPosition = _SelfProcessor.$GetPosition_Display(); 1877 if (currentPosition < _ProgressEnd) { 1878 _SelfSlider.$TriggerEvent(JssorSlider.$EVT_STATE_CHANGE, slideIndex, -currentPosition - 1, _ProgressBegin, _IdleBegin, _IdleEnd, _ProgressEnd); 1879 } 1880 }; 1881 1882 _SelfProcessor.$OpenSlideshowPanel = function (open) { 1883 if (slideshowProcessor) { 1884 $JssorUtils$.$CssOverflow(_SlideshowPanel, open && slideshowProcessor.$Transition.$Outside ? "" : "hidden"); 1885 } 1886 }; 1887 1888 _SelfProcessor.$OnInnerOffsetChange = function (oldPosition, newPosition) { 1889 1890 if (_IsSlideshowRunning && newPosition >= _SlideshowEnd) { 1891 _IsSlideshowRunning = false; 1892 UpdateLink(); 1893 slideItem.$UnhideContentForSlideshow(); 1894 _SlideshowRunner.$Clear(); 1895 1896 _SelfSlider.$TriggerEvent(JssorSlider.$EVT_SLIDESHOW_END, slideIndex, _ProgressBegin, _SlideshowBegin, _SlideshowEnd, _ProgressEnd); 1897 } 1898 1899 _SelfSlider.$TriggerEvent(JssorSlider.$EVT_PROGRESS_CHANGE, slideIndex, newPosition, _ProgressBegin, _IdleBegin, _IdleEnd, _ProgressEnd); 1900 }; 1901 1902 _SelfProcessor.$SetPlayer = function (playerInstance) { 1903 if (playerInstance && !_PlayerInstance) { 1904 _PlayerInstance = playerInstance; 1905 1906 playerInstance.$On($JssorPlayer$.$EVT_SWITCH, PlayerSwitchEventHandler); 1907 } 1908 }; 1909 1910 //Processor Constructor 1911 { 1912 if (slideshowProcessor) { 1913 _SelfProcessor.$Chain(slideshowProcessor); 1914 } 1915 1916 _SlideshowEnd = _SelfProcessor.$GetPosition_OuterEnd(); 1917 _CaptionInBegin = _SelfProcessor.$GetPosition_OuterEnd(); 1918 _SelfProcessor.$Chain(captionSliderIn); 1919 _IdleBegin = captionSliderIn.$GetPosition_OuterEnd(); 1920 _IdleEnd = _IdleBegin + _Options.$AutoPlayInterval; 1921 1922 captionSliderOut.$Shift(_IdleEnd); 1923 _SelfProcessor.$Combine(captionSliderOut); 1924 _ProgressEnd = _SelfProcessor.$GetPosition_OuterEnd(); 1925 } 1926 } 1927 //Processor 1928 //private classes 1929 1930 function SetPosition(elmt, position) { 1931 var orientation = _DragOrientation > 0 ? _DragOrientation : _PlayOrientation; 1932 var x = _StepLengthX * position * (orientation & 1); 1933 var y = _StepLengthY * position * ((orientation >> 1) & 1); 1934 1935 if (!$JssorUtils$.$IsBrowserChrome()) { 1936 x = Math.round(x); 1937 y = Math.round(y); 1938 } 1939 1940 if ($JssorUtils$.$IsBrowserIE() && $JssorUtils$.$GetBrowserVersion() >= 10 && $JssorUtils$.$GetBrowserVersion() < 11) { 1941 elmt.style.msTransform = "translate(" + x + "px, " + y + "px)"; 1942 } 1943 else if ($JssorUtils$.$IsBrowserChrome() && $JssorUtils$.$GetBrowserVersion() >= 30 && $JssorUtils$.$GetBrowserVersion() < 34) { 1944 elmt.style.WebkitTransition = "transform 0s"; 1945 elmt.style.WebkitTransform = "translate3d(" + x + "px, " + y + "px, 0px) perspective(2000px)"; 1946 } 1947 else { 1948 $JssorUtils$.$CssLeft(elmt, x); 1949 $JssorUtils$.$CssTop(elmt, y); 1950 } 1951 } 1952 1953 //Event handling begin 1954 1955 function OnMouseDown(event) { 1956 _LastDragSucceded = 0; 1957 1958 var tagName = $JssorUtils$.$GetEventSrcElement(event).tagName; 1959 if (!_DragOrientationRegistered && tagName != "INPUT" && tagName != "TEXTAREA" && RegisterDrag()) { 1960 OnDragStart(event); 1961 } 1962 } 1963 1964 function OnDragStart(event) { 1965 _DragStart_CarouselPlaying = _IsSliding; 1966 1967 _IsDragging = true; 1968 _DragInvalid = false;
1969 _LoadingTicket = null; 1970 1971 $JssorUtils$.$AddEvent(document, _MoveEvent, OnDragMove); 1972 1973 _LastTimeMoveByDrag = $JssorUtils$.$GetNow() - 50; 1974 _DragStartPlayToPosition = _CarouselPlayer.$GetPlayToPosition(); 1975 _CarouselPlayer.$Stop(); 1976 1977 if (!_DragStart_CarouselPlaying) 1978 _DragOrientation = 0; 1979 1980 if (_HandleTouchEventOnly) { 1981 var touchPoint = event.touches[0]; 1982 _DragStartMouseX = touchPoint.clientX; 1983 _DragStartMouseY = touchPoint.clientY; 1984 } 1985 else { 1986 var mousePoint = $JssorUtils$.$GetMousePosition(event); 1987 1988 _DragStartMouseX = mousePoint.x; 1989 _DragStartMouseY = mousePoint.y; 1990 1991 $JssorUtils$.$CancelEvent(event); 1992 } 1993 1994 _DragOffsetTotal = 0; 1995 _DragOffsetLastTime = 0; 1996 _DragIndexAdjust = 0; 1997 _DragStartPosition = _Conveyor.$GetPosition(); 1998 1999 //Trigger EVT_DRAGSTART 2000 _SelfSlider.$TriggerEvent(JssorSlider.$EVT_DRAG_START, GetRealIndex(_DragStartPosition), _DragStartPosition, event); 2001 } 2002 2003 function OnDragMove(event) { 2004 if (_IsDragging && (!$JssorUtils$.$IsBrowserIe9Earlier() || event.button)) { 2005 var actionPoint; 2006 2007 if (_HandleTouchEventOnly) { 2008 var touches = event.touches; 2009 if (touches && touches.length > 0) { 2010 actionPoint = new $JssorPoint$(touches[0].clientX, touches[0].clientY); 2011 } 2012 } 2013 else { 2014 actionPoint = $JssorUtils$.$GetMousePosition(event); 2015 } 2016 2017 if (actionPoint) { 2018 var distanceX = actionPoint.x - _DragStartMouseX; 2019 var distanceY = actionPoint.y - _DragStartMouseY; 2020 2021 2022 if (Math.floor(_DragStartPosition) != _DragStartPosition) 2023 _DragOrientation = _DragOrientation || (_PlayOrientation & _DragOrientationRegistered); 2024 2025 if ((distanceX || distanceY) && !_DragOrientation) { 2026 if (_DragOrientationRegistered == 3) { 2027 if (Math.abs(distanceY) > Math.abs(distanceX)) { 2028 _DragOrientation = 2; 2029 } 2030 else 2031 _DragOrientation = 1; 2032 } 2033 else { 2034 _DragOrientation = _DragOrientationRegistered; 2035 } 2036 2037 if (_HandleTouchEventOnly && _DragOrientation == 1 && Math.abs(distanceY) - Math.abs(distanceX) > 3) { 2038 _DragInvalid = true; 2039 } 2040 } 2041 2042 if (_DragOrientation) { 2043 var distance = distanceY; 2044 var stepLength = _StepLengthY; 2045 2046 if (_DragOrientation == 1) { 2047 distance = distanceX; 2048 stepLength = _StepLengthX; 2049 } 2050 2051 if (!(_Loop & 1)) { 2052 if (distance > 0) { 2053 var normalDistance = stepLength * _CurrentSlideIndex; 2054 var sqrtDistance = distance - normalDistance; 2055 if (sqrtDistance > 0) { 2056 distance = normalDistance + Math.sqrt(sqrtDistance) * 5; 2057 } 2058 } 2059 2060 if (distance < 0) { 2061 var normalDistance = stepLength * (_SlideCount - _DisplayPieces - _CurrentSlideIndex); 2062 var sqrtDistance = -distance - normalDistance; 2063 2064 if (sqrtDistance > 0) { 2065 distance = -normalDistance - Math.sqrt(sqrtDistance) * 5; 2066 } 2067 } 2068 } 2069 2070 if (_DragOffsetTotal - _DragOffsetLastTime < -2) { 2071 _DragIndexAdjust = 1; 2072 } 2073 else if (_DragOffsetTotal - _DragOffsetLastTime > 2) { 2074 _DragIndexAdjust = 0; 2075 } 2076 2077 _DragOffsetLastTime = _DragOffsetTotal; 2078 _DragOffsetTotal = distance; 2079 _PositionToGoByDrag = _DragStartPosition - _DragOffsetTotal / stepLength / (_ScaleRatio || 1); 2080 2081 if (_DragOffsetTotal && _DragOrientation && !_DragInvalid) { 2082 $JssorUtils$.$CancelEvent(event); 2083 if (!_IsSliding) {
2084 _CarouselPlayer.$StandBy(_PositionToGoByDrag); 2085 } 2086 else 2087 _CarouselPlayer.$SetStandByPosition(_PositionToGoByDrag); 2088 } 2089 else if ($JssorUtils$.$IsBrowserIe9Earlier()) { 2090 $JssorUtils$.$CancelEvent(event); 2091 } 2092 } 2093 } 2094 } 2095 else { 2096 OnDragEnd(event); 2097 } 2098 } 2099 2100 function OnDragEnd(event) { 2101 UnregisterDrag(); 2102 2103 if (_IsDragging) { 2104 2105 _IsDragging = false; 2106 2107 _LastTimeMoveByDrag = $JssorUtils$.$GetNow(); 2108 2109 $JssorUtils$.$RemoveEvent(document, _MoveEvent, OnDragMove); 2110 2111 _LastDragSucceded = _DragOffsetTotal; 2112 2113 _LastDragSucceded && $JssorUtils$.$CancelEvent(event); 2114 2115 _CarouselPlayer.$Stop(); 2116 2117 var currentPosition = _Conveyor.$GetPosition(); 2118 2119 //Trigger EVT_DRAG_END 2120 _SelfSlider.$TriggerEvent(JssorSlider.$EVT_DRAG_END, GetRealIndex(currentPosition), currentPosition, GetRealIndex(_DragStartPosition), _DragStartPosition, event); 2121 2122 var toPosition = Math.floor(_DragStartPosition); 2123 2124 if (Math.abs(_DragOffsetTotal) >= _Options.$MinDragOffsetToSlide) { 2125 toPosition = Math.floor(currentPosition); 2126 toPosition += _DragIndexAdjust; 2127 } 2128 2129 if (!(_Loop & 1)) { 2130 toPosition = Math.min(_SlideCount - _DisplayPieces, Math.max(toPosition, 0)); 2131 } 2132 2133 var t = Math.abs(toPosition - currentPosition); 2134 t = 1 - Math.pow(1 - t, 5); 2135 2136 if (!_LastDragSucceded && _DragStart_CarouselPlaying) { 2137 _CarouselPlayer.$Continue(_DragStartPlayToPosition); 2138 } 2139 else if (currentPosition == toPosition) { 2140 _CurrentSlideItem.$EnablePlayer(); 2141 _CurrentSlideItem.$TryActivate(); 2142 } 2143 else { 2144 _CarouselPlayer.$PlayCarousel(currentPosition, toPosition, t * _SlideDuration); 2145 } 2146 } 2147 } 2148 //Event handling end 2149 2150 function SetCurrentSlideIndex(index) { 2151 _PrevSlideItem = _SlideItems[_CurrentSlideIndex]; 2152 _PreviousSlideIndex = _CurrentSlideIndex; 2153 _CurrentSlideIndex = GetRealIndex(index); 2154 _CurrentSlideItem = _SlideItems[_CurrentSlideIndex]; 2155 ResetNavigator(index); 2156 return _CurrentSlideIndex; 2157 } 2158 2159 function OnPark(slideIndex, prevIndex) { 2160 _DragOrientation = 0; 2161 2162 SetCurrentSlideIndex(slideIndex); 2163 2164 //Trigger EVT_PARK 2165 _SelfSlider.$TriggerEvent(JssorSlider.$EVT_PARK, GetRealIndex(slideIndex), prevIndex); 2166 } 2167 2168 function ResetNavigator(index, temp) { 2169 _TempSlideIndex = index; 2170 $JssorUtils$.$Each(_Navigators, function (navigator) { 2171 navigator.$SetCurrentIndex(GetRealIndex(index), index, temp); 2172 }); 2173 } 2174 2175 function RegisterDrag() { 2176 var dragRegistry = JssorSlider.$DragRegistry || 0; 2177 var dragOrientation = _DragEnabled; 2178 if (_HandleTouchEventOnly) 2179 (dragOrientation & 1) && (dragOrientation &= 1); 2180 JssorSlider.$DragRegistry |= dragOrientation; 2181 2182 return (_DragOrientationRegistered = dragOrientation & ~dragRegistry); 2183 } 2184 2185 function UnregisterDrag() { 2186 if (_DragOrientationRegistered) { 2187 JssorSlider.$DragRegistry &= ~_DragEnabled; 2188 _DragOrientationRegistered = 0; 2189 } 2190 } 2191 2192 function CreatePanel() { 2193 var div = $JssorUtils$.$CreateDivElement(); 2194 2195 $JssorUtils$.$SetStyles(div, _StyleDef); 2196 $JssorUtils$.$CssPosition(div, "absolute"); 2197 2198 return div; 2199 } 2200 2201 function GetRealIndex(index) { 2202 return (index % _SlideCount + _SlideCount) % _SlideCount; 2203 } 2204 2205 function IsCurrentSlideIndex(index) { 2206 return GetRealIndex(index) == _CurrentSlideIndex; 2207 } 2208 2209 function IsPreviousSlideIndex(index) { 2210 return GetRealIndex(index) == _PreviousSlideIndex; 2211 } 2212 2213 //Navigation Request Handler 2214 function NavigationClickHandler(index, relative) { 2215 if (relative) { 2216 if (!_Loop) { 2217 //Stop at threshold 2218 index = Math.min(Math.max(index + _TempSlideIndex, 0), _SlideCount - _DisplayPieces); 2219 relative = false;
2220 } 2221 else if (_Loop & 2) { 2222 //Rewind 2223 index = GetRealIndex(index + _TempSlideIndex); 2224 relative = false; 2225 } 2226 } 2227 PlayTo(index, _Options.$SlideDuration, relative); 2228 } 2229 2230 function ShowNavigators() { 2231 $JssorUtils$.$Each(_Navigators, function (navigator) { 2232 navigator.$Show(navigator.$Options.$ChanceToShow > _HoverStatus); 2233 }); 2234 } 2235 2236 function MainContainerMouseOutEventHandler(event) { 2237 event = $JssorUtils$.$GetEvent(event); 2238 // we have to watch out for a tricky case: a mouseout occurs on a 2239 // child element, but the mouse is still inside the parent element. 2240 // the mouseout event will bubble up to us. this happens in all 2241 // browsers, so we need to correct for this. technique from: 2242 // http://www.quirksmode.org/js/events_mouse.html 2243 var from = event.target ? event.target : event.srcElement; 2244 var to = event.relatedTarget ? event.relatedTarget : event.toElement; 2245 2246 if (!$JssorUtils$.$IsChild(elmt, from) || $JssorUtils$.$IsChild(elmt, to)) { 2247 // the mouseout needs to start from this or a child node, and it 2248 // needs to end on this or an outer node. 2249 return; 2250 } 2251 2252 _HoverStatus = 1; 2253 2254 ShowNavigators(); 2255 2256 _SlideItems[_CurrentSlideIndex].$TryActivate(); 2257 } 2258 2259 function MainContainerMouseOverEventHandler() { 2260 _HoverStatus = 0; 2261 2262 ShowNavigators(); 2263 } 2264 2265 function AdjustSlidesContainerSize() { 2266 _StyleDef = { $Width: _SlideWidth, $Height: _SlideHeight, $Top: 0, $Left: 0 }; 2267 2268 $JssorUtils$.$Each(_SlideElmts, function (slideElmt, i) { 2269 2270 $JssorUtils$.$SetStyles(slideElmt, _StyleDef); 2271 $JssorUtils$.$CssPosition(slideElmt, "absolute"); 2272 $JssorUtils$.$CssOverflow(slideElmt, "hidden"); 2273 2274 $JssorUtils$.$HideElement(slideElmt); 2275 }); 2276 2277 $JssorUtils$.$SetStyles(_LoadingContainer, _StyleDef); 2278 } 2279 2280 function PlayToOffset(offset, slideDuration) { 2281 PlayTo(offset, slideDuration, true); 2282 } 2283 2284 function PlayTo(slideIndex, slideDuration, relative) { 2285 /// <summary> 2286 /// PlayTo( slideIndex [, slideDuration] ); //Play slider to position 'slideIndex' within a period calculated base on 'slideDuration'. 2287 /// </summary> 2288 /// <param name="slideIndex" type="Number"> 2289 /// slide slideIndex or position will be playing to 2290 /// </param> 2291 /// <param name="slideDuration" type="Number" optional="true"> 2292 /// base slide duration in milliseconds to calculate the whole duration to complete this play request. 2293 /// default value is '$SlideDuration' value which is specified when initialize the slider. 2294 /// </param> 2295 /// http://msdn.microsoft.com/en-us/library/vstudio/bb385682.aspx 2296 /// http://msdn.microsoft.com/en-us/library/vstudio/hh542720.aspx 2297 if (_CarouselEnabled && (!_IsDragging || _Options.$NaviQuitDrag)) { 2298 _IsSliding = true; 2299 _IsDragging = false; 2300 _CarouselPlayer.$Stop(); 2301 2302 { 2303 //Slide Duration 2304 if ($JssorUtils$.$IsUndefined(slideDuration)) 2305 slideDuration = _SlideDuration; 2306 2307 var positionDisplay = _Carousel.$GetPosition_Display(); 2308 var positionTo = slideIndex; 2309 if (relative) { 2310 positionTo = positionDisplay + slideIndex; 2311 if (slideIndex > 0) 2312 positionTo = Math.ceil(positionTo); 2313 else 2314 positionTo = Math.floor(positionTo); 2315 } 2316 2317 2318 if (!(_Loop & 1)) {
2319 positionTo = GetRealIndex(positionTo); 2320 positionTo = Math.max(0, Math.min(positionTo, _SlideCount - _DisplayPieces)); 2321 } 2322 2323 var positionOffset = (positionTo - positionDisplay) % _SlideCount; 2324 positionTo = positionDisplay + positionOffset; 2325 2326 var duration = positionDisplay == positionTo ? 0 : slideDuration * Math.abs(positionOffset); 2327 duration = Math.min(duration, slideDuration * _DisplayPieces * 1.5); 2328 2329 _CarouselPlayer.$PlayCarousel(positionDisplay, positionTo, duration || 1); 2330 } 2331 } 2332 } 2333 2334 //private functions 2335 2336 //member functions 2337 2338 _SelfSlider.$PlayTo = PlayTo; 2339 2340 _SelfSlider.$GoTo = function (slideIndex) { 2341 /// <summary> 2342 /// instance.$GoTo( slideIndex ); //Go to the specifed slide immediately with no play. 2343 /// </summary> 2344 PlayTo(slideIndex, 1); 2345 }; 2346 2347 _SelfSlider.$Next = function () { 2348 /// <summary> 2349 /// instance.$Next(); //Play the slider to next slide. 2350 /// </summary> 2351 PlayToOffset(1); 2352 }; 2353 2354 _SelfSlider.$Prev = function () { 2355 /// <summary> 2356 /// instance.$Prev(); //Play the slider to previous slide. 2357 /// </summary> 2358 PlayToOffset(-1); 2359 }; 2360 2361 _SelfSlider.$Pause = function () { 2362 /// <summary> 2363 /// instance.$Pause(); //Pause the slider, prevent it from auto playing. 2364 /// </summary> 2365 _AutoPlay = false; 2366 }; 2367 2368 _SelfSlider.$Play = function () { 2369 /// <summary> 2370 /// instance.$Play(); //Start auto play if the slider is currently paused. 2371 /// </summary> 2372 if (!_AutoPlay) { 2373 _AutoPlay = true; 2374 _SlideItems[_CurrentSlideIndex] && _SlideItems[_CurrentSlideIndex].$TryActivate(); 2375 } 2376 }; 2377 2378 _SelfSlider.$SetSlideshowTransitions = function (transitions) { 2379 /// <summary> 2380 /// instance.$SetSlideshowTransitions( transitions ); //Reset slideshow transitions for the slider. 2381 /// </summary> 2382 $JssorDebug$.$Execute(function () { 2383 if (!transitions || !transitions.length) { 2384 $JssorDebug$.$Error("Can not set slideshow transitions, no transitions specified."); 2385 } 2386 }); 2387 2388 _Options.$SlideshowOptions.$Transitions = transitions; 2389 }; 2390 2391 _SelfSlider.$SetCaptionTransitions = function (transitions) { 2392 /// <summary> 2393 /// instance.$SetCaptionTransitions( transitions ); //Reset caption transitions for the slider. 2394 /// </summary> 2395 $JssorDebug$.$Execute(function () { 2396 if (!transitions || !transitions.length) { 2397 $JssorDebug$.$Error("Can not set caption transitions, no transitions specified"); 2398 } 2399 }); 2400 2401 _CaptionSliderOptions.$CaptionTransitions = transitions; 2402 _CaptionSliderOptions.$Version = $JssorUtils$.$GetNow(); 2403 }; 2404 2405 _SelfSlider.$SlidesCount = function () { 2406 /// <summary> 2407 /// instance.$SlidesCount(); //Retrieve slides count of the slider. 2408 /// </summary> 2409 return _SlideElmts.length; 2410 }; 2411 2412 _SelfSlider.$CurrentIndex = function () { 2413 /// <summary> 2414 /// instance.$CurrentIndex(); //Retrieve current slide index of the slider. 2415 /// </summary> 2416 return _CurrentSlideIndex; 2417 }; 2418 2419 _SelfSlider.$IsAutoPlaying = function () { 2420 /// <summary> 2421 /// instance.$IsAutoPlaying(); //Retrieve auto play status of the slider. 2422 /// </summary> 2423 return _AutoPlay; 2424 }; 2425 2426 _SelfSlider.$IsDragging = function () { 2427 /// <summary> 2428 /// instance.$IsDragging(); //Retrieve drag status of the slider. 2429 /// </summary> 2430 return _IsDragging; 2431 }; 2432 2433 _SelfSlider.$IsSliding = function () { 2434 /// <summary> 2435 /// instance.$IsSliding(); //Retrieve right<-->left sliding status of the slider. 2436 /// </summary> 2437 return _IsSliding; 2438 }; 2439 2440 _SelfSlider.$IsMouseOver = function () { 2441 /// <summary> 2442 /// instance.$IsMouseOver(); //Retrieve mouse over status of the slider. 2443 /// </summary> 2444 return !_HoverStatus; 2445 }; 2446 2447 _SelfSlider.$LastDragSucceded = function () { 2448 /// <summary> 2449 /// instance.$IsLastDragSucceded(); //Retrieve last drag succeded status, returns 0 if failed, returns drag offset if succeded 2450 /// </summary> 2451 return _LastDragSucceded; 2452 }; 2453 2454 _SelfSlider.$GetOriginalWidth = function () { 2455 /// <summary> 2456 /// instance.$GetOriginalWidth(); //Retrieve original width of the slider. 2457 /// </summary> 2458 return $JssorUtils$.$CssWidth(_ScaleWrapper || elmt); 2459 }; 2460 2461 _SelfSlider.$GetOriginalHeight = function () { 2462 /// <summary> 2463 /// instance.$GetOriginalWidth(); //Retrieve original height of the slider. 2464 /// </summary> 2465 return $JssorUtils$.$CssHeight(_ScaleWrapper || elmt); 2466 }; 2467 2468 _SelfSlider.$GetScaleWidth = function () { 2469 /// <summary> 2470 /// instance.$GetScaleWidth(); //Retrieve scaled width the slider currently displays. 2471 /// </summary> 2472 return $JssorUtils$.$CssWidth(elmt); 2473 }; 2474 2475 _SelfSlider.$GetScaleHeight = function () { 2476 /// <summary> 2477 /// instance.$GetScaleHeight(); //Retrieve scaled height the slider currently displays. 2478 /// </summary> 2479 return $JssorUtils$.$CssHeight(elmt); 2480 }; 2481 2482 _SelfSlider.$SetScaleWidth = function (width) { 2483 /// <summary> 2484 /// instance.$SetScaleWidth( width ); //Scale the slider to new width and keep aspect ratio. 2485 /// </summary> 2486 $JssorDebug$.$Execute(function () { 2487 if (!width || width < 0) { 2488 $JssorDebug$.$Fail("'$SetScaleWidth' error, 'width' should be positive value."); 2489 } 2490 }); 2491 2492 if (!_ScaleWrapper) { 2493 $JssorDebug$.$Execute(function () { 2494 var originalWidthStr = $JssorUtils$.$Css(elmt, "width"); 2495 var originalHeightStr = $JssorUtils$.$Css(elmt, "height"); 2496 var originalWidth = $JssorUtils$.$CssP(elmt, "width"); 2497 var originalHeight = $JssorUtils$.$CssP(elmt, "height"); 2498 2499 if (!originalWidthStr) { 2500 $JssorDebug$.$Fail("Cannot scale jssor slider, 'width' of 'outer container' not specified. Please specify 'width' in pixel. e.g. 'width: 600px;'"); 2501 } 2502 2503 if (!originalHeightStr) { 2504 $JssorDebug$.$Fail("Cannot scale jssor slider, 'he
2504ight' of 'outer container' not specified. Please specify 'height' in pixel. e.g. 'height: 300px;'"); 2505 } 2506 2507 if (originalWidthStr.indexOf('%') != -1) { 2508 $JssorDebug$.$Fail("Cannot scale jssor slider, 'width' of 'outer container' not valid. Please specify 'width' in pixel. e.g. 'width: 600px;'"); 2509 } 2510 2511 if (originalHeightStr.indexOf('%') != -1) { 2512 $JssorDebug$.$Fail("Cannot scale jssor slider, 'height' of 'outer container' not valid. Please specify 'height' in pixel. e.g. 'height: 300px;'"); 2513 } 2514 2515 if (!originalWidth) { 2516 $JssorDebug$.$Fail("Cannot scale jssor slider, 'width' of 'outer container' not valid. 'width' of 'outer container' should be positive number. e.g. 'width: 600px;'"); 2517 } 2518 2519 if (!originalHeight) { 2520 $JssorDebug$.$Fail("Cannot scale jssor slider, 'height' of 'outer container' not valid. 'height' of 'outer container' should be positive number. e.g. 'height: 300px;'"); 2521 } 2522 }); 2523 2524 //var innerWrapper = $JssorUtils$.$CloneNode(elmt, false); 2525 //$JssorUtils$.$RemoveAttribute(innerWrapper, "id"); 2526 var innerWrapper = $JssorUtils$.$CreateDivElement(document); 2527 $JssorUtils$.$CssCssText(innerWrapper, $JssorUtils$.$CssCssText(elmt)); 2528 $JssorUtils$.$SetClassName(innerWrapper, $JssorUtils$.$GetClassName(elmt)); 2529 2530 $JssorUtils$.$CssPosition(innerWrapper, "relative"); 2531 $JssorUtils$.$CssTop(innerWrapper, 0); 2532 $JssorUtils$.$CssLeft(innerWrapper, 0); 2533 $JssorUtils$.$CssOverflow(innerWrapper, "visible"); 2534 2535 //_ScaleWrapper = $JssorUtils$.$CloneNode(elmt, false); 2536 //$JssorUtils$.$RemoveAttribute(_ScaleWrapper, "id"); 2537 //$JssorUtils$.$CssCssText(_ScaleWrapper, ""); 2538 _ScaleWrapper = $JssorUtils$.$CreateDivElement(document); 2539 2540 $JssorUtils$.$CssPosition(_ScaleWrapper, "absolute"); 2541 $JssorUtils$.$CssTop(_ScaleWrapper, 0); 2542 $JssorUtils$.$CssLeft(_ScaleWrapper, 0); 2543 $JssorUtils$.$CssWidth(_ScaleWrapper, $JssorUtils$.$CssWidth(elmt)); 2544 $JssorUtils$.$CssHeight(_ScaleWrapper, $JssorUtils$.$CssHeight(elmt)); 2545 $JssorUtils$.$SetStyleTransformOrigin(_ScaleWrapper, "0 0"); 2546 2547 $JssorUtils$.$AppendChild(_ScaleWrapper, innerWrapper); 2548 2549 var children = $JssorUtils$.$GetChildren(elmt); 2550 $JssorUtils$.$AppendChild(elmt, _ScaleWrapper); 2551 2552 $JssorUtils$.$Css(elmt, "backgroundImage", ""); 2553 2554 var noMoveElmts = { 2555 "navigator": _BulletNavigatorOptions && _BulletNavigatorOptions.$Scale == false, 2556 "arrowleft": _ArrowNavigatorOptions && _ArrowNavigatorOptions.$Scale == false, 2557 "arrowright": _ArrowNavigatorOptions && _ArrowNavigatorOptions.$Scale == false, 2558 "thumbnavigator": _ThumbnailNavigatorOptions && _ThumbnailNavigatorOptions.$Scale == false, 2559 "thumbwrapper": _ThumbnailNavigatorOptions && _ThumbnailNavigatorOptions.$Scale == false 2560 }; 2561 2562 $JssorUtils$.$Each(children, function (child) { 2563 $JssorUtils$.$AppendChild(noMoveElmts[$JssorUtils$.$GetAttributeEx(child, "u")] ? elmt : innerWrapper, child); 2564 }); 2565 2566 $JssorUtils$.$ShowElement(innerWrapper); 2567 $JssorUtils$.$ShowElement(_ScaleWrapper); 2568 } 2569 2570 $JssorDebug$.$Execute(function () { 2571 if (!_InitialScrollWidth) { 2572 _InitialScrollWidth = _SelfSlider.$Elmt.scrollWidth; 2573 } 2574 }); 2575 2576 _ScaleRatio = width / $JssorUtils$.$CssWidth(_ScaleWrapper); 2577 $JssorUtils$.$SetStyleScale(_ScaleWrapper, _ScaleRatio); 2578 2579 $JssorUtils$.$CssWidth(elmt, width); 2580 $JssorUtils$.$CssHeight(elmt, _ScaleRatio * $JssorUtils$.$CssHeight(_ScaleWrapper)); 2581 2582 $JssorUtils$.$Each(_Navigators, function (navigator) { 2583 navigator.$Relocate(); 2584 }); 2585 }; 2586 2587 _SelfSlider.$GetVirtualIndex = function (index) { 2588 var parkingIndex = Math.ceil(GetRealIndex(_ParkingPosition / _StepLength)); 2589 var displayIndex = GetRealIndex(index - _CurrentSlideIndex + parkingIndex); 2590 2591 if (displayIndex > _DisplayPieces) { 2592 if (index - _CurrentSlideIndex > _SlideCount / 2) 2593 index -= _SlideCount; 2594 else if (index - _CurrentSlideIndex <= -_SlideCount / 2) 2595 index += _SlideCount; 2596 } 2597 else { 2598 index = _CurrentSlideIndex + displayIndex - parkingIndex; 2599 } 2600 2601 return index; 2602 }; 2603 2604 //member functions 2605 2606 //Inherit $JssorEventManager$ 2607 $JssorEventManager$.call(this); 2608 2609 //initialize member variables 2610 _SelfSlider.$Elmt = elmt = $JssorUtils$.$GetElement(elmt); 2611 //initialize member variables 2612 2613 var _InitialScrollWidth; //for debug only 2614 var _CaptionSliderCount = 1; //for debug only 2615 2616 $JssorDebug$.$Execute(function () { 2617 var outerContainerElmt = $JssorUtils$.$GetElement(elmt); 2618 if (!outerContainerElmt) 2619 $JssorDebug$.$Fail("Outer container '" + elmt + "' not found."); 2620 }); 2621 2622 var _Options = $JssorUtils$.$Extend({ 2623 $FillMode: 0, //[Optional] The way to fill image in slide, 0 stretch, 1 contain (keep aspect ratio and put all inside slide), 2 cover (keep aspect ratio and cover whole slide), 4 actual size, 5 contain for large image, actual size for small image, default value is 0 2624 $LazyLoading: 1, //[Optional] For image with lazy loading format (<IMG src2="url" .../>), by default it will be loaded only when the slide comes.
2625 //But an integer value (maybe 1, 2 or 3) indicates that how far of nearby slides should be loaded immediately as well, default value is 1. 2626 $StartIndex: 0, //[Optional] Index of slide to display when initialize, default value is 0 2627 $AutoPlay: false, //[Optional] Whether to auto play, default value is false 2628 $Loop: 1, //[Optional] Enable loop(circular) of carousel or not, 0: stop, 1: loop, 2 rewind, default value is 1 2629 $HWA: true, //[Optional] Enable hardware acceleration or not, default value is true 2630 $NaviQuitDrag: true, 2631 $AutoPlaySteps: 1, //[Optional] Steps to go of every play (this options applys only when slideshow disabled), default value is 1 2632 $AutoPlayInterval: 3000, //[Optional] Interval to play next slide since the previous stopped if a slideshow is auto playing, default value is 3000 2633 $PauseOnHover: 1, //[Optional] Whether to pause when mouse over if a slider is auto playing, 0 no pause, 1 pause for desktop, 2 pause for touch device, 3 pause for desktop and touch device, default value is 1 2634 2635 $SlideDuration: 500, //[Optional] Specifies default duration (swipe) for slide in milliseconds, default value is 400 2636 $SlideEasing: $JssorEasing$.$EaseOutQuad, //[Optional] Specifies easing for right to left animation, default value is $JssorEasing$.$EaseOutQuad 2637 $MinDragOffsetToSlide: 20, //[Optional] Minimum drag offset that trigger slide, default value is 20 2638 $SlideSpacing: 0, //[Optional] Space between each slide in pixels, default value is 0 2639 $DisplayPieces: 1, //[Optional] Number of pieces to display (the slideshow would be disabled if the value is set to greater than 1), default value is 1 2640 $ParkingPosition: 0, //[Optional] The offset position to park slide (this options applys only when slideshow disabled), default value is 0. 2641 $UISearchMode: 1, //[Optional] The way (0 parellel, 1 recursive, default value is recursive) to search UI components (slides container, loading screen, navigator container, arrow navigator container, thumbnail navigator container etc. 2642 $PlayOrientation: 1, //[Optional] Orientation to play slide (for auto play, navigation), 1 horizental, 2 vertical, 5 horizental reverse, 6 vertical reverse, default value is 1 2643 $DragOrientation: 1 //[Optional] Orientation to drag slide, 0 no drag, 1 horizental, 2 vertical, 3 both, default value is 1 (Note that the $DragOrientation should be the same as $PlayOrientation when $DisplayPieces is greater than 1, or parking position is not 0) 2644 2645 }, options); 2646 2647 //Sodo statement for development time intellisence only 2648 $JssorDebug$.$Execute(function () { 2649 _Options = $JssorUtils$.$Extend({ 2650 $ArrowKeyNavigation: undefined, 2651 $SlideWidth: undefined, 2652 $SlideHeight: undefined, 2653 $SlideshowOptions: undefined, 2654 $CaptionSliderOptions: undefined, 2655 $BulletNavigatorOptions: undefined, 2656 $ArrowNavigatorOptions: undefined, 2657 $ThumbnailNavigatorOptions: undefined 2658 }, 2659 _Options); 2660 }); 2661 2662 var _PlayOrientation = _Options.$PlayOrientation & 3; 2663 var _PlayReverse = (_Options.$PlayOrientation & 4) / -4 || 1; 2664 2665 var _SlideshowOptions = _Options.$SlideshowOptions; 2666 var _CaptionSliderOptions = $JssorUtils$.$Extend({ $Class: $JssorCaptionSliderBase$, $PlayInMode: 1, $PlayOutMode: 1 }, _Options.$CaptionSliderOptions); 2667 var _BulletNavigatorOptions = _Options.$BulletNavigatorOptions; 2668 var _ArrowNavigatorOptions = _Options.$ArrowNavigatorOptions; 2669 var _ThumbnailNavigatorOptions = _Options.$ThumbnailNavigatorOptions; 2670 2671 $JssorDebug$.$Execute(function () { 2672 if (_SlideshowOptions && !_SlideshowOptions.$Class) { 2673 $JssorDebug$.$Fail("Option $SlideshowOptions error, class not specified."); 2674 } 2675 }); 2676 2677 $JssorDebug$.$Execute(function () { 2678 if (_Options.$CaptionSliderOptions && !_Options.$CaptionSliderOptions.$Class) { 2679 $JssorDebug$.$Fail("Option $CaptionSliderOptions error, class not specified."); 2680 } 2681 }); 2682 2683 $JssorDebug$.$Execute(function () { 2684 if (_BulletNavigatorOptions && !_BulletNavigatorOptions.$Class) { 2685 $JssorDebug$.$Fail("Option $BulletNavigatorOptions error, class not specified."); 2686 } 2687 }); 2688 2689 $JssorDebug$.$Execute(function () { 2690 if (_ArrowNavigatorOptions && !_ArrowNavigatorOptions.$Class) { 2691 $JssorDebug$.$Fail("Option $ArrowNavigatorOptions error, class not specified."); 2692 } 2693 }); 2694 2695 $JssorDebug$.$Execute(function () { 2696 if (_ThumbnailNavigatorOptions && !_ThumbnailNavigatorOptions.$Class) { 2697 $JssorDebug$.$Fail("Option $ArrowNavigatorOptions error, class not specified."); 2698 } 2699 }); 2700 2701 var _UISearchMode = _Options.$UISearchMode;
2702 var _ScaleWrapper; 2703 var _SlidesContainer = $JssorUtils$.$FindFirstChildByAttribute(elmt, "slides", null, _UISearchMode); 2704 var _LoadingContainer = $JssorUtils$.$FindFirstChildByAttribute(elmt, "loading", null, _UISearchMode) || $JssorUtils$.$CreateDivElement(document); 2705 var _NavigatorContainer = $JssorUtils$.$FindFirstChildByAttribute(elmt, "navigator", null, _UISearchMode); 2706 2707 var _ArrowLeft = $JssorUtils$.$FindFirstChildByAttribute(elmt, "arrowleft", null, _UISearchMode); 2708 var _ArrowRight = $JssorUtils$.$FindFirstChildByAttribute(elmt, "arrowright", null, _UISearchMode); 2709 2710 var _ThumbnailNavigatorContainer = $JssorUtils$.$FindFirstChildByAttribute(elmt, "thumbnavigator", null, _UISearchMode); 2711 2712 var _SlidesContainerWidth = $JssorUtils$.$CssWidth(_SlidesContainer); 2713 var _SlidesContainerHeight = $JssorUtils$.$CssHeight(_SlidesContainer); 2714 2715 $JssorDebug$.$Execute(function () { 2716 if (isNaN(_SlidesContainerWidth)) 2717 $JssorDebug$.$Fail("Width of slides container wrong specification, it should be specified by inline style in pixels (like style='width: 600px;')."); 2718 2719 if ($JssorUtils$.$IsUndefined(_SlidesContainerWidth)) 2720 $JssorDebug$.$Fail("Width of slides container not specified, it should be specified by inline style in pixels (like style='width: 600px;')."); 2721 2722 if (isNaN(_SlidesContainerHeight)) 2723 $JssorDebug$.$Fail("Height of slides container wrong specification, it should be specified by inline style in pixels (like style='height: 300px;')."); 2724 2725 if ($JssorUtils$.$IsUndefined(_SlidesContainerHeight)) 2726 $JssorDebug$.$Fail("Height of slides container not specified, it should be specified by inline style in pixels (like style='height: 300px;')."); 2727 2728 var slidesContainerOverflow = $JssorUtils$.$CssOverflow(_SlidesContainer); 2729 var slidesContainerOverflowX = $JssorUtils$.$Css(_SlidesContainer, "overflowX"); 2730 var slidesContainerOverflowY = $JssorUtils$.$Css(_SlidesContainer, "overflowY"); 2731 if (slidesContainerOverflow != "hidden" && (slidesContainerOverflowX != "hidden" || slidesContainerOverflowY != "hidden")) 2732 $JssorDebug$.$Fail("Overflow of slides container wrong specification, it should be specified as 'hidden' (style='overflow:hidden;')."); 2733 2734 //var slidesContainerTop = $JssorUtils$.$CssTop(_SlidesContainer); 2735 //var slidesContainerLeft = $JssorUtils$.$CssLeft(_SlidesContainer); 2736 2737 //if (isNaN(slidesContainerTop)) 2738 // $JssorDebug$.$Fail("Top of slides container wrong specification, it should be specified by inline style in pixels (like style='top: 0px;')."); 2739 2740 //if ($JssorUtils$.$IsUndefined(slidesContainerTop)) 2741 // $JssorDebug$.$Fail("Top of slides container not specified, it should be specified by inline style in pixels (like style='top: 0px;')."); 2742 2743 //if (isNaN(slidesContainerLeft)) 2744 // $JssorDebug$.$Fail("Left of slides container wrong specification, it should be specified by inline style in pixels (like style='left: 0px;')."); 2745 2746 //if ($JssorUtils$.$IsUndefined(slidesContainerLeft)) 2747 // $JssorDebug$.$Fail("Left of slides container not specified, it should be specified by inline style in pixels (like style='left: 0px;')."); 2748 }); 2749 2750 $JssorDebug$.$Execute(function () { 2751 if (!$JssorUtils$.$IsNumeric(_Options.$DisplayPieces)) 2752 $JssorDebug$.$Fail("Option $DisplayPieces error, it should be a numeric value and greater than or equal to 1."); 2753 2754 if (_Options.$DisplayPieces < 1) 2755 $JssorDebug$.$Fail("Option $DisplayPieces error, it should be greater than or equal to 1."); 2756 2757 if (_Options.$DisplayPieces > 1 && _Options.$DragOrientation && _Options.$DragOrientation != _PlayOrientation) 2758 $JssorDebug$.$Fail("Option $DragOrientation error, it should be 0 or the same of $PlayOrientation when $DisplayPieces is greater than 1."); 2759 2760 if (!$JssorUtils$.$IsNumeric(_Options.$ParkingPosition)) 2761 $JssorDebug$.$Fail("Option $ParkingPosition error, it should be a numeric value."); 2762 2763 if (_Options.$ParkingPosition && _Options.$DragOrientation && _Options.$DragOrientation != _PlayOrientation) 2764 $JssorDebug$.$Fail("Option $DragOrientation error, it should be 0 or the same of $PlayOrientation when $ParkingPosition is not equal to 0."); 2765 }); 2766 2767 var _StyleDef; 2768 2769 var _SlideElmts = []; 2770 2771 { 2772 var slideElmts = $JssorUtils$.$GetChildren(_SlidesContainer);
2773 $JssorUtils$.$Each(slideElmts, function (slideElmt) { 2774 if (slideElmt.tagName == "DIV" && !$JssorUtils$.$GetAttributeEx(slideElmt, "u")) { 2775 _SlideElmts.push(slideElmt); 2776 } 2777 }); 2778 } 2779 2780 $JssorDebug$.$Execute(function () { 2781 if (_SlideElmts.length < 1) { 2782 $JssorDebug$.$Error("Slides html code definition error, there must be at least 1 slide to initialize a slider."); 2783 } 2784 }); 2785 2786 var _SlideItemCreatedCount = 0; //for debug only 2787 var _SlideItemReleasedCount = 0; //for debug only 2788 2789 var _PreviousSlideIndex; 2790 var _CurrentSlideIndex = -1; 2791 var _TempSlideIndex; 2792 var _PrevSlideItem; 2793 var _CurrentSlideItem; 2794 var _SlideCount = _SlideElmts.length; 2795 2796 var _SlideWidth = _Options.$SlideWidth || _SlidesContainerWidth; 2797 var _SlideHeight = _Options.$SlideHeight || _SlidesContainerHeight; 2798 2799 var _SlideSpacing = _Options.$SlideSpacing; 2800 var _StepLengthX = _SlideWidth + _SlideSpacing; 2801 var _StepLengthY = _SlideHeight + _SlideSpacing; 2802 var _StepLength = (_PlayOrientation & 1) ? _StepLengthX : _StepLengthY; 2803 var _DisplayPieces = Math.min(_Options.$DisplayPieces, _SlideCount); 2804 2805 var _SlideshowPanel; 2806 var _CurrentBoardIndex = 0; 2807 var _DragOrientation; 2808 var _DragOrientationRegistered; 2809 var _DragInvalid; 2810 2811 var _HandleTouchEventOnly; 2812 2813 var _Navigators = []; 2814 var _BulletNavigator; 2815 var _ArrowNavigator; 2816 var _ThumbnailNavigator; 2817 2818 var _ShowLink; 2819 2820 var _Frozen; 2821 var _AutoPlay; 2822 var _AutoPlaySteps = _Options.$AutoPlaySteps; 2823 var _HoverToPause = _Options.$PauseOnHover; 2824 var _AutoPlayInterval = _Options.$AutoPlayInterval; 2825 var _SlideDuration = _Options.$SlideDuration; 2826 2827 var _SlideshowRunnerClass; 2828 var _TransitionsOrder; 2829 2830 var _SlideshowEnabled; 2831 var _ParkingPosition; 2832 var _CarouselEnabled = _DisplayPieces < _SlideCount; 2833 var _Loop = _CarouselEnabled ? _Options.$Loop : 0; 2834 2835 var _DragEnabled; 2836 var _LastDragSucceded; 2837 2838 var _HoverStatus = 1; //0 Hovering, 1 Not hovering 2839 2840 //Variable Definition 2841 var _IsSliding; 2842 var _IsDragging; 2843 var _LoadingTicket; 2844 2845 //The X position of mouse/touch when a drag start 2846 var _DragStartMouseX = 0; 2847 //The Y position of mouse/touch when a drag start 2848 var _DragStartMouseY = 0; 2849 var _DragOffsetTotal; 2850 var _DragOffsetLastTime; 2851 var _DragIndexAdjust; 2852 2853 var _Carousel; 2854 var _Conveyor; 2855 var _Slideshow; 2856 var _CarouselPlayer; 2857 var _SlideContainer = new SlideContainer(); 2858 var _ScaleRatio; 2859 2860 //$JssorSlider$ Constructor 2861 { 2862 _AutoPlay = _Options.$AutoPlay; 2863 _SelfSlider.$Options = options; 2864 2865 AdjustSlidesContainerSize(); 2866 2867 elmt["jssor-slider"] = true; 2868 2869 //_SlideshowPanel = CreatePanel(); 2870 //$JssorUtils$.$CssZIndex(elmt, $JssorUtils$.$CssZIndex(elmt)); 2871 //$JssorUtils$.$CssLeft(_SlideshowPanel, $JssorUtils$.$CssLeft(_SlidesContainer)); 2872 //$JssorUtils$.$CssZIndex(_SlidesContainer, $JssorUtils$.$CssZIndex(_SlidesContainer)); 2873 //$JssorUtils$.$CssTop(_SlideshowPanel, $JssorUtils$.$CssTop(_SlidesContainer)); 2874 $JssorUtils$.$CssZIndex(_SlidesContainer, $JssorUtils$.$CssZIndex(_SlidesContainer) || 0); 2875 $JssorUtils$.$CssPosition(_SlidesContainer, "absolute"); 2876 _SlideshowPanel = $JssorUtils$.$CloneNode(_SlidesContainer); 2877 $JssorUtils$.$InsertBefore($JssorUtils$.$GetParentNode(_SlidesContainer), _SlideshowPanel, _SlidesContainer); 2878 2879 if (_SlideshowOptions) { 2880 _ShowLink = _SlideshowOptions.$ShowLink; 2881 _SlideshowRunnerClass = _SlideshowOptions.$Class; 2882 2883 $JssorDebug$.$Execute(function () { 2884 if (!_SlideshowOptions.$Transitions || !_SlideshowOptions.$Transitions.length) { 2885 $JssorDebug$.$Error("Invalid '$SlideshowOptions', no '$Transitions' specified."); 2886 } 2887 }); 2888 2889 _SlideshowEnabled = _DisplayPieces == 1 && _SlideCount > 1 && _SlideshowRunnerClass && (!$JssorUtils$.$IsBrowserIE() || $JssorUtils$.$GetBrowserVersion() >= 8); 2890 } 2891 2892 _ParkingPosition = (_SlideshowEnabled || _DisplayPieces >= _SlideCount || !(_Loop & 1)) ? 0 : _Options.$ParkingPosition; 2893 2894 _DragEnabled = ((_DisplayPieces > 1 || _ParkingPosition) ? _PlayOrientation : -1) & _Options.$DragOrientation; 2895 2896 //SlideBoard 2897 var _SlideboardElmt = _SlidesContainer; 2898 var _SlideItems = []; 2899 2900 var _SlideshowRunner; 2901 var _LinkContainer; 2902 2903 var _DownEvent = "mousedown"; 2904 var _MoveEvent = "mousemove"; 2905 var _UpEvent = "mouseup"; 2906 var _CancelEvent; 2907 2908 var _LastTimeMoveByDrag; 2909 var _DragStartPosition; 2910 var _DragStart_CarouselPlaying; 2911 var _DragStartPlayToPosition; 2912 var _PositionToGoByDrag; 2913 2914 //SlideBoard Constructor 2915 { 2916 2917 if (window.navigator.msPointerEnabled) { 2918 2919 _DownEvent = "MSPointerDown"; 2920 _MoveEvent = "MSPointerMove"; 2921 _UpEvent = "MSPointerUp"; 2922 _CancelEvent = "MSPointerCancel"; 2923 2924 if (_DragEnabled) { 2925 var touchAction = "none"; 2926 if (_DragEnabled == 1) { 2927 touchAction = "pan-y"; 2928 } 2929 else if (_DragEnabled == 2) { 2930 touchAction = "pan-x"; 2931 } 2932 2933 $JssorUtils$.$SetAttribute(_SlideboardElmt.style, "-ms-touch-action", touchAction); 2934 } 2935 } 2936 else if ("ontouchstart" in window || "createTouch" in document) { 2937 _HandleTouchEventOnly = true; 2938 2939 _DownEvent = "touchstart"; 2940 _MoveEvent = "touchmove"; 2941 _UpEvent = "touchend"; 2942 _CancelEvent = "touchcancel"; 2943 } 2944 2945 _Slideshow = new Slideshow(); 2946 2947 if (_SlideshowEnabled) 2948 _SlideshowRunner = new _SlideshowRunnerClass(_SlideContainer, _SlideWidth, _SlideHeight, _SlideshowOptions, _HandleTouchEventOnly); 2949 2950 $JssorUtils$.$AppendChild(_SlideshowPanel, _Slideshow.$Wrapper); 2951 $JssorUtils$.$CssOverflow(_SlidesContainer, "hidden"); 2952 2953 //link container 2954 { 2955 _LinkContainer = CreatePanel(); 2956 $JssorUtils$.$Css(_LinkContainer, "backgroundColor", "#000"); 2957 $JssorUtils$.$CssOpacity(_LinkContainer, 0); 2958 $JssorUtils$.$InsertBefore(_SlideboardElmt, _LinkContainer, _SlideboardElmt.firstChild); 2959 } 2960 2961 for (var i = 0; i < _SlideElmts.length; i++) { 2962 var slideElmt = _SlideElmts[i]; 2963 var slideItem = new SlideItem(slideElmt, i); 2964 _SlideItems.push(slideItem); 2965 } 2966 2967 $JssorUtils$.$HideElement(_LoadingContainer); 2968 2969 $JssorDebug$.$Execute(function () { 2970 $JssorUtils$.$SetAttribute(_LoadingContainer, "debug
2970-id", "loading-container"); 2971 }); 2972 2973 _Carousel = new Carousel() 2974 _CarouselPlayer = new CarouselPlayer(_Carousel, _Slideshow); 2975 2976 $JssorDebug$.$Execute(function () { 2977 $JssorUtils$.$SetAttribute(_SlideboardElmt, "debug-id", "slide-board"); 2978 }); 2979 2980 if (_DragEnabled) { 2981 $JssorUtils$.$AddEvent(_SlidesContainer, _DownEvent, OnMouseDown); 2982 $JssorUtils$.$AddEvent(document, _UpEvent, OnDragEnd); 2983 _CancelEvent && $JssorUtils$.$AddEvent(document, _CancelEvent, OnDragEnd); 2984 } 2985 } 2986 //SlideBoard 2987 2988 _HoverToPause &= _HandleTouchEventOnly ? 2 : 1; 2989 2990 //Bullet Navigator 2991 if (_NavigatorContainer && _BulletNavigatorOptions) { 2992 _BulletNavigator = new _BulletNavigatorOptions.$Class(_NavigatorContainer, _BulletNavigatorOptions); 2993 _Navigators.push(_BulletNavigator); 2994 } 2995 2996 //Arrow Navigator 2997 if (_ArrowNavigatorOptions && _ArrowLeft && _ArrowRight) { 2998 _ArrowNavigator = new _ArrowNavigatorOptions.$Class(_ArrowLeft, _ArrowRight, _ArrowNavigatorOptions); 2999 _Navigators.push(_ArrowNavigator); 3000 } 3001 3002 //Thumbnail Navigator 3003 if (_ThumbnailNavigatorContainer && _ThumbnailNavigatorOptions) { 3004 _ThumbnailNavigatorOptions.$StartIndex = _Options.$StartIndex; 3005 _ThumbnailNavigator = new _ThumbnailNavigatorOptions.$Class(_ThumbnailNavigatorContainer, _ThumbnailNavigatorOptions); 3006 _Navigators.push(_ThumbnailNavigator); 3007 } 3008 3009 $JssorUtils$.$Each(_Navigators, function (navigator) { 3010 navigator.$Reset(_SlideCount, _SlideItems, _LoadingContainer); 3011 navigator.$On($JssorNavigatorEvents$.$NAVIGATIONREQUEST, NavigationClickHandler); 3012 }); 3013 3014 _SelfSlider.$SetScaleWidth(_SelfSlider.$GetOriginalWidth()); 3015 3016 $JssorUtils$.$AddEvent(elmt, "mouseout", MainContainerMouseOutEventHandler); 3017 $JssorUtils$.$AddEvent(elmt, "mouseover", MainContainerMouseOverEventHandler); 3018 3019 ShowNavigators(); 3020 3021 //Keyboard Navigation 3022 if (_Options.$ArrowKeyNavigation) { 3023 $JssorUtils$.$AddEvent(document, "keydown", function (e) { 3024 if (e.keyCode == $JssorKeyCode$.$LEFT) { 3025 //Arrow Left 3026 PlayToOffset(-1); 3027 } 3028 else if (e.keyCode == $JssorKeyCode$.$RIGHT) { 3029 //Arrow Right 3030 PlayToOffset(1); 3031 } 3032 }); 3033 } 3034 3035 var startPosition = _Options.$StartIndex; 3036 if (!(_Loop & 1)) { 3037 startPosition = Math.max(0, Math.min(startPosition, _SlideCount - _DisplayPieces)); 3038 } 3039 _CarouselPlayer.$PlayCarousel(startPosition, startPosition, 0); 3040 } 3041 } 3042 //Jssor Slider 3043 3044 //JssorSlider.$ASSEMBLY_BOTTOM_LEFT = ASSEMBLY_BOTTOM_LEFT; 3045 //JssorSlider.$ASSEMBLY_BOTTOM_RIGHT = ASSEMBLY_BOTTOM_RIGHT; 3046 //JssorSlider.$ASSEMBLY_TOP_LEFT = ASSEMBLY_TOP_LEFT; 3047 //JssorSlider.$ASSEMBLY_TOP_RIGHT = ASSEMBLY_TOP_RIGHT; 3048 //JssorSlider.$ASSEMBLY_LEFT_TOP = ASSEMBLY_LEFT_TOP; 3049 //JssorSlider.$ASSEMBLY_LEFT_BOTTOM = ASSEMBLY_LEFT_BOTTOM; 3050 //JssorSlider.$ASSEMBLY_RIGHT_TOP = ASSEMBLY_RIGHT_TOP; 3051 //JssorSlider.$ASSEMBLY_RIGHT_BOTTOM = ASSEMBLY_RIGHT_BOTTOM; 3052 3053 JssorSlider.$EVT_CLICK = 21; 3054 JssorSlider.$EVT_DRAG_START = 22; 3055 JssorSlider.$EVT_DRAG_END = 23; 3056 JssorSlider.$EVT_SWIPE_START = 24; 3057 JssorSlider.$EVT_SWIPE_END = 25; 3058 3059 JssorSlider.$EVT_LOAD_START = 26; 3060 JssorSlider.$EVT_LOAD_END = 27; 3061 3062 JssorSlider.$EVT_POSITION_CHANGE = 202; 3063 JssorSlider.$EVT_PARK = 203; 3064 3065 JssorSlider.$EVT_SLIDESHOW_START = 206; 3066 JssorSlider.$EVT_SLIDESHOW_END = 207; 3067 3068 JssorSlider.$EVT_PROGRESS_CHANGE = 208; 3069 JssorSlider.$EVT_STATE_CHANGE = 209; 3070 JssorSlider.$EVT_ROLLBACK_START = 210; 3071 JssorSlider.$EVT_ROLLBACK_END = 211; 3072 3073 window.$JssorSlider$ = $JssorSlider$ = JssorSlider; 3074 3075 //(function ($) { 3076 // jQuery.fn.jssorSlider = function (options) { 3077 // return this.each(function () { 3078 // return $(this).data('jssorSlider') || $(this).data('jssorSlider', new JssorSlider(this, options)); 3079 // }); 3080 // }; 3081 //})(jQuery); 3082 3083 //window.jQuery && (jQuery.fn.jssorSlider = function (options) { 3084 // return this.each(function () { 3085 // return jQuery(this).data('jssorSlider') || jQuery(this).data('jssorSlider', new JssorSlider(this, options)); 3086 // }); 3087 //}); 3088}; 3089 3090//$JssorBulletNavigator$ 3091var $JssorNavigatorEvents$ = { 3092 $NAVIGATIONREQUEST: 1, 3093 $INDEXCHANGE: 2, 3094 $RESET: 3 3095}; 3096 3097var $JssorBulletNavigator$ = window.$JssorBulletNavigator$ = function (elmt, options) { 3098 var self = this; 3099 $JssorEventManager$.call(self); 3100 3101 elmt = $JssorUtils$.$GetElement(elmt); 3102 3103 var _Count; 3104 var _Length; 3105 var _Width; 3106 var _Height; 3107 var _CurrentIndex; 3108 var _CurrentInnerIndex = 0; 3109 var _Options; 3110 var _Steps; 3111 var _Lanes; 3112 var _SpacingX; 3113 var _SpacingY; 3114 var _Orientation; 3115 var _ItemPrototype; 3116 var _PrototypeWidth; 3117 var _PrototypeHeight; 3118 3119 var _ButtonElements = []; 3120 var _Buttons = []; 3121 3122 function Highlight(index) { 3123 if (index != -1) 3124 _Buttons[index].$Activate(index == _CurrentInnerIndex); 3125 } 3126 3127 function OnNavigationRequest(index) { 3128 self.$TriggerEvent($JssorNavigatorEvents$.$NAVIGATIONREQUEST, index * _Steps); 3129 } 3130 3131 self.$Elmt = elmt; 3132 self.$GetCurrentIndex = function () { 3133 return _CurrentIndex; 3134 }; 3135 3136 self.$SetCurrentIndex = function (index) { 3137 if (index != _CurrentIndex) { 3138 var lastInnerIndex = _CurrentInnerIndex; 3139 var innerIndex = Math.floor(index / _Steps); 3140 _CurrentInnerIndex = innerIndex; 3141 _CurrentIndex = index; 3142 3143 Highlight(lastInnerIndex); 3144 Highlight(innerIndex); 3145 3146 //self.$TriggerEvent($JssorNavigatorEvents$.$INDEXCHANGE, index); 3147 } 3148 }; 3149 3150 self.$Show = function (show) { 3151 $JssorUtils$.$ShowElement(elmt, show); 3152 }; 3153 3154 var _Located; 3155 self.$Relocate = function (force) { 3156 if (!_Located || _Options.$Scale == false) {
3157 if (_Options.$AutoCenter & 1) { 3158 $JssorUtils$.$CssLeft(elmt, ($JssorUtils$.$CssWidth($JssorUtils$.$GetParentNode(elmt)) - _Width) / 2); 3159 } 3160 if (_Options.$AutoCenter & 2) { 3161 $JssorUtils$.$CssTop(elmt, ($JssorUtils$.$CssHeight($JssorUtils$.$GetParentNode(elmt)) - _Height) / 2); 3162 } 3163 3164 _Located = true; 3165 } 3166 }; 3167 3168 var _Initialized; 3169 self.$Reset = function (length) { 3170 if (!_Initialized) { 3171 _Length = length; 3172 _Count = Math.ceil(length / _Steps); 3173 _CurrentInnerIndex = 0; 3174 3175 var itemOffsetX = _PrototypeWidth + _SpacingX; 3176 var itemOffsetY = _PrototypeHeight + _SpacingY; 3177 3178 var maxIndex = Math.ceil(_Count / _Lanes) - 1; 3179 3180 _Width = _PrototypeWidth + itemOffsetX * (!_Orientation ? maxIndex : _Lanes - 1); 3181 _Height = _PrototypeHeight + itemOffsetY * (_Orientation ? maxIndex : _Lanes - 1); 3182 3183 $JssorUtils$.$CssWidth(elmt, _Width); 3184 $JssorUtils$.$CssHeight(elmt, _Height); 3185 3186 //self.$Relocate(true); 3187 3188 for (var buttonIndex = 0; buttonIndex < _Count; buttonIndex++) { 3189 3190 var numberDiv = $JssorUtils$.$CreateSpanElement(); 3191 $JssorUtils$.$SetInnerText(numberDiv, buttonIndex + 1); 3192 3193 var div = $JssorUtils$.$BuildElement(_ItemPrototype, "NumberTemplate", numberDiv, true); 3194 $JssorUtils$.$CssPosition(div, "absolute"); 3195 3196 var columnIndex = buttonIndex % (maxIndex + 1); 3197 $JssorUtils$.$CssLeft(div, !_Orientation ? itemOffsetX * columnIndex : buttonIndex % _Lanes * itemOffsetX); 3198 $JssorUtils$.$CssTop(div, _Orientation ? itemOffsetY * columnIndex : Math.floor(buttonIndex / (maxIndex + 1)) * itemOffsetY); 3199 3200 $JssorUtils$.$AppendChild(elmt, div); 3201 _ButtonElements[buttonIndex] = div; 3202 3203 if (_Options.$ActionMode & 1) 3204 $JssorUtils$.$AddEvent(div, "click", $JssorUtils$.$CreateCallback(null, OnNavigationRequest, buttonIndex)); 3205 3206 if (_Options.$ActionMode & 2) 3207 $JssorUtils$.$AddEvent(div, "mouseover", $JssorUtils$.$CreateCallback(null, OnNavigationRequest, buttonIndex)); 3208 3209 _Buttons[buttonIndex] = $JssorUtils$.$Buttonize(div); 3210 } 3211 3212 //self.$TriggerEvent($JssorNavigatorEvents$.$RESET); 3213 _Initialized = true; 3214 } 3215 }; 3216 3217 //JssorBulletNavigator Constructor 3218 { 3219 self.$Options = _Options = $JssorUtils$.$Extend({ 3220 $SpacingX: 0, 3221 $SpacingY: 0, 3222 $Orientation: 1, 3223 $ActionMode: 1 3224 }, options); 3225 3226 //Sodo statement for development time intellisence only 3227 $JssorDebug$.$Execute(function () { 3228 _Options = $JssorUtils$.$Extend({ 3229 $Steps: undefined, 3230 $Lanes: undefined 3231 }, _Options); 3232 }); 3233 3234 _ItemPrototype = $JssorUtils$.$FindFirstChildByAttribute(elmt, "prototype"); 3235 3236 $JssorDebug$.$Execute(function () { 3237 if (!_ItemPrototype) 3238 $JssorDebug$.$Fail("Navigator item prototype not defined."); 3239 3240 if (isNaN($JssorUtils$.$CssWidth(_ItemPrototype))) { 3241 $JssorDebug$.$Fail("Width of 'navigator item prototype' not specified."); 3242 } 3243 3244 if (isNaN($JssorUtils$.$CssHeight(_ItemPrototype))) { 3245 $JssorDebug$.$Fail("Height of 'navigator item prototype' not specified."); 3246 } 3247 }); 3248 3249 _PrototypeWidth = $JssorUtils$.$CssWidth(_ItemPrototype); 3250 _PrototypeHeight = $JssorUtils$.$CssHeight(_ItemPrototype); 3251 3252 $JssorUtils$.$RemoveChild(elmt, _ItemPrototype); 3253 3254 _Steps = _Options.$Steps || 1; 3255 _Lanes = _Options.$Lanes || 1; 3256 _SpacingX = _Options.$SpacingX; 3257 _SpacingY = _Options.$SpacingY; 3258 _Orientation = _Options.$Orientation - 1; 3259 } 3260}; 3261 3262var $JssorArrowNavigator$ = window.$JssorArrowNavigator$ = function (arrowLeft, arrowRight, options) { 3263 var self = this; 3264 $JssorEventManager$.call(self); 3265 3266 $JssorDebug$.$Execute(function () { 3267 //var arrowLeft = $JssorUtils$.$FindFirstChildByAttribute(elmt, "arrowleft", null, uiSearchMode); 3268 //var arrowRight = $JssorUtils$.$FindFirstChildByAttribute(elmt, "arrowright", null, uiSearchMode); 3269 3270 if (!arrowLeft) 3271 $JssorDebug$.$Fail("Option '$ArrowNavigatorOptions' spepcified, but UI 'arrowleft' not defined. Define 'arrowleft' to enable direct navigation, or remove option '$ArrowNavigatorOptions' to disable direct navigation."); 3272 3273 if (!arrowRight) 3274 $JssorDebug$.$Fail("Option '$ArrowNavigatorOptions' spepcified, but UI 'arrowright' not defined. Define 'arrowright' to enable direct navigation, or remove option '$ArrowNavigatorOptions' to disable direct navigation."); 3275 3276 if (isNaN($JssorUtils$.$CssWidth(arrowLeft))) { 3277 $JssorDebug$.$Fail("Width of 'arrow left' not specified."); 3278 } 3279 3280 if (isNaN($JssorUtils$.$CssWidth(arrowRight))) { 3281 $JssorDebug$.$Fail("Width of 'arrow right' not specified."); 3282 } 3283
3284 if (isNaN($JssorUtils$.$CssHeight(arrowLeft))) { 3285 $JssorDebug$.$Fail("Height of 'arrow left' not specified."); 3286 } 3287 3288 if (isNaN($JssorUtils$.$CssHeight(arrowRight))) { 3289 $JssorDebug$.$Fail("Height of 'arrow right' not specified."); 3290 } 3291 }); 3292 3293 //var arrowLeft = $JssorUtils$.$FindFirstChildByAttribute(elmt, "arrowleft", null, uiSearchMode); 3294 //var arrowRight = $JssorUtils$.$FindFirstChildByAttribute(elmt, "arrowright", null, uiSearchMode); 3295 var _Length; 3296 var _CurrentIndex; 3297 var _Options; 3298 var _Steps; 3299 var _ParentNode = $JssorUtils$.$GetParentNode(arrowLeft); 3300 var _ArrowWidth = $JssorUtils$.$CssWidth(arrowLeft); 3301 var _ArrowHeight = $JssorUtils$.$CssHeight(arrowLeft); 3302 3303 function OnNavigationRequest(steps) { 3304 self.$TriggerEvent($JssorNavigatorEvents$.$NAVIGATIONREQUEST, steps, true); 3305 } 3306 3307 self.$GetCurrentIndex = function () { 3308 return _CurrentIndex; 3309 }; 3310 3311 self.$SetCurrentIndex = function (index, virtualIndex, temp) { 3312 if (temp) { 3313 _CurrentIndex = virtualIndex; 3314 } 3315 else { 3316 _CurrentIndex = index; 3317 } 3318 //self.$TriggerEvent($JssorNavigatorEvents$.$INDEXCHANGE, index); 3319 }; 3320 3321 self.$Show = function (show) { 3322 $JssorUtils$.$ShowElement(arrowLeft, show); 3323 $JssorUtils$.$ShowElement(arrowRight, show); 3324 }; 3325 3326 var _Located; 3327 self.$Relocate = function (force) { 3328 if (!_Located || _Options.$Scale == false) { 3329 3330 var containerWidth = $JssorUtils$.$CssWidth(_ParentNode); 3331 var containerHeight = $JssorUtils$.$CssHeight(_ParentNode); 3332 3333 if (_Options.$AutoCenter & 1) { 3334 $JssorUtils$.$CssLeft(arrowLeft, (containerWidth - _ArrowWidth) / 2); 3335 $JssorUtils$.$CssLeft(arrowRight, (containerWidth - _ArrowWidth) / 2); 3336 } 3337 3338 if (_Options.$AutoCenter & 2) { 3339 $JssorUtils$.$CssTop(arrowLeft, (containerHeight - _ArrowHeight) / 2); 3340 $JssorUtils$.$CssTop(arrowRight, (containerHeight - _ArrowHeight) / 2); 3341 } 3342 3343 _Located = true; 3344 } 3345 }; 3346 3347 var _Initialized; 3348 self.$Reset = function (length) { 3349 _Length = length; 3350 _CurrentIndex = 0; 3351 3352 if (!_Initialized) { 3353 3354 //self.$Relocate(true); 3355 3356 $JssorUtils$.$AddEvent(arrowLeft, "click", $JssorUtils$.$CreateCallback(null, OnNavigationRequest, -_Steps)); 3357 $JssorUtils$.$AddEvent(arrowRight, "click", $JssorUtils$.$CreateCallback(null, OnNavigationRequest, _Steps)); 3358 3359 $JssorUtils$.$Buttonize(arrowLeft); 3360 $JssorUtils$.$Buttonize(arrowRight); 3361 3362 _Initialized = true; 3363 } 3364 3365 //self.$TriggerEvent($JssorNavigatorEvents$.$RESET); 3366 }; 3367 3368 //JssorArrowNavigator Constructor 3369 { 3370 self.$Options = _Options = $JssorUtils$.$Extend({ 3371 $Steps: 1 3372 }, options); 3373 3374 _Steps = _Options.$Steps; 3375 } 3376}; 3377 3378//$JssorThumbnailNavigator$ 3379var $JssorThumbnailNavigator$ = window.$JssorThumbnailNavigator$ = function (elmt, options) { 3380 var _Self = this; 3381 var _Length; 3382 var _Count; 3383 var _CurrentIndex; 3384 var _Options; 3385 var _NavigationItems = []; 3386 3387 var _Width; 3388 var _Height; 3389 var _Lanes; 3390 var _SpacingX; 3391 var _SpacingY; 3392 var _PrototypeWidth; 3393 var _PrototypeHeight; 3394 var _DisplayPieces; 3395 3396 var _Slider; 3397 var _CurrentMouseOverIndex = -1; 3398 3399 var _SlidesContainer; 3400 var _ThumbnailPrototype; 3401 3402 $JssorEventManager$.call(_Self); 3403 elmt = $JssorUtils$.$GetElement(elmt); 3404 3405 function NavigationItem(item, index) { 3406 var self = this; 3407 var _Wrapper; 3408 var _Button; 3409 var _Thumbnail; 3410 3411 function Highlight(mouseStatus) { 3412 _Button.$Activate(_CurrentIndex == index); 3413 } 3414 3415 function OnNavigationRequest(event) { 3416 if (!_Slider.$LastDragSucceded()) { 3417 var tail = _Lanes - index % _Lanes; 3418 var slideVirtualIndex = _Slider.$GetVirtualIndex((index + tail) / _Lanes - 1); 3419 var itemVirtualIndex = slideVirtualIndex * _Lanes + _Lanes - tail; 3420 _Self.$TriggerEvent($JssorNavigatorEvents$.$NAVIGATIONREQUEST, itemVirtualIndex); 3421 } 3422 } 3423 3424 $JssorDebug$.$Execute(function () { 3425 self.$Wrapper = undefined; 3426 }); 3427 3428 self.$Index = index; 3429 3430 self.$Highlight = Highlight; 3431 3432 //NavigationItem Constructor 3433 { 3434 _Thumbnail = item.$Thumb || item.$Image || $JssorUtils$.$CreateDivElement(); 3435 self.$Wrapper = _Wrapper = $JssorUtils$.$BuildElement(_ThumbnailPrototype, "ThumbnailTemplate", _Thumbnail, true); 3436 3437 _Button = $JssorUtils$.$Buttonize(_Wrapper); 3438 if (_Options.$ActionMode & 1) 3439 $JssorUtils$.$AddEvent(_Wrapper, "click", OnNavigationRequest); 3440 if (_Options.$ActionMode & 2) 3441 $JssorUtils$.$AddEvent(_Wrapper, "mouseover", OnNavigationRequest); 3442 } 3443 } 3444 3445 _Self.$GetCurrentIndex = function () { 3446 return _CurrentIndex; 3447 }; 3448 3449 _Self.$SetCurrentIndex = function (index, virtualIndex, temp) { 3450 var oldIndex = _CurrentIndex; 3451 _CurrentIndex = index; 3452 if (oldIndex != -1) 3453 _NavigationItems[oldIndex].$Highlight(); 3454 _NavigationItems[index].$Highlight(); 3455 3456 if (!temp) { 3457 _Slider.$PlayTo(_Slider.$GetVirtualIndex(Math.floor(virtualIndex / _Lanes))); 3458 } 3459 }; 3460 3461 _Self.$Show = function (show) { 3462 $JssorUtils$.$ShowElement(elmt, show); 3463 }; 3464 3465 _Self.$Relocate = $JssorUtils$.$EmptyFunction; 3466 3467 var _Initialized;
3468 _Self.$Reset = function (length, items, loadingContainer) { 3469 if (!_Initialized) { 3470 _Length = length; 3471 _Count = Math.ceil(_Length / _Lanes); 3472 _CurrentIndex = -1; 3473 _DisplayPieces = Math.min(_DisplayPieces, items.length); 3474 3475 var horizontal = _Options.$Orientation & 1; 3476 3477 var slideWidth = _PrototypeWidth + (_PrototypeWidth + _SpacingX) * (_Lanes - 1) * (1 - horizontal); 3478 var slideHeight = _PrototypeHeight + (_PrototypeHeight + _SpacingY) * (_Lanes - 1) * horizontal; 3479 3480 var slidesContainerWidth = slideWidth + (slideWidth + _SpacingX) * (_DisplayPieces - 1) * horizontal; 3481 var slidesContainerHeight = slideHeight + (slideHeight + _SpacingY) * (_DisplayPieces - 1) * (1 - horizontal); 3482 3483 $JssorUtils$.$CssPosition(_SlidesContainer, "absolute"); 3484 $JssorUtils$.$CssOverflow(_SlidesContainer, "hidden"); 3485 if (_Options.$AutoCenter & 1) { 3486 $JssorUtils$.$CssLeft(_SlidesContainer, (_Width - slidesContainerWidth) / 2); 3487 } 3488 if (_Options.$AutoCenter & 2) { 3489 $JssorUtils$.$CssTop(_SlidesContainer, (_Height - slidesContainerHeight) / 2); 3490 } 3491 //$JssorDebug$.$Execute(function () { 3492 // if (!_Options.$AutoCenter) { 3493 // var slidesContainerTop = $JssorUtils$.$CssTop(_SlidesContainer); 3494 // var slidesContainerLeft = $JssorUtils$.$CssLeft(_SlidesContainer); 3495 3496 // if (isNaN(slidesContainerTop)) { 3497 // $JssorDebug$.$Fail("Position 'top' wrong specification of thumbnail navigator slides container (<div u=\"thumbnavigator\">...<div u=\"slides\">), \r\nwhen option $ThumbnailNavigatorOptions.$AutoCenter set to 0, it should be specified by inline style in pixels (like <div u=\"slides\" style=\"top: 0px;\">)"); 3498 // } 3499 3500 // if (isNaN(slidesContainerLeft)) { 3501 // $JssorDebug$.$Fail("Position 'left' wrong specification of thumbnail navigator slides container (<div u=\"thumbnavigator\">...<div u=\"slides\">), \r\nwhen option $ThumbnailNavigatorOptions.$AutoCenter set to 0, it should be specified by inline style in pixels (like <div u=\"slides\" style=\"left: 0px;\">)"); 3502 // } 3503 // } 3504 //}); 3505 $JssorUtils$.$CssWidth(_SlidesContainer, slidesContainerWidth); 3506 $JssorUtils$.$CssHeight(_SlidesContainer, slidesContainerHeight); 3507 3508 var slideItemElmts = []; 3509 $JssorUtils$.$Each(items, function (item, index) { 3510 var navigationItem = new NavigationItem(item, index); 3511 var navigationItemWrapper = navigationItem.$Wrapper; 3512 3513 var columnIndex = Math.floor(index / _Lanes); 3514 var laneIndex = index % _Lanes; 3515 3516 $JssorUtils$.$CssLeft(navigationItemWrapper, (_PrototypeWidth + _SpacingX) * laneIndex * (1 - horizontal)); 3517 $JssorUtils$.$CssTop(navigationItemWrapper, (_PrototypeHeight + _SpacingY) * laneIndex * horizontal); 3518 3519 if (!slideItemElmts[columnIndex]) { 3520 slideItemElmts[columnIndex] = $JssorUtils$.$CreateDivElement(); 3521 $JssorUtils$.$AppendChild(_SlidesContainer, slideItemElmts[columnIndex]); 3522 } 3523 3524 $JssorUtils$.$AppendChild(slideItemElmts[columnIndex], navigationItemWrapper); 3525 3526 _NavigationItems.push(navigationItem); 3527 }); 3528 3529 var thumbnailSliderOptions = $JssorUtils$.$Extend({ 3530 $AutoPlay: false, 3531 $NaviQuitDrag: false, 3532 $SlideWidth: slideWidth, 3533 $SlideHeight: slideHeight, 3534 $SlideSpacing: _SpacingX * horizontal + _SpacingY * (1 - horizontal), 3535 $MinDragOffsetToSlide: 12, 3536 $SlideDuration: 200, 3537 $PauseOnHover: 1, 3538 $PlayOrientation: _Options.$Orientation, 3539 $DragOrientation: _Options.$DisableDrag ? 0 : _Options.$Orientation 3540 }, _Options); 3541 3542 _Slider = new $JssorSlider$(elmt, thumbnailSliderOptions); 3543 3544 _Initialized = true; 3545 } 3546 3547 //_Self.$TriggerEvent($JssorNavigatorEvents$.$RESET); 3548 }; 3549 3550 //JssorThumbnailNavigator Constructor 3551 { 3552 _Self.$Options = _Options = $JssorUtils$.$Extend({ 3553 $SpacingX: 3, 3554 $SpacingY: 3, 3555 $DisplayPieces: 1, 3556 $Orientation: 1, 3557 $AutoCenter: 3, 3558 $ActionMode: 1 3559 }, options); 3560 3561 //Sodo statement for development time intellisence only 3562 $JssorDebug$.$Execute(function () { 3563 _Options = $JssorUtils$.$Extend({ 3564 $Lanes: undefined, 3565 $Width: undefined, 3566 $Height: undefined 3567 }, _Options); 3568 }); 3569 3570 _Width = $JssorUtils$.$CssWidth(elmt); 3571 _Height = $JssorUtils$.$CssHeight(elmt); 3572 3573 $JssorDebug$.$Execute(function () { 3574 if (!_Width) 3575 $JssorDebug$.$Fail("width of 'thumbnavigator' container not specified."); 3576 if (!_Height) 3577 $JssorDebug$.$Fail("height of 'thumbnavigator' container not specified."); 3578 }); 3579 3580 _SlidesContainer = $JssorUtils$.$FindFirstChildByAttribute(elmt, "slides"); 3581 _ThumbnailPrototype = $JssorUtils$.$FindFirstChildByAttribute(_SlidesContainer, "prototype"); 3582 3583 $JssorDebug$.$Execute(function () { 3584 if (!_ThumbnailPrototype) 3585 $JssorDebug$.$Fail("prototype of 'thumbnavigator' not defined."); 3586 }); 3587 3588 _PrototypeWidth = $JssorUtils$.$CssWidth(_ThumbnailPrototype); 3589 _PrototypeHeight = $JssorUtils$.$CssHeight(_ThumbnailPrototype); 3590 3591 $JssorUtils$.$RemoveChild(_SlidesContainer, _ThumbnailPrototype); 3592 3593 _Lanes = _Options.$Lanes || 1; 3594 _SpacingX = _Options.$SpacingX; 3595 _SpacingY = _Options.$SpacingY; 3596 _DisplayPieces = _Options.$DisplayPieces; 3597 } 3598}; 3599 3600//$JssorCaptionSlider$ 3601function $JssorCaptionSliderBase$() { 3602 $JssorAnimator$.call(this, 0, 0); 3603 this.$Revert = $JssorUtils$.$EmptyFunction; 3604} 3605 3606var $JssorCaptionSlider$ = window.$JssorCaptionSlider$ = function (container, captionSlideOptions, playIn) { 3607 $JssorDebug$.$Execute(function () { 3608 if (!captionSlideOptions.$CaptionTransitions) { 3609 $JssorDebug$.$Error("'$CaptionSliderOptions' option error, '$CaptionSliderOptions.$CaptionTransitions' not specified."); 3610 } 3611 //else if (!$JssorUtils$.$IsArray(captionSlideOptions.$CaptionTransitions)) { 3612 // $JssorDebug$.$Error("'$CaptionSliderOptions' option error, '$CaptionSliderOptions.$CaptionTransitions' is not an array."); 3613 //} 3614 }); 3615 3616 var _Self = this; 3617 var _ImmediateOutCaptionHanger; 3618 var _PlayMode = playIn ? captionSlideOptions.$PlayInMode : captionSlideOptions.$PlayOutMode; 3619 3620 var _CaptionTransitions = captionSlideOptions.$CaptionTransitions; 3621 var _CaptionTuningFetcher = { $Transition: "t", $Delay: "d", $Duration: "du", $ScaleHorizontal: "x", $ScaleVertical: "y", $Rotate: "r", $Zoom: "z", $Opacity: "f", $BeginTime: "b" }; 3622 var _CaptionTuningTransfer = { 3623 $Default: function (value, tuningValue) { 3624 if (!isNaN(tuningValue.$Value)) 3625 value = tuningValue.$Value; 3626 else 3627 value *= tuningValue.$Percent; 3628 3629 return value; 3630 }, 3631 $Opacity: function (value, tuningValue) { 3632 return this.$Default(value - 1, tuningValue); 3633 } 3634 }; 3635 _CaptionTuningTransfer.$Zoom = _CaptionTuningTransfer.$Opacity; 3636 3637 $JssorAnimator$.call(_Self, 0, 0); 3638 3639 function GetCaptionItems(element, level) { 3640 3641 var itemsToPlay = []; 3642 var lastTransitionName; 3643 var namedTransitions = []; 3644 var namedTransitionOrders = []; 3645 3646 //$JssorDebug$.$Execute(function () { 3647 3648 // var debugInfoElement = $JssorUtils$.$GetElement("debugInfo"); 3649 3650 // if (debugInfoElement && playIn) { 3651 3652 // var text = $JssorUtils$.$GetInnerHtml(debugInfoElement) + "<br>"; 3653 3654 // $JssorUtils$.$SetInnerHtml(debugInfoElement, text); 3655 // } 3656 //}); 3657 3658 function FetchRawTransition(captionElmt, index) { 3659 var rawTransition = {}; 3660 3661 $JssorUtils$.$Each(_CaptionTuningFetcher, function (fetchAttribute, fetchProperty) { 3662 var attributeValue = $JssorUtils$.$GetAttributeEx(captionElmt, fetchAttribute + (index || "")); 3663 if (attributeValue) { 3664 var propertyValue = {}; 3665 3666 if (fetchAttribute == "t") { 3667 //if (($JssorUtils$.$IsBrowserChrome() || $JssorUtils$.$IsBrowserSafari() || $JssorUtils$.$IsBrowserFireFox()) && attributeValue == "*") { 3668 // attributeValue = Math.floor(Math.random() * captionSlideOptions.$CaptionTransitions.length); 3669 // $JssorUtils$.$SetAttribute(captionElmt, fetchAttribute + (index || ""), attributeValue); 3670 //} 3671 3672 propertyValue.$Value = attributeValue; 3673 } 3674 else if (attributeValue.indexOf("%") + 1) 3675 propertyValue.$Percent = $JssorUtils$.$ParseFloat(attributeValue) / 100; 3676 else 3677 propertyValue.$Value = $JssorUtils$.$ParseFloat(attributeValue); 3678 3679 rawTransition[fetchProperty] = propertyValue; 3680 } 3681 }); 3682 3683 return rawTransition; 3684 } 3685 3686 function GetRandomTransition() { 3687 //return _CaptionTransitions.length && _CaptionTransitions[Math.floor(Math.random() * 42737 / (i + 1)) % _CaptionTransitions.length]; 3688 return _CaptionTransitions[Math.floor(Math.random() * _CaptionTransitions.length)]; 3689 } 3690 3691 function EvaluateCaptionTransition(transitionName) { 3692 3693 var transition; 3694 3695 if (transitionName == "*") { 3696 transition = GetRandomTransition(); 3697 } 3698 else if (transitionName) { 3699 3700 //indexed transition allowed, just the same as named transition 3701 var tempTransition = _CaptionTransitions[$JssorUtils$.$ParseInt(transitionName)] || _CaptionTransitions[transitionName]; 3702 3703 if ($JssorUtils$.$IsArray(tempTransition)) { 3704 if (transitionName != lastTransitionName) { 3705 lastTransitionName = transitionName; 3706 namedTransitionOrders[transitionName] = 0; 3707 3708 namedTransitions[transitionName] = tempTransition[Math.floor(Math.random() * tempTransition.length)]; 3709 } 3710 else { 3711 namedTransitionOrders[transitionName]++; 3712 } 3713 3714 tempTransition = namedTransitions[transitionName]; 3715 3716 if ($JssorUtils$.$IsArray(tempTransition)) { 3717 tempTransition = tempTransition.length && tempTransition[namedTransitionOrders[transitionName] % tempTransition.length]; 3718 3719 if ($JssorUtils$.$IsArray(tempTransition)) { 3720 //got transition from array level 3, random for all captions 3721 tempTransition = tempTransition[Math.floor(Math.random() * tempTransition.length)]; 3722 } 3723 //else { 3724 // //got transition from array level 2, in sequence for all adjacent captions with same name specified 3725 // transition = tempTransition; 3726 //} 3727 } 3728 //else { 3729 // //got transition from array level 1, random but same for all adjacent captions with same name specified 3730 // transition = tempTransition; 3731 //} 3732 } 3733 //else { 3734 // //got transition directly from a simple transition object 3735 // transition = tempTransition; 3736 //} 3737 3738 transition = tempTransition; 3739 3740 if ($JssorUtils$.$IsString(transition)) 3741 transition = EvaluateCaptionTransition(transition); 3742 } 3743 3744 return transition; 3745 } 3746 3747 var captionElmts = $JssorUtils$.$GetChildren(element); 3748 $JssorUtils$.$Each(captionElmts, function (captionElmt, i) { 3749 3750 var transitionsWithTuning = []; 3751 transitionsWithTuning.$Elmt = captionElmt; 3752 var isCaption = $JssorUtils$.$GetAttributeEx(captionElmt, "u") == "caption"; 3753 3754 $JssorUtils$.$Each(playIn ? [0, 3] : [2], function (j, k) { 3755 3756 if (isCaption) { 3757 var transition; 3758 var rawTransition; 3759 3760 if (j != 2 || !$JssorUtils$.$GetAttributeEx(captionElmt, "t3")) { 3761 rawTransition = FetchRawTransition(captionElmt, j); 3762 3763 if (j == 2 && !rawTransition.$Transition) { 3764 rawTransition.$Delay = rawTransition.$Delay || { $Value: 0 }; 3765 rawTransition = $JssorUtils$.$Extend(FetchRawTransition(captionElmt, 0), rawTransition); 3766 } 3767 } 3768 3769 if (rawTransition && rawTransition.$Transition) { 3770 3771 transition = EvaluateCaptionTransition(rawTransition.$Transition.$Value); 3772 3773 if (transition) { 3774 3775 var transitionWithTuning = $JssorUtils$.$Extend({ $Delay: 0, $ScaleHorizontal: 1, $ScaleVertical: 1 }, transition); 3776 3777 $JssorUtils$.$Each(rawTransition, function (rawPropertyValue, propertyName) { 3778 var tuningPropertyValue = (_CaptionTuningTransfer[propertyName] || _CaptionTuningTransfer.$Default).apply(_CaptionTuningTransfer, [transitionWithTuning[propertyName], rawTransition[propertyName]]); 3779 if (!isNaN(tuningPropertyValue)) 3780 transitionWithTuning[propertyName] = tuningPropertyValue; 3781 }); 3782 3783 if (!k) { 3784 if (rawTransition.$BeginTime) 3785 transitionWithTuning.$BeginTime = rawTransition.$BeginTime.$Value || 0; 3786 else if ((_PlayMode) & 2) 3787 transitionWithTuning.$BeginTime = 0; 3788 } 3789 } 3790 } 3791 3792 transitionsWithTuning.push(transitionWithTuning); 3793 } 3794 3795 if ((level % 2) && !k) { 3796 //transitionsWithTuning.$Children = GetCaptionItems(captionElmt, lastTransitionName, [].concat(namedTransitions), [].concat(namedTransitionOrders), level
3796+ 1); 3797 transitionsWithTuning.$Children = GetCaptionItems(captionElmt, level + 1); 3798 } 3799 }); 3800 3801 itemsToPlay.push(transitionsWithTuning); 3802 }); 3803 3804 return itemsToPlay; 3805 } 3806 3807 function CreateAnimator(item, transition, immediateOut) { 3808 3809 var animatorOptions = { 3810 $Easing: transition.$Easing, 3811 $Round: transition.$Round, 3812 $During: transition.$During, 3813 $Reverse: playIn && !immediateOut, 3814 $Optimize: true 3815 }; 3816 3817 $JssorDebug$.$Execute(function () { 3818 animatorOptions.$CaptionAnimator = true; 3819 }); 3820 3821 var captionItem = item; 3822 var captionParent = $JssorUtils$.$GetParentNode(item); 3823 3824 var captionItemWidth = $JssorUtils$.$CssWidth(captionItem); 3825 var captionItemHeight = $JssorUtils$.$CssHeight(captionItem); 3826 var captionParentWidth = $JssorUtils$.$CssWidth(captionParent); 3827 var captionParentHeight = $JssorUtils$.$CssHeight(captionParent); 3828 3829 var toStyles = {}; 3830 var fromStyles = {}; 3831 var scaleClip = transition.$ScaleClip || 1; 3832 3833 //Opacity 3834 if (transition.$Opacity) { 3835 toStyles.$Opacity = 2 - transition.$Opacity; 3836 } 3837 3838 animatorOptions.$OriginalWidth = captionItemWidth; 3839 animatorOptions.$OriginalHeight = captionItemHeight; 3840 3841 //Transform 3842 if (transition.$Zoom || transition.$Rotate) { 3843 toStyles.$Zoom = transition.$Zoom ? transition.$Zoom - 1 : 1; 3844 3845 if ($JssorUtils$.$IsBrowserIe9Earlier() || $JssorUtils$.$IsBrowserOpera()) 3846 toStyles.$Zoom = Math.min(toStyles.$Zoom, 2); 3847 3848 fromStyles.$Zoom = 1; 3849 3850 var rotate = transition.$Rotate || 0; 3851 if (rotate == true) 3852 rotate = 1; 3853 3854 toStyles.$Rotate = rotate * 360; 3855 fromStyles.$Rotate = 0; 3856 } 3857 //Clip 3858 else if (transition.$Clip) { 3859 var fromStyleClip = { $Top: 0, $Right: captionItemWidth, $Bottom: captionItemHeight, $Left: 0 }; 3860 var toStyleClip = $JssorUtils$.$Extend({}, fromStyleClip); 3861 3862 var blockOffset = toStyleClip.$Offset = {}; 3863 3864 var topBenchmark = transition.$Clip & 4; 3865 var bottomBenchmark = transition.$Clip & 8; 3866 var leftBenchmark = transition.$Clip & 1; 3867 var rightBenchmark = transition.$Clip & 2; 3868 3869 if (topBenchmark && bottomBenchmark) { 3870 blockOffset.$Top = captionItemHeight / 2 * scaleClip; 3871 blockOffset.$Bottom = -blockOffset.$Top; 3872 } 3873 else if (topBenchmark) 3874 blockOffset.$Bottom = -captionItemHeight * scaleClip; 3875 else if (bottomBenchmark) 3876 blockOffset.$Top = captionItemHeight * scaleClip; 3877 3878 if (leftBenchmark && rightBenchmark) { 3879 blockOffset.$Left = captionItemWidth / 2 * scaleClip; 3880 blockOffset.$Right = -blockOffset.$Left; 3881 } 3882 else if (leftBenchmark) 3883 blockOffset.$Right = -captionItemWidth * scaleClip; 3884 else if (rightBenchmark) 3885 blockOffset.$Left = captionItemWidth * scaleClip; 3886 3887 animatorOptions.$Move = transition.$Move; 3888 toStyles.$Clip = toStyleClip; 3889 fromStyles.$Clip = fromStyleClip; 3890 } 3891 3892 //Fly 3893 { 3894 var direction = transition.$FlyDirection; 3895 3896 var toLeft = 0; 3897 var toTop = 0; 3898 3899 var scaleHorizontal = transition.$ScaleHorizontal; 3900 var scaleVertical = transition.$ScaleVertical; 3901 3902 if ($JssorDirection$.$IsToLeft(direction)) { 3903 toLeft -= captionParentWidth * scaleHorizontal; 3904 } 3905 else if ($JssorDirection$.$IsToRight(direction)) { 3906 toLeft += captionParentWidth * scaleHorizontal; 3907 } 3908 3909 if ($JssorDirection$.$IsToTop(direction)) { 3910 toTop -= captionParentHeight * scaleVertical; 3911 } 3912 else if ($JssorDirection$.$IsToBottom(direction)) { 3913 toTop += captionParentHeight * scaleVertical; 3914 } 3915 3916 if (toLeft || toTop || animatorOptions.$Move) { 3917 toStyles.$Left = toLeft + $JssorUtils$.$CssLeft(captionItem); 3918 toStyles.$Top = toTop + $JssorUtils$.$CssTop(captionItem); 3919 } 3920 } 3921 3922 //duration 3923 var duration = transition.$Duration; 3924 3925 fromStyles = $JssorUtils$.$Extend(fromStyles, $JssorUtils$.$GetStyles(captionItem, toStyles)); 3926 3927 animatorOptions.$Setter = $JssorUtils$.$GetStyleSetterEx(); 3928 3929 return new $JssorAnimator$(transition.$Delay, duration, animatorOptions, captionItem, fromStyles, toStyles); 3930 } 3931 3932 function CreateAnimators(streamLineLength, captionItems) { 3933 3934 $JssorUtils$.$Each(captionItems, function (captionItem, i) { 3935 3936 $JssorDebug$.$Execute(function () { 3937 if (captionItem.length) { 3938 var top = $JssorUtils$.$CssTop(captionItem.$Elmt); 3939 var left = $JssorUtils$.$CssLeft(captionItem.$Elmt); 3940 var width = $JssorUtils$.$CssWidth(captionItem.$Elmt); 3941 var height = $JssorUtils$.$CssHeight(captionItem.$Elmt); 3942 3943 var error = null; 3944 3945 if (isNaN(top)) 3946 error = "Style 'top' for caption not specified. Please always specify caption like 'position: absolute; top: ...px; left: ...px; width: ...px; height: ...px;'."; 3947 else if (isNaN(left)) 3948 error = "Style 'left' not specified. Please always specify caption like 'position: absolute; top: ...px; left: ...px; width: ...px; height: ...px;'."; 3949 else if (isNaN(width)) 3950 error = "Style 'width' not specified. Please always specify caption like 'position: absolute; top: ...px; left: ...px; width: ...px; height: ...px;'."; 3951 else if (isNaN(height)) 3952 error = "Style 'height' not specified. Please always specify caption like 'position: absolute; top: ...px; left: ...px; width: ...px; height: ...px;'."; 3953 3954 if (error) 3955 $JssorDebug$.$Error("Caption " + (i + 1) + " definition error, \r\n" + error + "\r\n" + captionItem.$Elmt.outerHTML); 3956 } 3957 }); 3958 3959 var animator; 3960 var captionElmt = captionItem.$Elmt; 3961 var transition = captionItem[0]; 3962 var transition3 = captionItem[1]; 3963 3964 if (transition) { 3965 3966 animator = CreateAnimator(captionElmt, transition); 3967 streamLineLength = animator.$Locate($JssorUtils$.$IsUndefined(transition.$BeginTime) ? streamLineLength : transition.$BeginTime, 1); 3968 } 3969 3970 streamLineLength = CreateAnimators(streamLineLength, captionItem.$Children); 3971 3972 if (transition3) { 3973 var animator3 = CreateAnimator(captionElmt, transition3, 1);
3974 animator3.$Locate(streamLineLength, 1); 3975 _Self.$Combine(animator3); 3976 _ImmediateOutCaptionHanger.$Combine(animator3); 3977 } 3978 3979 if (animator) 3980 _Self.$Combine(animator); 3981 }); 3982 3983 return streamLineLength; 3984 } 3985 3986 _Self.$Revert = function () { 3987 _Self.$GoToPosition(_Self.$GetPosition_OuterEnd() * (playIn || 0)); 3988 _ImmediateOutCaptionHanger.$GoToBegin(); 3989 }; 3990 3991 //Constructor 3992 { 3993 _ImmediateOutCaptionHanger = new $JssorAnimator$(0, 0); 3994 3995 //var streamLineLength = 0; 3996 //var captionItems = GetCaptionItems(container, null, [], [], 1); 3997 3998 CreateAnimators(0, _PlayMode ? GetCaptionItems(container, 1) : []); 3999 } 4000}; 4001 4002//Event Table 4003 4004//$EVT_CLICK = 21; function(slideIndex[, event]) 4005//$EVT_DRAG_START = 22; function(position[, virtualPosition, event]) 4006//$EVT_DRAG_END = 23; function(position, startPosition[, virtualPosition, virtualStartPosition, event]) 4007//$EVT_SWIPE_START = 24; function(position[, virtualPosition]) 4008//$EVT_SWIPE_END = 25; function(position[, virtualPosition]) 4009 4010//$EVT_LOAD_START = 26; function(slideIndex) 4011//$EVT_LOAD_END = 27; function(slideIndex) 4012 4013//$EVT_POSITION_CHANGE = 202; function(position, fromPosition[, virtualPosition, virtualFromPosition]) 4014//$EVT_PARK = 203; function(slideIndex, fromIndex) 4015 4016//$EVT_PROGRESS_CHANGE = 208; function(slideIndex, progress[, progressBegin, idleBegin, idleEnd, progressEnd]) 4017//$EVT_STATE_CHANGE = 209; function(slideIndex, progress[, progressBegin, idleBegin, idleEnd, progressEnd]) 4018 4019//$EVT_ROLLBACK_START = 210; function(slideIndex, progress[, progressBegin, idleBegin, idleEnd, progressEnd]) 4020//$EVT_ROLLBACK_END = 211; function(slideIndex, progress[, progressBegin, idleBegin, idleEnd, progressEnd]) 4021 4022//$EVT_SLIDESHOW_START = 206; function(slideIndex[, progressBegin, slideshowBegin, slideshowEnd, progressEnd]) 4023//$EVT_SLIDESHOW_END = 207; function(slideIndex[, progressBegin, slideshowBegin, slideshowEnd, progressEnd]) 4024 4025//http://www.jssor.com/development/reference-api.html
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.