PageSourceSearch

https://yelon.hu/wp-content/themes/cheerup/js/bunyad-theme.js?ver=6.0.3

js yelon.hu collected 2026-10-02 06:06:08 UTC 60,461 bytes, 2,196 lines download raw bytes

1/**
2 * CheerUp Theme Utilities
3 * 
4 * Copyright (c) 2018 ThemeSphere.
5 */
6var Bunyad_Theme = (function($) {
7	"use strict";
8	
9	var has_touch = false,
10		responsive_menu = false,
11		search_active = false,
12		sticky_bar_active = false
13	
14	// module
15	var self = {
16		has_sticky_nav: false,
17
18		init: function() 
19		{	
20			// Reflow bug fix for webkit
21			var nav = $('.navigation .menu ul').css('-webkit-box-sizing', 'border-box');
22			requestAnimationFrame(function() {
23				nav.css('-webkit-box-sizing', '');
24			});
25			
26			/**
27			 * Woocommerce
28			 */ 
29			$('.woocommerce-ordering .drop li a').on('click', function(e) {
30				var form = $(this).closest('form');
31				
32				form.find('[name=orderby]').val($(this).parent().data('value'));
33				form.submit();
34				
35				e.preventDefault();
36			});	
37			
38			$('.woocommerce .related > h2, .woocommerce .upsells > h2')
39				.addClass('block-heading').wrapInner('<span class="title" />');
40			
41			
42			// Fit videos to container
43			$('.featured-vid, .post-content').fitVids();
44			
45			// Add overlays to footer instagram
46			if ($('.mid-footer .instagram-pics').length) {
47				var link = $('.mid-footer .clear a');
48				link.addClass('overlay').html('<i class="fa fa-instagram"></i>' + link.text());
49			}
50			
51			// Back to top handler
52			$('.back-to-top').on('click', function() {
53				
54				// Using both html, body until scrollingElement has more support
55				$('html, body').animate({scrollTop: 0}, 800);
56				return false;
57			});
58			
59			// Go back handler
60			$('.go-back').on('click', function() { 
61				window.history.back();
62				return false;
63			});
64			
65			// Post ticker
66			$('.posts-ticker ul').each(function() {
67				
68				if (!$(this).find('li.active').length) {
69					$(this).find('li:first').addClass('active');
70				}
71				
72				var ticker = $(this);
73				
74				window.setInterval(function() {
75					
76					var active = ticker.find('li.active');
77					active.fadeOut(function() {
78						
79						var next = active.next();
80						if (!next.length) {
81							next = ticker.find('li:first');
82						}
83						
84						next.addClass('active').fadeIn();
85						active.removeClass('active');
86					});
87					
88				}, 8000);
89			});
90			
91			if (navigator.platform.toLowerCase().indexOf('win') !== -1) {
92				$('html').addClass('is-win');
93			}
94			
95			// Fix Firefox Bug #1149357
96			if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
97				
98				var logo = $('.logo-image');
99				if ($('.logo-image').length) {
100					
101					// order maters - attach event first
102					$('<img />').on('load', function() {
103						
104						// picked 2x logo? set 1x dimension to prevent firefox overflowing
105						if (logo.prop('currentSrc') !== logo.prop('src')) {
106							logo.prop('width', $(this)[0].naturalWidth).prop('height', $(this)[0].naturalHeight);
107						}
108						
109					}).attr('src', logo.attr('src'));
110				}
111			}
112			
113			/**
114			 * Header Parallax - for style 7
115			 */
116			var header = $('.main-head.top-below .inner'),
117				bg = header.css('background-image');
118			
119			if ($(window).width() > 940 && (bg && bg != 'none')) {
120				var parallax = $('<div class="parallax" />').css('background-image', bg);
121				header.append(parallax);
122				header.css('background-image', 'none');
123				
124				var bottom = parallax.offset().top + parallax.outerHeight(),
125					top = parallax.offset().top;
126				
127				$(window).on('scroll', function() {
128					
129					var scroll = $(window).scrollTop();
130					
131					// Already scrolled enough
132					if (scroll > bottom) {
133						return;
134					}
135					
136					var distance = scroll * 0.4;
137					
138					requestAnimationFrame(function() {
139						parallax.css('transform', 'translate3d(0,' + distance + 'px, 0)');
140					});
141				});
142			}
143			
144			// VC Blocks fix
145			$('.blocks .block, .blocks .wpb_content_element').last().addClass('last-block');
146			
147			// Setup search
148			this.search();
149			
150			// Setup all sliders
151			this.sliders();
152
153			// Setup mobile & touch navigation
154			this.responsive_nav();
155			
156			// Setup mega menus
157			this.mega_menus();
158			
159			// Setup sticky top-bar
160			this.sticky_bar();
161			
162			// Sticky sidebar
163			this.sticky_sidebar();
164						
165			// Lightbox for images
166			this.lightbox();
167			
168			// Likes system
169			this.likes();
170			
171			// Single post functionality
172			this.single();
173			
174			// Lazyload setup
175			this.lazy_load();
176			
177			// Masonry layouts setup
178			this.masonry();
179	
180			// Pin buttons
181			this.pin_it();
182		},
183
184		/**
185		 * Setup responsive and touch
186		 */
187		responsive_nav: function()
188		{
189			// detect touch capability dynamically
190			$(window).on('touchstart', function() {
191				has_touch = true;
192				$('body').addClass('touch');
193			});
194			
195			this.init_responsive_nav();
196			this.touch_nav();
197			var that = this;
198
199			$(window).on('resize orientationchange', function() {
200				that.init_responsive_nav();
201			});		
202		},
203		
204		/**
205		 * Setup the responsive nav events and markup
206		 */
207		init_responsive_nav: function() {
208			
209			if ($(window).width() > 940 || responsive_menu) {
210				return;
211			}
212			
213			// Set responsive initialized
214			responsive_menu = true;
215			
216			// Create off-canvas container
217			var menu_contain = $('.mobile-menu-container');
218			
219			// No items for mobile menu? Grab from others
220			if (!menu_contain.find('.mobile-menu').children().length) {
221				
222				// Merge existing menus
223				var mobile_menu = menu_contain.find('.mobile-menu'),
224				    main_menu = $('.navigation .menu');
225				
226				var menu = main_menu.children().clone();
227				
228				if (!main_menu.length) {
229					return;
230				}
231				
232				// add category mega menu links
233				menu.find('.mega-menu .sub-cats').each(function() {
234					var container = $(this).closest('.menu-item');
235					
236					container.append($(this).find('.sub-nav'));
237					container.find('.sub-nav').replaceWith(function() {
238						return $('<ul />', {html: $(this).html()});
239					});
240					
241					$(this).remove();
242					
243				});
244				
245				mobile_menu.append(menu);
246			}
247			
248			$('body').addClass('nav-off-canvas');
249			
250			// Setup mobile menu click handlers
251			$('.mobile-menu li > a').each(function() {
252				
253				if ($(this).parent().children('ul').length) {
254					$('<span class="chevron"><i class="fa fa-chevron-down"></i></span>').appendTo($(this));
255				}
256			});
257			
258			$('.mobile-menu li .chevron').click(function() {
259					$(this).closest('li').find('ul').first().parent().toggleClass('active item-active');
260					return false;
261			});
262			
263			// Menu open handler
264			$('.top-bar .mobile-nav, .main-head .mobile-nav').on('click', function() {
265				$('.mobile-menu').addClass('active');
266            	$('body').toggleClass('off-canvas-active');
267            	$('html').toggleClass('hide-scroll');
268			});
269			
270			// Off-canvas close
271			$('.off-canvas .close').click(function() {
272				$('body').toggleClass('off-canvas-active');
273			});
274		},
275
276		/**
277		 * Setup touch for touch devices
278		 */
279		touch_nav: function() {
280			
281			var targets = $('.menu:not(.mobile-menu) a'),
282				open_class = 'item-active',
283				child_tag = 'ul, .mega-menu';
284			
285			targets.each(function() {
286				
287				var $this = $(this),
288					$parent = $this.parent('li'),
289					$siblings = $parent.siblings().find('a');
290				
291				$this.click(function(e) {
292					
293					if (!has_touch) {
294						return;
295					}
296					
297					var $this = $(this);
298					e.stopPropagation();
299					
300					$siblings.parent('li').removeClass(open_class);
301					
302					// has a child? open the menu on tap
303					if (!$this.parent().hasClass(open_class) && $this.next(child_tag).length > 0 && !$this.parents('.mega-menu.links').length) {
304						e.preventDefault();
305						$this.parent().addClass(open_class);
306					}
307				});
308			});
309			
310			// close all menus
311			$(document).click(function(e) {
312				if (!$(e.target).is('.menu') && !$(e.target).parents('.menu').length) {
313					targets.parent('li').removeClass(open_class);
314				}
315			});
316		},
317		
318		/**
319		 * Search setup
320		 */
321		search: function() 
322		{
323			// Nav search overlay
324			$('.main-head.has-search-overlay .search-link').on('click', function() {
325				
326				var overlay = $(this).parent().find('.search-box-overlay');
327				
328				search_active = true;
329				if (overlay.hasClass('active')) {
330					search_active = false;
331				}
332				
333				overlay.toggleClass('active');
334				
335				return false;
336			});
337			
338			// Search bar for alt header
339			var search_active_alt = false;
340			$('.search-alt .top-bar .search-submit').on('click', function() {
341				if (!search_active_alt) {
342					$(this).closest('form').find('.search-field').addClass('active').focus();
343					search_active_alt = true;
344					
345					return false;
346				} 
347			});
348			
349			// Hide search on outside clicks
350			$(document).on('click', function(e) {
351				if (search_active && !$(e.target).parents('.search-box-overlay').length) {
352					$('.main-head.has-search-overlay .search-link').click();
353				}
354				
355				// Hide alt header search
356				if (search_active_alt && !$(e.target).parents('.top-bar').length) {
357					search_active_alt = false;
358					
359					$('.main-head.search-alt .search-submit')
360						.closest('form').find('.search-field').removeClass('active');
361				}
362			});
363
364			// Search modal
365			$('.main-head.has-search-modal .search-link').magnificPopup({
366				items: {
367					src: '.search-modal-wrap',
368					type: 'inline'
369				},
370				removalDelay: 400,
371				focus: 'input',
372				closeBtnInside: false,
373				closeOnBgClick: false,
374				mainClass: 'search-modal',
375				midClick: true,
376				fixedContentPos: true,
377				autoFocusLast: false
378			}); 
379		},
380		
381		/**
382		 * Mega Menus
383		 */
384		mega_menus: function()
385		{
386			// Bind events for mega menus
387			$('.navigation .mega-menu').each(function() {
388				
389				var menu = $(this),
390				    number = 4;
391				
392				if (menu.find('.one-fifth').length) {
393					number = 5;
394				}
395				
396				var slick_vars = {
397					draggable: false,
398					infinite: true,
399					slidesToShow: number,
400					slidesToScroll: number,
401					arrows: false
402				};
403				
404				// Helper to re-init
405				var slick_init = function(posts) {
406					if (!posts.hasClass('slick-initialized')) {
407						posts.slick(slick_vars);
408					}
409					// Race condition? Might have calculated while hiding - recalc pos
410					else if (posts.find('.slick-track').width() == 0) {
411						posts.slick('setPosition');
412					}
413				};
414				
415				// Init mega menus
416				var default_mega_menu = function f() {
417					slick_init( menu.find('.posts').last().addClass('active') );
418					return f;
419				}();
420
421				// Mega-menu sub-cats handling
422				menu.find('.menu-item').on('mouseenter', function() {
423
424					var id = parseInt( $(this).attr('class').match(/menu-cat-(\d+)/)[1] || 0 ),
425					    menu = $(this).parents('.mega-menu'),
426					    view_all = $(this).hasClass('view-all');
427				
428					if (!view_all && !id) {
429						return;
430					}
431					
432					// remove other actives
433					menu.find('.active, .current-menu-item').removeClass('active current-menu-item');
434
435					// activate current
436					$(this).addClass('current-menu-item');
437					var posts = menu.find('[data-id=' + id + ']').addClass('active');
438				
439					slick_init(posts);
440					
441					if (posts.find('.post').length < 5) {
442						posts.parent().find('.navigate').hide();
443					}
444					else {
445						posts.parent().find('.navigate').show();
446					}
447					
448					return false;
449				});
450				
451				// Reset mega menu state on fresh hover
452				menu.parent().on('mouseenter', function() {
453					
454					var menu = $(this).find('.mega-menu');
455					
456					// reset at beginning
457					menu.find('.active, .current-menu-item')
458						.removeClass('active current-menu-item');
459
460					$(this)[0].offsetWidth; // reflow
461					default_mega_menu();
462				});
463				
464			});
465			
466			// Mega menu pagination
467			$('.mega-menu .show-next, .mega-menu .show-prev').on('click', function() {
468				
469				var current = $(this).parents('.mega-menu').find('.posts.active'),
470				    action  = $(this).hasClass('show-prev') ? 'slickPrev' : 'slickNext';
471				
472				current.slick(action);
473				
474				return false;
475			});	
476		},
477
478		/**
479		 * Setup sticky bar if enabled
480		 */
481		sticky_bar: function()
482		{
483			var nav,
484			    top_bar = $('.top-bar-content'),
485			    is_smart = false,
486			    is_sticky = false,
487			    is_static = false,
488			    prev_scroll = 0,
489			    cur_scroll = 0,
490			    extra_top = 0,
491			    nav_top,
492			    hide_at,
493				head = $('.main-head'),
494				head_height;
495			
496
497			// Set height for container
498			var calc_head_size = writeRaf(function() {
499
500				// Don't reset if it's stuck
501				if (sticky_bar_active) {
502					return;
503				}
504
505				var new_height = head.css('min-height', 0).height();
506				head.css('min-height', new_height);
507				head_height = new_height;
508			});
509
510			var set_size = function(skip_calc) {
511
512				// Skip calculation if asked to and head height has been prev set
513				if (skip_calc && head_height) {
514					return;
515				}
516
517				calc_head_size();
518			};
519			
520			$(window).on('load resize', calc_head_size);
521			
522			var init = function() {
523				
524				// Reset vars - might be a re-init
525				is_static = false;
526
527				// Is smart?
528				var check_smart = function() {
529
530					// Enable smart at responsive
531					if ($(window).width() < 940) {
532						is_smart = true;
533					}
534					else {
535						is_smart = false;
536					}
537
538					if (nav && nav.data('sticky-bar') == 'smart') {
539						is_smart = true;
540					}
541				};
542				
543				if ($('.admin-bar').length) {
544					extra_top = $('#wpadminbar').height();
545				}
546				
547				// Target sticky based on header layout
548				if (head.is('.nav-below, .top-below')) {
549					
550					// Top bar below or nav-below-logo types
551					nav = head.hasClass('nav-below') ? $('.navigation.below') : top_bar;
552					
553					nav_top = nav.offset().top - extra_top;
554					hide_at = nav_top + 1;
555				}
556				// Compact has a sticky topbar configured below
557				else if (head.is('.simple') || (head.is('.compact') && $(window).width() >= 940)) {
558					
559					// Top bar below or nav below logo types
560					nav = head.find('.inner').first();
561					check_smart();
562					
563					nav_top = head.offset().top + (head.height()/2) - extra_top;
564					hide_at = nav_top + 200;
565
566					if (is_smart) {
567
568						// For performance
569						var parallax = $('.single-creative .featured');
570						if (parallax.length) {
571							hide_at  = nav_top;
572							nav_top += parallax.height();
573						}
574					}
575
576				}
577				else if (top_bar.length) {
578				
579					nav = top_bar;
580					check_smart();
581
582					// static sticky via CSS unless it's smart sticky
583					if (!is_smart && top_bar.data('sticky-bar')) {
584						top_bar.addClass('sticky-bar');
585						is_static = true;
586					}
587					
588					// default 
589					var pos_ele  = $('.top-bar');
590					
591					nav_top  = pos_ele.offset().top - extra_top,
592					hide_at  = nav_top + 1;
593				}
594
595				check_smart();
596
597				// Android fix on addr bar hide
598				if (is_smart && !sticky_bar_active) {
599					prev_scroll = 0;
600				}
601			};
602			
603			// Init and calculate defaults
604			init();
605			
606			if (!nav) {
607				return;
608			}
609			
610			// not enabled?
611			if (!nav.data('sticky-bar')) {
612				return;
613			}
614		
615			self.has_sticky_nav = true;
616			
617			if (nav.find('.sticky-logo').length) {
618				nav.addClass('has-logo');
619			}
620			
621			// disable the sticky nav
622			var remove_sticky = function() {
623				
624				// check before dom modification 
625				if (is_sticky) {
626					
627					sticky_bar_active = 0;
628					nav.removeClass('sticky-bar');
629					set_size(true);
630					
631					$(document).trigger('sticky-bar-hide');
632				}
633			};
634			
635			// Check and apply sticky - separated writes
636			var sticky_writes = writeRaf(function() {
637				
638				// make it sticky when viewport is scrolled beyond the navigation
639				if (cur_scroll > nav_top) {
640					
641					// for smart sticky, test for scroll change
642					if (is_smart && (!prev_scroll || cur_scroll > prev_scroll)) {
643						remove_sticky();
644					}
645					else {
646						sticky_bar_active = 1;
647						
648						if (!is_smart || cur_scroll < prev_scroll-4) {
649
650							if (!nav.hasClass('sticky-bar')) {
651								nav.addClass('sticky-bar no-transition');
652							
653								setTimeout(function() { 
654									nav.removeClass('no-transition'); 
655								}, 100);
656								
657								$(document).trigger('sticky-bar-show');
658							}
659						}
660					}
661					
662					prev_scroll = cur_scroll;
663					
664				} else {
665					
666					// hide at a certain point
667					if (cur_scroll <= hide_at) {
668						prev_scroll = 0;
669						remove_sticky();
670					}
671				}
672			});
673			
674			// Make the nav sticky
675			var sticky = function() {
676
677				if (!nav.data('sticky-bar') || is_static) {
678					return;
679				}
680
681				cur_scroll = $(window).scrollTop();
682				is_sticky  = nav.hasClass('sticky-bar');
683				
684				sticky_writes();
685			};
686
687			sticky();
688
689			$(window).on('scroll', function() {
690				sticky();
691			});
692			
693			// Re-initialize on resize
694			$(window).on('resize orientationchange', function() {
695				init();
696				sticky();
697			});
698		},
699		
700		/**
701		 * Setup sticky sidebar
702		 */
703		sticky_sidebar: function() 
704		{
705			
706			// Sidebar class on the widget element? Move it up
707			$('.main .sidebar').each(function() {
708				if ($(this).hasClass('wpb_content_element')) {
709					var parent = $(this).closest('.wpb_column'),
710						classes = 'sidebar';
711					
712					if ($(this).hasClass('sticky-col')) {
713						classes += ' sticky-col';
714					}
715					
716					parent.addClass(classes);
717					$(this).removeClass(classes);
718				}
719			});
720			
721			var sticky = $('.main .sticky-col, .main .sidebar[data-sticky=1]');
722			
723			if (!sticky.length) {
724				return;
725			}
726			
727			var add = 20;
728			if ($('.admin-bar').length) {
729				add += 32;
730			}
731			
732			if (self.has_sticky_nav) {
733				add += 50;
734			}
735			
736			sticky.each(function() {
737			
738				var parent_col = $(this);
739				
740				// Add wrapper class if missing
741				if (!parent_col.find('.theiaStickySidebar').length) {
742					parent_col.find('.wpb_wrapper').first().addClass('theiaStickySidebar');
743				}
744				
745				parent_col.theiaStickySidebar({
746					minWidth: 940, 
747					updateSidebarHeight: false,
748					additionalMarginTop: add
749				});
750			});
751			
752			// for iframe loads in sidebar
753			$(window).on('load', function() {
754				setTimeout(function() {
755					$(window).trigger('resize.TSS');
756				}, 2500);
757			});
758		},
759		
760		/**
761		 * Single post functionality
762		 */
763		single: function()
764		{
765			if (!$('body').hasClass('single-post')) {
766				return;
767			}
768
769			/**
770			 * Social sharing
771			 */
772			// Single top social sharing view all buttons
773			$('.post-share-b .show-more').on('click', function() {
774				$(this).parent().addClass('all');
775				return false;
776			});
777
778			// Setup floating share
779			Bunyad_Share_Float.init();
780			
781			// Paralax for creative
782			var creative = $('.single-creative .featured');
783			if (creative.length) {
784
785				var img = creative.find('.wp-post-image'),
786				    src = img.prop('src');
787				
788				if (img.prop('currentSrc')) {
789					src = img.prop('currentSrc');
790				}
791				
792				if ($(window).width() < 940) {
793					creative.removeClass('parallax');
794					return;
795				}
796				
797				creative.addClass('parallax');
798				creative.find('.image-link').jarallax({	
799					imgSrc: src,
800					speed: 0.4,
801					noIos: false
802				});
803			}
804
805			$(window).on('resize', this.post_navigation);
806			this.post_navigation();
807			
808		},
809		
810		/**
811		 * Post Naviation
812		 */
813		post_navigation: function() 
814		{
815			var initialized = false,
816			    post_nav = $('.post-nav');
817			
818			if (!post_nav.length || $(window).width() < 1300) {
819				post_nav.removeClass('post-nav-float').addClass('post-nav-inline');
820				return;
821			}
822			
823			// Already setup or shouldn't be init?
824			if (initialized) {
825				return;
826			}
827			
828			initialized = true;
829			post_nav.addClass('post-nav-float');
830			post_nav = post_nav.find('.post');
831
832			if ($('.has-share-float').length) {
833				post_nav.addClass('ss-overlap');
834			}
835			
836			// Show when post-content is in viewport and hide when footer 
837			// becomes visible in view. 
838			var ele = $('.the-post .post-content'), 
839				scroll, offset, win_height, show_at, hide_at;
840				
841			var calc = function() {
842			    offset     = ele.offset();
843				win_height = $(window).height();
844
845			    show_at = offset.top + (win_height / 2) + 56;
846			    hide_at = $('.main-footer').offset().top + (win_height / 3);
847			};
848
849			calc();
850			self._wait_load(calc, {'ready': true});
851
852			// Lazyload fires this
853			$(window).on('resize.TSS', calc);
854			
855			// Show at certain scroll
856			$(window).on('scroll', function() {
857				
858				if ($(window).width() < 940) {
859					return;
860				}
861				
862				// Add viewport height to scrollTop
863				scroll = $(window).scrollTop() + win_height;
864				
865				requestAnimationFrame(function() {
866					if (scroll > show_at && scroll < hide_at) {
867						
868						if (!post_nav.hasClass('active')) {
869							post_nav.addClass('active');
870						}
871					}
872					else {
873						post_nav.removeClass('active');
874					}
875				});
876			});
877		},
878		
879		/**
880		 * Util to wait for until async CSS has been applied - waits for async font load
881		 * too by default.
882		 */
883		_wait_load: function(cb, options) {
884
885			options = $.extend({
886				'fonts': true,
887				'ready': false
888			}, options);
889
890			var sel = options.fonts ? '.wf-loading, .ld' : '.ld';
891
892			if ($('html').is(sel) || (options.ready && document.readyState !== 'complete')) {
893				setTimeout(
894					self._wait_load.bind(null, cb, options), 
895					30
896				);
897			}
898			else {
899				cb();
900			}
901		},
902		
903		/**
904		 * Setup sliders and carousels
905		 */
906		sliders: function()
907		{
908			/**
909			 * Parallax extend 
910			 */
911			if (window.jarallax) {
912				var Jarallax = window.jarallax.constructor;
913				var orig = Jarallax.prototype.onScroll;
914				Jarallax.prototype.onScroll = function(force) {
915					
916					if (!force) {
917						var ele = $(this.options.elementInViewport);
918						if (ele && ele.data('active-only') && !ele.is('.slick-active, .active')) {
919							return;
920						}
921					}
922					
923					orig.apply(this, arguments);
924				};
925			}
926			
927			// Enable parallax
928			var add_parallax = function(slider, parallax_one) {
929				
930				var do_parallax = function() {
931					
932					if ($(window).width() < 940) {
933						slider.removeClass('parallax');
934						return;
935					}
936				
937					slider.addClass('parallax');
938					
939					var slides = slider.find('.slick-slide');
940	
941					if (slider.parent().is('.grid-slider, .grid-b-slider')) {
942						slides = slider.find('.item-large, .item-small').find('.image-link');
943					}
944					
945					slides.each(function() {
946						
947						var img = $(this).find('img'),
948						    src = img.prop('src');
949						
950						if (img.prop('currentSrc')) {
951							src = img.prop('currentSrc');
952						}
953						
954						if (parallax_one) {
955							$(this).data('active-only', true);
956						}
957						
958						$(this).jarallax({	
959							imgSrc: src,
960							speed: 0.4,
961							elementInViewport: parallax_one ? $(this) : $(this).closest('.slick-slider'),
962							noIos: false
963						});
964					});
965				};
966				
967				$(window).on('resize', do_parallax);
968				do_parallax();
969			};
970			
971			/**
972			 * Slider setup object
973			 */
974			var setup = {};
975
976			/**
977			 * Main featured post slider
978			 */
979			setup.main_slider = function(slider) {
980				
981				slider.slick({
982					centerMode: true,
983					variableWidth: true,
984					slidesToShow: 1,
985	            	slidesToScroll: 1,
986					autoplay: slider.data('autoplay') ? true : false,
987					autoplaySpeed: slider.data('speed'),
988					arrows: true,
989					prevArrow: '<a href="#" class="prev-arrow"><i class="fa fa-angle-left"></i></a>',
990					nextArrow: '<a href="#" class="next-arrow"><i class="fa fa-angle-right"></i></a>',
991					touchThreshold: 50,
992					dots: false,
993					infinite: true,
994					responsive: [{
995						breakpoint: 940,
996						settings: {
997							slidesToShow: 1,
998							centerMode: false,
999							variableWidth: false
1000						}
1001					}]
1002				});
1003				
1004				// Arrow positions
1005				slider.on('setPosition', function() {
1006					
1007					// not for responsive
1008					if ($(window).width() < 940) {
1009						return;
1010					}
1011					
1012					var center = $(this).find('.slick-active.slick-center'),
1013						pos   = center.offset(),
1014						right = pos.left + center.width();
1015					
1016					$(this).find('.prev-arrow').css('left', pos.left + 'px');
1017					$(this).find('.next-arrow').css('left', right + 'px');
1018				});
1019				
1020				slider.find('[data-slick-index=0]').addClass('active');
1021				
1022				// Force our active class by first removing it from clones
1023				slider.on('beforeChange', function(e, slick, prev, current) {
1024					
1025					$(this).find('.active').removeClass('active');
1026					var ele = $(this);
1027					
1028					requestAnimationFrame(function() {
1029						ele.find('[data-slick-index=' + current + ']').addClass('active');
1030					}, 1);
1031				});
1032				
1033			};
1033 // main slider
1034
1035			/**
1036			 * Beauty Slider
1037			 */
1038			setup.beauty_slider = function(slider, vars) {
1039
1040				slider.slick($.extend(vars, {
1041					arrows: true,
1042					dots: true,
1043					infinite: true,
1044					cssEase: 'ease-in'
1045				}));
1046			};
1047
1048			/**
1049			 * Fashion Slider
1050			 */
1051			setup.fashion_slider = function(slider, vars) {
1052
1053				slider.on('init', function(e, slick) {
1054					self._wait_load(function() {
1055						$(slick.$slides[0]).addClass('active');
1056					});
1057				});
1058
1059				slider.slick($.extend(vars, {
1060					arrows: true,
1061					infinite: true,
1062					cssEase: 'cubic-bezier(0.4, 0.03, 0, 0.83)',
1063					speed: 700
1064				}));
1065
1066				slider.on('beforeChange', function(e, slick, prev, current) {
1067					var ele = $(this);
1068
1069					requestAnimationFrame(function() {
1070
1071						ele.find('.active').removeClass('active');
1072						ele.find('[data-slick-index=' + current + ']').addClass('active');
1073						
1074					});
1075					
1076				});
1077			};
1078			
1079			/**
1080			 * Trendy Slider
1081			 */
1082			setup.trendy_slider = function(slider, vars) {
1083				
1084				slider.slick($.extend(vars, {
1085					arrows: true,
1086					slidesToShow: 2,
1087					infinite: true,
1088					cssEase: 'ease',
1089					speed: 300,
1090					autoplay: slider.data('autoplay') ? true : false,
1091					autoplaySpeed: slider.data('speed'),
1092					responsive: [{
1093						breakpoint: 940,
1094						settings: {
1095							slidesToShow: 1
1096						}
1097					}]
1098				}));
1099			};
1100			
1101			/**
1102			 * Large Slider
1103			 */
1104			setup.large_slider = function(slider, vars) {
1105				slider.slick($.extend(vars, {
1106					arrows: true,
1107					infinite: true,
1108					cssEase: 'ease',
1109					speed: 350
1110				}));
1111			};
1112			
1113			/**
1114			 * Grid Slider
1115			 */
1116			setup.grid_slider = function(slider, vars) {
1117				slider.slick($.extend(vars, {
1118					arrows: true,
1119					infinite: true,
1120					cssEase: 'ease',
1121					speed: 300
1122				}));
1123			};
1124			
1125			/**
1126			 * Carousel Slider
1127			 */
1128			setup.carousel_slider = function(slider, vars) {
1129				
1130				slider.slick($.extend(vars, {
1131					arrows: true,
1132					slidesToShow: 3,
1133					slidesToScroll: 3,
1134					infinite: true,
1135					cssEase: 'ease-out',
1136					speed: 500,
1137					responsive: [
1138						{
1139							breakpoint: 940,
1140							settings: {slidesToShow: 2, slidesToScroll: 2}
1141						},
1142						{
1143							breakpoint: 600,
1144							settings: {slidesToShow: 1, slidesToScroll: 1}
1145						}
1146					]
1147				}));
1148			};
1149			
1150			// Bold slider
1151			setup.bold_slider = function(slider, vars) {
1152				
1153				slider.on('init', function(e, slick) {
1154					self._wait_load(function() {
1155						$(slick.$slides[0]).addClass('active');
1156					});
1157				});
1158				
1159				//var slick = instance.get(0).slick;
1160				slider.slick($.extend(vars, {
1161					arrows: true,
1162					infinite: true,
1163					cssEase: 'ease-in-out',
1164					speed: 500
1165				}));
1166
1167				var nav = slider.parent().find('.post-thumb');
1168				
1169				slider.on('beforeChange', function(e, slick, prev, current) {
1170					
1171					// Current nav thumb to activate
1172					nav.eq(current).click();
1173					
1174					var ele = $(this);
1175					ele.find('.active').removeClass('active');
1176					
1177					requestAnimationFrame(function() {
1178						ele.find('[data-slick-index=' + current + ']').addClass('active');
1179					});
1180					
1181				});
1182				
1183				// Sync slider with navigation
1184				nav.first().addClass('active');
1185				nav.on('click', function() {
1186					var index = $(this).index();
1187					
1188					$(this)
1189						.addClass('active')
1190						.siblings().removeClass('active');
1191					
1192					slider.slick('slickGoTo', index);
1193					
1194					return false;
1195				});
1196			};
1197			
1198			
1199			/* Initialize home sliders */
1200			$('.common-slider .slides').each(function() {
1201			
1202				var slider = $(this).one('init', function() {
1203					$(this).addClass('loaded');
1204				});
1205				
1206				// Common setting
1207				var vars = {
1208					prevArrow: '<a href="#" class="prev-arrow"><i class="fa fa-angle-left"></i></a>',
1209					nextArrow: '<a href="#" class="next-arrow"><i class="fa fa-angle-right"></i></a>',
1210					autoplay: slider.data('autoplay') ? true : false,
1211					autoplaySpeed: slider.data('speed'),
1212					fade: slider.data('animation') == 'fade' ? true : false
1213				};
1214				
1215				var parallax = slider.data('parallax') || 0,
1216					parallax_one,
1217					slider_type = slider.data('slider');
1218				
1219				switch (slider_type) {
1220					case 'trendy':
1221						setup.trendy_slider(slider, vars);
1222						break;
1223					
1224					case 'beauty':
1225						setup.beauty_slider(slider, vars);
1226						break;
1227						
1228					case 'large':
1229						setup.large_slider(slider, vars);
1230						parallax_one = 1;
1231						break;
1232						
1233					case 'grid':
1234						setup.grid_slider(slider, vars);
1235						break;
1236						
1237					case 'carousel':
1238						setup.carousel_slider(slider, vars);
1239						break;
1240						
1241					case 'bold':
1242						setup.bold_slider(slider, vars);
1243						parallax_one = 1;
1244						break;
1245						
1246					default:
1247
1248						var fn = setup[slider_type + '_slider'];
1249						if (typeof fn === 'function') {
1250							fn(slider, vars);
1251						}
1252						else {
1253							setup.main_slider(slider);
1254						}
1255
1256						break;
1257				}
1258				
1259				// Has Parallax effect?
1260				if (parallax) {
1261					
1262					// One active slide only to parallax
1263					if (parallax_one) {
1264						slider.on('beforeChange', function(e, slick, prev, current) {
1265							$(this).find('.active').removeClass('active');
1266							var slide = $(this).find('[data-slick-index=' + current + ']');
1267							
1268							slide.addClass('active');
1269							slide.jarallax('onScroll');
1270						});
1271					}
1272					
1273					add_parallax(slider, parallax_one);
1274				}
1275
1276			});
1277
1278			this.post_gallery_slider();
1279			$(document).on('ajax-pagination', this.post_gallery_slider);
1280
1281			/**
1282			 * Homepage carousel
1283			 */
1284			var carousel = $('.posts-carousel .posts, .posts-carousel-b .posts')
1285				.one('init', function() {
1286					$(this).addClass('loaded');
1287				});
1288			
1289			carousel.each(function() {
1290				
1291				$(this).slick({
1292					infinite: true,
1293					slidesToShow: $(this).data('slides') || 4,
1294					prevArrow: '<a class="prev-post"><i class="fa fa-angle-left"></i></a>',
1295					nextArrow: '<a class="next-post"><i class="fa fa-angle-right"></i></a>',
1296					appendArrows: $(this).parent().find('.navigate'),
1297					slidesToScroll: $(this).data('slides') || 4,
1298					
1299					responsive: [{
1300						breakpoint: 940,
1301						settings: {slidesToShow: 3, slidesToScroll: 3}
1302					},
1303					{
1304						breakpoint: 767,
1305						settings: {slidesToShow: 2, slidesToScroll: 2}
1306					},
1307					{
1308						breakpoint: 480,
1309						settings: {slidesToShow: 1, slidesToScroll: 1}
1310					}]
1311				});
1312			});
1313			
1314			// Carousel arrows
1315			$(window).on('load', function() {
1316				
1317				// Calculate arrow position based on image heights
1318				var carousel = $('.posts-carousel .posts'),
1319				    image = carousel.find('img').first();
1320
1321				if (image && image.height() > 0) {
1322					carousel.parent().find('.slick-arrow').css('top', image.height()/2 + 'px');
1323				}
1324			});
1325			
1326			/**
1327			 * Widget: Posts slider
1328			 */
1329			$('.widget-slider .slides').each(function() {
1330				$(this).slick({
1331					prevArrow: '<a href="#" class="prev-arrow"><i class="fa fa-angle-left"></i></a>',
1332					nextArrow: '<a href="#" class="next-arrow"><i class="fa fa-angle-right"></i></a>',
1333					autoplay: $(this).data('autoplay') ? true : false,
1334					autoplaySpeed: 6000,
1335					infinite: true
1336				});
1337			});
1338			
1339			// Disable anchor jump on arrows
1340			$('.common-slider, .widget-slider').on('click', '.slick-arrow', function(e) {
1341				e.preventDefault();
1342			});
1343			
1344
1345			// polyfill check for outdated browsers
1346			var fit_images = $('.large-slider img, .grid-slider img, .fashion-slider img, .widget-slider .wp-post-image, .bold-slider img');
1347			
1348			if (fit_images.length) {
1349				objectFitImages(fit_images);
1350			}
1351		},
1352
1353		/**
1354		 * Posts featured gallery slider
1355		 */
1356		post_gallery_slider: function(e) {
1357
1358			$('.gallery-slider:not(.slick-initialized)').each(function() {
1359
1360				var slider = $(this);
1361
1362				var init = function() {
1363					
1364					var vars = {
1365						infinite: true,
1366						slidesToShow: 1,
1367						prevArrow: '<a href="#" class="prev-arrow"><i class="fa fa-angle-left"></i></a>',
1368						nextArrow: '<a href="#" class="next-arrow"><i class="fa fa-angle-right"></i></a>',
1369						slidesToScroll: 1,
1370						adaptiveHeight: true
1371					};
1372					
1373					var parent = slider.closest('.single-creative .featured'),
1374						parallax;
1375					
1376					if (parent.length) {
1377						
1378						parent.addClass('has-gallery');
1379						slider.addClass('gallery-slider-lg');
1380						
1381						vars = $.extend(vars, {
1382							variableWidth: true,
1383							centerMode: true,
1384							adaptiveHeight: false,
1385							responsive: [{
1386								breakpoint: 940,
1387								settings: {centerMode: false, variableWidth: false}
1388							}]
1389						});
1390						
1391					}
1392					
1393					slider.slick(vars);
1394					!parallax || add_parallax(slider);
1395				};
1396
1397				if (e) {
1398					slider.imagesLoaded(init);
1399				}
1400				else {
1401					init();
1402				}
1403
1404			});
1405		},
1406		
1407		/**
1408		 * Setup Likes system
1409		 */
1410		likes: function()
1411		{
1412			if (typeof Sphere_Plugin == 'undefined') {
1413				return;
1414			}
1415			
1416			$('.likes-count').on('click', function() {
1417				
1418				var like = $(this);
1419				
1420				if (like.hasClass('voted')) {
1421					return false;
1422				}
1423				
1424				// Register the vote!
1425				$.post(Sphere_Plugin.ajaxurl, {action: 'sphere_likes', id: $(this).data('id')}, function(data) {
1426					
1427					if (data === Object(data)) {
1428						like.addClass('voted animate').find('.number').html(data.count);
1429					}
1430					
1431				}, 'json');
1432				
1433				return false;
1434				
1435			});
1436		},
1437		
1438		/**
1439		 * Setup Lightbox
1440		 */
1441		lightbox: function() 
1442		{
1443			// disabled on mobile screens
1444			if (!$.fn.magnificPopup || $(window).width() < 768) {
1445				return;
1446			}
1447
1448			// filter to handle valid images only
1449			var filter_images = function() {
1450				
1451				if (!$(this).attr('href')) {
1452					return false;
1453				}
1454				
1455				return $(this).attr('href').match(/\.(jpe?g|png|bmp|gif)($|\?.+?)/); 
1456			};	
1457			
1458			var mfp_init = {
1459				type: 'image',
1460				tLoading: '',
1461				mainClass: 'mfp-fade mfp-img-mobile',
1462				removalDelay: 300,
1463				callbacks: {
1464					afterClose: function() {
1465						if (this._lastFocusedEl) {
1466							$(this._lastFocusedEl).addClass('blur');
1467						}
1468					}
1469				}
1470			};
1471			
1472			/**
1473			 * Handle Galleries in post
1474			 */
1475			
1476			var gal_selectors = '.gallery-slider, .post-content .gallery, .post-content .blocks-gallery-item, .post-content .tiled-gallery';
1477			
1478			// filter to only tie valid images
1479			$(gal_selectors).find('a').has('img').filter(filter_images).addClass('lightbox-gallery-img');
1480			
1481			// Add WooCommerce support
1482			$('.woocommerce a[data-rel^="prettyPhoto"], a.zoom').addClass('lightbox-gallery-img');
1483			gal_selectors += ', .woocommerce .images';
1484			
1485			// attach the lightbox as gallery
1486			$(gal_selectors).magnificPopup($.extend({}, mfp_init, {
1487				delegate: '.lightbox-gallery-img',
1488				gallery: {enabled: true},
1489				image: {
1490					titleSrc: function(item) {
1491						var image = item.el.find('img'), 
1492						    caption = item.el.find('.caption').html();
1493						
1494						return (caption || image.attr('title') || ' ');
1495					}
1496				}
1497			}));
1498			
1499			// Non-gallery images in posts
1500			var selector = $('.post-content, .main .featured, .single-creative .featured')
1501				.find('a:not(.lightbox-gallery-img)').has('img');
1502			
1503			selector.add('.post-content, .main .featured, .lightbox-img')
1504				.filter(filter_images)
1505				.magnificPopup(mfp_init);
1506			
1507			
1508			// WooCommerce lightbox
1509			//$('a[data-rel^="prettyPhoto"], a.zoom').magnificPopup({hook: 'data-rel'});
1510		},
1511		
1512		/**
1513		 * Pinterest Pin It
1514		 */
1515		pin_it: function()
1516		{	
1517			var button = $('body .pinit-btn'),
1518				the_button = button.prop('outerHTML'),
1519			    index = 1;
1520			
1521			// Only proceed if non-touch device and button exists
1522			if (has_touch || !the_button) {
1523				return;
1524			}
1525			
1526			var show_on = button.data('show-on').split(',');
1527			
1528			var get_image = function(ele) {
1529				if (!ele.is('img')) {
1530					ele = ele.find('img').first();
1531				}
1532				
1533				return ele;
1534			};
1535			
1536			var setup = function() {
1537				
1538				var selectors = [];
1539				if (show_on.indexOf('single') !== -1) {
1540					selectors.push('.post-content img, .single-cover .featured, .single:not(.layout-creative) .featured .image-link');
1541				}
1542				
1543				if (show_on.indexOf('listing') !== -1) {
1544					selectors.push('.posts-container .post-header .image-link, .posts-container .post-thumb .image-link');
1545				}
1546				
1547				selectors = selectors.join(', ');
1548				
1549				$(selectors)
1550					.on('mouseenter', function() {
1551						
1552						var img = get_image($(this)),
1553						    wrap = img.parent();
1554						
1555						if (img.hasClass('nopin') || img.width() < 200 || img.height < 200) {
1556							return;
1557						}
1558						
1559						var pos = img.position(),
1560						    media  = img.prop('src'),
1561						    url, desc, button;
1562						
1563						// URL
1564						if ($('body').hasClass('single')) {
1565							url = window.location.href;
1566						}
1567						else {
1568							
1569							if (wrap.hasClass('image-link')) {
1570								url = wrap.prop('href');
1571							}
1572							else {
1573								url = img.closest('.post').find('.post-title-alt a, .post-title a').prop('href');
1574							}
1575
1576							// featured img has post title
1577							desc = img.prop('title');
1578						}
1579
1580						// desc = img.prop('alt') || img.prop('title');
1581						
1582						if (!url) {
1583							return;
1584						}
1585						
1586						// Create if not already done
1587						if (!img.data('pinit-id')) {
1588							button = $(the_button).appendTo(wrap);
1589
1590							if (!desc) {
1591								desc = button.data('heading');
1592							}
1593
1594							var url_format = button.prop('href')
1595								.replace('%media%', encodeURIComponent(media))
1596								.replace('%url%', encodeURIComponent(url))
1597								.replace('%desc%', encodeURIComponent(desc));
1598							
1599							button.prop('href', url_format);
1600							
1601							button.on('click', function(e) {
1602								e.preventDefault();
1603								e.stopPropagation();
1604								
1605								window.open($(this).prop('href'), '_blank');
1606							});
1607							
1608							index++;
1609							img.attr('data-pinit-id', index);
1610							button.attr('data-pinit-id', index);
1611						}
1612						else {
1613							// Existing button
1614							button = wrap.find('a[data-pinit-id=' + img.data('pinit-id') +']');
1615						}
1616						
1617						button.addClass('show').css({
1618							top: pos.top + parseInt(img.css('marginTop')) + parseInt(img.css('paddingTop')),
1619							left: pos.left + parseInt(img.css('marginLeft')) + parseInt(img.css('paddingLeft'))
1620						});
1621				})	
1622				.on('mouseleave', function(e) {
1623						 
1624						var ele = get_image($(this)).parent();
1625						
1626						if ($(e.relatedTarget).hasClass('pinit-btn')) {
1627							return;
1628						}
1629						
1630						ele.find('.pinit-btn').removeClass('show');
1631				});
1632			};
1633			
1634			setup();
1635			$(document).on('ajax-pagination', setup);
1636			
1637		},
1638		
1639		lazy_load: function()
1640		{
1641			var type = $('body').prop('className').match(/lazy-([^\s]+)/);
1642			if (!type || !window.lazySizes) {
1643				return;
1644			}			
1645			type = type[1];
1646			
1647			// Debounced resize trigger
1648			var timer;
1649			var loaded = function() {
1650				clearTimeout(timer);
1651				timer = setTimeout(function() {
1652					$(window).trigger('resize.TSS');
1653				}, 50);
1654			};
1655			
1656			$(document).on('lazyloaded', '.main', function(e) {
1657				loaded();
1658			});
1659			
1660			// Only for "smart" type and large desktops
1661			if (type != 'smart' || $(window).width() < 1380) {
1662				return;
1663			}
1664			
1665			//window.lazySizesConfig.preloadAfterLoad = true;
1666			
1667			// Deferred preload
1668			var is_loaded = false;
1669			var defer_load = function() {
1670
1671				if (is_loaded) {
1672					return;
1673				}
1674
1675				$('img.lazyload').each(function() {
1676					lazySizes.loader.unveil($(this).get(0));
1677				});
1678
1679				is_loaded = true;
1680			};
1681			
1682			// With delay or immediate on scroll (touch, mousemove other candidates)
1683			var events = 'scroll.ll';
1684			$(window).on(events, function() {
1685				defer_load();
1686				$(this).off(events);
1687			});
1688
1689			self._wait_load(defer_load, {ready: true});
1690		},
1691		
1692		/**
1693		 * Setup masonry on archives
1694		 */
1695		masonry: function(reload, posts, grid) 
1696		{
1697			
1698			if ($.fn.masonry && $('.posts-dynamic').hasClass('masonry')) {
1699				var grid = grid || $('.posts-dynamic.masonry .posts-wrap'); 
1700				
1701				if (!grid.length) {
1702					return;
1703				}
1704
1705				grid.on('layoutComplete', function() {
1706					requestAnimationFrame(function() {
1707						$(window).trigger('resize.TSS');
1708					});
1709				});
1710				
1711				// Reload masonry?
1712				if (reload && posts) {
1713		
1714					var posts = grid.find(posts).css({ opacity: 0 });
1715					
1716					grid.each(function() {
1717
1718						$(this).imagesLoaded(function() {
1719							posts.css({ opacity: 1 });
1720							grid.masonry('appended', posts, true);
1721						});
1722					});
1723				}
1724				else {
1725					grid.each(function() {
1726						$(this).imagesLoaded(function() {
1727							grid.masonry();
1728						});
1729					});	
1730				}
1731			}
1732		}
1733		
1734	}; // end module
1735	
1736	// Utils
1737	function writeRaf(fn, options) {
1738		var running, 
1739		    args, 
1740		    that;
1741
1742		var run = function() {
1743			running = false;
1744			fn.apply(that, args);
1745		};
1746
1747		if (!options) {
1748			options = {};
1749		}
1750
1751		return function() {
1752			args = arguments;
1753			that = options.that || this;
1754
1755			if (!running) {
1756				running = true;
1757				requestAnimationFrame(run);
1758			}
1759		};
1760	}
1761	
1762	return self;
1763	
1764})(jQuery);
1765
1766/**
1767 * Social Sharing float behavior
1768 */
1769var Bunyad_Share_Float = (function($) {
1770	"use strict";
1771
1772	/**
1773	 * Check if element intersects
1774	 */
1775	var intersects = function(el1, el2) {
1776		var rect1 = el1.getBoundingClientRect();
1777		var rect2 = el2.getBoundingClientRect();
1778	
1779		return !(
1780			rect1.top    > rect2.bottom ||
1781			rect1.right  < rect2.left ||
1782			rect1.bottom < rect2.top ||
1783			rect1.left   > rect2.right
1784		);
1785	}
1786
1787	var start_at = 0;
1788
1789	return {
1790		init: function() {
1791
1792			if (!$('.post-share-float').length) {
1793				return;
1794			}
1795
1796			$(window).on('resize load resize.TSS', function() {
1797				this.init_calc();
1798				this.sticky();
1799				this.visibility();
1800			}.bind(this));
1801		},
1802
1803		/**
1804		 * Pre-calc for performance
1805		 */
1806		init_calc: function() {
1807
1808			if (!$('body').hasClass('no-sidebar') && !$('.the-post-modern').length) {
1809				var featured = $('.the-post-header .featured, .single-creative .featured, .single-cover .featured, .single-magazine .featured');
1810				start_at = featured.length ? featured.position().top : $('.the-post-header').position().top;
1811			}
1812		},
1813		
1814		/**
1815		 * Setup sticky float
1816		 */
1817		sticky: function() {
1818			// Floating social sharing
1819			var add = 20;
1820			add += $('.admin-bar').length ? 32 : 0;
1821			add += Bunyad_Theme.has_sticky_nav ? 50 : 0;
1822			var width = $(window).width();
1823			
1824			$('.post-share-float').each(function() {
1825
1826				var post_foot = $('.the-post-foot').outerHeight(true) + 50;
1827				$(this).css('height', $('.the-post .post-content').height() + (width > 1500 ? post_foot : 0) + 'px');
1828				
1829				$(this).theiaStickySidebar({
1830					minWidth: 768, 
1831					updateSidebarHeight: false,
1832					defaultPosition: 'absolute',
1833					additionalMarginTop: add
1834				});
1835			});
1836		},
1837
1838		/**
1839		 * Determine when to show and hide
1840		 */
1841		visibility: function() {
1842
1843			if ($(window).width() < 768) {
1844				return false;
1845			}
1846
1847			var intersect_sels = [
1848				'.the-post-modern .alignfull',
1849				'.the-post-modern .alignwide', 
1850				'.the-post-modern .gallery:not(.aligncenter)',
1851				'.the-post-modern .wp-block-gallery:not(.aligncenter)',
1852				'.the-post-modern figure.alignnone', 
1853				'.the-post-modern img.alignnone',
1854			];
1855
1856			var observe = [],
1857			    share_ele = $('.post-share-float');
1858
1859			$(intersect_sels.join(',')).each(function() { 
1860				observe.push(this);
1861			});
1862		
1863			$(window).on('scroll', function() {
1864				var is_hidden = false,
1865					ele = share_ele.find('.theiaStickySidebar').get(0);
1866
1867				if ($(window).scrollTop() < start_at) {
1868					is_hidden = true;
1869				}
1870				else {
1871
1872					// Check if any of the observed elements intersect
1873					for (var i in observe) {
1874						if (intersects(ele, observe[i])) {
1875							is_hidden = true;
1876							break;
1877						}
1878					}
1879				}
1880		
1881				(is_hidden
1882						? share_ele.addClass('is-hidden') 
1883						: share_ele.removeClass('is-hidden')
1884				);
1885			});
1886		}
1887	}
1888})(jQuery);
1889
1890
1891/**
1892 * Pagination handlers
1893 */
1894var Bunyad_Pagination = (function($) {
1895	"use strict";
1896
1897	// Blocks load more
1898	var processing = false,
1899	    cache = [];
1900	
1901	var self = {
1902			
1903		init: function() {
1904			// AJAX pagination handlers
1905			$('.main').on('click', '.main-pagination .load-button, .block .main-pagination.number a', this.ajax_pagination);
1906		},
1907		
1908		/**
1909		 * Initiate handling of AJAX pagination
1910		 */
1911		ajax_pagination: function(e) 
1912		{
1913			if (processing) {
1914				return false;
1915			}
1916			
1917			// Type of pagination
1918			var type = 'more';
1919			if ($(this).closest('.main-pagination').hasClass('number')) {
1920				type = 'number';
1921			}
1922			
1923			var ele = $(this),
1924		    	block = ele.closest('.block'),
1925		    	post_id = ele.closest('.page-content, .post-content').data('id'),
1926		    	page = ele.data('page') + 1,
1927		    	is_block = true;
1928		
1929			// Not a block, archives
1930			if (!block.length) {
1931				is_block = false;
1932				block = ele.closest('.main-content');
1933			}
1934			
1935			// AJAX params
1936			var params =  {
1937				'_bunyad_act': 'block',
1938				'page_id': post_id,
1939				'paged': page, 
1940				'block_id': block.data('id')
1941			};
1942
1943			switch(type) {
1944			
1945				// Type: Load More
1946				case 'more':
1947					ele.addClass('loading').find('.fa').addClass('fa-spin');
1948					
1949					// Processing method for load more
1950					var process = self.process_load_more;
1951					
1952					break;
1953				
1954				// Type: Numbered
1955				case 'number':
1956					block.find('.block-content').addClass('loading');
1957					
1958					// Change page number
1959					var permalink = ele.attr('href').match(/\/page\/(\d+)\//);
1960					if (permalink !== null) {
1961						params.paged = permalink[1];
1962					}
1963					else {
1964						// Plain links
1965						var src = ele.attr('href').match(/(\?|&)paged?=(\d+)/);
1966						params.paged = src ? src[2] : 1;
1967					}
1968					
1969					// Set height
1970					block.css('height', block.height());
1971					
1972					var process = function(data) {
1973						cache[params.paged] = data;
1974						var content = $(data),
1975						    block_content = block.find('.block-content');
1976						
1977						block_content.removeClass('fade-in-down-lg')
1978							.html($(data).find('.block-content').html());
1979						
1980						block.css('height', 'auto');
1981						block_content.addClass('fade-in-down-lg').removeClass('loading');
1982						
1983						// position correctly
1984						$('html, body').animate({scrollTop: block.offset().top - 50}, 200);
1985						
1986						$(document).trigger('ajax-pagination');
1987					};
1988					
1989					// In cache?
1990					if (cache[params.paged]) {
1991						processing = false;
1992						process(cache[params.paged]);
1993						
1994						return false;
1995					}
1996
1997					break;
1998			}
1999
2000			// Process block
2001			if (is_block) {
2002				
2003				// Home blocks AJAX
2004				var ajax_url = Bunyad.custom_ajax_url;
2005				ajax_url += (ajax_url.indexOf('?') !== -1 ? '&' : '?');
2006				
2007				processing = $.get(ajax_url + $.param(params), function(data) {
2008						process(data, block, ele);
2009					})
2010					.always(function() {
2011						// All done
2012						processing = false;
2013					});	
2014			}
2015			else {
2016				
2017				// Archives AJAX
2018				var ajax_url = $(this).attr('href');
2019				processing = $.get(ajax_url, function(data) {
2020					data = $(data).find('.main-content').get(0);
2021					process(data, block, ele);
2022				})
2023				.always(function() {
2024					// All done
2025					processing = false;
2026				});
2027			}
2028
2029			return false;
2030		},
2031		
2032		/**
2033		 * Load More Ajax callback method
2034		 */
2035		process_load_more: function(data, block, ele) 
2036		{
2037			var content = $(data),
2038				wrap = block.find('.posts-container'),
2039				posts;
2040			
2041			if (content.find('.posts-container').hasClass('mixed')) {
2042				posts = content.find('.posts-dynamic').children().addClass('fade-in-up-lg');
2043				wrap.append(posts);
2044			}
2045			else {
2046				// Directly below or in a .posts-wrap wrapper?
2047				// WARNING: Always have .posts-wrap to prevent unexpected bugs
2048				var container = block.find('.posts-wrap').length ? '.posts-wrap' : '.posts-container';
2049				
2050		        posts = content.find(container).children().addClass('fade-in-up-lg');
2051		        block.find(container).append(posts);
2052			}
2053			
2054			// Masonry reload
2055			if (wrap.hasClass('masonry')) {
2056				//posts.removeClass('fade-in-up-lg');
2057				Bunyad_Theme.masonry(true, posts, wrap.find('.posts-wrap'));
2058			}
2059			
2060			$(document).trigger('ajax-pagination');
2061
2062			block.find('.main-pagination')
2063				.replaceWith(content.find('.main-pagination'));
2064			
2065			ele.removeClass('loading')
2066				.find('.fa').removeClass('fa-spin');
2067		}
2068	};
2069	
2070	return self;
2071	
2072})(jQuery);
2073
2074// load when ready
2075jQuery(function($) {
2076	"use strict";
2077	
2078	// Init
2079	var init = function() {
2080		Bunyad_Theme.init();
2081		Bunyad_Pagination.init();
2082	};
2083
2084	var rp_support = function() {
2085		try {
2086			return document.createElement("link").relList.supports("preload");
2087		} catch (e) {
2088			return false;
2089		}
2090	};
2091	
2092	if (!window.ld_skip && !rp_support() && window.loadCSS) {
2093		
2094		var link = $('link[as=style]');
2095		if (link.length) {
2096			link = link[0];
2097			
2098			var css_load = function(target) {
2099				if (target.prop('media') == 'all') {
2100					init();
2101					
2102					setTimeout(function() {
2103						$('html').removeClass('ld');
2104					}, 50);
2105					
2106					return;
2107				}
2108
2109				setTimeout(css_load.bind(null, target), 20);
2110			};
2111			
2112			// find inserted - finds one
2113			var target = $('link[href="' + link.href + '"][as!=style]');
2114			if (target.length) {
2115				css_load(target);
2116			}
2117		}
2118	}
2119	else {
2120		init();
2121	}
2122
2123});
2124
2125
2126/**
2127 * Required plugins and 3rd Party Libraries
2128 */
2129
2130/**
2131 *  FitVids 1.1 - https://github.com/davatron5000/FitVids.js
2132 */
2133(function($){$.fn.fitVids=function(options){var settings={customSelector:null,ignore:null};if(!document.getElementById("fit-vids-style")){var head=document.head||document.getElementsByTagName("head")[0];var css=".fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}";var div=document.createElement("div");div.innerHTML='<p>x</p><style id="fit-vids-style">'+css+"</style>";head.appendChild(div.childNodes[1])}if(options)$.extend(settings,options);return this.each(function(){var selectors=["iframe[src*='player.vimeo.com']","iframe[src*='youtube.com']","iframe[src*='youtube-nocookie.com']","iframe[src*='kickstarter.com'][src*='video.html']","object","embed"];if(settings.customSelector)selectors.push(settings.customSelector);var ignoreList=".fitvidsignore";if(settings.ignore)ignoreList=ignoreList+", "+settings.ignore;var $allVideos=$(this).find(selectors.join(","));$allVideos=$allVideos.not("object object");$allVideos=$allVideos.not(ignoreList);$allVideos.each(function(){var $this=$(this);if($this.parents(ignoreList).length>0)return;if(this.tagName.toLowerCase()==="embed"&&$this.parent("object").length||$this.parent(".fluid-width-video-wrapper").length)return;if(!$this.css("height")&&!$this.css("width")&&(isNaN($this.attr("height"))||isNaN($this.attr("width")))){$this.attr("height",9);$this.attr("width",16)}var height=this.tagName.toLowerCase()==="object"||$this.attr("height")&&!isNaN(parseInt($this.attr("height"),10))?parseInt($this.attr("height"),10):$this.height(),width=!isNaN(parseInt($this.attr("width"),10))?parseInt($this.attr("width"),10):$this.width(),aspectRatio=height/width;if(!$this.attr("id")){var videoID="fitvid"+Math.floor(Math.random()*999999);$this.attr("id",videoID)}$this.wrap('<div class="fluid-width-video-wrapper"></div>').parent(".fluid-width-video-wrapper").css("padding-top",aspectRatio*100+"%");$this.removeAttr("height").removeAttr("width")})})}})(window.jQuery||window.Zepto);
2134
2135/**
2136 * Plus/minus polyfill for numbers - used in WooCommerce
2137 * 
2138 * Author Bryce Adams
2139 */
2140jQuery( function( $ ) {
2141
2142	// Quantity buttons
2143	$( 'div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)' )
2144		.addClass( 'buttons_added' )
2145		.append( '<div class="vertical-buttons"><input type="button" value="+" class="plus" /><input type="button" value="-" class="minus" /></div>' );
2146
2147	$( document ).on( 'click', '.plus, .minus', function() {
2148
2149		// Get values
2150		var $qty		= $( this ).closest( '.quantity' ).find( '.qty' ),
2151			currentVal	= parseFloat( $qty.val() ),
2152			max			= parseFloat( $qty.attr( 'max' ) ),
2153			min			= parseFloat( $qty.attr( 'min' ) ),
2154			step		= $qty.attr( 'step' );
2155
2156		// Format values
2157		if ( ! currentVal || currentVal === '' || currentVal === 'NaN' ) currentVal = 0;
2158		if ( max === '' || max === 'NaN' ) max = '';
2159		if ( min === '' || min === 'NaN' ) min = 0;
2160		if ( step === 'any' || step === '' || step === undefined || parseFloat( step ) 
2160=== 'NaN' ) step = 1;
2161
2162		// Change the value
2163		if ( $( this ).is( '.plus' ) ) {
2164
2165			if ( max && ( max == currentVal || currentVal > max ) ) {
2166				$qty.val( max );
2167			} else {
2168				$qty.val( currentVal + parseFloat( step ) );
2169			}
2170
2171		} else {
2172
2173			if ( min && ( min == currentVal || currentVal < min ) ) {
2174				$qty.val( min );
2175			} else if ( currentVal > 0 ) {
2176				$qty.val( currentVal - parseFloat( step ) );
2177			}
2178
2179		}
2180
2181		// Trigger change event
2182		$qty.trigger( 'change' );
2183
2184	});
2185
2186});
2187
2188/*! npm.im/object-fit-images */
2189var objectFitImages=function(){"use strict";function t(t){for(var e,r=getComputedStyle(t).fontFamily,i={};null!==(e=n.exec(r));)i[e[1]]=e[2];return i}function e(e,i){if(!e[c].parsingSrcset){var s=t(e);if(s["object-fit"]=s["object-fit"]||"fill",!e[c].s){if("fill"===s["object-fit"])return;if(!e[c].skipTest&&l&&!s["object-position"])return}var n=e[c].ios7src||e.currentSrc||e.src;if(i)n=i;else if(e.srcset&&!a&&window.picturefill){var o=window.picturefill._.ns;e[c].parsingSrcset=!0,e[o]&&e[o].evaled||window.picturefill._.fillImg(e,{reselect:!0}),e[o].curSrc||(e[o].supported=!1,window.picturefill._.fillImg(e,{reselect:!0})),delete e[c].parsingSrcset,n=e[o].curSrc||n}if(e[c].s)e[c].s=n,i&&(e[c].srcAttr=i);else{e[c]={s:n,srcAttr:i||f.call(e,"src"),srcsetAttr:e.srcset},e.src=c;try{e.srcset&&(e.srcset="",Object.defineProperty(e,"srcset",{value:e[c].srcsetAttr})),r(e)}catch(t){e[c].ios7src=n}}e.style.backgroundImage='url("'+n+'")',e.style.backgroundPosition=s["object-position"]||"center",e.style.backgroundRepeat="no-repeat",/scale-down/.test(s["object-fit"])?(e[c].i||(e[c].i=new Image,e[c].i.src=n),function t(){return e[c].i.naturalWidth?void(e[c].i.naturalWidth>e.width||e[c].i.naturalHeight>e.height?e.style.backgroundSize="contain":e.style.backgroundSize="auto"):void setTimeout(t,100)}()):e.style.backgroundSize=s["object-fit"].replace("none","auto").replace("fill","100% 100%")}}function r(t){var r={get:function(){return t[c].s},set:function(r){return delete t[c].i,e(t,r),r}};Object.defineProperty(t,"src",r),Object.defineProperty(t,"currentSrc",{get:r.get})}function i(){u||(HTMLImageElement.prototype.getAttribute=function(t){return!this[c]||"src"!==t&&"srcset"!==t?f.call(this,t):this[c][t+"Attr"]},HTMLImageElement.prototype.setAttribute=function(t,e){!this[c]||"src"!==t&&"srcset"!==t?g.call(this,t,e):this["src"===t?"src":t+"Attr"]=String(e)})}function s(t,r){var i=!A&&!t;if(r=r||{},t=t||"img",u&&!r.skipTest)return!1;"string"==typeof t?t=document.querySelectorAll("img"):t.length||(t=[t]);for(var n=0;n<t.length;n++)t[n][c]=t[n][c]||r,e(t[n]);i&&(document.body.addEventListener("load",function(t){"IMG"===t.target.tagName&&s(t.target,{skipTest:r.skipTest})},!0),A=!0,t="img"),r.watchMQ&&window.addEventListener("resize",s.bind(null,t,{skipTest:r.skipTest}))}var c="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",n=/(object-fit|object-position)\s*:\s*([-\w\s%]+)/g,o=new Image,l="object-fit"in o.style,u="object-position"in o.style,a="string"==typeof o.currentSrc,f=o.getAttribute,g=o.setAttribute,A=!1;return s.supportsObjectFit=l,s.supportsObjectPosition=u,i(),s}();
2190
2191/*!
2192 * imagesLoaded PACKAGED v4.1.0
2193 * JavaScript is all like "You images are done yet or what?"
2194 * MIT License
2195 */
2196!function(t,e){"function"==typeof define&&define.amd?define("ev-emitter/ev-emitter",e):"object"==typeof module&&module.exports?module.exports=e():t.EvEmitter=e()}(this,function(){function t(){}var e=t.prototype;return e.on=function(t,e){if(t&&e){var i=this._events=this._events||{},n=i[t]=i[t]||[];return-1==n.indexOf(e)&&n.push(e),this}},e.once=function(t,e){if(t&&e){this.on(t,e);var i=this._onceEvents=this._onceEvents||{},n=i[t]=i[t]||[];return n[e]=!0,this}},e.off=function(t,e){var i=this._events&&this._events[t];if(i&&i.length){var n=i.indexOf(e);return-1!=n&&i.splice(n,1),this}},e.emitEvent=function(t,e){var i=this._events&&this._events[t];if(i&&i.length){var n=0,o=i[n];e=e||[];for(var r=this._onceEvents&&this._onceEvents[t];o;){var s=r&&r[o];s&&(this.off(t,o),delete r[o]),o.apply(this,e),n+=s?0:1,o=i[n]}return this}},t}),function(t,e){"use strict";"function"==typeof define&&define.amd?define(["ev-emitter/ev-emitter"],function(i){return e(t,i)}):"object"==typeof module&&module.exports?module.exports=e(t,require("ev-emitter")):t.imagesLoaded=e(t,t.EvEmitter)}(window,function(t,e){function i(t,e){for(var i in e)t[i]=e[i];return t}function n(t){var e=[];
vendor: 4,118 bytes, line 2196
2196if(Array.isArray(t))e=t;else if("number"==typeof t.length)for(var i=0;i<t.length;i++)e.push(t[i]);else e.push(t);return e}function o(t,e,r){return this instanceof o?("string"==typeof t&&(t=document.querySelectorAll(t)),this.elements=n(t),this.options=i({},this.options),"function"==typeof e?r=e:i(this.options,e),r&&this.on("always",r),this.getImages(),h&&(this.jqDeferred=new h.Deferred),void setTimeout(function(){this.check()}.bind(this))):new o(t,e,r)}function r(t){this.img=t}function s(t,e){this.url=t,this.element=e,this.img=new Image}var h=t.jQuery,a=t.console;o.prototype=Object.create(e.prototype),o.prototype.options={},o.prototype.getImages=function(){this.images=[],this.elements.forEach(this.addElementImages,this)},o.prototype.addElementImages=function(t){"IMG"==t.nodeName&&this.addImage(t),this.options.background===!0&&this.addElementBackgroundImages(t);var e=t.nodeType;if(e&&d[e]){for(var i=t.querySelectorAll("img"),n=0;n<i.length;n++){var o=i[n];this.addImage(o)}if("string"==typeof this.options.background){var r=t.querySelectorAll(this.options.background);for(n=0;n<r.length;n++){var s=r[n];this.addElementBackgroundImages(s)}}}};var d={1:!0,9:!0,11:!0};return o.prototype.addElementBackgroundImages=function(t){var e=getComputedStyle(t);if(e)for(var i=/url\((['"])?(.*?)\1\)/gi,n=i.exec(e.backgroundImage);null!==n;){var o=n&&n[2];o&&this.addBackground(o,t),n=i.exec(e.backgroundImage)}},o.prototype.addImage=function(t){var e=new r(t);this.images.push(e)},o.prototype.addBackground=function(t,e){var i=new s(t,e);this.images.push(i)},o.prototype.check=function(){function t(t,i,n){setTimeout(function(){e.progress(t,i,n)})}var e=this;return this.progressedCount=0,this.hasAnyBroken=!1,this.images.length?void this.images.forEach(function(e){e.once("progress",t),e.check()}):void this.complete()},o.prototype.progress=function(t,e,i){this.progressedCount++,this.hasAnyBroken=this.hasAnyBroken||!t.isLoaded,this.emitEvent("progress",[this,t,e]),this.jqDeferred&&this.jqDeferred.notify&&this.jqDeferred.notify(this,t),this.progressedCount==this.images.length&&this.complete(),this.options.debug&&a&&a.log("progress: "+i,t,e)},o.prototype.complete=function(){var t=this.hasAnyBroken?"fail":"done";if(this.isComplete=!0,this.emitEvent(t,[this]),this.emitEvent("always",[this]),this.jqDeferred){var e=this.hasAnyBroken?"reject":"resolve";this.jqDeferred[e](this)}},r.prototype=Object.create(e.prototype),r.prototype.check=function(){var t=this.getIsImageComplete();return t?void this.confirm(0!==this.img.naturalWidth,"naturalWidth"):(this.proxyImage=new Image,this.proxyImage.addEventListener("load",this),this.proxyImage.addEventListener("error",this),this.img.addEventListener("load",this),this.img.addEventListener("error",this),void(this.proxyImage.src=this.img.src))},r.prototype.getIsImageComplete=function(){return this.img.complete&&void 0!==this.img.naturalWidth},r.prototype.confirm=function(t,e){this.isLoaded=t,this.emitEvent("progress",[this,this.img,e])},r.prototype.handleEvent=function(t){var e="on"+t.type;this[e]&&this[e](t)},r.prototype.onload=function(){this.confirm(!0,"onload"),this.unbindEvents()},r.prototype.onerror=function(){this.confirm(!1,"onerror"),this.unbindEvents()},r.prototype.unbindEvents=function(){this.proxyImage.removeEventListener("load",this),this.proxyImage.removeEventListener("error",this),this.img.removeEventListener("load",this),this.img.removeEventListener("error",this)},s.prototype=Object.create(r.prototype),s.prototype.check=function(){this.img.addEventListener("load",this),this.img.addEventListener("error",this),this.img.src=this.url;var t=this.getIsImageComplete();t&&(this.confirm(0!==this.img.naturalWidth,"naturalWidth"),this.unbindEvents())},s.prototype.unbindEvents=function(){this.img.removeEventListener("load",this),this.img.removeEventListener("error",this)},s.prototype.confirm=function(t,e){this.isLoaded=t,this.emitEvent("progress",[this,this.element,e])},o.makeJQueryPlugin=function(e){e=e||t.jQuery,e&&(h=e,h.fn.imagesLoaded=function(t,e){var i=new o(this,t,e);return i.jqDeferred.promise(h(this))})},o.makeJQueryPlugin(),o});

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.