From 8a2408ff7ec0edadb782fc7357726c7b20efc269 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Wed, 4 Feb 2015 15:42:16 +0530 Subject: [PATCH] include page in url of pdf documents --- static/js/URL.js | 11 ++++++++++- static/js/utils.js | 5 +++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/static/js/URL.js b/static/js/URL.js index 2cf76871c..91dd643f4 100644 --- a/static/js/URL.js +++ b/static/js/URL.js @@ -19,7 +19,12 @@ pandora.URL = (function() { if (Ox.contains(Object.keys(pandora.site.user.ui.part), state.page)) { state.part = pandora.user.ui.part[state.page]; } - + //fixme: pass zoom/center for images too + if (state.page == 'documents' + && pandora.user.ui.documents[state.part] + && pandora.user.ui.documents[state.part].page) { + state.parts = [pandora.user.ui.documents[state.part].page]; + } } else { state.type = pandora.user.ui.section == 'items' @@ -135,6 +140,10 @@ pandora.URL = (function() { if (Ox.contains(Object.keys(pandora.site.user.ui.part), state.page) && state.part) { set['part.' + state.page] = state.part; } + //fixme: parse zoom/center for images too + if (state.page == 'documents' && state.parts && state.parts.length == 1) { + set['documents.' + state.part + '.page'] = state.parts[0]; + } pandora.UI.set(set); callback && callback(); diff --git a/static/js/utils.js b/static/js/utils.js index ae3108a14..d75c07d9b 100644 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -1412,7 +1412,7 @@ pandora.getPageTitle = function(stateOrURL) { : null; }; -pandora.getPart = function(state, str, callback) { +pandora.getPart = function(state, str, parts, callback) { if (state.page == 'api') { pandora.api.api(function(result) { if (Ox.contains(Object.keys(result.data.actions), str)) { @@ -1476,7 +1476,8 @@ pandora.getPart = function(state, str, callback) { }, function(result) { if (result.data.items) { state.part = str; - //fixme set page/zoom/center here + //page/zoom/center get parsed in URL.js + state.parts = parts; } else { state.page = ''; }