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