PageSourceSearch

https://ael.edu.pt/wp-content/themes/fluida/resources/js/frontend.js?ver=1.6.0.2

js ael.edu.pt collected 2026-10-02 00:13:27 UTC 17,643 bytes, 538 lines download raw bytes

1/*
2 * Frontend JS
3 *
4 * @package Fluida
5 */
6
7jQuery( document ).ready( function() {
8
9	for (index = 1; index <= fluida_settings.lpboxratios.length; ++index) {
10		jQuery( '.lp-boxes-'+index+' .lp-box-image' ).keepRatio( fluida_settings.lpboxratios[index-1] );
11	}
12	jQuery( ".lp-boxes-animated.lp-boxes" ).mousedir( ".lp-boxes-animated.lp-boxes:not(.lp-boxes-animated2) .lp-box" );
13
14	fluida_mobilemenu_init();
15	fluida_initnav('#mobile-menu');
16	fluida_sitetitle_breakup();
17	fluida_menu_animate();
18	fluida_backtotop();
19	fluida_searchform_animation();
20	fluida_social_titles();
21	fluida_bodyclasses();
22	fluida_tabs_widget();
23	fluida_portfolio_filter();
24
25	if ( ( (fluida_settings.fitvids == 2) && (fluida_settings.is_mobile == 1) ) || ( fluida_settings.fitvids == 1 ) )	jQuery( ".entry-content" ).fitVids();
26	if ( fluida_settings.autoscroll == 1 ) fluida_autoscroll();
27}); /* document.ready */
28
29jQuery(window).load(function() {
30
31	jQuery( window ).trigger( "scroll" );
32
33	/* articles masonry */
34	if ( ( fluida_settings.masonry == 1 ) && ( fluida_settings.magazine != 1 ) && ( typeof jQuery.fn.masonry !== 'undefined' ) ) {
35		jQuery('#content-masonry').masonry({
36			itemSelector: 'article',
37			columnWidth: 'article',
38			percentPosition: true,
39			isRTL: fluida_settings.rtl,
40		});
41	}
42	/* jetpack portfolio masonry */
43	fluida_portfolio_masonry();
44
45}); /* window.load */
46
47/* Site Title Letter break */
48function fluida_sitetitle_breakup() {
49	var str = jQuery( "#site-title span a" ).text();
50	var newstr = "";
51	var delay = 0.05;
52	for ( var i = 0, len = str.length; i < len; i++ ) {
53		if ( str[i]!=' ' )
54			newstr += "<span>" + str[i] + "</span>";
55		else
56			newstr += "<span>&nbsp;</span>";
57	}
58	jQuery( "#site-title span a" ).html( newstr );
59	jQuery( "#site-title > span > a > span" ).each( function() {
60		jQuery( this ).css( {'transition': 'color 0s ease ' + delay + 's,' + ' background-color 0s ease ' + delay + 's'} );
61		delay += .02;
62	});
63} /* fluida_sitetitle_breakup() */
64
65/* Menu animation */
66function fluida_menu_animate() {
67	jQuery( "#access > .menu ul li > a:not(:only-child)" ).attr( "aria-haspopup", "true" );/* IE10 mobile Fix */
68
69	jQuery( "#access li" ).hover( function() {
70		jQuery( this ).addClass('menu-hover');
71	}, function() {
72		jQuery( this ).removeClass('menu-hover');
73	});
74
75	jQuery('#access ul').find('a').on( 'focus', function() {
76		jQuery( this ).parents( '.menu-item, .page_item' ).addClass( 'menu-hover' );
77	});
78
79	jQuery('#access ul').find('a').on( 'blur', function() {
80		jQuery( this ).parents( '.menu-item, .page_item' ).removeClass( 'menu-hover' );
81	});
82
83} /* fluida_menu_animate() */
84
85/* Back to top button animation */
86function fluida_backtotop() {
87	jQuery( window ).scroll( function() {
88		if ( jQuery( this ).scrollTop() > 500 ) {
89			jQuery( "#toTop" ).css( { "bottom": "-2px", "opacity": 1 } );
90		} else {
91			jQuery( "#toTop" ).css( { "bottom": "100px", "opacity": 0 } );
92		}
93		if ( jQuery( this ).scrollTop() > 300 ) {
94			jQuery( ".fluida-fixed-menu #site-header-main" ).addClass( "header-fixed" );
95		} else {
96			jQuery( ".fluida-fixed-menu #site-header-main" ).removeClass( "header-fixed" );
97		}
98	});
99} /* fluida_backtotop() */
100
101/* Search form animation */
102function fluida_searchform_animation() {
103	var i = 0;
104	jQuery( "#access .menu-search-animated > a" ).on( 'click', function( event ) {
105		event.preventDefault();
106	});
107	jQuery( "#access .menu-search-animated > a" ).on( 'mousedown focus', function( event ) {
108		event.preventDefault();
109		i++;
110		jQuery( ".menu-search-animated .searchform" ).slideToggle( 100 );
111		jQuery( ".menu-search-animated .s" ).focus();
112		if( i == 2 ) {
113			//jQuery( ".menu-search-animated .searchsubmit" ).click(); // disabled
114		}
115		event.stopPropagation();
116	});
117	jQuery( ".menu-search-animated .searchform" ).click( function( event ){
118		event.stopPropagation();
119	});
120	jQuery( "#access .menu-search-animated .s").blur( function() {
121		i = 0;
122		jQuery( "#access .menu-search-animated .searchform" ).fadeOut( 100 );
123	});
124
125	jQuery( "#toTop" ).click( function( event ) {
126		event.preventDefault();
127		jQuery( "html, body" ).animate( { scrollTop: 0 }, 500 );
128		return false;
129	});
130} /* fluida_searchform_animation() */
131
132/* Mobile Menu */
133function fluida_mobilemenu_init() {
134
135	jQuery("#nav-toggle").click(function(){
136		jQuery("#mobile-menu").show().animate({left: "0"}, 500);
137		jQuery('body').addClass("noscroll");
138	});
139
140	jQuery("#nav-cancel").click(function(){
141		jQuery("#mobile-menu").animate({left: "100%"},500,function(){jQuery(this).css("left","-100%").hide();});
142		jQuery('body').removeClass("noscroll");
143	});
144
145	/* Remove animated class from mobile menu */
146	jQuery("#mobile-menu .menu-main-search").removeClass("menu-search-animated");
147
148	jQuery( "#mobile-menu > div" ).append( jQuery( "#sheader" ).clone() );
149	jQuery( "#mobile-menu #sheader" ).attr( "id", "smobile");
150
151}
152
153/* Add submenus toggles to the primary navigation */
154function fluida_initnav(selector) {
155
156	container = jQuery(selector);
157
158	/* Add dropdown toggle that display child menu items. */
159	container.find( '.menu-item-has-children > a' ).after( '<button class="dropdown-toggle" aria-expanded="false"></button>' );
160	container.find( '.page_item_has_children > a' ).after( '<button class="dropdown-toggle" aria-expanded="false"></button>' );
161
162	/* Toggle buttons and submenu items with active children menu items. */
163	container.find( '.current-menu-ancestor > button, .current-page-ancestor > button' ).addClass( 'toggle-on' );
164	container.find( '.current-menu-ancestor > .sub-menu, .current-page-ancestor > .sub-menu, .current-menu-ancestor .children, .current-page-ancestor .children' ).show(0).addClass( 'toggled-on' );
165
166	container.find( '.dropdown-toggle' ).click( function( e ) {
167		var _this = jQuery( this );
168		e.preventDefault();
169		_this.toggleClass( 'toggle-on' );
170		if ( _this.hasClass( 'toggle-on') ) {
171			_this.next( '.children, .sub-menu' ).show(0).addClass( 'toggled-on' );
172			_this.prev("a").addClass( "toggled-on" );
173		}
174		else {
175			_this.next( '.children, .sub-menu' ).removeClass( 'toggled-on' );
176			_this.prev("a").removeClass( "toggled-on" );
177		}
178
179		/* _this.parent().find( 'a' ).toggleClass( 'toggled-on' ); */
180		_this.attr( 'aria-expanded', _this.attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' );
181	} );
182
183	/* Close mobile menu on click/tap */
184	jQuery('body').on('click','#mobile-nav a', function() {
185		jQuery('#nav-cancel i').trigger('click');
186	});
187}
188
189/* LP Boxes Keep aspect ratio*/
190jQuery.fn.keepRatio = function( ratio ) {
191
192	var $this = jQuery( this );
193	var nh = $this.width() / ratio;
194	$this.css( "height", nh + "px" );
195	jQuery( window ).resize( function() {
196		var nh = $this.width() / ratio;
197		$this.css( "height", nh + "px" );
198	});
199
200}; /* Keep boxes aspect ration */
201
202/* LP Box Mouse direction overlay animation */
203jQuery.fn.mousedir = function( el ) {
204	if ( ! jQuery( "body" ).hasClass( "fluida-landing-page" ) ) return;
205
206	var $this = jQuery( this ),
207		$el = jQuery( el ),
208		last_position = {},
209		$output = "direction-down";
210
211	jQuery( document ).on( "mousemove", function (event) {
212
213	    if ( typeof( last_position.x ) != "undefined" ) {
214	        var deltaX = last_position.x - event.offsetX,
215	            deltaY = last_position.y - event.offsetY;
216	        if ( Math.abs( deltaX ) > Math.abs( deltaY ) && deltaX > 0 ) {
217	            $output = "direction-left";
218	        } else if ( Math.abs( deltaX ) > Math.abs( deltaY ) && deltaX < 0 ) {
219	            $output = "direction-right";
220	        } else if ( Math.abs( deltaY ) > Math.abs( deltaX ) && deltaY > 0 ) {
221	            $output = "direction-up";
222	        } else if ( Math.abs( deltaY ) > Math.abs( deltaX ) && deltaY < 0 ) {
223	            $output = "direction-down";
224	        } else {
225				$output = "direction-down";
226			}
227		}
228		last_position = {
229	    	x : event.offsetX,
230	    	y : event.offsetY
231		};
232
233	});
234
235	$el.on( "mouseenter", function() {
236		jQuery( this ).removeClass( "in-direction-left in-direction-right in-direction-up in-direction-down out-direction-left out-direction-right out-direction-up out-direction-down" );
237		jQuery( this ).addClass( "in-" + $output );
238		return;
239	});
240	$el.on( "mouseleave", function() {
241		jQuery( this ).removeClass( "in-direction-left in-direction-right in-direction-up in-direction-down out-direction-left out-direction-right out-direction-up out-direction-down" );
242		jQuery( this ).addClass( "out-" + $output );
243		return;
244	});
245
246}; /* Mouse direction overlay animation */
247
248/* See if element is visible in browser window */
249jQuery.fn.visible = function( partial ) {
250	var $t            = jQuery( this ),
251		$w            = jQuery( window ),
252		viewTop       = $w.scrollTop(),
253		viewBottom    = viewTop + $w.height(),
254		_top          = $t.offset().top,
255		_bottom       = _top + $t.height(),
256		compareTop    = partial === true ? _bottom : _top,
257		compareBottom = partial === true ? _top : _bottom;
258
259	return ( (compareBottom <= viewBottom) && (compareTop >= viewTop) );
260}; /* jQuery.fn.visible() */
261
262/* Animate on scroll */
263function animateScroll( $articles ) {
264
265	var $articles = jQuery( $articles );
266
267	$articles.each( function( i, el ) {
268	  var el = jQuery( el );
269	  if ( ! el.visible( true ) ) {
270		  el.addClass( "animated-article" );
271	  }
272	});
273
274	jQuery( window ).on({
275	    'scroll': function( e ) {
276			$articles.each( function( i, el ) {
277				var el = jQuery( el );
278				if ( el.visible( true ) ) {
279					el.removeClass( "animated-article" );
280				}
281			});
282	    }
283	});
284
285} /* animateScroll() */
286if ( fluida_settings.articleanimation ) animateScroll( "#content-masonry > article" );
287
288/*  Add Social Icons titles */
289function fluida_social_titles() {
290
291	jQuery( ".socials a" ).each(function() {
292		jQuery( this ).attr( "title", jQuery( this ).children().html() );
293		jQuery( this ).html( "" );
294	});
295
296} /* fluida_social_titles() */
297
298/* Add body classes */
299function fluida_bodyclasses() {
300	/* Detect and apply custom class for Safari */
301	if ( navigator.userAgent.indexOf( "Safari" ) != -1 && navigator.userAgent.indexOf( "Chrome" ) == -1) {
302		jQuery( "body" ).addClass( "safari" );
303	}
304	/* Add body class if masonry is used on page */
305	if ( jQuery( "#content-masonry" ).length > 0 ) {
306		jQuery( "body" ).addClass( "fluida-with-masonry" );
307	}
308} /* fluida_bodyclasses() */
309
310
311/*  Tabs widget */
312function fluida_tabs_widget() {
313		var tabsNav       = jQuery('.cryout-wtabs-nav'),
314			tabsNavLis    = tabsNav.children('li'),
315			tabsContainer = jQuery('.cryout-wtabs-container');
316
317		tabsNav.each(function() {
318			var localthis = jQuery(this);
319			localthis.next().children('.cryout-wtab').stop(true,true).hide().siblings( localthis.find('a').attr('href') ).show();
320			localthis.children('li').first().addClass('active').stop(true,true).show();
321		});
322
323		tabsNavLis.on('click', function(e) {
324			var localthis = jQuery(this);
325
326			localthis.siblings().removeClass('active').end().addClass('active');
327
328			localthis.parent().next().children('.cryout-wtab').stop(true,true).hide().siblings( localthis.find('a').attr('href') ).fadeIn();
329			e.preventDefault();
330		}).children( window.location.hash ? 'a[href="' + window.location.hash + '"]' : 'a:first' ).trigger('click');
331
332};
333
334/* Jetpack Portfolio masonry */
335function fluida_portfolio_masonry() {
336	if ( ( fluida_settings.masonry == 1 ) && ( typeof jQuery.fn.masonry !== 'undefined' ) ) {
337		/* jQuery('#portfolio-masonry').masonry({
338			itemSelector: '.portfolio-entry',
339		 	columnWidth: '.portfolio-entry:not(.hidden)',
340		 	percentPosition: true,
341		 	isRTL: fluida_settings.rtl,
342		 });*/
343		jQuery('.jetpack-portfolio-shortcode').masonry({
344			itemSelector: '.portfolio-entry',
345			columnWidth: '.portfolio-entry:not(.hidden)',
346			percentPosition: true,
347			isRTL: fluida_settings.rtl,
348		});
349	}
350}
351
352/* Portfolio filtering */
353function fluida_portfolio_filter() {
354	jQuery('body').on('click', '#portfolio-filter > a', function(e) {
355		e.preventDefault();
356		jQuery('#portfolio-filter > a').removeClass('active');
357		jQuery(this).addClass('active');
358		var filter = jQuery(this).attr('data-slug');
359		jQuery('#portfolio-masonry .portfolio-entry').each( function(i,elm) {
360			if (filter == 'all') {
361				jQuery(elm).removeClass('hidden');
362			} else {
363				if ( !jQuery(elm).hasClass('type-'+filter) ) {
364					jQuery(elm).addClass('hidden');
365				} else {
366					jQuery(elm).removeClass('hidden');
367				}
368			}
369		}).promise().done( function() {
370			fluida_portfolio_masonry();
371			/*jQuery('.jetpack-portfolio-shortcode').masonry();*/
372		});
373		return false;
374	});
375}
376
377/* FitVids 1.1*/
378;(function( $ ){
379
380  'use strict';
381
382  $.fn.fitVids = function( options ) {
383    var settings = {
384      customSelector: null,
385      ignore: null
386    };
387
388    if(!document.getElementById('fit-vids-style')) {
389      /* appendStyles: https://github.com/toddmotto/fluidvids/blob/master/dist/fluidvids.js */
390      var head = document.head || document.getElementsByTagName('head')[0];
391      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%;}';
392      var div = document.createElement("div");
393      div.innerHTML = '<p>x</p><style id="fit-vids-style">' + css + '</style>';
394      head.appendChild(div.childNodes[1]);
395    }
396
397    if ( options ) {
398      $.extend( settings, options );
399    }
400
401    return this.each(function(){
402      var selectors = [
403        'iframe[src*="player.vimeo.com"]',
404        'iframe[src*="youtube.com"]',
405        'iframe[src*="youtube-nocookie.com"]',
406        'iframe[src*="kickstarter.com"][src*="video.html"]',
407        'object',
408        'embed'
409      ];
410
411      if (settings.customSelector) {
412        selectors.push(settings.customSelector);
413      }
414
415      var ignoreList = '.fitvidsignore, .wp-block-embed__wrapper';
416
417      if(settings.ignore) {
418        ignoreList = ignoreList + ', ' + settings.ignore;
419      }
420
421      var $allVideos = $(this).find(selectors.join(','));
422      $allVideos = $allVideos.not('object object');
422 /* SwfObj conflict patch */
423      $allVideos = $allVideos.not(ignoreList); /* Disable FitVids on this video. */
424
425      $allVideos.each(function(){
426        var $this = $(this);
427        if($this.parents(ignoreList).length > 0) {
428          return; /* Disable FitVids on this video. */
429        }
430        if (this.tagName.toLowerCase() === 'embed' && $this.parent('object').length || $this.parent('.fluid-width-video-wrapper').length) { return; }
431        if ((!$this.css('height') && !$this.css('width')) && (isNaN($this.attr('height')) || isNaN($this.attr('width'))))
432        {
433          $this.attr('height', 9);
434          $this.attr('width', 16);
435        }
436        var height = ( this.tagName.toLowerCase() === 'object' || ($this.attr('height') && !isNaN(parseInt($this.attr('height'), 10))) ) ? parseInt($this.attr('height'), 10) : $this.height(),
437            width = !isNaN(parseInt($this.attr('width'), 10)) ? parseInt($this.attr('width'), 10) : $this.width(),
438            aspectRatio = height / width;
439        if(!$this.attr('name')){
440          var videoName = 'fitvid' + $.fn.fitVids._count;
441          $this.attr('name', videoName);
442          $.fn.fitVids._count++;
443        }
444        $this.wrap('<div class="fluid-width-video-wrapper"></div>').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+'%');
445        $this.removeAttr('height').removeAttr('width');
446      });
447    });
448  };
449
450  /* Internal counter for unique video names. */
451  $.fn.fitVids._count = 0;
452
453/* Works with either jQuery or Zepto */
454})( window.jQuery || window.Zepto );
455
456
457/**
458 * Scroll to anchors
459 */
460function fluida_autoscroll(document, history, location) {
461	document = window.document;
462	history = window.history;
463	location = window.location;
464	var HISTORY_SUPPORT = !!(history && history.pushState);
465	var anchorScrolls = {
466		ANCHOR_REGEX: /^#[^ ]+$/,
467		OFFSET_HEIGHT_PX: jQuery('.fluida-fixed-menu #site-header-main').height()+40,
468
469		/**
470		* Establish events, and fix initial scroll position if a hash is provided.
471		*/
472		init: function() {
473			this.scrollToCurrent();
474			jQuery(window).on('hashchange', jQuery.proxy(this, 'scrollToCurrent'));
475			jQuery('body').on('click', '.main a, nav ul li a', jQuery.proxy(this, 'delegateAnchors'));
476		},
477
478		/**
479		* Return the offset amount to deduct from the normal scroll position.
480		* Modify as appropriate to allow for dynamic calculations
481		*/
482		getFixedOffset: function() {
483			return this.OFFSET_HEIGHT_PX;
484		},
485
486		/**
487		* If the provided href is an anchor which resolves to an element on the
488		* page, scroll to it.
489		* @param  {String} href
490		* @return {Boolean} - Was the href an anchor.
491		*/
492		scrollIfAnchor: function(href, pushToHistory) {
493			var match, anchorOffset;
494
495			if(!this.ANCHOR_REGEX.test(href)) {
496				return false;
497			}
498
499			match = document.getElementById(href.slice(1));
500
501			if(match && ! jQuery(match).visible( true )) {
502				anchorOffset = jQuery(match).offset().top - this.getFixedOffset();
503				jQuery('html, body').animate({ scrollTop: anchorOffset});
504
505				/* Add the state to history as-per normal anchor links */
506				if(HISTORY_SUPPORT && pushToHistory) {
507					history.pushState({}, document.title, location.pathname + href);
508				}
509			}
510
511			return !!match;
512		},
513
514		/**
515		* Attempt to scroll to the current location's hash.
516		*/
517		scrollToCurrent: function(e) {
518			if(this.scrollIfAnchor(window.location.hash) && e) {
519				e.preventDefault();
520			}
521		},
522
523		/**
524		* If the click event's target was an anchor, fix the scroll position.
525		*/
526		delegateAnchors: function(e) {
527			var elem = e.target.closest('a');
528
529			if(this.scrollIfAnchor(elem.getAttribute('href'), true)) {
530				e.preventDefault();
531			}
532		}
533	};
534
535	jQuery(document).ready(jQuery.proxy(anchorScrolls, 'init'));
536}
537
538/* FIN */

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.