PageSourceSearch

https://www.bestofsigns.com/blog/wp-content/themes/alison/assets/js/core.js

js bestofsigns.com collected 2026-09-26 00:24:31 UTC 12,689 bytes, 420 lines download raw bytes

1jQuery(document).ready(function($) {
2
3	"use strict";
4
5	var deviceAgent = navigator.userAgent.toLowerCase();
6    if(/(iphone|ipod|ipad).* os 8_/.test(deviceAgent)){
7		$("video, audio").removeAttr("preload");
8	}
9
10	$('.post-featured-item.gallery-post .justified-gallery a').attr("itemprop","contentUrl");
11
12	$('.post-featured-item.gallery-post .justified-gallery a').on("click",function(e){
13		e.preventDefault();
14		var $this = $(this);
15		var pswpElement = $(".pswp")[0];
16		var lightbox_item = $this.parents(".justified-gallery").find(".item");
17		var lightbox_item_link = $this.parents(".justified-gallery").find(".item a");
18		var itemCount = lightbox_item.length;
19		var pic_index = $this.parents(".item").index();
20
21		var i;
22		var items = [];
23		var options={
24			index: pic_index,
25			bgOpacity:1,
26			history:false,
27			barsSize: {top:0, bottom:0},
28			shareButtons: [
29			    {id:'facebook', label:'Share on Facebook', url:'https://www.facebook.com/sharer/sharer.php?u={{url}}'},
30			    {id:'twitter', label:'Tweet', url:'https://twitter.com/intent/tweet?text={{text}}&url={{url}}'},
31			    {id:'pinterest', label:'Pin it', url:'http://www.pinterest.com/pin/create/button/?url={{url}}&media={{image_url}}&description={{text}}'}
32			]
33		};
34
35
36		for ( i = 0; i < itemCount; i++) {
37			var item = {
38	            src: $(lightbox_item_link[i]).attr("href"),
39	            w:0,
40	   			h:0,
41	   			title:$(lightbox_item_link[i]).find("img").attr("alt")
42	         };
43	         items.push(item);
44		};
45		
46		
47		var gallery = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items,options);
48		gallery.listen('gettingData', function(index, item) {
49		    if (item.w < 1 || item.h < 1) { // unknown size
50		        var img = new Image(); 
51		        img.onload = function() { // will get size after load
52			        item.w = this.width; // set image width
53			        item.h = this.height; // set image height
54					gallery.invalidateCurrItems(); // reinit Items
55					gallery.updateSize(true); // reinit Items
56		        }
57		    	img.src = item.src; // let's download image
58		    }
59		});
60		gallery.init();
61	})
62
63
64	$(window).load(function(){
65
66		if($("#sidebar").length>0 && $("html").hasClass("no-mobile-device") && $("body").hasClass("sticky-sidebar")){
67			// Fixed Sidebar
68			setTimeout(function(){
69				sticky_sidebar();
70			},600);
71
72			$(window).resize(function(){
73				sticky_sidebar();
74			});
75		}
76
77		// Masonry Layout
78		if($('.masonry-layout').length>0){
79			var masonry_layout = $('.masonry-layout');
80			masonry_layout.masonry({
81				columnWidth: '.post-item',
82			  	itemSelector: '.post-item',
83			  	transitionDuration: 0
84			}).parents('.masonry-container').addClass("open");
85		
86			$(window).resize(function(){
87				setTimeout(function(){
88					masonry_layout.masonry('reloadItems').masonry();
89				},100);
90			});
91		}
92
93		//Instagram Fix
94		fixInstagram();
95        $(window).resize(function(){
96        	fixInstagram();
97        });
98
99        if($(".featured-area").length===1){
100			$('.featured-area .slider-item').css('background-image', 'url('+$('.featured-area .slider-item').data('bg-src')+')').addClass('animated');
101		}
102		
103	})
104
105	// Menu
106	$('.main-navigation-wrapper').each(function(){
107		var menu_mobile = $(this).find(".menu-mobile");
108		$(this).find(".nav-menu").slicknav({
109			prependTo:menu_mobile,
110			label:''
111		});
112	})
113	
114	// Scroll to top
115	
116	$('.goto-top').click(function(){
117		$('html, body').animate({scrollTop : 0},800);
118		return false;
119	});	
120
121	$(window).on("scroll",function(){
122		var scrollTop = $(window).scrollTop();
123		if(scrollTop > 800) {
124			if(!$(".goto-top").hasClass("on")){
125				$(".goto-top").addClass("on");
126			}
127		}
128		else if (scrollTop <= 800) {
129			if($(".goto-top").hasClass("on")){
130				$(".goto-top").removeClass("on");
131			}
132		}
133	});
134
135	// Search
136	
137	$('body').on('click', '.top-search-area a', function ( e ) {
138		e.preventDefault();
139		var top_search_link = $(this);
140		if($('body').hasClass("search-open")){
141			$('body').removeClass("search-open");
142		}
143		else {
144    		$('body').addClass("search-open");
145    		setTimeout(function(){
146    			top_search_link.parents(".top-search-area").find(".search-form-area .search").focus();
147    		},100);
148
149    		$(document).on("click", function (e){
150			    var container = $(".top-search-area");
151
152			    if (!container.is(e.target) && container.has(e.target).length === 0){
153					$('body').removeClass("search-open");
154			    }
155			});
156    	}
157    });
158	
159	// Swiper
160	var featured_area_type = $(".featured-area").data("slider-type");
161	var slides_PerView;
162	var ww = $(window).outerWidth();
163
164	if(featured_area_type == "slider"){
165		slides_PerView = 1;
166
167	}
168
169	if($("html").hasClass("ie9")){
170		var featured_area_width = $('.featured-area').outerWidth();
171		var featured_slide_number = $('.featured-area .swiper-slide').length;
172		$('.featured-area .swiper-wrapper').outerWidth(featured_area_width/slides_PerView*featured_slide_number).parents(".featured-area").addClass("open");
173		
174		$(window).resize(function(){
175			featured_area_width = $('.featured-area').outerWidth();
176			$('.featured-area .swiper-wrapper').outerWidth(featured_area_width/slides_PerView*featured_slide_number).parents(".featured-area").addClass("open");
177		});
178	}
179
180	if($(".featured-area .slider-item").length>1){
181		var featured_swiper_transition, featured_area_autoplay_enabled, autoPlay_value;
182		var slider =$(".featured-area");
183		featured_swiper_transition = slider.data("slider-transition");
184		featured_area_autoplay_enabled = slider.data("slider-autoplay-enabled");
185		
186		(featured_area_autoplay_enabled) ? autoPlay_value = 4000 : autoPlay_value = "";
187	
188		var featured_swiper = new Swiper('.featured-area .swiper-container', {
189	        //pagination: '.swiper-pagination',
190	        slidesPerView: slides_PerView,
191	        paginationClickable: true,
192            watchActiveIndex: true,
193	        spaceBetween: 0,
194	        preloadImages: false,
195	        preventClicks: false,
196	        preventClicksPropagation: false,
197	        grabCursor: true,
198	        watchSlidesVisibility: true,
199	        effect: featured_swiper_transition,
200	        autoplay: autoPlay_value,
201        	autoplayDisableOnInteraction: false,
202	        DOMAnimation:false,
203	        loop: true,
204	        centeredSlides: true,
205			loopedSlides: 100,
206	        onInit: function (swiper) {
207				swiper.stopAutoplay();
208	        	if(featured_area_type == "slider"){
209					$(window).load(function(){
210						$(".featured-area .swiper-slide:nth-of-type("+parseInt(swiper.activeIndex+1)+")").addClass("animated");
211					})
212					$('.swiper-slide-visible').each(function(){
213						$(this).find(".slider-item").css('background-image', 'url('+$(this).find(".slider-item").data('bg-src')+')');
214						$(this).next().find(".slider-item").css('background-image', 'url('+$(this).next().find(".slider-item").data('bg-src')+')');
215					})
216            	}
217
218            	$(".featured-area .swiper-button-prev-custom, .featured-area .swiper-button-next-custom").show();
219				
220				var mouse_down = false;
221				slider.on("mousedown",function(){
222					mouse_down = true;
223				})
224				
225				var timeout = null;
226				slider.on("mousemove",function(){
227					if(mouse_down){
228						if (timeout !== null) {
229							clearTimeout(timeout);
230							if($(".featured-area .swiper-slide-visible .click-overlay").length==0){
231								$(".featured-area .swiper-slide-visible").append('<div class="click-overlay"></div>');
232							}
233						}
234
235						timeout = setTimeout(function() {
236							$(".featured-area .swiper-slide .click-overlay").remove();
237						}, 100);	
238					}
239				})
240				slider.on("mouseup",function(){
241					mouse_down = false;
242					timeout = null;
243					$(".featured-area .swiper-slide .click-overlay").remove();
244				})
245				
246            },
247            onSlideChangeStart: function(swiper){
248            	if(featured_area_type == "slider"){
249					$('.swiper-slide-visible').each(function(){
250						$(this).find(".slider-item").css('background-image', 'url('+$(this).find(".slider-item").data('bg-src')+')');
251						$(this).next().find(".slider-item").css('background-image', 'url('+$(this).next().find(".slider-item").data('bg-src')+')');
252					})
253				}
254			},
255			onTransitionEnd: function(swiper){
256				setTimeout(function(){
257					$(".featured-area .swiper-slide").removeClass("animated");
258					$(".featured-area .swiper-slide:nth-of-type("+parseInt(swiper.activeIndex+1)+")").addClass("animated");
259				},100);
260			}
261	    });
262
263		$(".featured-area .swiper-button-next-custom").on("click",function(){
264			featured_swiper.slideNext();
265		});
266
267		$(".featured-area .swiper-button-prev-custom").on("click",function(){
268			featured_swiper.slidePrev();
269		});
270		
271		$(window).load(function(){
272			featured_swiper.startAutoplay();
273		});
274
275	    slider.find(".swiper-container").hover(
276	    	function() {featured_swiper.stopAutoplay()},
277	    	function() {featured_swiper.startAutoplay()}
278		);
279	}
280	else {
281		$('.featured-area .slider-item').css('background-image', 'url('+$('.featured-area .slider-item').data('bg-src')+')');
282	}
283
284    if($(".swiper-pagination-bullet").length>1) {
285    	$(".swiper-pagination").addClass("show");
286    }
287	
288	//Media element
289	if($(".post-featured-item video").length>0){
290		$('.post-featured-item video').mediaelementplayer().attr("poster","");
291	}
292
293	if($(".post-featured-item audio").length>0){
294		$('.post-featured-item audio').mediaelementplayer({
295			audioWidth: "100%",
296			audioHeight: 34
297		});
298	}
299
300	//Justified Gallery
301	if($(".post-featured-item .justified-gallery").length>0){
302		var row_height;
303		$(".post-featured-item .justified-gallery").each(function(){
304
305			row_height = $(this).data("row-height");
306			if ($(window).width() < 1024) {
307				row_height = row_height/1.2;
308			}
309			if(!row_height){
310				row_height = 300;
311			}
312			
313			if($(".post-list").hasClass("masonry")){
314				if($("#main-container > .container").hasClass("sidebar-open")){
315					row_height = row_height/2;
316				}
317				else {
318					row_height = row_height/2.6;
319				}
320			}
321
322			$(this).justifiedGallery({
323				rowHeight: row_height,
324				maxRowHeight: 0,
325				lastRow: "justify",
326				captions: false,
327				margins:5,
328				border:0
329			});
330		});
331	}
332
333	if($("#comments").length>0){
334		$(".comment-button").on("click",function(e){
335			var urlhashOfftestTop = $("#comments").offset().top-120;
336			$('html, body').animate({scrollTop : urlhashOfftestTop},800);
337			e.preventDefault();
338		});
339		
340		var urlHash = "#" + window.location.href.split("#")[1];
341		if(urlHash == "#comments"){
342			setTimeout ( function () {
343				var urlhashOfftestTop = $("#comments").offset().top-120;
344				$(window).scrollTop(urlhashOfftestTop);
345			},20);
346		}
347
348		var reqinput_text = $(".post-comments .commment-form-wrapper").data("required-text");
349		var emailcheck_text = $(".post-comments .commment-form-wrapper").data("email-check-text");
350		$(".post-comments .comment-form").on("submit",function(e){
351
352			$(this).find('span[role="alert"]').remove();
353			var reqinput = $(this).find("[aria-required='true']");
354			var reqinput_html = '<span role="alert" class="wpcf7-not-valid-tip">'+reqinput_text+'</span>';
355			var emailcheck_html = '<span role="alert" class="wpcf7-not-valid-tip">'+emailcheck_text+'</span>';
356
357			reqinput.each(function(){
358				var reqinput_val = $(this).val();
359			    if ( reqinput_val.length==0 ) {
360					$(this).after(reqinput_html);
361					e.preventDefault();
362				}
363				
364				if($(this).attr("id") == "email" && reqinput_val.length>0){
365					var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
366    				var emailvalid =  re.test(reqinput_val);
367    				if(!emailvalid){
368						$(this).after(emailcheck_html);
369    					e.preventDefault();
370    				}
371				}
372			})
373			
374		})
375
376		$(".post-comments .comment-form [aria-required='true']").on("focus",function(){
377			$(this).next('span[role="alert"]').fadeOut();
378		})
379
380		$(".post-comments .comment-form [aria-required='true']").removeAttr("required");
381
382	}
383
384	$(".post-entry").fitVids();
385	
386});
387
388function sticky_sidebar(){
389	"use strict";
390
391	var sticky_header_h = jQuery('.main-navigation-wrapper').outerHeight()+60;
392	jQuery('#sidebar').theiaStickySidebar({
393		containerSelector: '#main-container',
394		additionalMarginTop: sticky_header_h,
395		additionalMarginBottom: 30
396    });
397}
398
399function fixInstagram() {
400	"use strict";
401    
402	var count = jQuery('#alternate-widget-area .jr-insta-slider').length;
403	if( count > 0) {
404		var maxImageHeight;
405	    jQuery('#alternate-widget-area li').each(function(){
406	        var h = jQuery(this).height();
407	        if(maxImageHeight) {
408	            if (h < maxImageHeight) { 
409	              maxImageHeight = h;
410	            }
411	    	}
412	    	else {
413	    		maxImageHeight = h;
414	    	}
415	    });
416	    if (maxImageHeight) {
417	      jQuery('#alternate-widget-area ul').css({height:maxImageHeight});
418	    };
419	}
420}

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.