Completed
Push — master ( 5d4641...4113bc )
by
unknown
04:20
created

$(document).ready   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 0
dl 0
loc 19
rs 9.4285
c 0
b 0
f 0
1
var filter_item_width;
2
3
jQuery(document).ready(function($) {
4
	var $window = $(window),
5
		windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth,
6
		windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
7
8
	$window.resize(function() {
9
		windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth,
0 ignored issues
show
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
10
		windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
11
	});
12
13
	if ( $("header.banner").hasClass("navbar-static-top") ) {
14
		$("body").addClass("top-menu-fixed");
15
	}
16
	
17
	if($('li.menu-item-language-current.dropdown').length){
18
		$('li.menu-item-language-current.dropdown').find('a:first').append('<span class="caret"></span>');
19
	}
20
21
	if ($('.wp-pagenavi').children().length == 0) {
22
		$('.wp-pagenavi').remove();
23
	} else {
24
		$('.wp-pagenavi').wrap('<div class="wp-pagenavi-wrapper"></div>');
25
		$('<div class="lsx-breaker"></div>').prependTo( ".wp-pagenavi-wrapper" );
26
	}
27
28
	var sidebarExists = document.getElementById("secondary");
29
	if (sidebarExists) {
30
		$('body').addClass('has-sidebar');
31
	}
32
33
	if ( $('header.banner .container form').hasClass('search-form') ) {
34
		$('body').addClass('has-header-search');
35
	}
36
37
	var neg_margin = $('.portfolio-title').height();
38
	if (neg_margin > 40) {
39
		$('.portfolio-title').css('margin-top', -neg_margin);
40
	} else {
41
		$('.portfolio-title').css('margin-top', -neg_margin/2);
42
	}
43
44
	$('header.banner .search-toggle').remove();
45
46
	filter_item_width = jQuery('.filter-items-container').width();
47
	if(jQuery('.filter-items-container .filter-item').hasClass('column-1')){
48
		filter_item_width = 750;
49
	}else if(jQuery('.filter-items-container .filter-item').hasClass('column-2')){
50
		filter_item_width = filter_item_width/2;
51
	}else if(jQuery('.filter-items-container .filter-item').hasClass('column-3')){
52
		filter_item_width = filter_item_width/3;
53
	}else if(jQuery('.filter-items-container .filter-item').hasClass('column-4')){
54
		filter_item_width = filter_item_width/4;
55
	}else if(jQuery('.filter-items-container .filter-item').hasClass('column-5')){
56
		filter_item_width = filter_item_width/5;
57
	}else if(jQuery('.filter-items-container .filter-item').hasClass('column-6')){
58
		filter_item_width = filter_item_width/6;
59
	}
60
	
61
	if(windowWidth <= 768 && windowWidth > 400){
62
		filter_item_width = jQuery('.filter-items-container').width()/2;
63
		
64
		jQuery('.filter-items-container .filter-item').each(function(){
65
			jQuery(this).removeClass('column-1 column-2 column-3 column-4 column-5 column-6');
66
			jQuery(this).addClass('column-2');
67
		});
68
	}
69
70
	if(windowWidth <= 400){
71
		filter_item_width = jQuery('.filter-items-container').width();
72
		jQuery('.filter-items-container .filter-item').each(function(){
73
			jQuery(this).removeClass('column-1 column-2 column-3 column-4 column-5 column-6');
74
			jQuery(this).addClass('column-1');
75
		});
76
	}	
77
	
78
	$('table#wp-calendar').addClass('table');
79
80
	$('.dropdown-menu').on('touchstart.dropdown.data-api', function(e){
81
	    e.stopPropagation();
82
	});
83
84
	$window.scroll(function(){
85
	    if ( $window.scrollTop() > 250 && windowWidth > 768 ) {
86
	        $('#top-menu.top-menu-fixed').slideUp();
87
	        $('header.banner.navbar-static-top').addClass('scrolled');
88
	    } else {
89
	        $('#top-menu.top-menu-fixed').slideDown();
90
	        $('header.banner.navbar-static-top').removeClass('scrolled');
91
	    }
92
	});
93
	
94
	$window.resize(function () {
95
		if ( $window.scrollTop() > 250 && windowWidth > 768 ) {
96
	        $('#top-menu.top-menu-fixed').slideUp();
97
	        $('header.banner.navbar-static-top').addClass('scrolled');
98
	    } else {
99
	        $('#top-menu.top-menu-fixed').slideDown();
100
	        $('header.banner.navbar-static-top').removeClass('scrolled');
101
	    }
102
103
		var neg_margin = $('.portfolio-title').height();
104
		if (neg_margin > 40) {
105
			$('.portfolio-title').css('margin-top', -neg_margin);
106
		} else {
107
			$('.portfolio-title').css('margin-top', -neg_margin/2);
108
		}
109
	});
110
111
	// Disabling homepage slider, background image area on mobile
112
	$window.resize(function () {
113
	    if (windowWidth < 768) {
114
	        $(".home-bg-image").hide();
115
	        $(".home-bg-image-footer").hide();
116
	    } else {
117
	    	$(".home-bg-image-footer").show();
118
	        $(".home-bg-image").show();
119
	    }
120
	});
121
122
	// Sticky Info Box widget
123
	var spacing = 0;
124
	if ($('body').hasClass('logged-in')) {
125
		spacing = 125;
126
	} else {
127
		spacing = 93;
128
	}
129
130
	$(".info-box-sticky").sticky({ 
131
		topSpacing: spacing,
132
		bottomSpacing: 670,
133
		getWidthFrom: '#secondary',
134
		responsiveWidth: true,
135
		responsiveBreakpoint: 992
136
	});
137
138
	// Sticky Book Now widget
139
	$(".sticky-book").sticky({ 
140
		topSpacing: spacing,
141
		bottomSpacing: 520,
142
		getWidthFrom: '#secondary',
143
		responsiveWidth: true,
144
		responsiveBreakpoint: 992
145
	});
146
147
	// Sticky Enquire Now widget
148
	$(".sticky-enquire").sticky({ 
149
		topSpacing: spacing,
150
		bottomSpacing: 2000,
151
		getWidthFrom: '#secondary',
152
		responsiveWidth: true,
153
		responsiveBreakpoint: 992
154
	});
155
156
    $window.load(function() {
157
		// The sorter for the portfolio.
158
    	var has_filter = $('#filterNav');
159
    	if('undefined' !== has_filter){
160
			$('#main').imagesLoaded( function(){
161
				lsxProjectThumbInit();
162
				lsxProjectFilterInit();
163
	
164
				jQuery('#main').css('opacity', '1' );
165
		    });			
166
    	}
167
    	
168
    	//Portfolio Hover Class
169
		if(lsx_params.is_portfolio){
0 ignored issues
show
Bug introduced by
The variable lsx_params seems to be never declared. If this is a global, consider adding a /** global: lsx_params */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
170
			$('.portfolio-content-wrapper').hover(function() {
171
		        $(this).addClass('active');
172
		    }, function() {
173
		        $(this).removeClass('active');
174
		    });
175
		}
176
    	
177
		$('.masonry > article').hover(function() {
178
	        $(this).addClass('active');
179
	    }, function() {
180
	        $(this).removeClass('active');
181
	    });
182
183
		// Bootstrat Menu
184
185
		if (1199 < windowWidth) {
186
			$('.navbar-nav li.dropdown a').each(function() {
187
				$(this).removeClass('dropdown-toggle');
188
				$(this).removeAttr('data-toggle');
189
			});
190
		}
191
		
192
		$('.dropdown').on('show.bs.dropdown', function() {
193
			if (1200 > windowWidth) {
194
				$(this).siblings('.open').removeClass('open').find('a.dropdown-toggle').attr('data-toggle', 'dropdown');
195
				$(this).find('a.dropdown-toggle').removeAttr('data-toggle');
196
			}
197
		});
198
199
		$window.resize(function() {
200
			if (1199 < windowWidth) {
201
				$('.navbar-nav li.dropdown a').each(function() {
202
					$(this).removeClass('dropdown-toggle');
203
					$(this).removeAttr('data-toggle');
204
				});
205
			} else {
206
				$('.navbar-nav li.dropdown a').each(function() {
207
					$(this).addClass('dropdown-toggle');
208
					$(this).attr('data-toggle','dropdown');
209
				});				
210
			}
211
		});
212
213
		// Grandchild Menu
214
215
		var fixDropdownPosition = function() {
216
			$('.navbar-nav > .menu-item:last-child').each(function() {
217
				if ($(this).hasClass('menu-item-has-children')) {
218
					var $firstMenuItem = $(this),
219
						$dropdown = $firstMenuItem.children('.dropdown-menu'),
220
						$dropdownItem = $dropdown.children('.menu-item-has-children'),
221
						dropdownWidth,
222
						firstMenuItemRight;
223
224
					//if ($dropdownItem.length > 0) {
225
						dropdownWidth = $dropdown.outerWidth(),
0 ignored issues
show
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
226
						firstMenuItemRight = (windowWidth - ($firstMenuItem.offset().left + $firstMenuItem.outerWidth()));
227
228
						if (firstMenuItemRight < dropdownWidth) {
229
							$dropdown.addClass('pull-right');
230
							$dropdownItem.addClass('dropdown-menu-left');
231
						}
232
					//}
233
				}
234
			});
235
		};
236
237
		if (1199 < windowWidth) {
238
			fixDropdownPosition();
239
		} else {
240
			$('.dropdown .dropdown > a').on("click", function(e) {
241
				if (!$(this).hasClass('open')) {
242
					$(this).addClass('open');
243
					$(this).next('.dropdown-menu').toggle();
244
					e.stopPropagation();
245
					e.preventDefault();
246
				}
247
			});
248
		}
249
250
		// Search menu (in mobile)
251
252
		jQuery(document).on('click', 'header.banner #searchform button.search-submit', function(e) {
253
			if (1200 > windowWidth) {
254
				e.preventDefault();
255
				var form = jQuery(this).closest('form');
256
257
				if (form.hasClass('hover')) {
258
					form.submit();
259
				} else {
260
					form.addClass('hover');
261
					form.find('.search-field').focus();
262
				}
263
			}
264
		});
265
266
		jQuery(document).on('blur', 'header.banner #searchform .search-field', function(e) {
0 ignored issues
show
Unused Code introduced by
The parameter e is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
267
			if (1200 > windowWidth) {
268
				var form = jQuery(this).closest('form');
269
				form.removeClass('hover');
270
			}
271
		});
272
273
		// Parallax Effect on Banners
274
275
		var $banner,
276
			$bannerImage,
277
			$bannerContainer,
278
			bannerHeight,
279
			bannerContainerBaseSize,
280
			bannerParallax = function() {
281
				if ($window.scrollTop() <= windowHeight) {
282
					var scrolled = $window.scrollTop() / windowHeight * 100,
283
						paddingTop = (4 * scrolled),
284
						base = -130,
285
						top = base + (3 * scrolled),
286
						bottom = base - (3 * scrolled),
287
						breakpoint = bannerContainerBaseSize + paddingTop;
288
289
					$bannerImage.css('top', top + 'px');
290
					$bannerImage.css('bottom', bottom + 'px');
291
292
					if (breakpoint < bannerHeight) {
293
						$bannerContainer.css('padding-top', paddingTop + 'px');
294
					}
295
				}
296
			}
297
298
		if (991 < windowWidth) {
299
			$banner = $('.page-banner:not(.gmap-banner)');
300
301
			if ($banner.length > 0) {
302
				$bannerImage = $banner.children('.page-banner-image');
303
				$bannerContainer = $banner.children('.container');
304
				bannerHeight = $banner.height();
305
				bannerContainerBaseSize = $bannerContainer.height() + 
306
											parseInt(($bannerContainer.css('margin-top')).replace('px', '')) + 
307
											parseInt(($bannerContainer.css('margin-bottom')).replace('px', '')) + 
308
											parseInt(($bannerContainer.css('padding-bottom')).replace('px', ''));
309
				bannerParallax();
310
311
				$window.resize(function() {
312
					bannerHeight = $banner.height();
313
					bannerContainerBaseSize = $bannerContainer.height() + 
314
												parseInt(($bannerContainer.css('margin-top')).replace('px', '')) + 
315
												parseInt(($bannerContainer.css('margin-bottom')).replace('px', '')) + 
316
												parseInt(($bannerContainer.css('padding-bottom')).replace('px', ''));
317
				});
318
319
				$window.scroll(function(){
320
					bannerParallax();
321
				});
322
			}
323
		}
324
325
		// Comments anchor
326
327
		if (document.location.hash == '#comments') {
328
			var margin = jQuery('body').hasClass('top-menu-fixed') ? jQuery('header.banner').height() : 0;
329
			margin += jQuery('body').hasClass('admin-bar') ? jQuery('#wpadminbar').height() : 0;
330
331
			jQuery('html, body').animate({
332
				scrollTop: jQuery('.comments-link').offset().top - margin
333
			}, 500, function() {
334
				jQuery('.comments-link').trigger('click');
335
			});
336
		}
337
338
		if ((new RegExp("#comment-", "gi")).test(document.location.hash)) {
339
			var margin = jQuery('body').hasClass('top-menu-fixed') ? jQuery('header.banner').height() : 0;
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable margin already seems to be declared on line 328. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
340
			margin += jQuery('body').hasClass('admin-bar') ? jQuery('#wpadminbar').height() : 0;
341
342
			jQuery('html, body').animate({
343
				scrollTop: jQuery('.comments-link').offset().top - margin
344
			}, 500, function() {
345
				jQuery('.comments-link').trigger('click');
346
347
				jQuery('html, body').animate({
348
					scrollTop: jQuery(document.location.hash).offset().top - margin
349
				}, 500);
350
			});
351
		}
352
353
		// Sensei breadcrumb
354
		if ($('body').hasClass('sensei')) {
355
			if ($('header.archive-header').length > 0) {
356
				$('.woocommerce-breadcrumb').insertAfter('.archive-header');
357
358
				if ($('.woocommerce-breadcrumb').length > 1) {
359
					$('.woocommerce-breadcrumb').slice(1).remove();
360
				}
361
			}
362
		}
363
364
		//Lazy Load //Envira Gallery FIX
365
		var enviraIsotopUpdateLayout = function() {
366
			jQuery('.envira-gallery-wrap').each(function() {
367
				var id = jQuery(this).attr('id');
368
				id = id.replace('envira-gallery-wrap-', '');
369
370
				if (typeof envira_isotopes[id] == 'object') {
0 ignored issues
show
Bug introduced by
The variable envira_isotopes seems to be never declared. If this is a global, consider adding a /** global: envira_isotopes */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
371
					envira_isotopes[id].enviratope('layout');
372
				}
373
			});
374
		};
375
376
		if (jQuery('.lazyload, .lazyloaded').length > 0) {
377
			if (typeof envira_isotopes == 'object') {
378
				$window.scroll(function(){
379
					enviraIsotopUpdateLayout();
380
				});
381
			}
382
		}
383
384
		//Final load - LAST CODE TO EXECUTE
385
		$('body.preloader-content-enable').addClass('html-loaded');
386
	});
387
});
388
389
390
///////////////////////////////
391
//Project thumbs
392
///////////////////////////////
393
394
function lsxProjectThumbInit() {
395
	
396
	if( jQuery(".filter-items-container .filter-item").length ){
397
		jQuery('.filter-items-container').imagesLoaded( function() {
398
			
399
			jQuery('.filter-items-container').masonry({
400
				resizable: true,
401
				columnWidth: filter_item_width,
402
				itemSelector: '.filter-item'
403
			});		
404
		});	
405
	}
406
}
407
408
409
///////////////////////////////
410
//Project Filtering
411
///////////////////////////////
412
413
function lsxProjectFilterInit() {
414
	
415
	jQuery('#filterNav a').click(function(){
416
		var selector = jQuery(this).attr('data-filter');
417
		selector = selector.replace('.','');
418
		
419
		jQuery('.filter-items-container .filter-item').each(function(){
420
			
421
			if(jQuery(this).hasClass(selector) || '*' === selector){
422
				jQuery(this).show();
423
			}else{
424
				jQuery(this).hide();
425
			}
426
			
427
		});
428
		
429
		jQuery('.filter-items-container').masonry({
430
			resizable: true,
431
			columnWidth: filter_item_width,
432
			itemSelector: '.filter-item'
433
				
434
		});
435
		
436
		jQuery(window).trigger('resize');
437
438
		if ( !jQuery(this).hasClass('selected') ) {
439
			jQuery(this).parents('#filterNav').find('.selected').removeClass('selected');
440
			jQuery(this).addClass('selected');
441
		}
442
443
		return false;
444
	});	
445
}