PageSourceSearch

https://www.building-supplies.co.nz/wp-content/themes/probusiness/js/main.js?ver=1.0

js building-supplies.co.nz collected 2026-10-08 03:59:15 UTC 14,251 bytes, 448 lines download raw bytes

1/* 
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5/*-------------------------------------------------------------------------*/
6function wheel(event) {
7	if (event.wheelDelta) delta = event.wheelDelta / 120; 
8	else if (event.detail) delta = -event.detail / 3;
9	handle(270,500);
10	if (event.preventDefault){event.preventDefault()};
11	event.returnValue = false;
12}
13function handle(distance,time) {
14	jQuery('html, body').stop().animate({
15		scrollTop: jQuery(window).scrollTop() - (distance * delta)
16	}, time);
17}
18function fullWidth(){
19    var windowWidth = jQuery(window).width();
20    jQuery('.stripe').each(function(){
21        var $bgobj = jQuery(this);
22        var width = $bgobj.width();
23        var v = (windowWidth - width)/2;
24        $bgobj.css({
25            marginLeft:-v,
26            paddingLeft:v,
27            paddingRight:v
28        });
29    })
30}
31function boxed(){
32    var windowWidth = jQuery(window).width();
33    jQuery('.stripe').each(function(){
34        jQuery(this).css({
35            marginLeft:0,
36            paddingLeft:0,
37            paddingRight:0
38        });
39    })
40}
41function calcToTopColor(){
42	var $scrollTop = jQuery(window).scrollTop();
43	var $windowHeight = jQuery(window).height();
44	if($scrollTop > $windowHeight){
45		jQuery('#to-top').fadeIn();
46	}
47	else {
48		jQuery('#to-top').fadeOut();
49	}
50}
51jQuery(document).ready(function($){
52	"use strict";
53    $(window).resize(function(){
54        fullWidth();
55    })
56    /* Menu */
57	var depth = 0;
58	var el = null;
59	var w_width = jQuery(window).width();
60	jQuery('li.menu-item').hover(function(){
61		el = jQuery('.sub-menu:first',this);
62		if(el.length > 0){
63			var el_width = el.outerWidth();
64			var el_left = el.offset().left;
65			console.log(el_left);
66			if(w_width < (el_left+el_width)){
67				el.addClass('autodrop_left');
68			}else if(el_left<=0){
69				el.addClass('autodrop_right');
70			}
71		}
72	},function(){
73		if(el){
74			el.removeClass('autodrop_left');
75			el.removeClass('autodrop_right');
76			el = null;
77		}
78	})
79	/* End Menu */ 
80    $(window).scroll(function() {        
81        var offsetTop = $(this).scrollTop();
82        var headerHeight = $('#ww_header').height();
83        var headerOffset = $('#ww_header').offset();
84        if (offsetTop > (headerHeight/2) + headerOffset.top) { 
85            $('#stripe-style-header-wrapper').hide();
86            $('#ww_stick_header').show();
87            $('.ww-stick-header-wrapper').stop().animate({
88                top: 0
89            }, 400);
90        } else {
91            $('#stripe-style-header-wrapper').show();
92            $('#ww_stick_header').hide();
93            $('.ww-stick-header-wrapper').stop().animate({
94                top: -100
95            }, 100);
96        }
97    });
98	
99	/***************** Superfish ******************/
100    function initSF() {
101        $(".sf-menu").superfish({
102            delay: 0,
103            autoArrows: true,
104            speed: 'fast',
105            animation: {
106                opacity: 'show'
107            }
108        });
109    }
110    function addOrRemoveSF() {
111        if ($(window).width() < 940 && $('body').attr('data-responsive') == '1') {
112            $('body').addClass('mobile');
113            $('.ww-header-wrapper nav').hide();
114        }
115        else {
116            $('body').removeClass('mobile');
117            $('.ww-header-wrapper nav').show();
118            //$('.mobile-menu').hide();
119            $('.ww-submenu-mobile').hide();
120            $('.ww-submenu-mobiles').hide();
121            $('.ww-nav-stick').hide();
122            $('.sf-sub-indicator').css('height', $('a.sf-with-ul').height());
123        }
124    }
125    $('nav > ul.ww-menu > li.has-sub-menu').each(function() {
126        $(this).find(' > a').append('<span class="sf-sub-indicator"><i class="fa fa-caret-down"></i></span>');
127    });
128    
129    $('#menu-top-menu li').each(function() {
130        $(this).find(' > a').append('<span class="menusys_name"><i class="fa fa-home left"></i></span>');
131    });
132    
133    /* Hover on Verticla and Accordion menu */
134    $('.ww-menu-vertical .level-0 > li:has(">ul")').mouseover(function() {
135        $(this).find('.sf-sub-indicator').html('<i class="fa fa-caret-right"></i>');
136    });
137    $('.ww-menu-vertical .level-0 > li:has(">ul")').mouseout(function() {
138        $(this).find('.sf-sub-indicator').html('<i class="fa fa-caret-down"></i>');
139    });
140    /* Responsive nav */
141    $('#toggle-nav').click(function() {
142        $('.ww-submenu-mobile').stop(true, true).slideToggle(500);
143        return false;
144    }); 
145	$('#toggle-nav-mobiles').click(function() {
146        $('.ww-submenu-mobiles').stop(true, true).slideToggle(500);
147        return false;
148    });
149	$('#toggle-nav-stick').click(function() {
150        $('.ww-nav-stick').stop(true, true).slideToggle(500);
151        return false;
152    });
153    /* Append dropdown indicators / give classes */
154    $('.ww-submenu-mobile ul li').each(function() {
155        if ($(this).find('> ul').length > 0) {
156            $(this).addClass('has-ul');
157            $(this).find('> a').append('<span class="sf-sub-indicator"><i class="fa fa-angle-down"></i></span>');
158        }
159    });
160	/* Append dropdown indicators / give classes */
161    $('.ww-submenu-mobiles ul li').each(function() {
162        if ($(this).find('> ul').length > 0) {
163            $(this).addClass('has-ul');
164            $(this).find('> a').append('<span class="sf-sub-indicator"><i class="fa fa-angle-down"></i></span>');
165        }
166    });
167	$('.ww-nav-stick ul li').each(function() {
168        if ($(this).find('> ul').length > 0) {
169            $(this).addClass('has-ul');
170            $(this).find('> a').append('<span class="sf-sub-indicator"><i class="fa fa-angle-down"></i></span>');
171        }
172    });
173    /* Events */
174    $('.ww-submenu-mobile ul li:has(">ul") > a .sf-sub-indicator').click(function() {
175        $(this).parent().parent().toggleClass('open');
176        $(this).parent().parent().find('> ul').stop(true, true).slideToggle();
177        return false;
178    });
179	$('.ww-submenu-mobiles ul li:has(">ul") > a .sf-sub-indicator').click(function() {
180        $(this).parent().parent().toggleClass('open');
181        $(this).parent().parent().find('> ul').stop(true, true).slideToggle();
182        return false;
183    }); 
184	$('.ww-nav-stick ul li:has(">ul") > a .sf-sub-indicator').click(function() {
185        $(this).parent().parent().toggleClass('open');
186        $(this).parent().parent().find('> ul').stop(true, true).slideToggle();
187        return false;
188    }); 	
189	
190    /* End Horizontal Menu */
191	
192	if ( $.browser.webkit ) {
193		if (window.addEventListener) window.addEventListener('DOMMouseScroll', wheel, false);
194		window.onmousewheel = document.onmousewheel = wheel;
195		var time = 500;
196		var distance = 270;
197		$(document).keydown(function (e) {
198			switch (e.which) {
199				/* up */
200				case 38:
201					$('html, body').stop().animate({
202						scrollTop: $(window).scrollTop() - distance
203					}, time);
204					break;
205				/* down */
206				case 40:
207					$('html, body').stop().animate({
208						scrollTop: $(window).scrollTop() + distance
209					}, time);
210					break;
211			}
212		})
213	}
214	/*-------------------------------------------------------------------------*/
215	/* Scroll to top
216	/*-------------------------------------------------------------------------*/
217	var $scrollTop = $(window).scrollTop();
218    
219    /* starting bind */
220    if( $('#to-top').length > 0 && $(window).width() > 1000) {	
221        if($scrollTop > 350){
222            $(window).bind('scroll',hideToTop);
223        }
224        else {
225            $(window).bind('scroll',showToTop);
226        }
227    }
228    function showToTop(){
229        if( $scrollTop > 350 ){
230            $('#to-top').stop(true,true).animate({
231                'bottom' : '5px'
232            },350,'easeInOutCubic');			
233            $(window).unbind('scroll',showToTop);
234            $(window).bind('scroll',hideToTop);
235        }
236    }
237    function hideToTop(){
238        if( $scrollTop < 350 ){
239            $('#to-top').stop(true,true).animate({
240                'bottom' : '-30px'
241            },350,'easeInOutCubic');	
242		
243            $(window).unbind('scroll',hideToTop);
244            $(window).bind('scroll',showToTop);			
245        }
246    }
247    /* to top color */
248    if( $('#to-top').length > 0 ) {	
249        /* calc on scroll */
250        $(window).scroll(calcToTopColor);
251	
252        /* calc on resize */
253        $(window).resize(calcToTopColor);
254    }
255    /* scroll up event */
256    $('#to-top').click(function(){
257        $('body,html').stop().animate({
258            scrollTop:0
259        },800,'easeOutCubic')
260        return false;
261    });
262	
263	$('.alert a').click(function(){
264        var $p =$(this).parent();
265        $p.parent().slideUp(500);
266    })
267	
268    /* Parallax Section */
269    var windowHeight = jQuery(window).height();
270    fullWidth();
271    jQuery('.stripe-parallax-bg').each(function(){
272        var $bgobj = jQuery(this); // assigning the object
273    
274        jQuery(window).scroll(function() {
275            var scrollTop = jQuery(window).scrollTop();
276            var offset = $bgobj.offset().top;
277            var height = $bgobj.height();
278            /* Check if above or below viewport */
279            if (offset + height <= scrollTop || offset >= scrollTop + windowHeight) {
280            /* return; */
281            }
282            
283            var yPos = Math.round((offset - scrollTop) * 0.5);
284             
285            /* Put together our final background position */
286            var coords = 'center '+ (-yPos) + 'px';
287 
288            /* Move the background */
289            $bgobj.css({
290                backgroundPosition: coords
291            });
292        });
293    })
294	/* Video Section */
295    if(jQuery(window).width() > 767){
296        jQuery('.stripe-video-bg video.video-parallax').each(function(){
297            var $bgobj = jQuery(this);
298			var p_offsetTop = $bgobj.parents('.stripe-video-bg').offset().top;
299			var p_Height = $bgobj.parents('.stripe-video-bg').height();
300			var p_paddingTop = parseInt($bgobj.parent().css('paddingTop'));
301			var p_paddingBottom = parseInt($bgobj.parent().css('paddingBottom'));
302			var height = p_Height+p_paddingTop+p_paddingBottom;
303			$bgobj.attr('data-offset',height+p_offsetTop);
304			$bgobj.css({ 
305				 top: p_offsetTop
306			});
307            jQuery(window).scroll(function() {
308                var scrollTop = jQuery(window).scrollTop();
309                var offsetTop = $bgobj.offset().top;
310                var p_offsetTop = $bgobj.parents('.stripe-video-bg').offset().top;
311                var p_Height = $bgobj.parents('.stripe-video-bg').height();
312                var p_paddingTop = parseInt($bgobj.parent().css('paddingTop'));
313                var p_paddingBottom = parseInt($bgobj.parent().css('paddingBottom'));
314				var height = p_Height+p_paddingTop+p_paddingBottom;
315				var yPos = p_offsetTop-scrollTop;
316				$bgobj.css({ 
317					 top: yPos
318				});
319				if(p_offsetTop<scrollTop&&(p_offsetTop+p_Height+p_paddingTop+p_paddingBottom)>scrollTop){
320					$bgobj.css({ 
321						 top: 0
322					});
323				}
324				if((p_offsetTop+p_Height+p_paddingTop+p_paddingBottom)<scrollTop){
325					//$bgobj.hide();
326				}
327            }); 
328        });
329    }
330    jQuery('.tabs-wrapper').each(function() {
331        jQuery(this).find(".tab_content").hide(); //Hide all content
332        jQuery(this).find("ul.tabs li:first").addClass("active").show(); //Activate first tab
333        jQuery(this).find(".tab_content:first").show(); //Show first tab content
334    });
335	
336    /* On Click Event */
337    jQuery("ul.tabs li").click(function(e) {
338        jQuery(this).parents('.tabs-wrapper').find("ul.tabs li").removeClass("active");
339		/* Remove any "active" class */
340        jQuery(this).addClass("active"); //Add "active" class to selected tab
341        jQuery(this).parents('.tabs-wrapper').find(".tab_content").hide();
342		/* Hide all tab content */
343        var activeTab = jQuery(this).find("a").attr("href");
344		/* Find the href attribute value to identify the active tab + content */
345        jQuery(this).parents('.tabs-wrapper').find(activeTab).fadeIn();
346		/* Fade in the active ID content */
347		
348        e.preventDefault();
349    });
350	
351    jQuery("ul.tabs li a").click(function(e) {
352        e.preventDefault();
353    });
354	
355	jQuery('.es-carousel-wrapper').each(function() {
356        jQuery(this).elastislide({
357            imageW: 190,
358            minItems: 1,
359            margin: 30,
360            border: 0,
361            current:10
362        });
363    });
364    
365    /* Fix to adjust on windows resize */
366    jQuery(window).triggerHandler('resize.elastislide');
367});
368jQuery(window).load(function($) {
369	var dataFixedFooter = jQuery('body').data('fixed-footer');
370	if(dataFixedFooter == 1){
371	if (jQuery(window).width() >= 768) {
372		jQuery('#ww_footer').prevAll('section').css({
373			position: 'relative',
374			zIndex: 1
375		});
376		jQuery('#ww_footer').prev().css({
377			marginBottom: (jQuery('#ww_footer').height()) + 'px'
378		});
379		jQuery('#ww_footer').css({
380			bottom: 0
381		});
382		jQuery('#ww_footer').css({
383			position: 'fixed',
384			width: '100%'
385		});
386	}
387	
388	jQuery(window).resize(function() {
389		if (jQuery(window).width() >= 768) {
390			setTimeout(function() {
391				fixedfooter()
392			}, 500);
393		} else {
394			normalfooter();
395		}
396	});
397	
398	function fixedfooter() {
399		jQuery('#ww_footer').prevAll('section').css({
400			position: 'relative',
401			zIndex: 1
402		});
403		jQuery('#ww_footer').prev().css({
404			marginBottom: (jQuery('#ww_footer').height()) + 'px'
405		});
406		jQuery('#ww_main_body').css({
407			bottom: (jQuery('#ww_footer').height()) + 'px'
408		});
409		jQuery('#ww_footer').css({
410			bottom: 0
411		});
412		jQuery('#ww_footer').css({
413			position: 'fixed',
414			width: '100%'
415		});
416	}
417	function normalfooter() {
418		jQuery('#ww_footer').prev().css({
419			marginBottom: 0
420		});
421		jQuery('#ww_footer').css({
422			position: 'relative'
423		});
424		jQuery('#ww_footer').css({
425			marginBottom: 0,
426			bottom: 0
427		});
428	}
429	
430	}
431	
432	jQuery('.wpb_row').each(function(){
433        if(jQuery(this).hasClass('ww-same-height')){
434            var height = jQuery(this).height();
435             jQuery(this).find(".vc_style").each(function(){
436                jQuery(this).css('min-height', height);
437            });
438        }
439        
440    });
441     var windowWidth = jQuery(window).width();
442    jQuery('.stripe').each(function(){
443        var $bgobj = jQuery(this);
444		var width = $bgobj.width();
445		var v = (windowWidth - width)/2;
446		$bgobj.css({marginLeft:-v,paddingLeft:v,paddingRight:v});
447    })
448});

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.