From 0b474aa4cbb3e74a75925070b75a259dfc6a3482 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 2 Mar 2013 13:01:07 +0000 Subject: [PATCH] remember page for pdf texts and show in url --- pandora/config.0xdb.jsonc | 1 + pandora/config.indiancinema.jsonc | 1 + pandora/config.padma.jsonc | 1 + static/js/pandora/UI.js | 1 + static/js/pandora/URL.js | 53 +++++++++++++++++++------------ static/js/pandora/textPanel.js | 14 +++++--- static/pdf.js/embeds.js | 14 ++++++++ 7 files changed, 60 insertions(+), 25 deletions(-) diff --git a/pandora/config.0xdb.jsonc b/pandora/config.0xdb.jsonc index c6263a75..fbdc013d 100644 --- a/pandora/config.0xdb.jsonc +++ b/pandora/config.0xdb.jsonc @@ -776,6 +776,7 @@ "showSitePosters": false, "showTimeline": true, "sidebarSize": 256, + "textPositions": {}, "theme": "oxdark", "updateAdvancedFind": false, "videoMuted": false, diff --git a/pandora/config.indiancinema.jsonc b/pandora/config.indiancinema.jsonc index 2ef1ca72..9d3be41e 100644 --- a/pandora/config.indiancinema.jsonc +++ b/pandora/config.indiancinema.jsonc @@ -782,6 +782,7 @@ "showSitePosters": false, "showTimeline": true, "sidebarSize": 256, + "textPositions": {}, "theme": "oxmedium", "updateAdvancedFind": false, "videoMuted": false, diff --git a/pandora/config.padma.jsonc b/pandora/config.padma.jsonc index 266ec4bb..346f16b7 100644 --- a/pandora/config.padma.jsonc +++ b/pandora/config.padma.jsonc @@ -698,6 +698,7 @@ "showSitePosters": false, "showTimeline": true, "sidebarSize": 256, + "textPositions": {}, "theme": "oxlight", "updateAdvancedFind": false, "videoMuted": false, diff --git a/static/js/pandora/UI.js b/static/js/pandora/UI.js index 7754b905..e5b9bf8f 100644 --- a/static/js/pandora/UI.js +++ b/static/js/pandora/UI.js @@ -54,6 +54,7 @@ pandora.UI = (function() { self.previousUI = Ox.clone(pandora.user.ui, true); self.previousUI._list = pandora.getListState(self.previousUI.find); + if (args.section == 'texts') { trigger['section'] = args['section']; trigger['text'] = args['text']; diff --git a/static/js/pandora/URL.js b/static/js/pandora/URL.js index 7bc4bda9..b0d94c67 100644 --- a/static/js/pandora/URL.js +++ b/static/js/pandora/URL.js @@ -30,26 +30,31 @@ pandora.URL = (function() { state.view = pandora.user.ui.itemView; state.sort = pandora.user.ui.itemSort; } - } - - if (state.view == 'map') { - state.span = pandora.user.ui.mapFind - ? '@' + pandora.user.ui.mapFind - : pandora.user.ui.mapSelection - ? '@' + pandora.user.ui.mapSelection - : ''; - } else if (state.view == 'calendar') { - // ... - } else if (['timeline', 'player', 'editor'].indexOf(state.view) > -1) { - var videoPoints = pandora.user.ui.videoPoints[state.item] || {}; - state.span = videoPoints.annotation || [].concat( - videoPoints.position - ? videoPoints.position - : [], - videoPoints['in'] || videoPoints.out - ? [videoPoints['in'], videoPoints.out] - : [] - ); + if (state.view == 'map') { + state.span = pandora.user.ui.mapFind + ? '@' + pandora.user.ui.mapFind + : pandora.user.ui.mapSelection + ? '@' + pandora.user.ui.mapSelection + : ''; + } else if (state.view == 'calendar') { + // ... + } else if (['timeline', 'player', 'editor'].indexOf(state.view) > -1) { + var videoPoints = pandora.user.ui.videoPoints[state.item] || {}; + state.span = videoPoints.annotation || [].concat( + videoPoints.position + ? videoPoints.position + : [], + videoPoints['in'] || videoPoints.out + ? [videoPoints['in'], videoPoints.out] + : [] + ); + } + } else if (pandora.user.ui.section == 'texts') { + state.view = 'text'; + var position = pandora.user.ui.textPositions[pandora.user.ui.text]; + if (position) { + state.span = position; + } } } @@ -160,6 +165,10 @@ pandora.URL = (function() { set.find = pandora.site.user.ui.find; } } + } else if (state.type == 'texts') { + if (state.span) { + set['textPositions.' + state.item] = state.span; + } } Ox.Request.cancel(); @@ -275,7 +284,9 @@ pandora.URL = (function() { } spanType['texts'] = { list: [], - item: {} + item: { + 'text': 'number' + } } sortKeys['texts'] = { list: {}, diff --git a/static/js/pandora/textPanel.js b/static/js/pandora/textPanel.js index 88cf8633..ec882490 100644 --- a/static/js/pandora/textPanel.js +++ b/static/js/pandora/textPanel.js @@ -326,18 +326,20 @@ pandora.ui.textHTML = function(text) { pandora.ui.textPDF = function(text) { var that = Ox.Element(), - $iframe; + $iframe, + page = pandora.user.ui.textPositions[pandora.user.ui.text] ? + pandora.user.ui.textPositions[pandora.user.ui.text][0] : 1, + url = '/texts/' + pandora.user.ui.text + '/text.pdf.html#page=' + page; if (text.uploaded) { $iframe = Ox.Element('