From 4e4471f1f633ea1f73c5d5bb26329806aef1a950 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 13 Mar 2018 18:09:48 +0530 Subject: [PATCH] fix named links in documents, fixes #3107 --- static/js/URL.js | 15 +++++++++++---- static/js/textPanel.js | 4 ++-- static/js/utils.js | 4 +++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/static/js/URL.js b/static/js/URL.js index a285c677..47a18527 100644 --- a/static/js/URL.js +++ b/static/js/URL.js @@ -23,9 +23,13 @@ pandora.URL = (function() { if ( state.page == 'document' && pandora.user.ui.documents[state.part] - && pandora.user.ui.documents[state.part].position + && ( + pandora.user.ui.documents[state.part].position || + pandora.user.ui.documents[state.part].name + ) ) { - state.span = pandora.user.ui.documents[state.part].position; + state.span = pandora.user.ui.documents[state.part].position || + pandora.user.ui.documents[state.part].name; } } @@ -107,7 +111,6 @@ pandora.URL = (function() { state.span = [position]; } } - } if ( @@ -251,7 +254,11 @@ pandora.URL = (function() { set[!state.item ? 'collectionView' : 'documentView'] = state.view; } if (state.span) { - set['documents.' + state.item] = {position: state.span}; + if (Ox.isNumber(state.pan)) { + set['documents.' + state.item] = {position: state.span}; + } else { + set['documents.' + state.item] = {name: state.span}; + } } if (!state.item && state.find) { set.findDocuments = state.find; diff --git a/static/js/textPanel.js b/static/js/textPanel.js index 65f1f33a..23e1340d 100644 --- a/static/js/textPanel.js +++ b/static/js/textPanel.js @@ -7,7 +7,7 @@ pandora.ui.textPanel = function(text, $toolbar) { that = Ox.SplitPanel({ elements: [ { - element: textElement = pandora.ui.textHTML(text) + element: textElement = pandora.$ui.textElement = pandora.ui.textHTML(text) }, { element: textEmbed = pandora.ui.textEmbed(textElement), @@ -195,7 +195,7 @@ pandora.ui.textHTML = function(text) { that.update(); }, }) - .bindEvent('pandora_documents.' + text.id.toLowerCase(), function(data) { + .bindEvent('pandora_documents.' + pandora.user.ui.document.toLowerCase(), function(data) { data.value && data.value.name && scrollToPosition(); }) .bindEvent('pandora_texts.' + text.id.toLowerCase(), function(data) { diff --git a/static/js/utils.js b/static/js/utils.js index 206e97f5..22ddb586 100644 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -1994,7 +1994,9 @@ pandora.getSpan = function(state, val, callback) { if (Ox.contains(['epub', 'pdf', 'txt'], extension)) { state.span = Ox.limit(parseInt(val), 1, dimensions); } else if (Ox.contains(['html'], extension)) { - state.span = Ox.limit(parseInt(val), 0, 100); + //fixme: allow numbers or check names? + //state.span = Ox.limit(parseInt(val), 0, 100); + state.span = val } else if (Ox.contains(['gif', 'jpg', 'png'], extension)) { values = val.split(','); if (values.length == 4) {