/js/jssor.slider.js

https://bitbucket.org/ezek19/tesitng · JavaScript · 3901 lines · 2822 code · 745 blank · 334 comment · 648 complexity · 70dd56cbbfc9ccae79cdc1764a5ebdc3 MD5 · raw file

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