2014-09-23 21:46:03 +00:00
|
|
|
Ox.load({
|
|
|
|
'UI': {
|
|
|
|
loadCSS: false
|
|
|
|
}
|
|
|
|
}, function() {
|
2013-12-31 11:04:23 +00:00
|
|
|
var currentPage = PDFView.page;
|
|
|
|
window.addEventListener('pagechange', function (evt) {
|
|
|
|
var page = evt.pageNumber;
|
|
|
|
if (page && page != currentPage) {
|
|
|
|
currentPage = page;
|
2014-09-23 21:46:03 +00:00
|
|
|
Ox.parent.postMessage('page', {
|
2013-12-31 11:04:23 +00:00
|
|
|
page: Math.round(page)
|
|
|
|
});
|
|
|
|
}
|
2013-03-02 13:01:07 +00:00
|
|
|
});
|
2014-09-23 21:46:03 +00:00
|
|
|
Ox.parent.bindMessage({
|
|
|
|
page: function(data) {
|
2013-12-31 11:04:23 +00:00
|
|
|
if (data.page != PDFView.page) {
|
|
|
|
PDFView.page = data.page;
|
|
|
|
}
|
2014-09-23 21:46:03 +00:00
|
|
|
},
|
|
|
|
pdf: function(data) {
|
2014-01-07 15:34:55 +00:00
|
|
|
if (PDFView.url != data.pdf) {
|
|
|
|
PDFView.open(data.pdf);
|
|
|
|
}
|
2014-01-07 13:59:51 +00:00
|
|
|
}
|
2013-03-02 13:01:07 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-02-21 14:09:23 +00:00
|
|
|
function getVideoOverlay(page) {
|
2014-01-07 13:59:51 +00:00
|
|
|
var links = (window.embeds || []).filter(function(embed) {
|
2013-02-21 14:52:41 +00:00
|
|
|
return embed.page == page && embed.type =='inline';
|
|
|
|
});
|
2014-01-07 13:59:51 +00:00
|
|
|
return (window.editable || links.length) ? {
|
2013-02-21 14:09:23 +00:00
|
|
|
beginLayout: function() {
|
|
|
|
this.counter = 0;
|
|
|
|
},
|
|
|
|
endLayout: function() {
|
|
|
|
},
|
|
|
|
appendImage: function(image) {
|
|
|
|
var id = ++this.counter,
|
2013-02-21 14:52:41 +00:00
|
|
|
video = links.filter(function(embed) {
|
|
|
|
return embed.id == id;
|
|
|
|
})[0],
|
2013-02-21 14:09:23 +00:00
|
|
|
$interface, $playButton, $editButton;
|
2013-02-21 14:52:41 +00:00
|
|
|
if (editable || video) {
|
2013-02-21 14:09:23 +00:00
|
|
|
$interface = Ox.$('<div>')
|
|
|
|
.addClass('interface')
|
|
|
|
.css({
|
|
|
|
left: image.left + 'px',
|
|
|
|
top: image.top + 'px',
|
|
|
|
width: image.width + 'px',
|
|
|
|
height: image.height + 'px'
|
|
|
|
});
|
|
|
|
$playButton = Ox.$('<img>')
|
|
|
|
.addClass('button playButton')
|
|
|
|
.attr({
|
|
|
|
src: 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNTYiIGhlaWdodD0iMjU2Ij48cG9seWdvbiBwb2ludHM9IjU2LDMyIDI0OCwxMjggNTYsMjI0IiBmaWxsPSIjRkZGRkZGIi8+PC9zdmc+PCEtLXsiY29sb3IiOiJ2aWRlbyIsIm5hbWUiOiJzeW1ib2xQbGF5IiwidGhlbWUiOiJveGRhcmsifS0tPg=='
|
|
|
|
})
|
|
|
|
.hide()
|
|
|
|
.appendTo($interface);
|
|
|
|
$editButton = Ox.$('<img>')
|
|
|
|
.addClass('button editButton')
|
|
|
|
.attr({
|
|
|
|
src: 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNTYiIGhlaWdodD0iMjU2Ij48cG9seWdvbiBwb2ludHM9IjMyLDIyNCA2NCwxNjAgOTYsMTkyIiBmaWxsPSIjRkZGRkZGIi8+PGxpbmUgeDE9Ijg4IiB5MT0iMTY4IiB4Mj0iMTg0IiB5Mj0iNzIiIHN0cm9rZT0iI0ZGRkZGRiIgc3Ryb2tlLXdpZHRoPSI0OCIvPjxsaW5lIHgxPSIxOTIiIHkxPSI2NCIgeDI9IjIwOCIgeTI9IjQ4IiBzdHJva2U9IiNGRkZGRkYiIHN0cm9rZS13aWR0aD0iNDgiLz48bGluZSB4MT0iMTEyIiB5MT0iMjIwIiB4Mj0iMjI0IiB5Mj0iMjIwIiBzdHJva2U9IiNGRkZGRkYiIHN0cm9rZS13aWR0aD0iOCIvPjxsaW5lIHgxPSIxMjgiIHkxPSIyMDQiIHgyPSIyMjQiIHkyPSIyMDQiIHN0cm9rZT0iI0ZGRkZGRiIgc3Ryb2tlLXdpZHRoPSI4Ii8+PGxpbmUgeDE9IjE0NCIgeTE9IjE4OCIgeDI9IjIyNCIgeTI9IjE4OCIgc3Ryb2tlPSIjRkZGRkZGIiBzdHJva2Utd2lkdGg9IjgiLz48L3N2Zz4=',
|
|
|
|
title: 'Click to add video'
|
|
|
|
})
|
|
|
|
.on({click: edit})
|
|
|
|
.hide()
|
|
|
|
.appendTo($interface);
|
|
|
|
if (editable) {
|
|
|
|
$editButton.show();
|
|
|
|
}
|
2013-02-21 14:52:41 +00:00
|
|
|
if (video) {
|
2013-02-21 14:09:23 +00:00
|
|
|
enableVideoUI();
|
|
|
|
}
|
|
|
|
this.div.appendChild($interface[0]);
|
2014-09-23 21:46:03 +00:00
|
|
|
Ox.parent.bindMessage('update', function(data) {
|
|
|
|
if (video && data.id == video.id && data.page == video.page) {
|
|
|
|
video.src = data.src;
|
|
|
|
video.src !== '' ? enableVideoUI() : disableVideoUI();
|
2013-02-28 15:43:59 +00:00
|
|
|
}
|
|
|
|
});
|
2013-02-21 14:09:23 +00:00
|
|
|
}
|
|
|
|
function play(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
2013-02-28 15:43:59 +00:00
|
|
|
var videoId = 'video' + page + id + Ox.uid(),
|
2014-09-23 21:46:03 +00:00
|
|
|
$iframe = Ox.Element('<iframe>')
|
2013-02-21 14:09:23 +00:00
|
|
|
.attr({
|
|
|
|
id: videoId,
|
2013-09-08 18:12:44 +00:00
|
|
|
src: video.src
|
|
|
|
+ (video.src.indexOf('?') == -1 ? '?' : '&')
|
|
|
|
+ '&showCloseButton=true&fullscreen=false&paused=false',
|
2013-02-21 14:09:23 +00:00
|
|
|
width: '100%',
|
|
|
|
height: '100%',
|
2014-09-23 21:46:03 +00:00
|
|
|
scrolling: 'no',
|
2013-02-21 14:09:23 +00:00
|
|
|
frameborder: 0
|
|
|
|
})
|
2014-09-23 21:46:03 +00:00
|
|
|
.bindMessage({
|
|
|
|
close: function(data) {
|
|
|
|
if(!closed) {
|
|
|
|
closed = true;
|
|
|
|
$iframe.remove();
|
|
|
|
delete $iframe;
|
|
|
|
$playButton.show();
|
|
|
|
$editButton.show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2013-02-28 15:43:59 +00:00
|
|
|
.appendTo($interface),
|
|
|
|
closed = false;
|
2013-02-21 14:09:23 +00:00
|
|
|
$playButton.hide();
|
|
|
|
$editButton.hide();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
function edit(e) {
|
|
|
|
var url;
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
2013-02-28 15:43:59 +00:00
|
|
|
video = video || {
|
|
|
|
id: id,
|
|
|
|
page: page,
|
|
|
|
src: '',
|
|
|
|
type: 'inline'
|
|
|
|
};
|
2014-09-23 21:46:03 +00:00
|
|
|
Ox.parent.postMessage('edit', video);
|
2013-02-21 14:09:23 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
function enableVideoUI() {
|
|
|
|
$interface
|
|
|
|
.addClass('video')
|
|
|
|
.attr({title: 'Click to play video'})
|
|
|
|
.on({click: play});
|
|
|
|
$playButton.show();
|
|
|
|
$editButton.attr({title: 'Click to edit or remove video'});
|
|
|
|
}
|
|
|
|
function disableVideoUI() {
|
|
|
|
$interface
|
|
|
|
.removeClass('video')
|
|
|
|
.attr({title: ''})
|
|
|
|
.off({click: play});
|
|
|
|
$playButton.hide();
|
|
|
|
$editButton.attr({title: 'Click to add video'});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} : null;
|
|
|
|
}
|