diff --git a/pandora/text/models.py b/pandora/text/models.py index 2d758ae7..52a40047 100644 --- a/pandora/text/models.py +++ b/pandora/text/models.py @@ -188,6 +188,9 @@ class Text(models.Model): if self.type == 'pdf': response['uploaded'] = True if self.file and not self.uploading else False response['embeds'] = self.embeds + response['names'] = [] + else: + response['names'] = re.compile('<[^<>]*?data-name="(.+?)"').findall(self.text) return response def path(self, name=''): diff --git a/static/js/URL.js b/static/js/URL.js index 6edcedba..0dd103b6 100644 --- a/static/js/URL.js +++ b/static/js/URL.js @@ -65,10 +65,12 @@ pandora.URL = (function() { : [] ); } else if (pandora.user.ui.section == 'texts') { - var position = pandora.user.ui.texts[state.item] - ? pandora.user.ui.texts[state.item].position - : 0; - if (position) { + var textState = pandora.user.ui.texts[state.item], + position = textState.position || 0; + + if (textState.name) { + state.span = textState.name; + } else { state.span = [position]; } } @@ -217,7 +219,10 @@ pandora.URL = (function() { } else if (state.type == 'texts') { if (state.span) { - set['texts.' + pandora.UI.encode(state.item) + '.position'] = state.span[0]; + set['texts.' + pandora.UI.encode(state.item)] = { + position: Ox.isArray(state.span) ? state.span[0] : 0, + name: Ox.isArray(state.span) ? '' : state.span + }; } } diff --git a/static/js/pandora.js b/static/js/pandora.js index 82b01520..dd38ceed 100644 --- a/static/js/pandora.js +++ b/static/js/pandora.js @@ -355,7 +355,8 @@ appPanel view: 'list' }; pandora.site.textSettings = { - position: 0 + position: 0, + name: '' }; Ox.extend(pandora.user, { diff --git a/static/js/textPanel.js b/static/js/textPanel.js index f4bc5676..359698b4 100644 --- a/static/js/textPanel.js +++ b/static/js/textPanel.js @@ -190,7 +190,7 @@ pandora.ui.textPanel = function() { } function scrollToSelectedEmbed() { - var scrollTop = Math.max(pandora.$ui.text[0].scrollTop + $('#embed' + selected).offset().top - 50, 0), + var scrollTop = Math.max(pandora.$ui.text[0].scrollTop + $('#embed' + selected).offset().top - 48, 0), position = 100 * scrollTop / pandora.$ui.text[0].scrollHeight; pandora.$ui.text.scrollTo(position); }