openmedialibrary/static/js/info.js

77 lines
2.3 KiB
JavaScript
Raw Normal View History

2014-05-04 17:26:43 +00:00
'use strict';
oml.ui.info = function() {
var ui = oml.user.ui,
that = Ox.Element()
.addClass('OxTextPage')
2014-05-17 11:45:57 +00:00
.css({
padding: '0 16px',
2014-05-04 17:26:43 +00:00
textAlign: 'center',
2014-05-17 11:45:57 +00:00
overflowY: 'auto'
})
.bindEvent({
2014-05-25 14:05:26 +00:00
toggle: function(data) {
oml.UI.set({showInfo: !data.collapsed});
},
2016-01-16 05:14:22 +00:00
oml_icons: function() {
that.updateElement();
},
2014-05-04 17:26:43 +00:00
oml_item: function() {
2014-05-17 11:45:57 +00:00
that.updateElement();
2014-05-04 17:26:43 +00:00
},
2014-05-17 11:45:57 +00:00
oml_listselection: function() {
that.updateElement();
}
});
2014-05-04 17:26:43 +00:00
2014-05-17 11:45:57 +00:00
that.updateElement = function() {
2014-05-04 17:26:43 +00:00
var id = ui.item || ui.listSelection[0];
2016-01-13 08:44:07 +00:00
Ox.Request.clearCache('get');
2014-05-04 17:26:43 +00:00
if (id) {
oml.api.get({
id: id,
keys: [
'author', 'coverRatio',
'description', 'modified', 'title'
2014-05-04 17:26:43 +00:00
]
}, function(result) {
var data = result.data;
that.empty();
$('<img>')
2016-01-13 08:44:07 +00:00
.attr({
src: '/' + id + '/' + ui.icons + '128.jpg?'
+ data.modified
})
2014-05-04 17:26:43 +00:00
.css({margin: '16px 0 8px 0'})
.appendTo(that);
$('<div>')
2016-01-09 07:07:17 +00:00
.addClass('OxSelectable')
.css({fontWeight: 'bold'})
2016-01-08 08:37:34 +00:00
.text(data.title || '')
2014-05-04 17:26:43 +00:00
.appendTo(that);
$('<div>')
2016-01-09 07:07:17 +00:00
.addClass('OxSelectable')
.css({fontWeight: 'bold'})
2016-01-14 09:25:14 +00:00
.text(oml.formatAuthor(data.author))
2014-05-04 17:26:43 +00:00
.appendTo(that);
$('<div>')
2016-01-09 07:07:17 +00:00
.addClass('OxSelectable')
2014-05-04 17:26:43 +00:00
.css({marginTop: '8px'})
2016-01-08 08:37:34 +00:00
.text(result.data.description || '')
2014-05-04 17:26:43 +00:00
.appendTo(that);
$('<div>')
.css({height: '16px'})
.appendTo(that);
});
} else {
that.empty();
}
return that;
};
2014-05-17 11:45:57 +00:00
return that.updateElement();
2014-05-04 17:26:43 +00:00
};