From 880aa60945d9a3807e07133d0a84b89af725dece Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 17 Jan 2014 13:49:11 +0000 Subject: [PATCH] inital version of document urls --- pandora/config.0xdb.jsonc | 1 + pandora/config.indiancinema.jsonc | 1 + pandora/config.padma.jsonc | 1 + pandora/config.pandora.jsonc | 1 + static/js/URL.js | 2 +- static/js/appPanel.js | 6 +++++ static/js/documentDialog.js | 39 +++++++++++++++++++++++++++++++ static/js/documentsPanel.js | 27 ++++----------------- static/js/utils.js | 22 +++++++++++++++++ 9 files changed, 76 insertions(+), 24 deletions(-) diff --git a/pandora/config.0xdb.jsonc b/pandora/config.0xdb.jsonc index 69797ebc..a9219ef0 100644 --- a/pandora/config.0xdb.jsonc +++ b/pandora/config.0xdb.jsonc @@ -813,6 +813,7 @@ "page": "", "part": { "api": "", + "documents": "", "faq": "", "help": "", "news": "", diff --git a/pandora/config.indiancinema.jsonc b/pandora/config.indiancinema.jsonc index ec3b4a8b..3c4413b3 100644 --- a/pandora/config.indiancinema.jsonc +++ b/pandora/config.indiancinema.jsonc @@ -829,6 +829,7 @@ "page": "", "part": { "api": "", + "documents": "", "faq": "", "help": "", "news": "", diff --git a/pandora/config.padma.jsonc b/pandora/config.padma.jsonc index 91522362..306de17d 100644 --- a/pandora/config.padma.jsonc +++ b/pandora/config.padma.jsonc @@ -703,6 +703,7 @@ "page": "", "part": { "api": "", + "documents": "", "faq": "", "help": "", "news": "", diff --git a/pandora/config.pandora.jsonc b/pandora/config.pandora.jsonc index 0541fbd1..8888bbf1 100644 --- a/pandora/config.pandora.jsonc +++ b/pandora/config.pandora.jsonc @@ -622,6 +622,7 @@ "page": "", "part": { "api": "", + "documents": "", "faq": "", "help": "", "news": "", diff --git a/static/js/URL.js b/static/js/URL.js index 0f703480..b5c11977 100644 --- a/static/js/URL.js +++ b/static/js/URL.js @@ -378,7 +378,7 @@ pandora.URL = (function() { getPart: pandora.getPart, getSpan: pandora.getSpan, pages: [].concat( - ['home', 'software', 'api', 'help', 'tv'], + ['home', 'software', 'api', 'help', 'tv', 'documents'], pandora.site.sitePages.map(function(page) { return page.id; }), diff --git a/static/js/appPanel.js b/static/js/appPanel.js index 6c4d6cc3..3db4b787 100644 --- a/static/js/appPanel.js +++ b/static/js/appPanel.js @@ -71,6 +71,12 @@ pandora.ui.appPanel = function() { !pandora.$ui.appPanel ? 'showScreen' : 'fadeInScreen' ](); pandora.$ui.home && pandora.$ui.tv.mute(); + } else if (page == 'documents') { + if (pandora.user.ui.part.documents) { + pandora.openDocumentDialog([pandora.user.ui.part.documents.split('/')[0]]); + } else { + pandora.UI.set({page: ''}); + } } else { // open dialog Ox.forEach(dialogPages, function(pages, dialog) { diff --git a/static/js/documentDialog.js b/static/js/documentDialog.js index d56adceb..c4a2e52a 100644 --- a/static/js/documentDialog.js +++ b/static/js/documentDialog.js @@ -2,6 +2,45 @@ 'use strict'; +pandora.openDocumentDialog = function(ids) { + + pandora.api.findDocuments({ + query: { + conditions: ids.map(function(id) { + return {key: 'id', value: id, operator: '=='} + }), + operator: '|' + }, + keys: ['description', 'dimensions', 'extension', 'id', 'name'] + }, function(result) { + var i = 0, documents = result.data.items.map(function(document) { + return Ox.extend({index: i++}, document); + }); + + if (!pandora.$ui.documentDialog) { + pandora.$ui.documentDialog = pandora.ui.documentDialog({ + index: 0, + items: documents, + }) + .bindEvent({ + close: function() { + pandora.user.ui.page == 'documents' && pandora.UI.set({page: ''}); + } + }) + .open(); + } else { + pandora.$ui.documentDialog.update({ + index: 0, + items: documents, + }); + } + pandora.UI.set({ + page: 'documents', + 'part.documents': documents[0].id + }); + }); +}; + pandora.ui.documentDialog = function(options) { var dialogHeight = Math.round((window.innerHeight - 48) * 0.9) + 24, diff --git a/static/js/documentsPanel.js b/static/js/documentsPanel.js index 4cc8c8f3..47a38cdf 100644 --- a/static/js/documentsPanel.js +++ b/static/js/documentsPanel.js @@ -5,7 +5,7 @@ pandora.ui.documentsPanel = function(options) { var ui = pandora.user.ui, - hasItemView = false, + hasItemView = false, // FIXME isItemView = options.isItemView, columns = [ @@ -396,7 +396,8 @@ pandora.ui.documentsPanel = function(options) { //fixme just upload list here //self.$documentsList.reloadList(); pandora.$ui.contentPanel.replaceElement(1, - pandora.$ui.item = pandora.ui.item()); + pandora.$ui.item = pandora.ui.item() + ); } }); } @@ -450,27 +451,7 @@ pandora.ui.documentsPanel = function(options) { } function openDocuments() { - if (!pandora.$ui.documentDialog) { - pandora.$ui.documentDialog = pandora.ui.documentDialog({ - index: 0, - items: $list.options('selected').map(function(id) { - return $list.value(id); - }) - }) - .bindEvent({ - close: function() { - $list.closePreview(); - } - }) - .open(); - } else { - pandora.$ui.documentDialog.update({ - index: 0, - items: $list.options('selected').map(function(id) { - return $list.value(id); - }) - }); - } + pandora.openDocumentDialog($list.options('selected')); } function openDocumentsDialog() { diff --git a/static/js/utils.js b/static/js/utils.js index 9373ecd5..352aa76f 100644 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -1407,6 +1407,28 @@ pandora.getPart = function(state, str, callback) { } else { callback(); } + } else if (state.page == 'documents') { + var split = str.split('/')[0], + id = split[0]; + if (id) { + pandora.api.findDocuments({ + query: { + conditions: [{key: 'id', value: id, operator: '=='}], + operator: '&' + } + }, function(result) { + if (result.data.items) { + state.part = str; + //fixme set page/zoom/center here + } else { + state.page = ''; + } + callback(); + }); + } else { + state.page = ''; + callback(); + } } else { callback(); }