mirror of
https://github.com/medialab-prado/datamad2017.git
synced 2024-12-26 20:51:22 +01:00
1 line
No EOL
12 KiB
JavaScript
1 line
No EOL
12 KiB
JavaScript
(function(g){g(document).ready(function(){g(window).load(function(){g("#st-container").removeClass("disable-scrolling");g("#loading-animation").fadeOut();g("#preloader").delay(350).fadeOut(800);d();equalheight(".same-height")});if(g(window).width()>1500){g(".effect-wrapper").addClass("col-lg-3")}if(g(window).width()<768){g(".animated").removeClass("animated").removeClass("hiding");g(".stat span").removeClass("timer");g(".timeslot-label").addClass("stick-label")}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 q=g(this).scrollTop();var u=g("#top-header");var t=g("#logo-header .logo");var r=g(".right-nav-button");var s=u.height()+g(".track-header").height();if(q>=100){u.addClass("after-scroll");t.removeClass("logo-light").addClass("logo-dark")}else{u.removeClass("after-scroll");t.removeClass("logo-dark").addClass("logo-light")}if(q>=g(".top-section").height()&&g(window).width()>767){r.removeClass("right-nav-button-hidden")}else{if(q<g(".top-section").height()&&g(window).width()>767){r.addClass("right-nav-button-hidden")}}g(".slot").each(function(){var w=g(this).offset().top-q;var v=s+g(this).find(".slot-title").height();if(w<=v&&w>=0){g(".track-header.sticky").find(".slot-detail").html(g(this).data("slotDetail"))}})});g(window).resize(function(){if(g(window).width()>1500){g(".effect-wrapper").addClass("col-lg-3")}else{g(".effect-wrapper").removeClass("col-lg-3")}if(g(window).width()<768){g(".same-height").css("height","100%");g(".timeslot-label").addClass("stick-label")}else{g(".timeslot-label").removeClass("stick-label");if(n.hasClass("st-menu-open")){n.removeClass("st-menu-open");g("body").css("overflow","auto")}equalheight(".same-height")}if(g(window).height()<512){g(".st-menu").addClass("scrollable");g("#bottom-navlinks").removeClass("bottom-navlinks").addClass("bottom-navlinks-small")}else{g(".st-menu").removeClass("scrollable");g("#bottom-navlinks").removeClass("bottom-navlinks-small").addClass("bottom-navlinks")}});g(function(){g("a[href*=#]:not([href=#])").click(function(){if(location.pathname.replace(/^\//,"")==this.pathname.replace(/^\//,"")&&location.hostname==this.hostname){var q=g(this.hash);q=q.length?q:g("[name="+this.hash.slice(1)+"]");if(q.length){g("html,body").animate({scrollTop:q.offset().top},1000);return false}}})});g(function(){g("a[href=#]").click(function(){event.preventDefault()})});g(function(){if(window.location.href.indexOf("schedule")>-1&&window.location.hash){var q=window.location.hash;g(q).click()}});g(function(){var t,r,s,w,v,q,u;u=g(".appear-animation");for(v=0,q=u.length;v<q;v++){s=u[v];w=s.offsetLeft+s.offsetTop;r=w/1000;g(s).css("transition-delay",""+(r*0.47)+"s");g(s).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(".animated").appear(function(){var r=g(this);var s=r.data("animation");var q=r.data("delay");if(q){setTimeout(function(){r.addClass(s+" visible");r.removeClass("hiding");if(r.hasClass("counter")){r.find(".timer").countTo()}},q)}else{r.addClass(s+" visible");r.removeClass("hiding");if(r.hasClass("counter")){r.find(".timer").countTo()}}},{accY:-150});equalheight=function(r){var q=0,s=0,v=new Array(),u,t=0;g(r).each(function(){u=g(this);g(u).height("auto");topPostion=u.position().top;if(s!=topPostion){for(currentDiv=0;currentDiv<v.length;currentDiv++){v[currentDiv].height(q)}v.length=0;s=topPostion;q=u.height();v.push(u)}else{v.push(u);q=(q<u.height())?(u.height()):(q)}for(currentDiv=0;currentDiv<v.length;currentDiv++){v[currentDiv].height(q)}})};var n=g(".st-container");g("#menu-trigger").click(function(q){q.stopPropagation();n.toggleClass("st-menu-open")});g(".st-pusher").click(function(){if(n.hasClass("st-menu-open")){n.removeClass("st-menu-open")}});g(".track-header").each(function(){var r=g(this).closest(".schedule-table").find(".slot").first();var q;while(q===undefined){q=r.data("slotDetail");r=r.next()}g(this).find(".slot-detail").html(q)});g("#post-section .post-body p").each(function(){if(g(this).find(".feature-image").length){var q=g(this).find(".feature-image").prop("src");g("#top-section").css("background-image","url("+q+")").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 r=g(this).closest("div");var q=r.find(".slider-current-item").next();if(q.length){q.addClass("slider-current-item").removeClass("hidden");r.find(".slider-current-item").first().removeClass("slider-current-item").addClass("hidden")}else{r.find(".slider-item").first().addClass("slider-current-item").removeClass("hidden");r.find(".slider-current-item").last().removeClass("slider-current-item").addClass("hidden")}});g(".modal").on("hidden.bs.modal",function(){var q=g(this).find("iframe");q.attr("src",q.attr("src"))});g(".slot").click(function(){location.hash=g(this).attr("id")});if(typeof twitterFeedUrl!=="undefined"){g.getJSON(twitterFeedUrl,function(q){g.each(q,function(s,r){var t='<div class="tweet animated fadeInUp hidden"><p class="tweet-text">'+o(r.text)+'</p><p class="tweet-meta">by <a href="https://twitter.com/'+r.user.screen_name+'" target="_blank">@'+r.user.screen_name+"</a></p></div>";g("#tweets").append(t)});p()});function o(v){var s,r,q,u,t;r=/(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim;s=v.replace(r,'<a href="$1" target="_blank">$1</a>');q=/(^|[^\/])(www\.[\S]+(\b|$))/gim;s=s.replace(q,'$1<a href="http://$2" target="_blank">$2</a>');u=/#(\S*)/g;s=s.replace(u,'<a href="https://twitter.com/search?q=%23$1" target="_blank">#$1</a>');t=/\B@([\w-]+)/gm;s=s.replace(t,'<a href="https://twitter.com/$1" target="_blank">@$1</a>');return s}function p(){var q=g("#tweets").find(".tweet"),s=0;g(q.get(0)).removeClass("hidden");function t(){var u=(++s%q.length);g(q.get(u-1)).addClass("hidden");g(q.get(u)).removeClass("hidden")}var r=setInterval(t,5000)}}});var a=L.map("canvas-map-osm",{center:[40.41161,-3.69406],zoomControl:false,scrollWheelZoom:false,zoom:18,minZoom:18,maxZoom:18,dragging:false});L.tileLayer("http://{s}.tile.osm.org/{z}/{x}/{y}.png",{attribution:'© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'}).addTo(a);L.marker([40.41082,-3.69366]).addTo(a).bindPopup("Medialab-Prado").openPopup();function d(){var n=document.createElement("script");n.type="text/javascript";n.async=true;n.src="https://apis.google.com/js/platform.js";var o=document.getElementsByTagName("script")[0];o.parentNode.insertBefore(n,o)}if(typeof staticGoogleMaps!=="undefined"){g("#canvas-map").addClass("image-section").css("background-image","url(https://maps.googleapis.com/maps/api/staticmap?zoom=17¢er="+mobileCenterMapCoordinates+"&size="+g(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)")}if(typeof googleMaps!=="undefined"){var m,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 z=[{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 A=[{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 p={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){p.center=mobileCenterMap}if(googleMaps=="logistics"){p.zoom=5;p.zoomControl=true}a=new google.maps.Map(document.getElementById("canvas-map"),p);var q=new google.maps.Marker({position:eventPlace,animation:google.maps.Animation.DROP,icon:icon,map:a});e.push(q);var r={name:"Default Style"};var u={name:"Zoomed Style"};var t=new google.maps.StyledMapType(z,r);var s=new google.maps.StyledMapType(A,u);a.mapTypes.set("default",t);a.mapTypes.set("zoomed",s);if(googleMaps==="logistics"){a.setMapTypeId("default");var y=(document.getElementById("location-input"));b=new google.maps.places.Autocomplete(y);google.maps.event.addListener(b,"place_changed",function(){q.setVisible(false);var E=b.getPlace();if(E.geometry=="undefined"||!E.geometry){return}var D="";if(E.address_components){D=[(E.address_components[0]&&E.address_components[0].short_name||""),(E.address_components[1]&&E.address_components[1].short_name||""),(E.address_components[2]&&E.address_components[2].short_name||"")].join(" ")}c.geocode({address:D},function(G,F){if(F==google.maps.GeocoderStatus.OK){k=G[0].geometry.location;C(k,"TRANSIT")}else{alert("Geocode was not successful for the following reason: "+F)}})})}else{a.setMapTypeId("zoomed")}function C(D,F){var E={origin:D,destination:eventPlace,travelMode:google.maps.TravelMode[F]};i.route(E,function(H,G){if(G==google.maps.DirectionsStatus.OK){a.setMapTypeId("zoomed");l.setMap(a);l.setDirections(H);var K=H.routes[0].legs[0];n(K.start_location);n(K.end_location);g("#distance").text(K.distance.text);g("#estimateTime").text(K.duration.text);g("#mode-select").val(F);g("#mode").removeClass("hidden");var J=g("#mode-icon use").attr("xlink:href");J=J.substring(0,J.indexOf("#")+1)+"icon-"+F.toLowerCase();g("#mode-icon use").attr("xlink:href",J)}else{if(G!=google.maps.DirectionsStatus.OK&&F!="DRIVING"){C(D,"DRIVING")}else{var M=j.getPath();M.push(D);M.push(eventPlace);n(D);n(eventPlace);var I=new google.maps.LatLngBounds();I.extend(D);I.extend(eventPlace);a.fitBounds(I);j.setMap(a);var N=Math.round(google.maps.geometry.spherical.computeDistanceBetween(D,eventPlace)/1000);g("#distance").text(N+" km");g("#estimateTime").text("");g("#find-flight").removeClass("hidden");g("#mode").addClass("hidden")}}});B();g("#find-way").addClass("location-active");w(D);g("#find-way h3").removeClass("fadeInUp").addClass("fadeOutDown")}function o(){if(navigator.geolocation){navigator.geolocation.getCurrentPosition(function(D){k=new google.maps.LatLng(D.coords.latitude,D.coords.longitude);C(k,"TRANSIT")})}}function n(D){var E=new google.maps.Marker({position:D,map:a,icon:icon});e.push(E)}function x(E){var D=new google.maps.Marker({position:E,map:a});e.push(D)}function B(){for(var D=0;D<e.length;D++){e[D].setMap(null)}e=[]}function v(I){var F=a.getZoom(),H=50;var D=Math.abs(I-F);var G=(I>F)?1:-1;for(var E=0;E<D;E++){setTimeout(function(){F+=G;a.setZoom(F)},(E+1)*H)}}function w(D){c.geocode({latLng:D},function(G,F){if(F==google.maps.GeocoderStatus.OK&&G[1]){var E=G[1].address_components;g.each(E,function(H,I){if(I.types[0]=="locality"){g("#result-name").text(I.long_name);return false}})}})}g("#mode-select").change(function(){var D=g(this).val();C(k,D)});g("#direction-locate").click(o);g("#direction-cancel").click(function(){g("#find-way").removeClass("location-active");g("#location-input").val("");g("#find-flight").addClass("hidden");B();l.setMap(null);j.setMap(null);a.setMapTypeId("default");a.panTo(eventPlace);if(g(window).width()<768){a.setCenter(mobileCenterMap)}else{a.setCenter(centerMap)}n(eventPlace);v(5);g("#find-way h3").removeClass("fadeOutDown").addClass("fadeInUp")});if(typeof autoDirectionEnabled!=="undefined"&&autoDirectionEnabled==true){o()}}google.maps.event.addDomListener(window,"load",f)}})(jQuery); |