From df60dca85f99d1f21a100cf59cfbb411fab8c09d Mon Sep 17 00:00:00 2001 From: j Date: Wed, 25 Jan 2017 22:01:40 +0100 Subject: [PATCH] return of the document dialog at /document/ --- pandora/config.0xdb.jsonc | 2 +- pandora/config.indiancinema.jsonc | 1 + pandora/config.padma.jsonc | 1 + pandora/config.pandora.jsonc | 1 + static/js/URL.js | 11 ++++++----- static/js/appPanel.js | 6 +++--- static/js/documentDialog.js | 8 ++++---- static/js/documentsPanel.js | 2 +- static/js/utils.js | 19 +++++++++++++------ 9 files changed, 31 insertions(+), 20 deletions(-) diff --git a/pandora/config.0xdb.jsonc b/pandora/config.0xdb.jsonc index 5d08a295..4c444c04 100644 --- a/pandora/config.0xdb.jsonc +++ b/pandora/config.0xdb.jsonc @@ -1258,7 +1258,7 @@ "page": "", "part": { "api": "", - "documents": "", + "document": "", "entities": "", "faq": "", "help": "", diff --git a/pandora/config.indiancinema.jsonc b/pandora/config.indiancinema.jsonc index f63b6e0b..4939ea95 100644 --- a/pandora/config.indiancinema.jsonc +++ b/pandora/config.indiancinema.jsonc @@ -1743,6 +1743,7 @@ "page": "", "part": { "api": "", + "document": "", "entities": "", "faq": "", "help": "", diff --git a/pandora/config.padma.jsonc b/pandora/config.padma.jsonc index 5a7b1fd9..49cf7b99 100644 --- a/pandora/config.padma.jsonc +++ b/pandora/config.padma.jsonc @@ -1205,6 +1205,7 @@ "page": "", "part": { "api": "", + "document": "", "entities": "", "faq": "", "help": "", diff --git a/pandora/config.pandora.jsonc b/pandora/config.pandora.jsonc index 4b67f730..aa3bd4a3 100644 --- a/pandora/config.pandora.jsonc +++ b/pandora/config.pandora.jsonc @@ -1159,6 +1159,7 @@ examples (config.SITENAME.jsonc) that are part of this pan.do/ra distribution. "page": "", "part": { "api": "", + "document": "", "entities": "", "faq": "", "help": "", diff --git a/static/js/URL.js b/static/js/URL.js index 316798f7..a285c677 100644 --- a/static/js/URL.js +++ b/static/js/URL.js @@ -20,15 +20,13 @@ pandora.URL = (function() { Ox.contains(Object.keys(pandora.site.user.ui.part), state.page) ) { state.part = pandora.user.ui.part[state.page]; - /* if ( - state.page == 'documents' - && pandora.user.ui.documents[state.part] + state.page == 'document' + && pandora.user.ui.documents[state.part] && pandora.user.ui.documents[state.part].position ) { state.span = pandora.user.ui.documents[state.part].position; } - */ } } else { @@ -174,6 +172,9 @@ pandora.URL = (function() { ) && state.part) { set['part.' + state.page] = state.part; } + if (state.span) { + set['documents.' + state.part] = {position: state.span}; + } pandora.UI.set(set); callback && callback(); @@ -473,7 +474,7 @@ pandora.URL = (function() { getSort: pandora.getSort, getSpan: pandora.getSpan, pages: [].concat( - ['home', 'software', 'api', 'help', 'tv', 'entities'], + ['home', 'software', 'api', 'help', 'tv', 'document', 'entities'], pandora.site.sitePages.map(function(page) { return page.id; }), diff --git a/static/js/appPanel.js b/static/js/appPanel.js index 40d49cb2..e1c4388f 100644 --- a/static/js/appPanel.js +++ b/static/js/appPanel.js @@ -71,10 +71,10 @@ 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) { + } else if (page == 'document') { + if (pandora.user.ui.part.document) { pandora.openDocumentDialog({ - ids: [pandora.user.ui.part.documents.split('/')[0]] + ids: [pandora.user.ui.part.document.split('/')[0]] }); } else { pandora.UI.set({page: ''}); diff --git a/static/js/documentDialog.js b/static/js/documentDialog.js index b57548bd..48938cd7 100644 --- a/static/js/documentDialog.js +++ b/static/js/documentDialog.js @@ -9,7 +9,7 @@ pandora.openDocumentDialog = function(options) { pandora.$ui.documentDialog && options.ids && options.ids.length == 1 && Ox.getObjectById(pandora.$ui.documentDialog.getItems(), options.ids[0]) ) { - pandora.UI.set({'part.documents': options.ids[0]}); + pandora.UI.set({'part.document': options.ids[0]}); } else if (options.ids) { pandora.api.findDocuments({ query: { @@ -37,7 +37,7 @@ pandora.openDocumentDialog = function(options) { }) .bindEvent({ close: function() { - pandora.user.ui.page == 'documents' && pandora.UI.set({page: ''}); + pandora.user.ui.page == 'document' && pandora.UI.set({page: ''}); } }) .open(); @@ -48,8 +48,8 @@ pandora.openDocumentDialog = function(options) { }); } pandora.UI.set({ - page: 'documents', - 'part.documents': options.documents[0].id + page: 'document', + 'part.document': options.documents[0].id }); return pandora.$ui.documentDialog; } diff --git a/static/js/documentsPanel.js b/static/js/documentsPanel.js index 814832d1..6b87ffc3 100644 --- a/static/js/documentsPanel.js +++ b/static/js/documentsPanel.js @@ -34,7 +34,7 @@ pandora.documentColumns = [ format: function(value, data) { return Ox.isArray(value) ? Ox.formatDimensions(value, 'px') - : Ox.formatCount(value, data.extension == 'html' ? 'word' : 'page'); + : Ox.formatCount(value, (data && data.extension == 'html') ? 'word' : 'page'); }, id: 'dimensions', operator: '-', diff --git a/static/js/utils.js b/static/js/utils.js index 864dea50..74b992ad 100644 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -1497,9 +1497,14 @@ pandora.getItem = function(state, str, callback) { } }); } else if (state.type == 'documents') { - pandora.api.getDocument({id: str, keys: ['id']}, function(result) { + pandora.api.getDocument({ + id: str, + // send keys so that subsequent request when parsing + // page number etc. is already in the cache + keys: ['dimensions', 'extension'] + }, function(result) { if (result.status.code == 200) { - state.item = result.data.id; + state.item = str; callback(); } else { state.item = ''; @@ -1808,7 +1813,7 @@ pandora.getPart = function(state, str, callback) { } else { callback(); } - } else if (state.page == 'documents') { + } else if (state.page == 'document') { var id = str.split('/')[0]; if (id) { pandora.api.getDocument({ @@ -1963,10 +1968,12 @@ pandora.getSpan = function(state, val, callback) { // modify state.view. // fixme: "subtitles:23" is still missing Ox.Log('URL', 'getSpan', state, val); - if (state.type == 'documents') { - if (state.item) { + if (state.page == 'document' || // document dialog + state.type == 'documents' // document section + ) { + if (state.page == 'document' || state.item) { pandora.api.getDocument({ - id: state.item, + id: state.page == 'document' ? state.part : state.item, keys: ['dimensions', 'extension'] }, function(result) { var dimensions = result.data.dimensions,