$(function(){
$('html').addClass($('#mobile-tester').is(':visible') ? 'mobile' : 'no-mobile');
});
$(function(){
$('.show-shares').click(function(e){
e.preventDefault();
$(this).parent().addClass('active');
});
$('.share-buttons ul li a').click(function(e){
e.preventDefault();
if ($(this).hasClass('email-this'))
return;
var $container = $(this).closest('li.video-post');
var data = JSON.parse($('.social-metadata', $container).text());
switch ($(this).parent().get(0).className) {
case 'share-fb': share_fb_wnd(data.url, data.title); break;
case 'share-tw': share_tw_wnd(data.url, data.title); break;
case 'share-re': share_rd_wnd(data.url); break;
}
});
});
$(function(){
$('li.video-post a.expand-video').click(function(e){
// allow middle-click to pass-thru
if (e.which == 2)
return;
// allow ctrl+click to pass-thru
if (e.ctrlKey)
return;
e.preventDefault();
var $li = $(this).closest('li.video-post');
if ($li.hasClass('video-expanded')) {
$('.close-video', $li).click();
return;
}
$li.addClass('video-expanded');
var id = $(this).data('id');
var $e = $('#embed-' + id);
var $eouter = $e.parent();// .video-embed
var h = $e.html();
if (!$li.hasClass('did-expand')) {
$li.addClass('did-expand');
var view_nonce = $li.data('viewnonce');
var view_hash = $li.data('viewhash');
$('body').append('');
}
if ($('html').hasClass('mobile'))
$eouter.prependTo($('.image-box', $li));
var $summary = $('.video-summary.complete', $li);
if (!$summary.data('fetched')) {
$.post(
'/vs6/api/summary/' + id,
function(data) {
$summary.data('fetched', true).html(data.summary);
},
'json'
);
}
var $player = $(h).addClass('dynamic-video');
$e.parent().prepend($player).show();
$(window).resize();
$('html, body').animate({ scrollTop: $player.offset().top - 8 }, 400);
});
$('.close-video').click(function(e){
e.preventDefault();
var $li = $(this).closest('li.video-post');
var $ib = $('.image-box', $li);
var $img = $('> a', $ib);
var $e = $('#embed-' + $img.data('id')).parent().hide();
$('.dynamic-video', $e).remove();
$li.removeClass('video-expanded');
$('html, body').animate({ scrollTop: $li.offset().top - 5 }, 300);
});
$(window).resize(function(){
$('#index-listing .video-embed:visible').each(function(){
var $eouter = $(this);
var ar = parseFloat($(this).data('ar'));
$('.dynamic-video', this).each(function(){
var pw = $(this).parent().width();
if (!$('html').hasClass('mobile')) {
if ($(window).width() > 1200)
pw = Math.min(pw, $(window).width() * 0.6);
}
var h = Math.min(pw * ar, $(window).height() * 0.75);
$(this).width(pw);
$(this).css({ height : h });
$('.video-member-meta', $eouter).width(pw);
});
});
});
});
$(function(){
var $promo_lis = $('#index-listing > li.promoted');
if (!$promo_lis)
return;
/*
$promo_lis.each(function(){
if (!$(this).hasClass('nsfw'))
$('.image-box > a', this).click();
});
*/
var idx = 0;
$('.next-promoted').click(function(e){
e.preventDefault();
if (++idx >= $promo_lis.length)
idx = 0;
$promo_lis.hide().removeClass('active');
$promo_lis.eq(idx).show().addClass('active');
$('#index-listing > li.promoted.video-expanded .close-video').click();
});
});