pandora/static/js/printView.js

122 lines
4.4 KiB
JavaScript
Raw Permalink Normal View History

2013-03-09 03:49:15 +00:00
'use strict';
pandora.ui.printView = function(data) {
var that = Ox.Element().css({padding: '64px 128px'}),
2013-11-20 08:12:59 +00:00
$loading = Ox.LoadingScreen().start().appendTo(that),
2013-03-09 05:27:07 +00:00
sortKey = pandora.user.ui.listSort[0].key,
keys = Ox.unique(
['director', 'id', 'summary', 'title', 'year'].concat(sortKey)
);
$($loading.find('img')[0]).attr({
2014-09-26 12:30:51 +00:00
src: Ox.UI.getImageURL('symbolLoadingAnimated', null, 'oxlight')
});
2013-03-09 04:24:00 +00:00
Ox.$body.css({
background: 'rgb(255, 255, 255)',
overflow: 'auto'
});
2013-03-09 03:49:15 +00:00
pandora.api.find({
2013-03-09 05:27:07 +00:00
query: pandora.user.ui.find
2013-03-09 03:49:15 +00:00
}, function(result) {
2013-03-09 05:27:07 +00:00
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();
2013-03-09 03:49:15 +00:00
$('<div>')
.css({
height: '16px',
color: 'rgb(0, 0, 0)'
})
2013-03-09 03:49:15 +00:00
.html(
2013-03-09 05:27:07 +00:00
'<b>' + pandora.site.site.name + ' - '
2013-03-09 05:33:03 +00:00
+ (
pandora.user.ui._list
? 'List ' + pandora.user.ui._list
: 'All ' + pandora.site.itemName.plural
) + '</b>'
2013-03-09 05:27:07 +00:00
)
.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',
color: 'rgb(0, 0, 0)',
2013-03-09 05:27:07 +00:00
textAlign: 'justify',
textOverflow: 'ellipsis',
2013-03-09 05:30:35 +00:00
cursor: 'pointer',
2013-03-09 05:27:07 +00:00
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)">'
+ Ox.encodeHTMLEntities(item.summary)
+ '</span>'
2013-03-09 05:27:07 +00:00
: ''
)
2013-03-09 04:24:00 +00:00
)
2013-03-09 05:27:07 +00:00
.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>'
2013-03-09 03:49:15 +00:00
)
.appendTo(that);
});
});
2013-03-09 04:24:00 +00:00
that.display = function() {
// fixme: move animation into Ox.App
var animate = $('.OxScreen').length == 0;
Ox.Log('', 'ANIMATE?', animate)
animate && Ox.$body.css({opacity: 0});
that.appendTo(Ox.$body);
animate && Ox.$body.animate({opacity: 1}, 1000);
2013-03-09 04:24:00 +00:00
return that;
};
2013-03-09 03:49:15 +00:00
return that;
2018-06-19 06:33:26 +00:00
};