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

View File

@ -10,83 +10,95 @@ pandora.ui.printView = function(data) {
backgroundColor: 'rgb(255, 255, 255)',
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({
background: 'rgb(255, 255, 255)',
overflow: 'auto'
});
Ox.LoadingScreen().appendTo(that);
pandora.api.find({
keys: keys.concat(['id', 'summary']),
query: pandora.user.ui.find,
range: [0, 1000000],
sort: keys.map(function(key) {
return {
key: key,
operator: Ox.getObjectById(pandora.site.itemKeys, key).operator
};
})
query: pandora.user.ui.find
}, function(result) {
var padding;
that.empty();
$('<div>')
.css({
height: '16px'
})
.html(
'<b>' + pandora.site.site.name + ' - '
+ (pandora.user.ui._list || 'All ' + pandora.site.itemName.plural)
+ '</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;
var totals = pandora.getStatusText(result.data);
pandora.api.find({
keys: keys,
query: pandora.user.ui.find,
range: [0, result.data.items],
sort: pandora.user.ui.listSort
}, function(result) {
var padding;
$loading.remove();
$('<div>')
.attr({title: url})
.css({
height: '16px',
textAlign: 'justify',
textOverflow: 'ellipsis',
overflow: 'hidden'
})
.css({height: '16px'})
.html(
(item.director ? item.director.join(', ') + ': ' : '')
+ '<b>' + item.title + '</b>'
+ (item.year ? ' (' + item.year + ')' : '')
+ (
item.summary
? ' <span style="color: rgb(128, 128, 128)">'
+ item.summary + '</span>'
: ''
)
'<b>' + pandora.site.site.name + ' - '
+ (pandora.user.ui._list || 'All ' + pandora.site.itemName.plural)
+ '</b>'
)
.appendTo(that);
$('<div>').css({height: '16px'}).appendTo(that);
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);
});
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() {

View File

@ -29,35 +29,6 @@ pandora.ui.statusbar = function() {
.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() {
pandora.api.find({
query: pandora.user.ui.find,
@ -83,10 +54,10 @@ pandora.ui.statusbar = function() {
} else {
$text.titleTotal.show();
$text.titleSelected.show();
$text.selected.html(getText(data)).show();
$text.selected.html(pandora.getStatusText(data)).show();
}
} 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) {
var prefix = pandora.site.site.videoprefix
.replace('{id}', id)