update print view

This commit is contained in:
rolux 2013-03-09 05:27:07 +00:00
parent 9d65ac96f6
commit a4779d6063
4 changed files with 109 additions and 97 deletions

View file

@ -308,7 +308,7 @@ pandora.ui.mainMenu = function() {
} else if (data.id == 'deletelist') { } else if (data.id == 'deletelist') {
pandora.ui.deleteListDialog().open(); pandora.ui.deleteListDialog().open();
} else if (data.id == 'print') { } else if (data.id == 'print') {
window.open('#?print=true', '_blank') window.open(document.location.href + '#?print=true', '_blank');
} else if (data.id == 'showsidebar') { } else if (data.id == 'showsidebar') {
pandora.UI.set({showSidebar: !ui.showSidebar}); pandora.UI.set({showSidebar: !ui.showSidebar});
} else if (data.id == 'showinfo') { } else if (data.id == 'showinfo') {
@ -413,7 +413,7 @@ pandora.ui.mainMenu = function() {
} }
}, },
key_control_p: function() { key_control_p: function() {
window.open('#?print=true', '_blank'); window.open(document.location.href + '#?print=true', '_blank');
}, },
key_control_shift_f: function() { key_control_shift_f: function() {
if (!pandora.hasDialogOrScreen()) { if (!pandora.hasDialogOrScreen()) {

View file

@ -10,83 +10,95 @@ pandora.ui.printView = function(data) {
backgroundColor: 'rgb(255, 255, 255)', backgroundColor: 'rgb(255, 255, 255)',
color: 'rgb(0, 0, 0)' color: 'rgb(0, 0, 0)'
}), }),
keys = ['director', 'year', 'title']; $loading = Ox.LoadingScreen().appendTo(that),
sortKey = pandora.user.ui.listSort[0].key,
keys = Ox.unique(
['director', 'id', 'summary', 'title', 'year'].concat(sortKey)
);
Ox.$body.css({ Ox.$body.css({
background: 'rgb(255, 255, 255)', background: 'rgb(255, 255, 255)',
overflow: 'auto' overflow: 'auto'
}); });
Ox.LoadingScreen().appendTo(that);
pandora.api.find({ pandora.api.find({
keys: keys.concat(['id', 'summary']), query: pandora.user.ui.find
query: pandora.user.ui.find,
range: [0, 1000000],
sort: keys.map(function(key) {
return {
key: key,
operator: Ox.getObjectById(pandora.site.itemKeys, key).operator
};
})
}, function(result) { }, function(result) {
var padding; var totals = pandora.getStatusText(result.data);
that.empty(); pandora.api.find({
$('<div>') keys: keys,
.css({ query: pandora.user.ui.find,
height: '16px' range: [0, result.data.items],
}) sort: pandora.user.ui.listSort
.html( }, function(result) {
'<b>' + pandora.site.site.name + ' - ' var padding;
+ (pandora.user.ui._list || 'All ' + pandora.site.itemName.plural) $loading.remove();
+ '</b>'
)
.appendTo(that);
$('<div>').css({height: '16px'}).appendTo(that);
result.data.items && result.data.items.forEach(function(item) {
var url = (pandora.site.https ? 'https://' : 'http://')
+ pandora.site.site.url + '/' + item.id;
$('<div>') $('<div>')
.attr({title: url}) .css({height: '16px'})
.css({
height: '16px',
textAlign: 'justify',
textOverflow: 'ellipsis',
overflow: 'hidden'
})
.html( .html(
(item.director ? item.director.join(', ') + ': ' : '') '<b>' + pandora.site.site.name + ' - '
+ '<b>' + item.title + '</b>' + (pandora.user.ui._list || 'All ' + pandora.site.itemName.plural)
+ (item.year ? ' (' + item.year + ')' : '') + '</b>'
+ ( )
item.summary .appendTo(that);
? ' <span style="color: rgb(128, 128, 128)">' $('<div>').css({height: '16px'}).appendTo(that);
+ item.summary + '</span>' result.data.items && result.data.items.forEach(function(item) {
: '' var format = Ox.clone(
) Ox.getObjectById(pandora.site.itemKeys, sortKey).format
),
url = (pandora.site.https ? 'https://' : 'http://')
+ pandora.site.site.url + '/' + item.id;
if (format && format.type == 'ColorPercent') {
format = {type: 'percent', args: [100, 1]};
}
$('<div>')
.attr({title: url})
.css({
height: '16px',
textAlign: 'justify',
textOverflow: 'ellipsis',
overflow: 'hidden'
})
.html(
(item.director ? item.director.join(', ') + ' ' : '')
+ '<b>' + item.title + '</b>'
+ (item.year ? ' (' + item.year + ')' : '')
+ (
item[sortKey] && !Ox.contains(['director', 'title', 'year'], sortKey)
? ' ' + (
format && !/^color/.test(format.type)
? Ox['format' + Ox.toTitleCase(format.type)].apply(
this, [item[sortKey]].concat(format.args || [])
)
: item[sortKey]
)
: ''
)
+ (
item.summary
? ' <span style="color: rgb(128, 128, 128)">'
+ item.summary + '</span>'
: ''
)
)
.on({
click: function() {
document.location.href = url;
}
})
.appendTo(that);
});
if (result.data.items.length) {
$('<div>').css({height: '16px'}).appendTo(that);
}
$('<div>')
.css({height: '16px'})
.html(
'<span style="color: rgb(128, 128, 128)">'
+ totals + '</span'
) )
.on({
click: function() {
document.location.href = url;
}
})
.appendTo(that); .appendTo(that);
}); });
if (result.data.items.length) {
$('<div>').css({height: '16px'}).appendTo(that);
}
$('<div>')
.css({
height: '16px'
})
.html(
Ox.formatCount(
result.data.items.length,
pandora.site.itemName.singular,
pandora.site.itemName.plural
).toLowerCase()
)
.appendTo(that);
}); });
that.display = function() { that.display = function() {

View file

@ -29,35 +29,6 @@ pandora.ui.statusbar = function() {
.append($text.selected) .append($text.selected)
); );
function getText(data) {
var ui = pandora.user.ui,
canSeeFiles = pandora.site.capabilities.canSeeFiles[pandora.user.level],
canSeeSize = pandora.site.capabilities.canSeeSize[pandora.user.level],
itemName = ui.listView == 'clip'
? (data.items == 1 ? 'Clip' : 'Clips')
: (pandora.site.itemName[data.items == 1 ? 'singular' : 'plural']),
parts = [];
parts.push(Ox.formatNumber(data.items) + ' '+ itemName);
if (data.runtime) {
parts.push(Ox.formatDuration(data.runtime, 'short'));
} else if (data.duration) {
parts.push(Ox.formatDuration(data.duration, 'short'));
}
if (canSeeFiles) {
data.files && parts.push(
Ox.formatNumber(data.files) + ' file' + (data.files == 1 ? '' : 's')
);
data.duration && parts.push(Ox.formatDuration(data.duration));
}
if (canSeeSize) {
data.size && parts.push(Ox.formatValue(data.size, 'B'));
}
if (canSeeFiles) {
data.pixels && parts.push(Ox.formatValue(data.pixels, 'px'));
}
return parts.join(', ');
}
function setTotal() { function setTotal() {
pandora.api.find({ pandora.api.find({
query: pandora.user.ui.find, query: pandora.user.ui.find,
@ -83,10 +54,10 @@ pandora.ui.statusbar = function() {
} else { } else {
$text.titleTotal.show(); $text.titleTotal.show();
$text.titleSelected.show(); $text.titleSelected.show();
$text.selected.html(getText(data)).show(); $text.selected.html(pandora.getStatusText(data)).show();
} }
} else { } else {
$text.total.html(getText(data)).show(); $text.total.html(pandora.getStatusText(data)).show();
} }
} }
}; };

View file

@ -1041,6 +1041,35 @@ pandora.getSpan = function(state, str, callback) {
}; };
pandora.getStatusText = function(data) {
var ui = pandora.user.ui,
canSeeFiles = pandora.site.capabilities.canSeeFiles[pandora.user.level],
canSeeSize = pandora.site.capabilities.canSeeSize[pandora.user.level],
itemName = ui.listView == 'clip'
? (data.items == 1 ? 'Clip' : 'Clips')
: (pandora.site.itemName[data.items == 1 ? 'singular' : 'plural']),
parts = [];
parts.push(Ox.formatNumber(data.items) + ' '+ itemName);
if (data.runtime) {
parts.push(Ox.formatDuration(data.runtime, 'short'));
} else if (data.duration) {
parts.push(Ox.formatDuration(data.duration, 'short'));
}
if (canSeeFiles) {
data.files && parts.push(
Ox.formatNumber(data.files) + ' file' + (data.files == 1 ? '' : 's')
);
data.duration && parts.push(Ox.formatDuration(data.duration));
}
if (canSeeSize) {
data.size && parts.push(Ox.formatValue(data.size, 'B'));
}
if (canSeeFiles) {
data.pixels && parts.push(Ox.formatValue(data.pixels, 'px'));
}
return parts.join(', ');
};
pandora.getVideoURL = function(id, resolution, part) { pandora.getVideoURL = function(id, resolution, part) {
var prefix = pandora.site.site.videoprefix var prefix = pandora.site.site.videoprefix
.replace('{id}', id) .replace('{id}', id)