PageSourceSearch

https://fairyoak.com/js/script-common.js

js fairyoak.com collected 2026-10-02 13:50:01 UTC 13,233 bytes, 517 lines download raw bytes

1(function ($) {
2
3	/*---------------------------
4
5	START Functions declaration
6
7	----------------------------*/
8
9
10	function backgound_image(){
11
12	//Raplace image for background fullwidth
13
14		$("img.replace").each(function(i, elem) {
15			var img = $(elem);
16			var node_block = $('.img-box-replace');
17			var node_slide = $('.img-box-slide');
18			//var section_block = $('section.newsletter');
19
20
21			var div = $("<div />").css({
22			background: "url(" + img.attr("src") + ") no-repeat",
23			width: img.width() + "px",
24			height: node_block.height() + "px",
25			//height: section_block.height() + "px"
26			});
27
28			div.html(img.attr("alt"));
29			div.addClass("replacedImage");
30
31			img.replaceWith(div);
32
33		});
34	}
35	var globalID;
36	function repeatOften() {
37	  $(".leaf,.twins,.bg").delay(500).addClass("animate");
38		$(".stars div").addClass("animate");
39
40	  globalID = requestAnimationFrame(repeatOften);
41	}
42
43	function night_time(){
44		var currentTime = new Date().getHours();
45		//alert(currentTime);
46		if (currentTime > 14) {
47			$('.bg').css({
48				'background-image':'url(../images/bg-pages.jpg)',
49				'background-repeat':'no-repeat',
50				'background-position':'center top'
51			});
52		}
53	}
54
55	function on_img(){
56		/* img unveil lazyload */
57		$("img.unveil").unveil(200, function() {
58		  $(this).load(function() {
59		    this.style.opacity = 1;
60		  });
61		});
62
63		/*retina replace*/
64		$('.logo,.retina,.deco-top-20,input[type="radio"] + label').retinaReplace();
65
66	}
67
68	// function social_share(){
69	// 	//Share on twitter
70	// 	$('.share-tw').each(function(){
71	// 		$(this).attr('href', function(i, currentAttribute){
72	// 			var target_tw = $(this).parents('.item').find('.text-append').text();
73	// 		    if(target_tw.length > 110){
74	// 				return "https://twitter.com/intent/tweet?text=" + target_tw.substring(0,110) + "... www.fairyoak.com";
75	// 			}else{
76	// 				return "https://twitter.com/intent/tweet?text=" + target_tw + "... www.fairyoak.com";
77	// 			}
78	// 		});
79	// 	});
80
81	// 	$('.shop .share-tw').each(function(){
82	// 		$(this).attr('href', function(i, currentAttribute){
83	// 			var target_tw = $(this).parents('.shop-book').find('.box-info h4').text();
84	// 		    if(target_tw.length > 110){
85	// 				return "https://twitter.com/intent/tweet?text=" + target_tw.substring(0,110) + "... www.fairyoak.com";
86	// 			}else{
87	// 				return "https://twitter.com/intent/tweet?text=" + target_tw + "... www.fairyoak.com";
88	// 			}
89	// 		});
90	// 	});
91	// }
92
93	function shop_tabs(){
94		/*menu shop link acquista*/
95		$('.buttons .cart.enabled').on('mouseenter',function(){
96				$(this).siblings('ul.sub-menu-cart').stop().animate({
97				'bottom':'60px',
98				'opacity':'1',
99				'z-index':'1'
100				});
101				$(this).addClass('open').css({'background-color':'#f6a704'});
102		});
103		$('.shop .buttons ul li:last-child').on('mouseleave',function(){
104				$(this).find('ul.sub-menu-cart').stop().animate({
105				'bottom':'0px',
106				'opacity':'0',
107				'z-index':'-1'
108				});
109				$(this).find('.cart.enabled').removeClass('open').css({'background-color':'inherit'});
110		});
111		$('.buttons .tabs a').click(function(){
112			var class_bt = $(this).attr('class');
113			$(this).parents('.shop-book').children('.tab-expand').find('.' + class_bt).toggle().addClass('active').siblings().removeClass('active').hide().parents('.shop-book').siblings().children('.tab-expand').find('div.collapse').removeClass('active').fadeOut('fast');
114		});
115	}
116
117
118	function home_grid(){
119		/* mousover grid */
120		$( ".item.txt-block" ).hover(
121			  function() {
122			    $( this ).find('.col-hover').stop().slideDown();
123			  }, function() {
124			    $( this ).find('.col-hover').stop().slideUp();
125			  }
126	  	);
127
128	  	$( ".item.img-block" ).bind('click',function(){
129			$(this).addClass('clicked');
130			$( this ).find('.col-hover').stop().slideDown();
131	  	});
132	  	$( ".item.img-block" ).mouseleave(function(){
133		  	if($(this).hasClass('clicked')){
134			  	$(this).removeClass('clicked');
135			  	$( this ).find('.col-hover').stop().slideUp();
136			 }
137	  	});
138	  	/* scrollbars grid */
139	  	$('.scrollbar').mCustomScrollbar({
140		  	callbacks:{
141					onScrollStart:function(){
142				      // console.log("Scrolling started...");
143				      $(this).parents('.item').stop().mouseleave(function(){
144					      // console.log("esco dal blocco");
145					      $(this).find('.scrollbar').mCustomScrollbar("scrollTo",0);
146				      });
147
148				      }
149			    }
150	  	});
151
152	}
153
154
155	function social_shop(){
156		/* mousover grid */
157		$( ".shop-book" ).hover(
158			  function() {
159			    $( this ).find('.col-hover').stop().slideDown();
160			  }, function() {
161			    $( this ).find('.col-hover').stop().slideUp();
162			  }
163	  	);
164
165/*
166	  	$( ".item.img-block" ).bind('click',function(){
167			$(this).addClass('clicked');
168			$( this ).find('.col-hover').stop().slideDown();
169	  	});
170	  	$( ".item.img-block" ).mouseleave(function(){
171		  	if($(this).hasClass('clicked')){
172			  	$(this).removeClass('clicked');
173			  	$( this ).find('.col-hover').stop().slideUp();
174			 }
175	  	});
176*/
177
178
179	}
180
181
182	function header_menu(){
183				/* scroll top */
184
185		$(window).scroll(function() {
186		    var scroll = $(window).scrollTop();
187
188		     //>=, not <=
189		    if (scroll > 94) {
190		        //clearHeader, not clearheader - caps H
191				$(".menu").addClass("fixed").delay(1000).animate({
192					top:'0px'
193				});
194		        $('.slider-top-container').css({'padding-top':'114px'});
195						$('.biography .main').css({'padding-top':'94px'});
196
197		        if($(window).width() > 767){
198			       $('.top-page').css({'padding-top':'154px'});
199		        }else{
200			       $('.top-page').css({'padding-top':'110px'});
201				}
202
203
204		    }else{
205			   	$(".menu").removeClass("fixed").removeAttr( "style" );
206			    $('.slider-top-container').css({'padding-top':'20px'});
207			    $('.top-page').css({'padding-top':'60px'});
208					$('.biography .main').css({'padding-top':'0px'});
209		    }
210		});
211
212		$('.scroll-top').click(function(){
213			$('html, body').animate({scrollTop : 0},800);
214			return false;
215		});
216
217	    /* bouncy nav */
218
219	    var is_bouncy_nav_animating = false;
220		//open bouncy navigation
221		$('.cd-bouncy-nav-trigger').on('click', function(){
222			if($(this).hasClass('open')){
223
224				triggerBouncyNav(false);
225				$('.nav-toggle').removeClass( "active" );
226				//alert('bounce');
227				$(this).removeClass('open');
228				// console.log('click');
229
230			} else {
231
232				triggerBouncyNav(true);
233				$('.nav-toggle').addClass( "active" );
234				$(this).addClass('open');
235
236			}
237
238		});
239
240		$('.cd-bouncy-nav-modal').on('click', function(event){
241			if($(event.target).is('.cd-bouncy-nav-modal')) {
242				triggerBouncyNav(false);
243				$('.nav-toggle').removeClass( "active" );
244				$('.cd-bouncy-nav-trigger').toggleClass('open');
245			}
246		});
247
248		function triggerBouncyNav($bool) {
249			//check if no nav animation is ongoing
250			if( !is_bouncy_nav_animating) {
251				is_bouncy_nav_animating = true;
252
253				//toggle list items animation
254				$('.cd-bouncy-nav-modal').toggleClass('fade-in', $bool).toggleClass('fade-out', !$bool).find('li:last-child').one('webkitAnimationEnd oanimationend msAnimationEnd animationend', function(){
255					$('.cd-bouncy-nav-modal').toggleClass('is-visible', $bool);
256					if(!$bool) $('.cd-bouncy-nav-modal').removeClass('fade-out');
257					is_bouncy_nav_animating = false;
258				});
259
260				//check if CSS animations are supported...
261				if($('.cd-bouncy-nav-trigger').parents('.no-csstransitions').length > 0 ) {
262					$('.cd-bouncy-nav-modal').toggleClass('is-visible', $bool);
263					is_bouncy_nav_animating = false;
264				}
265			}
266		}
267
268	}
269	function form_contatti(){
270
271	$('.contactus').validate({
272		 rules: {
273	        email: 'required',
274	        email2: {
275	            equalTo: '#email'
276	        }
277	    }
278	});
279
280	$(document).on('submit', '.contactus', function() {
281	    $.ajax({
282	      url : 'mail.php',
283	      type : 'post',
284	      data : $(this).serialize(),
285	      success : function(data) {
286	       $('#message-popup .content-message.success').fadeIn().delay(1400).fadeOut('fast');
287	       $(".contactus input,.contactus textarea").val('');
288	     },
289	     error : function(xhr, err) {
290	      $('#message-popup .content-message.error').fadeIn();
291	    }
292	  });
293	    return false;
294	  });
295
296	}
297
298		function slide_author(){
299			var window_height = $(window).height();
300			var menu_height = $('header .menu').height();
301			$('.biography .slide').not('.biography .slide:last-child').height(window_height);
302			$('.biography .slide#slide0').height(window_height - menu_height);
303			var slide_height = 	$('.biography svg.line-center.bottom').parents('.slide').height();
304			$('.biography svg.line-center.bottom').height(slide_height - 320);
305
306			// if($('.biography .main').width() > 0){
307			// 	$('.biography .main').betterScroll();
308			// }
309
310		}
311
312		function onScroll(event){
313		    var scrollPos = $(document).scrollTop() + 600;
314		    $('.manu-bio a').each(function () {
315		        var currLink = $(this);
316		        var refElement = $(currLink.attr("href"));
317		        if (refElement.position().top <= scrollPos && refElement.position().top + refElement.height() > scrollPos) {
318		            $('.manu-bio a').removeClass("active");
319		            currLink.addClass("active");
320								refElement.find('.book').animate({
321									'margin-top':'0px',
322									'opacity':1
323								},800);
324								refElement.find('.img-box-slide').removeClass('filter');
325		        }
326		        else{
327		            currLink.removeClass("active");
328		        }
329		    });
330
331
332		}
333
334		function anchor_slide(){
335			$('a[href^="#"]').on('click', function (e) {
336				 e.preventDefault();
337				 $(document).off("scroll");
338				 $('a').each(function () {
339						 $(this).removeClass('active');
340				 });
341				 $(this).addClass('active');
342
343				 var target = this.hash,
344							menu = target;
345				 $target = $(target);
346
347				 $('html, body').stop().animate({
348						 'scrollTop': $target.offset().top+2
349				 }, 500, 'swing', function () {
350						 window.location.hash = target;
351						 $(document).on("scroll", onScroll);
352
353				 });
354			});
355
356		}
357
358	/*---------------------------
359
360	START Document Ready
361
362	----------------------------*/
363
364
365    $(document).ready(function () {
366
367	//	social_share();
368		shop_tabs();
369		home_grid();
370		header_menu();
371		form_contatti();
372		social_shop();
373		backgound_image();
374		//slide_author();
375		anchor_slide();
376		on_img();
377		//night_time();
378
379		$('.slick').slick({
380			dots: true,
381			infinite: true,
382			speed: 300,
383			slidesToShow: 1,
384			adaptiveHeight: true
385		});
386
387		// var slider_container_height = $('.slider-container').height();
388		// $('.horizontal').height(slider_container_height);
389		// 	// init controller
390		// 	var controller = new ScrollMagic.Controller({vertical: true});
391		//
392		// 	// build tween
393		// 	var tween = TweenMax.to("#target", 0.5, {height: "+=" + slider_container_height});
394		//
395		// 	// build scene
396		// 	var scene = new ScrollMagic.Scene({triggerElement: "#trigger", duration: 8
396000})
397		// 					.setTween(tween)
398		// 					.addIndicators() // add indicators (requires plugin)
399		// 					.addTo(controller);
400
401		//$('#youtube1').mediaelementplayer();
402
403	  	/* intro loading */
404
405	  	progress(1000, $('#progressBar'));
406
407			// $(document).mouseup(function (e)
408			// {
409			//     var container = $(".tab-expand .trailer");
410			//
411			//     if (!container.is(e.target) // if the target of the click isn't the container...
412			//         && container.has(e.target).length === 0) // ... nor a descendant of the container
413			//     {
414			//          $('.trailer iframe').attr('src', $('iframe').attr('src'));
415			//     }
416			// });
417
418
419			// Pretty simple huh?
420			// var scene = document.getElementById('scene');
421			// var parallax = new Parallax(scene);
422	  	/*bootstrap*/
423
424			$('.toggle-button').click(function(){
425				$(this).next('.toggle-section').toggle();
426			});
427
428
429
430		$('.dropdown-toggle').dropdown();
431
432		$('.selectpicker').selectpicker({
433		      size: 4,
434		      style: 'dft-select'
435		  });
436
437		//ON scroll Author slides
438		$(document).on("scroll", onScroll);
439
440		var slide_height = $('#slide0').height(),
441		$window = $(window),
442		$sidebar   = $(".manu-bio"),
443		first_slide = $('#slide0').height(),
444		offset     = $sidebar.offset(),
445		topPadding = 15,
446		menu_bio = $(".manu-bio").outerHeight(),
447		page_height = $('.biography .main').outerHeight(),
448		last_slide_height = $('.biography .slide:last-child').outerHeight();
449
450
451
452		$(document).on("scroll", function(){
453				if ($window.scrollTop() > first_slide) {
454						$sidebar.addClass('visibile');
455			  }else {
456					$sidebar.removeClass('visibile');
457		    }
458				if($window.scrollTop() > page_height - last_slide_height){
459					$sidebar.removeClass('visibile');
460				}
461
462		});
463
464
465
466    });/*document ready end*/
467
468
469
470
471
472
473    /*---------------------------
474
475	START Img Load event
476
477	----------------------------*/
478
479	/*---------------------------
480
481	START Window load event
482
483	----------------------------*/
484
485    $(window).load(function () {
486
487
488		//backgound_image();
489
490		$('#loading').fadeOut( function(){
491				globalID = requestAnimationFrame(repeatOften);
492		});
493
494		/* Packery NORMAL grid */
495
496		var $container = $('.grid');
497		$container.packery({
498		  itemSelector: '.item',
499		  gutter: 20
500		});
501
502
503    });/*window load end*/
504
505	// PROGRESS BAR
506
507	function progress(percent, $element) {
508		var progressBarHeight = percent * $element.height() / 500;
509		$element.find('div#bar-loader').velocity({ height: progressBarHeight }, 9000, function(){
510
511		});
512	}
513
514
515
516
517})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.