add print view

This commit is contained in:
rolux 2013-03-09 09:19:15 +05:30
commit ec3ffee3db
4 changed files with 70 additions and 8 deletions

View file

@ -1,6 +1,6 @@
'use strict';
// FIXME: rename to embed
// FIXME: rename to embedView
pandora.ui.embedPanel = function() {

View file

@ -307,6 +307,8 @@ pandora.ui.mainMenu = function() {
pandora.$ui.uploadDialog = pandora.ui.uploadDialog().open();
} else if (data.id == 'deletelist') {
pandora.ui.deleteListDialog().open();
} else if (data.id == 'print') {
window.open('#?print=true', '_blank')
} else if (data.id == 'showsidebar') {
pandora.UI.set({showSidebar: !ui.showSidebar});
} else if (data.id == 'showinfo') {
@ -410,6 +412,9 @@ pandora.ui.mainMenu = function() {
}
}
},
key_control_p: function() {
window.open('#?print=true', '_blank');
},
key_control_shift_f: function() {
if (!pandora.hasDialogOrScreen()) {
pandora.$ui.filterDialog = pandora.ui.filterDialog().open();
@ -671,6 +676,7 @@ pandora.ui.mainMenu = function() {
{ id: 'editlist', title: 'Edit Selected List...', disabled: isGuest || !pandora.user.ui._list, keyboard: 'control e' },
{ id: 'deletelist', title: 'Delete Selected List...', disabled: isGuest || !pandora.user.ui._list, keyboard: 'delete' },
{},
{ id: 'print', title: 'Print', keyboard: 'control p' },
{ id: 'tv', title: 'TV', keyboard: 'control space' }
]
)};

View file

@ -0,0 +1,52 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript
'use strict';
pandora.ui.printView = function(data) {
var that = Ox.Element()
.css({
padding: '64px 128px',
backgroundColor: 'rgb(255, 255, 255)',
color: 'rgb(0, 0, 0)'
}),
keys = ['director', 'year', 'title'];
pandora.api.find({
keys: keys.concat(['id']),
query: pandora.user.ui.find,
range: [0, 1000000],
sort: keys.map(function(key) {
return {
key: key,
operator: Ox.getObjectById(pandora.site.itemKeys, 'year').operator
};
})
}, function(result) {
result.data.items && result.data.items.forEach(function(item) {
var url = (pandora.site.https ? 'https://' : 'http://')
+ pandora.site.url + '/' + item.id;
$('<div>')
.attr({title: url})
.css({
height: '16px',
overflow: 'hidden',
textOverflow: 'ellipsis'
})
.html(
(item.director ? item.director.join(', ') + ': ' : '')
+ '<b>' + item.title + '</b>'
+ (item.year ? ' (' + item.year + ')' : '')
)
.on({
click: function() {
document.location.href = url;
}
})
.appendTo(that);
});
});
return that;
};