PageSourceSearch

https://thetig.com/wp-content/themes/thetig/js/main.js?ver=2.0

js thetig.com collected 2026-10-02 04:48:41 UTC 10,337 bytes, 400 lines download raw bytes

1(function($){
2	$(function(){
3
4		$("body").fitVids();
5
6		$(".post-content h3").wrapInner( "<span></span>");
7		
8		$(".news-trigger").click(function(){
9		  $(this).parent().toggleClass('current-menu-item');
10		  $(".news-pop").slideToggle();
11		  return false;
12		});
13	
14		$(".search-trigger").click(function(){
15		  $(this).parent().toggleClass('current-menu-item');
16		  $(".search-pop").slideToggle();
17		  return false;
18		});
19
20		$(".mobile-nav-trigger").click(function(){
21		  $(".main-nav").slideToggle();
22		  return false;
23		});
24
25		$(".mobile-shop-nav-trigger").click(function(){
26		  $(".shop-sidebar #pub_list").slideToggle();
27		  return false;
28		});
29
30		$(".back-to-top").click(function () {
31	  	$("html, body").animate({scrollTop: 0}, 1000);
32		});
33		
34		$(".page-id-4256 .sidebar").stick_in_parent();
35		
36		$(".shop-sidebar").stick_in_parent({
37			offset_top: 24
38		});
39		
40		$('#menu-main-menu li a').click(function(){
41			if($(window).width() < 680)
42				if($(this).parent().hasClass('menu-item-has-children'))
43					return false;
44		});
45
46		$('.shop-sidebar #pub_list h1').click(function(){
47			if($(window).width() < 740)
48				if($(this).hasClass('menu-item-has-children'))
49					$(this).toggleClass('active');
50					$(this).next('ul').slideToggle();
51		});	
52		
53		if($(window).width() < 680)
54		{
55			$('body.home .archive .post').hide();
56			$('body.home .archive .mobile-three .post').show();
57		}
58		
59
60    $(window).scroll(function(){
61      var posFromTop = $(window).scrollTop();
62      if(posFromTop > 700){
63  	    $(".back-to-top").fadeIn('fast');
64	        } else {
65	    	$(".back-to-top").stop().fadeOut('fast');
66      }
67    });
68	
69		$(".ellipsis, .archive .post p.excerpt").dotdotdot({
70			ellipsis: "...",
71			after: "a.more",
72			watch: "window"
73		});
74		
75		$(".hero .hero-main .excerpt-wrap p, .theme-wrap p.excerpt").dotdotdot({
76			ellipsis: "...",
77			watch: "window"
78		});
79			
80		var debounce = function(func, wait, immediate) {
81	    var timeout, result;
82	    return function() {
83	      var context = this, args = arguments;
84	      var later = function() {
85	        timeout = null;
86	        if (!immediate) result = func.apply(context, args);
87	      };
88	      var callNow = immediate && !timeout;
89	      clearTimeout(timeout);
90	      timeout = setTimeout(later, wait);
91	      if (callNow) result = func.apply(context, args);
92	      return result;
93	    };
94	  };
95
96		
97		var normalizeHeight = function(selector) {
98			var heights = $(selector).map(function(x){ return $(this).height()});
99			var height = Math.max.apply(heights, heights);
100			$(selector).css("height", height);
101		//	console.log("resized");
102		}
103		
104		var normalizer = function() {
105			normalizeHeight(".theme-inner .post");			
106		}
107		
108		$(window).on("resize", debounce(normalizer, 100));
109		normalizer();
110		
111		var shown_mobile = false;
112		
113		/* Load Posts */
114		$(".load-more a").click(function()
115		{
116			if($(this).data('press') == 'yes')
117			{
118				var data = { action: 'thetig_load_press_posts', page : $(this).data('page'), publications : false };
119					$.post(ajaxurl, data, function(response) {
120						if(response)
121						{
122							$( ".load-more" ).before( response );
123							$( ".load-more a" ).data('page', ($( ".load-more a" ).data('page') + 1));
124							$( ".archive .post p.excerpt" ).dotdotdot({
125								ellipsis: "...",
126								after: "a.more",
127								watch: "window"
128							});
129						}
130						else
131						{
132							$( ".load-more a" ).text('no more posts...');	
133						}
134					});	
135			}
136			else if($(this).data('shop') == 'yes')
137			{
138				var data = { action: 'thetig_load_shop_items', page : $(this).data('page'), taxonomy : $(this).data('taxonomy'), slug : $(this).data('slug') };
139					$.post(ajaxurl, data, function(response) {
140						if(response)
141						{
142							$( ".load-more" ).before( response );
143							$( ".load-more a" ).data('page', ($( ".load-more a" ).data('page') + 1));
144						}
145						else
146						{
147							$( ".load-more a" ).text('no more...');	
148						}
149					});	
150			}
151			else
152			{
153				if($(window).width() < 680 && shown_mobile == false)
154				{
155					$('.archive .post').show();
156					shown_mobile = true;
157				}
158				else
159				{
160			
161					var data = { action: 'thetig_load_posts', page : $(this).data('page'), taxonomy : $(this).data('taxonomy'), slug : $(this).data('slug'), s : $(this).data('s') };
162					$.post(ajaxurl, data, function(response) {
163						if(response)
164						{
165							$( ".load-more" ).before( response );
166							$( ".load-more a" ).data('page', ($( ".load-more a" ).data('page') + 1));
167							$( ".archive .post p.excerpt" ).dotdotdot({
168								ellipsis: "...",
169								after: "a.more",
170								watch: "window"
171							});
172						}
173						else
174						{
175							$( ".load-more a" ).text('no more posts...');	
176						}
177					});
178				}
179			}
180			
181			return false;
182		});
183		
184		
185		
186		//Press Publications
187		$('#pub_list.press a:not(.all)').click(function()
188		{
189			$('#pub_list.press a').removeClass('active');
190			$(this).addClass('active');
191			$("html, body").animate({scrollTop: 0}, 1000);
192			$(document.body).trigger('sticky_kit:recalc');
193			var data = { action: 'thetig_load_press_posts', slug : $(this).data('slug'), publications : true };
194			$.post(ajaxurl, data, function(response) {
195				if(response)
196				{
197					$( ".post-press" ).remove();
198					$( ".load-more" ).before( response );
199					$( ".load-more" ).hide();
200					$( ".archive .post p.excerpt" ).dotdotdot({
201						ellipsis: "...",
202						after: "a.more",
203						watch: "window"
204					});
205				}
206			});	
207			
208			return false;
209		});
210		
211		//All Publications
212		$('#pub_list.press a.all').click(function()
213		{
214			$('#pub_list.press a').removeClass('active');
215			$(this).addClass('active');
216			$("html, body").animate({scrollTop: 0}, 1000);
217			$(document.body).trigger("sticky_kit:recalc");
218			var data = { action: 'thetig_load_press_posts', page : 1, publications : false };
219			$.post(ajaxurl, data, function(response) {
220				if(response)
221				{
222					$( ".post-press" ).remove();
223					$( ".load-more" ).before( response );
224					$( ".load-more" ).show();
225					$( ".load-more a" ).data('page', 2);
226					$( ".archive .post p.excerpt" ).dotdotdot({
227						ellipsis: "...",
228						after: "a.more",
229						watch: "window"
230					});
231				}
232			});	
233			
234			return false;
235		});
236		
237		
238		
239		//Homepage Overlay Click
240		$('.hero-main .overlay, .hero-sub .overlay, .goto').click(function(e)
241		{
242			if(e.target.nodeName == 'A') return;
243			if(e.target.nodeName == 'SPAN') return;
244			window.location.href=$(this).data('goto');
245		})
246		
247		
248		
249		//Single 
250		$('.may-also-like .post-wrap').click(function(e)
251		{
252			if(e.target.nodeName == 'SPAN') return;
253			window.location.href=$(this).data('goto');
254		})
255		
256		
257		//Remove tags within post body
258		$('.post-content div.question + br').remove();
259		$('.post-content div.double-img').children('br').remove();
260		$('.post-content div.double-img').children('p').remove();
261		$('p > img').removeAttr('height').removeAttr('width').unwrap();
262		
263		
264		
265		//MailChimp Submission
266        $('.mc-form').ajaxChimp({
267		    url: 'http://thetig.us8.list-manage.com/subscribe/post?u=969d0555c3f46fddc6a4b5102&amp;id=236cbb27b5',
268		    callback: newsletter_submit
269		});
270		
271		$('.newsletter_message').hide();
272		
273		function newsletter_submit(resp,form)
274		{
275			$('.mc-form.popup .message').html('').removeClass('error').removeClass('success');
276			$('.newsletter_message div').html('');
277			$('.newsletter_message').removeClass('error');
278			$('.newsletter_message').removeClass('success');
279			
280			var parts = resp.msg.split(' - ', 2);
281            if (parts[1] === undefined) {
282                msg = resp.msg;
283            } else {
284                var i = parseInt(parts[0], 10);
285                if (i.toString() === parts[0]) {
286                    index = parts[0];
287                    msg = parts[1];
288                } else {
289                    index = -1;
290                    msg = resp.msg;
291                }
292            }
293            
294            
295            if(form.hasClass('popup'))
296            {
297				form_class = '.mc-form.popup';
298				if(resp.result == "error")
299				{
300					$(form_class+' .message').addClass('error');
301					$(form_class+' .message').html(msg);			
302				}
303				
304				if(resp.result == "success"){
305					$(form_class+' .message').addClass('success');
306					$(form_class+' .message').html(msg);
307					$.cookie('news_signedup', 'yes', { expires: 30, path: '/' });
308					setTimeout(function() {
309						$('.newsletter-takeover').fadeOut();
310					}, 5000);
311				}
312    	
313    		}
314    		else
315    		{
316				if(resp.result == "error"){
317					$('.newsletter_message').addClass('error');
318					$('.newsletter_message div').html(msg);
319				}
320				
321				if(resp.result == "success"){
322					$('.newsletter_message').addClass('success');
323					$('.newsletter_message div').html(msg);
324				}
325				
326				$('.newsletter_message').show();
327				setTimeout(function() {
328					$('.newslettver_message').fadeOut();
329				}, 10000);
330			}
331		}
332		
333		$('.newsletter-takeover .takeover-close').click(function(){
334			$('.newsletter-takeover').hide();
335			$.cookie('news_signedup', 'no', { expires: 30, path: '/' });
336		})
337		
338		
339		//if($.cookie('news_signedup') == null)
340			//$('.newsletter-takeover').show();
341		
342		
343		
344		
345		//Twitter & Facebook pop - since we are using our own buttons
346		$('.social-share a, a.pinterest').click(function(event) {
347			var width  = 575,
348			    height = 400,
349			    left   = ($(window).width()  - width)  / 2,
350			    top    = ($(window).height() - height) / 2,
351			    url    = this.href,
352			    opts   = 'status=1' +
353			             ',width='  + width  +
354			             ',height=' + height +
355			             ',top='    + top    +
356			             ',left='   + left;
357			
358			window.open(url, 'twitter', opts);
359			
360			return false;
361		});		
362
363	});
364	
365	
366	$(document).ready(function() {
367	  $('.image_post a').magnificPopup({
368	  type:'image',
369	  closeOnContentClick: false,
370	  closeBtnInside: false,
371	  mainClass: 'mfp-with-zoom mfp-img-mobile',
372	  		image: {
373	  			verticalFit: true
374	  		},
375	  		gallery: {
376	  			enabled: false
377	  		},
378	  		zoom: {
379	  			enabled: true,
380	  			duration: 300, // don't foget to change the duration also in CSS
381	  			opener: function(element) {
382	  				return element.find('img');
383	  			}
384	  		}
385	  
386	  
387	  });
388
389		$('.video_post a').magnificPopup({
390			disableOn: 700,
391			type: 'iframe',
392			mainClass: 'mfp-with-zoom mfp-img-mobile',
393			removalDelay: 160,
394			preloader: false,
395			fixedContentPos: false
396		});
397	});
398	
399	
400})(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.