jam-cloud/web/app/assets/javascripts/dialog/videoDialog.js

67 lines
1.7 KiB
JavaScript

(function (context, $) {
"use strict";
context.JK = context.JK || {};
context.JK.VideoDialog = function (app) {
var logger = context.JK.logger;
var rest = context.JK.Rest();
var dialogId = '#video-dialog';
async function videoClick(e) {
var $self = $(this);
var isNativeClient = context.JK.isQWebEngine;
if (!isNativeClient) {
$('#video-dialog-header').html($self.data('video-header') || $self.attr('data-video-header'));
$('#video-dialog-iframe').attr('src', $self.data('video-url') || $self.attr('data-video-url'));
app.layout.showDialog('video-dialog');
e.stopPropagation();
e.preventDefault();
return false;
}
else {
var videoUrl = $.param.querystring(window.location.href, 'showVideo=' + encodeURIComponent($self.data('video-url')));
await context.jamClient.OpenSystemBrowser(videoUrl);
}
}
function events() {
$('.carousel .slides').on('click', '.slideItem', videoClick);
$('.video-slide').on('click', videoClick);
$('.video-item').on('click', videoClick);
$(dialogId + '-close').click(function (e) {
app.layout.closeDialog('video-dialog');
$('#video-dialog-header').html('');
$('#video-dialog-iframe').attr('src', '');
e.stopPropagation();
return false;
});
}
function beforeShow() {
}
function afterHide() {
}
function initialize() {
var dialogBindings = {
'beforeShow': beforeShow,
'afterHide': afterHide
};
app.bindDialog('video-dialog', dialogBindings);
events();
}
this.initialize = initialize;
}
})(window, jQuery);