script.js 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637
  1. "use strict"; // start of use strict
  2. $(document).ready(function() {
  3. scroll_top ();
  4. //sticky_init ();
  5. hover_disable ();
  6. init_classic_menu();
  7. init_accordion();
  8. init_toggle();
  9. counter();
  10. $(window).on('scroll', progress_bar_loader);
  11. cws_page_focus();
  12. progress_bar_loader();
  13. //init_twitter_carusel();
  14. init_fancy();
  15. search_open ()
  16. if($(".cws_prlx_section").length) {
  17. $( ".cws_prlx_section" ).cws_prlx();
  18. }
  19. init_rev_slider();
  20. init_add_cart ();
  21. init_color_filter ();
  22. if ($(".price_slider_wrapper").length) {
  23. woocommerce_price_slider( $ )
  24. };
  25. video_img();
  26. cws_touch_events_fix ();
  27. masonry_init();
  28. filter_init();
  29. gridList_init();
  30. popup_login_init();
  31. //magicline_init();
  32. magicline_main_init();
  33. footer_height();
  34. search_form_height();
  35. search_form_click();
  36. search_tours_form_resize();
  37. slider_info_mob();
  38. scrollTo_init();
  39. flexslider_init();
  40. //add_button_menu();
  41. //mobile_menu_controller_init ();
  42. console.log($('.features-tours-wrap .features-tours-item').length);
  43. if($('.features-tours-wrap .features-tours-item').length) {
  44. equalizeheighttosmallest('.features-tours-wrap .features-tours-item .features-media');
  45. }
  46. if($('.isotope-grid').length) {
  47. init_isotop ();
  48. }
  49. });
  50. $(document).load(function() {
  51. if($('.features-tours-wrap .features-tours-item').length) {
  52. equalizeheighttosmallest('.features-tours-wrap .features-tours-item .features-media');
  53. }
  54. });
  55. $(window).resize(function() {
  56. if($('.isotope-grid').length) {
  57. init_isotop ();
  58. }
  59. masonry_init();
  60. search_form_height();
  61. search_tours_form_resize();
  62. slider_info_mob();
  63. footer_height();
  64. cws_touch_events_fix ();
  65. if($('.features-tours-wrap .features-tours-item').length) {
  66. equalizeheighttosmallest('.features-tours-wrap .features-tours-item .features-media');
  67. }
  68. });
  69. function equalizeheight(elementToEqualize) {
  70. //Equilize height
  71. var equalheight = function(container){
  72. var currentTallest = 0;
  73. var currentRowStart = 0;
  74. var rowDivs = new Array();
  75. var $el;
  76. var topPosition = 0;
  77. $(container).each(function() {
  78. $el = $(this);
  79. $($el).height('auto');
  80. var topPostion = $el.position().top;
  81. //console.log($el.height());
  82. if (currentRowStart != topPostion) {
  83. for (var currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
  84. rowDivs[currentDiv].height(currentTallest);
  85. }
  86. rowDivs.length = 0; // empty the array
  87. currentRowStart = topPostion;
  88. currentTallest = $el.height();
  89. rowDivs.push($el);
  90. } else {
  91. rowDivs.push($el);
  92. currentTallest = (currentTallest < $el.height()) ? ($el.height()) : (currentTallest);
  93. }
  94. for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
  95. rowDivs[currentDiv].height(currentTallest);
  96. }
  97. });
  98. };
  99. equalheight(elementToEqualize);
  100. }
  101. function equalizeheighttosmallest(elementToEqualize) {
  102. //Equilize height
  103. var equalheight = function(container){
  104. var currentSmallest = 0;
  105. var currentRowStart = 0;
  106. var rowDivs = new Array();
  107. var $el;
  108. var smallestHeight = 0;
  109. $(container).each(function() {
  110. $el = $(this);
  111. $($el).height('auto');
  112. var smallestHeight = $el.height;
  113. //console.log($el.height());
  114. if (currentRowStart != smallestHeight) {
  115. for (var currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
  116. rowDivs[currentDiv].height(currentSmallest);
  117. }
  118. rowDivs.length = 0; // empty the array
  119. currentRowStart = smallestHeight;
  120. currentSmallest = $el.height();
  121. rowDivs.push($el);
  122. } else {
  123. rowDivs.push($el);
  124. currentSmallest = (currentSmallest > $el.height()) ? ($el.height()) : (currentSmallest);
  125. }
  126. for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
  127. rowDivs[currentDiv].height(currentSmallest);
  128. }
  129. });
  130. };
  131. equalheight(elementToEqualize);
  132. }
  133. // ios touch fix
  134. function cws_touch_events_fix() {
  135. if ( is_mobile_device() ){
  136. jQuery( ".container" ).on( "mouseenter", ".hover-effect, .product .pic", function (e){
  137. e.preventDefault();
  138. jQuery( this ).trigger( "hover" );
  139. });
  140. jQuery( ".features-tours-item" ).on( "mouseenter", ".features-info-top, .features-info-bot", function (e){
  141. e.preventDefault();
  142. jQuery( this ).trigger( "hover" );
  143. });
  144. jQuery( ".main-nav" ).on( "hover", ".mobile_nav .button_open, .mobile_nav li > a", function ( e ){
  145. e.preventDefault();
  146. jQuery( this ).trigger( "click" );
  147. });
  148. jQuery( ".recom-item .recom-media > a" ).each(function(){
  149. jQuery(this).on( "click", function ( e ){
  150. e.preventDefault();
  151. })
  152. });
  153. jQuery( ".work-filter ul.magic-line li a" ).on( "mouseenter", function ( e ){
  154. e.preventDefault();
  155. jQuery( this ).trigger( "click" );
  156. });
  157. }
  158. }
  159. // hover disable function
  160. function hover_disable() {
  161. $('.recom-item .recom-media').off('mouseenter mouseleave');
  162. }
  163. // search open function
  164. function search_open() {
  165. $('.site-top-panel .top-search').on('click', function() {
  166. $('.site-top-panel').addClass('open-search');
  167. return false;
  168. })
  169. $('.site-top-panel .search_menu_cont .search_back_button').on('click', function() {
  170. $('.site-top-panel').removeClass('open-search');
  171. })
  172. $('.main-nav .inner-nav .search > a').on('click', function() {
  173. $('.main-nav').addClass('open-search');
  174. return false;
  175. })
  176. $('.main-nav .inner-nav .search .close-button').on('click', function() {
  177. $('.main-nav').removeClass('open-search');
  178. })
  179. }
  180. // menu
  181. function init_classic_menu() {
  182. var mobile_nav = $(".mobile_nav .mobile_menu_switcher");
  183. var desktop_nav = $(".desktop-nav");
  184. // Navbar sticky
  185. height_line($(".inner-nav.desktop-nav > ul > li > a"), $(".main-nav"));
  186. mobile_nav.css({
  187. "width": $(".main-nav").height() + "px"
  188. });
  189. // Transpaner menu
  190. if ($(".main-nav").hasClass("transparent")) {
  191. $(".main-nav").addClass("js-transparent");
  192. }
  193. var lastScrollTop = 0;
  194. $(window).scroll(function() {
  195. if ($('.sticky-wrapper').length) {
  196. if ($('.sticky-wrapper').hasClass('is-sticky')) {
  197. $(".js-transparent").removeClass("transparent");
  198. $(".main-nav, .nav-logo-wrap .logo, .mobile-nav").addClass("small-height");
  199. } else {
  200. $(".js-transparent").addClass("transparent");
  201. $(".main-nav, .nav-logo-wrap .logo, .mobile-nav").removeClass("small-height");
  202. }
  203. }
  204. });
  205. // Mobile menu toggle
  206. mobile_nav.on('click', function() {
  207. if (desktop_nav.hasClass("js-opened")) {
  208. desktop_nav.slideUp("slow", "easeOutExpo").removeClass("js-opened");
  209. $(this).removeClass("active");
  210. } else {
  211. desktop_nav.slideDown("slow", "easeOutQuart").addClass("js-opened");
  212. $(this).addClass("active");
  213. // Fix for responsive menu
  214. if ($(".main-nav").hasClass("not-top")) {
  215. $(window).scrollTo(".main-nav", "slow");
  216. }
  217. }
  218. });
  219. desktop_nav.find("a:not(.mn-has-sub)").on('click', function() {
  220. if (mobile_nav.hasClass("active")) {
  221. desktop_nav.slideUp("slow", "easeOutExpo").removeClass("js-opened");
  222. mobile_nav.removeClass("active");
  223. }
  224. });
  225. // Sub menu
  226. var mnHasSub = $(".mn-has-sub");
  227. var mnThisLi;
  228. $(".mobile-on .mn-has-sub").find(".fa:first").removeClass("fa-angle-right").addClass("fa-angle-down");
  229. mnHasSub.on('click', function() {
  230. if ($(".main-nav").hasClass("mobile-on")) {
  231. mnThisLi = $(this).parent("li:first");
  232. if (mnThisLi.hasClass("js-opened")) {
  233. mnThisLi.find(".mn-sub:first").slideUp(function() {
  234. mnThisLi.removeClass("js-opened");
  235. mnThisLi.find(".mn-has-sub").find(".fa:first").removeClass("fa-angle-up").addClass("fa-angle-down");
  236. });
  237. } else {
  238. $(this).find(".fa:first").removeClass("fa-angle-down").addClass("fa-angle-up");
  239. mnThisLi.addClass("js-opened");
  240. mnThisLi.find(".mn-sub:first").slideDown();
  241. }
  242. return false;
  243. }
  244. });
  245. $(window).resize(function(){
  246. nav_hover();
  247. })
  248. nav_hover();
  249. function nav_hover() {
  250. $('.inner-nav').each(function(){
  251. if( !($('.inner-nav').hasClass('.mobile_nav')) ) {
  252. $(".mn-has-sub").parent("li").on({
  253. mouseenter: function() {
  254. if (!($(".main-nav").hasClass("mobile-on"))) {
  255. $(this).find(".mn-sub:first").stop(true, true).delay(100).fadeIn("fast");
  256. }
  257. },
  258. mouseleave: function() {
  259. if (!($(".main-nav").hasClass("mobile-on"))) {
  260. $(this).find(".mn-sub:first").stop(true, true).delay(100).fadeOut("fast");
  261. }
  262. }
  263. });
  264. }
  265. });
  266. }
  267. }
  268. function sticky_init() {
  269. if (jQuery('.main-nav').length) {
  270. var jQueryheader = jQuery( ".main-nav" ).clone();
  271. jQuery('body').prepend('<div class="sticky-container"></div>');
  272. var sticky_contaner = jQuery('.sticky-container');
  273. sticky_contaner.html(jQueryheader);
  274. var lastScrollTop = 0;
  275. jQuery(window).scroll(function(event){
  276. var st = jQuery(this).scrollTop();
  277. if (st > lastScrollTop || st <= 120) {
  278. sticky_contaner.removeClass('sticky-on');
  279. } else {
  280. if (jQuery(window).width() <= 1000) {
  281. sticky_contaner.removeClass('sticky-on');
  282. } else {
  283. sticky_contaner.addClass('sticky-on');
  284. }
  285. }
  286. lastScrollTop = st;
  287. });
  288. }
  289. };
  290. // Function for block height 100%
  291. function height_line(height_object, height_donor){
  292. height_object.height(height_donor.height());
  293. height_object.css({"line-height": height_donor.height() + "px"});
  294. $('.inner-nav.desktop-nav').css('opacity', '1')
  295. }
  296. // Accordion
  297. function init_accordion () {
  298. $(".accordion").each(function() {
  299. var allPanels = $(this).children('.content').hide();
  300. allPanels.first().slideDown("easeOutExpo");
  301. $(this).children('.content-title').first().addClass("active");
  302. $(this).children('.content-title').on('click', function(){
  303. var current = $(this).next(".content");
  304. $(this).parent().children('.content-title').removeClass("active");
  305. $(this).addClass("active");
  306. allPanels.not(current).slideUp("easeInExpo");
  307. $(this).next().slideDown("easeOutExpo");
  308. return false;
  309. });
  310. })
  311. }
  312. // Toggle
  313. function init_toggle () {
  314. $(".toggle > .content").hide();
  315. $(".toggle > .content-title.active").next().slideDown();
  316. $(".toggle > .content-title").on('click', function(){
  317. if ($(this).hasClass("active")) {
  318. $(this).next().slideUp("easeOutExpo");
  319. $(this).removeClass("active");
  320. } else {
  321. var current = $(this).next(".content");
  322. $(this).addClass("active");
  323. $(this).next().slideDown("easeOutExpo");
  324. }
  325. return false;
  326. });
  327. }
  328. // counter
  329. var is_count = true
  330. function counter() {
  331. if($(".counter").length) {
  332. var winScr = $(window).scrollTop();
  333. var winHeight = $(window).height();
  334. var ofs = $('.counter').offset().top;
  335. $(window).on('scroll',function(){
  336. winScr = $(window).scrollTop();
  337. winHeight = $(window).height();
  338. ofs = $('.counter').offset().top;
  339. if ( (winScr+winHeight)>ofs && is_count) {
  340. $(".counter").each(function () {
  341. var atr = $(this).attr('data-count');
  342. var item = $(this);
  343. var n = atr;
  344. var d = 0;
  345. var c;
  346. item.text(d);
  347. var interval = setInterval(function() {
  348. c = atr/70;
  349. d += c;
  350. if ( (atr-d)<c) {
  351. d=atr;
  352. }
  353. item.text(Math.floor(d) );
  354. if (d==atr) {
  355. clearInterval(interval);
  356. }
  357. },50);
  358. });
  359. is_count = false;
  360. }
  361. })
  362. }
  363. }
  364. /**/
  365. /* Skill bar */
  366. /**/
  367. function progress_bar_loader() {
  368. if (!is_mobile_device()){
  369. $('.skill-bar-progress').each(function(){
  370. var el = this;
  371. if (is_visible(el)){
  372. if ($(el).attr("processed")!="true"){
  373. $(el).css("width","0%");
  374. $(el).attr("processed","true");
  375. var val = parseInt($(el).attr("data-value"), 10);
  376. var fill = 0;
  377. var speed = val/100;
  378. var timer = setInterval(function() {
  379. if (fill<val){
  380. fill += 1;
  381. $(el).css("width",String(fill)+"%");
  382. var ind = $(el).parent().parent().find(".skill-bar-perc");
  383. $(ind).text(fill+"%");
  384. }
  385. },(10/speed));
  386. }
  387. }
  388. });
  389. } else {
  390. $(".skill-bar-progress").each(function(){
  391. var el = this;
  392. var fill = $(el).attr("data-value");
  393. var ind = $(el).parent().parent().find(".skill-bar-perc");
  394. $(el).css('width',fill+'%');
  395. $(ind).text(fill+"%");
  396. });
  397. }
  398. }
  399. // Is Visible
  400. function is_visible (el){
  401. var w_h = $(window).height();
  402. var dif = $(el).offset().top - $(window).scrollTop();
  403. return ((dif > 0) && (dif<w_h));
  404. }
  405. /**/
  406. /* mobile device detect */
  407. /**/
  408. function is_mobile_device () {
  409. return ( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) );
  410. }
  411. /**/
  412. /* mobile video img */
  413. /**/
  414. function video_img(){
  415. if (is_mobile_device ()) {
  416. var img_url = $('.row_bg_video').attr('data-img-url');
  417. $('.row_bg_video').css({
  418. 'background-image': 'url('+img_url+')'
  419. })
  420. $('.row_bg_video').children().hide();
  421. }
  422. }
  423. /**/
  424. /* Tabs */
  425. /**/
  426. $(".tabs .tabs-btn").on( 'click', function() {
  427. var idBtn = ($(this).attr("data-tabs-id"));
  428. var containerList = $(this).parents(".tabs").find(".container-tabs");
  429. var f = $(".tabs [data-tabs-id=cont-"+idBtn+"]");
  430. $(f).addClass("active").siblings(".container-tabs").removeClass('active');
  431. $(containerList).fadeOut( 0 );
  432. $(f).fadeIn( 300 );
  433. $(this).addClass("active").siblings(".tabs-btn").removeClass('active');
  434. });
  435. $(".linkTipologia").hover( function() {
  436. $(".linkTipologia").removeClass('active');
  437. $(this).addClass("active");
  438. var idBtn = ($(this).data("target"));
  439. console.log(idBtn);
  440. $(".box-nav-type-locations").removeClass('active');
  441. $(idBtn).addClass('active');
  442. });
  443. $(".mobile_btn").click( function() {
  444. if($(this).hasClass( "closed" )){
  445. $(this).addClass("opened");
  446. $(this).removeClass("closed");
  447. }else{
  448. $(this).addClass("closed");
  449. $(this).removeClass("opened");
  450. }
  451. $('.inner-nav').toggle();
  452. });
  453. /**/
  454. /******** Carousel *********/
  455. /**/
  456. var owl_one = $('.owl-one-item')
  457. jQuery(owl_one).each(function() {
  458. jQuery(this).owlCarousel({
  459. itemsCustom : [
  460. [0, 1],
  461. [479, 1],
  462. [738, 1],
  463. [980, 1],
  464. [1170, 1],
  465. ],
  466. navigation: false,
  467. pagination: false,
  468. });
  469. var owl = $(this)
  470. $(this).parent().parent().find(".carousel-nav .next").on( 'click', function(){
  471. owl.trigger('owl.next');
  472. })
  473. jQuery(this).parent().parent().find(".carousel-nav .prev").on( 'click', function() {
  474. owl.trigger('owl.prev');
  475. })
  476. });
  477. /**/
  478. /******** Carousel *********/
  479. /**/
  480. var owl_two = $('.owl-two-item')
  481. jQuery(owl_two).each(function() {
  482. jQuery(this).owlCarousel({
  483. itemsCustom : [
  484. [0, 1],
  485. [479, 1],
  486. [630, 2],
  487. [980, 2],
  488. [1170, 2],
  489. ],
  490. navigation: false,
  491. pagination: false,
  492. });
  493. var owl = $(this)
  494. $(this).parent().parent().find(".carousel-nav .next").on( 'click', function(){
  495. owl.trigger('owl.next');
  496. })
  497. jQuery(this).parent().parent().find(".carousel-nav .prev").on( 'click', function() {
  498. owl.trigger('owl.prev');
  499. })
  500. });
  501. /**/
  502. /******** Carousel *********/
  503. /**/
  504. var owl_three = $('.owl-three-item')
  505. jQuery(owl_three).each(function() {
  506. jQuery(this).owlCarousel({
  507. itemsCustom : [
  508. [0, 1],
  509. [430, 1],
  510. [767, 2],
  511. [980, 3],
  512. [1170, 3],
  513. ],
  514. navigation: true,
  515. navigationText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"],
  516. pagination: false,
  517. });
  518. var owl = $(this)
  519. $(this).parent().parent().find(".carousel-nav .next").on( 'click', function(){
  520. owl.trigger('owl.next');
  521. })
  522. jQuery(this).parent().parent().find(".carousel-nav .prev").on( 'click', function() {
  523. owl.trigger('owl.prev');
  524. })
  525. });
  526. /**/
  527. /******** Carousel *********/
  528. /**/
  529. var owl_three_small = $('.owl-three-item-small')
  530. jQuery(owl_three_small).each(function() {
  531. jQuery(this).owlCarousel({
  532. itemsCustom : [
  533. [0, 1],
  534. [540, 2],
  535. [767, 2],
  536. [980, 3],
  537. [1170, 3],
  538. ],
  539. navigation: true,
  540. navigationText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"],
  541. pagination: false,
  542. });
  543. var owl = $(this)
  544. $(this).parent().parent().find(".carousel-nav .next").on( 'click', function(){
  545. owl.trigger('owl.next');
  546. })
  547. jQuery(this).parent().parent().find(".carousel-nav .prev").on( 'click', function() {
  548. owl.trigger('owl.prev');
  549. })
  550. });
  551. /**/
  552. /******** Carousel *********/
  553. /**/
  554. var owl_four = $('.owl-four-item')
  555. jQuery(owl_four).each(function() {
  556. jQuery(this).owlCarousel({
  557. itemsCustom : [
  558. [0, 1],
  559. [479, 2],
  560. [738, 2],
  561. [980, 3],
  562. [1170, 4],
  563. ],
  564. navigation: false,
  565. pagination: false,
  566. });
  567. var owl = $(this)
  568. $(this).parent().parent().find(".carousel-nav .next").on( 'click', function(){
  569. owl.trigger('owl.next');
  570. })
  571. jQuery(this).parent().parent().find(".carousel-nav .prev").on( 'click', function() {
  572. owl.trigger('owl.prev');
  573. })
  574. });
  575. /**/
  576. /******** Carousel *********/
  577. /**/
  578. var owl_single = $('.owl-single-item')
  579. jQuery(owl_single).each(function() {
  580. jQuery(this).owlCarousel({
  581. itemsCustom : [
  582. [0, 1],
  583. [479, 1],
  584. [738, 1],
  585. [980, 1],
  586. [1170, 1],
  587. ],
  588. autoHeight : true,
  589. navigation: true,
  590. pagination: false,
  591. });
  592. });
  593. /**/
  594. /* Twitter carousel */
  595. /**/
  596. /*
  597. function init_twitter_carusel () {
  598. if($('.twitter-1').length) {
  599. $('.twitter-1').tweet({
  600. username: 'Creative_WS',
  601. count: 3,
  602. loading_text: 'loading twitter feed...',
  603. template: "<i class='fa fa-twitter twitt-icon'></i><p><a href='{user_url}'>@{screen_name}</a>{join}{text}<br>{time}</p>"
  604. });
  605. $('.twitter-1.full-screen .tweet_list').addClass("carousel-pag main-color");
  606. var owl_pag = $('.carousel-pag')
  607. jQuery(owl_pag).each(function() {
  608. jQuery(this).owlCarousel({
  609. itemsCustom : [
  610. [0, 1],
  611. [479, 1],
  612. [738, 1],
  613. [980, 1],
  614. [1170, 1],
  615. ],
  616. navigation: false,
  617. pagination: true,
  618. });
  619. });
  620. }
  621. $('.twitter-footer').tweet({
  622. username: 'Creative_WS',
  623. count: 1,
  624. loading_text: 'loading twitter feed...',
  625. template: "<i class='fa fa-twitter twitt'></i><p><a class='link-color' href='{user_url}'>@{screen_name}</a>{join}{text}<br>{time}</p>"
  626. });
  627. }
  628. */
  629. /**/
  630. /******** Carousel *********/
  631. /**/
  632. var owl_pag = $('.carousel-pag')
  633. jQuery(owl_pag).each(function() {
  634. jQuery(this).owlCarousel({
  635. itemsCustom : [
  636. [0, 1],
  637. [479, 1],
  638. [738, 1],
  639. [980, 1],
  640. [1170, 1],
  641. ],
  642. navigation: false,
  643. pagination: true,
  644. });
  645. });
  646. /**/
  647. /******** Carousel *********/
  648. /**/
  649. var owl_single = $('.owl-two-pag')
  650. jQuery(owl_single).each(function() {
  651. jQuery(this).owlCarousel({
  652. itemsCustom : [
  653. [0, 1],
  654. [479, 2],
  655. [585, 1],
  656. [980, 1],
  657. [1200, 2],
  658. ],
  659. navigation: false,
  660. pagination: true,
  661. });
  662. });
  663. /**/
  664. /******** Carousel *********/
  665. /**/
  666. var owl_single = $('.owl-three-pag')
  667. jQuery(owl_single).each(function() {
  668. jQuery(this).owlCarousel({
  669. itemsCustom : [
  670. [0, 1],
  671. [479, 1],
  672. [738, 2],
  673. [980, 2],
  674. [1170, 3],
  675. ],
  676. navigation: false,
  677. pagination: true,
  678. });
  679. });
  680. /**/
  681. /* fancybox */
  682. /**/
  683. function init_fancy () {
  684. var fancy = $(".fancy");
  685. if (fancy.length) {
  686. fancy.fancybox();
  687. $('.fancybox').fancybox({
  688. helpers: { media: {} }
  689. });
  690. }
  691. }
  692. /**/
  693. /* calendar */
  694. /**/
  695. if ($("#calendar").length) {
  696. $('#calendar').datepicker({
  697. prevText: '<i class="fa fa-angle-left"></i>',
  698. nextText: '<i class="fa fa-angle-right"></i>',
  699. firstDay: 1,
  700. dayNamesMin: [ "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" ]
  701. });
  702. }
  703. /**/
  704. /* masonry */
  705. /**/
  706. function masonry_init(){
  707. $(".masonry").imagesLoaded(function(){
  708. $(".masonry").masonry();
  709. });
  710. }
  711. /**/
  712. /* filter function */
  713. /**/
  714. function filter_init(){
  715. var fselector = 0;
  716. var filter_mode;
  717. if ($("#filter-grid").hasClass("masonry")){
  718. filter_mode = "masonry";
  719. } else{
  720. filter_mode = "fitRows"
  721. }
  722. $("#filter-grid").imagesLoaded(function(){
  723. $("#filter-grid").isotope({
  724. itemSelector: '.all',
  725. layoutMode: filter_mode,
  726. filter: fselector
  727. });
  728. });
  729. $(".filter").on('click', function(){
  730. $(".filter").removeClass("active");
  731. $(this).addClass("active");
  732. fselector = $(this).attr('data-filter');
  733. $("#filter-grid").isotope({
  734. itemSelector: '.all',
  735. layoutMode: filter_mode,
  736. filter: fselector
  737. });
  738. });
  739. }
  740. /**/
  741. /* isotop */
  742. /**/
  743. function init_isotop () {
  744. var $container = $('.isotope-grid');
  745. $('.isotope-grid').isotope({
  746. itemSelector: '.isotope-grid .isotope-item',
  747. columnWidth: '.isotope-item',
  748. masonry: {}
  749. });
  750. if(jQuery('.filter-buttons a.active').length){
  751. var selector = jQuery('.filter-buttons a.active').attr('data-filter');
  752. $container.isotope({ filter: selector });
  753. }
  754. $('.filter-buttons').on('click', 'a', function() {
  755. $('.isotope-grid').isotope({
  756. filter: $(this).data('filter')
  757. });
  758. $(this).addClass('active').siblings().removeClass('active');
  759. return false;
  760. });
  761. }
  762. /**/
  763. /* revolution slider init */
  764. /**/
  765. function init_rev_slider () {
  766. $('.tp-banner, .tp-banner-slider').on("revolution.slide.onloaded",function (e) {
  767. $('.tp-banner, .tp-banner-slider').css("opacity","1");
  768. });
  769. if ($('.tp-banner').length) {
  770. $('.tp-banner').revolution({
  771. dottedOverlay:"custom",
  772. delay:8000,
  773. startwidth:1170,
  774. startheight:700,
  775. lazyLoad:"on",
  776. responsiveLevels:[4096,1025,778,480],
  777. hideThumbs: 1000,
  778. thumbWidth:100,
  779. thumbHeight:50,
  780. thumbAmount:5,
  781. navigation: {
  782. arrows:{enable:true}
  783. },
  784. touchenabled:"on",
  785. onHoverStop:"on",
  786. swipe_velocity: 0.7,
  787. swipe_min_touches: 1,
  788. swipe_max_touches: 1,
  789. drag_block_vertical: false,
  790. keyboardNavigation:"off",
  791. navigationHAlign:"center",
  792. navigationVAlign:"bottom",
  793. navigationHOffset:0,
  794. navigationVOffset:20,
  795. soloArrowLeftHalign:"left",
  796. soloArrowLeftValign:"center",
  797. soloArrowLeftHOffset:20,
  798. soloArrowLeftVOffset:0,
  799. soloArrowRightHalign:"right",
  800. soloArrowRightValign:"center",
  801. soloArrowRightHOffset:20,
  802. soloArrowRightVOffset:0,
  803. shadow:0,
  804. fullWidth:"off",
  805. fullScreen:"on",
  806. spinner:"off",
  807. stopLoop:"off",
  808. stopAfterLoops:-1,
  809. stopAtSlide:-1,
  810. shuffle:"off",
  811. autoHeight:"off",
  812. forceFullWidth:"off",
  813. hideThumbsOnMobile:"off",
  814. hideNavDelayOnMobile:1500,
  815. hideBulletsOnMobile:"off",
  816. hideArrowsOnMobile:"off",
  817. hideThumbsUnderResolution:0,
  818. startWithSlide:0,
  819. disableProgressBar: "on"
  820. })
  821. }
  822. if ($('.tp-banner-slider').length) {
  823. $('.tp-banner-slider').revolution({
  824. sliderType: "standard",
  825. sliderLayout: "auto",
  826. navigation: {
  827. arrows:{
  828. enable:true,
  829. left : {
  830. container:"slider",
  831. h_align:"left",
  832. v_align:"center",
  833. h_offset:0,
  834. v_offset:0,
  835. },
  836. right : {
  837. container:"slider",
  838. h_align:"right",
  839. v_align:"center",
  840. h_offset:0,
  841. v_offset:0
  842. }
  843. }
  844. },
  845. gridwidth: 1170,
  846. gridheight: 700,
  847. dottedOverlay:"custom",
  848. lazyLoad:"on",
  849. responsiveLevels:[4096,1025,778,480],
  850. delay:8000,
  851. parallax: {
  852. type:"mouse",
  853. origo:"slidercenter",
  854. speed:2000,
  855. levels:[2,3,4,5,6,7,12,16,10,50,47,48,49,50,51,55],
  856. },
  857. touchenabled:"on",
  858. onHoverStop:"on",
  859. startWithSlide:0,
  860. disableProgressBar: "on",
  861. hideArrowsOnMobile:"off",
  862. /*onHoverStop:"on"*/
  863. })
  864. }
  865. }
  866. /**/
  867. /* add to cart */
  868. /**/
  869. function init_add_cart () {
  870. $('.add-to-cart').on('click', function(){
  871. $(this).parents(".price-review").addClass("added");
  872. return false;
  873. })
  874. }
  875. /**/
  876. /* active color filter */
  877. /**/
  878. function init_color_filter () {
  879. $('.color-filter li, .brand-filter li').on('click', function(){
  880. $(this).addClass('active').siblings().removeClass('active');
  881. return false;
  882. })
  883. }
  884. /**/
  885. /* woocommerce_price_slider */
  886. /**/
  887. function woocommerce_price_slider(){
  888. var current_min_price
  889. var current_max_price
  890. window.woocommerce_price_slider_params = {
  891. 'currency_pos' : 'right',
  892. 'currency_symbol' : '<sup>$</sup>',
  893. }
  894. // woocommerce_price_slider_params is required to continue, ensure the object exists
  895. if ( typeof woocommerce_price_slider_params === 'undefined' ) {
  896. return false;
  897. }
  898. // Get markup ready for slider
  899. $( 'input#min_price, input#max_price' ).hide();
  900. $( '.price_slider, .price_label' ).show();
  901. // Price slider uses jquery ui
  902. var min_price = $( '.price_slider_amount #min_price' ).data( 'min' ),
  903. max_price = $( '.price_slider_amount #max_price' ).data( 'max' );
  904. current_min_price = parseInt( min_price, 10 );
  905. current_max_price = parseInt( max_price, 10 );
  906. if ( woocommerce_price_slider_params.min_price ) current_min_price = parseInt( woocommerce_price_slider_params.min_price, 10 );
  907. if ( woocommerce_price_slider_params.max_price ) current_max_price = parseInt( woocommerce_price_slider_params.max_price, 10 );
  908. $( 'body' ).on( 'price_slider_create price_slider_slide', function( event, min, max ) {
  909. var from, to;
  910. switch (woocommerce_price_slider_params.currency_pos) {
  911. case 'left':
  912. from = woocommerce_price_slider_params.currency_symbol + min;
  913. to = woocommerce_price_slider_params.currency_symbol + max;
  914. break;
  915. case 'left_space':
  916. from = woocommerce_price_slider_params.currency_symbol + ' ' + min;
  917. to = woocommerce_price_slider_params.currency_symbol + ' ' + max;
  918. break;
  919. case 'right':
  920. from = min + woocommerce_price_slider_params.currency_symbol;
  921. to = max + woocommerce_price_slider_params.currency_symbol;
  922. break;
  923. case 'right_space':
  924. from = min + ' ' + woocommerce_price_slider_params.currency_symbol;
  925. to = max + ' ' + woocommerce_price_slider_params.currency_symbol;
  926. break;
  927. }
  928. $( '.price_slider_amount span.from' ).html( from );
  929. $( '.price_slider_amount span.to' ).html( to );
  930. $( 'body' ).trigger( 'price_slider_updated', min, max );
  931. });
  932. $( '.price_slider' ).slider({
  933. range: true,
  934. animate: true,
  935. min: min_price,
  936. max: max_price,
  937. values: [ current_min_price, current_max_price ],
  938. create : function( event, ui ) {
  939. $( '.price_slider_amount #min_price' ).val( current_min_price );
  940. $( '.price_slider_amount #max_price' ).val( current_max_price );
  941. $( 'body' ).trigger( 'price_slider_create', [ current_min_price, current_max_price ] );
  942. },
  943. slide: function( event, ui ) {
  944. $( 'input#min_price' ).val( ui.values[0] );
  945. $( 'input#max_price' ).val( ui.values[1] );
  946. $( 'body' ).trigger( 'price_slider_slide', [ ui.values[0], ui.values[1] ] );
  947. },
  948. change: function( event, ui ) {
  949. $( 'body' ).trigger( 'price_slider_change', [ ui.values[0], ui.values[1] ] );
  950. },
  951. });
  952. };
  953. /* shop */
  954. if ( $("#ship-to-different-address-checkbox").length ) {
  955. $("#ship-to-different-address-checkbox").on('click', show_address)
  956. show_address()
  957. }
  958. function show_address () {
  959. if ( document.getElementById("ship-to-different-address-checkbox").checked ) {
  960. $(".shipping_address").show();
  961. } else {
  962. $(".shipping_address").hide();
  963. }
  964. }
  965. if ( $(".woocommerce-checkout").length ) {
  966. $(".input-radio").on('click', function(){
  967. $(".payment_box.payment_method_paypal").slideUp(400);
  968. $(".payment_box.payment_method_bacs").slideUp(400);
  969. $(".payment_box.payment_method_cheque").slideUp(400);
  970. switch (true) {
  971. case document.getElementById("payment_method_bacs").checked:
  972. $(".payment_box.payment_method_bacs").slideDown(400);
  973. break;
  974. case document.getElementById("payment_method_cheque").checked:
  975. $(".payment_box.payment_method_cheque").slideDown(400);
  976. break;
  977. case document.getElementById("payment_method_paypal").checked:
  978. $(".payment_box.payment_method_paypal").slideDown(400);
  979. break;
  980. }
  981. })
  982. }
  983. if ($(".contact-form").length) {
  984. /**/
  985. /* contact form */
  986. /**/
  987. /* validate the contact form fields */
  988. $(".contact-form").each(function(){
  989. $(this).validate( /*feedback-form*/{
  990. onkeyup: false,
  991. onfocusout: false,
  992. errorElement: 'p',
  993. errorLabelContainer: $(this).parent().children(".alert.alert-danger").children(".message"),
  994. rules:
  995. {
  996. name: { required: true },
  997. email:{ required: true, email: true },
  998. message: { required: true }
  999. },
  1000. messages:
  1001. {
  1002. name: { required: 'Please enter your name', },
  1003. email:{ required: 'Please enter your email address',
  1004. email: 'Please enter a VALID email address' },
  1005. message: { required: 'Please enter your message' }
  1006. },
  1007. invalidHandler: function()
  1008. {
  1009. $(this).parent().children(".alert.alert-danger").slideDown('fast');
  1010. $("#feedback-form-success").slideUp('fast');
  1011. },
  1012. submitHandler: function(form)
  1013. {
  1014. $(form).parent().children(".alert.alert-danger").slideUp('fast');
  1015. var $form = $(form).ajaxSubmit();
  1016. submit_handler($form, $(form).parent().children(".email_server_responce") );
  1017. }
  1018. });
  1019. })
  1020. /* Ajax, Server response */
  1021. var submit_handler = function (form, wrapper){
  1022. var $wrapper = $(wrapper); //this class should be set in HTML code
  1023. $wrapper.css("display","block");
  1024. var data = {
  1025. action: "email_server_responce",
  1026. values: $(form).serialize()
  1027. };
  1028. //send data to server
  1029. $.post("php/contacts-process.php", data, function(s_response) {
  1030. s_response = $.parseJSON(s_response);
  1031. if(s_response.info == 'success'){
  1032. $wrapper.addClass("message message-success").append('<div role="alert" class="alert alert-success alt alert-dismissible fade in"><button type="button" data-dismiss="alert" aria-label="Close" class="close"></button><i class="alert-icon flaticon-suntour-check"></i><strong>Success!</strong><br>Your message was successfully delivered.</div>');
  1033. $wrapper.delay(5000).slideUp(300, function(){
  1034. $(this).removeClass("message message-success").text("").fadeOut(500);
  1035. $wrapper.css("display","none");
  1036. });
  1037. $(form)[0].reset();
  1038. } else {
  1039. $wrapper.addClass("message message-error").append('<div role="alert" class="alert alert-warning alt alert-dismissible fade in"><button type="button" data-dismiss="alert" aria-label="Close" class="close"></button><i class="alert-icon flaticon-warning"></i><strong>Error!</strong><br>Server fail! Please try again later!</div>');
  1040. $wrapper.delay(5000).hide(500, function(){
  1041. $(this).removeClass("message message-success").text("").fadeIn(500);
  1042. $wrapper.css("display","none");
  1043. });
  1044. }
  1045. });
  1046. return false;
  1047. }
  1048. $('form.form.contact-form').on("click", function() {
  1049. $(this).find('p.error').remove();
  1050. })
  1051. }
  1052. /**/
  1053. /* mobile menu */
  1054. /**/
  1055. function mobile_menu_controller_init() {
  1056. window.mobile_nav = {
  1057. "is_mobile_menu" : false,
  1058. "nav_obj" : jQuery("header .inner-nav>ul").clone(),
  1059. "level" : 1,
  1060. "current_id" : false,
  1061. "next_id" : false,
  1062. "prev_id" : "",
  1063. "animation_params" : {
  1064. "vertical_start" : 100,
  1065. "vertical_end" : 0,
  1066. "horizontal_start" : 0,
  1067. "horizontal_end" : 200,
  1068. "speed" : 300
  1069. }
  1070. }
  1071. mobile_menu_controller();
  1072. jQuery(window).resize( function() {
  1073. mobile_menu_controller();
  1074. });
  1075. mobile_nav_switcher_init ();
  1076. }
  1077. function mobile_nav_switcher_init() {
  1078. var nav_container = jQuery("nav .inner-nav");
  1079. jQuery(document).on("click", "header nav .inner-nav.mobile_nav .mobile_menu_switcher", function() {
  1080. var nav = get_current_nav_level();
  1081. var cls = "opened";
  1082. if ( nav_container.hasClass(cls) ){
  1083. nav.stop().animate( {"margin-top": window.mobile_nav.animation_params.vertical_start + "px","opacity":0}, window.mobile_nav.animation_params.speed, function() {
  1084. nav_container.removeClass(cls);
  1085. })
  1086. } else {
  1087. nav_container.addClass(cls);
  1088. nav.stop().animate( {"margin-top": window.mobile_nav.animation_params.vertical_end + "px","opacity":1}, window.mobile_nav.animation_params.speed );
  1089. }
  1090. });
  1091. }
  1092. function mobile_nav_handlers_init() {
  1093. jQuery("header nav .inner-nav.mobile_nav .button_open").on( "click", function (e){
  1094. var el = jQuery(this);
  1095. var next_id = el.closest("li").attr("id");
  1096. var current_nav_level = get_current_nav_level();
  1097. var next_nav_level = get_next_nav_level( next_id );
  1098. current_nav_level.animate( { "right": window.mobile_nav.animation_params.horizontal_end + "px", "opacity" : 0 }, window.mobile_nav.animation_params.speed, function() {
  1099. current_nav_level.remove();
  1100. jQuery("header nav .inner-nav").append(next_nav_level);
  1101. next_nav_level.css( { "margin-top": window.mobile_nav.animation_params.vertical_end + "px", "right": "-" + window.mobile_nav.animation_params.horizontal_end + "px", "opacity" : 0} );
  1102. next_nav_level.animate( { "right": window.mobile_nav.animation_params.horizontal_start + "px", "opacity" : 1 }, window.mobile_nav.animation_params.speed );
  1103. window.mobile_nav.current_id = next_id;
  1104. window.mobile_nav.level ++;
  1105. mobile_nav_handlers_init ();
  1106. });
  1107. });
  1108. jQuery("header nav .inner-nav.mobile_nav .back>a").on("click", function() {
  1109. var current_nav_level = get_current_nav_level();
  1110. var next_nav_level = get_prev_nav_level();
  1111. current_nav_level.animate( { "right": "-" + window.mobile_nav.animation_params.horizontal_end + "px", "opacity" : 0 }, window.mobile_nav.animation_params.speed, function() {
  1112. current_nav_level.remove();
  1113. jQuery("header nav .inner-nav").append(next_nav_level);
  1114. next_nav_level.css( { "margin-top": window.mobile_nav.animation_params.vertical_end + "px", "right": window.mobile_nav.animation_params.horizontal_end + "px", "opacity" : 0} );
  1115. next_nav_level.animate( { "right": window.mobile_nav.animation_params.horizontal_start + "px", "opacity" : 1 }, window.mobile_nav.animation_params.speed );
  1116. window.mobile_nav.level --;
  1117. mobile_nav_handlers_init ();
  1118. });
  1119. return false;
  1120. });
  1121. }
  1122. function get_current_nav_level() {
  1123. var r = window.mobile_nav.level < 2 ? jQuery( "header nav .inner-nav>ul" ) : jQuery( "header nav .inner-nav ul" );
  1124. r.find("ul").remove();
  1125. return r;
  1126. }
  1127. function get_next_nav_level( next_id ) {
  1128. var r = window.mobile_nav.nav_obj.find( "#" + next_id ).children("ul").first().clone();
  1129. r.find("ul").remove();
  1130. return r;
  1131. }
  1132. function get_prev_nav_level() {
  1133. var r = {};
  1134. if ( window.mobile_nav.level > 2 ){
  1135. r = window.mobile_nav.nav_obj.find( "#" + window.mobile_nav.current_id ).parent("ul").parent("li");
  1136. window.mobile_nav.current_id = r.attr("id");
  1137. r = r.children("ul").first();
  1138. } else{
  1139. r = window.mobile_nav.nav_obj;
  1140. window.mobile_nav.current_id = false;
  1141. }
  1142. r = r.clone();
  1143. r.find("ul").remove();
  1144. return r;
  1145. }
  1146. function mobile_menu_controller() {
  1147. var is_mob = is_mobile();
  1148. if ( is_mob && !window.mobile_nav.is_mobile_menu ){
  1149. set_mobile_menu();
  1150. } else if ( !is_mob && window.mobile_nav.is_mobile_menu ){
  1151. reset_mobile_menu ();
  1152. }
  1153. }
  1154. function set_mobile_menu() {
  1155. var nav = get_current_nav_level();
  1156. $("header nav .inner-nav").addClass("mobile_nav");
  1157. $("header .sticky-menu").addClass("mobile");
  1158. $("header .inner-nav").removeClass("scrolling, desktop-nav");
  1159. nav.css( { "margin-top":window.mobile_nav.animation_params.vertical_start+"px" } );
  1160. window.mobile_nav.is_mobile_menu = true;
  1161. mobile_nav_handlers_init ();
  1162. }
  1163. function reset_mobile_menu() {
  1164. var nav = get_current_nav_level();
  1165. $("header nav .inner-nav").removeClass("mobile_nav opened").addClass('desktop-nav');
  1166. $("header .sticky-menu").removeClass("mobile");
  1167. nav.removeAttr("style");
  1168. window.mobile_nav.is_mobile_menu = false;
  1169. nav.remove();
  1170. reset_mobile_nav_params();
  1171. }
  1172. function reset_mobile_nav_params() {
  1173. jQuery("header nav .inner-nav").append(window.mobile_nav.nav_obj.clone());
  1174. window.mobile_nav.level = 1;
  1175. window.mobile_nav.current_id = false;
  1176. window.mobile_nav.next_id = false;
  1177. }
  1178. function is_mobile() {
  1179. return ( ( $(window).width()<992) || (navigator.userAgent.match(/(Android|iPhone|iPod|iPad)/) ) );
  1180. }
  1181. function add_button_menu() {
  1182. var v = $('header nav .inner-nav>ul').find("li");
  1183. for (var p=0;p<$('header nav .inner-nav>ul').find("li").length;p++) {
  1184. $(v[p]).attr('id','menu-item-'+p);
  1185. }
  1186. $('header nav .inner-nav').append("<i class='mobile_menu_switcher'></i>");
  1187. $('header nav .inner-nav>ul ul').each(function(){
  1188. var x = document.createElement('li');
  1189. $(x).attr("class","back");
  1190. x.innerHTML = "<a href='#'>Back</a>";
  1191. this.insertBefore( x, this.firstElementChild );
  1192. });
  1193. $('header nav .inner-nav li').each(function(){
  1194. if ( $(this).children("ul").length > 0 ) {
  1195. $(this).append("<span class='button_open'></span>");
  1196. };
  1197. });
  1198. };
  1199. /* \mobile menu */
  1200. function cws_page_focus() {
  1201. document.getElementsByTagName('html')[0].setAttribute('data-focus-chek', 'focused');
  1202. window.addEventListener('focus', function() {
  1203. document.getElementsByTagName('html')[0].setAttribute('data-focus-chek', 'focused');
  1204. });
  1205. window.addEventListener('blur', function() {
  1206. document.getElementsByTagName('html')[0].removeAttribute('data-focus-chek');
  1207. });
  1208. };
  1209. /**/
  1210. /* scroll-top */
  1211. /**/
  1212. function scroll_top() {
  1213. $('#scroll-top').on( 'click', function() {
  1214. $('html, body').animate({scrollTop: 0});
  1215. return false;
  1216. });
  1217. if( $(window).scrollTop() > 700 ) {
  1218. $('#scroll-top').fadeIn();
  1219. } else {
  1220. $('#scroll-top').fadeOut();
  1221. }
  1222. $(window).scroll(function() {
  1223. if( $(window).scrollTop() > 700 ) {
  1224. $('#scroll-top').fadeIn();
  1225. } else {
  1226. $('#scroll-top').fadeOut();
  1227. }
  1228. });
  1229. };
  1230. // Grid or List function
  1231. function gridList_init(){
  1232. $("#list-grid>div").on("click", function () {
  1233. $(this).addClass("active").siblings().removeClass("active");
  1234. if ($(this).hasClass("grid-view")) {
  1235. if ($(".list-grid-view .products").hasClass("grid-view")) {
  1236. return false;
  1237. } else {
  1238. $(".list-grid-view .products").fadeOut(300,function() {
  1239. $(".list-grid-view .products").addClass("grid-view").removeClass("list-view").fadeIn(300);
  1240. });
  1241. }
  1242. }
  1243. if ($(this).hasClass("list-view")){
  1244. if ($(".list-grid-view .products").hasClass("list-view")) {
  1245. return false;
  1246. } else {
  1247. $(".list-grid-view .products").fadeOut(300,function(){
  1248. $(".list-grid-view .products").addClass("list-view").removeClass("grid-view").fadeIn(300);
  1249. });
  1250. }
  1251. }
  1252. });
  1253. };
  1254. // login popup
  1255. function popup_login_init(){
  1256. $(".top-login").on("click", function() {
  1257. $(".login-popup").addClass("open");
  1258. })
  1259. $(".login-popup .close-button").on("click", function() {
  1260. $(".login-popup").removeClass("open");
  1261. })
  1262. };
  1263. // Magic line
  1264. function magicline_init(){
  1265. var $el, leftPos, newWidth;
  1266. if ( !$('.inner-nav').hasClass('mobile_nav')) {
  1267. $("header .inner-nav > ul").addClass("magic-line-main");
  1268. $("header .magic-line-main").append("<li class='magic-line-main-li'></li>");
  1269. if ($("header .inner-nav > ul > li > a").hasClass("active")) {
  1270. $("header .inner-nav > ul > li > a.active").parent("li").addClass("active-li");
  1271. }
  1272. var $magicLine = $(".magic-line-main-li");
  1273. $magicLine
  1274. .width($(".active-li").width())
  1275. .css("left", $(".active-li").position().left)
  1276. .data("origLeft", $magicLine.position().left)
  1277. .data("origWidth", $magicLine.width());
  1278. $(".magic-line-main > li:not(.slash)").on({
  1279. mouseenter: function() {
  1280. $el = $(this);
  1281. leftPos = $el.position().left;
  1282. newWidth = $el.width();
  1283. $magicLine.stop().animate({
  1284. left: leftPos,
  1285. width: newWidth
  1286. });
  1287. },
  1288. mouseleave: function() {
  1289. $magicLine.stop().animate({
  1290. left: $magicLine.data("origLeft"),
  1291. width: $magicLine.data("origWidth")
  1292. });
  1293. }
  1294. });
  1295. }
  1296. }
  1297. // Magic line main
  1298. function magicline_main_init(){
  1299. if($('.menu-widget').length) {
  1300. $(".magic-line").append("<li id='magic-line'></li>");
  1301. var recall_magicline_main = function() {
  1302. var $el, leftPos, newWidth;
  1303. var $magicLine = $("#magic-line");
  1304. $magicLine
  1305. .width($(".current_item").width())
  1306. .css("left", $(".current_item a").position().left)
  1307. .data("origLeft", $magicLine.position().left)
  1308. .data("origWidth", $magicLine.width());
  1309. $(".magic-line li").find("a").on({
  1310. mouseenter: function() {
  1311. $el = $(this);
  1312. leftPos = $el.position().left;
  1313. newWidth = $el.parent().width();
  1314. $magicLine.stop().animate({
  1315. left: leftPos,
  1316. width: newWidth
  1317. });
  1318. },
  1319. mouseleave: function() {
  1320. $magicLine.stop().animate({
  1321. left: $magicLine.data("origLeft"),
  1322. width: $magicLine.data("origWidth")
  1323. });
  1324. }
  1325. });
  1326. }
  1327. recall_magicline_main();
  1328. if ($('.menu-widget').hasClass('with-switch')) {
  1329. $('.menu-widget ul li').on('click', function (e){
  1330. e.preventDefault();
  1331. $(this).siblings().removeClass('current_item');
  1332. $(this).addClass('current_item');
  1333. recall_magicline_main();
  1334. })
  1335. }
  1336. }
  1337. }
  1338. // footer fixed
  1339. function footer_height(){
  1340. var fh = $('.footer').outerHeight();
  1341. if ( ( $(window).width()>992) && $('.footer').hasClass('footer-fixed')){
  1342. $('.footer.footer-fixed').addClass('fixed');
  1343. $('body').css('margin-bottom',' ' + fh + 'px');
  1344. } else{
  1345. $('body').css('margin-bottom','0px');
  1346. $('.footer.footer-fixed').removeClass('fixed');
  1347. }
  1348. var fh2 = fh * 1.5
  1349. if ( ( $(window).height()<fh2) ){
  1350. $('body').css('margin-bottom','0px');
  1351. $('.footer.footer-fixed').removeClass('fixed');
  1352. }
  1353. };
  1354. // search tours form
  1355. function search_form_height() {
  1356. var contH = $('.search-tours-wrap .tours-container.active').outerHeight();
  1357. $('.search-tours-content').css({'height': +contH+'px'});
  1358. }
  1359. function search_form_click() {
  1360. $('.tours-tab-btn').each(function(){
  1361. $(this).on('click', function() {
  1362. $(this).siblings().removeClass('active');
  1363. $(this).addClass('active');
  1364. var idBtn = ($(this).attr("data-tours-cat"));
  1365. var containerList = $(this).parents(".search-tours-wrap").find(".tours-container");
  1366. var f = $(".search-tours-wrap [data-tours-cat="+idBtn+"]");
  1367. $(f).addClass("active").siblings(".tours-container").removeClass('active');
  1368. $(containerList).fadeOut( 0 );
  1369. $(f).fadeIn( 600 );
  1370. $(this).addClass("active").siblings(".tours-tab-btn").removeClass('active');
  1371. var contH = $('.search-tours-wrap .tours-container.active').outerHeight();
  1372. $('.search-tours-content').css({'height': +contH+'px'});
  1373. })
  1374. });
  1375. $(document).on('click', '.tours-calendar span', function() {
  1376. $(this).siblings('.calendar-widget').toggleClass('active').fadeToggle('fast');
  1377. if($(this).parent().siblings('.tours-calendar').find('.calendar-widget').hasClass("active")) {
  1378. $(this).parent().siblings('.tours-calendar').find('.calendar-widget').removeClass('active').css("display","none");
  1379. }
  1380. });
  1381. }
  1382. // search tours form resize function
  1383. function search_tours_form_resize() {
  1384. if ($(window).width() <= 991) {
  1385. $(".search-tours-form").addClass("mob-search-form");
  1386. $(".search-tours-form .search-tours-wrap").parent().removeClass("container");
  1387. } else {
  1388. $(".search-tours-form").removeClass("mob-search-form");
  1389. $(".search-tours-form .search-tours-wrap").parent().addClass("container");
  1390. }
  1391. }
  1392. // slider info mobile function
  1393. function slider_info_mob(){
  1394. if ($(window).width() <= 980) {
  1395. $('.slider-info-item').addClass('mobile-on');
  1396. } else {
  1397. $('.slider-info-item').removeClass('mobile-on').removeClass('active');
  1398. }
  1399. }
  1400. $('.slider-info-item').each(function(){
  1401. $(this).on('click', function() {
  1402. if ($('.slider-info-item').hasClass('mobile-on')){
  1403. $(this).toggleClass("active").siblings(".slider-info-item").removeClass('active');
  1404. }
  1405. })
  1406. });
  1407. // scrollto function init
  1408. function scrollTo_init(){
  1409. var elementClick, destination;
  1410. $("a.scrollto").on('click', function () {
  1411. elementClick = jQuery(this).attr("href");
  1412. destination = jQuery(elementClick).offset().top;
  1413. $("html:not(:animated),body:not(:animated)").animate({scrollTop: destination}, 500);
  1414. return false;
  1415. });
  1416. };
  1417. // flexslider init
  1418. function flexslider_init(){
  1419. $('#flex-carousel').flexslider({
  1420. animation: "slide",
  1421. controlNav: false,
  1422. animationLoop: false,
  1423. slideshow: false,
  1424. itemWidth: 130,
  1425. itemMargin: 5,
  1426. asNavFor: '#flex-slider'
  1427. });
  1428. $('#flex-slider').flexslider({
  1429. animation: "slide",
  1430. controlNav: false,
  1431. animationLoop: false,
  1432. slideshow: false,
  1433. sync: "#flex-carousel"
  1434. });
  1435. }