datamad2017/js/scripts.js

313 lines
13 KiB
JavaScript
Raw Permalink Normal View History

2014-07-28 21:27:01 +02:00
(function($) {
$(document).ready(function() {
$(window).load(function() {
2014-08-25 13:15:21 +02:00
$('#st-container').removeClass('disable-scrolling');
$('#loading-animation').fadeOut();
$('#preloader').delay(350).fadeOut(800);
initGooglePlus();
2014-08-25 13:15:21 +02:00
equalheight('.same-height');
2014-07-28 21:27:01 +02:00
});
if ($(window).width() > 1500) {
2014-08-14 23:27:17 +02:00
$('.effect-wrapper').addClass('col-lg-3');
2014-07-28 21:27:01 +02:00
}
if ($(window).width() < 768) {
$('.animated').removeClass('animated').removeClass('hiding');
$('.stat span').removeClass('timer');
2014-08-14 23:27:17 +02:00
$('.timeslot-label').addClass('stick-label');
2014-07-28 21:27:01 +02:00
}
if ($(window).height() < 512) {
$('#bottom-navlinks').removeClass('bottom-navlinks').addClass('bottom-navlinks-small');
}
if ($(window).scrollTop() >= 100) {
$('#top-header').addClass('after-scroll');
$('#logo-header .logo').removeClass('logo-light').addClass('logo-dark');
2014-07-28 21:27:01 +02:00
}
$(window).scroll(function() {
var scroll = $(this).scrollTop();
var header = $('#top-header');
var logo = $('#logo-header .logo');
var buyButton = $('.right-nav-button');
2014-08-15 16:02:40 +02:00
var topOffset = header.height() + $('.track-header').height();
2014-07-28 21:27:01 +02:00
if (scroll >= 100) {
header.addClass('after-scroll');
logo.removeClass('logo-light').addClass('logo-dark');
} else {
header.removeClass('after-scroll');
logo.removeClass('logo-dark').addClass('logo-light');
2014-07-28 21:27:01 +02:00
}
if (scroll >= $('.top-section').height() && $(window).width() > 767) {
buyButton.removeClass('right-nav-button-hidden');
} else if (scroll < $('.top-section').height() && $(window).width() > 767){
buyButton.addClass('right-nav-button-hidden');
2014-07-28 21:27:01 +02:00
}
2014-08-14 23:27:17 +02:00
$('.slot').each(function() {
var currentPosition = $(this).offset().top - scroll;
var offsetActivator = topOffset + $(this).find('.slot-title').height();
2014-08-25 13:15:21 +02:00
if (currentPosition <= offsetActivator && currentPosition >= 0) {
2014-08-15 16:02:40 +02:00
$('.track-header.sticky').find('.slot-detail').html($(this).data('slotDetail'));
2014-08-14 23:27:17 +02:00
}
});
2014-07-28 21:27:01 +02:00
});
2014-08-25 13:15:21 +02:00
$(window).resize(function() {
if ($(window).width() > 1500) {
$('.effect-wrapper').addClass('col-lg-3');
2014-07-28 21:27:01 +02:00
} else {
2014-08-25 13:15:21 +02:00
$('.effect-wrapper').removeClass('col-lg-3');
}
if ($(window).width() < 768) {
$('.same-height').css('height', '100%');
$('.timeslot-label').addClass('stick-label');
} else {
$('.timeslot-label').removeClass('stick-label');
if (container.hasClass('st-menu-open')) {
container.removeClass('st-menu-open');
$('body').css('overflow', 'auto');
2014-07-28 21:27:01 +02:00
}
2014-08-25 13:15:21 +02:00
equalheight('.same-height');
}
if ($(window).height() < 512) {
$('.st-menu').addClass('scrollable');
$('#bottom-navlinks').removeClass('bottom-navlinks').addClass('bottom-navlinks-small');
} else {
$('.st-menu').removeClass('scrollable');
$('#bottom-navlinks').removeClass('bottom-navlinks-small').addClass('bottom-navlinks');
2014-07-28 21:27:01 +02:00
}
});
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});
$(function() {
$('a[href=#]').click(function() {
event.preventDefault();
});
});
$(function() {
if(window.location.href.indexOf("schedule") > -1 && window.location.hash) {
var hash = window.location.hash;
$(hash).click();
}
});
2014-07-28 21:27:01 +02:00
2014-08-25 13:15:21 +02:00
$(function() {
var appear, delay, i, offset, _i, _len, _ref;
_ref = $(".appear-animation");
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
i = _ref[_i];
offset = i.offsetLeft + i.offsetTop;
delay = offset / 1000;
$(i).css('transition-delay', '' + (delay * 0.47) + 's');
$(i).css('transition-duration', '' + 0.2 + 's');
2014-07-28 21:27:01 +02:00
}
});
2014-08-25 13:15:21 +02:00
$('.appear-animation-trigger').appear(function() {
setTimeout(function() {
$('.appear-animation-trigger').parent('div').find('.appear-animation').addClass('visible');
}, 1000);
2014-07-28 21:27:01 +02:00
});
2014-08-25 13:15:21 +02:00
$('.animated').appear(function() {
var element = $(this);
var animation = element.data('animation');
var animationDelay = element.data('delay');
if (animationDelay) {
setTimeout(function() {
element.addClass(animation + " visible");
element.removeClass('hiding');
if (element.hasClass('counter')) {
element.find('.timer').countTo();
}
}, animationDelay);
2014-07-28 21:27:01 +02:00
} else {
2014-08-25 13:15:21 +02:00
element.addClass(animation + " visible");
element.removeClass('hiding');
if (element.hasClass('counter')) {
element.find('.timer').countTo();
}
2014-07-28 21:27:01 +02:00
}
2014-08-25 13:15:21 +02:00
}, {
accY: -150
2014-07-28 21:27:01 +02:00
});
2014-08-25 13:15:21 +02:00
equalheight = function(container) {
var currentTallest = 0,
currentRowStart = 0,
rowDivs = new Array(),
$el,
topPosition = 0;
$(container).each(function() {
$el = $(this);
$($el).height('auto')
topPostion = $el.position().top;
if (currentRowStart != topPostion) {
for (currentDiv = 0; currentDiv < rowDivs.length; currentDiv++) {
rowDivs[currentDiv].height(currentTallest);
}
rowDivs.length = 0; // empty the array
currentRowStart = topPostion;
currentTallest = $el.height();
rowDivs.push($el);
} else {
rowDivs.push($el);
currentTallest = (currentTallest < $el.height()) ? ($el.height()) : (currentTallest);
}
for (currentDiv = 0; currentDiv < rowDivs.length; currentDiv++) {
rowDivs[currentDiv].height(currentTallest);
}
});
}
2014-07-28 21:27:01 +02:00
//Side menu
var container = $('.st-container');
$('#menu-trigger').click(function(event) {
event.stopPropagation();
container.toggleClass('st-menu-open');
2014-07-28 21:27:01 +02:00
});
$('.st-pusher').click(function() {
if (container.hasClass('st-menu-open')) {
container.removeClass('st-menu-open');
}
});
2014-08-25 13:15:21 +02:00
$('.track-header').each(function() {
var slot = $(this).closest('.schedule-table').find('.slot').first();
var scheduleFirstSlotText;
while (scheduleFirstSlotText === undefined) {
scheduleFirstSlotText = slot.data('slotDetail');
slot = slot.next();
2014-07-28 21:27:01 +02:00
}
2014-08-25 13:15:21 +02:00
$(this).find('.slot-detail').html(scheduleFirstSlotText);
});
$('#post-section .post-body p').each(function() {
if ($(this).find('.feature-image').length) {
var url = $(this).find('.feature-image').prop('src');
$('#top-section').css('background-image', 'url(' + url + ')').addClass('enable-overlay');
2014-07-28 21:27:01 +02:00
}
});
2014-08-25 13:15:21 +02:00
$('.slider').each(function() {
$(this).find('.slider-item').first().addClass('slider-current-item').removeClass('hidden');
if ($(this).find('.slider-item').length > 1) {
$(this).closest('.speaker-item').find('.slider-next-item').removeClass('hidden');
}
2014-07-28 21:27:01 +02:00
});
2014-08-25 13:15:21 +02:00
$('.slider-next-item').click(function() {
var slider = $(this).closest('div');
var elem = slider.find('.slider-current-item').next();
2014-08-25 13:15:21 +02:00
if (elem.length) {
elem.addClass('slider-current-item').removeClass('hidden');
slider.find('.slider-current-item').first().removeClass('slider-current-item').addClass('hidden');
2014-08-25 13:15:21 +02:00
} else {
slider.find('.slider-item').first().addClass('slider-current-item').removeClass('hidden');
slider.find('.slider-current-item').last().removeClass('slider-current-item').addClass('hidden');
2014-08-25 13:15:21 +02:00
}
2014-07-28 21:27:01 +02:00
});
$('.modal').on('hidden.bs.modal', function () {
var iframe = $(this).find('iframe');
iframe.attr('src', iframe.attr('src'));
});
2014-11-14 20:36:58 +01:00
$('.slot').click(function() {
location.hash = $(this).attr('id');
});
2014-07-28 21:27:01 +02:00
2014-08-25 13:15:21 +02:00
2014-07-28 21:27:01 +02:00
if (typeof twitterFeedUrl !== 'undefined') {
2014-08-25 13:15:21 +02:00
$.getJSON(twitterFeedUrl, function(data) {
$.each(data, function(i, gist) {
2014-08-25 12:59:13 +02:00
var tweetElement = '<div class="tweet animated fadeInUp hidden"><p class="tweet-text">' + linkify(gist.text) + '</p><p class="tweet-meta">by <a href="https://twitter.com/' + gist.user.screen_name + '" target="_blank">@' + gist.user.screen_name + '</a></p></div>';
2014-07-28 21:27:01 +02:00
$('#tweets').append(tweetElement);
});
animateTweets();
});
function linkify(inputText) {
2014-08-25 13:15:21 +02:00
var replacedText, links1, links2, hashtags, profileLinks;
links1 = /(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim;
replacedText = inputText.replace(links1, '<a href="$1" target="_blank">$1</a>');
links2 = /(^|[^\/])(www\.[\S]+(\b|$))/gim;
replacedText = replacedText.replace(links2, '$1<a href="http://$2" target="_blank">$2</a>');
hashtags = /#(\S*)/g;
replacedText = replacedText.replace(hashtags, '<a href="https://twitter.com/search?q=%23$1" target="_blank">#$1</a>');
profileLinks = /\B@([\w-]+)/gm;
replacedText = replacedText.replace(profileLinks, '<a href="https://twitter.com/$1" target="_blank">@$1</a>');
2014-07-28 21:27:01 +02:00
return replacedText;
}
function animateTweets() {
var $tweets = $('#tweets').find('.tweet'),
i = 0;
$($tweets.get(0)).removeClass('hidden');
function changeTweets() {
var next = (++i % $tweets.length);
$($tweets.get(next - 1)).addClass('hidden');
$($tweets.get(next)).removeClass('hidden');
}
var interval = setInterval(changeTweets, 5000);
}
}
});
2017-10-10 23:59:00 +02:00
//Openstreetmap with leaflet
2017-10-11 02:21:54 +02:00
var mapOptions ={
2017-10-10 23:59:00 +02:00
zoomControl: false,
scrollWheelZoom: false,
2017-10-11 10:54:42 +02:00
zoom: 17,
minZoom: 17,
2017-10-10 23:59:00 +02:00
maxZoom: 18,
dragging: false
2017-10-11 02:21:54 +02:00
}
if ($(window).width() < 768) {
2017-10-11 10:54:42 +02:00
mapOptions.center = [40.41282,-3.69406];
2017-10-11 02:21:54 +02:00
}else{
mapOptions.center = [40.41063,-3.69366];
};
var map = L.map('canvas-map-osm', mapOptions);
2017-10-10 23:59:00 +02:00
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
L.marker([40.41082,-3.69366]).addTo(map)
2017-10-11 00:10:22 +02:00
.bindPopup('Medialab-Prado<br>Plaza de las Letras. Calle Alameda, 15, Madrid')
//.openPopup();
2017-10-10 23:59:00 +02:00
2014-07-28 21:27:01 +02:00
//Google plus
function initGooglePlus() {
2014-07-28 21:27:01 +02:00
var po = document.createElement('script');
po.type = 'text/javascript';
po.async = true;
po.src = 'https://apis.google.com/js/platform.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
}
2014-07-28 21:27:01 +02:00
// Google maps static
if (typeof staticGoogleMaps !== 'undefined') {
2015-03-14 01:10:59 +01:00
$('#canvas-map').addClass('image-section').css('background-image','url(https://maps.googleapis.com/maps/api/staticmap?zoom=17&center=' + mobileCenterMapCoordinates +'&size=' + $(window).width() + 'x700&scale=2&language=en&markers=icon:' + icon +'|'+ eventPlaceCoordinates +'&maptype=roadmap&style=visibility:on|lightness:40|gamma:1.1|weight:0.9&style=element:labels|visibility:off&style=feature:water|hue:0x0066ff&style=feature:road|visibility:on&style=feature:road|element:labels|saturation:-30)');
}
2014-07-28 21:27:01 +02:00
})(jQuery);