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