PageSourceSearch

https://atulgawande.com/wp-content/themes/gawande-no-purchase/js/project.js?ver=7.1.2

js atulgawande.com collected 2026-09-24 08:26:37 UTC 10,800 bytes, 392 lines download raw bytes

1(function ($) {
2	var isPhone = false;
3	//$(".menu-item-35 a").first().addClass("firstLink");
4	setTimeout(function(){
5		$(".preloadFade").removeClass("preloadFade");
6		$("body").addClass("loaded");
7	},4000);
8	$(document).ready(function(){
9		$("a.firstLink").click(function(event){
10			event.preventDefault();
11		});
12		
13	});
14
15	$(window).load(function(){
16		$("body").addClass("loaded");
17	});
18
19	//setSizes();
20	$(document).ready(function(){
21		setSizes();
22		$(window).resize(setSizes);
23		$(window).trigger("resize");
24
25		var mobileCheck = null;
26		if($("html").hasClass("touch") && $(window).width() < 768){
27			mobileCheck = "mobile";
28		} else {
29			mobileCheck = "no-mobile";
30		}
31
32		if(mobileCheck == "mobile"){
33			$(".mobile-menu-toggle").click(function(){
34				$("body").toggleClass("showing-mobile-menu");
35			});
36		}
37
38		$(".menu li").hover(function(){
39			$(this).addClass("hovered");
40		},function(){
41			$(this).removeClass("hovered");
42		});
43
44		$(".sub-menu").each(function(){
45			$(this).append("<div class=\"arrow-down\"></div>");
46		});
47
48		checkCheckboxes();
49		if($("body").hasClass("page-id-23")){
50			$(".event-toggle").click(function(){
51				checkCheckboxes();
52			});
53		}
54		if($("body").hasClass("page-id-21")){
55			$(".research-toggle").click(function(){
56				checkCheckboxes();
57			});
58		}
59
60		$(".SocialTwitter a").click(function(event){
61			// if(isPhone === false){
62				// event.preventDefault();
63			// }
64			// $(".SocialMailLink a").removeClass("enabled");
65			// $(".header-mailinglist").removeClass("showing-mailinglist");
66			// $(this).toggleClass("enabled");
67			// $(".header-tweets").toggleClass("showing-tweets");
68		});
69
70		$(".SocialMailLink a").click(function(event){
71			if(isPhone === false){
72				event.preventDefault();
73			}
74			$(".SocialTwitter a").removeClass("enabled");
75			$(".header-tweets").removeClass("showing-tweets");
76			$(this).toggleClass("enabled");
77			$(".header-mailinglist").toggleClass("showing-mailinglist");
78		});
79
80		if($("body").hasClass("home")){
81			// $("body").addClass("bonusSlide");
82
83			if(isPhone === false){
84
85
86
87				$( '#home-cycle' ).on( 'cycle-after', function(e, optionHash, outgoingSlideEl, incomingSlideEl, forwardFlag ) {
88					homeCheck();
89				});
90
91				checkHeight(); $(window).resize(checkHeight);
92				homeCheck();
93				$("#checklist-navigation").click(function(){
94					$('#home-cycle').cycle('pause');
95
96					var checker = $("#checklist-navigation li input:checked");
97					var cycleTarget = checker.parent().attr('rel');
98					console.log("going to " + cycleTarget);
99
100					$("#home-cycle").cycle('goto', cycleTarget);
101
102					homeCheck();
103				});
104			} else {
105				$("#navcheck-0").click(function(){
106					window.location = "/about/";
107				});
108				$("#navcheck-1").click(function(){
109					window.location = "/articles/";
110				});
111				$("#navcheck-2").click(function(){
112					window.location = "/research/";
113				});
114			}
115
116		}
117
118		if($("body").hasClass("page-id-12") && mobileCheck != "mobile" || $("body").hasClass("page-id-831") && mobileCheck != "mobile"){
119			var galCurr = 0;
120			var galTotal = $(".rotate-slides li.slide").size() - 1;
121
122			$(".arrow").on("click",function(){
123				if($(this).hasClass("arrow-left")){
124					galCurr--;
125				} else {
126					galCurr++;
127				}
128				if(galCurr < 0){ galCurr = galTotal; }
129				if(galCurr > galTotal){ galCurr = 0; }
130
131				$(".rotate-slides li.slide").each(function(index){
132					if(index < galCurr){
133						$(this).removeClass("active-slide slide-next").addClass("slide-prev");
134					} else if(index == galCurr){
135						$(this).removeClass("slide-prev slide-next").addClass("active-slide");
136					} else {
137						$(this).removeClass("active-slide slide-prev").addClass("slide-next");
138					}
139				});
140			});
141		}
142
143		if($("body").hasClass("page-id-351")){
144			$(".featured-embed").fitVids({ customSelector: "iframe[src^='http://embed.ted.com'], iframe[src^='http://www.hulu.com'], iframe[src^='http://media.mtvnservices.com'], iframe[src^='http://comedycentral.com']"});
145		}
146
147		checkScroll();
148		$(window).scroll(function(){
149			checkScroll();
150		});
151		setSizes();
152	});
153
154	var allowScroll = null;
155	$(window).bind('scrollstop', function(e){
156		if(isPhone != true){
157			var scrollTop = $(window).scrollTop();
158			var scrollToPos = 0;
159			//.log(scrollTop + " | " + $("#header").height() + " | " + $(window).scrollTop() + " | " + Math.round(scrollTop / 20) * 20);
160			if(scrollTop > 100 && allowScroll == null){
161				allowScroll = 1;
162				scrollToPos = (Math.round(scrollTop / 20) * 20);
163				$('html,body').animate({scrollTop:scrollToPos+"px"}, 200);
164				setTimeout(function(){
165					allowScroll = null;
166				},1000);
167			}
168		}
169	});
170
171	function checkScroll(){
172		if(isPhone != true){
173			var navStart = $("#header").height();
174			var howScrolled = $(window).scrollTop();
175			if(howScrolled >= navStart){
176				$("body").addClass("navStick");
177				setSizes();
178			} else {
179				$("body").removeClass("navStick");
180				setSizes();
181			}
182
183			setMenuPos();
184		}
185	}
186
187	function setSizes(){
188		var tempH = $(window).height();
189		var tempW = $(window).width();
190		if(tempW >= 767){
191			if($("body").hasClass("admin-bar")){
192				tempH = tempH - 32;
193			}
194			var finalH = Math.ceil(tempH/2);
195			finalH = Math.round(finalH/20)*20 - 20;
196			$("#header").css({"height":finalH+"px"});
197
198			var mHeight = $("#header .gridFlex").height();
199			if(mHeight == null || mHeight == undefined){
200				mHeight = $("#header .gridFlex2").height();
201			}
202			//console.log(mHeight);
203			if(mHeight > 10) {
204				$("#header h1#main-title").css({"margin-top":Math.ceil((finalH-mHeight)/2) + "px"});
205			}
206			if($("body").hasClass("home")){
207				var mHeight = 200;
208				mHeight = Math.ceil((finalH-mHeight)/2);
209				mHeight = Math.round(mHeight/20)*20
210				if(mHeight > 10) {
211					$("#header h1#main-title").css({"margin-top":mHeight + "px"});
212				}
213				if($(".news-bug").hasClass("news-bug")){
214					var bugPos = Math.ceil((finalH-mHeight)/2);
215					if(bugPos % 20 !== 0){
216						bugPos = bugPos + 10;
217					}
218					$(".news-bug").css({"bottom":bugPos-60+1 + "px"});
219				}
220			}
221
222			if($("body").hasClass("page-id-19") || $("body").hasClass("archive") || $(".flexContents").hasClass("flexContents")){
223				if($(window).width() > 768){
224					var windW = $(window).width() - 80;
225					var numColl = Math.floor( (windW - 360) / 300);
226					var newSize = ( (numColl * 300) + 360);
227					if(newSize % 40 != 0) {
228						newSize = newSize + 20;
229					}
230					if(newSize > 1280){
231						newSize = 1280;
232					}
233					$(".flexContents").each(function(){
234						if($(this).hasClass("page-contents")){
235							if(newSize >= 965){
236								$(this).removeClass("sizeStandard").addClass("sizeExtended");
237							} else {
238								$(this).removeClass("sizeExtended").addClass("sizeStandard");
239							}
240							$(this).css({"width":newSize+1 + "px"});
241						} else {
242							$(this).css({"width":newSize + "px"});
243						}
244					});
245					setMenuPos();
246				}
247			}
248
249			$(".container").css({"height":"auto"});
250			var bodH = $(".container").height();
251			var footerAdjust = Math.floor($(window).height() / 2) - 200;
252			if(bodH < footerAdjust){
253				$(".container").css({"height":footerAdjust+"px"});
254			}
255
256			if($("body").hasClass("page-id-351")){
257				$(".featured-embed").each(function(){
258					$(this).css({"height":"auto"});
259					var tempVidHeight = $(this).height();
260					$(this).css({"height":(Math.ceil(tempVidHeight/20)*20) + "px"});
261				});
262			}
263
264			if($("body").hasClass("single-book")){
265				$(".book-covers").each(function(){
266					$(this).css({"height":"auto"});
267					var tempVidHeight = $(this).height();
268					$(this).css({"height":(Math.ceil(tempVidHeight/20)*20) + "px"});
269				});
270
271				if($(".book-covers .single-book-cover").size() < 2){
272					$(".covers-nav").remove();
273				}
274
275				checkRegionHeights();
276				$(window).resize(checkRegionHeights);
277			}
278		} else {
279			isPhone = true;
280		}
281
282
283		//setTimeout(function(){
284			$(".preloadFade").removeClass("preloadFade");
285		//},500);
286	}
287
288	function checkRegionHeights(){
289		$(".region-block").each(function(){
290			var thisItem = $(this);
291			//thisItem.css({"height":"auto"});
292			var tempH = thisItem.height();
293			if(tempH > 20){
294				if(((tempH-1) % 20 !== 0) && ((tempH) % 20 !== 0)) {
295					//console.log(tempH-1);
296					thisItem.addClass("resized").css({"height":tempH+2+"px"});
297				}
298			}
299		});
300	}
301
302	function setMenuPos(){
303		if(!$("body").hasClass("home") && !$("body").hasClass("single-book")){
304			if($("body").hasClass("navStick")){
305				$("#menu-research, #menu-articles, #checklist-navigation, #menu-press, #menu-media").css({"left":($(".flexContents").offset().left)+"px","margin-left":"0px"});
306			} else {
307				$("#menu-research, #menu-articles, #checklist-navigation, #menu-press, #menu-media").css({"left":"0px","margin-left":"0px"});
308			}
309		}
310	}
311
312
313	function homeCheck(){
314		// console.log($("#home-cycle").data("cycle.opts").currSlide);
315		var CurrentSlide = $("#home-cycle").data("cycle.opts").currSlide;
316		console.log(CurrentSlide);
317		// if(CurrentSlide !== 0){
318		// 	$("body").removeClass("bonusSlide");
319		// } else {
320		// 	$("body").addClass("bonusSlide");
321		// }
322		if(CurrentSlide == 1){
323			$('#navcheck-0 input').prop('checked', true);
324			$('#navcheck-1 input').prop('checked', false);
325			$('#navcheck-2 input').prop('checked', false);
326		} else if(CurrentSlide == 0){
327			$('#navcheck-0 input').prop('checked', false);
328			$('#navcheck-1 input').prop('checked', true);
329			$('#navcheck-2 input').prop('checked', false);
330		} else if(CurrentSlide == 2){
331			$('#navcheck-0 input').prop('checked', false);
332			$('#navcheck-1 input').prop('checked', false);
333			$('#navcheck-2 input').prop('checked', true);
334		}
335
336	}
337	function checkHeight(){
338		var wY = $(window).height();
339		var checkY = $(".gridFlex").height();
340		var containerHeight = wY - checkY;
341
342		$(".container").css({"min-height":containerHeight+"px"});
343	}
344
345	function checkCheckboxes(){
346		if($("body").hasClass("page-id-21")){
347			$(".single-research").hide();
348			$("#checklist-navigation li input").each(function(){
349				if($(this).is(':checked')){
350					var decadeToShow = $(this).attr("value");
351					$(".research-article-list ." + decadeToShow).show();
352				}
353			});
354		} else {
355			if($('#radio-upcoming').attr('checked') == "checked"){
356				$(".event-list-upcoming").show();
357				$(".event-list-past").hide();
358			} else {
359				$(".event-list-upcoming").hide();
360				$(".event-list-past").show();
361			}
362		}
363		setSizes();
364	}
365
366	var $body = $('body'),
367		colW = 40,
368		columns = null;
369	$(window).smartresize(function(){
370		var currentColumns = Math.floor( ( $body.width() ) / colW );
371		if ( currentColumns !== columns ) {
372			columns = currentColumns;
373			//$wall.width( columns * colW ).isotope('reLayout');
374			redrawCols();
375		}
376	}).smartresize();
377
378	function redrawCols(){
379		if($(window).width() > 768){
380			$(".gridFlex").css({"width":(columns*colW)+"px"});
381		}
382	}
383
384
385	$(window).load(function(){
386		setTimeout(function(){
387			$("body").addClass("loadGrid");
388		},1000);
389	});
390
391	
392})(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.