PageSourceSearch

https://fortstreetstudio.com/wp-content/themes/FortStreetStudio/library/js/layer_stack.js

js fortstreetstudio.com collected 2026-09-26 11:37:31 UTC 11,322 bytes, 485 lines download raw bytes

1var sections;
2var sl;
3var leftSpaces = new Array();
4var rightSpaces = new Array();
5var tops = new Array();
6var bottoms = new Array();	  
7var topMargins = new Array();	
8
9jQuery(document).ready(function($) {
10	
11	  	//SET DYNAMIC Z INDEX SO EACH SECTION IS STACKED ON TOP
12	  	var section = $('.content-section');
13	  	var z_index = 100;
14	  	
15	  	$('.wrapper').find('.content-section, .content-section-fixed').each(function(){;
16	  		$(this).css({'z-index' : z_index});
17	  		z_index = z_index + 100;
18	  	});
19	 
20	  	
21	  	var 	sections = $('.wrapper').find('.content-section');
22	  	var	sl = $(sections).length;
23
24		var firstSection = $('.content-section:first');
25
26		$wrapper = $('.wrapper');
27		$wrapper.imagesLoaded( function() {
28			
29			if(firstSection){
30				doFirst(firstSection);
31			}
32			  
33		  	var contentSections = $('.wrapper').find('.content-section').not(':first');
34		  		
35		  	$(contentSections).each(function(){
36		  			var thisSection = $(this);
37		  			initSection(thisSection);
38		  	});
39		  	
40		  	var contentSectionsFixed = $('.wrapper').find('.content-section-fixed');
41		  	
42			$(contentSectionsFixed).each(function(){
43	  			var thisSection = $(this);
44	  			doFixed(thisSection);
45	  	});
46		});
47		
48
49
50function doFixed(thisSection){
51
52	var thisSection = $(thisSection);
53	var prevSection = $(thisSection).prev('.content-section');
54	//$(prevSection).css({'background': 'red'});
55	var prevSectionHeight = $(prevSection).height();
56	var prevBoth = $(prevSection).find('.both-sides:last');
57	var prevLeft = $(prevSection).find('.left-side:last');
58	var prevRight = $(prevSection).find('.right-side:last');
59	
60
61	
62	var prevBottoms = new Array();
63	
64	if(prevBoth != undefined){
65		var prevBothBottom = getBottom(prevBoth);
66		//prevBottoms.push(prevBothBottom);
67		
68	}else{
69		var prevBothBottom = 0;
70	//	prevBottoms.push(prevBothBottom);
71		
72	}
73	
74
75	if(prevRight){
76		var prevRightBottom = getBottom(prevRight);
77		prevBottoms.push(prevRightBottom);
78	}
79	if(prevLeft){
80		var prevLeftBottom = getBottom(prevLeft);
81		prevBottoms.push(prevLeftBottom);
82	}
83	
84	
85	var prevBottom = Math.max.apply(Math, prevBottoms);
86	
87	
88
89	var prevSpace = prevSectionHeight - prevBottom -0;
90	
91	if(prevSpace < 0){
92		prevSpace=Math.abs(prevSpace);
93		var newTopMargin = prevSpace + 'px';
94
95	} else{
96		
97		var newTopMargin = '-' + prevSpace + 'px';
98	}
99	
100	var thisElement = $(thisSection).find('.both-sides')
101	$(thisSection).css({'marginTop' : newTopMargin});
102
103}
104
105$( window ).resize(function() {
106	  $('.wrapper').imagesLoaded( function() {
107		 
108		  var firstSection = $('.content-section:first');
109		  doFirst(firstSection);
110		  var fixed = $('.content-section-fixed');
111		doFixed(fixed );
112		  $('.content-section').not(':first').each(function(){
113			 
114			 
115				 initSection(this);
116		
117			  });
118			
119		});
120	});
121//*************************************  INIT SECTION  *************************************//
122
123function initSection(thisSection){
124
125	var thisSection = $(thisSection);
126	
127	var lefts = $(thisSection).find('.left-side');
128	var rights = $(thisSection).find('.right-side');
129		
130	if($(rights).length <= 1 && $(lefts).length <=1){
131		
132			var height = setHeight(thisSection );
133			$(thisSection).css({'height' : height + 'px'})
134		}
135		
136
137		var thisBoth = $(thisSection).find('.both-sides:last');
138		var thisRight = $(thisSection).find('.right-side:first');
139		var thisLeft = $(thisSection).find('.left-side:first');
140
141		var prevSection = $(thisSection).prev('.content-section');
142		
143		if($(prevSection).attr('id') != undefined){
144
145			 if(thisLeft){
146				 $(thisLeft).each(function(){
147					 
148				doOffsets(thisLeft);
149				 })
150			 }
151			 
152			 if(thisRight){
153				 $(thisRight).each(function(){
154					  doOffsets(thisRight);
155				 })
156				
157			 }
158		}
159		
160	if($(lefts).length >1){
161			
162			internalOffsets(thisSection, $('.left-side'));
163	}
164		
165		if($(rights).length >1){
166			internalOffsets(thisSection, $('.right-side'));
167			
168		}
169
170	//setHeight(thisSection);
171}
172
173
174//*************************************  DO OFFSETS  *************************************//
175
176function doOffsets(elem){
177
178	var thisElement = $(elem);
179	var thisSectionHeight = $(thisElement).parent('.content-section').height();
180	var prevSection = $(thisElement).parent('.content-section').prev('.content-section');
181	var thisHeight = $(thisElement).height();
182	var thisBottom = getBottom(thisElement);
183	var thisSpace = thisSectionHeight - thisBottom;
184
185		
186if(prevSection){
187
188	var prevSectionHeight = $(prevSection).height();
189
190	if($(elem).hasClass('right-side')){
191	
192		var prevRight = $(thisElement).parent('.content-section').prev('.content-section').find('.right-side:last');
193			
194			if(prevRight){
195				prevBottom = getBottom(prevRight);
196			}
197	}//end if right
198
199	if($(elem).hasClass('left-side')){
200	
201		var prevLeft = $(thisElement).parent('.content-section').prev('.content-section').find('.left-side:last	');
202	
203			if(prevLeft ){
204				prevBottom = getBottom(prevLeft);
205			}
206	
207	}//end if left
208	
209	if($(elem).hasClass('both-sides')){
210		var prevBoth = $(thisElement).parent('.content-section').prev('.content-section').find('.both-sides:last');
211		prevBottom = getBottom(prevBoth);
212		
213	}
214	
215	var prevSpace = prevSectionHeight - prevBottom -0;
216	
217	if(prevSpace < 0){
218		var newTopMargin = prevSpace + 'px';
219
220	} else{
221		
222		var newTopMargin = '-' + prevSpace + 'px';
223	}
224	
225	$(thisElement).css({'marginTop' : newTopMargin});
226	
227}//end if prevSection
228}//end of DoOffsets
229
230function doFirst(firstSection){
231  
232	var $window = $(window);
233	var windowsize = $window.width();
234	
235	var firstSection = $(firstSection)
236	
237	var firstRow = $(firstSection).find( "div:first-child" );
238
239  
240	var lefts = $(firstSection).find('.left-side');
241	var ll = $(lefts).length;
242  	var rights = $(firstSection).find('.right-side');
243  	var rl = $(rights).length;
244  	
245  	var left_offset = $('.wrapper').attr('left_offset');
246	left_offset = parseInt(left_offset) + 'px';
247	
248	var right_offset = $('.wrapper').attr('right_offset');
249	right_offset = parseInt(right_offset) + 'px';
250
251	//If first element in section is full row, set margins on the first left and right elements found
252	
253	if($(firstRow).hasClass('both-sides')){
254		var firstLeft = $(lefts[0]);
255		var firstRight = $(rights[0]);
256		var firstBoth = $(firstSection).find('.both-sides');
257	}else{
258		var firstLeft = $(lefts[1]);
259		var firstRight = $(rights[1]);
260	}
261	
262
263	if(windowsize > 768){
264		
265		$(firstLeft).css({'marginTop' : left_offset});
266		$(firstRight).css({'marginTop' : right_offset}); 
267	}else{
268		left_offset = '0px';
269		right_offset='0px';
270		$(firstLeft).css({'marginTop' : left_offset});
271		$(firstRight).css({'marginTop' : right_offset}); 
272	}
273
274	var leftTopMargin = stripPx(left_offset);
275	var rightTopMargin = stripPx(right_offset);
276	
277	if(leftTopMargin < 0){
278		if($(firstLeft).hasClass('text-ct')){
279			$(firstLeft).css({'padding' : '0px 64px 64px 64px'});
280		}else{
281			
282		var leftImage = $(firstLeft).find('img');
283		
284		$(firstLeft).css({'padding' : '0px 64px 64px 0px'});
285		
286		$(leftImage).css({'padding' : '64px 32px 32px 64px'});
287		$(firstLeft).css({'marginLeft' : '64px'});
288
289		}
290	}
291	
292	if(rightTopMargin < 0){
293		if($(firstRight).hasClass('text-ct')){
294			$(firstRight).css({'padding' : '0px 64px 64px 64px'});
295		}else{
296			
297		var rightImage = $(firstRight).find('img');
298		
299		$(firstRight).css({'padding' : '0px 64px 64px 0px'});
300		
301		$(rightImage).css({'padding' : '64px 32px 32px 32px'});
302		$(firstRight).css({'marginLeft' : '64px'});
303
304		}
305	}
306	
307	 if(ll  > 1){
308		 
309		 for(i=2; i<= ll; i++){
310			 var thisLeft = lefts[i];
311			 var prevLeft = lefts[i-1];
312			 	
313			if(prevLeft){
314				 prevLeft = $(prevLeft);
315				 var prevTopMargin = $(prevLeft).css('marginTop');
316				 prevTopMargin = stripPx(prevTopMargin);
317				 var prevLeftHeight = $(prevLeft).height();
318				 var newOffset = prevTopMargin + prevLeftHeight;
319				 $(thisLeft).css({'marginTop' : newOffset + 'px'})
320			}
321		 } 
322	  		
323	  }
324	 
325	 if(rl  > 1){
326		 
327		 for(i=2; i<=rl; i++){
328			
329			 var thisRight = rights[i];
330			 var prevRight = rights[i-1];
331			 	
332			if(prevRight){
333				 prevRight = $(prevRight);
334				 var prevTopMargin = $(prevRight).css('marginTop');
335				 prevTopMargin = stripPx(prevTopMargin);
336				 var prevRightHeight = $(prevRight).height();
337				 var newOffset = prevTopMargin + prevRightHeight;
338				 $(thisRight).css({'marginTop' : newOffset + 'px'})
339			}
340			 
341		 } 
342	  		
343	  }
344		
345	
346	 var height = setHeight(firstSection );
347		$(firstSection).css({'height' : height + 'px'});
348
349}
350
351//*************************************  ADJUST INTERNAL ELEMENTS TOP MARGINS *************************************//
352
353function internalOffsets(section, elem){
354
355	var section = $(section)
356	var elem = $(elem);
357	var elements = $(section).find(elem);
358	var el = $(elements).length;
359	
360	for(i=1; i <= el; i++){		
361
362			var thisElement = elements[i];
363			var prevElement = elements[i-1];
364
365			if(prevElement){
366				prevElement = $(prevElement);
367				var prevHeight = $(prevElement).height() - 64;
368				var prevMarginTop = $(prevElement).css('marginTop');
369				prevMarginTop = stripPx(prevMarginTop);
370				
371				if(prevMarginTop > 0){
372					var thisOffset = prevMarginTop + prevHeight + 64 + 'px';
373				}else{
374					var thisOffset = prevHeight + prevMarginTop +  64 + 'px';
375				}
376				
377				
378					
379				
380			/*	if(thisOffset > 0){
381					thisOffset = thisOffset + 'px';
382
383				} else{
384					
385					thisOffset = '-' + thisOffset + 'px';
386				}*/
387				
388				$(thisElement).css({'marginTop' : thisOffset})
389			}
390		
391	}
392	
393	
394	var height = setHeight(section );
395	$(section).css({'height' : height + 'px'})
396}
397
398
399//*************************************  GET ELEMENT HEIGHT *************************************//
400
401
402
403function setHeight(section){
404	tops=[];
405	bottoms=[];
406	
407	var thisSection = $(section);
408	var section_elements = $(thisSection).find('.both-sides, .right-side, .left-side ')
409	var el = $(section_elements).length;
410	
411	for(i=0; i<el; i++){
412		var thisElement = section_elements[i];
413		var thisTop = $(thisElement).position().top;
414		var top = getTop(thisElement);
415		var bottom = getBottom(thisElement );
416			
417		tops.push(top);
418		bottoms.push(bottom);
419	}
420
421				
422var highest = Math.min.apply(Math, tops);
423var lowest = Math.max.apply(Math, bottoms);
424var height = lowest - Math.abs(highest) + 64;
425
426//$(thisSection).css({'height' : height + 'px'})
427return height;
428}
429
430
431
432
433
434//*************************************  GET ELEMENT BOTTOM POSITION *************************************//
435  
436function getBottom(elem){
437			
438	var thisPosition = $(elem).position();
439				
440	if(thisPosition){
441		var thisTop = thisPosition.top;	
442		var thisHeight = $(elem).height();
443		var thisBottom = thisTop + thisHeight;	
444		var thisTopMargin = $(elem).css('marginTop');
445	}
446				  
447	if(thisTopMargin){
448		thisTopMargin = stripPx(thisTopMargin);
449		//adjust bottom value based on top margin
450		thisBottom = thisBottom + thisTopMargin;
451	}
452	else{
453		 //or leave bottom value as is
454		thisBottom = thisBottom;
455	}
456	
457	return(thisBottom);
458}
459
460//*************************************  GET ELEMENT TOP POSITION *************************************//
461
462function getTop(elem){
463var pos = $(elem).position();
464var top = pos.top;
465var	mt = $(elem).css('marginTop');
466if(mt){
467var mtn = parseInt(stripPx(mt));
468top = top + Math.abs(mtn);
469//top = top;
470}else{
471top = top;
472}
473return(top);
474}
475
476
477
478
479//*************************************  CONVERT CSS STRING TO NUMBER  *************************************//
480	
481	function stripPx(string){
482		var pxNum = parseInt(string.replace('px', ''));
483		return pxNum;
484	}	
485});//ends doc ready

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.