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