PageRenderTime 71ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 2ms

/js/link.net.js

https://github.com/oligarch777/mobilesoft
JavaScript | 4278 lines | 3900 code | 237 blank | 141 comment | 986 complexity | 23a6e85e0261ac07b25ac9024fd6813a MD5 | raw file
  1. /**
  2. * VERSION: 1.0
  3. * DATE: 2012-09-20
  4. *
  5. * @author: mediacreed, mediacreed.com
  6. **/
  7. /* start GENERAL CUSTOMIZATION PROPERTIES */
  8. var templateBaseURL = "http://localhost/YTS/mobilesoft/mobilesoft/";/*"http://themes.mediacreed.com/html/synergy/"*/
  9. var themeColor = "#008dd3";
  10. var menuActive = true;
  11. var menuHoverActive = true; /* it will change to false if menuActive == true. If 'menuActive'
  12. is false and this true than on hover it will show the menu */
  13. var menuTextOutColor = "#777777";
  14. var customPageStart = true;
  15. var customPageStartURL = "#portfolio.html";
  16. var customPageStartSide = "none";
  17. var customPageStartType = "full_width_gallery";
  18. var phpUrlPath = "php/contact_mobilesoft.php";
  19. var contactFormDemo = false; /* SET IT TO FALSE FOR CONTACT FORM TO WORK */
  20. /* end GENERAL CUSTOMIZATION PROPERTIES */
  21. /* start ready function */
  22. $(document).ready(function(){
  23. readyAndLoad++;
  24. $(window).error(function(msg, url, line){
  25. console.log("error: ", msg, " url: ", url, " line: ", line );
  26. });
  27. if( readyAndLoad == 2 ){ checkIfTouchDevice(); }
  28. });
  29. /* end ready function */
  30. /* start load function */
  31. $(window).load(function(){
  32. readyAndLoad++;
  33. if(templateBaseURL == "http://www.your_domain.com/" || templateBaseURL == "null"){
  34. $("body").empty().css("visibility", "visible").append("<br/><span>Please check the documentation on page 4 on how to change the 'templateBaseURL' path!!!</span>");
  35. return;
  36. }
  37. if( readyAndLoad == 2 ){
  38. checkIfTouchDevice();
  39. }
  40. });
  41. /* end load function */
  42. /* start GENERAL JS PROPERTIES */
  43. var readyAndLoad = 0;
  44. var firstRun = true;
  45. var isOverMenu = false;
  46. var templateMenuW = 0;
  47. var videojsHolder = "";
  48. /* end GENERAL JS PROPERTIES */
  49. /*================= GENERAL TXT NAMES ==========================*/
  50. var t_scrBarV1 = "#module-scrollbar-holder";
  51. var t_scrBarV2 = "#module-scrollbar-holder_v2";
  52. var txt_modCont = "#module-container #module-container-holder";
  53. var touchDevice = 0;
  54. function checkIfTouchDevice(){
  55. touchDevice = !!("ontouchstart" in window) ? 1 : 0;
  56. prepareTemplate();
  57. }
  58. //remove the template loader
  59. function removeTemplateLoader(){
  60. $(".main-template-loader").remove();
  61. var browserVersion = $.browser.version + "";
  62. var documentMode = document.documentMode;
  63. var indexOfChar = browserVersion.indexOf(".");
  64. browserVersion = browserVersion.substring(0, indexOfChar);
  65. if ($.browser.msie && (browserVersion < 8 || ( browserVersion >= 8 && documentMode < 8))){
  66. $("body").empty().css("visibility", "visible");
  67. $("body").append("Your browser is too old for this website. Please upgrade your browser version or experience this website in: Firefox, Chrome, Opera or Safari")
  68. return;
  69. }
  70. if ( ($.browser.msie && ( browserVersion.substr(0,1) > 8 && documentMode > 8 )) || !$.browser.msie ){
  71. if( $("#menu-container").hasClass("shadow-side-all") == false )
  72. $("#menu-container").addClass("shadow-side-all");
  73. }
  74. /*FIRST RUN CONFIGURATION*/
  75. prepareTemplate();
  76. }
  77. /*prepare the settings for the template*/
  78. var templateFirstRun = true;
  79. var templateFirstRunDone = false;
  80. function prepareTemplate(){
  81. if( templateFirstRun == true ){
  82. $("#template-logo").click(function(event){
  83. event.preventDefault();
  84. if( $(this).attr("data-href") != undefined && $(this).attr("data-href") != ""){
  85. window.location.hash = $(this).attr("data-href");
  86. }
  87. else{
  88. window.location.href = templateBaseURL;
  89. }
  90. });
  91. storeMenuArr();
  92. menuListeners();
  93. checkWhatToLoad();
  94. templateFirstRun = false;
  95. }
  96. else{ settingsForScreens(); }
  97. }
  98. /* check what page to load - only on the first run */
  99. function checkWhatToLoad(){
  100. var hrefPath = "";
  101. var url = "";
  102. currModuleType = $("#template-menu").attr("data-current-module-type");
  103. sideType = $("#template-menu").attr("data-side");
  104. url = $("#template-menu").attr("data-href").replace('#','');
  105. prevURL = "#" + url;
  106. if( templateFirstRun == true ){
  107. var checkURL = document.URL;
  108. checkURL = checkURL.replace(templateBaseURL, "");
  109. var hashURL = "";
  110. if(checkURL.indexOf("#") == -1 && checkURL != ""){
  111. if( checkURL == "index.html" || checkURL == "index.htm" ){
  112. checkURL = "";
  113. if( checkURL == "" && customPageStart == true ){
  114. checkURL = customPageStartURL;
  115. checkURL = checkURL.replace(templateBaseURL, "");
  116. }
  117. checkURL = checkURL.replace("#", "");
  118. checkURL = checkURL.substring( checkURL.lastIndexOf("/") + 1);
  119. hashURL = updateMenu(checkURL, prevURL, false, true);
  120. window.location.hash = hashURL;
  121. }
  122. else{
  123. window.location.href = templateBaseURL + checkURL;
  124. }
  125. }
  126. else{
  127. if( checkURL == "" && customPageStart == true ){
  128. checkURL = customPageStartURL;
  129. checkURL = checkURL.replace(templateBaseURL, "");
  130. url = customPageStartURL.replace("#", "");
  131. }else{
  132. checkURL = checkURL.replace("#", "");
  133. checkURL = checkURL.substring( checkURL.lastIndexOf("/") + 1);
  134. checkURL = (checkURL != "" && checkURL != "#") ? checkURL : url;
  135. url = checkURL;
  136. if( checkURL.indexOf("index.html") != -1 || checkURL.indexOf("index.htm") != -1){
  137. checkURL = checkURL.substring( checkURL.lastIndexOf("#") + 1);
  138. }
  139. }
  140. checkURL = checkURL.replace("#", "");
  141. checkURL = checkURL.substring( checkURL.lastIndexOf("/") + 1);
  142. hashURL = updateMenu(checkURL, prevURL, false, true);
  143. window.location.hash = hashURL;
  144. }
  145. }
  146. hrefPath = oldMenuData[3];
  147. hrefPath = (hrefPath == undefined) ? "" : hrefPath;
  148. setMobileMenuOption(oldMenuData[2]);
  149. $("#module-container").empty();
  150. $("#module-container").load( hrefPath + url + ' #module-container > *', firstRunLoaded );
  151. }
  152. /* select the current mobile option */
  153. function setMobileMenuOption( option ){
  154. var i =0;
  155. option = option.replace("#", "");
  156. $("#template-smpartphone-menu select").find("option").each(function(){
  157. var optVal = $(this).attr("value").replace("#", "");
  158. if( optVal == option ) {
  159. $(this).attr("selected","selected");
  160. }
  161. i++;
  162. });
  163. }
  164. /* on template hash change */
  165. function onTemplateHashChange( event, runLoad ){
  166. var url = window.location.hash + "",
  167. oldMenuID = menuOptionID,
  168. oldSubID = submenuOptionID,
  169. disabMenu = true,
  170. tempMenuData = menuData;
  171. url = url.replace("#", "");
  172. url = url.substring( url.lastIndexOf("/") + 1);
  173. updateMenu( url, prevURL, undefined, true);
  174. oldMenuData = tempMenuData;
  175. if( oldMenuID != menuOptionID ){
  176. disabMenu = undefined;
  177. }
  178. menuOptionOut(oldMenuID, oldSubID, disabMenu);
  179. menuData = ( menuOptionsArr[ menuOptionID ][ 1 ] != "null" ) ? menuOptionsArr[ menuOptionID ][ 1 ]: menuOptionsArr[ menuOptionID ][ 6 ][ submenuOptionID ][ 1 ] ;
  180. setMobileMenuOption(menuData[2]);
  181. touchContainer();
  182. urlChanged();
  183. }
  184. /* update menu */
  185. function updateMenu( currentURL, prevURL, sameURLParent, animate ){
  186. currentURL = currentURL.replace("#", "");
  187. prevURL = prevURL.replace("#", "");
  188. var returnURL = "",
  189. i = 0,
  190. j = 0,
  191. tempMenuID = 0,
  192. tempSubmID = 0,
  193. idx = menuOptionsArr.length;
  194. while(idx--){
  195. if( menuOptionsArr[ idx ][ 1 ] != "null" ){
  196. if(currentURL == menuOptionsArr[ idx ][ 1 ][ 2 ]){
  197. returnURL = "#" + menuOptionsArr[ idx ][ 1 ][ 2 ];
  198. setMenuData(menuOptionsArr[ idx ][ 1 ]);
  199. menuOptionID = idx;
  200. submenuOptionID = -1;
  201. if( animate == true ){
  202. menuOptionIn(menuOptionID, submenuOptionID);
  203. }
  204. idx = 0;
  205. }
  206. }
  207. else{
  208. var subMenu = menuOptionsArr[ idx ][ 6 ];
  209. var subLength = subMenu.length;
  210. while( subLength-- ){
  211. if( currentURL == subMenu[ subLength ][ 1 ][ 2 ]){
  212. returnURL = subMenu[ subLength ][ 0 ];
  213. setMenuData(subMenu[ subLength ][ 1 ]);
  214. menuOptionID = idx;
  215. submenuOptionID = subLength;
  216. if( animate == true ){
  217. menuOptionIn(menuOptionID, submenuOptionID);
  218. }
  219. idx = 0;
  220. }
  221. }
  222. }
  223. }
  224. return returnURL;
  225. }
  226. /* on first run loaded html page */
  227. function firstRunLoaded(response, status, xhr){
  228. $(window).bind('hashchange', onTemplateHashChange);
  229. switch ( status ){
  230. case "error":console.log( "Error loading the INDEX page: " + response );
  231. break;
  232. case "success": TweenMax.to($(".main-template-loader"), .3, { css:{opacity: "0"}, ease:Sine.easeOut, onComplete: removeTemplateLoader });
  233. break;
  234. }
  235. }
  236. /* menu width */
  237. function getMenuWidth(){
  238. return $("#menu-container").width();
  239. }
  240. /* menu height */
  241. function getMenuHeight(){
  242. return $("#menu-container").height();
  243. }
  244. /* settings for screen resolutions */
  245. function settingsForScreens(){
  246. $("body").css("visibility", "visible" );
  247. var menuWidth = parseInt( $("#menu-container .menu-content-holder").css("width"), 10 );
  248. var menuHider = parseInt( $("#menu-container #menu-hider").width(), 10 );
  249. var menuHiderIcon = parseInt( $("#menu-container #menu-hider #menu-hider-icon").width(), 10 );
  250. var menuHeight = parseInt( $("#menu-container").css("height"), 10 );
  251. var menuHiderH = parseInt( $("#menu-container #menu-hider").height(), 10 );
  252. var menuHiderIconH = parseInt( $("#menu-container #menu-hider #menu-hider-icon").height(), 10 );
  253. templateMenuW = menuWidth + menuHider;
  254. $("#menu-hider-icon").click(menuHideClick);
  255. $("#module-container").css( "width", ($(window).width() - templateMenuW) + "px" );
  256. if( $(window).width() > 767){
  257. $("#menu-container").css('left', -(menuWidth + menuHider + menuHiderIcon) + 'px');
  258. $("#menu-container").css( 'visibility', 'visible' );
  259. $("#menu-hider").css( 'display', 'inline' );
  260. $("#menu-hider").css( 'visibility', 'visible' );
  261. /*start-up animation*/
  262. $("#module-container").css( "opacity", 1 );
  263. $("#module-container").css( "left", menuWidth + menuHider + "px" );
  264. $("footer").css( 'display', 'inline' );
  265. TweenMax.to( $("#menu-container"), .4, { css:{left: "0px"}, ease:Sine.easeInOut, delay: 0.5, onComplete: endStartupAnimation });
  266. /*end start-up animation*/
  267. }
  268. if( $(window).width() <= 767 ){
  269. templateMenuW = 0;
  270. var containerH = $(window).height() - (menuHeight + menuHiderH);
  271. $("#menu-container").css("left", "0px");
  272. $("#menu-container").css("top", -(menuHeight + menuHiderH + menuHiderIconH) + "px");
  273. $("#menu-container").css( "visibility", "visible" );
  274. $("#menu-hider").css( "display", "inline" );
  275. $("#menu-hider").css( "visibility", "visible" );
  276. /*start-up animation*/
  277. $("#module-container").css( "opacity", "1" );
  278. $("#module-container").css( "left", "0px" );
  279. $("#module-container").css( "top", (menuHeight + menuHiderH) + "px" );
  280. $("#module-container").css( "height", containerH );
  281. TweenMax.to( $("#menu-container"), .4, { css:{top: "0px"}, ease:Sine.easeInOut, delay: 0.5, onComplete: endStartupAnimation });
  282. /*end start-up animation*/
  283. }
  284. $("#template-smpartphone-menu select").change(
  285. function(){
  286. if( $(this).val() != "#"){
  287. var hashURL = updateMenu( $(this).val(), prevURL, undefined, false);
  288. window.location.hash = hashURL;
  289. }
  290. });
  291. /*
  292. if( touchDevice == 1){
  293. $("#theme-panel").css("display", "none");
  294. $("#console-log").css("display", "inline");
  295. $("#console-log").css("left", "300px");
  296. $("#console-log").css("top", "10px")
  297. }*/
  298. }
  299. var delayInterval = "";
  300. function endStartupAnimation(){
  301. templateFirstRunDone = true;
  302. delayInterval = setInterval(function()
  303. {
  304. showModule();
  305. clearInterval( delayInterval );
  306. }, 200);
  307. }
  308. /*end module start*/
  309. function endModuleStart(){
  310. }
  311. /*menu hide click*/
  312. function menuHideClick(){
  313. var winW = $(window).width(),
  314. winH = $(window).height();
  315. if( menuActive == true ){
  316. menuActive = false;
  317. alwaysUpdate();
  318. if( winW >= 768 ){
  319. var menuHider = ($("#menu-hider").length > 0 ) ? parseInt($("#menu-hider").width(), 10) : 0,
  320. menuWidth = parseInt( $("#menu-container").css("width"), 10 ) - menuHider,
  321. menuVal = 0;
  322. TweenMax.to( $("#template-wrapper"), .4, { css:{left: -(menuWidth ) + "px"}, ease:Sine.easeInOut });
  323. TweenMax.to( $("#menu-container"), .4, { css:{left: menuVal + "px"}, ease:Sine.easeInOut, onComplete:function()
  324. {if(touchDevice == 0)activateHoverMenu();}
  325. });
  326. }
  327. else{
  328. var menuHiderH = parseInt( $("#menu-container #menu-hider").height(), 10 ),
  329. menuHeight = parseInt( $("#menu-container").css("height"), 10 ) - menuHiderH,
  330. menuVal = 0;
  331. TweenMax.to( $("#template-wrapper"), .4, { css:{top: -(menuHeight ) + "px"}, ease:Sine.easeInOut });
  332. TweenMax.to( $("#menu-container"), .4, { css:{top: menuVal + "px"}, ease:Sine.easeInOut, onComplete:function()
  333. {if(touchDevice == 0)activateHoverMenu();}
  334. });
  335. }
  336. }
  337. else{
  338. if(touchDevice == 0)disableHoverMenu();
  339. menuActive = true;
  340. isOverMenu = false;
  341. alwaysUpdate();
  342. TweenMax.to( $("#template-wrapper"), .4, { css:{left: "0px", top: "0px"}, ease:Sine.easeInOut });
  343. TweenMax.to( $("#menu-container"), .4, { css:{left: "0px"}, top: "0px", ease:Sine.easeInOut });
  344. }
  345. }
  346. /* activate hover menu */
  347. function activateHoverMenu(){
  348. $("#menu-container").bind( "mouseenter", overMenu );
  349. $("#menu-hider-icon").bind( "mouseenter", menuHiderOver );
  350. $("#menu-hider-icon").bind( "mouseleave", menuHiderOver );
  351. $("#menu-container").bind( "mouseleave", outMenu );
  352. }
  353. /* menu hider over */
  354. function menuHiderOver(event){
  355. event.stopPropagation();
  356. }
  357. /* disable hover menu */
  358. function disableHoverMenu(){
  359. $("#menu-container").unbind( "mouseenter", overMenu );
  360. $("#menu-hider-icon").unbind( "mouseenter", menuHiderOver );
  361. $("#menu-hider-icon").unbind( "mouseleave", menuHiderOver );
  362. $("#menu-container").unbind( "mouseleave", outMenu );
  363. }
  364. /* over menu */
  365. function overMenu(){
  366. if( menuActive == true) return;
  367. isOverMenu = true;
  368. TweenMax.to( $("#template-wrapper"), .4, { css:{left: "0px", top:"0px"}, ease:Sine.easeInOut });
  369. TweenMax.to( $("#menu-container"), .4, { css:{left: "0px", top:"0px"}, ease:Sine.easeInOut });
  370. alwaysUpdate();
  371. }
  372. /* out menu */
  373. function outMenu(){
  374. if( menuActive == true) return;
  375. isOverMenu = false;
  376. var winW = $(window).width(),
  377. winH = $(window).height();
  378. if(winW >= 768){
  379. var menuWidth = parseInt( $("#menu-container").css("width"), 10 ) - parseInt($("#menu-hider").width(), 10),
  380. menuVal = 0;
  381. TweenMax.to( $("#template-wrapper"), .4, { css:{left: -(menuWidth ) + "px", top:"0px"}, ease:Sine.easeInOut });
  382. TweenMax.to( $("#menu-container"), .4, { css:{left: menuVal + "px", top:"0px"}, ease:Sine.easeInOut });
  383. }else{
  384. var menuHiderH = parseInt( $("#menu-container #menu-hider").height(), 10 ),
  385. menuHeight = parseInt( $("#menu-container").css("height"), 10 ) - menuHiderH,
  386. menuVal = 0;
  387. TweenMax.to( $("#template-wrapper"), .4, { css:{top: -(menuHeight ) + "px", left: "0px"}, ease:Sine.easeInOut });
  388. TweenMax.to( $("#menu-container"), .4, { css:{top: menuVal + "px", left: "0px"}, ease:Sine.easeInOut, onComplete:function()
  389. {if(touchDevice == 0)activateHoverMenu();}
  390. });
  391. }
  392. alwaysUpdate()
  393. }
  394. /* always update */
  395. function alwaysUpdate(){
  396. if( currentSlide != null )resizeImage(currentSlide, true);/* ONLY IF SLIDESHOW ACTIVE */
  397. if( $showModuleBackground != null )resizeImage( $showModuleBackground, true );/*BACKGROUND CHECK*/
  398. var winW = $(window).width();
  399. var winH = $(window).height();
  400. var newModContW = winW - get_OffsetWidth();
  401. var newModContH = winH;
  402. var cModuleType = $("#template-menu").attr("data-current-module-type")
  403. if( winW < 768 ){
  404. var menuHiderH = parseInt( $("#menu-container #menu-hider").height(), 10 ),
  405. menuHeight = winH - menuHiderH;
  406. newModContH = menuHeight;
  407. }
  408. TweenMax.to( $("#module-container"), .4, { css:{width: newModContW + "px", height: newModContH + "px"}, ease:Sine.easeInOut });
  409. if( $("#module-container-old") != null && $("#module-container-old").length > 0 ){
  410. if($("#module-container-old #module-background-holder").length > 0){resizeImage($("#module-container-old #module-background-holder"), true);}
  411. if($("#module-container-old #slide-current").length > 0){resizeImage($("#module-container-old #slide-current"), true);}
  412. }
  413. var thumbsHolder = $('#slideshow-thumbs');
  414. if( thumbsHolder.length > 0){
  415. var val = (newModContW - thumbsHolder.width() )* .5;
  416. TweenMax.to( thumbsHolder, .4, {css:{marginLeft: val}, easing:Sine.easeOut});
  417. }
  418. var slideHolder = $("#slideshow .slideshow-slide", $("#module-container"));
  419. if( slideHolder.length > 0 ){
  420. $("#slideshow-captions", slideHolder ).each(function(){
  421. $(this ).css("top", (newModContH * 0.3) + "px");
  422. TweenMax.to( $(this ), .4, { css:{width: (newModContW * 0.5) + "px"}, ease:Sine.easeInOut });
  423. });
  424. }
  425. var moduleContainerHolder = $(txt_modCont);
  426. var modulePosition = moduleContainerHolder.attr("data-id");
  427. if( modulePosition == "module-position-bc" || modulePosition == "module-position-cc" ){
  428. if( moduleContainerHolder.length > 0 ){
  429. var value = Math.round(( newModContW - $(":first", moduleContainerHolder).width() ) * 0.5 );
  430. TweenMax.to( moduleContainerHolder, .4, {css:{left: value}, easing:Sine.easeOut});
  431. }
  432. }
  433. var fullWidGalModule = $("#module-full-width-gallery");
  434. if( fullWidGalModule.length > 0 ){
  435. if( initialThumbW <= 0)
  436. return;
  437. moduleUpdate_full_width_gallery();
  438. }
  439. var contactModule = $("#module-contact #module-contact-holder");
  440. if( contactModule.length > 0 ){
  441. moduleUpdate_contact();
  442. TweenMax.to( contactModule, .4, {css:{left: (newModContW - contactModule.width())*.5}, easing:Sine.easeOut});
  443. }
  444. var fullWidModule = $("#module-full-width");
  445. if( fullWidModule.length > 0 ){
  446. moduleUpdate_full_width( true );
  447. }
  448. var fullscreenVideo = $("#module-fullscreen-video");
  449. if( fullscreenVideo.length > 0 ){
  450. moduleUpdate_fullscreen_video( true )
  451. }
  452. if( cModuleType == "text_page"){
  453. moduleUpdate_text_page();
  454. }
  455. }
  456. /*----------------- start showTemplate --------------------*/
  457. var $showModuleBackground = null;
  458. var $showModuleBackgroundSolid = null;
  459. var showDone = false;
  460. function showModule(){
  461. if( templateFirstRunDone == false ){return;}
  462. if( moduleList != null ){
  463. moduleList.destroy();
  464. moduleList = null;
  465. }
  466. if( $("#template-menu").attr("data-current-module-type") == "slideshow" ){
  467. if(firstMediaLoaded == false ){return;}
  468. firstMediaLoaded = false;
  469. TweenMax.to( $("#loading-animation"), .3, { css:{right:"-104px"}, delay: .3, ease:Circ.easeOut });
  470. if( isOtherURL == true ){urlChanged();}
  471. else{
  472. loadedContent = true;
  473. moduleSlideshow();
  474. }
  475. }
  476. else{
  477. $showModuleBackground = $("#module-container #module-background-holder #module-background");
  478. $showModuleBackgroundSolid = $("#module-container #module-background-holder div");
  479. showDone = true;
  480. if( $showModuleBackground != null && $showModuleBackground.length > 0 ){
  481. if( backLoaded == true){
  482. showDone = true;
  483. animateModuleBackground();
  484. }
  485. }
  486. else if( $showModuleBackgroundSolid != null && $showModuleBackgroundSolid.length > 0 ){
  487. backLoaded = true;
  488. if( backLoaded == true){
  489. showDone = true;
  490. $showModuleBackground = null;
  491. $showModuleBackgroundSolid.css('display', 'inline').css("opacity", "0").css("visibility", "visible");
  492. TweenMax.to( $showModuleBackgroundSolid, .4, { css:{opacity:"1"}, delay: .4, ease:Sine.easeOut, onComplete:
  493. function(){
  494. if( isOtherURL == true ){urlChanged();}
  495. else{startModule();}
  496. }
  497. });
  498. TweenMax.to( $("#loading-animation"), .3, { css:{right:"-104px"}, ease:Circ.easeOut });
  499. }
  500. }
  501. else{
  502. $showModuleBackground = null;
  503. backLoaded = false;
  504. if( isOtherURL == true ){urlChanged();}
  505. else{TweenMax.to( $("#loading-animation"), .3, { css:{right:"-104px"}, delay: .3, ease:Circ.easeOut, onComplete: startModule });}
  506. }
  507. }
  508. }
  509. var backLoaded = false;
  510. /* animate module background */
  511. function animateModuleBackground(){
  512. backLoaded = true;
  513. if( showDone == true ){
  514. showDone = false;
  515. backLoaded = false;
  516. TweenMax.to( $("#loading-animation"), .3, { css:{right:"-104px"}, delay: .3, ease:Circ.easeOut, onComplete:
  517. function(){
  518. if( isOtherURL == true ){urlChanged();}
  519. else{hideAnimationCompleted();}
  520. }
  521. });
  522. }
  523. }
  524. /* hide animation completed */
  525. function hideAnimationCompleted(){
  526. $showModuleBackground = $("#module-container #module-background");
  527. if( $showModuleBackground.length > 0 ){
  528. resizeImage( $showModuleBackground );
  529. $showModuleBackground.css('display', 'inline').css("opacity", "0").css("visibility", "visible").css("left", (- 60) + "px");
  530. TweenMax.to( $showModuleBackground, .6, { css:{opacity:"1", left: "0px" }, ease:Circ.easeOut, onComplete:
  531. function(){
  532. if( isOtherURL == true ){urlChanged();}
  533. else{startModule();}
  534. }
  535. });
  536. }
  537. }
  538. var endModuleFunction = null;
  539. var endPreviousModule = false;
  540. var previousModuleType = "";
  541. /* start module */
  542. function startModule(){
  543. loadedContent = true;
  544. var moduleType = $("#template-menu").attr("data-current-module-type");
  545. if( menuData[2] != oldMenuData[2] && menuData[2] != undefined ){
  546. clearCustomInterval( showModuleInterval );
  547. urlChanged();
  548. return;
  549. }
  550. previousModuleType = moduleType;
  551. endShowPage();
  552. templateCollectGarbage();
  553. switch( moduleType ){
  554. case "slideshow": moduleSlideshow();
  555. break;
  556. case "home2": moduleHome2();
  557. break;
  558. case "home3": moduleHome3();
  559. break;
  560. case "banner": moduleBanner();
  561. break;
  562. case "text_page": moduleTextPage();
  563. break;
  564. case "news": moduleNews();
  565. break;
  566. case "contact": moduleContact();
  567. break;
  568. case "showreel": moduleShowreel();
  569. break;
  570. case "gallery": moduleGallery();
  571. break;
  572. case "full_width": moduleFullWidth();
  573. break;
  574. case "full_width_gallery": moduleFullWidthGallery();
  575. break;
  576. case "page_columns": modulePageColumns();
  577. break;
  578. case "fullscreen_video": moduleFullscreenVideo();
  579. break;
  580. case "pricing_tables": modulePricingTables();
  581. break;
  582. }
  583. }
  584. /* end show page */
  585. function endShowPage(){
  586. if( firstRun == true ){
  587. firstRun = false;
  588. /*endModuleStart();*/
  589. }
  590. if( $("#module-container-old").length > 0 ){
  591. $("body").find("#module-container-old").each( function(){ $(this).empty().remove(); });
  592. }
  593. }
  594. /*----------------- end showTemplate ----------------------*/
  595. /*----------------- start Modules Methods -----------------*/
  596. /*================= SLIDESHOW =============================*/
  597. var slideshowLimit = 0;
  598. var slideshowCurrID = 0;
  599. var slideshowPrevID = 0;
  600. var oldSlide = '';
  601. var slidesArray = new Array();
  602. var thumbsList = null;
  603. var currentSlide = null;
  604. var slideshowAutoPlay = false;
  605. var timerSec = 5;
  606. var timerSlideshow = null;
  607. var firstMediaLoaded = false;
  608. function moduleSlideshow(){
  609. slideshowCurrID = 0;
  610. slideshowPrevID = 0;
  611. currentSlide = $("#slide-current");
  612. currentSlide.attr("style", "display:list-item; visibility: visible; left:" + (-60) + "px;");
  613. resizeImage( currentSlide );
  614. currentSlide.css( "opacity", "0");
  615. storeAllSlides();
  616. $("#module-container").css( 'visibility', 'visible' );
  617. TweenMax.to( currentSlide, .6, { css:{opacity:"1", left: "0px" }, ease:Circ.easeOut, onComplete: slideshowShowThumbs });
  618. }
  619. function onFirstMediaLoaded() {
  620. firstMediaLoaded = true;
  621. showModule();
  622. $("#slide-current").attr("onload", "");
  623. }
  624. function storeAllSlides(){
  625. var i = 0;
  626. $("#slideshow").children().each(function() {
  627. slidesArray[ i ] = new Array();
  628. if( i != 0){
  629. var imgSrc = $('#slide-src', this);
  630. var imgTag = '<img src="'+ imgSrc.attr("data-src") + '" alt="" />';
  631. imgSrc.after(imgTag).remove();
  632. }
  633. slidesArray[ i ][ 0 ] = $('img', this);
  634. var captions = new Array();
  635. var captionsW = new Array();
  636. var j = 0;
  637. $('#slideshow-captions', this ).css("top", ($(window).height() * 0.3) + "px");
  638. $('#slideshow-captions', this ).css("left", ($("#module-container").width() * 0.5) + "px");
  639. $('#slideshow-captions', this ).children().each(function(){
  640. captions[ j ] = $(this);
  641. captionsW[ j ] = $(this).width();
  642. j++;
  643. });
  644. slidesArray[ i ][ 1 ] = captions;
  645. slidesArray[ i ][ 2 ] = captionsW;
  646. i++;
  647. });
  648. slideshowLimit = i++;
  649. if( slidesArray[ 0 ][ 1 ].length != 0 )captionAvailable = true;
  650. currentThumb = $('#slideshow-thumbs-container .slideshow-thumb-holder').slice( 0, 1);
  651. if( currentThumb.hasClass( 'thumb-selected' ) == false ){
  652. $(currentThumb).addClass( 'thumb-selected' );
  653. $("#thumb-image-hover", currentThumb).removeClass().attr("style", "left: 0px; top: 0px;");
  654. $("img", $(currentThumb)).attr("style", "border-color:" + themeColor + ";");
  655. }
  656. }
  657. function startTimer(){
  658. if( timerSlideshow == null ){
  659. timerSlideshow = $.timer(checkSlideshowTimer);
  660. timerSlideshow.set({ time : timerSec * 1000, autostart : false });
  661. }
  662. }
  663. function checkSlideshowTimer(){
  664. timerSlideshow.stop();
  665. if( slideshowCurrID < slideshowLimit-1 ){
  666. slideshowPrevID = slideshowCurrID;
  667. slideshowCurrID++;
  668. }
  669. else{
  670. slideshowPrevID = slideshowCurrID;
  671. slideshowCurrID = 0;
  672. }
  673. var spanEmpty = document.getElementById("slideshow-thumbs-counter").getElementsByTagName("span");
  674. $(spanEmpty).empty().append( (slideshowCurrID+1) + '/' + total);
  675. stopOrHidePrevCaptions();
  676. }
  677. function stopSlideshowTimer(){ timerSlideshow.stop(); }
  678. function deleteSlideshowTimer(){
  679. if( timerSlideshow != null ){
  680. timerSlideshow.stop();
  681. timerSlideshow = null;
  682. }
  683. }
  684. /* END SHOW PAGE WHEN SLIDESHOW MODULE IS NEXT */
  685. function slideshowShowThumbs(){
  686. endShowPage();
  687. if( thumbsList != null ){
  688. thumbsList.destroy();
  689. thumbsList = null;
  690. }
  691. if(touchDevice == 0){
  692. thumbsList = $("#slideshow-thumbs-content").McCustomList({ scrollDirection: "horizontal", scrollType: "linear" });
  693. thumbsList.setupList({
  694. scrollContainer: $('#slideshow-thumbs-container'),
  695. mouseWheelSupport: "yes",
  696. buttonsSupport: "no",
  697. draggerContainer: null,
  698. draggerScroll: null,
  699. totalMinusSize: 0,
  700. scrollSpeed: 112,
  701. offsetSize: -4, /* this is the margin right of the thumbs. On the last thumbs we have this margin */
  702. horizFixHolder: $('.horizontal-fix-slideshow-thumbs')
  703. });
  704. $("#slideshow-thumbs-container").find(".slideshow-thumb-holder").hover(
  705. function(event) {
  706. if( $(this).hasClass( 'thumb-selected' ) == false )
  707. {
  708. customHoverAnimation( "over", event, $(this), $("#thumb-image-hover", this) );
  709. TweenMax.to( $("img", this), .6, { css:{borderColor: themeColor}, ease:Circ.easeOut });
  710. }
  711. },
  712. function(event) {
  713. var color = '#ffffff';
  714. if( $(this).hasClass( 'thumb-selected' ) == false )
  715. {
  716. customHoverAnimation( "out", event, $(this), $("#thumb-image-hover", this) );
  717. TweenMax.to( $("img", this), .6, { css:{borderColor: color}, ease:Circ.easeOut });
  718. }
  719. }
  720. );
  721. var instanceArr = $(".slideshow-thumbs-arrow-backward .slideshow-thumbs-arrow-backg");
  722. var initOpacity = instanceArr.css("opacity");
  723. var initBackColor = rgb2hex( instanceArr.css("background-color") );
  724. var bothArrows = $(".slideshow-thumbs-arrow-backward, .slideshow-thumbs-arrow-forward");
  725. var thumbArrBack = $("#slideshow-thumbs-holder .slideshow-thumbs-arrow-backward");
  726. var thumbArrForw = $("#slideshow-thumbs-holder .slideshow-thumbs-arrow-forward");
  727. bothArrows.unbind('mouseenter mouseleave');
  728. bothArrows.hover(
  729. function() {
  730. TweenMax.to( $(".slideshow-thumbs-arrow-backg", this), 0.3, {css:{opacity: "1", backgroundColor: themeColor }, easing:Sine.easeOut });
  731. },
  732. function() {
  733. TweenMax.to( $(".slideshow-thumbs-arrow-backg", this), 0.3, {css:{opacity: initOpacity, backgroundColor: initBackColor}, easing:Sine.easeOut });
  734. }
  735. );
  736. thumbArrBack.unbind("click");thumbArrForw.unbind("click");
  737. thumbArrForw.click(function() {
  738. if( thumbsList != null )thumbsList.listAutoScroll(-1);
  739. });
  740. thumbArrBack.click(function(){
  741. if( thumbsList != null )thumbsList.listAutoScroll(1);
  742. });
  743. }
  744. else{
  745. if( touchDevice == 1 ){
  746. var thumbArrBack = $("#slideshow-thumbs-holder .slideshow-thumbs-arrow-backward");
  747. var thumbArrForw = $("#slideshow-thumbs-holder .slideshow-thumbs-arrow-forward");
  748. thumbArrBack.css("display", "none");
  749. thumbArrForw.css("display", "none");
  750. }
  751. }
  752. var total = slidesArray.length;
  753. var spanEmpty = document.getElementById("slideshow-thumbs-counter").getElementsByTagName("span");
  754. $(spanEmpty).empty().append( (slideshowCurrID+1) + '/' + total);
  755. /*'[id^="matchItem_"]' "#slideshow-thumb-holder" //'div[id^="matchItem_"]'*/
  756. var slideshowThumbsCont = $("#slideshow-thumbs-container .slideshow-thumb-holder");
  757. slideshowThumbsCont.click(function() {
  758. var index = slideshowThumbsCont.index( this );
  759. if( slideshowCurrID == index ) return;
  760. slideshowPrevID = slideshowCurrID;
  761. slideshowCurrID = index;
  762. if(timerSlideshow != null )timerSlideshow.stop();
  763. $(spanEmpty).empty().append( (index+1) + '/' + total);
  764. changeThumbsSelection( this );
  765. stopOrHidePrevCaptions();
  766. });
  767. var thumbsHolder = $('#slideshow-thumbs');
  768. var val = -Math.abs(thumbsHolder.width() - get_OffsetWidth()) / 2;
  769. thumbsHolder.attr("style", "margin-left:" + val + "px; bottom: -84px; visibility: visible;");
  770. if(touchDevice == 1){
  771. $('.horizontal-fix-slideshow-thumbs').css( "width", 999999 );
  772. $('#slideshow-thumbs-container').css("width", $('#slideshow-thumbs-container').width() );
  773. $('.horizontal-fix-slideshow-thumbs').css("width", '');
  774. $("#slideshow-thumbs-content").css("overflow", "auto");
  775. $("#slideshow-thumbs-content").css("-webkit-overflow-scrolling", "touch");
  776. }
  777. startTimer();
  778. initialThumbContW = $("#slideshow-thumbs-content").width();
  779. moduleUpdate_slideshow();
  780. TweenMax.to( thumbsHolder, .6, { css:{bottom:"4px"}, delay:0.6, ease:Circ.easeOut, onComplete: checkCaption });
  781. }
  782. var initialThumbContW = 0;
  783. function changeThumbsSelection( cThumb ) {
  784. oldThumb = $('#slideshow-thumbs-container .thumb-selected');
  785. var color = "#ffffff";
  786. if( oldThumb.length > 0 ){
  787. oldThumb.removeClass('thumb-selected');
  788. TweenMax.to( $("#thumb-image-hover", oldThumb), .3, { css:{ left:"-100%", top: "0%"}, ease:Sine.easeInOut});
  789. TweenMax.to( $('img', oldThumb), .6, { css:{borderColor: color}, ease:Circ.easeOut });
  790. }
  791. currentThumb = $(cThumb);
  792. if( currentThumb.hasClass( 'thumb-selected' ) == false ){
  793. currentThumb.addClass('thumb-selected');
  794. TweenMax.to( $("#thumb-image-hover", currentThumb), .3, { css:{ left:"0", top: "0%"}, ease:Sine.easeInOut });
  795. TweenMax.to( $('img', currentThumb), .6, { css:{borderColor: themeColor}, ease:Circ.easeOut });
  796. }
  797. }
  798. function changeSlideshowSlides( prevSlideID, currSlideID ){
  799. if( slidesArray[ prevSlideID ][ 0 ].attr('id') == 'slide-current' ){
  800. slidesArray[ prevSlideID ][ 0 ].removeAttr("id");
  801. oldSlide = slidesArray[ prevSlideID ][ 0 ];
  802. oldSlide.css("style", "z-index: 1;");
  803. }
  804. slidesArray[ currSlideID ][ 0 ].attr( "id", "slide-current" );
  805. currentSlide = slidesArray[ currSlideID ][ 0 ];
  806. if(currentSlide.css("style") != undefined)currentSlide.removeAttr('style');
  807. currentSlide.attr("style", "z-index: 2; display:list-item; left: 0px; visibility: visible;");
  808. resizeImage( currentSlide );
  809. currentSlide.css("opacity", "0");
  810. TweenMax.to( currentSlide, .6, { css:{opacity:"1" }, ease:Sine.easeOut, onComplete: completeSlideTransition });
  811. }
  812. function completeSlideTransition(){
  813. var i = 0;
  814. var total = slidesArray.length;
  815. for( i = 0; i < total; i++ ){
  816. if( i != slideshowPrevID && i != slideshowCurrID )slidesArray[ i ][ 0 ].attr("style", "display:none; opacity: 0; visibility: hidden;");
  817. }
  818. if( oldSlide != '' )oldSlide.attr("style", "display:none; opacity: 0; visibility: hidden;");
  819. checkCaption();
  820. }
  821. var showingInProgress = 0;
  822. function checkCaption(){
  823. if( showingInProgress == 1)return;
  824. if( slideshowAutoPlay == true && timerSlideshow != null ){
  825. /*checkSlideshowTimer();*/
  826. timerSlideshow.play(true);
  827. }
  828. if( slidesArray[ slideshowCurrID ][ 1 ].length != 0 ){
  829. showingInProgress = 1;
  830. var i = 0;
  831. var total = slidesArray[ slideshowCurrID ][ 1 ].length;
  832. var windowH = $(window).height();
  833. var windowW = $(window).width();
  834. for( i = 0; i < total; i++ ){
  835. var obj = slidesArray[ slideshowCurrID ][ 1 ][ i ];
  836. obj.css( 'width', '' );
  837. var width = slidesArray[ slideshowCurrID ][ 2 ][ i ] + 10;
  838. var topY = i * 45;
  839. var val = (i == total - 1) ? windowW * .5 : -(width + windowW * .5);
  840. var styleValue = "top:" + topY + "px; left:" + val + "px; display:inline-block; opacity:1;";
  841. obj.attr("style", styleValue);
  842. if( i == total - 1 ){ TweenMax.to( obj, 5, { css:{left: -(width + windowW * .5) +'px'}, ease:SlowMo.ease.config(0.7, 0.96), onComplete:resetShowing }); }
  843. else{ TweenMax.to( obj, 5, { css:{left: windowW * .5 +'px'}, ease:SlowMo.ease.config(0.7, 0.96) }); }
  844. }
  845. }
  846. }
  847. function resetShowing(){
  848. showingInProgress = 0;
  849. if( slidesArray[ slideshowCurrID ][ 1 ].length != 0 ){
  850. var i = 0;
  851. var total = slidesArray[ slideshowCurrID ][ 1 ].length;
  852. for( i = 0; i < total; i++ ){
  853. slidesArray[ slideshowCurrID ][ 1 ][ i ].css("opacity", "0");
  854. }
  855. }
  856. }
  857. function stopOrHidePrevCaptions()
  858. {
  859. var slideHolder = $("#slideshow .slideshow-slide");
  860. if( slideHolder.length > 0 ){
  861. $("#slideshow-captions", slideHolder ).each(function(){
  862. $(this ).css("top", ($(window).height() * 0.3) + "px");
  863. $(this ).css("left", ($("#module-container").width() * 0.5) + "px");
  864. });
  865. }
  866. if( slidesArray[ slideshowPrevID ][ 1 ].length != 0 ){
  867. showingInProgress = 0;
  868. var i = 0;
  869. var total = slidesArray[ slideshowPrevID ][ 2 ].length;
  870. var windowH = $(window).height();
  871. var windowW = $(window).width();
  872. for( i = 0; i < total; i++ ){
  873. var width = slidesArray[ slideshowPrevID ][ 2 ][ i ];
  874. var topY = windowH * .3 + i * 45;
  875. var obj = slidesArray[ slideshowPrevID ][ 1 ][ i ];
  876. if( i == total - 1 ){ TweenMax.to( obj, .2, { css:{left: -(width + windowW * .5) +'px', opacity:"0"}, ease:Sine.easeOut, onComplete: runOtherSlide }); }
  877. else{ TweenMax.to( obj, .2, { css:{left: windowW * .5 +'px', opacity:"0"}, ease:Sine.easeOut }); }
  878. }
  879. }
  880. else{ changeSlideshowSlides( slideshowPrevID, slideshowCurrID); }
  881. }
  882. function runOtherSlide(){ changeSlideshowSlides( slideshowPrevID, slideshowCurrID); }
  883. /*================= HOME 2 ================================*/
  884. var stdCurrIndex = 0;
  885. var stdPrevIndex = 0;
  886. function moduleHome2(){
  887. var textPageInstanceHolder = $( txt_modCont);
  888. var textPageInstance = $( "#module-home-layout2", textPageInstanceHolder);
  889. if( textPageInstance.length <= 0 )return;
  890. moduleUpdate_home2();
  891. var val = parseInt( textPageInstanceHolder.css("left"), 10);
  892. textPageInstanceHolder.attr("style", "left: 100%; visibility: visible;");
  893. TweenMax.to( textPageInstanceHolder, .6, { css:{ left: val }, ease:Circ.easeOut });
  894. var slidesBannArray = [];
  895. var stdBannCont = $("#standard-banner-controls");
  896. var controlPin = $("#control-pin", stdBannCont);
  897. var controlPinArr = [];
  898. var i = 0;
  899. stdBannCont.css("margin-left", -(stdBannCont.width()*.5) );
  900. $("#standard-banner").find("a").each(
  901. function(){
  902. var dataSrc = $("#dataSrc", this);
  903. if(dataSrc. length > 0 ){
  904. var imgTag = '<img src="' + dataSrc.attr("data-src") +'" />';
  905. dataSrc.after( imgTag ).remove();
  906. }
  907. slidesBannArray[ i ] = $(this)
  908. i++;
  909. }
  910. );
  911. i = 0;
  912. stdBannCont.find("#control-pin").each(
  913. function(){
  914. controlPinArr[ i ] = $(this)
  915. i++;
  916. }
  917. );
  918. controlPin.hover(
  919. function(){
  920. if( $(this).hasClass("selected") == false )
  921. TweenMax.to( $(".control-pin-hover", this), .3, {css:{opacity:"1"}, easing:Sine.easeOut});
  922. },
  923. function(){
  924. if( $(this).hasClass("selected") == false )
  925. TweenMax.to( $(".control-pin-hover", this), .3, {css:{opacity:"0"}, easing:Sine.easeOut});
  926. }
  927. );
  928. controlPin.click(function() {
  929. stdPrevIndex = stdCurrIndex;
  930. stdCurrIndex = $(controlPin).index(this);
  931. if( stdCurrIndex == stdPrevIndex )return;
  932. controlPinArr[ stdPrevIndex ].removeClass("selected");
  933. controlPinArr[ stdCurrIndex ].addClass("selected");
  934. TweenMax.to( $(".control-pin-hover", controlPinArr[ stdPrevIndex ]), .3, {css:{opacity:"0"}, easing:Sine.easeOut});
  935. TweenMax.to( $(".control-pin-hover", controlPinArr[ stdCurrIndex ]), .3, {css:{opacity:"1"}, easing:Sine.easeOut});
  936. changeHome2Slides();
  937. });
  938. function changeHome2Slides(){
  939. slidesBannArray[ stdCurrIndex ].attr("class", "selected opacity_0");
  940. TweenMax.to( slidesBannArray[ stdPrevIndex ], .6, {css:{opacity:"0"}, easing:Sine.easeOut, onComplete:
  941. function(){ hideOtherBannerSlides();}
  942. });
  943. TweenMax.to( slidesBannArray[ stdCurrIndex ], .6, {css:{opacity:"1"}, easing:Sine.easeOut});
  944. }
  945. function hideOtherBannerSlides(){
  946. var i = 0;
  947. var t = slidesBannArray.length;
  948. for( i = 0; i < t; i++ ){
  949. if( i != stdCurrIndex )slidesBannArray[ i ].attr("class", "");
  950. }
  951. }
  952. var clients = $(".home-layout-clients a");
  953. if( clients.length > 0 ){
  954. clients.hover(
  955. function(){
  956. TweenMax.to( $(".client-over", this), .6, { css:{opacity: "1"}, easing:Sine.easeOut});
  957. },
  958. function(){
  959. TweenMax.to( $(".client-over", this), .6, { css:{opacity: "0"}, easing:Sine.easeOut});
  960. }
  961. );
  962. }
  963. var contentLi = $(".home-layout2-content ul li");
  964. var baseColor = rgb2hex( $(".layout2-description p", contentLi).css("color") );
  965. if(touchDevice == 0)if(contentLi.length > 0){
  966. contentLi.hover(
  967. function(){
  968. TweenMax.to( $(".layout2-description p", this), .6, { css:{color: themeColor}, easing:Sine.easeOut});
  969. TweenMax.to( $("div:first", this), 0.3, { css:{top: "-5px"}, easing:Sine.easeOut});
  970. },
  971. function(){
  972. TweenMax.to( $(".layout2-description p", this), .6, { css:{color: baseColor}, easing:Sine.easeOut});
  973. TweenMax.to( $("div:first", this), 0.3, { css:{top: "0px"}, easing:Sine.easeOut});
  974. }
  975. );
  976. }
  977. }
  978. function animateBannerHome2( img ){ TweenMax.to( img, 0.4, {css:{opacity:"1"}, easing:Sine.easeOut}); }
  979. /*================= END HOME 2 ============================*/
  980. /*================= HOME 3 ================================*/
  981. var homeInterval = "";
  982. function moduleHome3(){
  983. var textPageInstanceHolder = $( txt_modCont);
  984. var textPageInstance = $( "#module-home-layout3", textPageInstanceHolder);
  985. var modWrapper = $("#module-wrapper", textPageInstance);
  986. if( textPageInstance.length <= 0 )return;
  987. moduleUpdate_home3();
  988. var val = parseInt( textPageInstanceHolder.css("left"), 10);
  989. textPageInstanceHolder.css("left", "100%").css("visibility", "visible");
  990. TweenMax.to( textPageInstanceHolder, .6, { css:{ left: val }, ease:Circ.easeOut });
  991. var homeLayoutVideo = $("#video-wrapper", textPageInstanceHolder);
  992. templateAddMediaVideo( homeLayoutVideo.attr("data-video-type"), homeLayoutVideo, undefined );
  993. $("#home-advertise1, #home-advertise2", textPageInstanceHolder).hover(
  994. function(){
  995. var back = $(".advertise-details", this);
  996. TweenMax.to( back, .3, { css:{ backgroundColor: "#3f3f3f" }, ease:Sine.easeOut });
  997. TweenMax.to( $("span", back), .3, { css:{ color: "#f1f1f1" }, ease:Sine.easeOut });
  998. },
  999. function(){
  1000. var back = $(".advertise-details", this);
  1001. TweenMax.to( back, .3, { css:{ backgroundColor: "#f1f1f1" }, ease:Sine.easeOut });
  1002. TweenMax.to( $("span", back), .3, { css:{ color: "#0c0c0c" }, ease:Sine.easeOut });
  1003. }
  1004. );
  1005. var clients = $(".home-layout-clients a");
  1006. if( clients.length > 0 ){
  1007. clients.hover(
  1008. function(){
  1009. TweenMax.to( $(".client-over", this), .6, { css:{opacity: "1"}, easing:Sine.easeOut});
  1010. },
  1011. function(){
  1012. TweenMax.to( $(".client-over", this), .6, { css:{opacity: "0"}, easing:Sine.easeOut});
  1013. }
  1014. );
  1015. }
  1016. clearCustomInterval( homeInterval );
  1017. homeInterval = setInterval(function(){
  1018. moduleUpdate_home3();
  1019. clearCustomInterval( homeInterval );
  1020. }, 1000);
  1021. }
  1022. /*================= END HOME 3 ============================*/
  1023. var moduleList = null;
  1024. /* customStartPosition - used on news vertical when we close news preview we want to have the list and scrollbar at the positions they were */
  1025. function getElementStyle( elem ){
  1026. var style = "";
  1027. if( elem.length > 0 ){ style = ( elem.attr("style") == undefined ) ? " " : elem.attr("style") + " "; }
  1028. return style;
  1029. }
  1030. var updateInterval = "";
  1031. function moduleUpdate( pMod, pCon, cCon, modSide, anim, noRepos, custStartPos ){
  1032. if( endPreviousModule == true )return;
  1033. var extrH = parseInt( $("#module-container").css("top"), 10 )
  1034. var pModH = getElem_W_H( pMod, "h" ) - extrH;
  1035. var pModW = getElem_W_H( pMod, "w" );
  1036. var pConH = getElem_W_H( pCon, "h" ) - extrH;
  1037. var pConW = getElem_W_H( pMod, "w" );
  1038. var cConH = getElem_W_H( cCon, "h" );
  1039. var cConW = getElem_W_H( cCon, "w" );
  1040. var mPos = $("#module-container-holder").attr("data-id");
  1041. var scrollbar_v1 = $(t_scrBarV1);
  1042. var scrollbar_v2 = $(t_scrBarV2);
  1043. var availScrollbar = (scrollbar_v1.length > 0) ? scrollbar_v1 : scrollbar_v2;
  1044. var winH = $(window).height();
  1045. var winW = $(window).width();
  1046. var menH = getMenuHeight();
  1047. var menuHiderH = ( menuActive == true ) ? parseInt( $("#menu-container").height(), 10 ) : parseInt( $("#menu-container #menu-hider").height(), 10 );
  1048. if( touchDevice == 0 ){
  1049. var totalMinusSize = 0;
  1050. var activScrollbar = availScrollbar.length;
  1051. if( availScrollbar.length > 0){
  1052. if( winW >= 768 ) { availScrollbar.css("height", winH).css("top", "0px"); }
  1053. else{
  1054. availScrollbar.css("height", ( winH - menuHiderH ) + "px");
  1055. totalMinusSize = menH;
  1056. }
  1057. }
  1058. if( pModH >= cConH ){
  1059. if( availScrollbar.length > 0 && availScrollbar.css("display") != "none" ){
  1060. TweenMax.to( availScrollbar, .6, { css:{opacity:"0"}, ease:Quad.easeOut, onComplete:function(){availScrollbar.css("display", "none");} });
  1061. }
  1062. if( moduleList != null ){
  1063. moduleList.destroy();
  1064. moduleList = null;
  1065. }
  1066. if(noRepos == true)return;
  1067. var valTop = pModH - cConH;
  1068. if( modSide == "none"){
  1069. if(mPos != "module-position-bc"){ pCon.parent(pCon).css("top", Math.round( valTop * 0.5 ) + "px" ); }
  1070. else{ pCon.parent(pCon).css("top", Math.round( valTop ) + "px" ); }
  1071. }
  1072. else if( modSide == "height" ){ cCon.css("top", Math.round( valTop * 0.5 ) + "px" ); }
  1073. else if( modSide == "custom" ){
  1074. if(anim == true){ TweenMax.to( cCon, .3, { css:{top: "0px"}, ease:Sine.easeOut }); }
  1075. else{ cCon.css("top", "0px" ); }
  1076. }
  1077. if( mPos == "module-position-bc" || mPos == "module-position-cc" ){
  1078. var value = Math.round( (($("#module-container").width() - pConW) * .5 /*+ get_OffsetWidth()*/) );
  1079. if(anim == true){ TweenMax.to( pMod, .6, { css:{left: value + "px"}, ease:Sine.easeOut }); }
  1080. else{ pMod.css("left", value + "px" ); }
  1081. }
  1082. }
  1083. else{
  1084. if( availScrollbar.length > 0 ){
  1085. switch( modSide ){
  1086. case "none":
  1087. pCon.parent(pCon).css("top", "0px" );
  1088. cCon.parent(cCon).css("top", "0px" );
  1089. break;
  1090. case "height": cCon.css("top", "0px" );
  1091. break;
  1092. }
  1093. TweenMax.killTweensOf(availScrollbar);
  1094. if( availScrollbar.css("display") == "none" ){ availScrollbar.css("opacity", "0").css("display", "inline"); }
  1095. TweenMax.to( availScrollbar, .6, { css:{opacity:"1"}, ease:Quad.easeOut });
  1096. }
  1097. if( moduleList == null ){
  1098. moduleList = pMod.McCustomList({ scrollDirection: "vertical", scrollType: "linear" });
  1099. moduleList.setupList({
  1100. scrollContainer: cCon,
  1101. mouseWheelSupport: "yes",
  1102. buttonsSupport: "no",
  1103. draggerContainer: availScrollbar,
  1104. draggerScroll: $("#module-scrollbar-dragger", availScrollbar),
  1105. totalMinusSize: totalMinusSize,
  1106. scrollSpeed: 100,
  1107. offsetSize: 0,
  1108. horizFixHolder: null,
  1109. customStartPos: custStartPos
  1110. });
  1111. }
  1112. else{ moduleList.updateCustomList( totalMinusSize ); }
  1113. if( mPos == "module-position-bc" || mPos == "module-position-cc" ){
  1114. var value = Math.round( (($("#module-container").width() - pConW) * .5 ) );
  1115. if(mPos == "module-position-bc"){ pCon.parent(pCon).css("top", "0px" ); }
  1116. if(anim == true){ TweenMax.to( pMod, .6, { css:{left: value + "px"}, ease:Sine.easeOut }); }
  1117. else{ pMod.css("left", value + "px" ); }
  1118. }
  1119. }
  1120. }
  1121. else{
  1122. /*remove scrollbar if present and add overflow for touch devices*/
  1123. var valTop = pModH - cConH;
  1124. switch( modSide ){
  1125. case "none":
  1126. if( pModH >= cConH && pCon.length > 0){
  1127. if(mPos != "module-position-bc"){ pCon.parent(pCon).css("top", Math.round( valTop * 0.5 ) + "px" ); }
  1128. else{ pCon.parent(pCon).css("top", Math.round( valTop ) + "px" ); }
  1129. }
  1130. else {pCon.parent(pCon).css("top", "0px" );}
  1131. break;
  1132. case "height":if(cCon.length > 0)cCon.css("top", "0px" );
  1133. break;
  1134. case "width":
  1135. break;
  1136. case "custom":
  1137. if(cCon.length > 0)
  1138. if(anim == true){ TweenMax.to( cCon, .3, { css:{top: "0px"}, ease:Sine.easeOut }); }
  1139. else{ cCon.css("top", "0px" ); }
  1140. break;
  1141. }
  1142. if(cCon.length <= 0 || pCon.length <= 0)return;
  1143. pCon.css("overflow", "").css("-webkit-overflow-scrolling", "");
  1144. clearCustomInterval( updateInterval );
  1145. updateInterval = setInterval(function(){
  1146. pCon.css("overflow", "auto").css("-webkit-overflow-scrolling", "touch");
  1147. clearCustomInterval( updateInterval );
  1148. }, 100);
  1149. if(currModuleType == "news" && previewNewsOpen == true ){ TweenMax.to(pCon, .3, {scrollTop: 0, easing:Sine.easeOut}); }
  1150. if(currModuleType == "page_columns" && columnsPreviewOpen == true ){ TweenMax.to(pCon, .3, {scrollTop: 0, easing:Sine.easeOut}); }
  1151. else if(currModuleType == "page_columns" && columnsPreviewOpen == false ){ pCon.scrollTop( custStartPos ) }
  1152. if( mPos == "module-position-bc" || mPos == "module-position-cc" ){
  1153. if( currModuleType == "text_page" && modSide == "none"){
  1154. $( "#module-text-page", $( txt_modCont)).css( "height", "" );
  1155. }
  1156. if( winH <= pConH && $( "#module-text-page", $( txt_modCont)).length > 0){
  1157. $( "#module-text-page", $( txt_modCont)).css( "height", "" );
  1158. $( "#module-text-page", $( txt_modCont)).css( "height", "100%" );
  1159. }
  1160. var value = Math.round( (($("#module-container").width() - pConW) * .5 /*+ get_OffsetWidth()*/) );
  1161. if(anim == true){ TweenMax.to( pMod, .6, { css:{left: value + "px"}, ease:Sine.easeOut }); }
  1162. else{ pMod.css("left", value + "px" ); }
  1163. }
  1164. }
  1165. }
  1166. function getElem_W_H( elem, type ){
  1167. var val1 = ( elem.length > 0 ) ? elem.height() + parseInt( elem.css("margin-top"), 10) + parseInt( elem.css("margin-bottom"), 10) : 0;
  1168. var val2 = ( elem.length > 0 ) ? elem.width() : 0;
  1169. return (type == "w") ? val2 : val1;
  1170. }
  1171. /*================= TEXT PAGE =============================*/
  1172. function moduleTextPage(){
  1173. var textPageInstanceHolder = $( txt_modCont);
  1174. var textPageInstance = $( "#module-text-page", textPageInstanceHolder);
  1175. var modWrapper = $( "#module-wrapper", textPageInstanceHolder);
  1176. var modulePositionType = textPageInstanceHolder.attr("data-id");
  1177. var moduleWidth = textPageInstanceHolder.width();
  1178. var moduleHeight = textPageInstanceHolder.height();
  1179. moduleEnd = true;
  1180. if( textPageInstance.length <= 0 ) return;
  1181. endModuleFunction = endModuleTextPage;
  1182. switch( modulePositionType ){
  1183. case "module-position-lb":
  1184. break;
  1185. case "module-position-lc":
  1186. var val = ( - moduleWidth) + "px";
  1187. moduleUpdate( textPageInstance, modWrapper, $("div:first", modWrapper), sideType );
  1188. textPageInstanceHolder.attr("style", getElementStyle( textPageInstanceHolder ) + " left:" + val + "; visibility: visible;");
  1189. TweenMax.to( textPageInstanceHolder, .6, { css:{left: "0px" }, ease:Circ.easeInOut, onComplete: moduleUpdate_text_page });/*get_OffsetWidth() +*/
  1190. break;
  1191. case "module-position-bc":
  1192. moduleUpdate( textPageInstanceHolder, modWrapper, $("div:first", modWrapper), sideType );
  1193. var val = parseInt(textPageInstance.css("top"), 10) + "px";
  1194. textPageInstanceHolder.css("top", moduleHeight).css("visibility", "visible");
  1195. TweenMax.to( textPageInstanceHolder, .6, { css:{ top: "0px" }, ease:Circ.easeInOut, onComplete: moduleUpdate_text_page });
  1196. break;
  1197. case "module-position-rc":
  1198. textPageInstanceHolder.css("position", "fixed");
  1199. moduleUpdate( textPageInstance, modWrapper, $("div:first", modWrapper), sideType );
  1200. var val = (- moduleWidth) + "px";
  1201. textPageInstanceHolder.attr("style", getElementStyle( textPageInstanceHolder ) + " position: fixed; right:" + val + "; visibility: visible;");
  1202. TweenMax.to( textPageInstanceHolder, .6, { css:{ right: "0px" }, ease:Circ.easeInOut, onComplete: moduleUpdate_text_page });
  1203. break;
  1204. case "module-position-cc":
  1205. moduleUpdate( textPageInstanceHolder, modWrapper, $("div:first", modWrapper), sideType );
  1206. var val = parseInt( textPageInstanceHolder.css("left"), 10);
  1207. textPageInstanceHolder.attr("style", getElementStyle( textPageInstanceHolder ) + " left: 100%; visibility: visible;");
  1208. TweenMax.to( textPageInstanceHolder, .6, { css:{ left: val }, ease:Circ.easeOut, onComplete: moduleUpdate_text_page });
  1209. break;
  1210. }
  1211. }
  1212. function endModuleTextPage(){
  1213. var textPageInstance = $("#module-container-holder");
  1214. var modulePositionType = textPageInstance.attr("data-id");
  1215. var moduleWidth = textPageInstance.width();
  1216. var moduleHeight = textPageInstance.height();
  1217. endPreviousModule = true;
  1218. switch( modulePositionType ){
  1219. case "module-position-lb":
  1220. break;
  1221. case "module-position-lc":
  1222. var val = (- moduleWidth) + "px";
  1223. TweenMax.to( textPageInstance, .6, { css:{ left: val }, ease:Circ.easeInOut, onComplete: endModuleComplete });
  1224. break;
  1225. case "module-position-bc":
  1226. TweenMax.to( textPageInstance, .6, { css:{ top: moduleHeight + "px" }, ease:Circ.easeInOut, onComplete: endModuleComplete });
  1227. break;
  1228. case "module-position-rc":
  1229. var val = (- moduleWidth) + "px";
  1230. TweenMax.to( textPageInstance, .6, { css:{ right: val }, ease:Circ.easeInOut, onComplete: endModuleComplete });
  1231. break;
  1232. case "module-position-cc":
  1233. var val = $(window).width() + get_OffsetWidth() + "px";
  1234. TweenMax.to( textPageInstance, .6, { css:{ left: val }, ease:Circ.easeInOut, onComplete: endModuleComplete });
  1235. break;
  1236. }
  1237. endModuleFunction = null;
  1238. }
  1239. function endModuleComplete(){ endPreviousModule = false; }
  1240. /*================= NEWS ===================================*/
  1241. var previewNewsOpen = false;
  1242. var previewNewsIndex = 0;
  1243. var totalPreviews = 0;
  1244. var previewNewsMediaParent = "";
  1245. var newsPrevItemArr = "";
  1246. var shortNIV = "news-item-vertical";
  1247. var shortNP = "news-preview"
  1248. var shortNPH = "#module-news-preview-holder";
  1249. var shortNPU = "#news-preview-list";
  1250. var newsPrvH = "";
  1251. var newsPrvU = "";
  1252. function moduleNews(){
  1253. previewNewsOpen = false;
  1254. previewNewsIndex = 0;
  1255. previewNewsMediaParent = "";
  1256. newsPrevItemArr = new Array();
  1257. var textPageInstanceHolder = $( txt_modCont);
  1258. var textPageInstance = $( "#module-news-vertical", textPageInstanceHolder);
  1259. var moduleWidth = textPageInstanceHolder.width();
  1260. var moduleHeight = textPageInstanceHolder.height();
  1261. newsPrvH = $(shortNPH);
  1262. newsPrvU = $(shortNPU);
  1263. moduleUpdate( textPageInstanceHolder, $("#module-news-vertical-holder", textPageInstance), $("#module-news-vertical-holder div:first", textPageInstance), sideType );
  1264. if(touchDevice == 1){
  1265. $("#module-news-vertical-holder").css("overflow", "auto").css("-webkit-overflow-scrolling", "touch");
  1266. newsPrvH.css("overflow", "auto").css("-webkit-overflow-scrolling", "touch");
  1267. }
  1268. var val = ( - moduleWidth) + "px";
  1269. textPageInstanceHolder.attr("style", "left:" + val + "; visibility:visible;");
  1270. TweenMax.to( textPageInstanceHolder, .6, { css:{left: "0px" }, delay:0.1, ease:Circ.easeInOut });
  1271. endModuleFunction = endModuleTextPage;
  1272. moduleEnd = true;
  1273. newsPrvH.css("display", "inline");
  1274. var newsPrevItemMediaArr = new Array();
  1275. $(textPageInstance).find("." + shortNP + "-horizontal-fix").each(function(){
  1276. $(this).css("width", 999999);
  1277. var newsPrevItem = $("ul li",this);
  1278. var i = 0;
  1279. newsPrevItem.each(function(){
  1280. var mediaSrc = $(".media-holder-news-preview", this).attr("data-src");
  1281. newsPrevItemArr[ i ] = $(this);
  1282. newsPrevItemMediaArr[ i ] = mediaSrc;
  1283. i++;
  1284. });
  1285. $("ul", this).css("width", $("ul", this).width()).css("left", moduleWidth);
  1286. $(this).css("width", "");
  1287. });
  1288. newsPrvH.css("display", "");
  1289. var readMoreBtn = $("." + shortNIV + "-read-more", textPageInstance );
  1290. var basicColor = rgb2hex(readMoreBtn.css("background-color"));
  1291. var newsList = $("#module-news-vertical-holder");
  1292. var prevItemW = $("." + shortNP + "-horizontal-fix").width();
  1293. readMoreBtn.hover(
  1294. function(){ TweenMax.to($(this), 0.6, {css:{backgroundColor: themeColor}, easing:Sine.easeOut}); },
  1295. function(){ TweenMax.to($(this), 0.6, {css:{backgroundColor: basicColor}, easing:Sine.easeOut}); }
  1296. );
  1297. var newsPreviewControls = $("#" + shortNP + "-controls");
  1298. var newsPrevItemMargRight = parseInt($("li:first", newsPrvU).css("margin-right"), 10 );
  1299. newsPreviewControls.css("left", moduleWidth );
  1300. var nwsItem = $(".news-item-vertical", textPageInstance );
  1301. var nwsItemTitle = $(".news-item-vertical-title", $(".news-item-vertical:first", textPageInstance) );
  1302. var nwsTitleColor = rgb2hex(nwsItemTitle.css("color"));
  1303. nwsItem.hover(
  1304. function(){
  1305. TweenMax.to( $(".news-item-vertical-title", this), .6, {css:{color: themeColor}, easing:Sine.easeOut});
  1306. },
  1307. function(){
  1308. TweenMax.to( $(".news-item-vertical-title", this), .6, {css:{color: nwsTitleColor}, easing:Sine.easeOut});
  1309. }
  1310. );
  1311. nwsItem.click(function(){
  1312. previewNewsIndex = nwsItem.index(this);
  1313. newsItemClick( previewNewsIndex );
  1314. });
  1315. var newsItemTopPos = 0;
  1316. totalPreviews = newsPrvU.children().length;
  1317. function newsItemClick( index ){
  1318. if( moduleList != null ){
  1319. moduleList.disableList();
  1320. newsItemTopPos = moduleList.currentPosition();
  1321. var ts = $(t_scrBarV1);
  1322. TweenMax.to( ts, .3, {css:{opacity: "0"}, easing:Sine.easeOut, onComplete: function(){ ts.css("display", "none"); } });
  1323. }
  1324. newsPrvH.css("display", "inline");
  1325. var newsListW = $(newsList).width() + $(newsList).position().left + 30;
  1326. var i = 0;
  1327. for( i; i < totalPreviews; i++){
  1328. if( i == index ){ newsPrevItemArr[ i ].css("display", "inline"); }
  1329. else { newsPrevItemArr[ i ].css("display", "none"); }
  1330. }
  1331. $(".news-preview-counter span").empty().append( (index+1) + "/" + totalPreviews );
  1332. TweenMax.to(newsList, .6, {css:{left: - newsListW }, delay:0.1, easing: Sine.easeOut})
  1333. TweenMax.to([newsPrvU, newsPreviewControls], .6, {css:{left: "0px" }, delay:0.1, easing: Sine.easeOut, onComplete:loadNewsVerticalPreview, onCompleteParams:[index]});
  1334. }
  1335. function loadNewsVerticalPreview( index ){
  1336. var scrollValue = index * (prevItemW + newsPrevItemMargRight);
  1337. if( previewNewsOpen == false ){
  1338. previewNewsOpen = true;
  1339. newsPrvU.css("left", -(scrollValue) + "px");
  1340. newsPreviewItemDisplay( "inline" );
  1341. checkScrollBar( previewNewsOpen );
  1342. }
  1343. else{
  1344. $(".news-preview-counter span").empty().append( (index+1) + "/" + totalPreviews );
  1345. TweenMax.to(newsPrvU, 0.6, {css:{left:-scrollValue}, delay:0.1, easing:Sine.easeOut, onComplete: checkScrollBar, onCompleteParams:[previewNewsOpen]});
  1346. }
  1347. }
  1348. function checkScrollBar( previewNewsOpen ){
  1349. enablePreviewClose(true);
  1350. if( moduleList != null){
  1351. moduleList.destroy( false );
  1352. moduleList = null;
  1353. }
  1354. var i = 0;
  1355. for( i; i < totalPreviews; i++){ if( i != previewNewsIndex ){ newsPrevItemArr[ i ].css("display", "none"); } }
  1356. moduleUpdate( textPageInstanceHolder, $("#module-news-preview-holder", textPageInstance), $("#module-news-preview-container", textPageInstance), "custom", 0 );
  1357. previewNewsMediaParent = $(".media-holder-news-preview", newsPrevItemArr[ previewNewsIndex ]);
  1358. if( $("img", previewNewsMediaParent).length <= 0 ){
  1359. previewNewsMediaParent.empty().append('<img width="100%" class="opacity_0" onload="animateNewsPreviewMedia(this)" />');
  1360. $("img", previewNewsMediaParent).attr("src", newsPrevItemMediaArr[ previewNewsIndex ]);
  1361. }
  1362. else{
  1363. if( touchDevice == 1){
  1364. $("#module-news-preview-container", textPageInstance).css("height", "");
  1365. $("#module-news-preview-container", textPageInstance).css("height", $("#module-news-preview-container", textPageInstance).height());
  1366. }
  1367. }
  1368. newsPreviewItemDisplay( "inline" );
  1369. }
  1370. var initBackColor = rgb2hex( $("." + shortNP + "-backward ." + shortNP + "-backg").css("background-color") );
  1371. $("." + shortNP + "-backward, ." + shortNP + "-forward, ." + shortNP + "-close").hover(
  1372. function(){ TweenMax.to( $("." + shortNP + "-backg", this), 0.3, {css:{backgroundColor: themeColor }, easing:Sine.easeOut }); },
  1373. function(){ TweenMax.to( $("." + shortNP + "-backg", this), 0.3, {css:{backgroundColor: initBackColor}, easing:Sine.easeOut }); }
  1374. );
  1375. $("." + shortNP + "-backward, ." + shortNP + "-forward", textPageInstance ).click(
  1376. function(){
  1377. var index = previewNewsIndex;
  1378. if( $(this).hasClass("" + shortNP + "-backward") == true ){
  1379. index--;
  1380. changeNewsPreviewMedia( index );
  1381. }
  1382. else if( $(this).hasClass("" + shortNP + "-forward") == true ){
  1383. index++;
  1384. changeNewsPreviewMedia( index );
  1385. }
  1386. });
  1387. function changeNewsPreviewMedia( index ){
  1388. if( index < 0)index = 0;
  1389. if( index > totalPreviews-1)index = totalPreviews-1;
  1390. if( index == previewNewsIndex)return;
  1391. enablePreviewClose( false )
  1392. previewNewsIndex = index;
  1393. loadNewsVerticalPreview( previewNewsIndex );
  1394. }
  1395. newsPrvU.wipetouch({
  1396. tapToClick: false, /*if user taps the screen, triggers a click event*/
  1397. preventDefault: false,
  1398. wipeLeft: function(result) {
  1399. var index = previewNewsIndex; index++;
  1400. changeNewsPreviewMedia( index )
  1401. },
  1402. wipeRight: function(result) {
  1403. var index = previewNewsIndex; index--;
  1404. changeNewsPreviewMedia( index )
  1405. }
  1406. });
  1407. /*initial close enabled*/
  1408. enablePreviewClose(true);
  1409. function enablePreviewClose( enable ){
  1410. var newsPreviewCloseBtn = $("." + shortNP + "-close", textPageInstance);
  1411. newsPreviewCloseBtn.unbind("click");
  1412. if( enable == true ){
  1413. newsPreviewCloseBtn.click(function(){ click_PreviewClose();});
  1414. TweenMax.to(newsPreviewCloseBtn, .4, {css:{opacity:"1"}, easing:Sine.easeOut});
  1415. }
  1416. else{ TweenMax.to(newsPreviewCloseBtn, .4, {css:{opacity:"0.5"}, easing:Sine.easeOut}); }
  1417. }
  1418. function click_PreviewClose(){
  1419. previewNewsOpen = false;
  1420. newsPrvU.css("left", 0);
  1421. var i = 0;
  1422. for( i; i < totalPreviews; i++){ if( i != previewNewsIndex ){ newsPrevItemArr[ i ].css("display", "none"); } }
  1423. TweenMax.to([newsPrvU, newsPreviewControls], 0.6, {css:{left: $(newsList).width()}, delay:0.1, easing:Sine.easeOut});
  1424. TweenMax.to($(t_scrBarV1), .3, {css:{opacity: "0"}, easing:Sine.easeOut });
  1425. TweenMax.to(newsList, .6, {css:{left: "0" }, delay:0.1, easing: Sine.easeOut, onComplete: disableNewsPreview})
  1426. }
  1427. function disableNewsPreview(){
  1428. newsPrvH.css("display", "none");
  1429. $(t_scrBarV1).css("display", "none");
  1430. if(moduleList!= null){
  1431. moduleList.destroy( true );
  1432. moduleList = null;
  1433. }
  1434. moduleUpdate( textPageInstanceHolder, $("#module-news-vertical-holder", textPageInstance), $("#module-news-vertical-holder div:first", textPageInstance), sideType, null, null, newsItemTopPos );
  1435. }
  1436. }
  1437. function animateNewsPreviewMedia( src ){
  1438. var inst = $(src);
  1439. TweenMax.to($(src).parent(), .3, {css:{ height: inst.height()}, easing:Sine.easeOut});
  1440. TweenMax.to(inst, .4, {css:{ opacity:'1'}, easing:Sine.easeOut, onComplete: moduleUpdate_news});
  1441. }
  1442. function newsPreviewItemDisplay( display ){
  1443. var i = 0;
  1444. for( i; i < totalPreviews; i++){newsPrevItemArr[ i ].css("display", display);}
  1445. }
  1446. /*================= CONTACT ================================*/
  1447. function moduleContact(){
  1448. var textPageInstanceHolder = $( txt_modCont);
  1449. var textPageInstance = $( "#module-wrapper", textPageInstanceHolder);
  1450. if( textPageInstance.length <= 0 ){return;}
  1451. var $mapHolder = $("#module-container #map-holder");
  1452. var winH = $(window).height();
  1453. var winW = $(window).width();
  1454. var mapW = window.width-get_OffsetWidth()-$("#module-scrollbar-holder_v2").width();//screen.width;/**/
  1455. var mapLeft = 0;//(- get_OffsetWidth()) * .5;
  1456. var mapH = $mapHolder.height();
  1457. if( $mapHolder.length > 0 ){
  1458. $mapHolder.attr("style", "display: inline; visibility: visible;");
  1459. $mapHolder.css("opacity", "0").css("width", mapW);
  1460. $mapHolder.css("left", mapLeft + "px");
  1461. TweenMax.to( $mapHolder, .3, {css:{opacity: "1"}, easing: Sine.easeOut });
  1462. var iconSize = $mapHolder.attr("data-size").split(",");
  1463. var anchor = $mapHolder.attr("data-anchor").split(",");
  1464. }
  1465. var currWindowW = $(window).width() - get_OffsetWidth() - $(t_scrBarV2).width();
  1466. if( touchDevice == 1){ currWindowW = $(window).width() - templateMenuW; }
  1467. textPageInstance.css("width", currWindowW);
  1468. if( $("div:first", textPageInstance).height() <= $(window).height() )
  1469. { currWindowW = currWindowW + $(t_scrBarV2).width(); }
  1470. textPageInstance.css("width", currWindowW);
  1471. moduleUpdate( textPageInstanceHolder, textPageInstance, $("div:first", textPageInstance), sideType );
  1472. var $modContact = $("#module-container #module-contact");
  1473. var modContactH = $modContact.height();
  1474. var conH = ((winH - mapH) >= modContactH ) ? (winH - mapH) : modContactH;
  1475. $modContact.attr( "style", "bottom: " + (-conH) + "px; height: "+ conH + "px; visibility: visible;" );
  1476. contactFormSetup();
  1477. moduleUpdate_contact();
  1478. TweenMax.to( $modContact, .6, { css:{ bottom:"0px" }, ease:Circ.easeInOut,
  1479. onComplete: function(){
  1480. $mapHolder.gMap({
  1481. controls: {
  1482. panControl: true,
  1483. zoomControl: true,
  1484. mapTypeControl: false,
  1485. scaleControl: false,
  1486. streetViewControl: false,
  1487. overviewMapControl: false
  1488. },
  1489. scrollwheel: true,
  1490. address: $mapHolder.attr("data-address"),
  1491. zoom: 5,
  1492. markers:[{
  1493. latitude: $mapHolder.attr("data-latitude"),
  1494. longitude: $mapHolder.attr("data-longitude")/*,
  1495. icon: {
  1496. image: $mapHolder.attr("data-icon"),
  1497. iconsize: [iconSize[0], iconSize[1]],
  1498. iconanchor: [anchor[0], anchor[1]]
  1499. }*/
  1500. }]
  1501. });
  1502. }
  1503. });
  1504. var modContainerW = $("#module-container").width();
  1505. $("#module-contact-holder").css("left", (modContainerW - $("#module-contact-holder").width())*.5 + "px");
  1506. endModuleFunction = null;
  1507. moduleEnd = true;
  1508. var inputDefaultText = '';
  1509. var btnBackgColor = rgb2hex( $("#form-reset").css("background-color") );
  1510. $("#form-reset, #form-send").hover(
  1511. function() {
  1512. TweenMax.to( $(this), .6, { css:{backgroundColor:themeColor}, ease:Circ.easeOut });
  1513. },
  1514. function() {
  1515. TweenMax.to( $(this), .6, { css:{backgroundColor:btnBackgColor}, ease:Circ.easeOut });
  1516. });
  1517. $(".form-input-half-left input, .form-input-half-right input, .form-input-large input, .form-input-textarea textarea").focus(
  1518. function() {
  1519. var $obj = $(this),
  1520. $parent = $obj.parent();
  1521. if( $parent.hasClass("form-input-error-border") == true ){
  1522. setFormInputBorder( $parent, "form-input-error-border", "form-input-border" );
  1523. }
  1524. if( $obj.val() == ($obj.attr('name') + ' ' + '*' ) ){
  1525. inputDefaultText = $obj.val();
  1526. $obj.val('');
  1527. }
  1528. TweenMax.to( $(".form-input-background", $parent), .6, { css:{backgroundColor:"#ffffff", opacity:"1"}, ease:Circ.easeOut });
  1529. });
  1530. $(".form-input-half-left input, .form-input-half-right input, .form-input-large input, .form-input-textarea textarea").focusout(
  1531. function() {
  1532. var $obj = $(this);
  1533. if( $obj.val() == '' || $obj.val() == ' ' )$obj.val( inputDefaultText );
  1534. TweenMax.to( $(".form-input-background", $obj.parent()), .6, { css:{backgroundColor:"#9e9e9e", opacity:"0.2"}, ease:Circ.easeOut });
  1535. });
  1536. }
  1537. function showMap(){
  1538. var mapHolder = $("#module-container #map-holder");
  1539. var iFrame = $("iframe", mapHolder);
  1540. iFrame.css("opacity", "0");
  1541. iFrame.css("display", "inline");
  1542. TweenMax.to(iFrame, .3, {css:{opacity: "1"}, easing: Sine.easeOut });
  1543. }
  1544. var name = "", email = "", phone = "", messg = "",
  1545. nameDefTxt = "", emailDefTxt = "", phoneDefTxt = "", messgDefTxt = "",
  1546. resetBtn = "", sendBtn = "", sendBtnText = "", btnTextSend = "";
  1547. function contactFormSetup(){
  1548. $name = $("#contact-form #name");
  1549. $email = $("#contact-form #email");
  1550. $phone = $("#contact-form #phone");
  1551. $messg = $("#contact-form #message");
  1552. nameDefTxt = $name.val();
  1553. emailDefTxt = $email.val();
  1554. phoneDefTxt = $phone.val();
  1555. messgDefTxt = $messg.val();
  1556. $resetBtn = $("#contact-form #form-reset");
  1557. $sendBtn = $("#contact-form #form-send");
  1558. sendBtnText = $("p", $sendBtn).text();
  1559. btnTextSend = ($sendBtn.attr("data-sending-txt") != undefined ) ? $sendBtn.attr("data-sending-txt") : "null";
  1560. var parentArr = [$name.parent($name), $email.parent($email), $phone.parent($phone), $messg.parent($messg)];
  1561. var $responseForm = $("#response-form");
  1562. $resetBtn.click(function(){
  1563. resetFormValues();
  1564. setFormArrInputBorder( parentArr, "form-input-error-border", "form-input-border" );
  1565. TweenMax.to( $responseForm, .4, {css:{opacity:0}, delay:0.1, easing:Sine.easeOut, onComplete: function(){
  1566. $("p", $responseForm).css("display", "none");//inline-block
  1567. $("#form-warning", $responseForm).css("display", "none");//inline-block
  1568. }});
  1569. });
  1570. var sendingVal = false;
  1571. $sendBtn.click(function(){
  1572. if( sendingVal == true )return
  1573. var validForm = validateForm();
  1574. $responseForm.css("display", "inline-block").css("opacity", "0");
  1575. if( validForm.valid == true ){
  1576. sendingVal = true;
  1577. if( contactFormDemo == true ){
  1578. if( btnTextSend != "null" ){
  1579. changeTxtSendBtn( $("p", $sendBtn), btnTextSend );
  1580. TweenMax.to( $sendBtn, .6, { css:{opacity: 0.5}, ease:Sine.easeOut, onComplete: function(){
  1581. sendingVal = false;
  1582. changeTxtSendBtn( $("p", $sendBtn), sendBtnText )
  1583. TweenMax.to( $sendBtn, .4, {css:{opacity: 1}, easing:Sine.easeOut});
  1584. runSendAnimation( "inline-block", "none", "none" );
  1585. }});
  1586. }
  1587. }else{
  1588. if( btnTextSend != "null" ){
  1589. changeTxtSendBtn( $("p", $sendBtn), btnTextSend );
  1590. TweenMax.to( $sendBtn, .6, { css:{opacity: 0.5}, ease:Sine.easeOut});
  1591. }
  1592. /*$.ajax({
  1593. url: phpUrlPath,
  1594. type: "post",
  1595. data: ({senderName : $name.val(), senderEmail : $email.val(), senderPhone : $phone.val(), senderMessage : $messg.val()}),
  1596. dataType: "json",
  1597. success: function(data){
  1598. $responseForm.css("display", "inline-block").css("opacity", "1");
  1599. $("p", $responseForm).css("display", "inline-block");
  1600. if(data.result == true){
  1601. runSendAnimation( "inline-block", "none", "none" );
  1602. }
  1603. else{
  1604. $("#server-error", $responseForm).empty().text(data.msg);
  1605. runSendAnimation( "none", "none", "inline-block" );
  1606. }
  1607. changeTxtSendBtn( $("p", $sendBtn), sendBtnText );
  1608. TweenMax.to( $sendBtn, .4, {css:{opacity: 1}, easing:Sine.easeOut});
  1609. sendingVal = false;
  1610. },
  1611. error: function(err){
  1612. debugger;
  1613. }
  1614. });*/
  1615. $.post(phpUrlPath, {'senderName' : $name.val(), 'senderEmail' : $email.val(), 'senderPhone' : $phone.val(), 'senderMessage' : $messg.val()}, function(data){
  1616. data = $.parseJSON(data);
  1617. $responseForm.css("display", "inline-block").css("opacity", "1");
  1618. $("p", $responseForm).css("display", "inline-block");
  1619. if(data.result == true){
  1620. runSendAnimation( "inline-block", "none", "none" );
  1621. }
  1622. else{
  1623. $("#server-error", $responseForm).empty().text(data.msg);
  1624. runSendAnimation( "none", "none", "inline-block" );
  1625. }
  1626. changeTxtSendBtn( $("p", $sendBtn), sendBtnText );
  1627. TweenMax.to( $sendBtn, .4, {css:{opacity: 1}, easing:Sine.easeOut});
  1628. sendingVal = false;
  1629. });
  1630. }
  1631. }
  1632. else{
  1633. if( validForm.highlightInp != "null" ){
  1634. var arr = validForm.highlightInp,
  1635. t = arr.length;
  1636. while(t--){
  1637. var parent = $(arr[ t ]).parent(arr[ t ]);
  1638. setFormInputBorder( parent, "form-input-border", "form-input-error-border" );
  1639. }
  1640. }
  1641. $responseForm.css("display", "inline-block").css("opacity", "0");
  1642. $("p", $responseForm).css("display", "none");
  1643. $("#form-warning", $responseForm).css("display", "inline-block");
  1644. TweenMax.to( $responseForm, .4, {css:{opacity: 1}, delay: 0.1, easing:Sine.easeOut});
  1645. }
  1646. });
  1647. function changeTxtSendBtn( obj, param ){
  1648. obj.empty().append(param);
  1649. }
  1650. function validateForm(){
  1651. var valid = true,
  1652. nameVal = $name.val(),
  1653. emailVal = $email.val(),
  1654. phoneVal = $phone.val(),
  1655. messgVal = $messg.val();
  1656. var highlightInput = [];
  1657. var i = 0;
  1658. if( nameVal == nameDefTxt || nameVal == "" ){
  1659. valid = false;
  1660. highlightInput[i] = $name;
  1661. i++;
  1662. }
  1663. if( emailVal == emailDefTxt || emailVal == "" || isValidEmailAddress( emailVal ) == false ){
  1664. valid = false;
  1665. highlightInput[i] = $email;
  1666. i++;
  1667. }
  1668. if( phoneVal == phoneDefTxt || phoneVal == "" || isValidPhone( phoneVal ) == false ){
  1669. valid = false;
  1670. highlightInput[i] = $phone;
  1671. i++;
  1672. }
  1673. if( messgVal == messgDefTxt || messgVal == "" ){
  1674. valid = false;
  1675. highlightInput[i] = $messg;
  1676. i++;
  1677. }
  1678. highlightInput = ( highlightInput.length > 0 ) ? highlightInput : "null";
  1679. return {valid: valid, highlightInp:highlightInput};
  1680. }
  1681. }
  1682. function resetFormValues(){
  1683. $name.val( nameDefTxt );
  1684. $email.val( emailDefTxt );
  1685. $phone.val( phoneDefTxt );
  1686. $messg.val( messgDefTxt );
  1687. }
  1688. function runSendAnimation( v1, v2, v3 ){
  1689. var $responseForm = $("#response-form");
  1690. if( $responseForm.length > 0 ){
  1691. resetFormValues();
  1692. $responseForm.css("display", "inline-block").css("opacity", "0");
  1693. $("p", $responseForm).css("display", v1);
  1694. $("#form-warning", $responseForm).css("display", v2);
  1695. $("#server-error", $responseForm).css("display", v3);
  1696. var delay = (v3 != "none") ? 2 : 1.3;
  1697. TweenMax.to( $responseForm, .4, {css:{opacity:1}, easing:Sine.easeOut, onComplete: function(){
  1698. TweenMax.to( $responseForm, .4, {css:{opacity: 0}, delay: delay, easing:Sine.easeOut});
  1699. }});
  1700. }
  1701. }
  1702. function setFormArrInputBorder( parent, v1, v2 ){
  1703. if( $.isArray(parent) == true ){
  1704. var t = parent.length;
  1705. while(t--){
  1706. setFormInputBorder( parent[t], v1, v2 );
  1707. }
  1708. }
  1709. }
  1710. function setFormInputBorder( parent, v1, v2 ){
  1711. if( parent.hasClass( v1 ) == true ){
  1712. parent.removeClass( v1 )
  1713. }
  1714. if( parent.hasClass( v2 ) == false ){
  1715. parent.addClass( v2 )
  1716. }
  1717. }
  1718. function isValidPhone( phoneNumber ){
  1719. var pattern = new RegExp(/^[0-9-+]+$/);
  1720. return pattern.test(phoneNumber);
  1721. }
  1722. function isValidEmailAddress(emailAddress) {
  1723. var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
  1724. return pattern.test(emailAddress);
  1725. };
  1726. /*================= SHOWREEL ===============================*/
  1727. function moduleShowreel(){
  1728. var textPageInstanceHolder = $( txt_modCont);
  1729. var textPageInstance = $( "#module-showreel", textPageInstanceHolder);
  1730. if( textPageInstance.length <= 0 ){return;}
  1731. var modulePositionType = textPageInstanceHolder.attr("data-id");
  1732. var moduleWidth = textPageInstance.width();
  1733. moduleUpdate( textPageInstanceHolder, textPageInstance, $("div:first", textPageInstance), sideType );
  1734. textPageInstance.css("width", "0px").css("visibility", "visible");
  1735. var showreelVideo = $("#video-wrapper", textPageInstanceHolder);
  1736. var media = $("#module-showreel-holder", textPageInstance);
  1737. if( touchDevice == 1){
  1738. if( showreelVideo.children().length > 0 ){
  1739. tempVid = $("div:first", showreelVideo);
  1740. media.empty();
  1741. media.append(tempVid);
  1742. }
  1743. showreelVideo = $("#video-wrapper", textPageInstanceHolder);
  1744. }
  1745. showreelVideo.empty();
  1746. if( showreelVideo.length > 0 )templateAddMediaVideo( showreelVideo.attr("data-video-type"), showreelVideo, undefined )
  1747. TweenMax.to( textPageInstance, .4, { css:{ width: moduleWidth + "px" }, ease:Quad.easeOut });
  1748. endModuleFunction = endModuleShowreel;
  1749. moduleEnd = true;
  1750. }
  1751. function endModuleShowreel(){
  1752. var textPageInstance = $("#module-showreel");
  1753. var moduleWidth = textPageInstance.width();
  1754. TweenMax.to( textPageInstance, .6, { css:{ width: "0px" }, ease:Quad.easeInOut, onComplete:function(){
  1755. destroyVideoJS();
  1756. }
  1757. });
  1758. endModuleFunction = null;
  1759. }
  1760. function reverseEndModuleShowreel(){
  1761. var textPageInstanceHolder = $( txt_modCont);
  1762. var textPageInstance = $( "#module-showreel", textPageInstanceHolder);
  1763. if( textPageInstance.length <= 0 ){return;}
  1764. textPageInstance.css("visibility", "hidden");
  1765. textPageInstance.css("width", "");
  1766. var moduleWidth = textPageInstance.width();
  1767. textPageInstance.css("width", "0px").css("visibility", "visible");
  1768. var showreelVideo = $("#video-wrapper", textPageInstanceHolder);
  1769. var media = $("#module-showreel-holder", textPageInstance);
  1770. if( touchDevice == 1){
  1771. if( showreelVideo.children().length > 0 ){
  1772. tempVid = $("div:first", showreelVideo);
  1773. media.empty();
  1774. media.append(tempVid);
  1775. }
  1776. }
  1777. showreelVideo = $("#video-wrapper", textPageInstanceHolder);
  1778. showreelVideo.empty();
  1779. if( showreelVideo.length > 0 ){templateAddMediaVideo( showreelVideo.attr("data-video-type"), showreelVideo, undefined );}
  1780. TweenMax.to( textPageInstance, .4, { css:{ width: moduleWidth + "px" }, ease:Quad.easeOut });
  1781. endModuleFunction = endModuleShowreel;
  1782. moduleEnd = true;
  1783. }
  1784. /*================= FULLSCREEN VIDEO ========================*/
  1785. function moduleFullscreenVideo(){
  1786. var textPageInstanceHolder = $( txt_modCont);
  1787. var textPageInstance = $( "#module-fullscreen-video", textPageInstanceHolder);
  1788. var width = $(window).width() - get_OffsetWidth();
  1789. var height = $(window).height();
  1790. textPageInstance.css("opacity", "0");
  1791. textPageInstance.attr("style", "width:" + width + "px; height:" + height + "px;" );
  1792. textPageInstanceHolder.css("visibility", "visible");
  1793. TweenMax.to( textPageInstance, .6, { css:{ opacity: "1"}, ease:Circ.easeOut });
  1794. var fullscreenVideo = $("#video-wrapper", textPageInstanceHolder);
  1795. if( fullscreenVideo.length > 0 ){
  1796. fullscreenVideo.attr("data-width", width);
  1797. fullscreenVideo.attr("data-height", height);
  1798. var media = $("#fullscreen-video-holder", textPageInstance);
  1799. if( touchDevice == 1){
  1800. if( fullscreenVideo.children().length > 0 ){
  1801. tempVid = $("div:first", fullscreenVideo);
  1802. media.empty();
  1803. media.append(tempVid);
  1804. }
  1805. fullscreenVideo = $("#video-wrapper", textPageInstanceHolder);
  1806. }
  1807. fullscreenVideo.empty();
  1808. templateAddMediaVideo( fullscreenVideo.attr("data-video-type"), fullscreenVideo, undefined );
  1809. }
  1810. }
  1811. /*================= PRICING TABLES ========================*/
  1812. function modulePricingTables(){
  1813. var textPageInstanceHolder = $( txt_modCont);
  1814. var textPageInstance = $( "#module-pricing", textPageInstanceHolder);
  1815. if( textPageInstance.length <= 0 )return;
  1816. var moduleWidth = textPageInstanceHolder.width();
  1817. var moduleHeight = textPageInstanceHolder.height();
  1818. moduleUpdate( textPageInstanceHolder, textPageInstance, $("div:first", textPageInstance), sideType );
  1819. var val = parseInt( textPageInstanceHolder.css("left"), 10);
  1820. textPageInstanceHolder.css("left", "100%").css("visibility", "visible" );
  1821. TweenMax.to( textPageInstanceHolder, .5, { css:{ left: val }, delay: 0.1, ease:Circ.easeOut});
  1822. $("#pricing-column-holder", textPageInstance).hover(
  1823. function(){
  1824. $(this).css('z-index',2);
  1825. if ( $.browser.msie ){
  1826. if( $.browser.version != "8.0" && ( $.browser.version == "9.0" && isIE9Std() == true ))
  1827. if( $(this).hasClass("shadow-side-all-pricing-tables") == false )$(this).addClass("shadow-side-all-pricing-tables");
  1828. }
  1829. else{ if( $(this).hasClass("shadow-side-all-pricing-tables") == false )$(this).addClass("shadow-side-all-pricing-tables"); }
  1830. TweenMax.to( $("div:first", this), .4, { css:{ backgroundColor: themeColor}, ease:Sine.easeOut });
  1831. },
  1832. function(){
  1833. $(this).css('z-index',1);
  1834. if ( $.browser.msie ){
  1835. if( $.browser.version != "8.0" && ( $.browser.version == "9.0" && isIE9Std() == true ))
  1836. if( $(this).hasClass("shadow-side-all-pricing-tables") == true )$(this).removeClass("shadow-side-all-pricing-tables");
  1837. }
  1838. else{ if( $(this).hasClass("shadow-side-all-pricing-tables") == true )$(this).removeClass("shadow-side-all-pricing-tables"); }
  1839. TweenMax.to( $("div:first", this), .4, { css:{ backgroundColor: "#909090"}, ease:Sine.easeOut });
  1840. }
  1841. );
  1842. $("#pricing-column-holder #pricing-buy-holder", textPageInstance).hover(
  1843. function(){ TweenMax.to( $(this), .4, { css:{ backgroundColor: themeColor}, ease:Sine.easeOut }); },
  1844. function(){ TweenMax.to( $(this), .4, { css:{ backgroundColor: "#3F3F3F"}, ease:Sine.easeOut }); }
  1845. );
  1846. }
  1847. function customHoverAnimation( type, event, parent, child ){
  1848. var directionCSS = getDirectionCSS( parent, { x : event.pageX, y : event.pageY } );
  1849. if( type == "over" ){
  1850. child.removeClass(); child.css("left", directionCSS.from.val1); child.css("top", directionCSS.from.val2);
  1851. TweenMax.to( child, .3, { css:{ left:directionCSS.to.val1, top: directionCSS.to.val2}, ease:Sine.easeInOut });
  1852. }
  1853. else if( type == "out" ){ TweenMax.to( child, .3, { css:{ left:directionCSS.from.val1, top: directionCSS.from.val2}, ease:Sine.easeInOut }); }
  1854. }
  1855. /*================= FULL WIDTH =============================*/
  1856. function moduleFullWidth(){
  1857. var textPageInstanceHolder = $( txt_modCont);
  1858. var textPageInstance = $( "#module-full-width", textPageInstanceHolder);
  1859. if( textPageInstance.length <= 0 ){return;}
  1860. var currWindowW = $(window).width() - get_OffsetWidth();
  1861. var media = $("#module-full-width-media");
  1862. if( touchDevice == 1){ currWindowW = $(window).width() - templateMenuW; }
  1863. textPageInstance.css("width", currWindowW);
  1864. if( $("#module-full-width-holder-text", textPageInstance).height() > $(window).height() && touchDevice == 0)
  1865. { currWindowW = currWindowW - $(t_scrBarV2).width(); }
  1866. textPageInstanceHolder.css("opacity", "0");
  1867. textPageInstanceHolder.css("visibility", "visible");
  1868. media.css("height", "200px");
  1869. textPageInstance.css("width", currWindowW);
  1870. TweenMax.to( textPageInstanceHolder, .6, { css:{ opacity: "1" }, ease:Circ.easeOut });
  1871. if( media.attr("data-src") != undefined ){
  1872. media.empty().append('<img onload="animateFullWidthMedia(this)" width="100%" />')
  1873. $("img", media).css("opacity", "0").attr("src", media.attr("data-src"));
  1874. }
  1875. else{
  1876. var vidMedia = $("#video-wrapper", media);
  1877. if( touchDevice == 1){
  1878. if( vidMedia.children().length > 0 ){
  1879. tempVid = $("div:first", vidMedia);
  1880. media.empty();
  1881. media.append(tempVid);
  1882. }
  1883. }
  1884. vidMedia = $("#video-wrapper", media);
  1885. if( vidMedia.length > 0 ){
  1886. vidMedia.attr("data-width", media.width());
  1887. media.css("height", vidMedia.attr("data-height"));
  1888. moduleUpdate( textPageInstanceHolder, textPageInstance, $("div:first", textPageInstance), sideType );
  1889. templateAddMediaVideo( vidMedia.attr("data-video-type"), vidMedia, undefined );
  1890. }
  1891. else{
  1892. moduleUpdate( textPageInstanceHolder, textPageInstance, $("div:first", textPageInstance), sideType );
  1893. }
  1894. }
  1895. }
  1896. function animateFullWidthMedia( src ){
  1897. var inst = $(src);
  1898. TweenMax.to($(src).parent(), .4, {css:{ height: inst.height()}, easing:Sine.easeOut});
  1899. TweenMax.to(inst, .4, {css:{ opacity:'1'}, easing:Sine.easeOut, onComplete:
  1900. function()
  1901. {
  1902. $(src).parent().css("overflow", "visible").css("height", "");
  1903. moduleUpdate_full_width(true);
  1904. }
  1905. });
  1906. }
  1907. /*================= FULL WIDTH GALLERY =====================*/
  1908. var initialNumberColumns = 4;
  1909. var maximNumberColumns = 4;
  1910. var initialThumbW = 0;
  1911. var initialThumbH = 0;
  1912. var previewMediaArr = Array();
  1913. var previewMediaDescArr = Array();
  1914. var previewBorderSize = 0;
  1915. var currIndex = 0;
  1916. var previewFullWidthOpen = false;
  1917. function moduleFullWidthGallery(){
  1918. var textPageInstanceHolder = $( txt_modCont);
  1919. var textPageInstance = $( "#module-full-width-gallery", textPageInstanceHolder);
  1920. if(textPageInstance.length <= 0 ){return;}
  1921. var galleryItem = $(".full-width-item", textPageInstance);
  1922. var currWindowW = $(window).width() - get_OffsetWidth() - $(t_scrBarV2).width();
  1923. initialThumbW = galleryItem.width();
  1924. initialThumbH = galleryItem.height();
  1925. if( touchDevice == 1){ currWindowW = $(window).width() - get_OffsetWidth(); }
  1926. checkItems();
  1927. textPageInstance.css("width", currWindowW);
  1928. textPageInstanceHolder.css("opacity", "0").css("visibility", "visible");
  1929. TweenMax.to( textPageInstanceHolder, .6, { css:{ opacity: "1" }, ease:Circ.easeOut });
  1930. moduleUpdate( textPageInstanceHolder, textPageInstance, $("div:first", textPageInstance), sideType );
  1931. galleryItem.hover(
  1932. function(event){ customHoverAnimation( "over", event, $(this), $("#thumb-image-hover", this) ); },
  1933. function(event){ customHoverAnimation( "out", event, $(this), $("#thumb-image-hover", this) ); }
  1934. );
  1935. setFullWidthPreview();
  1936. storeFullWidthPreviewMedia();
  1937. galleryItem.click(
  1938. function(){
  1939. currIndex = 0;
  1940. changeFWPreviewMediaDesc(-1);
  1941. var index = $(".full-width-item").index(this);
  1942. currIndex = index;
  1943. if(moduleList != null ) moduleList.disableList();
  1944. $("#full-width-preview-media-holder").find("#preview-media-holder").empty();
  1945. loadFullWidthPreview( index );
  1946. });
  1947. }
  1948. function storeFullWidthPreviewMedia(){
  1949. previewMediaArr = new Array();
  1950. var i = 0;
  1951. $("#full-width-preview #full-width-preview-media-holder").find("#preview-media-holder").children().each(
  1952. function(){
  1953. if( $(this).attr("id") == "preview-media-image" ){
  1954. previewMediaArr[ i ] = '<img id="preview-media-image" src="' + $(this).attr("data-url") +
  1955. '" title="' + $(this).attr("data-title") + '"' +
  1956. ' alt="' + $(this).attr("data-alt") +'" />';
  1957. }
  1958. else if( $(this).attr("id") == "video-wrapper"){
  1959. var videoType = $(this).attr("data-type");
  1960. previewMediaArr[ i ] = $(this);
  1961. }
  1962. i++;
  1963. });
  1964. previewMediaDescArr = new Array();
  1965. i = 0;
  1966. $(".full-width-info-holder").find(".full-width-info-holder-desc").each( function(){ previewMediaDescArr[ i ] = $(this).get(0); i++; } );
  1967. $("#full-width-preview-media-holder").find("#preview-media-holder").empty();
  1968. }
  1969. function changeFWPreviewMediaDesc( pID, cID){
  1970. if( pID != -1 ){
  1971. var pDesc = previewMediaDescArr[ pID ];
  1972. TweenMax.to( $(pDesc), .4, { css:{ opacity: "0" }, ease:Circ.easeOut, onComplete: hideFWPrevMediaDesc, onCompleteParams: [ pID ] });
  1973. }
  1974. else{ $(".full-width-info-holder").find(".full-width-info-holder-desc").each( function(){ $(this).css("display", "none"); } ); }
  1975. if( cID != -1 && cID != undefined){
  1976. var cDesc = previewMediaDescArr[ cID ];
  1977. $(cDesc).attr("style", "visibility: visible; display: inline;");
  1978. $(cDesc).css("opacity", "0");
  1979. TweenMax.to( $(cDesc), .6, { css:{ opacity: "1" }, ease:Circ.easeOut });
  1980. }
  1981. }
  1982. function hideFWPrevMediaDesc( pID ){
  1983. var pDesc = previewMediaDescArr[ pID ];
  1984. $(pDesc).attr("style", "visibility: visible; display: inline;");
  1985. $(pDesc).css("opacity", "0");
  1986. }
  1987. function emptyPreviewMediaHolder(){ $("#full-width-preview-media-holder").find("#preview-media-holder").empty(); }
  1988. function updateFullWidthPreviewPosition(){
  1989. var fullWidthPreview = $("#full-width-preview");
  1990. var previewInfoHolder = $("#full-width-preview-info-holder", fullWidthPreview);
  1991. var fwMediaContainer = $("#full-width-preview-media-holder");
  1992. var infoWidth = previewInfoHolder.width();
  1993. var mediaContW = $(window).width() - infoWidth;
  1994. var mediaContH = $(window).height();
  1995. fwMediaContainer.attr("style", "width:" + mediaContW + "px; height:" + mediaContH + "px;");
  1996. $(".preview-arrow-close").css("right", infoWidth);
  1997. $(".preview-arrow-forward").css("right", infoWidth);
  1998. var mediaType = fwMediaType;
  1999. if( mediaType == "preview-media-image" ){
  2000. var elem = $("#preview-media-load");
  2001. $(elem).css("width", ''); $(elem).css("height", '');
  2002. checkSizeMedia( $(elem), mediaContW, mediaContH );
  2003. var mediaBackNewW = $(elem).width() + previewBorderSize*2;
  2004. var mediaBackNewH = $(elem).height() + previewBorderSize*2;
  2005. var mediaBackMarginTop = - mediaBackNewH * .5;
  2006. var mediaBackMarginLeft = - mediaBackNewW * .5;
  2007. $("#preview-media-holder").attr("style", "width: 100%; height: 100%; margin: 0px; top: 50%; left: 50%; margin-top:" + mediaBackMarginTop + "px; margin-left:" + mediaBackMarginLeft +"px;");
  2008. }
  2009. }
  2010. function loadFullWidthPreview( index ){
  2011. previewFullWidthOpen = true;
  2012. var fullWidthPreview = $("#full-width-preview");
  2013. var fwMediaContainer = $("#full-width-preview-media-holder");
  2014. if( fullWidthPreview.length <= 0 )return;
  2015. fullWidthPreview.css("opacity", "0");
  2016. fullWidthPreview.css("display", "inline");
  2017. fullWidthPreview.css("visibility", "visible");
  2018. TweenMax.to(fullWidthPreview, 0.4, {css:{opacity:"1"}, easing:Sine.easeOut, onComplete:addPreviewCloseClick});
  2019. function addPreviewCloseClick(){
  2020. showHideFullWidthPreviewInfo( true );
  2021. showFullWidthMedia();
  2022. $(".full-width-preview-media-holder-background, .preview-arrow-close", fullWidthPreview).click(
  2023. function(){ emptyPreviewMediaHolder(); showHideFullWidthPreviewInfo( false ); }
  2024. );
  2025. }
  2026. var previewInfoHolder = $("#full-width-preview-info-holder", fullWidthPreview);
  2027. var infoWidth = previewInfoHolder.width();
  2028. var mediaContW = $(window).width() - infoWidth;
  2029. var mediaContH = $(window).height();
  2030. fwMediaContainer.attr("style", "width:" + mediaContW + "px; height:" + mediaContH + "px;");
  2031. $(".preview-arrow-close").css("right", infoWidth);
  2032. $(".preview-arrow-forward").css("right", infoWidth);
  2033. function showHideFullWidthPreviewInfo( show ){
  2034. previewInfoHolder.css("position", "fixed");
  2035. var val = (- infoWidth) + "px";
  2036. if( show == true ){
  2037. previewInfoHolder.css("right", val);
  2038. changeFWPreviewMediaDesc( -1, currIndex );
  2039. previewInfoHolder.css("visibility", "visible");
  2040. TweenMax.to( previewInfoHolder, .3, { css:{ right: "0px" }, delay:0.1, ease:Quad.easeInOut });
  2041. }
  2042. else{
  2043. TweenMax.to( fwMediaContainer, .3, { css:{ opacity: "0"}, ease:Circ.easeInOut });
  2044. TweenMax.to( [$(".preview-arrow-close"), $(".preview-arrow-forward"), $(".preview-arrow-backward")], .3, { css:{ opacity: "0"}, ease:Circ.easeInOut });
  2045. TweenMax.to( previewInfoHolder, .3, { css:{ right: val }, ease:Circ.easeInOut, onComplete: hideFullWidthPreview });
  2046. }
  2047. function hideFullWidthPreview(){
  2048. previewFullWidthOpen = false;
  2049. justOpenedPreivew = true;
  2050. animationLoadFWPreviewDone = true;
  2051. $("#full-width-preview-media-holder", fullWidthPreview).unbind("click");
  2052. $(".preview-arrow-close", fullWidthPreview).unbind("click");
  2053. TweenMax.to(fullWidthPreview, 0.4, {css:{opacity:"0"}, easing:Sine.easeOut, onComplete:removeFullWidthPreview});
  2054. }
  2055. function removeFullWidthPreview(){
  2056. if(moduleList != null ) moduleList.enableList();
  2057. fullWidthPreview.css("display", "none");
  2058. }
  2059. }
  2060. function showFullWidthMedia(){
  2061. fwMediaContainer.css("opacity", "0");
  2062. fwMediaContainer.css("visibility", "visible");
  2063. TweenMax.to( fwMediaContainer, 0.2, {css:{opacity:"1"}, easing:Sine.easeOut});
  2064. loadFullWidthMedia();
  2065. }
  2066. }
  2067. function loadFullWidthMedia(){
  2068. var currPreviewElem = previewMediaArr[ currIndex ];
  2069. var mediaType = $(currPreviewElem).attr("id");
  2070. var fwMediaContainer = $("#full-width-preview-media-holder");
  2071. if( mediaType == "preview-media-image" ){
  2072. /*PLAY MEDIA IMAGE*/
  2073. var totalWidth = fwMediaContainer.width() - previewBorderSize*2;
  2074. var totalHeight = fwMediaContainer.height() - previewBorderSize*2;
  2075. var prevMediaLoad = $("#preview-media-load");
  2076. fwMediaType = mediaType;
  2077. fwW = totalWidth;
  2078. fwH = totalHeight;
  2079. prevMediaLoad.css("opacity", "0" );
  2080. var prevMediaHolder = fwMediaContainer.find("#preview-media-holder");
  2081. prevMediaHolder.append('<img id="preview-media-load" onload="animateFullWidthPreviewMedia()" title="" alt="" />');
  2082. prevMediaLoad = $("#preview-media-load");
  2083. prevMediaLoad.attr("style", "visibility: visible; display: inline;");
  2084. prevMediaLoad.css("opacity", "0" );
  2085. prevMediaLoad.attr("src", $(currPreviewElem).attr("src") );
  2086. prevMediaLoad.attr("title", $(currPreviewElem).attr("title") );
  2087. prevMediaLoad.attr("alt", $(currPreviewElem).attr("alt") );
  2088. }
  2089. else if( mediaType == "video-wrapper" ){
  2090. /*PLAY MEDIA VIDEO*/
  2091. fwMediaContainer.find("#preview-media-holder").empty();
  2092. var prevMediaHolder = $("#preview-media-holder");
  2093. var mediaBackNewW = parseInt($(currPreviewElem).attr("data-width"), 10) + previewBorderSize*2;
  2094. var mediaBackNewH = parseInt($(currPreviewElem).attr("data-height"), 10) + previewBorderSize*2;
  2095. var mediaBackMarginTop = - mediaBackNewH * .5;
  2096. var mediaBackMarginLeft = - mediaBackNewW * .5;
  2097. prevMediaHolder.attr("style", "width: " + mediaBackNewW + "px; height: " + mediaBackNewH + "px; margin: 0px; top: 50%; left: 50%; margin-top:" + mediaBackMarginTop + "px; margin-left:" + mediaBackMarginLeft + "px;");
  2098. prevMediaHolder.append('<div id="video-wrapper"></div>')
  2099. templateAddMediaVideo( $(currPreviewElem).attr("data-video-type"), $(currPreviewElem), $("#video-wrapper") );
  2100. TweenMax.to($(".full-width-preview-media-loader"), .3, {css:{opacity:"0"}, easing:Sine.easeOut});
  2101. loadingAnimationDone = true;
  2102. animationLoadFWPreviewDone = true;
  2103. fwMediaType = mediaType;
  2104. fullWidthFadeInMedia( mediaType );
  2105. }
  2106. }
  2107. var fwMediaType = "";
  2108. var fwW = "";
  2109. var fwH = "";
  2110. function animateFullWidthPreviewMedia(){
  2111. var mediaType = fwMediaType;
  2112. var width = fwW;
  2113. var height = fwH;
  2114. var elem = "";
  2115. if( mediaType == "preview-media-image" ) {
  2116. elem = $("#preview-media-load");
  2117. $(elem).css("width", ''); $(elem).css("height", '');
  2118. checkSizeMedia( $(elem), width, height );
  2119. }
  2120. animationLoadFWPreviewDone = true;
  2121. if( $(elem).width() != null ){
  2122. var mediaBackNewW = $(elem).width() + previewBorderSize*2;
  2123. var mediaBackNewH = $(elem).height() + previewBorderSize*2;
  2124. var mediaBackMarginTop = - mediaBackNewH * .5;
  2125. var mediaBackMarginLeft = - mediaBackNewW * .5;
  2126. var prevMediaHolder = $("#preview-media-holder");
  2127. prevMediaHolder.attr("style", "width: " + mediaBackNewW + "px; height: " + mediaBackNewH + "px; margin: 0px; top: 50%; left: 50%; margin-top:" + mediaBackMarginTop + "px; margin-left:" + mediaBackMarginLeft + "px;");
  2128. TweenMax.to($(".full-width-preview-media-loader"), .3, {css:{opacity:"0"}, easing:Sine.easeOut});
  2129. fullWidthFadeInMedia( mediaType );
  2130. loadingAnimationDone = true;
  2131. }
  2132. }
  2133. var justOpenedPreivew = true;
  2134. function fullWidthFadeInMedia( mediaType ){
  2135. if( mediaType == "preview-media-image" ){ TweenMax.to( $("#preview-media-load"), .6, { css:{ opacity: "1" }, ease:Circ.easeOut }); }
  2136. if( justOpenedPreivew == true ){
  2137. justOpenedPreivew = false;
  2138. var fwMediaContainer = $("#full-width-preview-media-holder");
  2139. var tW = fwMediaContainer.width() - 60;
  2140. var prevControlClose = $(".preview-arrow-close");
  2141. var prevControlBack = $(".preview-arrow-backward");
  2142. var prevControlForw = $(".preview-arrow-forward");
  2143. prevControlClose.css("opacity", "0").css("display", "inline");
  2144. prevControlBack.css("opacity", "0").css("display", "inline");
  2145. prevControlForw.css("opacity", "0").css("display", "inline");
  2146. TweenMax.to( [prevControlClose, prevControlBack, prevControlForw], .6, { css:{ opacity: "1"}, ease:Circ.easeInOut });
  2147. var initOpacity = $(".preview-arrow-backward .preview-arrow-backg").css("opacity");
  2148. var initBackColor = rgb2hex( $(".preview-arrow-backward .preview-arrow-backg").css("background-color") );
  2149. $(".preview-arrow-backward, .preview-arrow-forward, .preview-arrow-close").unbind('mouseenter mouseleave');
  2150. $(".preview-arrow-backward, .preview-arrow-forward, .preview-arrow-close").hover(
  2151. function(){ TweenMax.to( $(".preview-arrow-backg", this), 0.3, {css:{opacity: "1", backgroundColor: themeColor }, easing:Sine.easeOut }); },
  2152. function(){ TweenMax.to( $(".preview-arrow-backg", this), 0.3, {css:{opacity: initOpacity, backgroundColor: initBackColor}, easing:Sine.easeOut }); }
  2153. );
  2154. $(".preview-arrow-backward").unbind("click"); $(".preview-arrow-forward").unbind("click");
  2155. $(".preview-arrow-backward").click(
  2156. function(){
  2157. TweenMax.to($(".full-width-preview-media-loader"), .3, {css:{opacity:"1"}, easing:Sine.easeOut});
  2158. changeFullWidthPreviewMedia( -1 );
  2159. });
  2160. $(".preview-arrow-forward").click(
  2161. function(){
  2162. TweenMax.to($(".full-width-preview-media-loader"), .3, {css:{opacity:"1"}, easing:Sine.easeOut});
  2163. changeFullWidthPreviewMedia( 1 );
  2164. });
  2165. }
  2166. }
  2167. var animationLoadFWPreviewDone = true;
  2168. function changeFullWidthPreviewMedia( value ){
  2169. var nextThumbID = currIndex + value;
  2170. if( nextThumbID > previewMediaArr.length - 1 ){ nextThumbID = 0; }
  2171. else if( nextThumbID < 0 ){ nextThumbID = previewMediaArr.length - 1; }
  2172. if( currIndex != nextThumbID ){
  2173. var elem = previewMediaArr[ currIndex ];
  2174. if( $(elem).attr("id") == "preview-media-image" ) {
  2175. $("#preview-media-load").css("opacity", 0 );
  2176. $("#preview-media-load").attr("style", "visibility: hidden; display: none;");
  2177. }
  2178. else if( $(elem).attr("id") == "video-wrapper" ){
  2179. $(elem).css("opacity", "0" );
  2180. $(elem).attr("style", "visibility: hidden; display: none;");
  2181. }
  2182. changeFWPreviewMediaDesc( currIndex, nextThumbID );
  2183. currIndex = nextThumbID;
  2184. elem = previewMediaArr[ currIndex ];
  2185. $("#full-width-preview-media-holder").find("#preview-media-holder").empty();
  2186. loadFullWidthMedia();
  2187. }
  2188. }
  2189. function setFullWidthPreview(){
  2190. var fullWidthPreview = $("#full-width-preview");
  2191. if( $("#full-width-preview").length > 0 ){
  2192. fullWidthPreview.remove();
  2193. $("#template-wrapper").after(fullWidthPreview);
  2194. }
  2195. }
  2196. function checkItems(){
  2197. var currWindowW = $(window).width() - get_OffsetWidth() - $(t_scrBarV2).width();
  2198. var textPageInstanceHolder = $( txt_modCont);
  2199. var textPageInstance = $( "#module-full-width-gallery", textPageInstanceHolder);
  2200. var itemW = currWindowW / maximNumberColumns;
  2201. var currRatio = itemW / initialThumbW;
  2202. var itemH = initialThumbH / initialThumbW * itemW;
  2203. if( initialThumbW <= 0){return;}
  2204. if( touchDevice == 1){
  2205. currWindowW = $(window).width() - get_OffsetWidth();
  2206. }
  2207. textPageInstance.css("width", currWindowW);
  2208. if( currRatio >= 0.8 && currRatio <= 1){
  2209. itemW = currWindowW / maximNumberColumns;
  2210. itemH = initialThumbH / initialThumbW * itemW;
  2211. }
  2212. else if( currRatio < 0.8 || currRatio > 1){
  2213. itemW = currWindowW / (maximNumberColumns-1);
  2214. currRatio = itemW / initialThumbW;
  2215. if( currRatio <= 1){
  2216. maximNumberColumns--;
  2217. itemW = currWindowW / maximNumberColumns;
  2218. itemH = initialThumbH / initialThumbW * itemW;
  2219. currRatio = itemW / initialThumbW;
  2220. while( currRatio < 0.8 ){
  2221. maximNumberColumns--;
  2222. itemW = currWindowW / maximNumberColumns;
  2223. itemH = initialThumbH / initialThumbW * itemW;
  2224. currRatio = itemW / initialThumbW;
  2225. }
  2226. if( currRatio > 1 ){
  2227. itemW = currWindowW / maximNumberColumns;
  2228. itemH = initialThumbH / initialThumbW * itemW;
  2229. while( itemW > initialThumbW ){
  2230. maximNumberColumns++;
  2231. itemW = currWindowW / maximNumberColumns;
  2232. itemH = initialThumbH / initialThumbW * itemW;
  2233. }
  2234. }
  2235. }
  2236. else{
  2237. itemW = currWindowW / maximNumberColumns;
  2238. itemH = initialThumbH / initialThumbW * itemW;
  2239. while( itemW > initialThumbW ){
  2240. maximNumberColumns++;
  2241. itemW = currWindowW / maximNumberColumns;
  2242. itemH = initialThumbH / initialThumbW * itemW;
  2243. }
  2244. }
  2245. }
  2246. var col = 0;
  2247. var lin = 0;
  2248. $("#module-full-width-holder").find(".full-width-item").each(
  2249. function(){
  2250. $(this).css("position", "absolute");
  2251. var topV = 0;
  2252. var lefV = 0;
  2253. if( col < maximNumberColumns){
  2254. topV = Math.round(itemH) * lin;
  2255. lefV = Math.round(itemW) * col;
  2256. col++;
  2257. }
  2258. else{
  2259. col = 0;
  2260. lin++;
  2261. topV = Math.round(itemH) * lin;
  2262. lefV = Math.round(itemW) * col;
  2263. col++;
  2264. }
  2265. /* we have added img width= 100.5% in CSS file so we don't need to tween the 'img' anymore';
  2266. 100.5% to fill the extra -0.5px that sometime appears on resizing*/
  2267. if( touchDevice == 0 ){
  2268. TweenMax.to( $("img",this), 0.6, {css:{width: Math.round(itemW), height: Math.round(itemH)}, easing: Sine.easeOut});
  2269. TweenMax.to( $(this), 0.6, {css:{width: Math.round(itemW), height: Math.round(itemH), left: lefV, top: topV}, easing: Sine.easeOut});
  2270. }
  2271. else{
  2272. $("img",this).css("width", Math.round(itemW)).css("height", Math.round(itemH) );
  2273. $(this).css("width", Math.round(itemW)).css("height", Math.round(itemH) ).css("left", lefV).css("top", topV);
  2274. }
  2275. });
  2276. lin++;
  2277. $("div:first", textPageInstance).css("height", lin * Math.round(itemH));
  2278. }
  2279. /*================= COLUMNS PORTFOLIO ======================*/
  2280. var columnsPreviewOpen = false;
  2281. var previewAnimDone = true;
  2282. var columnsPreviewIndex = 0;
  2283. var columnsPrevItemArr = "";
  2284. var totalColPreviews = 0;
  2285. var $originalDataPos = 0;
  2286. function modulePageColumns(){
  2287. columnsPreviewOpen = false;
  2288. previewAnimDone = true;
  2289. columnsPreviewIndex = 0;
  2290. columnsPrevItemArr = new Array();
  2291. totalColPreviews = 0;
  2292. var textPageInstanceHolder = $( txt_modCont);
  2293. var textPageInstance = $( "#module-columns", textPageInstanceHolder);
  2294. if( textPageInstance.length <= 0 ) return;
  2295. var modulePositionType = textPageInstanceHolder.attr("data-id");
  2296. var moduleWidth = textPageInstanceHolder.width();
  2297. var moduleHeight = textPageInstanceHolder.height();
  2298. var columnItemWrapper = $( "#module-columns-wrapper", textPageInstanceHolder);
  2299. var columnPrevWrapper = $( "#module-columns-preview-wrapper", textPageInstanceHolder);
  2300. if( touchDevice == 1 ){
  2301. columnItemWrapper.css("overflow", "").css("-webkit-overflow-scrolling", "");
  2302. columnItemWrapper.css("overflow", "auto").css("-webkit-overflow-scrolling", "touch");
  2303. }
  2304. checkColumnSize();
  2305. moduleUpdate( textPageInstanceHolder, columnItemWrapper, $("div:first", columnItemWrapper), sideType );
  2306. var val = Math.abs($("#module-container").width() - textPageInstanceHolder.width()) * .5;
  2307. textPageInstanceHolder.css("left", "100%").css("visibility", "visible");
  2308. TweenMax.to( textPageInstanceHolder, .6, { css:{ left: val }, ease:Circ.easeOut });
  2309. var thumbHolderClass = $("#module-columns-holder div:first", textPageInstance).attr("class");
  2310. thumbHolderClass = $("." + thumbHolderClass);
  2311. var backgOverColor = "#3f3f3f";
  2312. var backgOutColor = rgb2hex( thumbHolderClass.css("background-color") );
  2313. var text1BaseColor = rgb2hex( $(".thumb-tag h1", thumbHolderClass).css("color") );
  2314. var text2BaseColor = rgb2hex( $(".thumb-tag h2", thumbHolderClass).css("color") );
  2315. if( touchDevice == 0 ){
  2316. thumbHolderClass.unbind("mouseenter mouseleave");
  2317. thumbHolderClass.hover(
  2318. function(event){
  2319. customHoverAnimation( "over", event, $(this), $("#thumb-image-hover", this) );
  2320. var text = $(".thumb-tag h1", this);
  2321. var text2 = $(".thumb-tag h2", this);
  2322. TweenMax.to( [ text, text2 ], .6, { css:{ color: backgOutColor }, ease:Quad.easeOut });
  2323. TweenMax.to( $(this), .6, { css:{ backgroundColor: backgOverColor }, ease:Quad.easeOut });
  2324. },
  2325. function(event){
  2326. customHoverAnimation( "out", event, $(this), $("#thumb-image-hover", this) );
  2327. var text = $(".thumb-tag h1", this);
  2328. var text2 = $(".thumb-tag h2", this);
  2329. TweenMax.to( text, .6, { css:{ color: text1BaseColor }, ease:Circ.easeOut });
  2330. TweenMax.to( text2, .6, { css:{ color: text2BaseColor }, ease:Circ.easeOut });
  2331. TweenMax.to( $(this), .6, { css:{ backgroundColor: backgOutColor }, ease:Quad.easeOut });
  2332. });
  2333. }
  2334. var columnsPrevItemMediaArr = new Array();
  2335. var previewWidth = $("#module-columns-preview-holder", columnPrevWrapper).width();
  2336. columnPrevWrapper.css("display", "inline");
  2337. $(columnPrevWrapper, textPageInstance).find(".columns-preview-horizontal-fix").each(
  2338. function(){
  2339. $(this).css("width", 9999999);
  2340. var cPIH = $("ul", this);
  2341. var cPI = $("ul li",this);
  2342. var i = 0;
  2343. cPI.each(function(){
  2344. var mediaSrc = $(".columns-preview-media", this).attr("data-src");
  2345. columnsPrevItemArr[ i ] = $(this);
  2346. columnsPrevItemMediaArr[ i ] = mediaSrc;
  2347. i++;
  2348. $(this).css("width", previewWidth);
  2349. $(this).css("display", "none");
  2350. });
  2351. $(this).css("width", previewWidth);
  2352. cPIH.css("width", cPIH.width() );
  2353. });
  2354. columnPrevWrapper.css("display", "none");
  2355. var columnTopPos = 0;
  2356. totalColPreviews = $(".columns-preview-horizontal-fix ul", textPageInstance).children().length;
  2357. thumbHolderClass.unbind("click");
  2358. thumbHolderClass.click(
  2359. function(){
  2360. var index = $(thumbHolderClass).index(this);
  2361. columnsPreviewIndex = index;
  2362. if( moduleList != null ){
  2363. moduleList.disableList();
  2364. columnTopPos = moduleList.currentPosition();
  2365. TweenMax.to($(t_scrBarV2), .3, {css:{opacity: "0"}, easing:Sine.easeOut, onComplete: function(){ $(t_scrBarV2).css("display", "none"); } });
  2366. }
  2367. if(touchDevice == 1){columnTopPos = columnItemWrapper.scrollTop();}
  2368. TweenMax.to( columnItemWrapper, .4, {css:{opacity: "0"}, easing:Sine.easeOut, onComplete:function(){ columnItemWrapper.css("display", "none"); }});
  2369. var i = 0;
  2370. for( i; i < totalColPreviews; i++){
  2371. if( i == columnsPreviewIndex ){columnsPrevItemArr[ i ].css("display", "inline");}
  2372. else{ columnsPrevItemArr[ i ].css("display", "none"); }
  2373. }
  2374. $(".columns-preview-counter span", "#columns-preview-controls").empty().append( (index+1) + "/" + totalColPreviews );
  2375. loadColumnsPreview( index );
  2376. });
  2377. function loadColumnsPreview( index ){
  2378. var prevListW = $("#module-columns-preview-holder").width();
  2379. var elMargR = parseInt($("li:first",".columns-preview-horizontal-fix ul").css("margin-right"), 10 );
  2380. var scrollValue = index * (prevListW + elMargR);
  2381. if( moduleList != null){ moduleList.disableList(); }
  2382. previewAnimDone = false;
  2383. if( columnsPreviewOpen == false ){
  2384. columnsPreviewOpen = true;
  2385. $(".columns-preview-horizontal-fix ul").css("left", -scrollValue);
  2386. columnPrevWrapper.css("opacity", "0").css("display", "inline");
  2387. TweenMax.to( columnPrevWrapper, .6, {css:{opacity: "1"}, delay:0.3, easing:Sine.easeOut});
  2388. checkColumnsPreviewScrollbar(columnsPreviewOpen);
  2389. }
  2390. else{
  2391. TweenMax.to( $("#module-columns-preview", textPageInstance), .3, {css:{top: "0px"}, easing:Sine.easeOut});
  2392. TweenMax.to($(".columns-preview-horizontal-fix ul"), 0.6, {css:{left:-scrollValue}, delay:0.1, easing:Sine.easeOut, onComplete: checkColumnsPreviewScrollbar, onCompleteParams:[columnsPreviewOpen]});
  2393. }
  2394. $(".columns-preview-counter span", "#columns-preview-controls").empty().append( (index+1) + "/" + totalColPreviews );
  2395. }
  2396. function checkColumnsPreviewScrollbar( previewOpen ){
  2397. if( moduleList != null){ moduleList.enableList(); }
  2398. enableColumnsPreviewClose(true);
  2399. if( moduleList != null){ moduleList.destroy( false ); moduleList = null; }
  2400. var i = 0;
  2401. for( i; i < totalColPreviews; i++){
  2402. if( i != columnsPreviewIndex ){columnsPrevItemArr[ i ].css("display", "none");}
  2403. }
  2404. moduleUpdate( textPageInstanceHolder, columnPrevWrapper, $("div:first", columnPrevWrapper), sideType );
  2405. var previewColMediaParent = $(".columns-preview-media", columnsPrevItemArr[ columnsPreviewIndex ]);
  2406. if( $("img", previewColMediaParent).length <= 0 ){
  2407. previewColMediaParent.empty().append('<img width="100%" class="opacity_0" onload="animateColPreviewMedia(this)" />');
  2408. $("img", previewColMediaParent).attr("src", columnsPrevItemMediaArr[ columnsPreviewIndex ]);
  2409. }
  2410. else{
  2411. previewAnimDone = true;
  2412. if( touchDevice == 1){
  2413. $("div:first", columnPrevWrapper).css("height", "");
  2414. $("div:first", columnPrevWrapper).css("height", $("div:first", columnPrevWrapper).height());
  2415. }
  2416. }
  2417. colPreviewItemDisplay("inline");
  2418. }
  2419. /*initial close enabled*/
  2420. enableColumnsPreviewClose(true);
  2421. function enableColumnsPreviewClose( enable ){
  2422. $(".columns-preview-close", textPageInstance).unbind("click");
  2423. if( enable == true ){
  2424. $(".columns-preview-close", textPageInstance).click( function(){ click_ColumnsPreviewClose(); } );
  2425. TweenMax.to($(".columns-preview-close", textPageInstance), .4, {css:{opacity:"1"}, easing:Sine.easeOut})
  2426. }
  2427. else{ TweenMax.to($(".columns-preview-close", textPageInstance), .4, {css:{opacity:"0.5"}, easing:Sine.easeOut}) }
  2428. }
  2429. function click_ColumnsPreviewClose(){
  2430. columnsPreviewOpen = false;
  2431. TweenMax.to($(t_scrBarV2), .3, {css:{opacity: "0"}, easing:Sine.easeOut });
  2432. TweenMax.to( columnPrevWrapper, .4, {css:{opacity: "0"}, easing:Sine.easeOut, onComplete:hideColumnsPreview});
  2433. }
  2434. function hideColumnsPreview(){
  2435. $("div:first", columnPrevWrapper).css("height", "");
  2436. columnPrevWrapper.css("opacity", "0").css("display", "none");
  2437. $(t_scrBarV2).css("display", "none");
  2438. $(".columns-preview-horizontal-fix ul", textPageInstance).find("li").each( function(){ $(this).css("display", "none"); } );
  2439. $(".columns-preview-horizontal-fix ul", textPageInstance).css("left", "0");
  2440. if(moduleList!= null){ moduleList.resetPosition( 0 ); moduleList.disableList(); moduleList.destroy(); moduleList = null; }
  2441. columnItemWrapper.css("opacity", "0").css("display", "inline");
  2442. moduleUpdate_page_columns( columnTopPos );
  2443. TweenMax.to( columnItemWrapper, .6, {css:{opacity: "1"}, easing:Sine.easeOut });
  2444. $("#filter-buttons-holder", textPageInstance).find(".filter-button").each(
  2445. function(){
  2446. var obj = $(this);
  2447. var dataF = obj.attr("data-filter");
  2448. if( dataF != undefined && dataF == "*" ){
  2449. obj.addClass("selected");
  2450. TweenMax.to( obj, .3, { css:{ color:"#ffffff", backgroundColor: themeColor }, ease:Sine.easeOut });
  2451. }
  2452. else{
  2453. if(obj.hasClass("selected") == true){
  2454. obj.removeClass("selected").css("color", "#3f3f3f").css("background-color", "transparent");
  2455. }
  2456. }
  2457. });
  2458. }
  2459. var initBackColor = rgb2hex( $(".columns-preview-backward .columns-preview-backg").css("background-color") );
  2460. $(".columns-preview-backward, .columns-preview-forward, .columns-preview-close").unbind("mouseenter mouseleave");
  2461. $(".columns-preview-backward, .columns-preview-forward, .columns-preview-close").hover(
  2462. function(){ TweenMax.to( $(".columns-preview-backg", this), 0.3, {css:{backgroundColor: themeColor }, easing:Sine.easeOut }); },
  2463. function(){ TweenMax.to( $(".columns-preview-backg", this), 0.3, {css:{backgroundColor: initBackColor}, easing:Sine.easeOut }); }
  2464. );
  2465. $(".columns-preview-backward, .columns-preview-forward", textPageInstance ).click(
  2466. function(){
  2467. var index = columnsPreviewIndex;
  2468. if( $(this).hasClass("columns-preview-backward") == true ){
  2469. index--;
  2470. changeColPreviewMedia( index );
  2471. }
  2472. else if( $(this).hasClass("columns-preview-forward") == true ){
  2473. index++;
  2474. changeColPreviewMedia( index );
  2475. }
  2476. });
  2477. $(".columns-preview-horizontal-fix ul").wipetouch({
  2478. tapToClick: false, /* if user taps the screen, triggers a click event*/
  2479. preventDefault: false,
  2480. wipeLeft: function(result) {
  2481. var index = columnsPreviewIndex; index++;
  2482. changeColPreviewMedia( index )
  2483. },
  2484. wipeRight: function(result) {
  2485. var index = columnsPreviewIndex; index--;
  2486. changeColPreviewMedia( index )
  2487. }
  2488. });
  2489. function changeColPreviewMedia( index ){
  2490. if( index < 0){index = 0;}
  2491. if( index > totalColPreviews-1){index = totalColPreviews-1;}
  2492. if( index == columnsPreviewIndex){return;}
  2493. enableColumnsPreviewClose( false )
  2494. columnsPreviewIndex = index;
  2495. loadColumnsPreview( columnsPreviewIndex );
  2496. }
  2497. var $filterContainer = $("#module-columns-holder", textPageInstance);
  2498. $originalDataPos = getOriginalPos($filterContainer);
  2499. if( touchDevice == 0 )$("#filter-buttons-holder .filter-button", textPageInstance).hover(
  2500. function(){
  2501. if($(this).hasClass("selected") == true)return;
  2502. TweenMax.to( $(this), .3, { css:{ color:"#ffffff", backgroundColor: themeColor }, ease:Sine.easeOut });
  2503. },
  2504. function(){
  2505. if($(this).hasClass("selected") == true)return;
  2506. TweenMax.to( $(this), .3, { css:{ color:"#3f3f3f", backgroundColor: "transparent" }, ease:Sine.easeOut });
  2507. }
  2508. );
  2509. $("#filter-buttons-holder .filter-button", textPageInstance).click(
  2510. function(){
  2511. if($(this).hasClass("selected") == true)return;
  2512. var selector = $(this).attr('data-filter');
  2513. $("#filter-buttons-holder", textPageInstance).find(".filter-button").each(
  2514. function(){
  2515. if($(this).hasClass("selected") == true){
  2516. $(this).removeClass("selected");
  2517. TweenMax.to( $(this), .3, { css:{ color:"#3f3f3f", backgroundColor: "transparent" }, ease:Sine.easeOut });
  2518. }
  2519. });
  2520. $(this).addClass("selected");
  2521. if(touchDevice == 1){TweenMax.to( $(this), .3, { css:{ color:"#ffffff", backgroundColor: themeColor }, ease:Sine.easeOut });}
  2522. filterContent( $filterContainer, selector, $originalDataPos, onFilterComplete );
  2523. return false;
  2524. });
  2525. }
  2526. var containerTotalH = 0;
  2527. function onFilterComplete( index, container, child, hide ){
  2528. var total = container.children().length-1;
  2529. if( hide == false ){ containerTotalH = child.position().top + parseInt(child.css("margin-bottom"), 10) + child.height(); }
  2530. if( index == total){
  2531. var textPageInstanceHolder = $( txt_modCont);
  2532. var textPageInstance = $( "#module-columns-wrapper", textPageInstanceHolder);
  2533. container.css("height", containerTotalH);
  2534. TweenMax.to( $("div:first", textPageInstance), .3, {css:{top: "0px"}, easing:Sine.easeOut, onComplete:
  2535. function(){
  2536. var sType = $("#template-menu").attr("data-side");
  2537. moduleUpdate( textPageInstanceHolder, textPageInstance, $("div:first", textPageInstance), sType, true, false );
  2538. //moduleUpdate_page_columns();
  2539. if(moduleList != null)moduleList.enableList();
  2540. }
  2541. });
  2542. }
  2543. }
  2544. function getOriginalPos( container ){
  2545. var i = 0;
  2546. var posArray = new Array();
  2547. container.children().each( function(){ posArray[ i ] = { x: $(this).position().left, y: $(this).position().top }; i++; });
  2548. container.css("height", container.height());
  2549. container.css("width", container.width());
  2550. i = 0;
  2551. container.children().each(function(){ $(this).css("position", "absolute"); $(this).css("left", posArray[i].x); $(this).css("top", posArray[i].y); i++; });
  2552. return posArray;
  2553. }
  2554. function filterContent( container, selector, originalDataPos, onCompleteFunction ){
  2555. var i = 0;
  2556. var j = 0;
  2557. if( i == 0 && moduleList != null ){moduleList.disableList();}
  2558. container.children().each(
  2559. function(){
  2560. if($(this).attr("data-id") != selector && selector != "*"){
  2561. TweenMax.to($(this), .6, {css:{opacity:"0", left: originalDataPos[ j ].x, top: originalDataPos[ j ].y }, easing:Sine.easeOut, onComplete:onCompleteFunction, onCompleteParams: [i, container, $(this), true] });
  2562. }
  2563. else{
  2564. var valLeft = originalDataPos[ j ].x;
  2565. var valTop = originalDataPos[ j ].y;
  2566. TweenMax.to($(this), .6, {css:{opacity:"1", left: valLeft, top: valTop}, easing:Sine.easeOut, onComplete:onCompleteFunction, onCompleteParams: [i, container, $(this), false] });
  2567. j++;
  2568. }
  2569. i++;
  2570. });
  2571. }
  2572. function getDirectionCSS( $element, coordinates ){
  2573. /** the width and height of the current div **/
  2574. var w = $element.width(), h = $element.height(),
  2575. /** calculate the x and y to get an angle to the center of the div from that x and y. **/ /** gets the x value relative to the center of the DIV and "normalize" it **/
  2576. x = ( coordinates.x - $element.offset().left - ( w/2 )) * ( w > h ? ( h/w ) : 1 ),
  2577. y = ( coordinates.y - $element.offset().top - ( h/2 )) * ( h > w ? ( w/h ) : 1 ),
  2578. /** the angle and the direction from where the mouse came in/went out clockwise (TRBL=0123);**/
  2579. /** first calculate the angle of the point, add 180 deg to get rid of the negative values divide by 90 to get the quadrant
  2580. add 3 and do a modulo by 4 to shift the quadrants to a proper clockwise TRBL (top/right/bottom/left) **/
  2581. direction = Math.round( ( ( ( Math.atan2(y, x) * (180 / Math.PI) ) + 180 ) / 90 ) + 3 ) % 4;
  2582. var fromClass, toClass;
  2583. switch( direction ) {
  2584. case 0:/* from top */
  2585. fromClass = {instance:'hover-slideFromTop', val1: "0px", val2:"-100%"};
  2586. toClass = {instance:'hover-slideTopLeft', val1: "0px", val2:"0px"};
  2587. break;
  2588. case 1:/* from right */
  2589. fromClass = {instance:'hover-slideFromRight', val1: "100%", val2:"0px"};
  2590. toClass = {instance:'hover-slideTopLeft', val1: "0px", val2:"0px"};
  2591. break;
  2592. case 2:/* from bottom */
  2593. fromClass = {instance:'hover-slideFromBottom', val1: "0px", val2:"100%"};
  2594. toClass = {instance:'hover-slideTopLeft', val1: "0px", val2:"0px"};
  2595. break;
  2596. case 3:/* from left */
  2597. fromClass = {instance:'hover-slideFromLeft', val1: "-100%", val2:"0px"};
  2598. toClass = {instance:'hover-slideTopLeft', val1: "0px", val2:"0px"};
  2599. break;
  2600. };
  2601. return { from : fromClass, to: toClass };
  2602. }
  2603. function animateThumb( img ){ TweenMax.to( img, 0.4, {css:{opacity:"1"}, easing:Sine.easeOut}); }
  2604. var initialColumns = 0;
  2605. var maxColumns = 4;
  2606. function checkColumnSize( adjustPreview ){
  2607. var textPageInstanceHolder = $( txt_modCont);
  2608. var textPageInstance = $( "#module-columns", textPageInstanceHolder);
  2609. var modulePositionType = textPageInstanceHolder.attr("data-id");
  2610. var container = $("#module-columns-holder", textPageInstance);
  2611. var marginRight = parseInt($("div:first", container).css("margin-right"), 10);
  2612. var marginBottom = parseInt($("div:first", container).css("margin-bottom"), 10);
  2613. var elementW = $("div:first", container).width();
  2614. var thumbType = $("div:first", container).attr("class");
  2615. var elementH = $("div:first", container).height();
  2616. var visibleWidth = $("#module-container").width();
  2617. var columns = Math.round(visibleWidth / (elementW + marginRight));
  2618. if( textPageInstance.length <= 0 ) return;
  2619. if( thumbType == "fourth-thumb-holder"){ maxColumns = 4; }
  2620. if( thumbType == "third-thumb-holder"){ maxColumns = 3; }
  2621. if( thumbType == "half-thumb-holder"){ maxColumns = 2; }
  2622. var maxWidth = (columns > 1) ? textPageInstance.width() : container.width();
  2623. if( columns > maxColumns ){ columns = maxColumns; }
  2624. initialColumns = columns;
  2625. var prevMedia = $(".columns-preview-media");
  2626. var prevDesc = $(".columns-preview-description");
  2627. var thumbNewW = columns * ( elementW + marginRight ) - marginRight
  2628. var newWidth = thumbNewW + parseInt($("#module-columns-container").css("margin-left"), 10) + parseInt($("#module-columns-container").css("margin-right"), 10);
  2629. if( visibleWidth < newWidth ){
  2630. if( columns > 1 )columns--;
  2631. else initialColumns--;
  2632. }
  2633. else if( visibleWidth > newWidth ){ initialColumns--; }
  2634. if( adjustPreview != undefined && adjustPreview == true ){
  2635. var thumbNewW = columns * ( elementW + marginRight ) - marginRight
  2636. var newWidth = thumbNewW + parseInt($("#module-columns-container").css("margin-left"), 10) + parseInt($("#module-columns-container").css("margin-right"), 10);
  2637. $("#module-columns-preview-holder", textPageInstance).css("width", thumbNewW + "px");
  2638. if( thumbNewW < 768 ){
  2639. prevMedia.css("width", thumbNewW + "px");
  2640. prevDesc.css("margin-left", "0px" ).css("width", "100%");
  2641. }
  2642. else{
  2643. prevMedia.css("width", "" );
  2644. prevDesc.css("margin-left", "" ).css("width", "");
  2645. }
  2646. var previewWidth = thumbNewW;
  2647. if( columnsPreviewOpen == false ){ $("#module-columns-preview", textPageInstance).css("display", "inline"); }
  2648. $(textPageInstance).find(".columns-preview-horizontal-fix").each(
  2649. function(){
  2650. var columPrevItemHolder = $("ul", this);
  2651. var columPrevItem = $("ul li",this);
  2652. $(this).css("width", 9999999);
  2653. columPrevItem.each(function(){$(this).css("width", previewWidth);});
  2654. var realW = columPrevItemHolder.width();
  2655. columPrevItem.each(function(){if( columnsPreviewOpen == false ) $(this).css("display", "none");});
  2656. $(this).css("width", previewWidth );
  2657. columPrevItemHolder.css("width", realW );
  2658. });
  2659. var prevListW = $("#module-columns-preview-holder").width();
  2660. var elMargR = parseInt($("li:first",".columns-preview-horizontal-fix ul").css("margin-right"), 10 );
  2661. $(".columns-preview-horizontal-fix ul").css("left", -(columnsPreviewIndex * (prevListW + elMargR)));
  2662. }
  2663. if( initialColumns != columns ){
  2664. var lin = 0;
  2665. var col = 0
  2666. var newH = 0;
  2667. var count = 0;
  2668. var total = container.children().length;
  2669. container.children().each(
  2670. function(){
  2671. if( col < columns ){
  2672. var topVal = lin * ( elementH + marginBottom );
  2673. var leftVal = col * ( elementW + marginRight );
  2674. $(this).css("position", "absolute").css("left", leftVal + "px").css("top", topVal + "px");
  2675. col++;
  2676. }
  2677. else{
  2678. col = 0;
  2679. lin++;
  2680. var topVal = lin * ( elementH + marginBottom );
  2681. var leftVal = col * ( elementH + marginRight );
  2682. $(this).css("position", "absolute").css("left", leftVal + "px").css("top", topVal + "px");
  2683. col++;
  2684. }
  2685. $(this).css("opacity", "1");
  2686. if( count == total - 1 ){ newH = parseInt($(this).css("top"), 10 ) + $(this).height(); }
  2687. count++;
  2688. }
  2689. );
  2690. $originalDataPos = getOriginalPos( container );
  2691. var thumbNewW = columns * ( elementW + marginRight ) - marginRight
  2692. var newWidth = thumbNewW + parseInt($("#module-columns-container").css("margin-left"), 10) + parseInt($("#module-columns-container").css("margin-right"), 10);
  2693. $("#module-columns").css("width", newWidth + "px");
  2694. $("#module-columns-container").css("width", thumbNewW + "px");
  2695. container.css("height", newH + "px");
  2696. container.css("width", thumbNewW + "px");
  2697. $("#module-columns-preview-holder", textPageInstance).css("width", thumbNewW + "px");
  2698. if( thumbNewW < 768 ){
  2699. prevMedia.css("width", thumbNewW + "px");
  2700. prevDesc.css("margin-left", "0px" ).css("width", "100%");
  2701. }
  2702. else{
  2703. prevMedia.css("width", "" );
  2704. prevDesc.css("margin-left", "" ).css("width", "");
  2705. }
  2706. }
  2707. var columnPrevWrapper = $( "#module-columns-preview-wrapper", textPageInstanceHolder);
  2708. var previewWidth = $( "#module-columns-preview-holder", columnPrevWrapper).width();
  2709. if( columnsPreviewOpen == false ){ columnPrevWrapper.css("display", "inline"); }
  2710. $(columnPrevWrapper, textPageInstance).find(".columns-preview-horizontal-fix").each(
  2711. function(){
  2712. $(this).css("width", 9999999);
  2713. var cPIH = $("ul", this);
  2714. var cPI = $("ul li",this);
  2715. cPI.each(function(){ $(this).css("width", previewWidth); });
  2716. cPIH.css("width", cPIH.width() );
  2717. $(this).css("width", previewWidth);
  2718. cPI.each(function(){ if( columnsPreviewOpen == false ){ $(this).css("display", "none"); } });
  2719. });
  2720. if( columnsPreviewOpen == false ){ columnPrevWrapper.css("display", "none"); }
  2721. }
  2722. function colPreviewItemDisplay( display ){
  2723. var i = 0;
  2724. for( i; i < totalColPreviews; i++){columnsPrevItemArr[ i ].css("display", display);}
  2725. }
  2726. function animateColPreviewMedia( src ){
  2727. var inst = $(src);
  2728. var parent = $(src).parent();
  2729. if(touchDevice == 0){TweenMax.to($(src).parent(), .3, {css:{ height: inst.height()}, easing:Sine.easeOut});}
  2730. else{parent.css("height", inst.height());}
  2731. previewAnimDone = true;
  2732. TweenMax.to(inst, .5, {css:{ opacity:'1'}, easing:Sine.easeOut, delay:0.1, onComplete: moduleUpdate_page_columns});
  2733. }
  2734. /*================= GALLERY ================================*/
  2735. var galleryList = null;
  2736. var galleryPreviewMediaArr = new Array();
  2737. var galleryPreviewDescArr = new Array();
  2738. var currGalleryThumbID = 0;
  2739. var currPreviewElem = "";
  2740. var visibleGalleryH = 0;
  2741. var galleryColumns = 0;
  2742. var galleryLines = 0;
  2743. var galleryVisibleThumbs = 0;
  2744. var previewGalleryOpen = false;
  2745. var galleryItemArr = new Array();
  2746. function moduleGallery(){
  2747. var textPageInstanceHolder = $( txt_modCont);
  2748. var textPageInstance = $( "#module-galleries", textPageInstanceHolder);
  2749. if( textPageInstance.length <= 0 ){return;}
  2750. var moduleWidth = textPageInstanceHolder.width();
  2751. var moduleHeight = textPageInstanceHolder.height();
  2752. var galleryHolder = $("#module-galleries-holder", textPageInstance);
  2753. var thumbMarginRight = parseInt($(".thumb-holder").css("margin-right"), 10);
  2754. var thumbMarginBottom = parseInt($(".thumb-holder").css("margin-bottom"), 10);
  2755. var thumbWidth = $(".thumb-holder").width();
  2756. var thumbHeight = $(".thumb-holder").height();
  2757. var containerWidth = galleryHolder.width();
  2758. var containerHeight = galleryHolder.height();
  2759. var visibleHeight = textPageInstance.height();
  2760. var numberColumns = Math.round( containerWidth / ( thumbWidth + thumbMarginRight) );
  2761. var numberLines = Math.floor( visibleHeight / ( thumbHeight + thumbMarginBottom) + 1);
  2762. var totalVisibleThumbs = numberColumns * numberLines - 1;
  2763. var windowH = $(window).height() + 50;
  2764. visibleGalleryH = visibleHeight;
  2765. galleryColumns = numberColumns;
  2766. galleryLines = numberLines;
  2767. galleryItemArr = [];
  2768. setPreview();
  2769. storePreviewMedia();
  2770. addControlsListeners();
  2771. if( $(window).width() < 480 && galleryColumns > 2 ) galleryColumns = 1;
  2772. $(".thumb-holder" + ":nth-child(" + galleryColumns + "n+" + galleryColumns + ")", galleryHolder).css("margin-right", "0px");
  2773. moduleUpdate( textPageInstanceHolder, textPageInstance, $("div:first", textPageInstance), sideType );
  2774. textPageInstanceHolder.css("visibility", "visible");
  2775. var galleryItem = $("#module-galleries-holder .thumb-holder", textPageInstance);
  2776. var backgOverColor = "#3f3f3f";
  2777. var backgOutColor = rgb2hex( galleryItem.css("background-color") );
  2778. var text1BaseColor = rgb2hex( $(".thumb-tag p", galleryItem).css("color") );
  2779. if( touchDevice == 0 )galleryItem.hover(
  2780. function(event){
  2781. customHoverAnimation( "over", event, $(this), $("#thumb-image-hover", this) );
  2782. var text = $(".thumb-tag p", this);
  2783. TweenMax.to( text, .6, { css:{ color: backgOutColor }, ease:Quad.easeOut });
  2784. TweenMax.to( $(this), .6, { css:{ backgroundColor: backgOverColor }, ease:Quad.easeOut });
  2785. },
  2786. function(event){
  2787. customHoverAnimation( "out", event, $(this), $("#thumb-image-hover", this) );
  2788. var text = $(".thumb-tag p", this);
  2789. TweenMax.to( text, .6, { css:{ color: text1BaseColor }, ease:Circ.easeOut });
  2790. TweenMax.to( $(this), .6, { css:{ backgroundColor: backgOutColor }, ease:Quad.easeOut });
  2791. });
  2792. galleryItem.click(
  2793. function() {
  2794. var index = $(".thumb-holder").index( this );
  2795. currGalleryThumbID = index;
  2796. currPreviewElem = galleryPreviewMediaArr[ index ];
  2797. setPreviewLoadHTML();
  2798. TweenMax.to( textPageInstance, .6, { css:{ opacity: "0" }, ease:Circ.easeOut, onComplete: showGalleryPreview });
  2799. if( moduleList != null ){moduleList.disableList();}
  2800. });
  2801. var childLength = galleryHolder.children().length - 1;
  2802. totalVisibleThumbs = ( childLength < totalVisibleThumbs ) ? childLength : totalVisibleThumbs;
  2803. galleryVisibleThumbs = totalVisibleThumbs+1;
  2804. var i = 0;
  2805. var tempI = 0;
  2806. var tempJ = 0;
  2807. var onceD = true;
  2808. galleryHolder.find(".thumb-holder").each(
  2809. function(){
  2810. if( i > totalVisibleThumbs){$(this).css("display", "none");}
  2811. else{$(this).css("top", windowH + "px");}
  2812. galleryItemArr[ i ] = $(this);
  2813. i++;
  2814. });
  2815. i = 0
  2816. var tempI = 0;
  2817. var tempJ = 0;
  2818. var onceD = true;
  2819. galleryHolder.find(".thumb-holder").each(
  2820. function(){
  2821. if( i <= totalVisibleThumbs ){
  2822. tempI = Math.floor( i / (numberColumns));
  2823. tempJ = (i - (tempI * (numberColumns))) * 0.15;
  2824. tempI = tempI * 0.1;
  2825. var delay = (0.1 )+ (tempJ) + (tempI);
  2826. if( i == totalVisibleThumbs ){TweenMax.to( $(this), .6, { css:{ top:"0px" }, delay: delay, ease:Circ.easeOut, onComplete: afterGalleryStartupAnimation, onCompleteParams:[ visibleHeight ] });}
  2827. else{TweenMax.to( $(this), .6, { css:{ top:"0px" }, delay: delay, ease:Circ.easeOut });}
  2828. }
  2829. else{ return;}
  2830. i++;
  2831. });
  2832. endModuleFunction = endModuleGallery;
  2833. moduleEnd = true;
  2834. return;
  2835. }
  2836. var moduleEnd = true;
  2837. function endModuleGallery( reverse ){
  2838. var textPageInstanceHolder = $( txt_modCont);
  2839. var textPageInstance = $( "#module-galleries", textPageInstanceHolder);
  2840. var galleryHolder = $("#module-galleries-holder", textPageInstance);
  2841. var thumbInstance = $(".thumb-holder", textPageInstance);
  2842. var thumbHeight = thumbInstance.height() + parseInt(thumbInstance.css("margin-bottom"), 10);
  2843. var containerPos = parseInt(galleryHolder.css("top"), 10);
  2844. var currLine = Math.floor(Math.abs( containerPos / thumbHeight ));
  2845. var startNumber = currLine * galleryColumns;
  2846. var endNumber = startNumber + galleryVisibleThumbs;
  2847. var windowH = $(window).height() + 50;
  2848. var totalVisibleThumbs = galleryColumns * galleryLines - 1;
  2849. var childLength = galleryHolder.children().length - 1;
  2850. var currH = galleryHolder.height()
  2851. var i = 0;
  2852. var t = galleryItemArr.length;
  2853. if( reverse == true ){
  2854. totalVisibleThumbs = ( childLength < totalVisibleThumbs ) ? childLength : totalVisibleThumbs;
  2855. while(t--){
  2856. if( t >= totalVisibleThumbs){galleryItemArr[t].css("display", "none");}
  2857. else{galleryItemArr[t].css("top", windowH + "px");}
  2858. }
  2859. }
  2860. else{
  2861. t = galleryItemArr.length;
  2862. while(t--){
  2863. if( t < startNumber || t >= endNumber ){ galleryItemArr[t].css("display", "none");}
  2864. }
  2865. }
  2866. if( currH > $(window).height() ){ galleryHolder.css("top", "0px"); }
  2867. i = 0;
  2868. var j = 0;
  2869. var tempI = 0;
  2870. var tempJ = 0;
  2871. var onceD = true;
  2872. if( reverse == true ){
  2873. moduleEnd = true;
  2874. galleryHolder.find(".thumb-holder").each(
  2875. function(){
  2876. if( i <= totalVisibleThumbs ){
  2877. tempI = Math.floor( i / (galleryColumns));
  2878. tempJ = (i - (tempI * (galleryColumns))) * 0.15;
  2879. tempI = tempI * 0.1;
  2880. var delay = (0.1 )+ (tempJ) + (tempI);
  2881. TweenMax.killTweensOf( $(this) );
  2882. if( i == totalVisibleThumbs ){TweenMax.to( $(this), .6, { css:{ top:"0px" }, delay: delay, ease:Circ.easeOut, onComplete: showOtherThumbs, onCompleteParams:[galleryHolder] });}
  2883. else{TweenMax.to( $(this), .6, { css:{ top:"0px" }, delay: delay, ease:Circ.easeOut });}
  2884. }
  2885. else{ return;}
  2886. i++;
  2887. });
  2888. }
  2889. else{
  2890. t = galleryItemArr.length;
  2891. i = 0;
  2892. while(t--){
  2893. if( t >= startNumber ){
  2894. tempI = Math.floor( i / (galleryColumns));
  2895. tempJ = (i - (tempI * (galleryColumns))) * 0.15;
  2896. tempI = tempI * 0.1;
  2897. var delay = (0.1 )+ (tempJ) + (tempI);
  2898. if( t == startNumber && reverse == true)
  2899. {TweenMax.to( galleryItemArr[t], 0.8, { css:{ top: windowH + "px" }, delay: delay, ease:Circ.easeInOut, onComplete: showOtherThumbs, onCompleteParams:[galleryHolder]});}
  2900. else
  2901. {TweenMax.to( galleryItemArr[t], 0.8, { css:{ top: windowH + "px" }, delay: delay, ease:Circ.easeInOut});}
  2902. if( onceD == true && $("#dragger-holder").length > 0 ){
  2903. onceD = false;
  2904. TweenMax.to( $("#dragger-holder"), 0.8, { css:{ top: windowH + "px" }, ease:Circ.easeInOut });
  2905. }
  2906. i++;
  2907. }
  2908. }
  2909. }
  2910. if(reverse == undefined )endModuleFunction = null;
  2911. }
  2912. function showOtherThumbs( galleryHolder ){
  2913. galleryHolder.find(".thumb-holder").each( function(){ $(this).css("display", "inline").css("top", "0px"); } );
  2914. }
  2915. function afterGalleryStartupAnimation( visibleH ){
  2916. var textPageInstanceHolder = $( txt_modCont);
  2917. var textPageInstance = $( "#module-galleries", textPageInstanceHolder);
  2918. if( textPageInstance.length <= 0){return;}
  2919. $("#module-galleries-holder", textPageInstance).find(".thumb-holder").each( function(){ $(this).css("display", "inline"); } );
  2920. $("#module-galleries-preview").wipetouch({
  2921. tapToClick: false, /* if user taps the screen, triggers a click event*/
  2922. preventDefault:false,/* if user taps the screen, triggers a click event*/
  2923. wipeLeft: function(result) { wipeChange( 1 ); },
  2924. wipeRight: function(result) { wipeChange( -1 ); }
  2925. });
  2926. }
  2927. function wipeChange( idx ){
  2928. var prevMediaChild = $("#preview-media-holder :first");
  2929. TweenMax.to($(".gallery-preview-media-loader"), .3, {css:{opacity:"1"}, delay:.3, easing:Sine.easeOut});
  2930. TweenMax.to(prevMediaChild, .4, {css:{opacity: "0"}, easing:Sine.easeOut, onComplete:
  2931. function(){
  2932. changePreviewMedia( idx );
  2933. }
  2934. });
  2935. }
  2936. function storePreviewMedia(){
  2937. galleryPreviewMediaArr = new Array();
  2938. galleryPreviewDescArr = new Array();
  2939. var i = 0;
  2940. $("#module-galleries-preview").find("#preview-media-holder").children().each(
  2941. function(){
  2942. if( $(this).attr("id") == "preview-media-image" ){
  2943. galleryPreviewMediaArr[ i ] = '<img id="preview-media-image" src="' + $(this).attr("data-url") +
  2944. '" title="' + $(this).attr("data-title") + '"' +
  2945. ' alt="' + $(this).attr("data-alt") +'" />';
  2946. }
  2947. else if( $(this).attr("id") == "video-wrapper"){
  2948. var videoType = $(this).attr("data-type");
  2949. galleryPreviewMediaArr[ i ] = $(this);
  2950. }
  2951. var descTxt = $(":first", this);
  2952. if( $(":first", this).length > 0){ galleryPreviewDescArr[ i ] = descTxt; }
  2953. else{ galleryPreviewDescArr[ i ] = undefined; }
  2954. i++;
  2955. });
  2956. i = 0;
  2957. var total = galleryPreviewDescArr.length;
  2958. var descHolder = $("#module-galleries-preview-description-holder");
  2959. for( i = 0; i < total; i++){
  2960. if( descHolder.length > 0 && galleryPreviewDescArr[ i ] != undefined ){ descHolder.append(galleryPreviewDescArr[ i ]); }
  2961. }
  2962. setPreviewLoadHTML();
  2963. }
  2964. function isIE9Std() {
  2965. var a;
  2966. try{var b=arguments.caller.length;a=0;}catch(e){a=1;}
  2967. return((document.all&&a)==1);
  2968. }
  2969. function setPreviewLoadHTML(){
  2970. $("#module-galleries-preview").find("#preview-media-holder").empty();
  2971. }
  2972. function setPreview(){
  2973. var galleriesPreview = $("#module-galleries-preview");
  2974. if( galleriesPreview.length > 0 ){
  2975. galleriesPreview.remove();
  2976. $("#template-wrapper").after(galleriesPreview);
  2977. }
  2978. }
  2979. function showGalleryPreview(){
  2980. previewGalleryOpen = true;
  2981. var modGallPrev = $("#module-galleries-preview");
  2982. $("#module-galleries").attr("style", "display: none; visibility: visible;");
  2983. modGallPrev.css("opacity", "0");
  2984. modGallPrev.css("display", "inline");
  2985. modGallPrev.css("visibility", "visible");
  2986. changeGalleryPreviewDescription( -1, currGalleryThumbID)
  2987. TweenMax.to( modGallPrev, .6, { css:{ opacity: "1" }, ease:Circ.easeOut, onComplete: showGalleryPreviewMedia });
  2988. }
  2989. function showGalleryPreviewMedia(){
  2990. if( $(currPreviewElem).attr("id") == "preview-media-image" ){
  2991. /*PLAY MEDIA IMAGE*/
  2992. $("#module-galleries-preview").find("#preview-media-holder").append('<img id="preview-media-load" onload="animatePreviewMedia()" title="" alt="" />');
  2993. var prevMediaLoad = $("#preview-media-load");
  2994. prevMediaLoad.attr("style", "visibility: visible; display: inline");
  2995. prevMediaLoad.css("opacity", "0" );
  2996. prevMediaLoad.attr("src", $(currPreviewElem).attr("src") ).attr("title", $(currPreviewElem).attr("title") ).attr("alt", $(currPreviewElem).attr("alt") );
  2997. }
  2998. else if( $(currPreviewElem).attr("id") == "video-wrapper" ){
  2999. /*PLAY MEDIA VIDEO*/
  3000. $("#module-galleries-preview").find("#preview-media-holder").find("#video-wrapper").remove();
  3001. var descHeight = ($("#module-galleries-preview-description-holder").length > 0) ? $("#module-galleries-preview-description-holder").height() : 0;
  3002. if( previewDescriptionActive == false ) descHeight = 0;
  3003. var prevMediaHolder = $("#preview-media-holder");
  3004. var mediaBackNewW = parseInt($(currPreviewElem).attr("data-width"), 10) + previewBorderSize*2;
  3005. var mediaBackNewH = parseInt($(currPreviewElem).attr("data-height"), 10) + previewBorderSize*2;
  3006. var mediaBackMarginTop = - mediaBackNewH * .5 - descHeight * .5;
  3007. var mediaBackMarginLeft = - mediaBackNewW * .5;
  3008. prevMediaHolder.attr("style", "width: " + mediaBackNewW + "px; height: " + mediaBackNewH + "px; margin: 0px; top: 50%; left: 50%; margin-top:" + mediaBackMarginTop + "px; margin-left:" + mediaBackMarginLeft + "px;");
  3009. $("#preview-media-holder").append('<div id="video-wrapper"></div>')
  3010. templateAddMediaVideo( $(currPreviewElem).attr("data-video-type"), $(currPreviewElem), $("#video-wrapper") );
  3011. TweenMax.to($(".gallery-preview-media-loader"), .3, {css:{opacity:"0"}, easing:Sine.easeOut});
  3012. loadingAnimationDone = true;
  3013. fadeInMedia("");
  3014. }
  3015. }
  3016. function addControlsListeners(){
  3017. if( touchDevice == 0 ){
  3018. var initOpacity = $(".module-galleries-preview-arrow-backward .module-galleries-preview-arrow-backg").css("opacity");
  3019. var initBackColor = rgb2hex( $(".module-galleries-preview-arrow-backward .module-galleries-preview-arrow-backg").css("background-color") );
  3020. var prevControls = $(".module-galleries-preview-arrow-backward, .module-galleries-preview-arrow-forward, .module-galleries-preview-arrow-close");
  3021. prevControls.unbind('mouseenter mouseleave');
  3022. prevControls.hover(
  3023. function(){
  3024. TweenMax.to( $(".module-galleries-preview-arrow-backg", this), 0.3, {css:{opacity: "1", backgroundColor: themeColor }, easing:Sine.easeOut });
  3025. },
  3026. function(){
  3027. TweenMax.to( $(".module-galleries-preview-arrow-backg", this), 0.3, {css:{opacity: initOpacity, backgroundColor: initBackColor}, easing:Sine.easeOut });
  3028. });
  3029. }
  3030. var prevArrBack = $(".module-galleries-preview-arrow-backward");
  3031. var prevArrForw = $(".module-galleries-preview-arrow-forward")
  3032. prevArrBack.unbind("click");
  3033. prevArrBack.click(
  3034. function(){
  3035. TweenMax.to($(".gallery-preview-media-loader"), .3, {css:{opacity:"1"}, easing:Sine.easeOut});
  3036. changePreviewMedia( -1 );
  3037. });
  3038. prevArrForw.unbind("click");
  3039. prevArrForw.click(
  3040. function(){
  3041. TweenMax.to($(".gallery-preview-media-loader"), .3, {css:{opacity:"1"}, easing:Sine.easeOut});
  3042. changePreviewMedia( 1 );
  3043. });
  3044. var prevArrClose = ".module-galleries-preview-arrow-close";
  3045. var prevBackg = "#module-galleries-preview-background";
  3046. $(prevBackg).unbind("click");
  3047. $(prevArrClose).unbind("click");
  3048. $(prevArrClose + "," + prevBackg).click(
  3049. function(){
  3050. firstDescRun = true;
  3051. if( $(currPreviewElem).attr("id") == "preview-media-image" ){ TweenMax.to( $("#preview-media-load"), .3, { css:{ opacity: "0" }, ease:Circ.easeOut }); }
  3052. else if( $(currPreviewElem).attr("id") == "video-wrapper" ){
  3053. setPreviewLoadHTML();
  3054. TweenMax.to( $(currPreviewElem), .3, { css:{ opacity: "0" }, ease:Circ.easeOut });
  3055. }
  3056. if(previewDescriptionActive == true )TweenMax.to( $("#module-galleries-preview-description-holder"), .3, { css:{ bottom: "-60px" }, ease:Circ.easeOut });
  3057. TweenMax.to( $("#module-galleries-preview"), .6, { css:{ opacity: "0" }, ease:Circ.easeOut, delay:0.3, onComplete: onClosePreviewComplete });
  3058. });
  3059. }
  3060. var loadingAnimationDone = true;
  3061. var previewDescriptionActive = true;
  3062. function changePreviewMedia( value ){
  3063. var nextThumbID = currGalleryThumbID + value;
  3064. if( nextThumbID > galleryPreviewMediaArr.length - 1 ){ nextThumbID = 0; }
  3065. else if( nextThumbID < 0 ){ nextThumbID = galleryPreviewMediaArr.length - 1; }
  3066. if( currGalleryThumbID != nextThumbID ){
  3067. if( $(currPreviewElem).attr("id") == "preview-media-image" ){ $("#preview-media-load").css("opacity", 0 ).css("visibility", "hidden").css("display", "none"); }
  3068. else if( $(currPreviewElem).attr("id") == "video-wrapper" ){ $(currPreviewElem).css("opacity", "0" ).css("visibility", "hidden").css("display", "none"); }
  3069. changeGalleryPreviewDescription( currGalleryThumbID, nextThumbID)
  3070. currGalleryThumbID = nextThumbID;
  3071. currPreviewElem = galleryPreviewMediaArr[ currGalleryThumbID ];
  3072. setPreviewLoadHTML();
  3073. showGalleryPreviewMedia();
  3074. }
  3075. }
  3076. function changeGalleryPreviewDescription( pID, cID){
  3077. if( pID != -1 ){
  3078. var pDesc = galleryPreviewDescArr[ pID ];
  3079. if( pDesc != undefined)
  3080. TweenMax.to( $(pDesc), .4, { css:{ opacity: "0" }, ease:Circ.easeOut, onComplete: hidePrevDescText, onCompleteParams: [ pID ] });
  3081. }
  3082. if( cID != -1 ){
  3083. var cDesc = galleryPreviewDescArr[ cID ];
  3084. if( cDesc == undefined){
  3085. previewDescriptionActive = false;
  3086. firstDescRun = true;
  3087. TweenMax.to( $("#module-galleries-preview-description-holder"), .4, { css:{ bottom: "-60px" }, ease:Circ.easeOut });
  3088. return;
  3089. }
  3090. else {previewDescriptionActive = true;}
  3091. $(cDesc).css("opacity", "0").css("visibility", "visible").css("display", "inline");
  3092. TweenMax.to( $(cDesc), .6, { css:{ opacity: "1" }, ease:Circ.easeOut });
  3093. }
  3094. }
  3095. function hidePrevDescText( pID ){
  3096. var pDesc = galleryPreviewDescArr[ pID ];
  3097. $(pDesc).css("opacity", "0").css("visibility", "hidden").css("display", "none");
  3098. }
  3099. function updatePreviewMediaPosition(){
  3100. var visibleWidth = $( window ).width() - previewBorderSize*2;
  3101. var visibleHeight = $( window ).height() - 36;
  3102. var elem = "";
  3103. var mediaType = $(currPreviewElem).attr("id");
  3104. if( mediaType == "preview-media-image" ){
  3105. elem = $("#preview-media-load");
  3106. elem.css("width", '').css("height", '');
  3107. checkSizeMedia( $(elem), visibleWidth, visibleHeight );
  3108. }
  3109. if( $(elem).width() != null ){
  3110. var mediaBackNewW = $(elem).width() + previewBorderSize*2;
  3111. var mediaBackNewH = $(elem).height() + previewBorderSize*2;
  3112. var mediaBackMarginTop = - mediaBackNewH * .5 - 18;
  3113. var mediaBackMarginLeft = - mediaBackNewW * .5;
  3114. var prevMediaHolder = $("#preview-media-holder");
  3115. prevMediaHolder.attr("style", "width: " + $(elem).width() + "px; height: " + $(elem).height() + "px; margin: 0px; top: 50%; left: 50%; margin-top:" + mediaBackMarginTop + "px; margin-left:" + mediaBackMarginLeft + "px;");
  3116. }
  3117. }
  3118. function onClosePreviewComplete(){
  3119. setPreviewLoadHTML();
  3120. var prevMediaLoad = $("#preview-media-load");
  3121. var modGallPrev = $("#module-galleries-preview");
  3122. var modGall = $("#module-galleries");
  3123. if( $(currPreviewElem).attr("id") == "preview-media-image" ){ prevMediaLoad.css("opacity", 0 ).css("visibility", "hidden").css("display", "none"); }
  3124. if( $(currPreviewElem).attr("id") == "preview-media-video" ){ prevMediaLoad.css("opacity", 0 ); }
  3125. modGallPrev.css("opacity", "0").css("display", "none").css("visibility", "hidden");
  3126. modGall.css("opacity", "0").css("display", "inline").css("visibility", "visible");
  3127. previewGalleryOpen = false;
  3128. changeGalleryPreviewDescription(currGalleryThumbID, -1)
  3129. var textPageInstanceHolder = $(txt_modCont);
  3130. var textPageInstance = $( "#module-galleries", textPageInstanceHolder);
  3131. if( moduleList != null ){ moduleList.enableList(); }
  3132. moduleUpdate( textPageInstanceHolder, textPageInstance, $("div:first", textPageInstance), sideType, true, false );
  3133. TweenMax.to( textPageInstance, .6, { css:{ opacity: "1" }, ease:Circ.easeOut });
  3134. }
  3135. function animatePreviewMedia(){
  3136. var descHeight = ($("#module-galleries-preview-description-holder").length > 0) ? $("#module-galleries-preview-description-holder").height() : 0;
  3137. if( previewDescriptionActive == false ) descHeight = 0;
  3138. var visibleWidth = $( window ).width() - previewBorderSize*2;
  3139. var visibleHeight = $( window ).height() - descHeight;
  3140. var elem = "";
  3141. var mediaType = $(currPreviewElem).attr("id");
  3142. if( mediaType == "preview-media-image" ) {
  3143. elem = $("#preview-media-load");
  3144. checkSizeMedia( $(elem), visibleWidth, visibleHeight );
  3145. }
  3146. if( $(elem).width() != null ){
  3147. var mediaBackNewW = $(elem).width() + previewBorderSize*2;
  3148. var mediaBackNewH = $(elem).height() + previewBorderSize*2;
  3149. var mediaBackMarginTop = - mediaBackNewH * .5 - descHeight * .5;
  3150. var mediaBackMarginLeft = - mediaBackNewW * .5;
  3151. var prevMediaHolder = $("#preview-media-holder");
  3152. prevMediaHolder.attr("style", "width: " + $(elem).width() + "px; height: " + $(elem).height() + "px; margin: 0px; top: 50%; left: 50%; margin-top:" + mediaBackMarginTop + "px; margin-left:" + mediaBackMarginLeft + "px;");
  3153. TweenMax.to($(".gallery-preview-media-loader"), .3, {css:{opacity:"0"}, easing:Sine.easeOut});
  3154. loadingAnimationDone = true;
  3155. fadeInMedia( mediaType );
  3156. }
  3157. }
  3158. var firstDescRun = true;
  3159. function fadeInMedia( mediaType ){
  3160. if( mediaType == "preview-media-image" ){ TweenMax.to( $("#preview-media-load"), .6, { css:{ opacity: "1" }, ease:Circ.easeOut }); }
  3161. if( firstDescRun == true && previewDescriptionActive == true ){
  3162. firstDescRun = false;
  3163. TweenMax.to( $("#module-galleries-preview-description-holder"), .6, { css:{ bottom: "0px" }, delay: 0.5, ease:Circ.easeOut });
  3164. }
  3165. }
  3166. function checkSizeMedia( image, w, h ){
  3167. var imageW = image.width();
  3168. var imageH = image.height();
  3169. var scale = 1;
  3170. var newImageW;
  3171. var newImageH;
  3172. if( imageW > w && imageH > h){
  3173. newImageW = w; newImageH = imageH / imageW * newImageW;
  3174. if( imageH > h ){ newImageW = imageW / imageH * h; newImageH = h;}
  3175. }
  3176. else if( imageW > w && imageH < h ){ newImageW = w; newImageH = imageH / imageW * newImageW; }
  3177. else if( imageW < w && imageH > h ){ newImageH = h; newImageW = newImageH / imageH * imageW; }
  3178. else if( imageW < w && imageH < h ){ newImageW = imageW; newImageH = imageH; }
  3179. image.width(newImageW);
  3180. image.height(newImageH);
  3181. }
  3182. function gallerySizeMedia( image , w, h ){
  3183. var imageW = image.width();
  3184. var imageH = image.height();
  3185. var scale = 1;
  3186. /* image aspect ratio is wider than browser window*/
  3187. if (imageW / imageH > w / h) { scale = h / imageH; }
  3188. else { scale = w / imageW; }
  3189. var newImageW = imageW * scale;
  3190. var newImageH = imageH * scale;
  3191. image.width(newImageW);
  3192. image.height(newImageH);
  3193. }
  3194. /*----------------- end Modules Methods -------------------*/
  3195. /*----------------- start footerListeners -----------------*/
  3196. function footerListeners(){
  3197. $("#footer-social").find("#footer-social-holder").find("a").each(
  3198. function(){
  3199. var aTitle = $("img", this).attr("title");
  3200. $(this).hover(
  3201. function(){
  3202. $("#footer-social-tooltip").css("opacity", "0");
  3203. $("#footer-social-tooltip").css("display", "inline");
  3204. $("#footer-social-tooltip").css("visibility", "visible");
  3205. $("#footer-social-tooltip").empty();
  3206. $("#footer-social-tooltip").append('<span>' + aTitle + '</span>' );
  3207. TweenMax.to( $("#footer-social-tooltip"), .6, { css:{opacity:"1"}, ease:Circ.easeOut });
  3208. },
  3209. function(){
  3210. $("#footer-social-tooltip").css("opacity", "0");
  3211. $("#footer-social-tooltip").css("display", "none");
  3212. $("#footer-social-tooltip").css("visibility", "hidden");
  3213. $("#footer-social-tooltip").empty();
  3214. });
  3215. });
  3216. }
  3217. /*----------------- end footerListeners -------------------*/
  3218. /*----------------- start menuListeners -------------------*/
  3219. var currModuleType = '';
  3220. var prevModuleType = '';
  3221. var sideType = 'none';
  3222. var prevURL = '';
  3223. var loadURL = '';
  3224. var menuOptionsArr = new Array();
  3225. var menuOptionID = 0;
  3226. var submenuOptionID = -1;
  3227. function storeMenuArr(){
  3228. var extraWidth = $(".template-menu").width() + $("#menu-hider").width();
  3229. $("#template-menu").children().each(function(index, element){
  3230. var menu = $(element),
  3231. subOptArr = "null",
  3232. subHol = "null",
  3233. menOptText = $(".menu-option-text a", menu);
  3234. menuOptionsArr[ index ] = [];
  3235. menuOptionsArr[ index ][ 0 ] = menu;
  3236. if( menu.attr("data-module-type") == undefined ){
  3237. var subMenu = [];
  3238. subHol = menu.find(".sub-menu-holder");
  3239. subHol.children().each(function(index, elem){
  3240. var submenu = $(elem),
  3241. subOptTxt = $(".sub-menu-option-text a", this),
  3242. subOptHref = String(subOptTxt.attr("href")),
  3243. subOptHrefPath = subOptTxt.attr("data-path-href");
  3244. subMenu[ index ] = [];
  3245. subMenu[ index ][ 0 ] = "#" + menOptText.text().toLowerCase() + "/" + subOptHref.replace("#","");
  3246. subMenu[ index ][ 1 ] = [submenu.attr("data-module-type"), submenu.attr("data-side"), subOptHref.replace("#",""), subOptHrefPath];
  3247. subMenu[ index ][ 2 ] = $(".sub-menu-option-background", this);
  3248. subMenu[ index ][ 3 ] = subOptTxt;
  3249. });
  3250. subOptArr = subMenu;
  3251. menuOptionsArr[ index ][ 1 ] = "null";
  3252. }
  3253. else{
  3254. menuOptionsArr[ index ][ 1 ] = [menu.attr("data-module-type"), menu.attr("data-side"), String(menOptText.attr("href")).replace("#",""), menOptText.attr("data-path-href")];
  3255. }
  3256. menuOptionsArr[ index ][ 2 ] = $(".menu-option-background", menu);
  3257. menuOptionsArr[ index ][ 3 ] = ( subOptArr == "null" ) ? [menOptText] : [menOptText, $(".menu-option-text div", menu)];
  3258. menuOptionsArr[ index ][ 4 ] = extraWidth - parseInt( menOptText.css("padding-left"), 10);
  3259. menuOptionsArr[ index ][ 5 ] = subHol;
  3260. menuOptionsArr[ index ][ 6 ] = subOptArr;
  3261. if( touchDevice == 0 )menu.bind("mouseenter mouseleave", {idx: index}, menuOptionHover);
  3262. });
  3263. }
  3264. function menuOptionIn( idx1, idx2 ){
  3265. menuOptionsArr[ idx1 ][ 2 ].attr("class", "menu-option-background-selected");
  3266. TweenMax.to( menuOptionsArr[ idx1 ][ 2 ], menuAnimDuration, { css:{marginLeft: "0px", width: menuWidth}, ease:menuAnimEase });
  3267. TweenMax.to( menuOptionsArr[ idx1 ][ 3 ], menuAnimDuration, { css:{color: "#FFF"}, ease:menuAnimEase });
  3268. if( idx2 != -1 ){
  3269. var subMenu = menuOptionsArr[ idx1 ][ 6 ];
  3270. subMenu[ idx2 ][ 2 ].attr("class", "sub-menu-option-background-selected");
  3271. TweenMax.to( subMenu[ idx2 ][ 2 ], menuAnimDuration, { css:{marginLeft: "0px", width: menuWidth}, ease:menuAnimEase });
  3272. TweenMax.to( subMenu[ idx2 ][ 3 ], menuAnimDuration, { css:{color: "#FFF"}, ease:menuAnimEase });
  3273. }
  3274. }
  3275. function menuOptionOut( idx1, idx2, disableIdx1){
  3276. if( disableIdx1 == undefined){
  3277. menuOptionsArr[ idx1 ][ 2 ].attr("class", "menu-option-background");
  3278. TweenMax.to( menuOptionsArr[ idx1 ][ 2 ], menuAnimDuration, { css:{marginLeft: menuWidth, width: "0px"}, ease:menuAnimEase });
  3279. TweenMax.to( menuOptionsArr[ idx1 ][ 3 ], menuAnimDuration, { css:{color: menuTextOutColor}, ease:menuAnimEase });
  3280. }
  3281. if( idx2 != -1 ){
  3282. var subMenu = menuOptionsArr[ idx1 ][ 6 ];
  3283. subMenu[ idx2 ][ 2 ].attr("class", "sub-menu-option-background");
  3284. TweenMax.to( subMenu[ idx2 ][ 2 ], menuAnimDuration, { css:{marginLeft: menuWidth, width: "0px"}, ease:menuAnimEase });
  3285. TweenMax.to( subMenu[ idx2 ][ 3 ], menuAnimDuration, { css:{color: menuTextOutColor}, ease:menuAnimEase });
  3286. }
  3287. }
  3288. function setMenuData( val ){
  3289. oldMenuData = val;
  3290. currModuleType = val[0];
  3291. sideType = val[1];
  3292. url = val[2];
  3293. $("#template-menu").attr("data-current-module-type", val[0]);
  3294. $("#template-menu").attr("data-side", val[1]);
  3295. $("#template-menu").attr("data-href", val[2]);
  3296. endPreviousModule = false;
  3297. }
  3298. function menuOptionHover( event ){
  3299. //---custom add---------------------------------------
  3300. var offset = 0,
  3301. _menuWidth = menuWidth;
  3302. if ($(event.currentTarget).hasClass('nolink'))
  3303. {
  3304. return;
  3305. } else
  3306. if ($(event.currentTarget).hasClass('submenu'))
  3307. {
  3308. offset = 20;
  3309. _menuWidth = _menuWidth.replace('px','');
  3310. _menuWidth = _menuWidth - offset;
  3311. _menuWidth = _menuWidth + "px";
  3312. }
  3313. //----------------------------------------------------
  3314. var idx = event.data.idx,
  3315. subMenuHol = menuOptionsArr[ idx ][ 5 ];
  3316. if( event.type == "mouseenter" ){
  3317. menuOptionsArr[ idx ][ 3 ][ 0 ].css("width", menuOptionsArr[ idx ][ 4 ]);
  3318. TweenMax.to( menuOptionsArr[ idx ][ 2 ], menuAnimDuration, { css:{marginLeft: (0+offset)+"px", width: _menuWidth}, ease:menuAnimEase });
  3319. TweenMax.to( menuOptionsArr[ idx ][ 3 ], menuAnimDuration, { css:{color: "#FFF"}, ease:menuAnimEase });
  3320. if( subMenuHol != "null" ){
  3321. subMenuHol.css( 'height', '').css( 'width', '');
  3322. var initialHeight = subMenuHol.css( 'height'),
  3323. initialWidth = subMenuHol.css( 'width');
  3324. subMenuHol.css( 'width', '0px' ).css( 'height', '0px' );
  3325. TweenMax.to( subMenuHol, menuAnimDuration, { css:{height:initialHeight, width:initialWidth}, delay:0.2, ease:menuAnimEase, onStart:
  3326. function(){
  3327. subMenuHol.css( 'opacity', '1' ).css( 'display', 'block' );
  3328. }
  3329. });
  3330. }
  3331. }
  3332. else{
  3333. menuOptionsArr[ idx ][ 3 ][ 0 ].css("width", "");
  3334. if( menuOptionsArr[ idx ][ 2 ].hasClass('menu-option-background-selected') == false ){
  3335. TweenMax.to( menuOptionsArr[ idx ][ 2 ], menuAnimDuration, { css:{marginLeft: menuWidth, width: "0px"}, ease:menuAnimEase });
  3336. TweenMax.to( menuOptionsArr[ idx ][ 3 ], menuAnimDuration, { css:{color: menuTextOutColor}, ease:menuAnimEase });
  3337. }
  3338. if( subMenuHol != "null" ){
  3339. subMenuHol.css( 'overflow', '' );
  3340. TweenMax.killTweensOf( subMenuHol );
  3341. TweenMax.to( subMenuHol, menuAnimDuration, { css:{height:"0px", width:"0px" }, ease:menuAnimEase, onComplete:hideSubmenu, onCompleteParams:[subMenuHol]});
  3342. }
  3343. }
  3344. }
  3345. function hideSubmenu( obj ){ obj.css( 'opacity', '0' ).css( 'display', 'none' ); }
  3346. var menuAnimEase = Quad.easeOut; /* Circ.easeOut Quad.easeOut*/
  3347. var menuAnimDuration = 0.4; /* 0.6 or 0.3*/
  3348. var menuWidth = 0;
  3349. var submenuWidth = 0;
  3350. var oldMenuData = "";
  3351. var menuData = "";
  3352. function menuListeners(){
  3353. menuWidth = $(".template-menu").width() + "px";
  3354. /* We add 2 px in order to fix the 2px margin on the right. Since sub menu holder */
  3355. /* has overflow hidden the 2px will fill the gap in IE 8 and in the other browser it won't be shown. */
  3356. submenuWidth = $(".template-menu").width() + 2 + "px";
  3357. /* MENU & SUBMENU -- OVER & OUT LISTENER */
  3358. function hideSubmenu( obj ){ obj.css( 'opacity', '0' ).css( 'display', 'none' ); }
  3359. var submOptBackSel = "sub-menu-option-background-selected";
  3360. if( touchDevice == 0 )$(".sub-menu-option-holder").hover(
  3361. function(){
  3362. var submOptBack = $(".sub-menu-option-background", this);
  3363. var elem = submOptBack.length == 1 ? submOptBack : $("." + submOptBackSel, this);
  3364. TweenMax.to( elem, menuAnimDuration, { css:{marginLeft:"0px", width: submenuWidth}, ease:menuAnimEase });
  3365. TweenMax.to( $(".sub-menu-option-text a", this), menuAnimDuration, { css:{color:"#FFF"}, ease:menuAnimEase });
  3366. },
  3367. function(){
  3368. if( $('div:first', this ).hasClass(submOptBackSel) == false ){
  3369. var submOptBack = $(".sub-menu-option-background", this);
  3370. var elem = submOptBack.length == 1 ? submOptBack : $("." + submOptBackSel, this);
  3371. TweenMax.to( elem, menuAnimDuration, { css:{marginLeft: submenuWidth, width:"0px"}, ease:menuAnimEase });
  3372. TweenMax.to( $(".sub-menu-option-text a", this), menuAnimDuration, { css:{color: menuTextOutColor}, ease:menuAnimEase });
  3373. }
  3374. });
  3375. // MENU & SUBMENU -- CLICK LISTENER
  3376. $(".menu-option-holder").click(
  3377. function(event){
  3378. event.preventDefault();
  3379. var idx = $(".menu-option-holder").index(this);
  3380. if( touchDevice == 1 ){
  3381. if( menuOptionsArr[ idx ][ 6 ] != "null" ){
  3382. if( touchMenuID != -1 && touchMenuID != idx ){
  3383. menuOptionHover({data:{idx:touchMenuID}, type:"mouseleave"});
  3384. }
  3385. menuOptionHover({data:{idx:idx}, type:"mouseenter"});
  3386. touchMenuID = idx;
  3387. if( touchRemoveOn == false ){
  3388. touchRemoveOn = true;
  3389. var moduleContainer = document.getElementById("module-container");
  3390. moduleContainer.addEventListener("touchstart", touchContainer, false);
  3391. }
  3392. }
  3393. else{
  3394. if( touchMenuID != -1 && touchMenuID != idx ){
  3395. menuOptionHover({data:{idx:touchMenuID}, type:"mouseleave"});
  3396. touchMenuID = -1;
  3397. }
  3398. }
  3399. }
  3400. if( menuOptionID != idx && $(this).attr("data-module-type") != undefined && $(this).attr("data-module-type") != "#" ){
  3401. if(loadedContent == false )return;
  3402. menuOptionsArr[ idx ][ 2 ].attr("class", "menu-option-background-selected");
  3403. menuOptionOut( menuOptionID, submenuOptionID );
  3404. menuOptionID = idx;
  3405. submenuOptionID = -1;
  3406. if( touchDevice == 1){
  3407. menuOptionIn( menuOptionID, submenuOptionID );
  3408. }
  3409. var hashURL = "#" + menuOptionsArr[ idx ][ 1 ][ 2 ];
  3410. menuData = menuOptionsArr[ idx ][ 1 ];
  3411. $(window).unbind('hashchange', onTemplateHashChange);
  3412. window.location.hash = hashURL;
  3413. clearCustomInterval( delayInterval );
  3414. delayInterval = setInterval(function(){
  3415. menuOptionClicked( menuData[2],
  3416. menuData[0],
  3417. menuData[1],
  3418. menuData[3]);
  3419. clearCustomInterval( delayInterval );
  3420. $(window).bind('hashchange', onTemplateHashChange);
  3421. }, 400);
  3422. }
  3423. });
  3424. subCloseInterval = "";
  3425. $(".sub-menu-holder .sub-menu-option-holder").click(
  3426. function(event){
  3427. event.preventDefault();
  3428. var submenuParent = $(this).parent().get(0);
  3429. var menuParent = $(submenuParent).parent().get(0);
  3430. currMenuOptionID = $(menuParent).index();
  3431. var submenuOptIdx = $(this).index();
  3432. if( submenuOptionID == submenuOptIdx && menuOptionID == currMenuOptionID){ return false; }
  3433. else{
  3434. if(loadedContent == false ){return;}
  3435. var subMenu = menuOptionsArr[ currMenuOptionID ][ 6 ];
  3436. menuOptionsArr[ currMenuOptionID ][ 2 ].attr("class", "menu-option-background-selected");
  3437. subMenu[ submenuOptIdx ][ 2 ].attr("class", "sub-menu-option-background-selected");
  3438. if( touchDevice == 1 ){
  3439. menuOptionIn(currMenuOptionID, submenuOptIdx);
  3440. clearCustomInterval( subCloseInterval );
  3441. subCloseInterval = setInterval(function(){
  3442. touchContainer();
  3443. clearCustomInterval( subCloseInterval );
  3444. }, 200);
  3445. }
  3446. var disableIdx1 = undefined;
  3447. if(menuOptionID == currMenuOptionID){ disableIdx1 = true; }
  3448. menuOptionOut( menuOptionID, submenuOptionID, disableIdx1 );
  3449. menuOptionID = currMenuOptionID;
  3450. submenuOptionID = submenuOptIdx;
  3451. var hashURL = subMenu[ submenuOptIdx ][ 0 ] ;
  3452. menuData = subMenu[ submenuOptIdx ][ 1 ];
  3453. $(window).unbind('hashchange', onTemplateHashChange);
  3454. window.location.hash = hashURL;
  3455. clearCustomInterval( delayInterval );
  3456. delayInterval = setInterval(function(){
  3457. menuOptionClicked( menuData[2],
  3458. menuData[0],
  3459. menuData[1],
  3460. menuData[3]);
  3461. clearCustomInterval( delayInterval );
  3462. $(window).bind('hashchange', onTemplateHashChange);
  3463. }, 400);
  3464. }
  3465. event.stopPropagation();
  3466. });
  3467. }
  3468. var touchRemoveOn = false;
  3469. var touchMenuID = -1;
  3470. function touchContainer(){
  3471. touchRemoveOn = false;
  3472. if( touchMenuID != -1 && menuOptionsArr[ touchMenuID ][ 6 ] != "null" ){
  3473. var evt = {data:{idx:touchMenuID}, type:"mouseleave"};
  3474. menuOptionHover(evt);
  3475. }
  3476. var moduleContainer = document.getElementById("module-container");
  3477. moduleContainer.removeEventListener("touchstart", touchContainer, false);
  3478. }
  3479. function urlChanged(){
  3480. loadedContent = true;
  3481. menuOptionClicked( menuData[2], menuData[0], menuData[1], menuData[3]);
  3482. }
  3483. function isOtherURL(){
  3484. var val = ( menuData != "" && menuData[2] != prevURL ) ? true : false;
  3485. return val;
  3486. }
  3487. function menuOptionClicked( val, mType, sType, hrefPath ){
  3488. if( val != "#" ){
  3489. var url = '';
  3490. if( $("#template-menu").attr("data-current-module-type") == "slideshow" ){deleteSlideshowTimer();}
  3491. currModuleType = mType;
  3492. sideType = sType;
  3493. hrefPath = (hrefPath == undefined) ? "" : hrefPath;
  3494. setMobileMenuOption(val);
  3495. url = templateBaseURL + hrefPath + val.replace('#','');
  3496. if( prevURL == '' ){prevURL = url;}
  3497. else{prevURL = loadURL;}
  3498. loadURL = url;
  3499. stopCurrentLoading();
  3500. if( endModuleFunction != null ){
  3501. delayAnimationLoading = 0.3;
  3502. if( moduleEnd == true ){
  3503. moduleEnd = false;
  3504. endModuleFunction();
  3505. }
  3506. }
  3507. else{delayAnimationLoading = 0.1;}
  3508. if(menuData[2] != oldMenuData[2] ){
  3509. loadedContent = true;
  3510. activateAnimationLoading();
  3511. }
  3512. else{
  3513. loadedContent = true;
  3514. var loadAnim = $("#loading-animation");
  3515. if(loadAnim.length > 0 ){ TweenMax.to( loadAnim, .3, { css:{right:"-104px"}, ease:Circ.easeOut }); }
  3516. if(endModuleFunction == null){
  3517. switch( menuData[0] ){
  3518. case "news":
  3519. var textPageInstanceHolder = $( txt_modCont);
  3520. TweenMax.to( textPageInstanceHolder, .6, { css:{left: "0px" }, delay:0.1, ease:Circ.easeInOut });/*get_OffsetWidth() +*/
  3521. endModuleFunction = endModuleTextPage;
  3522. moduleEnd = true;
  3523. break;
  3524. case "text_page":
  3525. moduleTextPage();
  3526. break;
  3527. case "gallery":
  3528. endModuleGallery(true);
  3529. endModuleFunction = endModuleGallery;
  3530. break;
  3531. case "showreel":
  3532. reverseEndModuleShowreel();
  3533. break;
  3534. }
  3535. }
  3536. }
  3537. }
  3538. }
  3539. function stopCurrentLoading(){
  3540. if( loadInterval != ""){
  3541. clearInterval( loadInterval );
  3542. loadInterval = "";
  3543. }
  3544. if( showModuleInterval != ""){
  3545. clearInterval( showModuleInterval );
  3546. showModuleInterval = "";
  3547. }
  3548. }
  3549. var delayAnimationLoading = 0.3;
  3550. function activateAnimationLoading(){
  3551. var loadAnim = $("#loading-animation");
  3552. TweenMax.killTweensOf( loadAnim );
  3553. loadAnim.css("right", "-104px" ).css("display", "inline").css("visibility", "visible" );
  3554. if(loadAnim.length > 0 ){ TweenMax.to( loadAnim, .3, { css:{right:"0px"}, delay: delayAnimationLoading, ease:Circ.easeOut, onComplete: doLoad }); }
  3555. else{doLoad();}
  3556. }
  3557. var loadInterval = ""
  3558. function doLoad(){
  3559. if( loadedContent == true ){
  3560. var toLoad = loadURL;
  3561. clearCustomInterval( loadInterval );
  3562. var modGallPrev = $("#module-galleries-preview");
  3563. var fullWidPrev = $("#full-width-preview");
  3564. if( modGallPrev.length > 0 ){ modGallPrev.remove(); }
  3565. if( fullWidPrev.length > 0 ){ fullWidPrev.remove(); }
  3566. loadedContent = false;
  3567. loadInterval = setInterval(function(){
  3568. loadModule( toLoad )
  3569. clearCustomInterval( loadInterval );
  3570. }, 50);
  3571. }
  3572. }
  3573. /*------------------ end menuListeners --------------------*/
  3574. /*------------------ start module load functions ----------*/
  3575. var loadedContent = true;
  3576. function loadModule( url ){
  3577. loadedContent = false;
  3578. backLoaded = false;
  3579. showDone = false;
  3580. var loadContainer = $("#load-container");
  3581. if( loadContainer.length > 0 ){
  3582. prevURL = url;
  3583. loadContainer.empty().load( url + ' #module-container > *', moduleLoaded );
  3584. }
  3585. }
  3586. var showModuleInterval = "";
  3587. var cc = 0;
  3588. function moduleLoaded(response, status, xhr)
  3589. {
  3590. switch ( status )
  3591. {
  3592. case "error":console.log( "Error loading the page: " + response );
  3593. break;
  3594. case "success":
  3595. if( prevURL != loadURL ){
  3596. clearCustomInterval( showModuleInterval );
  3597. }
  3598. else{
  3599. clearCustomInterval( showModuleInterval );
  3600. showModuleInterval = setInterval(function(){
  3601. if( menuData[2] == oldMenuData[2]){
  3602. clearCustomInterval( showModuleInterval );
  3603. loadedContent = true;
  3604. var loadAnim = $("#loading-animation");
  3605. if(loadAnim.length > 0 ){ TweenMax.to( loadAnim, .3, { css:{right:"-104px"}, ease:Circ.easeOut }); }
  3606. return;
  3607. }
  3608. setMenuData(menuData);
  3609. var containerStyle = $("#module-container").attr("style");
  3610. if( containerStyle == undefined ) containerStyle = "";
  3611. $("#module-container").attr("id", "module-container-old" ).attr("style", containerStyle );
  3612. $("#load-container").css("visibility", "hidden" ).attr('id', 'module-container').attr("style", containerStyle );
  3613. $("#module-container-old").after($("#module-container"));
  3614. $("#template-wrapper").after( '<div id="load-container"></div>' ); //.css("left", get_OffsetWidth() + "px" )
  3615. showModule();
  3616. clearCustomInterval( showModuleInterval );
  3617. }, 50);
  3618. }
  3619. break;
  3620. }
  3621. }
  3622. /*------------------- end module load functions -----------*/
  3623. function templateCollectGarbage(){
  3624. var moduleType = $("#template-menu").attr("data-current-module-type");
  3625. if( moduleType != "slideshow" ){
  3626. currentSlide = null;
  3627. if( thumbsList != null ){
  3628. thumbsList.destroy();
  3629. thumbsList = null;
  3630. }
  3631. }
  3632. moduleType = null;
  3633. }
  3634. /*------------------- start window resize -----------------*/
  3635. function moduleUpdate_slideshow(){
  3636. var winW = $(window).width();
  3637. if( $("#slideshow-thumbs-content").length > 0 ){
  3638. var thumbHolder = $("#slideshow-thumbs");
  3639. if( winW >= 768 && winW <= 1024 ){ $("#slideshow-thumbs-content").css("width", initialThumbContW + "px"); }
  3640. else{
  3641. var thumbCont = $("#slideshow-thumbs-content");
  3642. var thumbW = $(".slideshow-thumb-holder").width() + parseInt( $(".slideshow-thumb-holder").css("margin-right"), 10 );
  3643. if( thumbHolder.width() > winW ){
  3644. $("#slideshow-thumbs-content").css("width", (thumbCont.width() - thumbW) + "px");
  3645. }
  3646. else if( thumbHolder.width() + thumbW <= winW ){
  3647. if( thumbCont.width() + thumbW <= initialThumbContW )thumbCont.css("width", (thumbCont.width() + thumbW) + "px");
  3648. }
  3649. }
  3650. thumbHolder.css("margin-left", ($("#module-container").width() - thumbHolder.width() )* .5 );
  3651. if( thumbsList != null )thumbsList.updateCustomList();
  3652. }
  3653. var slideHolder = $("#slideshow .slideshow-slide");
  3654. if( slideHolder.length > 0 ){
  3655. $("#slideshow-captions", slideHolder ).each(function(){
  3656. $(this ).css("top", ($(window).height() * 0.3) + "px");
  3657. $(this ).css("left", ($("#module-container").width() * 0.5) + "px");
  3658. });
  3659. }
  3660. }
  3661. function moduleUpdate_home2(){
  3662. var winW = $(window).width();
  3663. var li = ".home-layout2-content ul li";
  3664. var mH = "#module-home-layout2";
  3665. var textPageInstanceHolder = $(txt_modCont);
  3666. var textPageInstance = $( mH, textPageInstanceHolder);
  3667. if( textPageInstance.length <= 0 )return;
  3668. if( winW > 1200){
  3669. $(mH).css("width", "");
  3670. $(li).attr("style", "");
  3671. $(li + ":nth-child(4n+4)").css("margin-right", "0px");
  3672. }
  3673. else if( winW > 1024 && winW <= 1200){
  3674. $(mH).css("width", "800");
  3675. $(li).attr("style", "").attr("style", " margin-right: 20px; width: 162px;");
  3676. $(li + ":nth-child(4n+4)").css("margin-right", "0px");
  3677. }
  3678. else if( winW >= 768 && winW <= 1024 ){
  3679. $(mH).css("width", "570");
  3680. $(li).attr("style", "");
  3681. $(li + ":nth-child(2n+2)").css("margin-right", "0px");
  3682. }
  3683. else if( winW < 768 ){
  3684. $(mH).css("width", "510");
  3685. $(li).attr("style", "");
  3686. $(li + ":nth-child(2n+2)").css("margin-right", "0px");
  3687. }
  3688. moduleUpdate( textPageInstanceHolder, textPageInstance, $("div:first", textPageInstance), sideType );
  3689. }
  3690. function moduleUpdate_home3(){
  3691. var textPageInstanceHolder = $(txt_modCont);
  3692. var textPageInstance = $( "#module-home-layout3", textPageInstanceHolder);
  3693. if( textPageInstance.length <= 0 )return;
  3694. moduleUpdate( textPageInstanceHolder, textPageInstance, $("div:first", textPageInstance), sideType );
  3695. }
  3696. function moduleUpdate_text_page(){
  3697. var textPageInstanceHolder = $(txt_modCont);
  3698. var textPageInstance = $( "#module-wrapper", textPageInstanceHolder);
  3699. if( textPageInstance.length <= 0 )return;
  3700. moduleUpdate( textPageInstanceHolder, textPageInstance, $("div:first", textPageInstance), sideType );
  3701. }
  3702. function moduleUpdate_showreel(){
  3703. var textPageInstanceHolder = $(txt_modCont);
  3704. var textPageInstance = $( "#module-showreel", textPageInstanceHolder);
  3705. if( textPageInstance.length <= 0 )return;
  3706. moduleUpdate( textPageInstanceHolder, textPageInstance, $("div:first", textPageInstance), sideType );
  3707. }
  3708. function moduleUpdate_fullscreen_video( animate ){
  3709. var textPageInstanceHolder = $( txt_modCont);
  3710. var textPageInstance = $( "#module-fullscreen-video", textPageInstanceHolder);
  3711. if( textPageInstance.length <= 0 )return;
  3712. var width = $(window).width() - get_OffsetWidth();
  3713. var height = $(window).height();
  3714. var standalone = $("#standalone-wrapper", textPageInstance);
  3715. if( standalone.length > 0 ){ TweenMax.to( [ standalone, textPageInstance ], .6, {css:{width: width, height: height}, easing:Sine.easeOut}); }
  3716. else{ TweenMax.to( textPageInstance, .6, {css:{width: width, height: height}, easing:Sine.easeOut}); }
  3717. }
  3718. function moduleUpdate_pricing_tables(){
  3719. var textPageInstanceHolder = $(txt_modCont);
  3720. var textPageInstance = $("#module-pricing", textPageInstanceHolder);
  3721. if( textPageInstance.length <= 0 )return;
  3722. moduleUpdate( textPageInstanceHolder, textPageInstance, $("div:first", textPageInstance), sideType );
  3723. }
  3724. function moduleUpdate_full_width( animate ){
  3725. var textPageInstanceHolder = $( txt_modCont);
  3726. var textPageInstance = $( "#module-full-width", textPageInstanceHolder);
  3727. var modWrapper = $( "#module-wrapper", textPageInstance);
  3728. if( textPageInstance.length <= 0 ) return;
  3729. var currWindowW = $(window).width() - get_OffsetWidth();
  3730. if( touchDevice == 1){ currWindowW = $(window).width() - templateMenuW; }
  3731. textPageInstance.css("width", currWindowW);
  3732. if( $("#module-full-width-holder-text", modWrapper).height() > $(window).height() && touchDevice == 0){ currWindowW = currWindowW - $(t_scrBarV2).width(); }
  3733. if( animate == undefined || animate == false ){
  3734. textPageInstance.css("width", currWindowW);
  3735. moduleUpdate( textPageInstanceHolder, modWrapper, $("div:first", modWrapper), sideType );
  3736. }
  3737. else{
  3738. TweenMax.to(textPageInstance, .3, {css:{width: currWindowW}, easeing:Sine.easeOut, onComplete:
  3739. function(){
  3740. moduleUpdate( textPageInstanceHolder, modWrapper, $("div:first", modWrapper), sideType );
  3741. }
  3742. });
  3743. }
  3744. }
  3745. function moduleUpdate_news(){
  3746. var textPageInstanceHolder = $( txt_modCont);
  3747. var textPageInstance = $( "#module-news-vertical", textPageInstanceHolder);
  3748. var newsPreviewContainer = $(newsPrvU, textPageInstance);
  3749. if( previewNewsOpen == true ){
  3750. var i = 0;
  3751. for( i; i < totalPreviews; i++){ if( i != previewNewsIndex ){ newsPrevItemArr[ i ].css("display", "none"); } }
  3752. moduleUpdate( textPageInstanceHolder, $("#module-news-preview-holder", textPageInstance), $("#module-news-preview-container", textPageInstance), "custom", 0 );
  3753. if( touchDevice == 1){
  3754. $("#module-news-preview-container", textPageInstance).css("height", "");
  3755. $("#module-news-preview-container", textPageInstance).css("height", $("#module-news-preview-container", textPageInstance).height());
  3756. }
  3757. newsPreviewItemDisplay("inline");
  3758. }
  3759. else{ moduleUpdate( textPageInstanceHolder, $("#module-news-vertical"), $("#module-news-vertical div:first"), sideType ); }
  3760. }
  3761. function moduleUpdate_contact(){
  3762. var textPageInstanceHolder = $( txt_modCont);
  3763. var textPageInstance = $( "#module-wrapper", textPageInstanceHolder);
  3764. var mapHolder = $("#map-holder", textPageInstanceHolder);
  3765. if(textPageInstance.length <= 0 || $("#module-contact-holder").length <= 0){return;}
  3766. var dd = $("#module-container").width();
  3767. $("#module-contact-holder").css("left", (dd - $("#module-contact-holder").width())*.5 + "px");
  3768. var mapW = window.width-get_OffsetWidth()-$("#module-scrollbar-holder_v2").width();//screen.width;
  3769. var mapLeft = 0;//(- get_OffsetWidth()) * .5;
  3770. if( mapHolder.length > 0 ){TweenMax.to(mapHolder, .3, {css:{left: mapLeft, width: mapW, height: ($(window).height())/2+"px"}, easing:Sine.easeOut});}
  3771. var currWindowW = $(window).width() - get_OffsetWidth() - $(t_scrBarV2).width();
  3772. if( touchDevice == 1){ currWindowW = $(window).width() - templateMenuW; }
  3773. textPageInstance.css("width", currWindowW);
  3774. if( $("div:first", textPageInstance).height() <= $(window).height() )
  3775. { currWindowW = currWindowW + $(t_scrBarV2).width(); }
  3776. textPageInstance.css("width", currWindowW);
  3777. moduleUpdate( textPageInstanceHolder, textPageInstance, $("div:first", textPageInstance), sideType );
  3778. }
  3779. function moduleUpdate_gallery(){
  3780. var textPageInstanceHolder = $( txt_modCont);
  3781. var textPageInstance = $( "#module-galleries", textPageInstanceHolder);
  3782. var galleryHolder = $("#module-galleries-holder", textPageInstance);
  3783. if( textPageInstance.length <= 0 ) return;
  3784. var thumbMarginRight = parseInt($(".thumb-holder").css("margin-right"), 10);
  3785. var thumbMarginBottom = parseInt($(".thumb-holder").css("margin-bottom"), 10);
  3786. var thumbWidth = $(".thumb-holder").width();
  3787. var thumbHeight = $(".thumb-holder").height();
  3788. var containerWidth = galleryHolder.width();
  3789. var containerHeight = galleryHolder.height();
  3790. var visibleHeight = textPageInstance.height();
  3791. var numberColumns = Math.round( containerWidth / ( thumbWidth + thumbMarginRight) );
  3792. var numberLines = Math.floor( visibleHeight / ( thumbHeight + thumbMarginBottom) + 1);
  3793. var totalVisibleThumbs = numberColumns * numberLines - 1;
  3794. visibleGalleryH = visibleHeight;
  3795. galleryColumns = numberColumns;
  3796. galleryLines = numberLines;
  3797. $(".thumb-holder", galleryHolder).css("margin-right", "");
  3798. $(".thumb-holder" + ":nth-child(" + galleryColumns + "n+" + galleryColumns + ")", galleryHolder).css("margin-right", "0px");
  3799. moduleUpdate( textPageInstanceHolder, textPageInstance, $("div:first", textPageInstance), sideType );
  3800. if( previewGalleryOpen == true ){ updatePreviewMediaPosition() }
  3801. }
  3802. function moduleUpdate_full_width_gallery(){
  3803. var textPageInstanceHolder = $(txt_modCont);
  3804. var textPageInstance = $( "#module-full-width-gallery", textPageInstanceHolder);
  3805. var modulePositionType = textPageInstanceHolder.attr("data-id");
  3806. if( textPageInstance.length > 0 ){
  3807. if( initialThumbW <= 0)return;
  3808. checkItems();
  3809. moduleUpdate( textPageInstanceHolder, textPageInstance, $("div:first", textPageInstance), sideType );
  3810. }
  3811. if( previewFullWidthOpen == true ){ updateFullWidthPreviewPosition(); }
  3812. }
  3813. function moduleUpdate_page_columns( customStartPos ){
  3814. var textPageInstanceHolder = $( txt_modCont);
  3815. var textPageInstance = $( "#module-columns", textPageInstanceHolder);
  3816. var modulePositionType = textPageInstanceHolder.attr("data-id");
  3817. var columnItemWrapper = $("#module-columns-wrapper", textPageInstance);
  3818. var columnPrevWrapper = $("#module-columns-preview-wrapper", textPageInstance);
  3819. if( textPageInstance.length <= 0 )return;
  3820. checkColumnSize( columnsPreviewOpen );
  3821. var val = Math.abs($("#module-container").width() - textPageInstanceHolder.width()) * .5;
  3822. TweenMax.to( textPageInstanceHolder, .2, { css:{ left: val }, ease:Circ.easeOut });
  3823. if( columnsPreviewOpen == false ){
  3824. if( customStartPos == undefined ){ customStartPos = 0; }
  3825. moduleUpdate( textPageInstanceHolder, columnItemWrapper, $("div:first", columnItemWrapper), sideType, null, null, customStartPos );
  3826. }
  3827. else{
  3828. if(previewAnimDone == false)return;
  3829. var i = 0;
  3830. for( i; i < totalColPreviews; i++){if( i != columnsPreviewIndex )columnsPrevItemArr[ i ].css("display", "none");}
  3831. moduleUpdate( textPageInstanceHolder, columnPrevWrapper, $("div:first", columnPrevWrapper), sideType, null, null, 0 );
  3832. if( touchDevice == 1){
  3833. $("div:first", columnPrevWrapper).css("height", "");
  3834. $("div:first", columnPrevWrapper).css("height", $("div:first", columnPrevWrapper).height());
  3835. }
  3836. colPreviewItemDisplay("inline");
  3837. }
  3838. }
  3839. $(window).resize(
  3840. function(){
  3841. /*SLIDESHOW CHECK*/
  3842. if( currentSlide != null )resizeImage(currentSlide);
  3843. /*BACKGROUND CHECK*/
  3844. if( $showModuleBackground != null )resizeImage( $showModuleBackground );
  3845. var scrollbar_v1 = $("#module-container #module-scrollbar-holder");
  3846. var scrollbar_v2 = $("#module-container #module-scrollbar-holder_v2");
  3847. var availScrollbar = (scrollbar_v1.length > 0) ? scrollbar_v1 : scrollbar_v2;
  3848. var winW = $(window).width();
  3849. var winH = $(window).height();
  3850. var menuHiderH = parseInt( $("#menu-container #menu-hider").height(), 10 );
  3851. var menW = getMenuWidth();
  3852. var menH = getMenuHeight();
  3853. $("#module-container").css( "width", (winW - get_OffsetWidth()) + "px" );
  3854. if( winW >= 768 ){
  3855. $("#module-container").css( "top", "0px" ).css( "left", menW + "px" );
  3856. $("#module-container").css( "height", "100%" );
  3857. if( firstRun == false )$("footer").css( 'display', 'inline' ).css( 'visibility', 'visible' );
  3858. if( availScrollbar.length > 0){ availScrollbar.css("height", winH).css("top", "0px"); }
  3859. if( menuActive == false ){
  3860. var menuHider = ($("#menu-hider").length > 0 ) ? parseInt($("#menu-hider").width(), 10) : 0;
  3861. var menuWidth = parseInt( $("#menu-container").css("width"), 10 ) - menuHider;
  3862. var menuVal = 0;
  3863. $("#template-wrapper").css("left", -(menuWidth ) + "px").css("top", "0px");
  3864. $("#menu-container").css("left", menuVal + "px").css("top", "0px");
  3865. }
  3866. }
  3867. else{
  3868. if( menuActive == true ){
  3869. var menuVal = 0;
  3870. $("#template-wrapper").css("left", "0px").css("top", "0px");
  3871. $("#menu-container").css("left", "0px").css("top", "0px");
  3872. }
  3873. else{
  3874. var menuHeight = parseInt( $("#menu-container").height(), 10 ) - menuHiderH;
  3875. $("#template-wrapper").css("left", "0px").css("top", -menuHeight + "px");
  3876. $("#menu-container").css("left", "0px").css("top", "0px");
  3877. }
  3878. $("#module-container").css( "left", "0px" ).css( "top", $("#menu-container").height() + "px" );
  3879. $("#module-container").css( "height", ( winH - menuHiderH ) + "px" );
  3880. if( firstRun == false )$("footer").css( 'display', 'none' ).css( 'visibility', 'hidden' );
  3881. if( availScrollbar.length > 0 && touchDevice == 0){ availScrollbar.css("height", (winH - menuHiderH) + "px");}
  3882. }
  3883. /*window["moduleUpdate_" + currModuleType]();*/
  3884. switch( currModuleType ){
  3885. case "slideshow": moduleUpdate_slideshow();
  3886. break;
  3887. case "home2": moduleUpdate_home2();
  3888. break;
  3889. case "home3": moduleUpdate_home3();
  3890. break;
  3891. case "text_page": moduleUpdate_text_page();
  3892. break;
  3893. case "showreel": moduleUpdate_showreel();
  3894. break;
  3895. case "fullscreen_video": moduleUpdate_fullscreen_video();
  3896. break;
  3897. case "pricing_tables": moduleUpdate_pricing_tables();
  3898. break;
  3899. case "full_width": moduleUpdate_full_width();
  3900. break;
  3901. case "news": moduleUpdate_news();
  3902. break;
  3903. case "contact": moduleUpdate_contact();
  3904. break;
  3905. case "gallery": moduleUpdate_gallery();
  3906. break;
  3907. case "full_width_gallery": moduleUpdate_full_width_gallery();
  3908. break;
  3909. case "page_columns": moduleUpdate_page_columns();
  3910. break;
  3911. }
  3912. moduleType = null;
  3913. /*FOOTER*/
  3914. if( firstRun == true )return;
  3915. if( $(window).width() >= 768){ $("footer").css( 'display', 'inline' ).css( 'visibility', 'visible' ); }
  3916. else{ $("footer").css( 'display', 'none' ).css( 'visibility', 'hidden' ); }
  3917. }
  3918. );
  3919. function get_OffsetWidth(){
  3920. var value = 0;
  3921. if( $(window).width() > 767 ){
  3922. if( menuActive == false ){
  3923. if( isOverMenu == false )
  3924. value = parseInt( $("#menu-hider").css("width"), 10 );
  3925. else
  3926. value = parseInt( $("#menu-container").css("width"), 10 );
  3927. }
  3928. else{ value = parseInt( $("#menu-container").css("width"), 10 ); }
  3929. }
  3930. return value;
  3931. }
  3932. /*------------------- end window resize -------------------*/
  3933. /*----------------- start Utils Methods -------------------*/
  3934. function templateAddMediaVideo( videoType, elem, elemParent ){
  3935. var id = elem.attr("id");
  3936. var url = (videoType != "standalone") ? url = elem.attr("data-url") : "";
  3937. var parent = ( elemParent == undefined) ? elem : elemParent;
  3938. var videoEmbedCode = "";
  3939. if( videoType == "standalone" ){
  3940. videoEmbedCode += '<video id="standalone-wrapper" class="video-js vjs-default-skin" controls preload="none" width="'+ elem.attr("data-width") +'" height="'+ elem.attr("data-height") +'"'
  3941. + 'poster="'+ elem.attr("data-poster") +'">';
  3942. for( var i = 1; i <= 3; i++ ){
  3943. videoEmbedCode += '<source src="' + $(elem).attr("data-url" + i) + '" type="' + $(elem).attr("data-type" + i) + '" />';
  3944. }
  3945. videoEmbedCode += '</video>';
  3946. }
  3947. else if( videoType != "standalone" ){
  3948. videoEmbedCode += '<iframe src="' + url + '" width="' + elem.attr("data-width") + '" height="'+ elem.attr("data-height") +'" frameborder="0" allowfullscreen="" mozallowfullscreen="" webkitallowfullscreen=""></iframe>';
  3949. if ( $.browser.msie && videoType == "youtube"){
  3950. if( $.browser.version == "8.0" || ( $.browser.version == "9.0" && isIE9Std() == false )){
  3951. url = url.replace("http://www.youtube.com/embed/", "http://www.youtube.com/v/");
  3952. videoEmbedCode = '<object width="' + elem.attr("data-width") + '" height="' + elem.attr("data-height") + '">'+ '<param name="movie" value="' + url + '?fs=1&enablejsapi=1"></param>' +
  3953. '<param name="allowFullScreen" value="true"></param>' +
  3954. '<param name="allowScriptAccess" value="always"></param>' +
  3955. '<embed id="ytplayer" src="' + url + '?fs=1&enablejsapi=1"' + 'type="application/x-shockwave-flash"' +
  3956. 'allowfullscreen="true"' + 'allowscriptaccess="always"' + 'width="' + elem.attr("data-width") + '" height="' + elem.attr("data-height") + '">' +
  3957. '</embed>' +
  3958. '</object>';
  3959. }
  3960. }
  3961. }
  3962. parent.append( videoEmbedCode );
  3963. destroyVideoJS();
  3964. parent.css("opacity", "0").css("visibility","visible");
  3965. if( videoType == "standalone" ){ var ready = false;
  3966. videojsHolder = _V_("standalone-wrapper", {}, function(){
  3967. if(ready == false){ ready = true;
  3968. TweenMax.to( [$("#standalone-wrapper"), parent], .6, { css:{ opacity: "1" }, ease:Circ.easeOut });
  3969. }
  3970. });
  3971. }
  3972. else{ TweenMax.to( parent, .6, { css:{ opacity: "1" }, ease:Circ.easeOut }); }
  3973. }
  3974. function destroyVideoJS(){
  3975. if( videojsHolder != "" ){
  3976. videojsHolder.pause();
  3977. /* for html5 - clear out the src which solves a browser memory leak */
  3978. /* this workaround was found here: http://stackoverflow.com/questions/5170398/ios-safari-memory-leak-when-loading-unloading-html5-video */
  3979. if(videojsHolder.techName == "html5"){
  3980. videojsHolder.tag.src = "";
  3981. videojsHolder.tech.removeTriggers();
  3982. videojsHolder.load();
  3983. }
  3984. videojsHolder.tech.destroy();/* destroy the parts of the player which are specific to html5 or flash */
  3985. videojsHolder.destroy();/* destroy the player */
  3986. $(videojsHolder.el).remove();/* remove the entire player from the dom */
  3987. videojsHolder.players = {} ;
  3988. }
  3989. }
  3990. function clearCustomInterval( interval ){
  3991. if( interval != "" ){
  3992. clearInterval( interval );
  3993. interval = "";
  3994. }
  3995. }
  3996. function resizeImage( image, animate ){
  3997. image.removeAttr('width');
  3998. image.removeAttr('height');
  3999. var ww = $( window ).width() - get_OffsetWidth(),
  4000. wh = $( window ).height(),
  4001. iw = image.width(),
  4002. ih = image.height(),
  4003. rw = wh / ww,
  4004. ri = ih / iw,
  4005. newWidth, newHeight,
  4006. newLeft, newTop,
  4007. properties;
  4008. if ( rw > ri ) {
  4009. newWidth = wh / ri;
  4010. newHeight = wh;
  4011. } else {
  4012. newWidth = ww;
  4013. newHeight = ww * ri;
  4014. }
  4015. if( animate == undefined || animate == false ){
  4016. image.css("width", newWidth).css("height", newHeight);
  4017. }
  4018. else if( animate == true ){ TweenMax.to( image, .6, { css:{width: newWidth, height: newHeight}, ease:Sine.easeOut }); }
  4019. }
  4020. function rgb2hex(rgb){
  4021. var value = "";
  4022. if( rgb != undefined )
  4023. {
  4024. if ( ($.browser.msie && ($.browser.version == "9.0" && isIE9Std() == true )) || !$.browser.msie ){
  4025. rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
  4026. value = "#" + ("0" + parseInt(rgb[1],10).toString(16)).slice(-2) + ("0" + parseInt(rgb[2],10).toString(16)).slice(-2) + ("0" + parseInt(rgb[3],10).toString(16)).slice(-2);
  4027. }
  4028. else{ value = rgb; }
  4029. }
  4030. return value;
  4031. }
  4032. function mobileConsole(text, value, clear, displayConsole ){
  4033. if( clear != undefined && clear == true )$("#console-log").empty();
  4034. $("#console-log").append('<span>' + text + ' ' + value + '</span>');
  4035. if( displayConsole == true )
  4036. {
  4037. $("#console-log").css("display", "inline");
  4038. }
  4039. }
  4040. /*----------------- end Utils Methods ---------------------*/