PageSourceSearch

https://trachtmanpoler.com/wp-content/themes/polerlegal/js/default.js?v=1.2

js trachtmanpoler.com collected 2026-10-09 22:14:46 UTC 6,352 bytes, 237 lines download raw bytes

1var animating = false;
2var breakpoint = 830;
3var paddingTop = 100; // Height of the minimized menu.
4var lastScrollTop = 0;
5
6function viewportWidth() {
7	return Math.max($(window).width(), window.innerWidth);
8}
9
10function hideMenu() {
11	// console.log('Hiding menu');
12	var h = $('#stick').height() + 1; // 1px for border.
13	// $('#stick').css('top', '-'+h+'px').css('backgroundColor', 'transparent');
14	$('#stick').css('top', '-'+h+'px');
15}
16
17function setupMenu() {
18	var st = $(this).scrollTop();
19	
20	// Handle the mobile view first
21	if(viewportWidth() <= breakpoint) {
22		if(st < 100) { // If the user is toward the top of the page, just show the menu.
23			$('#stick').css('top', '0px').removeClass('minimized');
24			return;
25		} else {
26			// If the viewport is not at the top, make the background opaque.
27			$('#stick').addClass('minimized');
28		}
29
30		if ((st-5) > lastScrollTop){
31			// downscroll code
32			hideMenu();
33		} else if((st+5) < lastScrollTop){
34			// upscroll code
35			$('#stick').css('top', '0px');
36		}
37
38	// Now handle the desktop view			
39	} else {
40		if(st < 100) { // If the user is toward the top of the page, just show the menu.
41			$('#stick').removeClass('minimized');
42			$('#stick').css('top', '0px');
43			return;
44		}
45
46		if ((st-5) > lastScrollTop){
47			// Down scroll
48			$('#stick').addClass('minimized');
49		} else if((st+5) < lastScrollTop){
50			// Up scroll
51		}
52	}
53
54	lastScrollTop = st;
55}
56
57$(document).ready(function(){
58
59/*
60    if(/iPad|iPhone|iPod/.test(navigator.platform) && !!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/)) {
61        // console.log('Hero height is ' + element.height());
62        $('#hero').css('height', $('#hero').height() - 69);
63    }
64*/
65	$('.gaEvent').click(function() {
66		sendToAnalytics(this);
67	});	
68
69	$("#mobileMenu").click(function(){
70		// $("#navMobile").css("display", "block");
71		$("#menu-primary").slideToggle(500);
72		// $(this).css("display", "none");
73	});
74
75	// Dropdown menu
76	$('.has-children').each(function(index, element) {
77		$(this).click(function(event) {
78			if(viewportWidth() > breakpoint) {
79				$('.sub-menu').css('display', 'none');
80				$(this).siblings('ul').slideToggle(500);
81			}
82			return false;
83		});
84	});
85
86	$('.sub-menu > li > a').each(function(index, element) {
87		$(this).click(function(event) {
88			if(viewportWidth() > breakpoint) {
89				$(this).parent().parent().css('display', 'none');
90			}
91		});
92	});
93
94/*	
95	// allow elements to be clicked on as if they were a link; the href can be assigned using data-href="/path/to/page"
96	$('.clickable').each(function(index, element) {
97		// for function, see outside of ready
98		makeClickable(element);
99	});
100*/
101/*
102	$('.readMore').each(function(index, element) {
103		var parent = $(this);
104
105		$(this).append(
106			$('<div>').addClass('readMoreButton').append(
107				$('<img>').attr({src:'/wp-content/themes/rapharma/img/read-more.png'}).click(function() {
108					parent.removeClass('readMore');
109					$(this).remove();
110				})
111			)
112		).append(
113
114		);
115	});
116*/
117
118
119	$(".anchorMenu a").click(function() {
120		if(viewportWidth() <= breakpoint) {
121			paddingTop = 50;
122			$("#menu-primary").slideToggle(500);
123		}
124		var pos = Math.ceil($($(this).attr('href')).offset().top) - paddingTop;
125		console.log('href', $(this).attr('href'));
126		console.log('href top', $($(this).attr('href')).offset().top);
127		console.log('paddingTop', paddingTop);
128		console.log('pos', pos);
129		var dur = Math.abs(pos - $(window).scrollTop()) * 0.4;
130		console.log('dur', dur);
131		lastScrollTop = pos;
132
133		animating = true;
134	    $('html, body').animate({
135	        scrollTop: pos
136	    }, dur, "swing", function() {
137		    if(viewportWidth() <= breakpoint && pos > 0) {
138		    	hideMenu();
139		    } else {
140		    	$('#stick').addClass('minimized');
141		    }
142
143		    if(pos == -paddingTop) {
144		    	$('#stick').removeClass('minimized');
145		    }
146
147		    animating = false;
148	    });
149
150	    return false;
151	});
152
153/*
154	lastScrollTop = $(window).scrollTop();
155	if(lastScrollTop > 100 && viewportWidth() > breakpoint) {
156		$('#stick').addClass('minimized');
157	}
158*/
159	$(window).resize(function(event){
160		var vw = viewportWidth();
161		if(vw <= breakpoint) {
162			// $('#stick').removeClass('minimized');
163		} else {
164			$("#menu-primary").css('display', 'block');
165			// $('#stick').addClass('minimized');
166		}
167	});
168
169	$(window).scroll(function(event){
170		if(animating) {
171			return;
172		}
173
174		setupMenu();
175	});
176
177	setupMenu();
178
179
180});
181
182// allow elements to be clicked on as if they were links
183// this was moved into a function so we can call it whenever we want (i.e. we can enable clickability for new elements on the page)
184// it also has been genericized to be used on any element, not just tables
185function makeClickable(element) {
186	var targets = [];
187	if($(element).is('tr')) {
188		// this is a table row, so we want to attach the listeners to the cells so we can exclude specific cells
189		$(element).find('td').each(function(index, el) {
190			if(!$(el).hasClass('actions')) {
191				// this is not the actions class, so add it to the array of targets
192				targets.push(el);
193			}	
194		});
195
196		for (var i = targets.length - 1; i >= 0; i--) {
197			$(targets[i]).click(function(event) {
198				// if this has a data-href, attach a click listener
199				if ($(this).parent().attr('data-href')) {
200					sendToAnalytics(this);
201					document.location.href = $(this).parent().attr('data-href');
202				};
203			});
204		}
205
206	} else {
207		// this is a normal element, so just push itself into the array
208		// targets.push(element);
209		$(element).click(function(event) {
210			if ($(this).attr('data-href')) {
211				sendToAnalytics(this);
212				document.location.href = $(this).attr('data-href');
213			};
214		});
215	}
216}
217
218function sendToAnalytics(element) {
219	if($(element).attr('data-category') && $(element).attr('data-action')) {
220		if($(element).attr('data-label')) {
221			// console.log("ga('send', 'event', '"+$(element).attr('data-category')+"', '"+$(element).attr('data-action')+"', '"+$(element).attr('data-label')+"');");
222			ga('send', {
223				hitType: 'event',
224				eventCategory: $(element).attr('data-category'),
225				eventAction: $(element).attr('data-action'),
226				eventLabel: $(element).attr('data-label')
227			});
228		} else {
229			// console.log("ga('send', 'event', '"+$(element).attr('data-category')+"', '"+$(element).attr('data-action')+"');");
230			ga('send', {
231				hitType: 'event',
232				eventCategory: $(element).attr('data-category'),
233				eventAction: $(element).attr('data-action')
234			});
235		}
236	}
237}

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.