text names

This commit is contained in:
j 2013-11-08 18:57:24 +00:00
parent 775003c298
commit 0ef598195c
4 changed files with 16 additions and 7 deletions

View file

@ -188,6 +188,9 @@ class Text(models.Model):
if self.type == 'pdf': if self.type == 'pdf':
response['uploaded'] = True if self.file and not self.uploading else False response['uploaded'] = True if self.file and not self.uploading else False
response['embeds'] = self.embeds response['embeds'] = self.embeds
response['names'] = []
else:
response['names'] = re.compile('<[^<>]*?data-name="(.+?)"').findall(self.text)
return response return response
def path(self, name=''): def path(self, name=''):

View file

@ -65,10 +65,12 @@ pandora.URL = (function() {
: [] : []
); );
} else if (pandora.user.ui.section == 'texts') { } else if (pandora.user.ui.section == 'texts') {
var position = pandora.user.ui.texts[state.item] var textState = pandora.user.ui.texts[state.item],
? pandora.user.ui.texts[state.item].position position = textState.position || 0;
: 0;
if (position) { if (textState.name) {
state.span = textState.name;
} else {
state.span = [position]; state.span = [position];
} }
} }
@ -217,7 +219,10 @@ pandora.URL = (function() {
} else if (state.type == 'texts') { } else if (state.type == 'texts') {
if (state.span) { 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
};
} }
} }

View file

@ -355,7 +355,8 @@ appPanel
view: 'list' view: 'list'
}; };
pandora.site.textSettings = { pandora.site.textSettings = {
position: 0 position: 0,
name: ''
}; };
Ox.extend(pandora.user, { Ox.extend(pandora.user, {

View file

@ -190,7 +190,7 @@ pandora.ui.textPanel = function() {
} }
function scrollToSelectedEmbed() { 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; position = 100 * scrollTop / pandora.$ui.text[0].scrollHeight;
pandora.$ui.text.scrollTo(position); pandora.$ui.text.scrollTo(position);
} }