mirror of
https://github.com/medialab-prado/datamad2017.git
synced 2024-12-27 13:11:22 +01:00
1 line
No EOL
11 KiB
JavaScript
1 line
No EOL
11 KiB
JavaScript
(function(g){g(document).ready(function(){g("body").css("overflow","hidden");g(window).load(function(){var v=350,t=800;function u(){var x=g("#loading-animation"),w=g("#preloader");x.fadeOut();w.delay(v).fadeOut(t)}g("body").css("overflow","auto");u();d();r();setTimeout(function(){g(".explore").removeClass("hidden")},1000)});if(g(window).width()>1500){g(".effect-wrapper").each(function(){g(this).addClass("col-lg-3")})}if(g(window).width()<768){g(".animated").removeClass("animated").removeClass("hiding");g(".stat span").removeClass("timer")}if(g(window).height()<512){g("#bottom-navlinks").removeClass("bottom-navlinks").addClass("bottom-navlinks-small")}if(g(window).scrollTop()>=100){g("#top-header").addClass("after-scroll");g("#logo-header .logo").removeClass("logo-light").addClass("logo-dark")}g(window).scroll(function(){var t=g(this).scrollTop();var x=g("#top-header");var v=g("#logo-header .logo");var w=v.attr("src");var u=g("#right-nav-button");if(t>=100){x.addClass("after-scroll");v.removeClass("logo-light").addClass("logo-dark")}else{x.removeClass("after-scroll");v.removeClass("logo-dark").addClass("logo-light")}if(t>=g(window).height()){u.removeClass("right-nav-button-hidden")}else{u.addClass("right-nav-button-hidden")}});g(function(){var u=[];g(".rockstar-speakers-item").each(function(){u[u.length]=g(this).attr("data-id")});u=q(u);for(var t=0;t<4;t++){g("#rockstar-speaker-"+u[t]).removeClass("hidden")}});function q(w){for(var u,t,v=w.length;v;u=parseInt(Math.random()*v),t=w[--v],w[v]=w[u],w[u]=t){}return w}var n=parseInt(g(".increment-animation").attr("data-delay"));g(".increment-animation").not("hidden").each(function(t){g(this).attr("data-delay",t*n)});g(".animated").appear(function(){var u=g(this);var v=u.data("animation");var t=u.data("delay");if(t){setTimeout(function(){u.addClass(v+" visible");u.removeClass("hiding");if(u.hasClass("counter")){u.find(".timer").countTo()}},t)}else{u.addClass(v+" visible");u.removeClass("hiding");if(u.hasClass("counter")){u.find(".timer").countTo()}}},{accY:-150});g(function(){var w,u,v,z,y,t,x;x=g(".appear-animation");for(y=0,t=x.length;y<t;y++){v=x[y];z=v.offsetLeft+v.offsetTop;u=z/1000;g(v).css("transition-delay",""+(u*0.47)+"s");g(v).css("transition-duration",""+0.2+"s")}});g(".appear-animation-trigger").appear(function(){setTimeout(function(){g(".appear-animation-trigger").parent("div").find(".appear-animation").addClass("visible")},1000)});g(function(){g("a[href*=#]:not([href=#])").click(function(){if(location.pathname.replace(/^\//,"")==this.pathname.replace(/^\//,"")&&location.hostname==this.hostname){var t=g(this.hash);t=t.length?t:g("[name="+this.hash.slice(1)+"]");if(t.length){g("html,body").animate({scrollTop:t.offset().top},1000);return false}}})});g(function(){g("a[href=#]").click(function(){event.preventDefault()})});function r(){if(g(window).width()>767){g(".same-height-wrapper").each(function(){var t=0;g(".same-height").each(function(){var u=g(this).height();if(u>t){t=u}});g(".same-height").each(function(){g(this).height(t)})})}}g("#post-section .post-body p").each(function(){if(g(this).find(".feature-image").length){var t=g(this).find(".feature-image").prop("src");g("#top-section").css("background-image","url("+t+")").addClass("enable-overlay")}});g(".slider").each(function(){g(this).find(".slider-item").first().addClass("slider-current-item").removeClass("hidden");if(g(this).find(".slider-item").length>1){g(this).closest(".speaker-item").find(".slider-next-item").removeClass("hidden")}});g(".slider-next-item").click(function(){var t=g(this).closest(".speaker-item");var u=t.find(".slider-current-item").next();if(u.length){u.addClass("slider-current-item").removeClass("hidden");t.find(".slider-current-item").first().removeClass("slider-current-item").addClass("hidden")}else{t.find(".slider-item").first().addClass("slider-current-item").removeClass("hidden");t.find(".slider-current-item").last().removeClass("slider-current-item").addClass("hidden")}});var m=g(".st-container");g("#menu-trigger").click(function(u){u.stopPropagation();var w=g(window).scrollTop();var v=g(window).scrollLeft();var t=g(this).attr("data-effect");if(!m.hasClass("st-menu-open")){m.addClass(t).delay(25).addClass("st-menu-open");g("body").css("overflow","hidden")}else{m.removeClass("st-menu-open");g("body").css("overflow","auto")}});g(".st-pusher").click(function(){if(m.hasClass("st-menu-open")){m.removeClass("st-menu-open");g("body").css("overflow","auto")}});g(window).resize(function(){if(g(window).width()>1500){g(".effect-wrapper").each(function(){g(this).addClass("col-lg-3")})}else{g(".effect-wrapper").each(function(){g(this).removeClass("col-lg-3")})}if(g(window).width()>767){if(m.hasClass("st-menu-open")){m.removeClass("st-menu-open");g("body").css("overflow","auto")}r()}var t=g("#bottom-navlinks");if(g(window).height()<512){t.removeClass("bottom-navlinks").addClass("bottom-navlinks-small")}else{t.removeClass("bottom-navlinks-small").addClass("bottom-navlinks")}if(g(window).width()<768){g(".same-height").css("height","100%")}});g(".modal").on("show.bs.modal",function(){g("body").css("overflow","hidden")});g(".modal").on("hide.bs.modal",function(){g("body").css("overflow","auto")});if(typeof twitterFeedUrl!=="undefined"){var p="http://query.yahooapis.com/v1/public/yql?q="+encodeURIComponent('select * from json where url="'+twitterFeedUrl+'"')+"&format=json&callback=?";g.getJSON(p,function(t){g.each(t.query.results.json.json,function(v,u){var w='<div class="tweet animated fadeInUp hidden"><p class="tweet-text">'+o(u.text)+'</p><p class="tweet-meta">by <a href="https://twitter.com/'+u.user.screen_name+' target="_blank">@'+u.user.screen_name+"</a></p></div>";g("#tweets").append(w)});s()});function o(y){var t,x,w,v,u;x=/(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim;t=y.replace(x,'<a href="$1" target="_blank">$1</a>');w=/(^|[^\/])(www\.[\S]+(\b|$))/gim;t=t.replace(w,'$1<a href="http://$2" target="_blank">$2</a>');v=/#(\S*)/g;t=t.replace(v,'<a href="https://twitter.com/search?q=%23$1" target="_blank">#$1</a>');u=/\B@([\w-]+)/gm;t=t.replace(u,'<a href="https://twitter.com/$1" target="_blank">@$1</a>');return t}function s(){var t=g("#tweets").find(".tweet"),v=0;g(t.get(0)).removeClass("hidden");function w(){var x=(++v%t.length);g(t.get(x-1)).addClass("hidden");g(t.get(x)).removeClass("hidden")}var u=setInterval(w,5000)}}});function d(){var m=document.createElement("script");m.type="text/javascript";m.async=true;m.src="https://apis.google.com/js/platform.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(m,n)}if(typeof googleMaps!=="undefined"){var a,b,l,c,j,k;var e=[];var i=new google.maps.DirectionsService();var h="custom_style";function f(){l=new google.maps.DirectionsRenderer({suppressMarkers:true});c=new google.maps.Geocoder();j=new google.maps.Polyline({strokeColor:"#03a9f4",strokeOpacity:1,strokeWeight:2});var x=[{stylers:[{lightness:40},{visibility:"on"},{gamma:0.9},{weight:0.4}]},{elementType:"labels",stylers:[{visibility:"on"}]},{featureType:"water",stylers:[{color:"#5dc7ff"}]},{featureType:"road",stylers:[{visibility:"off"}]}];var y=[{stylers:[{lightness:40},{visibility:"on"},{gamma:1.1},{weight:0.9}]},{elementType:"labels",stylers:[{visibility:"off"}]},{featureType:"water",stylers:[{color:"#5dc7ff"}]},{featureType:"road",stylers:[{visibility:"on"}]},{featureType:"road",elementType:"labels",stylers:[{saturation:-30}]}];var n={zoom:17,minZoom:2,scrollwheel:false,panControl:false,draggable:true,zoomControl:false,zoomControlOptions:{position:google.maps.ControlPosition.RIGHT_TOP},scaleControl:false,mapTypeControl:false,streetViewControl:false,center:centerMap,mapTypeControlOptions:{mapTypeIds:[google.maps.MapTypeId.ROADMAP,h]},mapTypeId:h};if(g(window).width()<768){n.center=mobileCenterMap}if(googleMaps=="logistics"){n.zoom=5;n.zoomControl=true}a=new google.maps.Map(document.getElementById("canvas-map"),n);var o=new google.maps.Marker({position:eventPlace,animation:google.maps.Animation.DROP,icon:icon,map:a});e.push(o);var p={name:"Default Style"};var s={name:"Zoomed Style"};var r=new google.maps.StyledMapType(x,p);var q=new google.maps.StyledMapType(y,s);a.mapTypes.set("default",r);a.mapTypes.set("zoomed",q);if(googleMaps==="logistics"){a.setMapTypeId("default");var w=(document.getElementById("location-input"));b=new google.maps.places.Autocomplete(w);google.maps.event.addListener(b,"place_changed",function(){o.setVisible(false);var C=b.getPlace();if(C.geometry=="undefined"||!C.geometry){return}var B="";if(C.address_components){B=[(C.address_components[0]&&C.address_components[0].short_name||""),(C.address_components[1]&&C.address_components[1].short_name||""),(C.address_components[2]&&C.address_components[2].short_name||"")].join(" ")}c.geocode({address:B},function(E,D){if(D==google.maps.GeocoderStatus.OK){k=E[0].geometry.location;A(k,"TRANSIT")}else{alert("Geocode was not successful for the following reason: "+D)}})})}else{a.setMapTypeId("zoomed")}function A(B,D){var C={origin:B,destination:eventPlace,travelMode:google.maps.TravelMode[D]};i.route(C,function(F,E){if(E==google.maps.DirectionsStatus.OK){a.setMapTypeId("zoomed");l.setMap(a);l.setDirections(F);var I=F.routes[0].legs[0];m(I.start_location);m(I.end_location);g("#distance").text(I.distance.text);g("#estimateTime").text(I.duration.text);g("#mode-select").val(D);g("#mode").removeClass("hidden");var H=g("#mode-icon use").attr("xlink:href");H=H.substring(0,H.indexOf("#")+1)+"icon-"+D.toLowerCase();g("#mode-icon use").attr("xlink:href",H)}else{if(E!=google.maps.DirectionsStatus.OK&&D!="DRIVING"){A(B,"DRIVING")}else{var J=j.getPath();J.push(B);J.push(eventPlace);m(B);m(eventPlace);var G=new google.maps.LatLngBounds();G.extend(B);G.extend(eventPlace);a.fitBounds(G);j.setMap(a);var K=Math.round(google.maps.geometry.spherical.computeDistanceBetween(B,eventPlace)/1000);g("#distance").text(K+" km");g("#estimateTime").text("");g("#find-flight").removeClass("hidden");g("#mode").addClass("hidden")}}});z();g("#find-way").addClass("location-active");u(B);g("#find-way h3").removeClass("fadeInUp").addClass("fadeOutDown")}function m(B){var C=new google.maps.Marker({position:B,map:a,icon:icon});e.push(C)}function v(C){var B=new google.maps.Marker({position:C,map:a});e.push(B)}function z(){for(var B=0;B<e.length;B++){e[B].setMap(null)}e=[]}function t(G){var D=a.getZoom(),F=50;var B=Math.abs(G-D);var E=(G>D)?1:-1;for(var C=0;C<B;C++){setTimeout(function(){D+=E;a.setZoom(D)},(C+1)*F)}}function u(B){c.geocode({latLng:B},function(E,D){if(D==google.maps.GeocoderStatus.OK&&E[1]){var C=E[1].address_components;g.each(C,function(F,G){if(G.types[0]=="locality"){g("#result-name").text(G.long_name);return false}})}})}g("#mode-select").change(function(){var B=g(this).val();A(k,B)});g("#direction-locate").click(function(){if(navigator.geolocation){navigator.geolocation.getCurrentPosition(function(B){k=new google.maps.LatLng(B.coords.latitude,B.coords.longitude);A(k,"TRANSIT")})}});g("#direction-cancel").click(function(){g("#find-way").removeClass("location-active");g("#location-input").val("");g("#find-flight").addClass("hidden");z();l.setMap(null);j.setMap(null);a.setMapTypeId("default");a.panTo(eventPlace);if(g(window).width()<768){a.setCenter(mobileCenterMap)}else{a.setCenter(centerMap)}m(eventPlace);t(5);g("#find-way h3").removeClass("fadeOutDown").addClass("fadeInUp")})}google.maps.event.addDomListener(window,"load",f)}})(jQuery); |