PageSourceSearch

https://odgsicilia.it/assets/js/plugins.js

js odgsicilia.it collected 2026-10-02 13:33:02 UTC 21,737 bytes, 876 lines download raw bytes

1;(function($){
2
3	'use strict';
4
5	$.mad_core = $.mad_core || {};
6
7	$.mad_core = {
8
9		setUp: function (options) {
10			var base = this;
11
12			var animEndEventNames = {
13				'WebkitAnimation' : 'webkitAnimationEnd',
14				'OAnimation' : 'oAnimationEnd',
15				'msAnimation' : 'MSAnimationEnd',
16				'animation' : 'animationend'
17			},
18			transEndEventNames = {
19				'WebkitTransition': 'webkitTransitionEnd',
20				'MozTransition': 'transitionend',
21				'OTransition': 'oTransitionEnd',
22				'msTransition': 'MSTransitionEnd',
23				'transition': 'transitionend'
24			}
25
26			base.$window = $(window);
27			base.ANIMATIONEND = animEndEventNames[ Modernizr.prefixed('animation') ];
28			base.TRANSITIONEND = transEndEventNames[ Modernizr.prefixed('transition') ];
29			base.SUPPORT = {
30				animations : Modernizr.csstransitions && Modernizr.cssanimations,
31				ANIMATIONSUPPORTED: Modernizr.cssanimations,
32				TRANSITIONSUPPORTED: Modernizr.csstransitions,
33				ISRTL: getComputedStyle(document.body).direction === 'rtl',
34				ISTOUCH: Modernizr.touch
35			};
36			base.XHRLEVEL2 = !!window.FormData;
37			base.event = base.SUPPORT.ISTOUCH ? 'touchstart' : 'click';
38
39			// Refresh elements
40			base.refresh();
41		},
42
43		DOMLoaded: function(options) {
44
45			var base = this;
46
47			// set up
48			base.setUp(options);
49
50			// counters
51			if($('.counter').length) base.counters();
52			
53			// responsive menu
54			if($('#header').length) base.navInit.init(this);
55
56			// search
57			if($('.search-holder').length) base.searchHolder();
58
59			// background load
60			if($('[data-bg]').length) base.bg();
61
62			// sync carousel
63			if($('.owl-carousel[data-sync]').length) base.syncOwlCarousel.init();
64
65			// hidden elements init
66			if($('.hidden-section').length) base.hiddenSections();
67
68			// dropdown elements init
69			if($('.dropdown-invoker').length) base.dropdown();
70
71			// close btn init
72			if($('.item-close').length) base.closeBtn();
73			if($('.shopping-cart-full').length) base.removeProduct();
74
75		},
76
77		elements: {
78			'.main-navigation, .topbar:not(.no-mobile-advanced)': 'navMain',
79			'#mobile-advanced': 'navMobile',
80			'#wrapper': 'wrapper',
81			'#header' : 'header'
82		},
83
84		/*
85		Plugin Name: 	Refresh
86		*/
87		$: function (selector) {
88			return $(selector);
89		},
90
91		refresh: function() {
92			for (var key in this.elements) {
93				this[this.elements[key]] = this.$(key);
94			}
95		},
96
97		/**
98		 * Initializes dropdown module
99		 * @return Object Core;
100		 **/
101		dropdown: function(){
102
103			var dropdown = {
104
105				init: function(){
106
107					this.bindEvents();
108
109				},
110
111				bindEvents: function(){
112
113					var self = this;
114
115					$('body').on('click', '.dropdown-invoker', function(e){
116
117						e.preventDefault();
118						e.stopPropagation();
119
120						var invoker = $(this),
121							dropdown = invoker.next('.dropdown-window');
122
123						self.smartPosition(dropdown);
124						
125						invoker.add(dropdown).toggleClass('opened');
126						dropdown.parent().toggleClass('dropdown-over');
127
128					});
129
130					$(document).on('click', function(e){
131
132						var dropdown = $('.dropdown-window');
133
134						if(!$(e.target).closest(dropdown).length){
135
136							dropdown.add(dropdown.prev('.dropdown-invoker')).removeClass('opened');
137							dropdown.parent().removeClass('dropdown-over');
138
139						}
140
141					});
142
143				},
144
145				smartPosition: function(dropdown){
146
147					var dWidth = dropdown.outerWidth(),
148						dOfsset = dropdown.offset().left,
149						$wW = $(window).width();
150
151					if(dOfsset + dWidth > $wW) dropdown.addClass('reverse');
152
153				}
154
155			}
156
157			dropdown.init();
158
159			return this;
160
161		},
162
163		/**
164		 * Initialize global close event
165		 * @return Object Core;
166		 **/
167		closeBtn: function(){
168
169			$('body').on('click.globalclose', '.item-close:not(.shopping-cart-full .item-close)', function(e){
170
171				e.preventDefault();
172
173				$(this).parent().stop().animate({
174					opacity: 0
175				}, function(){
176
177					$(this).stop().slideUp(function(){
178
179						$(this).remove();
180
181					});
182
183				});
184
185			});
186
187			return this;
188
189		},
190
191		/**
192		Remove item
193		**/
194		removeProduct: function(collection){
195
196			var c = $('.shopping-cart-full');
197
198			c.on('click.removeProduct', '.item-close', function(e){
199
200				e.preventDefault();
201
202				$(this).closest('tr').stop().fadeOut(function(){
203					$(this).remove();
204				});
205
206			});
207
208		},
209
210		/*
211		Plugin Name: 	SearchHolder
212		*/
213		searchHolder : function () {
214
215		    $.searchClick = function (el, options) {
216				this.el = $(el);
217				this.init(options);
218			}
219
220			$.searchClick.DEFAULTS = {
221				key_esc: 27
222			}
223
224			$.searchClick.prototype = {
225				init: function (options) {
226					var base = this;
227					base.o = $.extend({}, $.searchClick.DEFAULTS, options);
228					base.key_esc = base.o.key_esc;
229					base.searchWrap = $('.searchform-wrap');
230					base.searchBtn = $('.search-button', base.el);
231					base.searchClose = $('.close-search-form', base.el);
232					base.searchField = $('#s', base.el);
233					base.event = Modernizr.touch ? 'touchstart' : 'click';
234
235					base.set();
236					base.bind();
237				},
238				set: function () {
239					var transEndEventNames = {
240						'WebkitTransition': 'webkitTransitionEnd',
241						'MozTransition': 'transitionend',
242						'OTransition': 'oTransitionEnd',
243						'msTransition': 'MSTransitionEnd',
244						'transition': 'transitionend'
245					};
246					this.transEndEventName = transEndEventNames[Modernizr.prefixed( 'transition' )];
247					this.animations = Modernizr.csstransitions;
248				},
249				hide: function () {
250				    var base = this;
251				    base.searchWrap.addClass('closed').removeClass('opened');
252				    var onEndTransitionFn = function () {
253				      base.searchWrap.removeClass('closed');
254				    };
255				    if (base.animations) {
256				      base.searchWrap.on(base.transEndEventName, onEndTransitionFn);
257				    } else {
258				      onEndAnimationFn();
259				    }
260
261				    var $body = $(document.body),
262				    $popup = $(".searchform-wrap");
263
264				},
265				bind: function () {
266					this.searchBtn.on(this.event, $.proxy(this.display_show, this));
267					this.searchClose.on(this.event, $.proxy(function (e) {
268						this.display_hide(e, this.key_esc);
269					}, this));
270					this.keyDownHandler(this.key_esc);
271
272					$(window).on("load",function(){
273
274				        var $win = $('.wrapper-container'); // or $box parent container
275						var $box = $(".search-form");
276						var $sb = $(".search-button");
277						
278					 	$win.on("click.Bst", function(event){		
279							if ( 
280				            $box.has(event.target).length == 0 //checks if descendants of $box was clicked
281				            &&
282				            !$box.is(event.target) //checks if the $box itself was clicked
283				            &&
284				            !$sb.is(event.target) //checks if the $box itself was clicked
285					        ){
286								$('.searchform-wrap').removeClass('opened');;
287							}
288						});
289
290						$('.close-search-form').on( "click", function() {
291						  $('.searchform-wrap').removeClass('opened');
292						});
293						  
294					});
295					
296				},
297				display_show: function (e) {
298					e.preventDefault();
299					if (!this.searchWrap.hasClass('opened')) {
300						this.searchWrap.addClass('opened');
301						this.searchField.focus();
302					}
303				},
304				display_hide: function (e, key) {
305					var base = this;
306					if (base.searchWrap.hasClass('opened')) {
307						if (e.type == base.event || e.type == 'keydown' && e.keyCode === key) {
308							e.preventDefault();
309							base.hide();
310							base.searchField.blur();
311						}
312					}
313				},
314				keyDownHandler: function (key) {
315					$(window).on('keydown', $.proxy(function (e) {
316						this.display_hide(e, key);
317					}, this));
318				}
319			}
320
321			$.fn.extend({
322				searchClick: function (option) {
323					if (!this.length) return this;
324					return this.each(function () {
325						var $this = $(this), data = $this.data('searchClick'),
326							options = typeof option == 'object' && option;
327						if (!data) {
328							$this.data('searchClick', new $.searchClick(this, options));
329						}
330					});
331				}
332			});
333
334			var searchHolder = $('.search-holder');
335
336			if (searchHolder.length) {
337				searchHolder.searchClick();
338			}
339
340		},
341
342		/**
343		Counters
344		**/
345		counters : function(){
346
347			var counter = $('.counter');
348
349			counter.each(function(){
350
351				var $this = $(this),
352				offset = $this.offset().top - 3000;
353
354				$(window).on('scroll',function(){
355					if($this.hasClass('counted')) return false;
356
357					if($(this).scrollTop() >= offset){
358
359						$this.addClass('counted');
360						
361						(function ($) {
362							$.fn.countTo = function (options) {
363								options = options || {};
364								
365								return $(this).each(function () {
366									// set options for current element
367									var settings = $.extend({}, $.fn.countTo.defaults, {
368										from:            $(this).data('from'),
369										to:              $(this).data('to'),
370										speed:           $(this).data('speed'),
371										refreshInterval: $(this).data('refresh-interval'),
372										decimals:        $(this).data('decimals')
373									}, options);
374									
375									// how many times to update the value, and how much to increment the value on each update
376									var loops = Math.ceil(settings.speed / settings.refreshInterval),
377										increment = (settings.to - settings.from) / loops;
378									
379									// references & variables that will change with each update
380									var self = this,
381										$self = $(this),
382										loopCount = 0,
383										value = settings.from,
384										data = $self.data('countTo') || {};
385									
386									$self.data('countTo', data);
387									
388									// if an existing interval can be found, clear it first
389									if (data.interval) {
390										clearInterval(data.interval);
391									}
392									data.interval = setInterval(updateTimer, settings.refreshInterval);
393									
394									// initialize the element with the starting value
395									render(value);
396									
397									function updateTimer() {
398										value += increment;
399										loopCount++;
400										
401										render(value);
402										
403										if (typeof(settings.onUpdate) == 'function') {
404											settings.onUpdate.call(self, value);
405										}
406										
407										if (loopCount >= loops) {
408											// remove the interval
409											$self.removeData('countTo');
410											clearInterval(data.interval);
411											value = settings.to;
412											
413											if (typeof(settings.onComplete) == 'function') {
414												settings.onComplete.call(self, value);
415											}
416										}
417									}
418									
419									function render(value) {
420										var formattedValue = settings.formatter.call(self, value, settings);
421										$self.html(formattedValue);
422									}
423								});
424							};
425							
426							$.fn.countTo.defaults = {
427								from: 0,               // the number the element should start at
428								to: 0,                 // the number the element should end at
429								speed: 1000,           // how long it should take to count between the target numbers
430								refreshInterval: 100,  // how often the element should be updated
431								decimals: 0,           // the number of decimal places to show
432								formatter: formatter,  // handler for formatting the value before rendering
433								onUpdate: null,        // callback method for every time the element is updated
434								onComplete: null       // callback method for when the element finishes updating
435							};
436							
437							function formatter(value, settings) {
438								return value.toFixed(settings.decimals);
439							}
440						}(jQuery));
441
442						jQuery(function ($) {
443						  // custom formatting example
444						  $('.count-number').data('countToOptions', {
445							formatter: function (value, options) {
446							  return value.toFixed(options.decimals).replace(/\B(?=(?:\d{3})+(?!\d))/g, '');
447							}
448						  });
449						  
450						  // start all the timers
451						  $('.timer').each(count);  
452						  
453						  function count(options) {
454							var $this = $(this);
455							options = $.extend({}, options || {}, $this.data('countToOptions') || {});
456							$this.countTo(options);
457						  }
458						});
459						
460					}
461
462				});
463
464			});
465
466		},
467
468		/**
469		 * Emulates single accordion item
470		 * @param Function callback
471		 * @return jQuery collection;
472		 **/
473		hiddenSections: function(callback){
474
475			var collection = $('.hidden-section');
476			if(!collection.length) return;
477
478			collection.each(function(i, el){
479				$(el).find('.content').hide();
480			});
481
482			collection.on('click.hidden', '.invoker', function(e){
483
484				e.preventDefault();
485
486				var content = $(this).closest('.hidden-section').find('.content');
487
488				content.slideToggle({
489					duration: 500,
490					easing: 'easeOutQuint',
491					complete: callback ? callback : function(){}
492				});
493
494			});
495
496			return collection;
497
498		},
499
500		/**
501		Isotope
502		**/
503		isotope : function(){
504			var cthis = this;
505			$('[data-isotope-options]').each(function(){
506
507				var self = $(this),
508				options = self.data('isotope-options');
509
510				self.isotope(options);
511
512			});
513		},
514
515		/**
516		Sync Owl Carousel
517		**/
518		syncOwlCarousel: {
519
520			init: function(){
521
522				this.collection = $('.owl-carousel[data-sync]');
523				if(!this.collection.length) return false;
524
525				this.bindEvents();
526
527			},
528
529			bindEvents: function(){
530
531				var self = this;
532
533				this.collection.each(function(i, el){
534
535					var $this = $(el),
536						sync = $($this.data('sync'));
537
538					if(!sync.length){
539						console.log('Not found carousel with selector ' + $this.data('sync'));
540						return;
541					}
542
543					// nav
544					$this.on('click', '.owl-prev', function(e){
545						sync.trigger('prev.owl.carousel');
546					});
547					$this.on('click', '.owl-next', function(e){
548						sync.trigger('next.owl.carousel');
549					});
550
551					sync.on('click', '.owl-prev', function(e){
552						$this.trigger('prev.owl.carousel');
553					});
554					sync.on('click', '.owl-next', function(e){
555						$this.trigger('next.owl.carousel');
556					});
557
558					// // drag 
559					$this.on('dragged.owl.carousel', function(e){
560
561				        if(e.relatedTarget.state.direction == 'left'){
562				            sync.trigger('next.owl.carousel');
563				        }
564				        else{
565				            sync.trigger('prev.owl.carousel');
566				        }
567				        
568					});
569
570					sync.on('dragged.owl.carousel', function(e){
571
572						if(e.relatedTarget.state.direction == 'left'){
573				            $this.trigger('next.owl.carousel');
574				        }
575				        else{
576				            $this.trigger('prev.owl.carousel');
577				        }
578
579					});
580
581				});
582
583			}
584
585		},
586
587		/**
588		 Adds background image
589		 * @return undefined;
590		**/
591		bg: function(collection){
592
593			var collection = collection ? collection : $('[data-bg]');
594
595			collection.each(function(){
596
597				var $this = $(this),
598					bg = $this.data('bg');
599
600				if(bg) $this.css('background-image', 'url('+bg+')');
601
602			});
603
604		},
605
606		navInit : {
607
608			init : function (base) {
609
610				this.createResponsiveButtons.call(base);
611				this.navProcess(base);
612
613				if ( base.SUPPORT.ISTOUCH ) {
614					this.touchNavEvent(base);
615				}
616			},
617
618			touchNavEvent: function (base) {
619				var clicked = false;
620
621				$("li.menu-item-has-children > a, li.cat-parent > a, li.page-item-has-children > a").on(base.event, function (e) {
622					if (clicked != this) {
623						e.preventDefault();
624						clicked = this;
625					}
626				});
627			},
628
629			navProcess: function (base) {
630
631				base.navInit.touchNav(base, base.$window);
632
633				$(window).resize(function (e) {
634					setTimeout(function () {
635						base.navInit.touchNav(base, e.currentTarget);
636					}, 30);
637				});
638
639			},
640
641			touchNav: function (base, target) {
642
643				if (base.SUPPORT.ISTOUCH || $(target).width() < 992) {
644
645					if (!base.navMobile.children('ul').length) {
646						base.navMobile.append(base.navMain.html());
647					}
648
649					base.navButton.on(base.event, function (e) {
650						e.preventDefault();
651
652						if (!base.wrapper.is('.active')) {
653							$('html, body').animate({ scrollTop: 0 }, 0, function () {
654								base.wrapper.css({
655									height: base.navMobile.children('ul').outerHeight(true)
656								}).addClass('active');
657							});
658						}
659					});
660
661					base.navHide.on(base.event, function (e) {
662						e.preventDefault();
663						if (base.wrapper.is('.active')) {
664							base.wrapper.css({ height: 'auto' }).removeClass('active');
665						}
666					});
667
668				} else {
669					base.navMobile.children('ul').remove();
670				}
671			},
672
673			createResponsiveButtons : function () {
674
675				this.navButton = $('<button></button>', {
676					id: 'responsive-nav-button',
677					'class': 'responsive-nav-button'
678				}).insertBefore(this.navMain);
679
680				this.navHide = $('<a></a>', {
681					id: 'advanced-menu-hide',
682					'href' : '#'
683				}).insertBefore(this.navMobile); 
684
685			},
686
687		}
688
689	}
690
691	$(function(){
692
693		$.mad_core.DOMLoaded();
694
695	});
696
697})(jQuery);
698
699/**
700Custom select
701**/
702$.fn.madCustomSelect = function () {
703
704	return this.each(function(){
705
706		var list = $(this).children('ul'),
707			select = $(this).find('select'),
708			title = $(this).find('.select-title');
709	 
710
711		// select items to list items
712
713		if($(this).find('[data-filter]').length){
714			for(var i = 0,len = select.children('option').length;i < len;i++){
715				list.append('<li data-filter="'+select.children('option').eq(i).data('filter')+'">'+select.children('option').eq(i).text()+'</li>')
716			}
717		}
718		else{
719			for(var i = 0,len = select.children('option').length;i < len;i++){
720				list.append('<li>'+select.children('option').eq(i).text()+'</li>')
721			}
722		}
723		select.hide();
724
725		// open list
726		
727		title.on('click',function(){
728			list.slideToggle(400);
729			$(this).toggleClass('active');
730		});
731
732		// selected option
733
734		list.on('click','li',function(){
735			var val = $(this).text();
736			title.text(val);
737			list.slideUp(400);
738			select.val(val);
739			title.toggleClass('active');
740			return false;
741		});
742
743	});
744
745},
746
747// Sticky and Go-top
748
749(function ($, window) {
750
751	function Temp(el, options) {
752		this.el = $(el);
753		this.init(options);
754	}
755
756	Temp.DEFAULTS = {
757		sticky: true
758	}
759
760	Temp.prototype = {
761		init: function (options) {
762			var base = this;
763				base.window = $(window);
764				base.options = $.extend({}, Temp.DEFAULTS, options);
765				base.stickyWrap = $('.sticky-header');
766				base.goTop = $('<button class="go-to-top" id="go-to-top"></button>').appendTo(base.el);
767
768			// Sticky
769			if (base.options.sticky) {
770				base.sticky.stickySet.call(base, base.window);
771				base.stickyWrap.before($(".sticky-header").clone(true).addClass("clone-fixed"));
772
773				$(".sticky-header.clone-fixed").css('top', '-' + $('#header').outerHeight() + 'px');
774				
775				$( window ).on('load resize', function() {
776
777				  	$(".sticky-header.clone-fixed").css('top', '-' + $('#header').outerHeight() + 'px');
778				     
779				});
780				
781			}
782			
783			// Scroll Event
784			base.window.on('scroll', function (e) {
785				/*if (base.options.sticky) {
786					base.sticky.stickyInit.call(base, e.currentTarget);
787				}*/
788				base.gotoTop.scrollHandler.call(base, e.currentTarget);
789			});
790
791			// Click Handler Button GotoTop
792			base.gotoTop.clickHandler(base);
793		},
794
795		sticky: {
796
797			stickySet: function () {
798
799				// Script
800				var lastScroll = 0;
801				var stickyWrap = $('.sticky-header');
802				$(window).on('scroll',function(data,base) {    
803				    var scroll = $(window).scrollTop();
804				    if(lastScroll - scroll > 0) {
805				        if (!stickyWrap.hasClass('sticky')) {
806							stickyWrap.addClass('sticky');
807							$('.sticky-header.clone-fixed').addClass('slideDown');
808						}
809				    } else {
810				        if (stickyWrap.hasClass('sticky')) {
811							stickyWrap.removeClass('sticky');
812							$('.sticky-header.clone-fixed').removeClass('slideDown');
813						}
814				    } 
815				    lastScroll = scroll;
816				    if (scroll < stickyWrap.outerHeight()) {
817				        //clearHeader, not clearheader - caps H
818				        $('.sticky-header.clone-fixed').removeClass('slideDown');
819				    }
820				});
821
822			},
823			/*stickyInit: function (win) {
824				var base = this, data;
825				if (base.stickyWrap.length) {
826					data = $.data(base.stickyWrap, 'data');
827					base.sticky.stickyAction(data, win, base);
828				}
829			},
830			stickyAction: function (data, win, base) {
831				var scrollTop = $(win).scrollTop();
832				if (scrollTop > data.offset)  {
833					if (!base.stickyWrap.hasClass('sticky')) {
834						base.stickyWrap.addClass('sticky');
835						$('.sticky-header.clone-fixed').addClass('slideDown');
836					}
837				} else {
838					if (base.stickyWrap.hasClass('sticky')) {
839						base.stickyWrap.removeClass('sticky');
840						$('.sticky-header.clone-fixed').removeClass('slideDown');
841					}
842				}
843			}*/
844
845		},
846		gotoTop: {
847			scrollHandler: function (win) {
848				$(win).scrollTop() > 200 ?
849				this.goTop.addClass('go-top-visible'):
850				this.goTop.removeClass('go-top-visible');
851				$('.fb-link').addClass('fb-visible');
852			},
853			clickHandler: function (self) {
854				self.goTop.on('click', function (e) {
855					e.preventDefault();
856					$('html, body').animate({ scrollTop: 0 }, 800);
857				});
858			}
859		}
860
861	}
862
863	/* Temp Plugin
864	 * ================================== */
865
866	$.fn.Temp = function (option) {
867		return this.each(function () {
868			var $this = $(this), data = $this.data('Temp'),
869				options = typeof option == 'object' && option;
870			if (!data) {
871				$this.data('Temp', new Temp(this, options));
872			}
873		});
874	}
875
876})(jQuery, window);

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.