2014-05-04 17:26:43 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
oml.ui.gridView = function() {
|
|
|
|
|
|
|
|
var ui = oml.user.ui,
|
|
|
|
|
|
|
|
that = Ox.IconList({
|
2014-05-21 00:02:39 +00:00
|
|
|
defaultRatio: oml.config.iconRatio,
|
2014-05-04 17:26:43 +00:00
|
|
|
draggable: true,
|
|
|
|
item: function(data, sort, size) {
|
2014-05-21 00:02:39 +00:00
|
|
|
var color = oml.getIconInfoColor(ui.iconInfo, data).map(function(rgb) {
|
2014-05-12 12:57:47 +00:00
|
|
|
return rgb.concat(0.8);
|
2014-05-04 17:26:43 +00:00
|
|
|
}),
|
2014-05-21 00:02:39 +00:00
|
|
|
ratio = (ui.icons == 'cover' ? data.coverRatio : data.previewRatio)
|
|
|
|
|| oml.config.iconRatio,
|
2014-05-04 17:26:43 +00:00
|
|
|
width = Math.round(ratio >= 1 ? size : size * ratio),
|
|
|
|
height = Math.round(ratio <= 1 ? size : size / ratio),
|
|
|
|
sortKey = sort[0].key,
|
|
|
|
info = Ox.getObjectById(oml.config.sortKeys, sortKey).format(
|
|
|
|
Ox.contains(['title', 'random'], sortKey)
|
|
|
|
? (data.author || '') : data[sortKey]
|
|
|
|
);
|
|
|
|
size = size || 128;
|
|
|
|
return {
|
2014-05-21 00:02:39 +00:00
|
|
|
extra: ui.showIconInfo ? $('<div>')
|
2014-05-04 17:26:43 +00:00
|
|
|
.css({
|
|
|
|
width: width + 'px',
|
|
|
|
height: Math.round(size / 12.8) + 'px',
|
|
|
|
borderWidth: Math.round(size / 64) + 'px 0',
|
|
|
|
borderStyle: 'solid',
|
2014-05-12 12:57:47 +00:00
|
|
|
borderColor: 'rgba(' + color[2].join(', ') + ')',
|
2014-05-19 20:58:00 +00:00
|
|
|
margin: Math.round(size / 18) + 'px ' + Math.round(width / 2 - 14) + 'px',
|
2014-05-04 17:26:43 +00:00
|
|
|
fontSize: Math.round(size / 16) + 'px',
|
|
|
|
textAlign: 'center',
|
2014-05-12 12:57:47 +00:00
|
|
|
color: 'rgba(' + color[2].join(', ') + ')',
|
|
|
|
backgroundImage: '-webkit-linear-gradient(top, ' + color.slice(0, 2).map(function(rgba) {
|
|
|
|
return 'rgba(' + rgba.join(', ') + ')';
|
|
|
|
}).join(', ') + ')',
|
2015-02-22 11:39:33 +00:00
|
|
|
MozTransform: 'rotate(45deg)',
|
2014-05-04 17:26:43 +00:00
|
|
|
WebkitTransform: 'rotate(45deg)'
|
|
|
|
})
|
|
|
|
.html(
|
2014-05-21 00:02:39 +00:00
|
|
|
ui.iconInfo == 'extension'
|
2014-05-04 17:26:43 +00:00
|
|
|
? data.extension.toUpperCase()
|
|
|
|
: Ox.formatValue(data.size, 'B')
|
|
|
|
) : null,
|
|
|
|
height: height,
|
|
|
|
id: data.id,
|
|
|
|
info: info,
|
|
|
|
title: data.title,
|
2014-05-21 00:02:39 +00:00
|
|
|
url: '/' + data.id + '/' + ui.icons + '128.jpg',
|
2014-05-04 17:26:43 +00:00
|
|
|
width: width
|
|
|
|
};
|
|
|
|
},
|
|
|
|
items: function(data, callback) {
|
|
|
|
oml.api.find(Ox.extend(data, {
|
|
|
|
query: ui.find
|
|
|
|
}), callback);
|
|
|
|
},
|
|
|
|
keys: [
|
2014-05-21 00:02:39 +00:00
|
|
|
'author', 'coverRatio', 'extension', 'id', 'mediastate',
|
|
|
|
'previewRatio', 'size', 'textsize', 'title'
|
2014-05-04 17:26:43 +00:00
|
|
|
],
|
|
|
|
selected: ui.listSelection,
|
|
|
|
size: 128,
|
2014-10-31 13:52:58 +00:00
|
|
|
sort: Ox.clone(ui.listSort, true),
|
2014-05-04 17:26:43 +00:00
|
|
|
unique: 'id'
|
2014-05-21 00:02:39 +00:00
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
oml_iconinfo: function() {
|
|
|
|
that.reloadList(true);
|
|
|
|
},
|
|
|
|
oml_icons: function() {
|
|
|
|
that.reloadList(true);
|
|
|
|
},
|
|
|
|
oml_showiconinfo: function() {
|
|
|
|
that.reloadList(true);
|
|
|
|
}
|
2014-05-04 17:26:43 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return that;
|
|
|
|
|
2014-10-31 13:52:58 +00:00
|
|
|
};
|