$(document).ready(function() { decorateScrollerLinks(); initializeWebinarInfo(); // handleAlert(); }); function decorateScrollerLinks() { $("a[href*='#']:not([data-lity],[data-toggle='tab'])").attr({ "data-scrollto": function () { return $(this).attr("href").replace(/\./g, '\\.'); }, "data-offset": "0", "data-easing": "easeInOutCubic" // see http://easings.net/ }); } function initializeWebinarInfo() { // return in non-webinar pages if ($("#webinar-start-time").length == 0) { return; } var webinarStartTime = $("#webinar-start-time").text(); var webinarEndTime = $("#webinar-end-time").text(); var dateFormat = "YYYY/MM/DD HH:mm"; var webinarStartTimeCET = moment.tz(webinarStartTime, dateFormat, 'Europe/Budapest'); var webinarStartTimeLocalized = webinarStartTimeCET.tz(moment.tz.guess()); if (webinarStartTimeLocalized > moment()) { var timerId = countdown( webinarStartTimeLocalized, function (ts) { var timeString = ts.toString(); if (timeString === '') { window.clearInterval(timerId); document.getElementById('webinar-timer').innerHTML = ''; } else { document.getElementById('webinar-timer').innerHTML = 'Webinar starts in: ' + ts.toString(); } }, countdown.DAYS | countdown.HOURS | countdown.MINUTES | countdown.SECONDS); } var friendlyDateFormat = "ddd, D MMM - HH:mm"; $("#webinar-table-time #europe-gmt").prepend(webinarStartTimeCET.tz('Etc/GMT').format(friendlyDateFormat)); $("#webinar-table-time #europe-cet").prepend(webinarStartTimeCET.tz('Europe/Budapest').format(friendlyDateFormat)); $("#webinar-table-time #europe-bst").prepend(webinarStartTimeCET.tz('Europe/London').format(friendlyDateFormat)); $("#webinar-table-time #us-east").prepend(webinarStartTimeCET.tz('America/New_York').format(friendlyDateFormat)); $("#webinar-table-time #us-west").prepend(webinarStartTimeCET.tz('America/Los_Angeles').format(friendlyDateFormat)); $("#webinar-table-time #australia").prepend(webinarStartTimeCET.tz('Australia/Sydney').format(friendlyDateFormat)); $("#webinar-table-duration").prepend(moment(webinarEndTime, dateFormat).diff(moment(webinarStartTime, dateFormat), 'minutes')); } (function($) { (function($) { $.fn.sticky = function(options) { var settings = $.extend({ fixedTop: 50, stopAtBottom: 0 }, options ); return this.each(function() { var body = $("body"); var box = $(this); var shouldBeFixed = function() { return body.scrollTop() > box.data("initialOffset").top - settings.fixedTop; }; var shouldBeStopped = function() { return body.scrollTop() > body.height() - settings.fixedTop - settings.stopAtBottom - box.height(); }; var setStickyState = function(sticky) { box.css({ "position": sticky ? "fixed" : "", "top": sticky ? settings.fixedTop : "", "left": sticky ? box.data("initialOffset").left : "" }); }; var setStoppedState = function() { var adjustedFixedTop = settings.fixedTop - (body.scrollTop() - (body.height() - settings.fixedTop - settings.stopAtBottom - box.height())); box.css({ "position": "fixed", "top": adjustedFixedTop, "left": box.data("initialOffset").left }); }; var refreshPositions = function() { // recalculate position after a window resize setStickyState(false); box.data("initialOffset", box.offset()); refreshStickyState(); }; var refreshStickyState = function() { if (shouldBeFixed()) { if (shouldBeStopped()) { setStoppedState(); } else { setStickyState(true); } } else { setStickyState(false); } }; refreshPositions(); // initialize before adding any event handlers $(window).on("scroll", debounce(refreshStickyState, 10)) .resize(debounce(refreshPositions, 10)); }); }; })(jQuery); $("#blog-post-share-links").sticky({ stopAtBottom: 520 // do not let the share buttons "slide over" the page footer even if window height is small }); $("#blog-post-subscribe").sticky({ fixedTop: window.innerHeight - $("#blog-post-subscribe").height() - 20, stopAtBottom: 520 }); })(jQuery); // Returns a function, that, as long as it continues to be invoked, will not // be triggered. The function will be called after it stops being called for // N milliseconds. If `immediate` is passed, trigger the function on the // leading edge, instead of the trailing. // Source: https://davidwalsh.name/javascript-debounce-function function debounce(func, wait, immediate) { var timeout; return function() { var context = this, args = arguments; var later = function() { timeout = null; if (!immediate) func.apply(context, args); }; var callNow = immediate && !timeout; clearTimeout(timeout); timeout = setTimeout(later, wait); if (callNow) func.apply(context, args); }; } function openTwitterPopup(type, url, title, w, h) { var left = (screen.width/2)-(w/2); var top = (screen.height/2)-(h/2); return window.open(url + "&url=" + encodeURI(window.location.href) + ("tweetable" === type ? "&via=MidoriGlobal" : ""), title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left); } function handleAlert() { if( $.cookie('alert-box') !== 'closed' ) { $('#alert-container').html('
We're hiring exceptional Java developers! (remote work)
') } $('.close').click(function( e ) { e.preventDefault(); var date = new Date(); var minutes = 14*24*60; // once per every two weeks date.setTime(date.getTime() + (minutes*60*1000)); $.cookie('alert-box', 'closed', { path: '/', expires: date }); }); }