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