var container = $('.container'); var header = $('header'); var headerHeight = getHeadHeight(); var headerFixClass = "fixed"; var breakPoint = $(window).height() - headerHeight; var toTopBtn = $('.toTop'); var img = $('img'); var resMenuBtn = $('.resMenuBtn'); var resMenu = $('.nav'); var picSlideshow = { slideContainer: $('.slide, .appView .appDescription .wdgMenu'), sequence: [ { container: $('.slide .contMenu, .appView .appDescription .wdgMenu .contMenu') }, { element: $('.slide .menuItem, .appView .appDescription .wdgMenu .menuItem') }, { content: null } ], autoPlay: true, timeStill: 7000, timeBetween: 1500, effects: [ { fade: true } ], navigation: [ { arrows: true }, { selectors: true } ], setFullScreenHeight: function(header) { var slideContainer = this.slideContainer; var headerHeight = parseInt(header.css('height')) + $('.presupuestosBanner').height(); var totalHeight = 100 - ((100 * headerHeight) / $(window).height()); slideContainer.css('height', '' + totalHeight + 'vh'); }, setBackground: function() { var slideContainer = this.slideContainer; var element = this.sequence[1].element; element.each(function(index) { var elementPic = $(this).find('.menuPic'); var imgSrc = elementPic.find('img').attr('src'); elementPic.hide(); $(this).css('background-image', 'url(' + imgSrc + ')'); }); }, setNavigation: function() { var slideContainer = this.slideContainer; var element = this.sequence[1].element; var arrows = this.navigation[0].arrows; var selectors = this.navigation[1].selectors; if (arrows === true) { var arrowNav = '
'; arrowNav += ''; arrowNav += ''; arrowNav += '
'; slideContainer.append(arrowNav); } if (selectors === true) { var selectorNav = '
'; selectorNav += '
'; slideContainer.append(selectorNav); $('.selectorNav li').first().addClass('active'); } }, setActions: function() { var slideContainer = this.slideContainer; var sequence = this.sequence[0].container; var element = this.sequence[1].element; var elementContent = this.sequence[2].content; var autoPlay = this.autoPlay; var timeBetween = this.timeBetween; var timeStill = this.timeStill; var fadeEffect = this.effects[0].fade; var arrows = this.navigation[0].arrows; var selectors = this.navigation[1].selectors; var animationComplete = true; var timer; var interval; function prev_e() { var currentElement = sequence.find('> .active'); var prevElement = currentElement.prev(); var transition = timeBetween / 2; animationComplete = false; if (prevElement.length === 0) { prevElement = element.last(); } if (elementContent != null) { elementContent.hide(); } if (selectors === true) { var currentSelector = $('.selectorNav li.active'); var prevSelector = currentSelector.prev(); if(prevSelector.length === 0) { prevSelector = $('.selectorNav li').last(); } currentSelector.removeClass('active'); prevSelector.addClass('active'); } currentElement.fadeOut(transition, function() { $(this).removeClass('active'); prevElement.addClass('active'); }); prevElement.fadeIn(transition, function() { if (elementContent != null) { elementContent.fadeIn(); } animationComplete = true; }).css('display', 'block'); } function next_e() { var currentElement = sequence.find('> .active'); var nextElement = currentElement.next(); var transition = timeBetween / 2; animationComplete = false; if (nextElement.length === 0) { nextElement = element.first(); } if (elementContent != null) { elementContent.hide(); } if (selectors === true) { var currentSelector = $('.selectorNav li.active'); var nextSelector = currentSelector.next(); if (nextSelector.length === 0) { nextSelector = $('.selectorNav li').first(); } currentSelector.removeClass('active'); nextSelector.addClass('active'); } currentElement.fadeOut(transition, function() { $(this).removeClass('active'); nextElement.addClass('active'); }); nextElement.fadeIn(transition, function() { if (elementContent != null) { elementContent.fadeIn(); } animationComplete = true; }).css('display', 'block'); } function select_e(selection) { var currentSelector = $('.selectorNav li.active'); var selectedSelector = $(selection); var selectorIndex = selectedSelector.index(); var currentElement = sequence.find('> .active'); var selectedElement = $(element.get(selectorIndex)); var transition = timeBetween / 2; if (currentSelector.index() === selectorIndex) { return; } else { animationComplete = false; if (elementContent != null) { elementContent.hide(); } currentSelector.removeClass('active'); selectedSelector.addClass('active'); currentElement.fadeOut(transition, function() { $(this).removeClass('active'); selectedElement.addClass('active'); }); selectedElement.fadeIn(transition, function() { if (elementContent != null) { elementContent.fadeIn(); } animationComplete = true; }).css('display', 'block'); } } if (autoPlay === true) { timer = function() { interval = setInterval(function() { next_e(); }, timeStill); } timer(); } if (arrows === true) { var arrowPrev = $('.arrowNav .prev'); var arrowNext = $('.arrowNav .next'); arrowPrev.click(function() { if (animationComplete) { if (autoPlay === true) { clearInterval(interval); prev_e(); timer(); } else { prev_e(); } } }); arrowNext.click(function() { if (animationComplete) { if (autoPlay === true) { clearInterval(interval); next_e(); timer(); } else { next_e(); } } }); } if (selectors === true) { var selector = $('.selectorNav li'); selector.click(function() { if (animationComplete) { if (autoPlay === true) { clearInterval(interval); select_e(this); timer(); } else { select_e(this); } } }); } } }; function getHeadHeight() { header.addClass(headerFixClass); var height = header.height(); header.removeClass(headerFixClass); return height; } function scrollEffects(header, breakPoint, fixClass, toTopBtn) { $(window).scroll(function() { var scroll = $(window).scrollTop(); if (scroll < breakPoint) { header.removeClass(fixClass); toTopBtn.fadeOut(); } else if (scroll >= breakPoint) { header.addClass(fixClass); toTopBtn.fadeIn(); } }); } function scrollTo() { $('a[href*=#]').on('click', function(e) { var target = $(this).attr('href'); var $target = $(target); var offset = $target.offset().top - headerHeight; e.preventDefault(); $('html, body').animate({scrollTop: offset}, 'slow'); }); } function menuResponsive(menu, boton) { var closeBtn = '
'; var menuLink = menu.find('a'); menu.prepend(closeBtn); boton.click(function() { menu.animate({left: 0}, "slow"); menuLink.click(function() { menu.animate({left: "-100%"}, "fast"); }); menu.find('.closeBtn').click(function() { menu.animate({left: "-100%"}, "slow"); }); }); } function svgToInline(img) { img.each(function(){ var $img = jQuery(this); var imgID = $img.attr('id'); var imgClass = $img.attr('class'); var imgURL = $img.attr('src'); jQuery.get(imgURL, function(data) { var $svg = jQuery(data).find('svg'); if(typeof imgID !== 'undefined') { $svg = $svg.attr('id', imgID); } if(typeof imgClass !== 'undefined') { $svg = $svg.attr('class', imgClass+' replaced-svg'); } $svg = $svg.removeAttr('xmlns:a'); $img.replaceWith($svg); }, 'xml'); }); } function prependScreenPosts() { var ecosystems_ScreenPost = $('.ecosystems .screenPost'); var smartContracts_screenPost = $('.smart_contracts .screenPost'); ecosystems_ScreenPost.prependTo(ecosystems_ScreenPost.parents('.wdgPostPrincipal')); smartContracts_screenPost.prependTo(smartContracts_screenPost.parents('.wdgPostPrincipal')); } function moveNavs() { var nav1 = $('header .trialBtn'); var nav2 = $('.ecosistemProfile .appsCont, .ecosistemProfile .userCont'); var newLocation = $('header'); var origin1 = $('header .head_left'); var origin2 = $('.ecosistemProfile .obCont'); if ($(window).width() <= 680) { newLocation.prepend(nav2).prepend(nav1); nav1.show(); } else if ($(window).width() > 680) { nav1.hide(function() { origin1.append(nav1); nav1.show(); }); origin2.append(nav2); } } function wrapMainPostLinks() { var post = $('.main_post .wdgItemPost'); var postButton = $('.main_post .more'); if ($(window).width() > 600 && post.find('.wrapper').length == 0) { post.each(function() { var button = $(this).find('.more'); var link = button.attr('href'); $(this).find('.wdgItemPostCont').wrap(''); button.hide(); }); } else if ($(window).width() <= 600 && post.find('.wrapper').length != 0) { post.find('.wdgItemPostCont').unwrap(); postButton.show(); } } function wrapCategItems() { var categ = $('.categsList .categItem'); categ.each(function() { var link = $(this).find('.categItemCont a').attr('href'); $(this).find('.categItemCont').wrap(''); }); } picSlideshow.sequence[1].element.first().addClass('active'); picSlideshow.setBackground(); picSlideshow.setNavigation(); picSlideshow.setActions(); svgToInline(img); menuResponsive(resMenu, resMenuBtn); scrollTo(); scrollEffects(header, breakPoint, headerFixClass, toTopBtn); prependScreenPosts(); moveNavs(); wrapCategItems(); $(document).ajaxStop(function() { wrapMainPostLinks(); }); $(window).resize(function() { moveNavs(); wrapMainPostLinks(); });