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,32 +10,31 @@ 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
}, function(result) {
var totals = pandora.getStatusText(result.data);
pandora.api.find({
keys: keys,
query: pandora.user.ui.find, query: pandora.user.ui.find,
range: [0, 1000000], range: [0, result.data.items],
sort: keys.map(function(key) { sort: pandora.user.ui.listSort
return {
key: key,
operator: Ox.getObjectById(pandora.site.itemKeys, key).operator
};
})
}, function(result) { }, function(result) {
var padding; var padding;
that.empty(); $loading.remove();
$('<div>') $('<div>')
.css({ .css({height: '16px'})
height: '16px'
})
.html( .html(
'<b>' + pandora.site.site.name + ' - ' '<b>' + pandora.site.site.name + ' - '
+ (pandora.user.ui._list || 'All ' + pandora.site.itemName.plural) + (pandora.user.ui._list || 'All ' + pandora.site.itemName.plural)
@ -44,8 +43,14 @@ pandora.ui.printView = function(data) {
.appendTo(that); .appendTo(that);
$('<div>').css({height: '16px'}).appendTo(that); $('<div>').css({height: '16px'}).appendTo(that);
result.data.items && result.data.items.forEach(function(item) { result.data.items && result.data.items.forEach(function(item) {
var url = (pandora.site.https ? 'https://' : 'http://') var format = Ox.clone(
Ox.getObjectById(pandora.site.itemKeys, sortKey).format
),
url = (pandora.site.https ? 'https://' : 'http://')
+ pandora.site.site.url + '/' + item.id; + pandora.site.site.url + '/' + item.id;
if (format && format.type == 'ColorPercent') {
format = {type: 'percent', args: [100, 1]};
}
$('<div>') $('<div>')
.attr({title: url}) .attr({title: url})
.css({ .css({
@ -55,9 +60,20 @@ pandora.ui.printView = function(data) {
overflow: 'hidden' overflow: 'hidden'
}) })
.html( .html(
(item.director ? item.director.join(', ') + ': ' : '') (item.director ? item.director.join(', ') + ' ' : '')
+ '<b>' + item.title + '</b>' + '<b>' + item.title + '</b>'
+ (item.year ? ' (' + item.year + ')' : '') + (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 item.summary
? ' <span style="color: rgb(128, 128, 128)">' ? ' <span style="color: rgb(128, 128, 128)">'
@ -76,18 +92,14 @@ pandora.ui.printView = function(data) {
$('<div>').css({height: '16px'}).appendTo(that); $('<div>').css({height: '16px'}).appendTo(that);
} }
$('<div>') $('<div>')
.css({ .css({height: '16px'})
height: '16px'
})
.html( .html(
Ox.formatCount( '<span style="color: rgb(128, 128, 128)">'
result.data.items.length, + totals + '</span'
pandora.site.itemName.singular,
pandora.site.itemName.plural
).toLowerCase()
) )
.appendTo(that); .appendTo(that);
}); });
});
that.display = function() { that.display = function() {
// fixme: move animation into Ox.App // fixme: move animation into Ox.App

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)