openmedialibrary/static/js/viewer.js

40 lines
1 KiB
JavaScript
Raw Normal View History

2014-05-04 19:26:43 +02:00
'use strict';
oml.ui.viewer = function() {
var ui = oml.user.ui,
that = Ox.Element()
.bindEvent({
oml_itemview: function(data) {
2014-05-25 14:16:04 +02:00
if (ui.item != item && ui.itemView == 'book') {
that.updateElement(ui.item);
}
2014-05-04 19:26:43 +02:00
}
}),
2014-05-25 14:16:04 +02:00
$iframe, item;
2014-05-04 19:26:43 +02:00
2014-05-17 13:45:57 +02:00
that.updateElement = function() {
2014-05-25 14:16:04 +02:00
item = ui.item;
2014-05-26 18:02:41 +02:00
if (item && item.length) {
2014-05-25 16:10:38 +02:00
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/'
});
}
2014-05-04 19:26:43 +02:00
});
}
return that;
};
2014-05-17 13:45:57 +02:00
return that.updateElement();
2014-05-04 19:26:43 +02:00
};