revolution.extension.navigation.js 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156
  1. /********************************************
  2. * REVOLUTION 5.4.2 EXTENSION - NAVIGATION
  3. * @version: 1.3.5 (06.04.2017)
  4. * @requires jquery.themepunch.revolution.js
  5. * @author ThemePunch
  6. *********************************************/
  7. (function($) {
  8. "use strict";
  9. var _R = jQuery.fn.revolution,
  10. _ISM = _R.is_mobile(),
  11. extension = { alias:"Navigation Min JS",
  12. name:"revolution.extensions.navigation.min.js",
  13. min_core: "5.4.0",
  14. version:"1.3.5"
  15. };
  16. ///////////////////////////////////////////
  17. // EXTENDED FUNCTIONS AVAILABLE GLOBAL //
  18. ///////////////////////////////////////////
  19. jQuery.extend(true,_R, {
  20. hideUnHideNav : function(opt) {
  21. var w = opt.c.width(),
  22. a = opt.navigation.arrows,
  23. b = opt.navigation.bullets,
  24. c = opt.navigation.thumbnails,
  25. d = opt.navigation.tabs;
  26. if (ckNO(a)) biggerNav(opt.c.find('.tparrows'),a.hide_under,w,a.hide_over);
  27. if (ckNO(b)) biggerNav(opt.c.find('.tp-bullets'),b.hide_under,w,b.hide_over);
  28. if (ckNO(c)) biggerNav(opt.c.parent().find('.tp-thumbs'),c.hide_under,w,c.hide_over);
  29. if (ckNO(d)) biggerNav(opt.c.parent().find('.tp-tabs'),d.hide_under,w,d.hide_over);
  30. setONHeights(opt);
  31. },
  32. resizeThumbsTabs : function(opt,force) {
  33. if ((opt.navigation && opt.navigation.tabs.enable) || (opt.navigation && opt.navigation.thumbnails.enable)) {
  34. var f = (jQuery(window).width()-480) / 500,
  35. tws = new punchgs.TimelineLite(),
  36. otab = opt.navigation.tabs,
  37. othu = opt.navigation.thumbnails,
  38. otbu = opt.navigation.bullets;
  39. tws.pause();
  40. f = f>1 ? 1 : f<0 ? 0 : f;
  41. if (ckNO(otab) && (force || otab.width>otab.min_width)) rtt(f,tws,opt.c,otab,opt.slideamount,'tab');
  42. if (ckNO(othu) && (force || othu.width>othu.min_width)) rtt(f,tws,opt.c,othu,opt.slideamount,'thumb');
  43. if (ckNO(otbu) && force) {
  44. // SET BULLET SPACES AND POSITION
  45. var bw = opt.c.find('.tp-bullets');
  46. bw.find('.tp-bullet').each(function(i){
  47. var b = jQuery(this),
  48. am = i+1,
  49. w = b.outerWidth()+parseInt((otbu.space===undefined? 0:otbu.space),0),
  50. h = b.outerHeight()+parseInt((otbu.space===undefined? 0:otbu.space),0);
  51. if (otbu.direction==="vertical") {
  52. b.css({top:((am-1)*h)+"px", left:"0px"});
  53. bw.css({height:(((am-1)*h) + b.outerHeight()),width:b.outerWidth()});
  54. }
  55. else {
  56. b.css({left:((am-1)*w)+"px", top:"0px"});
  57. bw.css({width:(((am-1)*w) + b.outerWidth()),height:b.outerHeight()});
  58. }
  59. });
  60. }
  61. tws.play();
  62. setONHeights(opt);
  63. }
  64. return true;
  65. },
  66. updateNavIndexes : function(opt) {
  67. var _ = opt.c;
  68. function setNavIndex(a) {
  69. if (_.find(a).lenght>0) {
  70. _.find(a).each(function(i) {
  71. jQuery(this).data('liindex',i);
  72. })
  73. }
  74. }
  75. setNavIndex('.tp-tab');
  76. setNavIndex('.tp-bullet');
  77. setNavIndex('.tp-thumb');
  78. _R.resizeThumbsTabs(opt,true);
  79. _R.manageNavigation(opt);
  80. },
  81. // PUT NAVIGATION IN POSITION AND MAKE SURE THUMBS AND TABS SHOWING TO THE RIGHT POSITION
  82. manageNavigation : function(opt) {
  83. var lof = _R.getHorizontalOffset(opt.c.parent(),"left"),
  84. rof = _R.getHorizontalOffset(opt.c.parent(),"right");
  85. if (ckNO(opt.navigation.bullets)) {
  86. if (opt.sliderLayout!="fullscreen" && opt.sliderLayout!="fullwidth") {
  87. // OFFSET ADJUSTEMENT FOR LEFT ARROWS BASED ON THUMBNAILS AND TABS OUTTER
  88. opt.navigation.bullets.h_offset_old = opt.navigation.bullets.h_offset_old === undefined ? opt.navigation.bullets.h_offset : opt.navigation.bullets.h_offset_old;
  89. opt.navigation.bullets.h_offset = opt.navigation.bullets.h_align==="center" ? opt.navigation.bullets.h_offset_old+lof/2 -rof/2: opt.navigation.bullets.h_offset_old+lof-rof;
  90. }
  91. setNavElPositions(opt.c.find('.tp-bullets'),opt.navigation.bullets,opt);
  92. }
  93. if (ckNO(opt.navigation.thumbnails))
  94. setNavElPositions(opt.c.parent().find('.tp-thumbs'),opt.navigation.thumbnails,opt);
  95. if (ckNO(opt.navigation.tabs))
  96. setNavElPositions(opt.c.parent().find('.tp-tabs'),opt.navigation.tabs,opt);
  97. if (ckNO(opt.navigation.arrows)) {
  98. if (opt.sliderLayout!="fullscreen" && opt.sliderLayout!="fullwidth") {
  99. // OFFSET ADJUSTEMENT FOR LEFT ARROWS BASED ON THUMBNAILS AND TABS OUTTER
  100. opt.navigation.arrows.left.h_offset_old = opt.navigation.arrows.left.h_offset_old === undefined ? opt.navigation.arrows.left.h_offset : opt.navigation.arrows.left.h_offset_old;
  101. opt.navigation.arrows.left.h_offset = opt.navigation.arrows.left.h_align==="right" ? opt.navigation.arrows.left.h_offset_old+rof : opt.navigation.arrows.left.h_offset_old+lof;
  102. opt.navigation.arrows.right.h_offset_old = opt.navigation.arrows.right.h_offset_old === undefined ? opt.navigation.arrows.right.h_offset : opt.navigation.arrows.right.h_offset_old;
  103. opt.navigation.arrows.right.h_offset = opt.navigation.arrows.right.h_align==="right" ? opt.navigation.arrows.right.h_offset_old+rof : opt.navigation.arrows.right.h_offset_old+lof;
  104. }
  105. setNavElPositions(opt.c.find('.tp-leftarrow.tparrows'),opt.navigation.arrows.left,opt);
  106. setNavElPositions(opt.c.find('.tp-rightarrow.tparrows'),opt.navigation.arrows.right,opt);
  107. }
  108. if (ckNO(opt.navigation.thumbnails))
  109. moveThumbsInPosition(opt.c.parent().find('.tp-thumbs'),opt.navigation.thumbnails);
  110. if (ckNO(opt.navigation.tabs))
  111. moveThumbsInPosition(opt.c.parent().find('.tp-tabs'),opt.navigation.tabs);
  112. },
  113. // MANAGE THE NAVIGATION
  114. createNavigation : function(container,opt) {
  115. if (_R.compare_version(extension).check==="stop") return false;
  116. var cp = container.parent(),
  117. _a = opt.navigation.arrows, _b = opt.navigation.bullets, _c = opt.navigation.thumbnails, _d = opt.navigation.tabs,
  118. a = ckNO(_a), b = ckNO(_b), c = ckNO(_c), d = ckNO(_d);
  119. // Initialise Keyboard Navigation if Option set so
  120. initKeyboard(container,opt);
  121. // Initialise Mouse Scroll Navigation if Option set so
  122. initMouseScroll(container,opt);
  123. //Draw the Arrows
  124. if (a) initArrows(container,_a,opt);
  125. // BUILD BULLETS, THUMBS and TABS
  126. opt.li.each(function(index) {
  127. var li_rtl = jQuery(opt.li[opt.li.length-1-index]);
  128. var li = jQuery(this);
  129. if (b)
  130. if (opt.navigation.bullets.rtl)
  131. addBullet(container,_b,li_rtl,opt);
  132. else
  133. addBullet(container,_b,li,opt);
  134. if (c)
  135. if (opt.navigation.thumbnails.rtl)
  136. addThumb(container,_c,li_rtl,'tp-thumb',opt);
  137. else
  138. addThumb(container,_c,li,'tp-thumb',opt);
  139. if (d)
  140. if (opt.navigation.tabs.rtl)
  141. addThumb(container,_d,li_rtl,'tp-tab',opt);
  142. else
  143. addThumb(container,_d,li,'tp-tab',opt);
  144. });
  145. // LISTEN TO SLIDE CHANGE - SET ACTIVE SLIDE BULLET
  146. container.bind('revolution.slide.onafterswap revolution.nextslide.waiting',function() {
  147. //cp.find('.tp-bullet, .tp-thumb, .tp-tab').removeClass("selected");
  148. var si = container.find(".next-revslide").length==0 ? container.find(".active-revslide").data("index") : container.find(".next-revslide").data("index");
  149. container.find('.tp-bullet').each(function() {
  150. var _t = jQuery(this);
  151. if (_t.data('liref')===si)
  152. _t.addClass("selected");
  153. else
  154. _t.removeClass("selected");
  155. });
  156. cp.find('.tp-thumb, .tp-tab').each(function() {
  157. var _t = jQuery(this);
  158. if (_t.data('liref')===si) {
  159. _t.addClass("selected");
  160. if (_t.hasClass("tp-tab"))
  161. moveThumbsInPosition(cp.find('.tp-tabs'),_d);
  162. else
  163. moveThumbsInPosition(cp.find('.tp-thumbs'),_c);
  164. } else
  165. _t.removeClass("selected");
  166. });
  167. var ai = 0,
  168. f = false;
  169. if (opt.thumbs)
  170. jQuery.each(opt.thumbs,function(i,obj) {
  171. ai = f === false ? i : ai;
  172. f = obj.id === si || i === si ? true : f;
  173. });
  174. var pi = ai>0 ? ai-1 : opt.slideamount-1,
  175. ni = (ai+1)==opt.slideamount ? 0 : ai+1;
  176. if (_a.enable === true) {
  177. var inst = _a.tmp;
  178. if (opt.thumbs[pi]!=undefined) {
  179. jQuery.each(opt.thumbs[pi].params,function(i,obj) {
  180. inst = inst.replace(obj.from,obj.to);
  181. });
  182. }
  183. _a.left.j.html(inst);
  184. inst = _a.tmp;
  185. if (ni>opt.slideamount) return;
  186. jQuery.each(opt.thumbs[ni].params,function(i,obj) {
  187. inst = inst.replace(obj.from,obj.to);
  188. });
  189. _a.right.j.html(inst);
  190. if (!_a.rtl) {
  191. punchgs.TweenLite.set(_a.left.j.find('.tp-arr-imgholder'),{backgroundImage:"url("+opt.thumbs[pi].src+")"});
  192. punchgs.TweenLite.set(_a.right.j.find('.tp-arr-imgholder'),{backgroundImage:"url("+opt.thumbs[ni].src+")"});
  193. } else {
  194. punchgs.TweenLite.set(_a.left.j.find('.tp-arr-imgholder'),{backgroundImage:"url("+opt.thumbs[ni].src+")"});
  195. punchgs.TweenLite.set(_a.right.j.find('.tp-arr-imgholder'),{backgroundImage:"url("+opt.thumbs[pi].src+")"});
  196. }
  197. }
  198. });
  199. hdResets(_a);
  200. hdResets(_b);
  201. hdResets(_c);
  202. hdResets(_d);
  203. // HOVER OVER ELEMENTS SHOULD SHOW/HIDE NAVIGATION ELEMENTS
  204. cp.on("mouseenter mousemove",function() {
  205. if (!cp.hasClass("tp-mouseover")) {
  206. cp.addClass("tp-mouseover");
  207. punchgs.TweenLite.killDelayedCallsTo(showHideNavElements);
  208. if (a && _a.hide_onleave) showHideNavElements(cp.find('.tparrows'),_a,"show");
  209. if (b && _b.hide_onleave) showHideNavElements(cp.find('.tp-bullets'),_b,"show");
  210. if (c && _c.hide_onleave) showHideNavElements(cp.find('.tp-thumbs'),_c,"show");
  211. if (d && _d.hide_onleave) showHideNavElements(cp.find('.tp-tabs'),_d,"show");
  212. // ON MOBILE WE NEED TO HIDE ELEMENTS EVEN AFTER TOUCH
  213. if (_ISM) {
  214. cp.removeClass("tp-mouseover");
  215. callAllDelayedCalls(container,opt);
  216. }
  217. }
  218. });
  219. cp.on("mouseleave",function() {
  220. cp.removeClass("tp-mouseover");
  221. callAllDelayedCalls(container,opt);
  222. });
  223. // FIRST RUN HIDE ALL ELEMENTS
  224. if (a && _a.hide_onleave) showHideNavElements(cp.find('.tparrows'),_a,"hide",0);
  225. if (b && _b.hide_onleave) showHideNavElements(cp.find('.tp-bullets'),_b,"hide",0);
  226. if (c && _c.hide_onleave) showHideNavElements(cp.find('.tp-thumbs'),_c,"hide",0);
  227. if (d && _d.hide_onleave) showHideNavElements(cp.find('.tp-tabs'),_d,"hide",0);
  228. // Initialise Swipe Navigation
  229. if (c) swipeAction(cp.find('.tp-thumbs'),opt);
  230. if (d) swipeAction(cp.find('.tp-tabs'),opt);
  231. if (opt.sliderType==="carousel") swipeAction(container,opt,true);
  232. if ((opt.navigation.touch.touchOnDesktop==="on") || (opt.navigation.touch.touchenabled=="on" && _ISM)) swipeAction(container,opt,"swipebased");
  233. }
  234. });
  235. /////////////////////////////////
  236. // - INTERNAL FUNCTIONS - ///
  237. /////////////////////////////////
  238. var moveThumbsInPosition = function(container,opt) {
  239. var thumbs = container.hasClass("tp-thumbs") ? ".tp-thumbs" : ".tp-tabs",
  240. thumbmask = container.hasClass("tp-thumbs") ? ".tp-thumb-mask" : ".tp-tab-mask",
  241. thumbsiw = container.hasClass("tp-thumbs") ? ".tp-thumbs-inner-wrapper" : ".tp-tabs-inner-wrapper",
  242. thumb = container.hasClass("tp-thumbs") ? ".tp-thumb" : ".tp-tab",
  243. t=container.find(thumbmask),
  244. el = t.find(thumbsiw),
  245. thumbdir = opt.direction,
  246. tw = thumbdir==="vertical" ? t.find(thumb).first().outerHeight(true)+opt.space : t.find(thumb).first().outerWidth(true)+opt.space,
  247. tmw = thumbdir==="vertical" ? t.height() : t.width(),
  248. ti = parseInt(t.find(thumb+'.selected').data('liindex'),0),
  249. me = tmw/tw,
  250. ts = thumbdir==="vertical" ? t.height() : t.width(),
  251. tp = 0-(ti * tw),
  252. els = thumbdir==="vertical" ? el.height() : el.width(),
  253. curpos = tp < 0-(els-ts) ? 0-(els-ts) : curpos > 0 ? 0 : tp,
  254. elp = el.data('offset');
  255. if (me>2) {
  256. curpos = tp - (elp+tw) <= 0 ? tp - (elp+tw) < 0-tw ? elp : curpos + tw : curpos;
  257. curpos = ( (tp-tw + elp + tmw)< tw && tp + (Math.round(me)-2)*tw < elp) ? tp + (Math.round(me)-2)*tw : curpos;
  258. }
  259. curpos = curpos < 0-(els-ts) ? 0-(els-ts) : curpos > 0 ? 0 : curpos;
  260. if (thumbdir!=="vertical" && t.width()>=el.width()) curpos = 0;
  261. if (thumbdir==="vertical" && t.height()>=el.height()) curpos = 0;
  262. if (!container.hasClass("dragged")) {
  263. if (thumbdir==="vertical")
  264. el.data('tmmove',punchgs.TweenLite.to(el,0.5,{top:curpos+"px",ease:punchgs.Power3.easeInOut}));
  265. else
  266. el.data('tmmove',punchgs.TweenLite.to(el,0.5,{left:curpos+"px",ease:punchgs.Power3.easeInOut}));
  267. el.data('offset',curpos);
  268. }
  269. };
  270. // RESIZE THE THUMBS BASED ON ORIGINAL SIZE AND CURRENT SIZE OF WINDOW
  271. var rtt = function(f,tws,c,o,lis,wh) {
  272. var h = c.parent().find('.tp-'+wh+'s'),
  273. ins = h.find('.tp-'+wh+'s-inner-wrapper'),
  274. mask = h.find('.tp-'+wh+'-mask'),
  275. cw = o.width*f < o.min_width ? o.min_width : Math.round(o.width*f),
  276. ch = Math.round((cw/o.width) * o.height),
  277. iw = o.direction === "vertical" ? cw : (cw*lis) + ((o.space)*(lis-1)),
  278. ih = o.direction === "vertical" ? (ch*lis) + ((o.space)*(lis-1)) : ch,
  279. anm = o.direction === "vertical" ? {width:cw+"px"} : {height:ch+"px"};
  280. tws.add(punchgs.TweenLite.set(h,anm));
  281. tws.add(punchgs.TweenLite.set(ins,{width:iw+"px",height:ih+"px"}));
  282. tws.add(punchgs.TweenLite.set(mask,{width:iw+"px",height:ih+"px"}));
  283. var fin = ins.find('.tp-'+wh+'');
  284. if (fin)
  285. jQuery.each(fin,function(i,el) {
  286. if (o.direction === "vertical")
  287. tws.add(punchgs.TweenLite.set(el,{top:(i*(ch+parseInt((o.space===undefined? 0:o.space),0))),width:cw+"px",height:ch+"px"}));
  288. else
  289. if (o.direction === "horizontal")
  290. tws.add(punchgs.TweenLite.set(el,{left:(i*(cw+parseInt((o.space===undefined? 0:o.space),0))),width:cw+"px",height:ch+"px"}));
  291. });
  292. return tws;
  293. };
  294. // INTERNAL FUNCTIONS
  295. var normalizeWheel = function( event) /*object*/ {
  296. var sX = 0, sY = 0, // spinX, spinY
  297. pX = 0, pY = 0, // pixelX, pixelY
  298. PIXEL_STEP = 1,
  299. LINE_HEIGHT = 1,
  300. PAGE_HEIGHT = 1;
  301. // Legacy
  302. if ('detail' in event) { sY = event.detail; }
  303. if ('wheelDelta' in event) { sY = -event.wheelDelta / 120; }
  304. if ('wheelDeltaY' in event) { sY = -event.wheelDeltaY / 120; }
  305. if ('wheelDeltaX' in event) { sX = -event.wheelDeltaX / 120; }
  306. //sY = navigator.userAgent.match(/mozilla/i) ? sY*10 : sY;
  307. // side scrolling on FF with DOMMouseScroll
  308. if ( 'axis' in event && event.axis === event.HORIZONTAL_AXIS ) {
  309. sX = sY;
  310. sY = 0;
  311. }
  312. pX = sX * PIXEL_STEP;
  313. pY = sY * PIXEL_STEP;
  314. if ('deltaY' in event) { pY = event.deltaY; }
  315. if ('deltaX' in event) { pX = event.deltaX; }
  316. if ((pX || pY) && event.deltaMode) {
  317. if (event.deltaMode == 1) { // delta in LINE units
  318. pX *= LINE_HEIGHT;
  319. pY *= LINE_HEIGHT;
  320. } else { // delta in PAGE units
  321. pX *= PAGE_HEIGHT;
  322. pY *= PAGE_HEIGHT;
  323. }
  324. }
  325. // Fall-back if spin cannot be determined
  326. if (pX && !sX) { sX = (pX < 1) ? -1 : 1; }
  327. if (pY && !sY) { sY = (pY < 1) ? -1 : 1; }
  328. pY = navigator.userAgent.match(/mozilla/i) ? pY*10 : pY;
  329. if (pY>300 || pY<-300) pY = pY/10;
  330. return { spinX : sX,
  331. spinY : sY,
  332. pixelX : pX,
  333. pixelY : pY };
  334. };
  335. var initKeyboard = function(container,opt) {
  336. if (opt.navigation.keyboardNavigation!=="on") return;
  337. jQuery(document).keydown(function(e){
  338. if ((opt.navigation.keyboard_direction=="horizontal" && e.keyCode == 39) || (opt.navigation.keyboard_direction=="vertical" && e.keyCode==40)) {
  339. opt.sc_indicator="arrow";
  340. opt.sc_indicator_dir = 0;
  341. _R.callingNewSlide(container,1);
  342. }
  343. if ((opt.navigation.keyboard_direction=="horizontal" && e.keyCode == 37) || (opt.navigation.keyboard_direction=="vertical" && e.keyCode==38)) {
  344. opt.sc_indicator="arrow";
  345. opt.sc_indicator_dir = 1;
  346. _R.callingNewSlide(container,-1);
  347. }
  348. });
  349. };
  350. var initMouseScroll = function(container,opt) {
  351. if (opt.navigation.mouseScrollNavigation!=="on" && opt.navigation.mouseScrollNavigation!=="carousel") return;
  352. opt.isIEEleven = !!navigator.userAgent.match(/Trident.*rv\:11\./);
  353. opt.isSafari = !!navigator.userAgent.match(/safari/i);
  354. opt.ischrome = !!navigator.userAgent.match(/chrome/i);
  355. var bl = opt.ischrome ? -49 : opt.isIEEleven || opt.isSafari ? -9 : navigator.userAgent.match(/mozilla/i) ? -29 : -49,
  356. tl = opt.ischrome ? 49 : opt.isIEEleven || opt.isSafari ? 9 : navigator.userAgent.match(/mozilla/i) ? 29 : 49;
  357. container.on('mousewheel DOMMouseScroll', function(e) {
  358. var res = normalizeWheel(e.originalEvent),
  359. asi = container.find('.tp-revslider-slidesli.active-revslide').index(),
  360. psi = container.find('.tp-revslider-slidesli.processing-revslide').index(),
  361. fs = asi!=-1 && asi==0 || psi!=-1 && psi==0 ? true : false,
  362. ls = asi!=-1 && asi==opt.slideamount-1 || psi!=1 && psi==opt.slideamount-1 ? true:false,
  363. ret = true;
  364. if (opt.navigation.mouseScrollNavigation=="carousel")
  365. fs = ls = false;
  366. if (psi==-1) {
  367. if(res.pixelY<bl) {
  368. if (!fs) {
  369. opt.sc_indicator="arrow";
  370. if (opt.navigation.mouseScrollReverse!=="reverse") {
  371. opt.sc_indicator_dir = 1;
  372. _R.callingNewSlide(container,-1);
  373. }
  374. ret = false;
  375. }
  376. if (!ls) {
  377. opt.sc_indicator="arrow";
  378. if (opt.navigation.mouseScrollReverse==="reverse") {
  379. opt.sc_indicator_dir = 0;
  380. _R.callingNewSlide(container,1);
  381. }
  382. ret = false;
  383. }
  384. }
  385. else
  386. if(res.pixelY>tl) {
  387. if (!ls) {
  388. opt.sc_indicator="arrow";
  389. if (opt.navigation.mouseScrollReverse!=="reverse") {
  390. opt.sc_indicator_dir = 0;
  391. _R.callingNewSlide(container,1);
  392. }
  393. ret = false;
  394. }
  395. if (!fs) {
  396. opt.sc_indicator="arrow";
  397. if (opt.navigation.mouseScrollReverse==="reverse") {
  398. opt.sc_indicator_dir = 1;
  399. _R.callingNewSlide(container,-1);
  400. }
  401. ret = false;
  402. }
  403. }
  404. } else {
  405. ret = false;
  406. }
  407. var tc = opt.c.offset().top-jQuery('body').scrollTop(),
  408. bc = tc+opt.c.height();
  409. if (opt.navigation.mouseScrollNavigation!="carousel") {
  410. if (opt.navigation.mouseScrollReverse!=="reverse")
  411. if ((tc>0 && res.pixelY>0) || (bc<jQuery(window).height() && res.pixelY<0))
  412. ret = true;
  413. if (opt.navigation.mouseScrollReverse==="reverse")
  414. if ((tc<0 && res.pixelY<0) || (bc>jQuery(window).height() && res.pixelY>0))
  415. ret = true;
  416. } else {
  417. ret=false;
  418. }
  419. if (ret==false) {
  420. e.preventDefault(e);
  421. return false;
  422. } else {
  423. return;
  424. }
  425. });
  426. };
  427. var isme = function (a,c,e) {
  428. a = _ISM ? jQuery(e.target).closest('.'+a).length || jQuery(e.srcElement).closest('.'+a).length : jQuery(e.toElement).closest('.'+a).length || jQuery(e.originalTarget).closest('.'+a).length;
  429. return a === true || a=== 1 ? 1 : 0;
  430. };
  431. // - SET THE SWIPE FUNCTION //
  432. var swipeAction = function(container,opt,vertical) {
  433. //container[0].opt = opt;
  434. // TOUCH ENABLED SCROLL
  435. var _ = opt.carousel;
  436. jQuery(".bullet, .bullets, .tp-bullets, .tparrows").addClass("noSwipe");
  437. _.Limit = "endless";
  438. var notonbody = _ISM || _R.get_browser()==="Firefox",
  439. SwipeOn = container, //notonbody ? container : jQuery('body'),
  440. pagescroll = opt.navigation.thumbnails.direction==="vertical" || opt.navigation.tabs.direction==="vertical"? "none" : "vertical",
  441. swipe_wait_dir = opt.navigation.touch.swipe_direction || "horizontal";
  442. pagescroll = vertical == "swipebased" && swipe_wait_dir=="vertical" ? "none" : vertical ? "vertical" : pagescroll;
  443. if (!jQuery.fn.swipetp) jQuery.fn.swipetp = jQuery.fn.swipe;
  444. if (!jQuery.fn.swipetp.defaults || !jQuery.fn.swipetp.defaults.excludedElements)
  445. if (!jQuery.fn.swipetp.defaults)
  446. jQuery.fn.swipetp.defaults = new Object();
  447. jQuery.fn.swipetp.defaults.excludedElements = "label, button, input, select, textarea, .noSwipe"
  448. SwipeOn.swipetp({
  449. allowPageScroll:pagescroll,
  450. triggerOnTouchLeave:true,
  451. treshold:opt.navigation.touch.swipe_treshold,
  452. fingers:opt.navigation.touch.swipe_min_touches,
  453. excludeElements:jQuery.fn.swipetp.defaults.excludedElements,
  454. swipeStatus:function(event,phase,direction,distance,duration,fingerCount,fingerData) {
  455. var withinslider = isme('rev_slider_wrapper',container,event),
  456. withinthumbs = isme('tp-thumbs',container,event),
  457. withintabs = isme('tp-tabs',container,event),
  458. starget = jQuery(this).attr('class'),
  459. istt = starget.match(/tp-tabs|tp-thumb/gi) ? true : false;
  460. // SWIPE OVER SLIDER, TO SWIPE SLIDES IN CAROUSEL MODE
  461. if (opt.sliderType==="carousel" &&
  462. (((phase==="move" || phase==="end" || phase=="cancel") && (opt.dragStartedOverSlider && !opt.dragStartedOverThumbs && !opt.dragStartedOverTabs))
  463. || (phase==="start" && withinslider>0 && withinthumbs===0 && withintabs===0))) {
  464. if (_ISM && (direction ==="up" || direction==="down")) return;
  465. opt.dragStartedOverSlider = true;
  466. distance = (direction && direction.match(/left|up/g)) ? Math.round(distance * -1) : distance = Math.round(distance * 1);
  467. switch (phase) {
  468. case "start":
  469. if (_.positionanim!==undefined) {
  470. _.positionanim.kill();
  471. _.slide_globaloffset = _.infinity==="off" ? _.slide_offset : _R.simp(_.slide_offset, _.maxwidth);
  472. }
  473. _.overpull = "none";
  474. _.wrap.addClass("dragged");
  475. break;
  476. case "move":
  477. opt.c.find('.tp-withaction').addClass("tp-temporarydisabled");
  478. _.slide_offset = _.infinity==="off" ? _.slide_globaloffset + distance : _R.simp(_.slide_globaloffset + distance, _.maxwidth);
  479. if (_.infinity==="off") {
  480. var bb = _.horizontal_align==="center" ? ((_.wrapwidth/2-_.slide_width/2) - _.slide_offset) / _.slide_width : (0 - _.slide_offset) / _.slide_width;
  481. if ((_.overpull ==="none" || _.overpull===0) && (bb<0 || bb>opt.slideamount-1))
  482. _.overpull = distance;
  483. else
  484. if (bb>=0 && bb<=opt.slideamount-1 && ((bb>=0 && distance>_.overpull) || (bb<=opt.slideamount-1 && distance<_.overpull)))
  485. _.overpull = 0;
  486. _.slide_offset = bb<0 ? _.slide_offset+ (_.overpull-distance)/1.1 + Math.sqrt(Math.abs((_.overpull-distance)/1.1)) :
  487. bb>opt.slideamount-1 ? _.slide_offset+ (_.overpull-distance)/1.1 - Math.sqrt(Math.abs((_.overpull-distance)/1.1)) : _.slide_offset ;
  488. }
  489. _R.organiseCarousel(opt,direction,true,true);
  490. break;
  491. case "end":
  492. case "cancel":
  493. //duration !!
  494. _.slide_globaloffset = _.slide_offset;
  495. _.wrap.removeClass("dragged");
  496. _R.carouselToEvalPosition(opt,direction);
  497. opt.dragStartedOverSlider = false;
  498. opt.dragStartedOverThumbs = false;
  499. opt.dragStartedOverTabs = false;
  500. setTimeout(function() {
  501. opt.c.find('.tp-withaction').removeClass("tp-temporarydisabled");
  502. },19);
  503. break;
  504. }
  505. } else
  506. // SWIPE OVER THUMBS OR TABS
  507. if ((
  508. ((phase==="move" || phase==="end" || phase=="cancel") && (!opt.dragStartedOverSlider && (opt.dragStartedOverThumbs || opt.dragStartedOverTabs)))
  509. ||
  510. (phase==="start" && (withinslider>0 && (withinthumbs>0 || withintabs>0))))) {
  511. if (withinthumbs>0) opt.dragStartedOverThumbs = true;
  512. if (withintabs>0) opt.dragStartedOverTabs = true;
  513. var thumbs = opt.dragStartedOverThumbs ? ".tp-thumbs" : ".tp-tabs",
  514. thumbmask = opt.dragStartedOverThumbs ? ".tp-thumb-mask" : ".tp-tab-mask",
  515. thumbsiw = opt.dragStartedOverThumbs ? ".tp-thumbs-inner-wrapper" : ".tp-tabs-inner-wrapper",
  516. thumb = opt.dragStartedOverThumbs ? ".tp-thumb" : ".tp-tab",
  517. _o = opt.dragStartedOverThumbs ? opt.navigation.thumbnails : opt.navigation.tabs;
  518. distance = (direction && direction.match(/left|up/g)) ? Math.round(distance * -1) : distance = Math.round(distance * 1);
  519. var t= container.parent().find(thumbmask),
  520. el = t.find(thumbsiw),
  521. tdir = _o.direction,
  522. els = tdir==="vertical" ? el.height() : el.width(),
  523. ts = tdir==="vertical" ? t.height() : t.width(),
  524. tw = tdir==="vertical" ? t.find(thumb).first().outerHeight(true)+_o.space : t.find(thumb).first().outerWidth(true)+_o.space,
  525. newpos = (el.data('offset') === undefined ? 0 : parseInt(el.data('offset'),0)),
  526. curpos = 0;
  527. switch (phase) {
  528. case "start":
  529. container.parent().find(thumbs).addClass("dragged");
  530. newpos = tdir === "vertical" ? el.position().top : el.position().left;
  531. el.data('offset',newpos);
  532. if (el.data('tmmove')) el.data('tmmove').pause();
  533. break;
  534. case "move":
  535. if (els<=ts) return false;
  536. curpos = newpos + distance;
  537. curpos = curpos>0 ? tdir==="horizontal" ? curpos - (el.width() * (curpos/el.width() * curpos/el.width())) : curpos - (el.height() * (curpos/el.height() * curpos/el.height())) : curpos;
  538. var dif = tdir==="vertical" ? 0-(el.height()-t.height()) : 0-(el.width()-t.width());
  539. curpos = curpos < dif ? tdir==="horizontal" ? curpos + (el.width() * (curpos-dif)/el.width() * (curpos-dif)/el.width()) : curpos + (el.height() * (curpos-dif)/el.height() * (curpos-dif)/el.height()) : curpos;
  540. if (tdir==="vertical")
  541. punchgs.TweenLite.set(el,{top:curpos+"px"});
  542. else
  543. punchgs.TweenLite.set(el,{left:curpos+"px"});
  544. break;
  545. case "end":
  546. case "cancel":
  547. if (istt) {
  548. curpos = newpos + distance;
  549. curpos = tdir==="vertical" ? curpos < 0-(el.height()-t.height()) ? 0-(el.height()-t.height()) : curpos : curpos < 0-(el.width()-t.width()) ? 0-(el.width()-t.width()) : curpos;
  550. curpos = curpos > 0 ? 0 : curpos;
  551. curpos = Math.abs(distance)>tw/10 ? distance<=0 ? Math.floor(curpos/tw)*tw : Math.ceil(curpos/tw)*tw : distance<0 ? Math.ceil(curpos/tw)*tw : Math.floor(curpos/tw)*tw;
  552. curpos = tdir==="vertical" ? curpos < 0-(el.height()-t.height()) ? 0-(el.height()-t.height()) : curpos : curpos < 0-(el.width()-t.width()) ? 0-(el.width()-t.width()) : curpos;
  553. curpos = curpos > 0 ? 0 : curpos;
  554. if (tdir==="vertical")
  555. punchgs.TweenLite.to(el,0.5,{top:curpos+"px",ease:punchgs.Power3.easeOut});
  556. else
  557. punchgs.TweenLite.to(el,0.5,{left:curpos+"px",ease:punchgs.Power3.easeOut});
  558. curpos = !curpos ? tdir==="vertical" ? el.position().top : el.position().left : curpos;
  559. el.data('offset',curpos);
  560. el.data('distance',distance);
  561. setTimeout(function() {
  562. opt.dragStartedOverSlider = false;
  563. opt.dragStartedOverThumbs = false;
  564. opt.dragStartedOverTabs = false;
  565. },100);
  566. container.parent().find(thumbs).removeClass("dragged");
  567. return false;
  568. }
  569. break;
  570. }
  571. }
  572. else {
  573. if (phase=="end" && !istt) {
  574. opt.sc_indicator="arrow";
  575. if ((swipe_wait_dir=="horizontal" && direction == "left") || (swipe_wait_dir=="vertical" && direction == "up")) {
  576. opt.sc_indicator_dir = 0;
  577. _R.callingNewSlide(opt.c,1);
  578. return false;
  579. }
  580. if ((swipe_wait_dir=="horizontal" && direction == "right") || (swipe_wait_dir=="vertical" && direction == "down")) {
  581. opt.sc_indicator_dir = 1;
  582. _R.callingNewSlide(opt.c,-1);
  583. return false;
  584. }
  585. }
  586. opt.dragStartedOverSlider = false;
  587. opt.dragStartedOverThumbs = false;
  588. opt.dragStartedOverTabs = false;
  589. return true;
  590. }
  591. }
  592. });
  593. };
  594. // NAVIGATION HELPER FUNCTIONS
  595. var hdResets = function(o) {
  596. o.hide_delay = !jQuery.isNumeric(parseInt(o.hide_delay,0)) ? 0.2 : o.hide_delay/1000;
  597. o.hide_delay_mobile = !jQuery.isNumeric(parseInt(o.hide_delay_mobile,0)) ? 0.2 : o.hide_delay_mobile/1000;
  598. };
  599. var ckNO = function(opt) {
  600. return opt && opt.enable;
  601. };
  602. var ckNOLO = function(opt) {
  603. return opt && opt.enable && opt.hide_onleave===true && (opt.position===undefined ? true : !opt.position.match(/outer/g));
  604. };
  605. var callAllDelayedCalls = function(container,opt) {
  606. var cp = container.parent();
  607. if (ckNOLO(opt.navigation.arrows))
  608. punchgs.TweenLite.delayedCall(_ISM ? opt.navigation.arrows.hide_delay_mobile : opt.navigation.arrows.hide_delay,showHideNavElements,[cp.find('.tparrows'),opt.navigation.arrows,"hide"]);
  609. if (ckNOLO(opt.navigation.bullets))
  610. punchgs.TweenLite.delayedCall(_ISM ? opt.navigation.bullets.hide_delay_mobile : opt.navigation.bullets.hide_delay,showHideNavElements,[cp.find('.tp-bullets'),opt.navigation.bullets,"hide"]);
  611. if (ckNOLO(opt.navigation.thumbnails))
  612. punchgs.TweenLite.delayedCall(_ISM ? opt.navigation.thumbnails.hide_delay_mobile : opt.navigation.thumbnails.hide_delay,showHideNavElements,[cp.find('.tp-thumbs'),opt.navigation.thumbnails,"hide"]);
  613. if (ckNOLO(opt.navigation.tabs))
  614. punchgs.TweenLite.delayedCall(_ISM ? opt.navigation.tabs.hide_delay_mobile : opt.navigation.tabs.hide_delay,showHideNavElements,[cp.find('.tp-tabs'),opt.navigation.tabs,"hide"]);
  615. };
  616. var showHideNavElements = function(container,opt,dir,speed) {
  617. speed = speed===undefined ? 0.5 : speed;
  618. switch (dir) {
  619. case "show":
  620. punchgs.TweenLite.to(container,speed, {autoAlpha:1,ease:punchgs.Power3.easeInOut,overwrite:"auto"});
  621. break;
  622. case "hide":
  623. punchgs.TweenLite.to(container,speed, {autoAlpha:0,ease:punchgs.Power3.easeInOu,overwrite:"auto"});
  624. break;
  625. }
  626. };
  627. // ADD ARROWS
  628. var initArrows = function(container,o,opt) {
  629. // SET oIONAL CLASSES
  630. o.style = o.style === undefined ? "" : o.style;
  631. o.left.style = o.left.style === undefined ? "" : o.left.style;
  632. o.right.style = o.right.style === undefined ? "" : o.right.style;
  633. // ADD LEFT AND RIGHT ARROWS
  634. if (container.find('.tp-leftarrow.tparrows').length===0)
  635. container.append('<div class="tp-leftarrow tparrows '+o.style+' '+o.left.style+'">'+o.tmp+'</div>');
  636. if (container.find('.tp-rightarrow.tparrows').length===0)
  637. container.append('<div class="tp-rightarrow tparrows '+o.style+' '+o.right.style+'">'+o.tmp+'</div>');
  638. var la = container.find('.tp-leftarrow.tparrows'),
  639. ra = container.find('.tp-rightarrow.tparrows');
  640. if (o.rtl) {
  641. // CLICK HANDLINGS ON LEFT AND RIGHT ARROWS
  642. la.click(function() { opt.sc_indicator="arrow"; opt.sc_indicator_dir = 0;container.revnext();});
  643. ra.click(function() { opt.sc_indicator="arrow"; opt.sc_indicator_dir = 1;container.revprev();});
  644. } else {
  645. // CLICK HANDLINGS ON LEFT AND RIGHT ARROWS
  646. ra.click(function() { opt.sc_indicator="arrow"; opt.sc_indicator_dir = 0;container.revnext();});
  647. la.click(function() { opt.sc_indicator="arrow"; opt.sc_indicator_dir = 1;container.revprev();});
  648. }
  649. // SHORTCUTS
  650. o.right.j = container.find('.tp-rightarrow.tparrows');
  651. o.left.j = container.find('.tp-leftarrow.tparrows')
  652. // OUTTUER PADDING DEFAULTS
  653. o.padding_top = parseInt((opt.carousel.padding_top||0),0),
  654. o.padding_bottom = parseInt((opt.carousel.padding_bottom||0),0);
  655. // POSITION OF ARROWS
  656. setNavElPositions(la,o.left,opt);
  657. setNavElPositions(ra,o.right,opt);
  658. o.left.opt = opt;
  659. o.right.opt = opt;
  660. if (o.position=="outer-left" || o.position=="outer-right") opt.outernav = true;
  661. };
  662. // PUT ELEMENTS VERTICAL / HORIZONTAL IN THE RIGHT POSITION
  663. var putVinPosition = function(el,o,opt) {
  664. var elh = el.outerHeight(true),
  665. elw = el.outerWidth(true),
  666. oh = o.opt== undefined ? 0 : opt.conh == 0 ? opt.height : opt.conh,
  667. by = o.container=="layergrid" ? opt.sliderLayout=="fullscreen" ? opt.height/2 - (opt.gridheight[opt.curWinRange]*opt.bh)/2 : (opt.autoHeight=="on" || (opt.minHeight!=undefined && opt.minHeight>0)) ? oh/2 - (opt.gridheight[opt.curWinRange]*opt.bh)/2 : 0 : 0,
  668. a = o.v_align === "top" ? {top:"0px",y:Math.round(o.v_offset+by)+"px"} : o.v_align === "center" ? {top:"50%",y:Math.round(((0-elh/2)+o.v_offset))+"px"} : {top:"100%",y:Math.round((0-(elh+o.v_offset+by)))+"px"};
  669. if (!el.hasClass("outer-bottom")) punchgs.TweenLite.set(el,a);
  670. };
  671. var putHinPosition = function(el,o,opt) {
  672. var elh = el.outerHeight(true),
  673. elw = el.outerWidth(true),
  674. bx = o.container=="layergrid" ? opt.sliderType==="carousel" ? 0 : opt.width/2 - (opt.gridwidth[opt.curWinRange]*opt.bw)/2 : 0,
  675. a = o.h_align === "left" ? {left:"0px",x:Math.round(o.h_offset+bx)+"px"} : o.h_align === "center" ? {left:"50%",x:Math.round(((0-elw/2)+o.h_offset))+"px"} : {left:"100%",x:Math.round((0-(elw+o.h_offset+bx)))+"px"};
  676. punchgs.TweenLite.set(el,a);
  677. };
  678. // SET POSITION OF ELEMENTS
  679. var setNavElPositions = function(el,o,opt) {
  680. var wrapper =
  681. el.closest('.tp-simpleresponsive').length>0 ?
  682. el.closest('.tp-simpleresponsive') :
  683. el.closest('.tp-revslider-mainul').length>0 ?
  684. el.closest('.tp-revslider-mainul') :
  685. el.closest('.rev_slider_wrapper').length>0 ?
  686. el.closest('.rev_slider_wrapper'):
  687. el.parent().find('.tp-revslider-mainul'),
  688. ww = wrapper.width(),
  689. wh = wrapper.height();
  690. putVinPosition(el,o,opt);
  691. putHinPosition(el,o,opt);
  692. if (o.position==="outer-left" && (o.sliderLayout=="fullwidth" || o.sliderLayout=="fullscreen"))
  693. punchgs.TweenLite.set(el,{left:(0-el.outerWidth())+"px",x:o.h_offset+"px"});
  694. else
  695. if (o.position==="outer-right" && (o.sliderLayout=="fullwidth" || o.sliderLayout=="fullscreen"))
  696. punchgs.TweenLite.set(el,{right:(0-el.outerWidth())+"px",x:o.h_offset+"px"});
  697. // MAX WIDTH AND HEIGHT BASED ON THE SOURROUNDING CONTAINER
  698. if (el.hasClass("tp-thumbs") || el.hasClass("tp-tabs")) {
  699. var wpad = el.data('wr_padding'),
  700. maxw = el.data('maxw'),
  701. maxh = el.data('maxh'),
  702. mask = el.hasClass("tp-thumbs") ? el.find('.tp-thumb-mask') : el.find('.tp-tab-mask'),
  703. cpt = parseInt((o.padding_top||0),0),
  704. cpb = parseInt((o.padding_bottom||0),0);
  705. // ARE THE CONTAINERS BIGGER THAN THE SLIDER WIDTH OR HEIGHT ?
  706. if (maxw>ww && o.position!=="outer-left" && o.position!=="outer-right") {
  707. punchgs.TweenLite.set(el,{left:"0px",x:0,maxWidth:(ww-2*wpad)+"px"});
  708. punchgs.TweenLite.set(mask,{maxWidth:(ww-2*wpad)+"px"});
  709. } else {
  710. punchgs.TweenLite.set(el,{maxWidth:(maxw)+"px"});
  711. punchgs.TweenLite.set(mask,{maxWidth:(maxw)+"px"});
  712. }
  713. if (maxh+2*wpad>wh && o.position!=="outer-bottom" && o.position!=="outer-top") {
  714. punchgs.TweenLite.set(el,{top:"0px",y:0,maxHeight:(cpt+cpb+(wh-2*wpad))+"px"});
  715. punchgs.TweenLite.set(mask,{maxHeight:(cpt+cpb+(wh-2*wpad))+"px"});
  716. } else {
  717. punchgs.TweenLite.set(el,{maxHeight:(maxh)+"px"});
  718. punchgs.TweenLite.set(mask,{maxHeight:maxh+"px"});
  719. }
  720. if (o.position!=="outer-left" && o.position!=="outer-right") {
  721. cpt = 0;
  722. cpb = 0;
  723. }
  724. // SPAN IS ENABLED
  725. if (o.span===true && o.direction==="vertical") {
  726. punchgs.TweenLite.set(el,{maxHeight:(cpt+cpb+(wh-2*wpad))+"px",height:(cpt+cpb+(wh-2*wpad))+"px",top:(0-cpt),y:0});
  727. putVinPosition(mask,o,opt);
  728. } else
  729. if (o.span===true && o.direction==="horizontal") {
  730. punchgs.TweenLite.set(el,{maxWidth:"100%",width:(ww-2*wpad)+"px",left:0,x:0});
  731. putHinPosition(mask,o,opt);
  732. }
  733. }
  734. };
  735. // ADD A BULLET
  736. var addBullet = function(container,o,li,opt) {
  737. // Check if Bullet exists already ?
  738. if (container.find('.tp-bullets').length===0) {
  739. o.style = o.style === undefined ? "" : o.style;
  740. container.append('<div class="tp-bullets '+o.style+' '+o.direction+'"></div>');
  741. }
  742. // Add Bullet Structure to the Bullet Container
  743. var bw = container.find('.tp-bullets'),
  744. linkto = li.data('index'),
  745. inst = o.tmp;
  746. jQuery.each(opt.thumbs[li.index()].params,function(i,obj) { inst = inst.replace(obj.from,obj.to);})
  747. bw.append('<div class="justaddedbullet tp-bullet">'+inst+'</div>');
  748. // SET BULLET SPACES AND POSITION
  749. var b = container.find('.justaddedbullet'),
  750. am = container.find('.tp-bullet').length,
  751. w = b.outerWidth()+parseInt((o.space===undefined? 0:o.space),0),
  752. h = b.outerHeight()+parseInt((o.space===undefined? 0:o.space),0);
  753. //bgimage = li.data('thumb') !==undefined ? li.data('thumb') : li.find('.defaultimg').data('lazyload') !==undefined && li.find('.defaultimg').data('lazyload') !== 'undefined' ? li.find('.defaultimg').data('lazyload') : li.find('.defaultimg').data('src');
  754. if (o.direction==="vertical") {
  755. b.css({top:((am-1)*h)+"px", left:"0px"});
  756. bw.css({height:(((am-1)*h) + b.outerHeight()),width:b.outerWidth()});
  757. }
  758. else {
  759. b.css({left:((am-1)*w)+"px", top:"0px"});
  760. bw.css({width:(((am-1)*w) + b.outerWidth()),height:b.outerHeight()});
  761. }
  762. b.find('.tp-bullet-image').css({backgroundImage:'url('+opt.thumbs[li.index()].src+')'});
  763. // SET LINK TO AND LISTEN TO CLICK
  764. b.data('liref',linkto);
  765. b.click(function() {
  766. opt.sc_indicator="bullet";
  767. container.revcallslidewithid(linkto);
  768. container.find('.tp-bullet').removeClass("selected");
  769. jQuery(this).addClass("selected");
  770. });
  771. // REMOVE HELP CLASS
  772. b.removeClass("justaddedbullet");
  773. // OUTTUER PADDING DEFAULTS
  774. o.padding_top = parseInt((opt.carousel.padding_top||0),0),
  775. o.padding_bottom = parseInt((opt.carousel.padding_bottom||0),0);
  776. o.opt = opt;
  777. if (o.position=="outer-left" || o.position=="outer-right") opt.outernav = true;
  778. bw.addClass("nav-pos-hor-"+o.h_align);
  779. bw.addClass("nav-pos-ver-"+o.v_align);
  780. bw.addClass("nav-dir-"+o.direction);
  781. // PUT ALL CONTAINER IN POSITION
  782. setNavElPositions(bw,o,opt);
  783. };
  784. var cHex = function(hex,o){
  785. o = parseFloat(o);
  786. hex = hex.replace('#','');
  787. var r = parseInt(hex.substring(0,2), 16),
  788. g = parseInt(hex.substring(2,4), 16),
  789. b = parseInt(hex.substring(4,6), 16),
  790. result = 'rgba('+r+','+g+','+b+','+o+')';
  791. return result;
  792. };
  793. // ADD THUMBNAILS
  794. var addThumb = function(container,o,li,what,opt) {
  795. var thumbs = what==="tp-thumb" ? ".tp-thumbs" : ".tp-tabs",
  796. thumbmask = what==="tp-thumb" ? ".tp-thumb-mask" : ".tp-tab-mask",
  797. thumbsiw = what==="tp-thumb" ? ".tp-thumbs-inner-wrapper" : ".tp-tabs-inner-wrapper",
  798. thumb = what==="tp-thumb" ? ".tp-thumb" : ".tp-tab",
  799. timg = what ==="tp-thumb" ? ".tp-thumb-image" : ".tp-tab-image";
  800. o.visibleAmount = o.visibleAmount>opt.slideamount ? opt.slideamount : o.visibleAmount;
  801. o.sliderLayout = opt.sliderLayout;
  802. // Check if THUNBS/TABS exists already ?
  803. if (container.parent().find(thumbs).length===0) {
  804. o.style = o.style === undefined ? "" : o.style;
  805. var spanw = o.span===true ? "tp-span-wrapper" : "",
  806. addcontent = '<div class="'+what+'s '+spanw+" "+o.position+" "+o.style+'"><div class="'+what+'-mask"><div class="'+what+'s-inner-wrapper" style="position:relative;"></div></div></div>';
  807. if (o.position==="outer-top")
  808. container.parent().prepend(addcontent)
  809. else
  810. if (o.position==="outer-bottom")
  811. container.after(addcontent);
  812. else
  813. container.append(addcontent);
  814. // OUTTUER PADDING DEFAULTS
  815. o.padding_top = parseInt((opt.carousel.padding_top||0),0),
  816. o.padding_bottom = parseInt((opt.carousel.padding_bottom||0),0);
  817. if (o.position=="outer-left" || o.position=="outer-right") opt.outernav = true;
  818. }
  819. // Add Thumb/TAB Structure to the THUMB/TAB Container
  820. var linkto = li.data('index'),
  821. t = container.parent().find(thumbs),
  822. tm = t.find(thumbmask),
  823. tw = tm.find(thumbsiw),
  824. maxw = o.direction==="horizontal" ? (o.width * o.visibleAmount) + (o.space*(o.visibleAmount-1)) : o.width,
  825. maxh = o.direction==="horizontal" ? o.height : (o.height * o.visibleAmount) + (o.space*(o.visibleAmount-1)),
  826. inst = o.tmp;
  827. jQuery.each(opt.thumbs[li.index()].params,function(i,obj) {
  828. inst = inst.replace(obj.from,obj.to);
  829. })
  830. tw.append('<div data-liindex="'+li.index()+'" data-liref="'+linkto+'" class="justaddedthumb '+what+'" style="width:'+o.width+'px;height:'+o.height+'px;">'+inst+'</div>');
  831. // SET BULLET SPACES AND POSITION
  832. var b = t.find('.justaddedthumb'),
  833. am = t.find(thumb).length,
  834. w = b.outerWidth()+parseInt((o.space===undefined? 0:o.space),0),
  835. h = b.outerHeight()+parseInt((o.space===undefined? 0:o.space),0);
  836. // FILL CONTENT INTO THE TAB / THUMBNAIL
  837. b.find(timg).css({backgroundImage:"url("+opt.thumbs[li.index()].src+")"});
  838. if (o.direction==="vertical") {
  839. b.css({top:((am-1)*h)+"px", left:"0px"});
  840. tw.css({height:(((am-1)*h) + b.outerHeight()),width:b.outerWidth()});
  841. }
  842. else {
  843. b.css({left:((am-1)*w)+"px", top:"0px"});
  844. tw.css({width:(((am-1)*w) + b.outerWidth()),height:b.outerHeight()});
  845. }
  846. t.data('maxw',maxw);
  847. t.data('maxh',maxh);
  848. t.data('wr_padding',o.wrapper_padding);
  849. var position = o.position === "outer-top" || o.position==="outer-bottom" ? "relative" : "absolute",
  850. _margin = (o.position === "outer-top" || o.position==="outer-bottom") && (o.h_align==="center") ? "auto" : "0";
  851. tm.css({maxWidth:maxw+"px",maxHeight:maxh+"px",overflow:"hidden",position:"relative"});
  852. t.css({maxWidth:(maxw)+"px",/*margin:_margin, */maxHeight:maxh+"px",overflow:"visible",position:position,background:o.wrapper_color,padding:o.wrapper_padding+"px",boxSizing:"contet-box"});
  853. // SET LINK TO AND LISTEN TO CLICK
  854. b.click(function() {
  855. opt.sc_indicator="bullet";
  856. var dis = container.parent().find(thumbsiw).data('distance');
  857. dis = dis === undefined ? 0 : dis;
  858. if (Math.abs(dis)<10) {
  859. container.revcallslidewithid(linkto);
  860. container.parent().find(thumbs).removeClass("selected");
  861. jQuery(this).addClass("selected");
  862. }
  863. });
  864. // REMOVE HELP CLASS
  865. b.removeClass("justaddedthumb");
  866. o.opt = opt;
  867. t.addClass("nav-pos-hor-"+o.h_align);
  868. t.addClass("nav-pos-ver-"+o.v_align);
  869. t.addClass("nav-dir-"+o.direction);
  870. // PUT ALL CONTAINER IN POSITION
  871. setNavElPositions(t,o,opt);
  872. };
  873. var setONHeights = function(o) {
  874. var ot = o.c.parent().find('.outer-top'),
  875. ob = o.c.parent().find('.outer-bottom');
  876. o.top_outer = !ot.hasClass("tp-forcenotvisible") ? ot.outerHeight() || 0 : 0;
  877. o.bottom_outer = !ob.hasClass("tp-forcenotvisible") ? ob.outerHeight() || 0 : 0;
  878. };
  879. // HIDE NAVIGATION ON PURPOSE
  880. var biggerNav = function(el,a,b,c) {
  881. if (a>b || b>c)
  882. el.addClass("tp-forcenotvisible")
  883. else
  884. el.removeClass("tp-forcenotvisible");
  885. };
  886. })(jQuery);