var EWRrio = window.EWRrio || {};
!function($, window, document)
{
// ################################## --- ###########################################
EWRrio.ResizeVideo = XF.Element.newHandler(
{
init: function()
{
this.$target.on('click', '.rio-resize-small', $.proxy(this, 'small'));
this.$target.on('click', '.rio-resize-medium', $.proxy(this, 'medium'));
this.$target.on('click', '.rio-resize-large', $.proxy(this, 'large'));
this.$target.on('click', '.rio-resize-popout', $.proxy(this, 'popout'));
},
small: function(e)
{
$('body').removeClass('rio-cinema');
$('.rio-embed>div').attr('class', 'rio-embed-small');
document.cookie = "xf_EWRrio_layout=small; max-age=31536000; path=/";
},
medium: function(e)
{
$('body').removeClass('rio-cinema');
$('.rio-embed>div').attr('class', 'rio-embed-medium');
document.cookie = "xf_EWRrio_layout=medium; max-age=31536000; path=/";
},
large: function(e)
{
$('body').addClass('rio-cinema');
$('.rio-embed>div').attr('class', 'rio-embed-large');
},
popout: function(e)
{
e.preventDefault();
var video = $('.rio-video').html();
var win = window.open($(e.currentTarget).attr('href'), '_blank',
'width=800,height=450,toolbar=no,scrollbars=no,menubar=no,resizable=yes');
win.focus();
$('.rio-embed>div').addClass('rio-embed-popped');
$('.rio-video').html('');
var winTimer = window.setInterval(function()
{
if (win.closed !== false)
{
window.clearInterval(winTimer);
$('.rio-embed>div').removeClass('rio-embed-popped');
$('.rio-video').html(video);
}
}, 200);
},
});
// ################################## --- ###########################################
EWRrio.MultiPopout = XF.Element.newHandler(
{
init: function()
{
this.$target.on('click', $.proxy(this, 'popout'));
},
popout: function(e)
{
e.preventDefault();
var win = window.open($(e.currentTarget).attr('href'), '_blank',
'width=1280,height=720,toolbar=no,scrollbars=no,menubar=no,resizable=yes');
win.focus();
},
});
EWRrio.MultiViewer = XF.Element.newHandler(
{
init: function()
{
this.$target.on('click', '.rio-multi-open', $.proxy(this, 'open'));
this.$target.on('click', '.rio-multi-close', $.proxy(this, 'close'));
this.$target.on('click', '.rio-multi-share', $.proxy(this, 'share'));
EWRrio.CheckActives();
},
open: function(e)
{
e.preventDefault();
var $item = $(e.currentTarget),
id = $item.data('id');
$('.rio-multi-large').removeClass('rio-multi-large').addClass('rio-multi-small');
$('#video_'+id).removeClass('rio-multi-small').addClass('rio-multi-large');
$('#name_'+id).trigger('click');
},
close: function(e)
{
e.preventDefault();
var $item = $(e.currentTarget),
id = $item.data('id');
$('#name_'+id).remove();
$('#pane_'+id).remove();
$('#video_'+id).remove();
EWRrio.CheckActives();
},
share: function(e)
{
e.preventDefault();
var channels = [];
$('.rio-multi-tabs .tabs-tab').each(function()
{
channels.push($(this).data('key'));
});
prompt("SHARE URL", $('#TabNames').data('url') + '?q=' + channels.join(';'));
},
});
EWRrio.MultiAdder = XF.Element.newHandler(
{
init: function()
{
this.$target.on('ajax-submit:response', $.proxy(this, 'response'));
},
response: function(e, data)
{
e.preventDefault();
if (data.html.content)
{
var html = data.html.content.split('#####');
$(html[0]).appendTo('#TabNames');
$(html[1]).appendTo('#TabPanes');
$(html[2]).appendTo('#TabVideos');
EWRrio.CheckActives();
$('.rio-multi-tabs .tabs-tab').off('click');
$('.rio-multi-tabs .tabs-tab').on('click', EWRrio.FocusActive);
XF.hideOverlays();
}
},
});
EWRrio.MultiTabs = XF.Element.newHandler(
{
init: function()
{
$('.rio-multi-tabs .tabs-tab').on('click', EWRrio.FocusActive);
EWRrio.CheckActives();
},
});
EWRrio.FocusActive = function()
{
$('.rio-multi-tabs .tabs-tab').removeClass('is-active');
$('.rio-multi-panes .tabs-pane').removeClass('is-active');
$(this).addClass('is-active');
$($(this).data('pane')).addClass('is-active');
}
EWRrio.CheckActives = function()
{
if (!$('.rio-multi-large').length && $('.rio-multi-small').length)
{
$('.rio-multi-hidden').removeClass('rio-multi-hidden');
$('.rio-multi-small:first').removeClass('rio-multi-small').addClass('rio-multi-large');
}
if (!$('.rio-multi-tabs .tabs-tab.is-active').length)
{
$('.rio-multi-tabs .tabs-tab:first').addClass('is-active');
$('.rio-multi-panes .tabs-pane:first').addClass('is-active');
}
}
// ################################## --- ###########################################
XF.Element.register('rio-resize-video', 'EWRrio.ResizeVideo');
XF.Element.register('rio-multi-popout', 'EWRrio.MultiPopout');
XF.Element.register('rio-multi-viewer', 'EWRrio.MultiViewer');
XF.Element.register('rio-multi-adder', 'EWRrio.MultiAdder');
XF.Element.register('rio-multi-tabs', 'EWRrio.MultiTabs');
}
(window.jQuery, window, document);