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