$(document).ready(function() { $(this).on("click keydown", ".x-members-list > div", function(event) { if (event.type === "click" || event.which === 13 || event.which === 32) { $(this).stop().toggleClass("on"); if ($(this).hasClass("on")) { $(this).animate({ width: "504px"}, 300, function() { $(this).find("div").first().slideDown(300); }); } else { $(this).find("div").first().slideUp(300, function() { $(this).parent().animate({ width: "240px"}, 300); }); } } }); var x_pause; $(window).resize(function() { clearTimeout(x_pause); x_pause = setTimeout(x_video, 100); }); function x_video() { if($(this).width() >= 1779) { $("#x-ambient-video source").attr("src", $("#x-ambient-video source").data("2400x600")); } else if ($(this).width() >= 1084) { $("#x-ambient-video source").attr("src", $("#x-ambient-video source").data("1600x600")); } else { $("#x-ambient-video source").attr("src", $("#x-ambient-video source").data("1200x800")); } $("#x-ambient-video")[0].load(); } x_video(); });