From 9d65ac96f6aef6fe2cd5bb104e132c31905ddede Mon Sep 17 00:00:00 2001 From: rolux Date: Sat, 9 Mar 2013 04:24:00 +0000 Subject: [PATCH] update print view --- static/js/pandora/URL.js | 2 + static/js/pandora/printView.js | 72 +++++++++++++++++++++++++++++----- static/js/pandora/utils.js | 13 ++++++ 3 files changed, 77 insertions(+), 10 deletions(-) diff --git a/static/js/pandora/URL.js b/static/js/pandora/URL.js index 45e7878e5..991ec7aab 100644 --- a/static/js/pandora/URL.js +++ b/static/js/pandora/URL.js @@ -105,6 +105,8 @@ pandora.URL = (function() { if (state.hash.query) { if (state.hash.query.embed === true) { // ... + } else if (state.hash.query.print == true) { + // ... } else { state.hash.query.forEach(function(kv) { set[kv.key] = kv.value; diff --git a/static/js/pandora/printView.js b/static/js/pandora/printView.js index 58af4a493..210684a93 100644 --- a/static/js/pandora/printView.js +++ b/static/js/pandora/printView.js @@ -5,38 +5,65 @@ pandora.ui.printView = function(data) { var that = Ox.Element() - .css({ - padding: '64px 128px', - backgroundColor: 'rgb(255, 255, 255)', - color: 'rgb(0, 0, 0)' - }), + .css({ + padding: '64px 128px', + backgroundColor: 'rgb(255, 255, 255)', + color: 'rgb(0, 0, 0)' + }), keys = ['director', 'year', 'title']; + Ox.$body.css({ + background: 'rgb(255, 255, 255)', + overflow: 'auto' + }); + + Ox.LoadingScreen().appendTo(that); + pandora.api.find({ - keys: keys.concat(['id']), + 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, 'year').operator + operator: Ox.getObjectById(pandora.site.itemKeys, key).operator }; }) }, function(result) { + var padding; + that.empty(); + $('
') + .css({ + height: '16px' + }) + .html( + '' + pandora.site.site.name + ' - ' + + (pandora.user.ui._list || 'All ' + pandora.site.itemName.plural) + + '' + ) + .appendTo(that); + $('
').css({height: '16px'}).appendTo(that); result.data.items && result.data.items.forEach(function(item) { var url = (pandora.site.https ? 'https://' : 'http://') - + pandora.site.url + '/' + item.id; + + pandora.site.site.url + '/' + item.id; $('
') .attr({title: url}) .css({ height: '16px', - overflow: 'hidden', - textOverflow: 'ellipsis' + textAlign: 'justify', + textOverflow: 'ellipsis', + overflow: 'hidden' }) .html( (item.director ? item.director.join(', ') + ': ' : '') + '' + item.title + '' + (item.year ? ' (' + item.year + ')' : '') + + ( + item.summary + ? ' ' + + item.summary + '' + : '' + ) ) .on({ click: function() { @@ -45,8 +72,33 @@ pandora.ui.printView = function(data) { }) .appendTo(that); }); + if (result.data.items.length) { + $('
').css({height: '16px'}).appendTo(that); + } + $('
') + .css({ + height: '16px' + }) + .html( + Ox.formatCount( + result.data.items.length, + pandora.site.itemName.singular, + pandora.site.itemName.plural + ).toLowerCase() + ) + .appendTo(that); }); + that.display = function() { + // fixme: move animation into Ox.App + var animate = $('.OxScreen').length == 0; + Ox.Log('', 'ANIMATE?', animate) + animate && pandora.$ui.body.css({opacity: 0}); + that.appendTo(pandora.$ui.body); + animate && pandora.$ui.body.animate({opacity: 1}, 1000); + return that; + }; + return that; }; \ No newline at end of file diff --git a/static/js/pandora/utils.js b/static/js/pandora/utils.js index 161bcc646..cc14210a5 100644 --- a/static/js/pandora/utils.js +++ b/static/js/pandora/utils.js @@ -652,6 +652,11 @@ pandora.getHash = function(state, callback) { && Ox.indexOf(state.hash.query, function(condition) { return Ox.isEqual(condition, {key: 'embed', value: true}); }) > -1, + isPrint = state.hash && state.hash.query + && Ox.indexOf(state.hash.query, function(condition) { + return Ox.isEqual(condition, {key: 'print', value: true}); + }) > -1, + printKeys = ['print'], removeKeys = []; if (state.hash && state.hash.anchor) { if (state.page == 'help') { @@ -672,6 +677,12 @@ pandora.getHash = function(state, callback) { removeKeys.push(condition.key); } }); + } else if (isPrint) { + state.hash.query.forEach(function(condition) { + if (!Ox.contains(printKeys, condition.key)) { + removeKeys.push(condition.key); + } + }); } else { state.hash.query.forEach(function(condition) { var key = condition.key.split('.')[0]; @@ -1313,6 +1324,8 @@ pandora.resizeFolders = function() { pandora.resizeWindow = function() { if (pandora.$ui.embedPanel) { pandora.$ui.embedPanel.resizePanel(); + } + if (pandora.$ui.embedPanel || pandora.$ui.printView) { return; } // FIXME: a lot of this throws errors on load