$(document).ready(function () { // Top Slider activation $('#home-top-slider .flexslider').flexslider({ slideshow: false, controlNav: false, keyboard: true, directionNav: true, multipleKeyboard: true, animationLoop: true, pause: true, pauseOnAction: false, pauseOnHover: false, pausePlay: true, prevText:'', nextText:'', smoothHeight: true, animation: "slide", animationSpeed: 700, randomize: false, after: function(){ $('.c-slide a').attr('tabindex', '-1'); $('.flex-active-slide a').attr('tabindex', '0'); } }); $('.c-slide a').attr('tabindex', '-1'); $('.flex-active-slide a').attr('tabindex', '0'); $('.flexslider .flex-nav-prev a').attr('aria-label', 'Previous slide'); $('.flexslider .flex-nav-next a').attr('aria-label', 'Next slide'); // Photo Slider activation $('#photo-slider .flexslider').flexslider({ slideshow: false, prevText:'', nextText:'', animation: "slide" }); // JQuery Advanced News Ticker activation var i = 1; var nt = $('#updates-scroller').newsTicker({ max_rows: 1, prevButton: $('#prev-update'), nextButton: $('#next-update'), stopButton: $('#updates-pause'), startButton: $('#updates-play'), autostart: ($("#updates-scroller > li").length > 1 ? 1 : 0) }); $("#updates-pause, #updates-play").click(function () { $('#updates-play').toggle(); $('#updates-pause').toggle(); }); $('#updates-hide').click(function () { $('#updates').toggleClass('hidden'); $('#updates-play').show(); $('#updates-pause').hide(); nt.newsTicker('stop'); }); $('#updates-show').click(function () { $('#updates').toggleClass('hidden'); }); $(window).resize(function () { var visibleHeight = $('#updates-scroller li:visible').height(); visibleHeight = visibleHeight - 1; $('#updates-scroller').animate({ 'height': visibleHeight }, 100); }); if ($("#updates-scroller > li").length <= 1) { $('#updates-controls').hide(); } /***/ /** var i = 1; $('#updates-scroller').show(); $('#updates-scroller').newsTicker({ max_rows: 1, prevButton: $('#prev-update'), nextButton: $('#next-update'), movingUp: function () { if (i == $('#updates-number span:last-child').html()) { i = 1; } else { i++; } $('#updates-number span:first-child').html(i) }, movingDown: function () { if (i == 1) { i = $('#updates-number span:last-child').html(); } else { i--; } $('#updates-number span:first-child').html(i) }, autostart: ($("#updates-scroller > li").length > 1 ? 1 : 0) }); $('#updates-number span:last-child').html($("#updates-scroller > li").length) $(window).resize(function () { var visibleHeight = $('#updates-scroller li:visible').height(); visibleHeight = visibleHeight - 1; $('#updates-scroller').animate({ 'height': visibleHeight }, 100); }); /**/ // Events by day // init $('.list-module #events-detail > div').hide(); var currentDetail = $('.list-module .events li.current a span:nth-of-type(2)').html() + $( '.list-module .events li.current a span:first-child').html(); $('#' + currentDetail).show(); // hover $(".list-module .events li").mouseover(function () { $('.list-module #events-detail > div').hide(); var hoverDetail = $(this).find('span:nth-of-type(2)').html() + $(this).find('span:first-child').html() $('#' + hoverDetail).show(); }); $(".list-module .events").mouseout(function () { $('.list-module #events-detail > div').hide(); $('#' + currentDetail).show(); }); $(".list-module .events li").focusin(function () { $('.list-module #events-detail > div').hide(); var hoverDetail = $(this).find('span:nth-of-type(2)').html() + $(this).find('span:first-child').html() $('#' + hoverDetail).show(); }); $(".list-module .events").focusout(function () { $('.list-module #events-detail > div').hide(); $('#' + currentDetail).show(); }); $('#frmSubscribe').submit(function( event ) { event.preventDefault(); $.post('https://program.unisdr.org/community-cloud-api/?nocache='+(Math.random()*1000000), $('#frmSubscribe').serialize()).done(function( data ) { //var objResult = jQuery.parseJSON(data); //if (objResult.success) { $('#signupHeader').addClass('hide'); $('#signupMsg').addClass('hide'); $('#frmSubscribe').addClass('hide'); $('#signupHeaderConfirm').removeClass('hide'); $('#signupMsgConfirm').removeClass('hide'); } }); }); $('input[name=email]').keyup(function(){ if ($(this).val()) $('#btnSubscribe').removeAttr('disabled'); else $('#btnSubscribe').attr('disabled', 'disabled'); }); document.querySelector( "input" ).addEventListener("input", function (event) { if (this.validity.typeMismatch || this.validity.patternMismatch) { this.setCustomValidity("Please enter an email address in a valid format"); } else { this.setCustomValidity(""); } }); $('#twitter-tabs a').click(function(){ window.open($(this).attr('href')) }); window.twttr = (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0], t = window.twttr || {}; if (d.getElementById(id)) return t; js = d.createElement(s); js.id = id; js.src = "https://platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js, fjs); t._e = []; t.ready = function(f) { t._e.push(f); }; return t; }(document, "script", "twitter-wjs")); });