openmedialibrary/static/js/viewer.js
2014-05-25 16:10:38 +02:00

39 lines
1 KiB
JavaScript

'use strict';
oml.ui.viewer = function() {
var ui = oml.user.ui,
that = Ox.Element()
.bindEvent({
oml_itemview: function(data) {
if (ui.item != item && ui.itemView == 'book') {
that.updateElement(ui.item);
}
}
}),
$iframe, item;
that.updateElement = function() {
item = ui.item;
if (item) {
oml.api.get({id: item, keys: ['mediastate']}, function(result) {
if (result.data.mediastate == 'available') {
$iframe = $iframe || Ox.Element('<iframe>').css({
width: '100%',
height: '100%',
border: 0
}).appendTo(that);
$iframe.attr({
src: '/' + item + '/reader/'
});
}
});
}
return that;
};
return that.updateElement();
};