revolution.extension.layeranimation.min.js 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462
  1. /********************************************
  2. * REVOLUTION 5.0 EXTENSION - LAYER ANIMATION
  3. * @version: 1.1.5 (23.10.2015)
  4. * @requires jquery.themepunch.revolution.js
  5. * @author ThemePunch
  6. *********************************************/
  7. (function($) {
  8. var _R = jQuery.fn.revolution,
  9. _ISM = _R.is_mobile();
  10. ///////////////////////////////////////////
  11. // EXTENDED FUNCTIONS AVAILABLE GLOBAL //
  12. ///////////////////////////////////////////
  13. jQuery.extend(true,_R, {
  14. // MAKE SURE THE ANIMATION ENDS WITH A CLEANING ON MOZ TRANSFORMS
  15. animcompleted : function(_nc,opt) {
  16. var t = _nc.data('videotype'),
  17. ap = _nc.data('autoplay'),
  18. an = _nc.data('autoplayonlyfirsttime');
  19. if (t!=undefined && t!="none")
  20. if (ap==true || ap=="true" || ap=="on" || ap=="1sttime" || an) {
  21. _R.playVideo(_nc,opt);
  22. if ( an || ap=="1sttime") {
  23. _nc.data('autoplayonlyfirsttime',false);
  24. _nc.data('autoplay',"off");
  25. }
  26. } else
  27. if (ap=="no1sttime")
  28. _nc.data('autoplay','on');
  29. },
  30. /********************************************************
  31. - PREPARE AND DEFINE STATIC LAYER DIRECTIONS -
  32. *********************************************************/
  33. handleStaticLayers : function(_nc,opt) {
  34. var s = parseInt(_nc.data('startslide'),0),
  35. e = parseInt(_nc.data('endslide'),0);
  36. if (s < 0)
  37. s=0;
  38. if (e <0 )
  39. e = opt.slideamount;
  40. if (s===0 && e===opt.slideamount-1)
  41. e = opt.slideamount+1;
  42. _nc.data('startslide',s);
  43. _nc.data('endslide',e);
  44. },
  45. /************************************
  46. ANIMATE ALL CAPTIONS
  47. *************************************/
  48. animateTheCaptions : function(nextli, opt,recalled,mtl) {
  49. var base_offsetx = opt.sliderType==="carousel" ? 0 : opt.width/2 - (opt.gridwidth[opt.curWinRange]*opt.bw)/2,
  50. base_offsety=0,
  51. index = nextli.data('index');
  52. opt.layers = opt.layers || new Object();
  53. opt.layers[index] = opt.layers[index] || nextli.find('.tp-caption')
  54. opt.layers["static"] = opt.layers["static"] || opt.c.find('.tp-static-layers').find('.tp-caption');
  55. var allcaptions = new Array;
  56. opt.conh = opt.c.height();
  57. opt.conw = opt.c.width();
  58. opt.ulw = opt.ul.width();
  59. opt.ulh = opt.ul.height();
  60. /* ENABLE DEBUG MODE */
  61. if (opt.debugMode) {
  62. nextli.addClass("indebugmode");
  63. nextli.find('.helpgrid').remove();
  64. opt.c.find('.hglayerinfo').remove();
  65. nextli.append('<div class="helpgrid" style="width:'+(opt.gridwidth[opt.curWinRange]*opt.bw)+'px;height:'+(opt.gridheight[opt.curWinRange]*opt.bw)+'px;"></div>');
  66. var hg = nextli.find('.helpgrid');
  67. hg.append('<div class="hginfo">Zoom:'+(Math.round(opt.bw*100))+'% &nbsp;&nbsp;&nbsp; Device Level:'+opt.curWinRange+'&nbsp;&nbsp;&nbsp; Grid Preset:'+opt.gridwidth[opt.curWinRange]+'x'+opt.gridheight[opt.curWinRange]+'</div>')
  68. opt.c.append('<div class="hglayerinfo"></div>')
  69. hg.append('<div class="tlhg"></div>');
  70. }
  71. if (allcaptions)
  72. jQuery.each(allcaptions,function(i) {
  73. var _nc = jQuery(this);
  74. punchgs.TweenLite.set(_nc.find('.tp-videoposter'),{autoAlpha:1});
  75. punchgs.TweenLite.set(_nc.find('iframe'),{autoAlpha:0});
  76. })
  77. // COLLECT ALL CAPTIONS
  78. if (opt.layers[index])
  79. jQuery.each(opt.layers[index], function(i,a) { allcaptions.push(a); });
  80. if (opt.layers["static"])
  81. jQuery.each(opt.layers["static"], function(i,a) { allcaptions.push(a); });
  82. // GO THROUGH ALL CAPTIONS, AND MANAGE THEM
  83. if (allcaptions)
  84. jQuery.each(allcaptions,function(i) {
  85. _R.animateSingleCaption(jQuery(this),opt,base_offsetx,base_offsety,i,recalled)
  86. });
  87. var bt=jQuery('body').find('#'+opt.c.attr('id')).find('.tp-bannertimer');
  88. bt.data('opt',opt);
  89. if (mtl != undefined) setTimeout(function() {
  90. mtl.resume();
  91. },30);
  92. },
  93. /***************************************
  94. - ANIMATE THE CAPTIONS -
  95. ***************************************/
  96. animateSingleCaption : function(_nc,opt,offsetx,offsety,i,recalled,triggerforce) {
  97. var internrecalled = recalled,
  98. staticdirection = staticLayerStatus(_nc,opt,"in",true),
  99. _pw = _nc.data('_pw') || _nc.closest('.tp-parallax-wrap'),
  100. _lw = _nc.data('_lw') || _nc.closest('.tp-loop-wrap'),
  101. _mw = _nc.data('_mw') || _nc.closest('.tp-mask-wrap'),
  102. _responsive = _nc.data('responsive') || "on",
  103. _respoffset = _nc.data('responsive_offset') || "on",
  104. _ba = _nc.data('basealign') || "grid",
  105. _gw = _ba==="grid" ? opt.width : opt.ulw, //opt.conw,
  106. _gh = _ba==="grid" ? opt.height : opt.ulh, //opt.conh;
  107. rtl = jQuery('body').hasClass("rtl");
  108. if (!_nc.data('_pw')) {
  109. _nc.data('_pw',_pw);
  110. _nc.data('_lw',_lw);
  111. _nc.data('_mw',_mw);
  112. }
  113. if (opt.sliderLayout=="fullscreen")
  114. offsety = _gh/2 - (opt.gridheight[opt.curWinRange]*opt.bh)/2;
  115. if (opt.autoHeight=="on" || (opt.minHeight!=undefined && opt.minHeight>0))
  116. offsety = opt.conh/2 - (opt.gridheight[opt.curWinRange]*opt.bh)/2;;
  117. if (offsety<0) offsety=0;
  118. // LAYER GRID FOR DEBUGGING
  119. if (opt.debugMode) {
  120. _nc.closest('li').find('.helpgrid').css({top:offsety+"px", left:offsetx+"px"});
  121. var linfo = opt.c.find('.hglayerinfo');
  122. _nc.on("hover, mouseenter",function() {
  123. var ltxt = "",
  124. spa = 0;
  125. if (_nc.data())
  126. jQuery.each(_nc.data(),function(key,val) {
  127. if (typeof val !== "object") {
  128. ltxt = ltxt + '<span style="white-space:nowrap"><span style="color:#27ae60">'+key+":</span>"+val+"</span>&nbsp; &nbsp; ";
  129. }
  130. });
  131. linfo.html(ltxt);
  132. });
  133. }
  134. /* END OF DEBUGGING */
  135. var handlecaption=0,
  136. layervisible = makeArray(_nc.data('visibility'),opt)[opt.forcedWinRange] || makeArray(_nc.data('visibility'),opt) || "on";
  137. // HIDE CAPTION IF RESOLUTION IS TOO LOW
  138. if (layervisible=="off" || (_gw<opt.hideCaptionAtLimit && _nc.data('captionhidden')=="on") || (_gw<opt.hideAllCaptionAtLimit))
  139. _nc.addClass("tp-hidden-caption");
  140. else
  141. _nc.removeClass("tp-hidden-caption")
  142. _nc.data('layertype',"html");
  143. if (offsetx<0) offsetx=0;
  144. // FALL BACK TO NORMAL IMAGES
  145. if (_nc.data('thumbimage')!=undefined && _nc.data('videoposter')==undefined)
  146. _nc.data('videoposter',_nc.data('thumbimage'))
  147. // FALL BACK TO NORMAL IMAGE IF NO VIDEO SHOULD BE PLAYED ON MOBILE DEVICES
  148. if (_nc.hasClass("tp-videolayer") && _nc.data('videoposter')!=undefined && (_nc.data('posterOnMobile')=="on" || _nc.data('posteronmobile')=="on") && _ISM) {
  149. var vidw = makeArray(_nc.data('videowidth'),opt)[opt.curWinRange] || makeArray(_nc.data('videowidth'),opt) || "auto",
  150. vidh = makeArray(_nc.data('videoheight'),opt)[opt.curWinRange] || makeArray(_nc.data('videoheight'),opt) || "auto";
  151. vidw = parseFloat(ww),
  152. vidh = parseFloat(hh);
  153. _nc.append('<div class="tp-videoposter" style="position:absolute;top:0px;left:0px;width:100%;height:100%;background-image:url('+_nc.data('videoposter')+'); background-size:cover;background-position:center center;"></div>');
  154. if (vidw!="100%")
  155. _nc.css({minWidth:vidw+"px",minHeight:vidh+"px"});
  156. else
  157. _nc.css({width:"100%",height:"100%"});
  158. _nc.removeClass("tp-videolayer");
  159. }
  160. // IF IT IS AN IMAGE
  161. if (_nc.find('img').length>0) {
  162. var im = _nc.find('img');
  163. _nc.data('layertype',"image");
  164. if (im.width()==0) im.css({width:"auto"});
  165. if (im.height()==0) im.css({height:"auto"});
  166. if (im.data('ww') == undefined && im.width()>0) im.data('ww',im.width());
  167. if (im.data('hh') == undefined && im.height()>0) im.data('hh',im.height());
  168. var ww = im.data('ww'),
  169. hh = im.data('hh'),
  170. fuw = _ba =="slide" ? opt.ulw : opt.gridwidth[opt.curWinRange],
  171. fuh = _ba =="slide" ? opt.ulh : opt.gridheight[opt.curWinRange],
  172. ww = makeArray(im.data('ww'),opt)[opt.curWinRange] || makeArray(im.data('ww'),opt) || "auto",
  173. hh = makeArray(im.data('hh'),opt)[opt.curWinRange] || makeArray(im.data('hh'),opt) || "auto";
  174. var wful = ww==="full" || ww === "full-proportional",
  175. hful = hh==="full" || hh === "full-proportional";
  176. if (ww==="full-proportional") {
  177. var ow = im.data('owidth'),
  178. oh = im.data('oheight');
  179. if (ow/fuw < oh/fuh) {
  180. ww = fuw;
  181. hh = oh*(fuw/ow);
  182. } else {
  183. hh = fuh;
  184. ww = ow*(fuh/oh);
  185. }
  186. } else {
  187. ww = wful ? fuw : parseFloat(ww);
  188. hh = hful ? fuh : parseFloat(hh);
  189. }
  190. if (ww==undefined) ww=0;
  191. if (hh==undefined) hh=0;
  192. if (_responsive!=="off") {
  193. if (_ba!="grid" && wful)
  194. im.width(ww);
  195. else
  196. im.width(ww*opt.bw);
  197. if (_ba!="grid" && hful)
  198. im.height(hh);
  199. else
  200. im.height(hh*opt.bh);
  201. } else {
  202. im.width(ww);
  203. im.height(hh);
  204. }
  205. }
  206. if (_ba==="slide") {
  207. offsetx = 0;
  208. offsety=0;
  209. }
  210. // IF IT IS A VIDEO LAYER
  211. if (_nc.hasClass("tp-videolayer") || _nc.find('iframe').length>0 || _nc.find('video').length>0) {
  212. _nc.data('layertype',"video");
  213. _R.manageVideoLayer(_nc,opt,recalled,internrecalled);
  214. if (!recalled && !internrecalled) {
  215. var t = _nc.data('videotype');
  216. _R.resetVideo(_nc,opt);
  217. }
  218. var asprat = _nc.data('aspectratio');
  219. if (asprat!=undefined && asprat.split(":").length>1)
  220. _R.prepareCoveredVideo(asprat,opt,_nc);
  221. var im = _nc.find('iframe') ? _nc.find('iframe') : im = _nc.find('video'),
  222. html5vid = _nc.find('iframe') ? false : true,
  223. yvcover = _nc.hasClass('coverscreenvideo');
  224. im.css({display:"block"});
  225. // SET WIDTH / HEIGHT
  226. if (_nc.data('videowidth') == undefined) {
  227. _nc.data('videowidth',im.width());
  228. _nc.data('videoheight',im.height());
  229. }
  230. var ww = makeArray(_nc.data('videowidth'),opt)[opt.curWinRange] || makeArray(_nc.data('videowidth'),opt) || "auto",
  231. hh = makeArray(_nc.data('videoheight'),opt)[opt.curWinRange] || makeArray(_nc.data('videoheight'),opt) || "auto",
  232. getobj;
  233. ww = parseFloat(ww);
  234. hh = parseFloat(hh);
  235. // READ AND WRITE CSS SETTINGS OF IFRAME AND VIDEO FOR RESIZING ELEMENST ON DEMAND
  236. if (_nc.data('cssobj')===undefined) {
  237. getobj = getcssParams(_nc,0);
  238. _nc.data('cssobj',getobj);
  239. }
  240. var ncobj = setResponsiveCSSValues(_nc.data('cssobj'),opt);
  241. // IE8 FIX FOR AUTO LINEHEIGHT
  242. if (ncobj.lineHeight=="auto") ncobj.lineHeight = ncobj.fontSize+4;
  243. if (!_nc.hasClass('fullscreenvideo') && !yvcover) {
  244. punchgs.TweenLite.set(_nc,{
  245. paddingTop: Math.round((ncobj.paddingTop * opt.bh)) + "px",
  246. paddingBottom: Math.round((ncobj.paddingBottom * opt.bh)) + "px",
  247. paddingLeft: Math.round((ncobj.paddingLeft* opt.bw)) + "px",
  248. paddingRight: Math.round((ncobj.paddingRight * opt.bw)) + "px",
  249. marginTop: (ncobj.marginTop * opt.bh) + "px",
  250. marginBottom: (ncobj.marginBottom * opt.bh) + "px",
  251. marginLeft: (ncobj.marginLeft * opt.bw) + "px",
  252. marginRight: (ncobj.marginRight * opt.bw) + "px",
  253. borderTopWidth: Math.round(ncobj.borderTopWidth * opt.bh) + "px",
  254. borderBottomWidth: Math.round(ncobj.borderBottomWidth * opt.bh) + "px",
  255. borderLeftWidth: Math.round(ncobj.borderLeftWidth * opt.bw) + "px",
  256. borderRightWidth: Math.round(ncobj.borderRightWidth * opt.bw) + "px",
  257. width:(ww*opt.bw)+"px",
  258. height:(hh*opt.bh)+"px"
  259. });
  260. } else {
  261. offsetx=0; offsety=0;
  262. _nc.data('x',0)
  263. _nc.data('y',0)
  264. var ovhh = _gh;
  265. if (opt.autoHeight=="on") ovhh = opt.conh
  266. _nc.css({'width':_gw, 'height':ovhh });
  267. }
  268. if ((html5vid == false && !yvcover) || ((_nc.data('forcecover')!=1 && !_nc.hasClass('fullscreenvideo') && !yvcover))) {
  269. im.width(ww*opt.bw);
  270. im.height(hh*opt.bh);
  271. }
  272. } // END OF POSITION AND STYLE READ OUTS OF VIDEO
  273. // ALL WRAPPED REKURSIVE ELEMENTS SHOULD BE RESPONSIVE HANDLED
  274. _nc.find('.tp-resizeme, .tp-resizeme *').each(function() {
  275. calcCaptionResponsive(jQuery(this),opt,"rekursive",_responsive);
  276. });
  277. // ALL ELEMENTS IF THE MAIN ELEMENT IS REKURSIVE RESPONSIVE SHOULD BE REPONSIVE HANDLED
  278. if (_nc.hasClass("tp-resizeme"))
  279. _nc.find('*').each(function() {
  280. calcCaptionResponsive(jQuery(this),opt,"rekursive",_responsive);
  281. });
  282. // RESPONIVE HANDLING OF CURRENT LAYER
  283. calcCaptionResponsive(_nc,opt,0,_responsive);
  284. // _nc FRONTCORNER CHANGES
  285. var ncch = _nc.outerHeight(),
  286. bgcol = _nc.css('backgroundColor');
  287. sharpCorners(_nc,'.frontcorner','left','borderRight','borderTopColor',ncch,bgcol);
  288. sharpCorners(_nc,'.frontcornertop','left','borderRight','borderBottomColor',ncch,bgcol);
  289. sharpCorners(_nc,'.backcorner','right','borderLeft','borderBottomColor',ncch,bgcol);
  290. sharpCorners(_nc,'.backcornertop','right','borderLeft','borderTopColor',ncch,bgcol);
  291. if (opt.fullScreenAlignForce == "on") {
  292. offsetx=0;
  293. offsety=0;
  294. }
  295. var arrobj = _nc.data('arrobj');
  296. if (arrobj===undefined) {
  297. var arrobj = new Object();
  298. arrobj.voa = makeArray(_nc.data('voffset'),opt)[opt.curWinRange] || makeArray(_nc.data('voffset'),opt)[0];
  299. arrobj.hoa = makeArray(_nc.data('hoffset'),opt)[opt.curWinRange] || makeArray(_nc.data('hoffset'),opt)[0];
  300. arrobj.elx = makeArray(_nc.data('x'),opt)[opt.curWinRange] || makeArray(_nc.data('x'),opt)[0];
  301. arrobj.ely = makeArray(_nc.data('y'),opt)[opt.curWinRange] || makeArray(_nc.data('y'),opt)[0];
  302. }
  303. // CORRECTION OF NEGATIVE VALUES FROM OLDER SLIDER
  304. //arrobj.voa = arrobj.ely==="bottom" ? arrobj.voa * -1 : arrobj.voa;
  305. //arrobj.hoa = arrobj.elx==="right" ? arrobj.hoa * -1 : arrobj.hoa;
  306. var voa = arrobj.voa.length==0 ? 0 : arrobj.voa,
  307. hoa = arrobj.hoa.length==0 ? 0 : arrobj.hoa,
  308. elx = arrobj.elx.length==0 ? 0 : arrobj.elx,
  309. ely = arrobj.ely.length==0 ? 0 : arrobj.ely,
  310. eow = _nc.outerWidth(true),
  311. eoh = _nc.outerHeight(true);
  312. // NEED CLASS FOR FULLWIDTH AND FULLHEIGHT LAYER SETTING !!
  313. if (eow==0 && eoh==0) {
  314. eow = opt.ulw;
  315. eoh = opt.ulh;
  316. }
  317. var vofs= _respoffset !=="off" ? parseInt(voa,0)*opt.bw : parseInt(voa,0),
  318. hofs= _respoffset !=="off" ? parseInt(hoa,0)*opt.bw : parseInt(hoa,0),
  319. crw = _ba==="grid" ? opt.gridwidth[opt.curWinRange]*opt.bw : _gw,
  320. crh = _ba==="grid" ? opt.gridheight[opt.curWinRange]*opt.bw : _gh;
  321. if (opt.fullScreenAlignForce == "on") {
  322. crw = opt.ulw;
  323. crh = opt.ulh;
  324. }
  325. // ALIGN POSITIONED ELEMENTS
  326. elx = elx==="center" || elx==="middle" ? (crw/2 - eow/2) + hofs : elx==="left" ? hofs : elx==="right" ? (crw - eow) - hofs : _respoffset !=="off" ? elx * opt.bw : elx;
  327. ely = ely=="center" || ely=="middle" ? (crh/2 - eoh/2) + vofs : ely =="top" ? vofs : ely=="bottom" ? (crh - eoh)-vofs : _respoffset !=="off" ? ely*opt.bw : ely;
  328. if (rtl)
  329. elx = elx + eow;
  330. // THE TRANSITIONS OF CAPTIONS
  331. // MDELAY AND MSPEED
  332. var $lts = _nc.data('lasttriggerstate'),
  333. $cts = _nc.data('triggerstate'),
  334. $start = _nc.data('start') || 100,
  335. $end = _nc.data('end'),
  336. mdelay = triggerforce ? 0 : $start==="bytrigger" || $start==="sliderenter" ? 0 : parseFloat($start)/1000,
  337. calcx = (elx+offsetx),
  338. calcy = (ely+offsety),
  339. tpcapindex = _nc.css("z-Index");
  340. if (!triggerforce)
  341. if ($lts=="reset" && $start!="bytrigger") {
  342. _nc.data("triggerstate","on");
  343. _nc.data('animdirection',"in");
  344. $cts = "on";
  345. } else
  346. if ($lts=="reset" && $start=="bytrigger") {
  347. _nc.data("triggerstate","off");
  348. _nc.data('animdirection',"out");
  349. $cts = "off";
  350. }
  351. // SET TOP/LEFT POSITION OF LAYER
  352. punchgs.TweenLite.set(_pw,{zIndex:tpcapindex, top:calcy,left:calcx,overwrite:"auto"});
  353. if (staticdirection == 0) internrecalled = true;
  354. // STATIC LAYER, THINK ON THIS !!!
  355. if (_nc.data('timeline')!=undefined && !internrecalled) {
  356. if (staticdirection!=2)
  357. _nc.data('timeline').gotoAndPlay(0);
  358. internrecalled = true;
  359. }
  360. // KILL OUT ANIMATION
  361. if (!recalled && _nc.data('timeline_out') && staticdirection!=2 && staticdirection!=0) {
  362. _nc.data('timeline_out').kill();
  363. _nc.data('outstarted',0);
  364. }
  365. // TRIGGERED ELEMENTS SHOULD
  366. if (triggerforce && _nc.data('timeline')!=undefined) {
  367. _nc.removeData('$anims')
  368. _nc.data('timeline').pause(0);
  369. _nc.data('timeline').kill();
  370. if (_nc.data('newhoveranim')!=undefined) {
  371. _nc.data('newhoveranim').progress(0);
  372. _nc.data('newhoveranim').kill();
  373. }
  374. _nc.removeData('timeline');
  375. punchgs.TweenLite.killTweensOf(_nc);
  376. _nc.unbind('hover');
  377. _nc.removeClass("rs-hover-ready");
  378. _nc.removeData('newhoveranim');
  379. }
  380. var $time = _nc.data('timeline') ? _nc.data('timeline').time() : 0,
  381. $progress = _nc.data('timeline')!==undefined ? _nc.data('timeline').progress() : 0,
  382. tl = _nc.data('timeline') || new punchgs.TimelineLite({smoothChildTiming:true});
  383. $progress = jQuery.isNumeric($progress) ? $progress: 0;
  384. tl.pause();
  385. // LAYER IS TRIGGERED ??
  386. if ($progress<1 && _nc.data('outstarted') != 1 || staticdirection==2 || triggerforce) {
  387. var animobject = _nc;
  388. if (_nc.data('mySplitText') !=undefined) _nc.data('mySplitText').revert();
  389. if (_nc.data('splitin')!=undefined && _nc.data('splitin').match(/chars|words|lines/g) || _nc.data('splitout')!=undefined && _nc.data('splitout').match(/chars|words|lines/g)) {
  390. var splittarget = _nc.find('a').length>0 ? _nc.find('a') : _nc;
  391. _nc.data('mySplitText',new punchgs.SplitText(splittarget,{type:"lines,words,chars",charsClass:"tp-splitted",wordsClass:"tp-splitted",linesClass:"tp-splitted"}));
  392. _nc.addClass("splitted");
  393. }
  394. if ( _nc.data('mySplitText') !==undefined && _nc.data('splitin') && _nc.data('splitin').match(/chars|words|lines/g)) animobject = _nc.data('mySplitText')[_nc.data('splitin')]
  395. var $a = new Object();
  396. var reverseanim = _nc.data('transform_in')!=undefined ? _nc.data('transform_in').match(/\(R\)/gi) : false;
  397. // BUILD ANIMATION LIBRARY AND HOVER ANIMATION
  398. if (!_nc.data('$anims') || triggerforce || reverseanim) {
  399. var $from = newAnimObject(),
  400. $result = newAnimObject(),
  401. $hover = newHoverAnimObject(),
  402. hashover = _nc.data('transform_hover')!==undefined || _nc.data('style_hover')!==undefined;
  403. // WHICH ANIMATION TYPE SHOULD BE USED
  404. $result = getAnimDatas($result,_nc.data('transform_idle'));
  405. $from = getAnimDatas($result,_nc.data('transform_in'),opt.sdir==1);
  406. if (hashover) {
  407. $hover = getAnimDatas($hover,_nc.data('transform_hover'));
  408. $hover = convertHoverStyle($hover,_nc.data('style_hover'));
  409. _nc.data('hover',$hover);
  410. }
  411. // DELAYS
  412. $from.elemdelay = (_nc.data('elementdelay') == undefined) ? 0 : _nc.data('elementdelay');
  413. $result.anim.ease = $from.anim.ease = $from.anim.ease || punchgs.Power1.easeInOut;
  414. // HOVER ANIMATION
  415. if (hashover && !_nc.hasClass("rs-hover-ready")) {
  416. _nc.addClass("rs-hover-ready");
  417. _nc.hover(function(e) {
  418. var nc = jQuery(e.currentTarget),
  419. t = nc.data('hover'),
  420. intl = nc.data('timeline');
  421. if (intl && intl.progress()==1) {
  422. if (nc.data('newhoveranim')===undefined || nc.data('newhoveranim')==="none") {
  423. nc.data('newhoveranim',punchgs.TweenLite.to(nc,t.speed,t.anim));
  424. } else {
  425. nc.data('newhoveranim').progress(0);
  426. nc.data('newhoveranim').play();
  427. }
  428. }
  429. },
  430. function(e) {
  431. var nc = jQuery(e.currentTarget),
  432. intl = nc.data('timeline');
  433. if (intl && intl.progress()==1 && nc.data('newhoveranim')!=undefined) {
  434. nc.data('newhoveranim').reverse();
  435. }
  436. });
  437. }
  438. $a = new Object();
  439. $a.f = $from;
  440. $a.r = $result;
  441. _nc.data('$anims');
  442. } else {
  443. $a = _nc.data('$anims');
  444. }
  445. // SET WRAPPING CONTAINER SIZES
  446. var $mask_frm = getMaskDatas(_nc.data('mask_in')),
  447. newtl = new punchgs.TimelineLite();
  448. $a.f.anim.x = $a.f.anim.x * opt.bw || getBorderDirections($a.f.anim.x,opt,eow,eoh,calcy,calcx, "horizontal" );
  449. $a.f.anim.y = $a.f.anim.y * opt.bw || getBorderDirections($a.f.anim.y,opt,eow,eoh,calcy,calcx, "vertical" );
  450. // IF LAYER IS NOT STATIC, OR STATIC AND NOT ANIMATED IN AT THIS LOOP
  451. if (staticdirection != 2 || triggerforce) {
  452. // SPLITED ANIMATION IS IN GAME
  453. if (animobject != _nc) {
  454. var oldease = $a.r.anim.ease;
  455. tl.add(punchgs.TweenLite.set(_nc, $a.r.anim));
  456. $a.r = newAnimObject();
  457. $a.r.anim.ease = oldease;
  458. }
  459. $a.f.anim.visibility = "hidden";
  460. newtl.eventCallback("onStart",function(){
  461. punchgs.TweenLite.set(_nc,{visibility:"visible"});
  462. // FIX VISIBLE IFRAME BUG IN SAFARI
  463. if (_nc.data('iframes'))
  464. _nc.find('iframe').each(function() {
  465. punchgs.TweenLite.set(jQuery(this),{autoAlpha:1});
  466. })
  467. punchgs.TweenLite.set(_pw,{visibility:"visible"});
  468. var data={};
  469. data.layer = _nc;
  470. data.eventtype = "enterstage";
  471. data.layertype = _nc.data('layertype');
  472. data.layersettings = _nc.data();
  473. opt.c.trigger("revolution.layeraction",data)
  474. });
  475. newtl.eventCallback("onComplete",function() {
  476. var data={};
  477. data.layer = _nc;
  478. data.eventtype = "enteredstage";
  479. data.layertype = _nc.data('layertype');
  480. data.layersettings = _nc.data();
  481. opt.c.trigger("revolution.layeraction",data);
  482. _R.animcompleted(_nc,opt);
  483. });
  484. // SHOW ELEMENTS WITH SLIDEENTER A BIT LATER FIRST !
  485. if (($start=="sliderenter" && opt.overcontainer))
  486. mdelay = 0.6;
  487. tl.add(newtl.staggerFromTo(animobject,$a.f.speed,$a.f.anim,$a.r.anim,$a.f.elemdelay),mdelay);
  488. // MASK ANIMATION
  489. if ($mask_frm) {
  490. var $mask_rsl = new Object();
  491. $mask_rsl.ease = $a.r.anim.ease;
  492. $mask_rsl.overflow = $mask_frm.anim.overflow ="hidden";
  493. $mask_rsl.x = $mask_rsl.y = 0;
  494. $mask_frm.anim.x = $mask_frm.anim.x * opt.bw || getBorderDirections($mask_frm.anim.x,opt,eow,eoh,calcy,calcx,"horizontal");
  495. $mask_frm.anim.y = $mask_frm.anim.y * opt.bw || getBorderDirections($mask_frm.anim.y,opt,eow,eoh,calcy,calcx,"vertical");
  496. tl.add(punchgs.TweenLite.fromTo(_mw,$a.f.speed,$mask_frm.anim,$mask_rsl,$from.elemdelay),mdelay);
  497. } else {
  498. tl.add(punchgs.TweenLite.set(_mw,{overflow:"visible"},$from.elemdelay),0);
  499. }
  500. }
  501. // SAVE IT TO NCAPTION BEFORE NEW STEPS WILL BE ADDED
  502. _nc.data('timeline',tl);
  503. // IF THERE IS ANY EXIT ANIM DEFINED
  504. // For Static Layers -> 1 -> In, 2-> Out 0-> Ignore -1-> Not Static
  505. staticdirection = staticLayerStatus(_nc,opt,"in");
  506. if (($progress === 0 || staticdirection==2) && $end!=="bytrigger" && !triggerforce && $end!="sliderleave")
  507. if (($end!=undefined) && (staticdirection==-1 || staticdirection==2) && ($end!=="bytriger"))
  508. punchgs.TweenLite.delayedCall(parseInt(_nc.data('end'),0)/1000,_R.endMoveCaption,[_nc,_mw,_pw,opt]);
  509. else
  510. punchgs.TweenLite.delayedCall(999999,_R.endMoveCaption,[_nc,_mw,_pw,opt]);
  511. // SAVE THE TIMELINE IN DOM ELEMENT
  512. tl = _nc.data('timeline');
  513. if (_nc.data('loopanimation')=="on") callCaptionLoops(_lw,opt.bw);
  514. if (($start!="sliderenter" || ($start=="sliderenter" && opt.overcontainer)) && (staticdirection==-1 || staticdirection==1 || triggerforce || (staticdirection==0 && $progress<1 && _nc.hasClass("rev-static-visbile"))))
  515. if (($progress<1 && $progress>0) ||
  516. ($progress==0 && $start!="bytrigger" && $lts!="keep") ||
  517. ($progress==0 && $start!="bytrigger" && $lts=="keep" && $cts=="on") ||
  518. ($start=="bytrigger" && $lts=="keep" && $cts=="on"))
  519. tl.resume($time);
  520. }
  521. //punchgs.TweenLite.set(_mw,{width:eow, height:eoh});
  522. if (_nc.data('loopanimation')=="on") punchgs.TweenLite.set(_lw,{minWidth:eow,minHeight:eoh});
  523. if (_nc.data('slidelink')!=0 && (_nc.data('slidelink')==1 || _nc.hasClass("slidelink"))) {
  524. punchgs.TweenLite.set(_mw,{width:"100%", height:"100%"});
  525. _nc.data('slidelink',1);
  526. } else {
  527. punchgs.TweenLite.set(_mw,{width:"auto", height:"auto"});
  528. _nc.data('slidelink',0);
  529. }
  530. },
  531. //////////////////////////////
  532. // MOVE OUT THE CAPTIONS //
  533. ////////////////////////////
  534. endMoveCaption : function(_nc,_mw,_pw,opt) {
  535. _mw = _mw || _nc.data('_mw');
  536. _pw = _pw || _nc.data('_pw');
  537. // Kill TimeLine of "in Animation"
  538. _nc.data('outstarted',1);
  539. if (_nc.data('timeline'))
  540. _nc.data('timeline').pause();
  541. else
  542. if (_nc.data('_pw')===undefined) return;
  543. var tl = new punchgs.TimelineLite(),
  544. subtl = new punchgs.TimelineLite(),
  545. newmasktl = new punchgs.TimelineLite(),
  546. $from = getAnimDatas(newAnimObject(),_nc.data('transform_in'),opt.sdir==1),
  547. $to = _nc.data('transform_out') ? getAnimDatas(newEndAnimObject(),_nc.data('transform_out'),opt.sdir==1) : getAnimDatas(newEndAnimObject(),_nc.data('transform_in'),opt.sdir==1),
  548. animobject = _nc.data('splitout') && _nc.data('splitout').match(/words|chars|lines/g) ? _nc.data('mySplitText')[_nc.data('splitout')] : _nc,
  549. elemdelay = (_nc.data('endelementdelay') == undefined) ? 0 : _nc.data('endelementdelay'),
  550. iw = _nc.innerWidth(),
  551. ih = _nc.innerHeight(),
  552. p = _pw.position();
  553. // IF REVERSE AUTO ANIMATION ENABLED
  554. if (_nc.data('transform_out') && _nc.data('transform_out').match(/auto:auto/g)) {
  555. $from.speed = $to.speed;
  556. $from.anim.ease = $to.anim.ease;
  557. $to = $from;
  558. }
  559. var $mask_to = getMaskDatas(_nc.data('mask_out'));
  560. $to.anim.x = $to.anim.x * opt.bw || getBorderDirections($to.anim.x,opt,iw,ih,p.top,p.left,"horizontal");
  561. $to.anim.y = $to.anim.y * opt.bw || getBorderDirections($to.anim.y,opt,iw,ih,p.top,p.left,"vertical");
  562. subtl.eventCallback("onStart",function(){
  563. var data={};
  564. data.layer = _nc;
  565. data.eventtype = "leavestage";
  566. data.layertype = _nc.data('layertype');
  567. data.layersettings = _nc.data();
  568. opt.c.trigger("revolution.layeraction",data);
  569. });
  570. subtl.eventCallback("onComplete",function(){
  571. punchgs.TweenLite.set(_nc,{visibility:"hidden"});
  572. punchgs.TweenLite.set(_pw,{visibility:"hidden"});
  573. var data={};
  574. data.layer = _nc;
  575. data.eventtype = "leftstage";
  576. data.layertype = _nc.data('layertype');
  577. data.layersettings = _nc.data();
  578. opt.c.trigger("revolution.layeraction",data);
  579. });
  580. tl.add(subtl.staggerTo(animobject,$to.speed,$to.anim,elemdelay),0);
  581. // MASK ANIMATION
  582. if ($mask_to) {
  583. $mask_to.anim.ease = $to.anim.ease;
  584. $mask_to.anim.overflow = "hidden";
  585. $mask_to.anim.x = $mask_to.anim.x * opt.bw || getBorderDirections($mask_to.anim.x,opt,iw,ih,p.top,p.left,"horizontal");
  586. $mask_to.anim.y = $mask_to.anim.y * opt.bw || getBorderDirections($mask_to.anim.y,opt,iw,ih,p.top,p.left,"vertical");
  587. tl.add(newmasktl.to(_mw,$to.speed,$mask_to.anim,elemdelay),0);
  588. } else {
  589. tl.add(newmasktl.set(_mw,{overflow:"visible",overwrite:"auto"},elemdelay),0);
  590. }
  591. _nc.data('timeline_out',tl);
  592. },
  593. //////////////////////////
  594. // REMOVE THE CAPTIONS //
  595. /////////////////////////
  596. removeTheCaptions : function(actli,opt) {
  597. var removetime = 0,
  598. index = actli.data('index'),
  599. allcaptions = new Array;
  600. // COLLECT ALL CAPTIONS
  601. if (opt.layers[index])
  602. jQuery.each(opt.layers[index], function(i,a) { allcaptions.push(a); });
  603. if (opt.layers["static"])
  604. jQuery.each(opt.layers["static"], function(i,a) { allcaptions.push(a); });
  605. punchgs.TweenLite.killDelayedCallsTo(_R.endMoveCaption);
  606. // GO THROUGH ALL CAPTIONS, AND MANAGE THEM
  607. if (allcaptions)
  608. jQuery.each(allcaptions,function(i) {
  609. var _nc=jQuery(this),
  610. stat = staticLayerStatus(_nc,opt,"out");
  611. if (stat != 0 ) { //0 == ignore
  612. killCaptionLoops(_nc);
  613. clearTimeout(_nc.data('videoplaywait'));
  614. if (_R.stopVideo) _R.stopVideo(_nc,opt);
  615. _R.endMoveCaption(_nc,null,null,opt)
  616. opt.playingvideos = [];
  617. opt.lastplayedvideos = [];
  618. }
  619. });
  620. }
  621. });
  622. /**********************************************************************************************
  623. - HELPER FUNCTIONS FOR LAYER TRANSFORMS -
  624. **********************************************************************************************/
  625. /////////////////////////////////////
  626. // - CREATE ANIMATION OBJECT - //
  627. /////////////////////////////////////
  628. var newAnimObject = function() {
  629. var a = new Object();
  630. a.anim = new Object();
  631. a.anim.x=0;
  632. a.anim.y=0;
  633. a.anim.z=0;
  634. a.anim.rotationX = 0;
  635. a.anim.rotationY = 0;
  636. a.anim.rotationZ = 0;
  637. a.anim.scaleX = 1;
  638. a.anim.scaleY = 1;
  639. a.anim.skewX = 0;
  640. a.anim.skewY = 0;
  641. a.anim.opacity=1;
  642. a.anim.transformOrigin = "50% 50%";
  643. a.anim.transformPerspective = 600;
  644. a.anim.rotation = 0;
  645. a.anim.ease = punchgs.Power3.easeOut;
  646. a.anim.force3D = "auto";
  647. a.speed = 0.3;
  648. a.anim.autoAlpha = 1;
  649. a.anim.visibility = "visible";
  650. a.anim.overwrite = "all";
  651. return a;
  652. }
  653. var newEndAnimObject = function() {
  654. var a = new Object();
  655. a.anim = new Object();
  656. a.anim.x=0;
  657. a.anim.y=0;
  658. a.anim.z=0;
  659. return a;
  660. }
  661. var newHoverAnimObject = function() {
  662. var a = new Object();
  663. a.anim = new Object();
  664. a.speed = 0.2;
  665. return a;
  666. }
  667. var animDataTranslator = function(val,defval) {
  668. if (jQuery.isNumeric(parseFloat(val))) {
  669. return parseFloat(val);
  670. } else
  671. if (val===undefined || val==="inherit") {
  672. return defval;
  673. } else
  674. if (val.split("{").length>1) {
  675. var min = val.split(","),
  676. max = parseFloat(min[1].split("}")[0]);
  677. min = parseFloat(min[0].split("{")[1]);
  678. val = Math.random()*(max-min) + min;
  679. }
  680. return val;
  681. }
  682. var getBorderDirections = function (x,o,w,h,top,left,direction) {
  683. if (!jQuery.isNumeric(x) && x.match(/%]/g)) {
  684. x = x.split("[")[1].split("]")[0];
  685. if (direction=="horizontal")
  686. x = (w+2)*parseInt(x,0)/100;
  687. else
  688. if (direction=="vertical")
  689. x = (h+2)*parseInt(x,0)/100;
  690. } else {
  691. x = x === "layer_left" ? (0-w) : x === "layer_right" ? w : x;
  692. x = x === "layer_top" ? (0-h) : x==="layer_bottom" ? h : x;
  693. x = x === "left" || x==="stage_left" ? (0-w-left) : x === "right" || x==="stage_right" ? o.conw-left : x === "center" || x === "stage_center" ? (o.conw/2 - w/2)-left : x;
  694. x = x === "top" || x==="stage_top" ? (0-h-top) : x==="bottom" || x==="stage_bottom" ? o.conh-top : x === "middle" || x === "stage_middle" ? (o.conh/2 - h/2)-top : x;
  695. }
  696. return x;
  697. }
  698. ///////////////////////////////////////////////////
  699. // ANALYSE AND READ OUT DATAS FROM HTML CAPTIONS //
  700. ///////////////////////////////////////////////////
  701. var getAnimDatas = function(frm,data,reversed) {
  702. var o = new Object();
  703. o = jQuery.extend(true,{},o, frm);
  704. if (data === undefined)
  705. return o;
  706. var customarray = data.split(';');
  707. if (customarray)
  708. jQuery.each(customarray,function(index,pa) {
  709. var p = pa.split(":")
  710. var w = p[0],
  711. v = p[1];
  712. if (reversed && v!=undefined && v.length>0 && v.match(/\(R\)/)) {
  713. v = v.replace("(R)","");
  714. v = v==="right" ? "left" : v==="left" ? "right" : v==="top" ? "bottom" : v==="bottom" ? "top" : v;
  715. if (v[0]==="[" && v[1]==="-") v = v.replace("[-","[");
  716. else
  717. if (v[0]==="[" && v[1]!=="-") v = v.replace("[","[-");
  718. else
  719. if (v[0]==="-") v = v.replace("-","");
  720. else
  721. if (v[0].match(/[1-9]/)) v="-"+v;
  722. }
  723. if (v!=undefined) {
  724. v = v.replace(/\(R\)/,'');
  725. if (w=="rotationX" || w=="rX") o.anim.rotationX = animDataTranslator(v,o.anim.rotationX)+"deg";
  726. if (w=="rotationY" || w=="rY") o.anim.rotationY = animDataTranslator(v,o.anim.rotationY)+"deg";
  727. if (w=="rotationZ" || w=="rZ") o.anim.rotation = animDataTranslator(v,o.anim.rotationZ)+"deg";
  728. if (w=="scaleX" || w=="sX") o.anim.scaleX = animDataTranslator(v,o.anim.scaleX);
  729. if (w=="scaleY" || w=="sY") o.anim.scaleY = animDataTranslator(v,o.anim.scaleY);
  730. if (w=="opacity" || w=="o") o.anim.opacity = animDataTranslator(v,o.anim.opacity);
  731. if (w=="skewX" || w=="skX") o.anim.skewX = animDataTranslator(v,o.anim.skewX);
  732. if (w=="skewY" || w=="skY") o.anim.skewY = animDataTranslator(v,o.anim.skewY);
  733. if (w=="x") o.anim.x = animDataTranslator(v,o.anim.x);
  734. if (w=="y") o.anim.y = animDataTranslator(v,o.anim.y);
  735. if (w=="z") o.anim.z = animDataTranslator(v,o.anim.z);
  736. if (w=="transformOrigin" || w=="tO") o.anim.transformOrigin = v.toString();
  737. if (w=="transformPerspective" || w=="tP") o.anim.transformPerspective=parseInt(v,0);
  738. if (w=="speed" || w=="s") o.speed = parseFloat(v)/1000;
  739. if (w=="ease" || w=="e") o.anim.ease = v;
  740. }
  741. })
  742. return o;
  743. }
  744. /////////////////////////////////
  745. // BUILD MASK ANIMATION OBJECT //
  746. /////////////////////////////////
  747. var getMaskDatas = function(d) {
  748. if (d === undefined)
  749. return false;
  750. var o = new Object();
  751. o.anim = new Object();
  752. var s = d.split(';')
  753. if (s)
  754. jQuery.each(s,function(index,param) {
  755. param = param.split(":")
  756. var w = param[0],
  757. v = param[1];
  758. if (w=="x") o.anim.x = v;
  759. if (w=="y") o.anim.y = v;
  760. if (w=="s") o.speed = parseFloat(v)/1000;
  761. if (w=="e" || w=="ease") o.anim.ease = v;
  762. });
  763. return o;
  764. }
  765. ////////////////////////
  766. // SHOW THE CAPTION //
  767. ///////////////////////
  768. var makeArray = function(obj,opt,show) {
  769. if (obj==undefined) obj = 0;
  770. if (!jQuery.isArray(obj) && jQuery.type(obj)==="string" && (obj.split(",").length>1 || obj.split("[").length>1)) {
  771. obj = obj.replace("[","");
  772. obj = obj.replace("]","");
  773. var newobj = obj.match(/'/g) ? obj.split("',") : obj.split(",");
  774. obj = new Array();
  775. if (newobj)
  776. jQuery.each(newobj,function(index,element) {
  777. element = element.replace("'","");
  778. element = element.replace("'","");
  779. obj.push(element);
  780. })
  781. } else {
  782. var tempw = obj;
  783. if (!jQuery.isArray(obj) ) {
  784. obj = new Array();
  785. obj.push(tempw);
  786. }
  787. }
  788. var tempw = obj[obj.length-1];
  789. if (obj.length<opt.rle) {
  790. for (var i=1;i<=opt.curWinRange;i++) {
  791. obj.push(tempw);
  792. }
  793. }
  794. return obj;
  795. }
  796. /* CREATE SHARP CORNERS */
  797. function sharpCorners(nc,$class, $side,$borderh,$borderv,ncch,bgcol) {
  798. var a = nc.find($class);
  799. a.css('borderWidth',ncch+"px");
  800. a.css($side,(0-ncch)+'px');
  801. a.css($borderh,'0px solid transparent');
  802. a.css($borderv,bgcol);
  803. }
  804. var staticLayerStatus = function(_nc,opt,dir,dontmod) {
  805. var a = -1;
  806. if (_nc.hasClass("tp-static-layer")) {
  807. var s = parseInt(_nc.data('startslide'),0),
  808. e = parseInt(_nc.data('endslide'),0),
  809. pi = opt.c.find('.processing-revslide').index(),
  810. ai = pi!=-1 ? pi : opt.c.find('.active-revslide').index();
  811. ai = ai == -1 ? 0 : ai;
  812. if (dir==="in") {
  813. // IF STATIC ITEM CURRENTLY NOT VISIBLE
  814. if (!_nc.hasClass("rev-static-visbile")) {
  815. // IF ITEM SHOULD BECOME VISIBLE
  816. if ((s<=ai && e>=ai) || (s == ai) || (e == ai)){
  817. if (!dontmod) {
  818. _nc.addClass("rev-static-visbile");
  819. _nc.removeClass("rev-static-hidden");
  820. }
  821. a = 1;
  822. } else
  823. a = 0;
  824. // IF STATIC ITEM ALREADY VISIBLE
  825. } else {
  826. if ((e==ai) || (s > ai) || (e < ai))
  827. a = 2;
  828. else
  829. a = 0;
  830. }
  831. } else {
  832. // IF STATIC ITEM CURRENTLY NOT VISIBLE
  833. if (_nc.hasClass("rev-static-visbile")) {
  834. if ((s > ai) ||
  835. (e < ai)) {
  836. a = 2;
  837. if (!dontmod) {
  838. _nc.removeClass("rev-static-visbile");
  839. _nc.addClass("rev-static-hidden");
  840. }
  841. } else {
  842. a = 0;
  843. }
  844. } else {
  845. a = 2;
  846. }
  847. }
  848. }
  849. return a; // 1 -> In, 2-> Out 0-> Ignore -1-> Not Static
  850. }
  851. var convertHoverStyle = function(t,s) {
  852. if (s===undefined) return t;
  853. s = s.replace("c:","color:");
  854. s = s.replace("bg:","background-color:");
  855. s = s.replace("bw:","border-width:");
  856. s = s.replace("bc:","border-color:");
  857. s = s.replace("br:","borderRadius:");
  858. s = s.replace("bs:","border-style:");
  859. s = s.replace("td:","text-decoration:");
  860. var sp = s.split(";");
  861. if (sp)
  862. jQuery.each(sp,function(key,cont){
  863. var attr = cont.split(":");
  864. if (attr[0].length>0)
  865. t.anim[attr[0]] = attr[1];
  866. })
  867. return t;
  868. }
  869. ////////////////////////////////////////////////
  870. // - GET CSS ATTRIBUTES OF ELEMENT - //
  871. ////////////////////////////////////////////////
  872. var getcssParams = function(nc,level) {
  873. var obj = new Object(),
  874. gp = false,
  875. pc;
  876. // CHECK IF CURRENT ELEMENT SHOULD RESPECT REKURSICVE RESIZES, AND SHOULD OWN THE SAME ATTRIBUTES FROM PARRENT ELEMENT
  877. if (level=="rekursive") {
  878. pc = nc.closest('.tp-caption');
  879. if (pc && nc.css("fontSize") === pc.css("fontSize"))
  880. gp = true;
  881. }
  882. obj.basealign = nc.data('basealign') || "grid";
  883. obj.fontSize = gp ? pc.data('fontsize')===undefined ? parseInt(pc.css('fontSize'),0) || 0 : pc.data('fontsize') : nc.data('fontsize')===undefined ? parseInt(nc.css('fontSize'),0) || 0 : nc.data('fontsize');
  884. obj.fontWeight = gp ? pc.data('fontweight')===undefined ? parseInt(pc.css('fontWeight'),0) || 0 : pc.data('fontweight') : nc.data('fontweight')===undefined ? parseInt(nc.css('fontWeight'),0) || 0 : nc.data('fontweight');
  885. obj.whiteSpace = gp ? pc.data('whitespace')===undefined ? pc.css('whitespace') || "normal" : pc.data('whitespace') : nc.data('whitespace')===undefined ? nc.css('whitespace') || "normal" : nc.data('whitespace');
  886. obj.lineHeight = gp ? pc.data('lineheight')===undefined ? parseInt(pc.css('lineHeight'),0) || 0 : pc.data('lineheight') : nc.data('lineheight')===undefined ? parseInt(nc.css('lineHeight'),0) || 0 : nc.data('lineheight');
  887. obj.letterSpacing = gp ? pc.data('letterspacing')===undefined ? parseFloat(pc.css('letterSpacing'),0) || 0 : pc.data('letterspacing') : nc.data('letterspacing')===undefined ? parseFloat(nc.css('letterSpacing')) || 0 : nc.data('letterspacing');
  888. obj.paddingTop = nc.data('paddingtop')===undefined ? parseInt(nc.css('paddingTop'),0) || 0 : nc.data('paddingtop');
  889. obj.paddingBottom = nc.data('paddingbottom')===undefined ? parseInt(nc.css('paddingBottom'),0) || 0 : nc.data('paddingbottom');
  890. obj.paddingLeft = nc.data('paddingleft')===undefined ? parseInt(nc.css('paddingLeft'),0) || 0 : nc.data('paddingleft');
  891. obj.paddingRight = nc.data('paddingright')===undefined ? parseInt(nc.css('paddingRight'),0) || 0 : nc.data('paddingright');
  892. obj.marginTop = nc.data('margintop')===undefined ? parseInt(nc.css('marginTop'),0) || 0 : nc.data('margintop');
  893. obj.marginBottom = nc.data('marginbottom')===undefined ? parseInt(nc.css('marginBottom'),0) || 0 : nc.data('marginbottom');
  894. obj.marginLeft = nc.data('marginleft')===undefined ? parseInt(nc.css('marginLeft'),0) || 0 : nc.data('marginleft');
  895. obj.marginRight = nc.data('marginright')===undefined ? parseInt(nc.css('marginRight'),0) || 0 : nc.data('marginright');
  896. obj.borderTopWidth = nc.data('bordertopwidth')===undefined ? parseInt(nc.css('borderTopWidth'),0) || 0 : nc.data('bordertopwidth');
  897. obj.borderBottomWidth = nc.data('borderbottomwidth')===undefined ? parseInt(nc.css('borderBottomWidth'),0) || 0 : nc.data('borderbottomwidth');
  898. obj.borderLeftWidth = nc.data('borderleftwidth')===undefined ? parseInt(nc.css('borderLeftWidth'),0) || 0 : nc.data('borderleftwidth');
  899. obj.borderRightWidth = nc.data('borderrightwidth')===undefined ? parseInt(nc.css('borderRightWidth'),0) || 0 : nc.data('borderrightwidth');
  900. if (level!="rekursive") {
  901. obj.color = nc.data('color')===undefined ? "nopredefinedcolor" : nc.data('color');
  902. obj.whiteSpace = gp ? pc.data('whitespace')===undefined ? pc.css('whiteSpace') || "nowrap" : pc.data('whitespace') : nc.data('whitespace')===undefined ? nc.css('whiteSpace') || "nowrap" : nc.data('whitespace');
  903. obj.minWidth = nc.data('width')===undefined ? parseInt(nc.css('minWidth'),0) || 0 : nc.data('width');
  904. obj.minHeight = nc.data('height')===undefined ? parseInt(nc.css('minHeight'),0) || 0 : nc.data('height');
  905. if (nc.data('videowidth')!=undefined && nc.data('videoheight')!=undefined) {
  906. var vwid = nc.data('videowidth'),
  907. vhei = nc.data('videoheight');
  908. vwid = vwid==="100%" ? "none" : vwid;
  909. vhei = vhei==="100%" ? "none" : vhei;
  910. nc.data('width',vwid);
  911. nc.data('height',vhei);
  912. }
  913. obj.maxWidth = nc.data('width')===undefined ? parseInt(nc.css('maxWidth'),0) || "none" : nc.data('width');
  914. obj.maxHeight = nc.data('height')===undefined ? parseInt(nc.css('maxHeight'),0) || "none" : nc.data('height');
  915. obj.wan = nc.data('wan')===undefined ? parseInt(nc.css('-webkit-transition'),0) || "none" : nc.data('wan');
  916. obj.moan = nc.data('moan')===undefined ? parseInt(nc.css('-moz-animation-transition'),0) || "none" : nc.data('moan');
  917. obj.man = nc.data('man')===undefined ? parseInt(nc.css('-ms-animation-transition'),0) || "none" : nc.data('man');
  918. obj.ani = nc.data('ani')===undefined ? parseInt(nc.css('transition'),0) || "none" : nc.data('ani');
  919. }
  920. obj.styleProps = nc.css(["background-color",
  921. "border-top-color",
  922. "border-bottom-color",
  923. "border-right-color",
  924. "border-left-color",
  925. "border-top-style",
  926. "border-bottom-style",
  927. "border-left-style",
  928. "border-right-style",
  929. "border-left-width",
  930. "border-right-width",
  931. "border-bottom-width",
  932. "border-top-width",
  933. // "color",
  934. "text-decoration",
  935. "font-style",
  936. "border-radius"]);
  937. return obj;
  938. }
  939. // READ SINGLE OR ARRAY VALUES OF OBJ CSS ELEMENTS
  940. var setResponsiveCSSValues = function(obj,opt) {
  941. var newobj = new Object();
  942. if (obj)
  943. jQuery.each(obj,function(key,val){
  944. newobj[key] = makeArray(val,opt)[opt.curWinRange] || obj[key];
  945. })
  946. return newobj;
  947. }
  948. var minmaxconvert = function(a,m,r,fr) {
  949. a = jQuery.isNumeric(a) ? (a * m)+"px" : a;
  950. a = a==="full" ? fr : a==="auto" || a==="none" ? r : a;
  951. return a;
  952. }
  953. /////////////////////////////////////////////////////////////////
  954. // - CALCULATE THE RESPONSIVE SIZES OF THE CAPTIONS - //
  955. /////////////////////////////////////////////////////////////////
  956. var calcCaptionResponsive = function(nc,opt,level,responsive) {
  957. var getobj;
  958. if (nc.data('cssobj')===undefined) {
  959. getobj = getcssParams(nc,level);
  960. nc.data('cssobj',getobj);
  961. } else
  962. getobj = nc.data('cssobj');
  963. var obj = setResponsiveCSSValues(getobj,opt);
  964. var bw=opt.bw,
  965. bh=opt.bh;
  966. if (responsive==="off") {
  967. bw=1;
  968. bh=1;
  969. }
  970. // IE8 FIX FOR AUTO LINEHEIGHT
  971. if (obj.lineHeight=="auto") obj.lineHeight = obj.fontSize+4;
  972. if (!nc.hasClass("tp-splitted")) {
  973. nc.css("-webkit-transition", "none");
  974. nc.css("-moz-transition", "none");
  975. nc.css("-ms-transition", "none");
  976. nc.css("transition", "none");
  977. var hashover = nc.data('transform_hover')!==undefined || nc.data('style_hover')!==undefined;
  978. if (hashover) punchgs.TweenLite.set(nc,obj.styleProps);
  979. punchgs.TweenLite.set(nc,{
  980. fontSize: Math.round((obj.fontSize * bw))+"px",
  981. fontWeight: obj.fontWeight,
  982. letterSpacing:Math.floor((obj.letterSpacing * bw))+"px",
  983. paddingTop: Math.round((obj.paddingTop * bh)) + "px",
  984. paddingBottom: Math.round((obj.paddingBottom * bh)) + "px",
  985. paddingLeft: Math.round((obj.paddingLeft* bw)) + "px",
  986. paddingRight: Math.round((obj.paddingRight * bw)) + "px",
  987. marginTop: (obj.marginTop * bh) + "px",
  988. marginBottom: (obj.marginBottom * bh) + "px",
  989. marginLeft: (obj.marginLeft * bw) + "px",
  990. marginRight: (obj.marginRight * bw) + "px",
  991. borderTopWidth: Math.round(obj.borderTopWidth * bh) + "px",
  992. borderBottomWidth: Math.round(obj.borderBottomWidth * bh) + "px",
  993. borderLeftWidth: Math.round(obj.borderLeftWidth * bw) + "px",
  994. borderRightWidth: Math.round(obj.borderRightWidth * bw) + "px",
  995. lineHeight: Math.round(obj.lineHeight * bh) + "px",
  996. overwrite:"auto"});
  997. if (level!="rekursive") {
  998. var winw = obj.basealign =="slide" ? opt.ulw : opt.gridwidth[opt.curWinRange],
  999. winh = obj.basealign =="slide" ? opt.ulh : opt.gridheight[opt.curWinRange],
  1000. maxw = minmaxconvert(obj.maxWidth,bw,"none",winw),
  1001. maxh = minmaxconvert(obj.maxHeight,bh,"none",winh),
  1002. minw = minmaxconvert(obj.minWidth,bw,"0px",winw),
  1003. minh = minmaxconvert(obj.minHeight,bh,"0px",winh);
  1004. punchgs.TweenLite.set(nc,{
  1005. maxWidth:maxw,
  1006. maxHeight:maxh,
  1007. minWidth:minw,
  1008. minHeight:minh,
  1009. whiteSpace:obj.whiteSpace,
  1010. overwrite:"auto"
  1011. });
  1012. if (obj.color!="nopredefinedcolor")
  1013. punchgs.TweenLite.set(nc,{color:obj.color,overwrite:"auto"});
  1014. }
  1015. setTimeout(function() {
  1016. nc.css("-webkit-transition", nc.data('wan'));
  1017. nc.css("-moz-transition", nc.data('moan'));
  1018. nc.css("-ms-transition", nc.data('man'));
  1019. nc.css("transition", nc.data('ani'));
  1020. },30);
  1021. }
  1022. }
  1023. //////////////////////
  1024. // CAPTION LOOPS //
  1025. //////////////////////
  1026. var callCaptionLoops = function(el,factor) {
  1027. // SOME LOOPING ANIMATION ON INTERNAL ELEMENTS
  1028. if (el.hasClass("rs-pendulum")) {
  1029. if (el.data('loop-timeline')==undefined) {
  1030. el.data('loop-timeline',new punchgs.TimelineLite);
  1031. var startdeg = el.data('startdeg')==undefined ? -20 : el.data('startdeg'),
  1032. enddeg = el.data('enddeg')==undefined ? 20 : el.data('enddeg'),
  1033. speed = el.data('speed')==undefined ? 2 : el.data('speed'),
  1034. origin = el.data('origin')==undefined ? "50% 50%" : el.data('origin'),
  1035. easing = el.data('easing')==undefined ? punchgs.Power2.easeInOut : el.data('ease');
  1036. startdeg = startdeg * factor;
  1037. enddeg = enddeg * factor;
  1038. el.data('loop-timeline').append(new punchgs.TweenLite.fromTo(el,speed,{force3D:"auto",rotation:startdeg,transformOrigin:origin},{rotation:enddeg,ease:easing}));
  1039. el.data('loop-timeline').append(new punchgs.TweenLite.fromTo(el,speed,{force3D:"auto",rotation:enddeg,transformOrigin:origin},{rotation:startdeg,ease:easing,onComplete:function() {
  1040. el.data('loop-timeline').restart();
  1041. }}));
  1042. }
  1043. }
  1044. // SOME LOOPING ANIMATION ON INTERNAL ELEMENTS
  1045. if (el.hasClass("rs-rotate")) {
  1046. if (el.data('loop-timeline')==undefined) {
  1047. el.data('loop-timeline',new punchgs.TimelineLite);
  1048. var startdeg = el.data('startdeg')==undefined ? 0 : el.data('startdeg'),
  1049. enddeg = el.data('enddeg')==undefined ? 360 : el.data('enddeg');
  1050. speed = el.data('speed')==undefined ? 2 : el.data('speed'),
  1051. origin = el.data('origin')==undefined ? "50% 50%" : el.data('origin'),
  1052. easing = el.data('easing')==undefined ? punchgs.Power2.easeInOut : el.data('easing');
  1053. startdeg = startdeg * factor;
  1054. enddeg = enddeg * factor;
  1055. el.data('loop-timeline').append(new punchgs.TweenLite.fromTo(el,speed,{force3D:"auto",rotation:startdeg,transformOrigin:origin},{rotation:enddeg,ease:easing,onComplete:function() {
  1056. el.data('loop-timeline').restart();
  1057. }}));
  1058. }
  1059. }
  1060. // SOME LOOPING ANIMATION ON INTERNAL ELEMENTS
  1061. if (el.hasClass("rs-slideloop")) {
  1062. if (el.data('loop-timeline')==undefined) {
  1063. el.data('loop-timeline',new punchgs.TimelineLite);
  1064. var xs = el.data('xs')==undefined ? 0 : el.data('xs'),
  1065. ys = el.data('ys')==undefined ? 0 : el.data('ys'),
  1066. xe = el.data('xe')==undefined ? 0 : el.data('xe'),
  1067. ye = el.data('ye')==undefined ? 0 : el.data('ye'),
  1068. speed = el.data('speed')==undefined ? 2 : el.data('speed'),
  1069. easing = el.data('easing')==undefined ? punchgs.Power2.easeInOut : el.data('easing');
  1070. xs = xs * factor;
  1071. ys = ys * factor;
  1072. xe = xe * factor;
  1073. ye = ye * factor;
  1074. el.data('loop-timeline').append(new punchgs.TweenLite.fromTo(el,speed,{force3D:"auto",x:xs,y:ys},{x:xe,y:ye,ease:easing}));
  1075. el.data('loop-timeline').append(new punchgs.TweenLite.fromTo(el,speed,{force3D:"auto",x:xe,y:ye},{x:xs,y:ys,onComplete:function() {
  1076. el.data('loop-timeline').restart();
  1077. }}));
  1078. }
  1079. }
  1080. // SOME LOOPING ANIMATION ON INTERNAL ELEMENTS
  1081. if (el.hasClass("rs-pulse")) {
  1082. if (el.data('loop-timeline')==undefined) {
  1083. el.data('loop-timeline',new punchgs.TimelineLite);
  1084. var zoomstart = el.data('zoomstart')==undefined ? 0 : el.data('zoomstart'),
  1085. zoomend = el.data('zoomend')==undefined ? 0 : el.data('zoomend'),
  1086. speed = el.data('speed')==undefined ? 2 : el.data('speed'),
  1087. easing = el.data('easing')==undefined ? punchgs.Power2.easeInOut : el.data('easing');
  1088. el.data('loop-timeline').append(new punchgs.TweenLite.fromTo(el,speed,{force3D:"auto",scale:zoomstart},{scale:zoomend,ease:easing}));
  1089. el.data('loop-timeline').append(new punchgs.TweenLite.fromTo(el,speed,{force3D:"auto",scale:zoomend},{scale:zoomstart,onComplete:function() {
  1090. el.data('loop-timeline').restart();
  1091. }}));
  1092. }
  1093. }
  1094. if (el.hasClass("rs-wave")) {
  1095. if (el.data('loop-timeline')==undefined) {
  1096. el.data('loop-timeline',new punchgs.TimelineLite);
  1097. var angle= el.data('angle')==undefined ? 10 : parseInt(el.data('angle'),0),
  1098. radius = el.data('radius')==undefined ? 10 : parseInt(el.data('radius'),0),
  1099. speed = el.data('speed')==undefined ? -20 : el.data('speed'),
  1100. origin = el.data('origin')==undefined ? "50% 50%" : el.data('origin'),
  1101. ors = origin.split(" "),
  1102. oo = new Object();
  1103. if (ors.length>=1) {
  1104. oo.x = ors[0];
  1105. oo.y = ors[1];
  1106. } else {
  1107. oo.x = "50%";
  1108. oo.y = "50%";
  1109. }
  1110. angle = angle*factor;
  1111. radius = radius * factor;
  1112. var yo = (0-el.height()/2) + (radius*(-1+(parseInt(oo.y,0)/100))),
  1113. xo = (el.width())*(-0.5+(parseInt(oo.x,0)/100)),
  1114. angobj= {a:0, ang : angle, element:el, unit:radius, xoffset:xo, yoffset:yo};
  1115. el.data('loop-timeline').append(new punchgs.TweenLite.fromTo(angobj,speed,
  1116. { a:360 },
  1117. { a:0,
  1118. force3D:"auto",
  1119. ease:punchgs.Linear.easeNone,
  1120. onUpdate:function() {
  1121. var rad = angobj.a * (Math.PI / 180);
  1122. punchgs.TweenLite.to(angobj.element,0.1,{force3D:"auto",x:angobj.xoffset+Math.cos(rad) * angobj.unit, y:angobj.yoffset+angobj.unit * (1 - Math.sin(rad))});
  1123. },
  1124. onComplete:function() {
  1125. el.data('loop-timeline').restart();
  1126. }
  1127. }
  1128. ));
  1129. }
  1130. }
  1131. }
  1132. var killCaptionLoops = function(nextcaption) {
  1133. // SOME LOOPING ANIMATION ON INTERNAL ELEMENTS
  1134. nextcaption.find('.rs-pendulum, .rs-slideloop, .rs-pulse, .rs-wave').each(function() {
  1135. var el = jQuery(this);
  1136. if (el.data('loop-timeline')!=undefined) {
  1137. el.data('loop-timeline').pause();
  1138. el.data('loop-timeline',null);
  1139. }
  1140. });
  1141. }
  1142. })(jQuery);