var reserveCache; $(function () { $('.watch-webinar').click(function () { var url = "http://www.youtube.com/embed/"; var id = $(this).parents('.past-webinar').data('id'); $('#webinar-modal').find('iframe').attr('src', url+id+'?autoplay=1'); $('#webinar-modal').modal('show'); analytics.track('Webinars: Watch Recorded', {webinar: id}); }); $('.btn-webinar').click(function (event) { // show register form if user is guess if (!logged_in){ $('#register-modal').modal(); reserveCache = $(this); event.preventDefault(); return false; } // begin to webinar product register module if user is authenticated var t = $(this); webinarRegister(t); return false; }); $('.webinar-more').click(function () { var t = $(this); t.parent().addClass('hide'); t.parent().siblings('.webinar-long').removeClass('hide'); analytics.track('Webinars: Clicked Read More'); return false; }); $('.webinar-less').click(function () { var t = $(this); t.parent().addClass('hide'); t.parent().siblings('.webinar-short').removeClass('hide'); analytics.track('Webinars: Clicked Read Less'); return false; }); $('.webinar-link input').click(function () { $(this).select(); }); // $(document).click(function () { // $('.calendar-menu').addClass('hide'); // }); // $('.btn-calendar').click(function () { // $(this).siblings('.calendar-menu').toggleClass('hide'); // return false; // }); }); var webinarRetry = function (webinarRow, secondsLeft) { if (secondsLeft > 0) { webinarRow.find('.webinar-free, .webinar-seats').addClass('hide'); webinarRow.find('.webinar-error').removeClass('hide').find('.webinar-seconds').text(secondsLeft); setTimeout(function () { webinarRetry(webinarRow, secondsLeft - 1)}, 1000); } else { webinarRow.find('.webinar-free, .webinar-seats').removeClass('hide'); webinarRow.find('.webinar-error').addClass('hide'); webinarRow.find('.btn-webinar').removeAttr('disabled'); } }; // reserve seat for webinar product - extract and reused from master's <$('.btn-webinar').click> function function webinarRegister(t) { var a = t.parents('.webinar-actions'); t.attr('disabled', 'disabled'); data_key = t.attr('data-key'); $.post('/product/webinars/register/', {'webinar_key': data_key.toString()}, function (data) { t.removeAttr('disabled'); a.find('.webinar-registration').addClass('hide'); a.find('.webinar-registered').removeClass('hide'); $('.btn-store').html('Continue to Store →'); analytics.track('Webinars: Registered', {webinar: data_key.toString(), page: webinar_page}); }) .error(function () { webinarRetry(a, 8); }); } // let users know that they have registered successfully by ajax since the web does not refresh function registeredNotify(){ // create popover messages for user's menu profile $("#nav-profile").popover({ trigger : "manual", placement: "bottom", html: true, title: "Congratulation", content: "

You have successfully registered

", delay: { show: 2000, hide: 2000 }, }); // active the messages and auto hide for 5 secs. $("#nav-profile").popover('show'); $(".reg-notify-title").css('color','black'); $(".reg-notify-content").css('color', '#228b22'); setTimeout(function () { $("#nav-profile").popover('hide'); }, 5000); }