remember page for pdf texts and show in url

This commit is contained in:
j 2013-03-02 13:01:07 +00:00
parent f8830119e0
commit 0b474aa4cb
7 changed files with 60 additions and 25 deletions

View file

@ -776,6 +776,7 @@
"showSitePosters": false,
"showTimeline": true,
"sidebarSize": 256,
"textPositions": {},
"theme": "oxdark",
"updateAdvancedFind": false,
"videoMuted": false,

View file

@ -782,6 +782,7 @@
"showSitePosters": false,
"showTimeline": true,
"sidebarSize": 256,
"textPositions": {},
"theme": "oxmedium",
"updateAdvancedFind": false,
"videoMuted": false,

View file

@ -698,6 +698,7 @@
"showSitePosters": false,
"showTimeline": true,
"sidebarSize": 256,
"textPositions": {},
"theme": "oxlight",
"updateAdvancedFind": false,
"videoMuted": false,

View file

@ -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'];

View file

@ -30,8 +30,6 @@ 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
@ -51,6 +49,13 @@ pandora.URL = (function() {
: []
);
}
} 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: {},

View file

@ -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('<iframe>')
.attr({
frameborder: 0,
height: '100%',
src: '/texts/' + pandora.user.ui.text + '/text.pdf.html',
src: url,
width: '100%'
})
.onMessage(function(event, data) {
if(event == 'edit') {
console.log('existing url?', data);
pandora.ui.insertEmbedDialog(data.src, function(url) {
data.src = url;
var embed = text.embeds.filter(function(embed) {
@ -352,7 +354,6 @@ pandora.ui.textPDF = function(text) {
text.embeds.push(data);
//fixme sort embeds by page/id
}
console.log('saving', text.embeds);
pandora.api.editText({
id: text.id,
embeds: text.embeds
@ -360,9 +361,14 @@ pandora.ui.textPDF = function(text) {
$iframe.postMessage('update', data);
});
}).open();
} else if (event == 'page') {
pandora.UI.set('textPositions.' + pandora.user.ui.text, [data.page]);
}
})
.appendTo(that);
that.setPage = function(page) {
$iframe && $iframe.postMessage('page', {page: page});
}
} else {
that.html('UPLOADED: ' + text.uploaded);
}

View file

@ -1,3 +1,17 @@
Ox.load(function() {
window.addEventListener('hashchange', function() {
var page = document.location.hash.substring(1).split('=')[1];
page && Ox.$parent.postMessage('page', {
page: page
});
});
Ox.$parent.onMessage(function(event, data, oxid) {
if (event == 'page' && Ox.isUndefined(oxid)) {
window.location.hash = '#page=' + data.page;
}
});
});
function getVideoOverlay(page) {
var links = embeds.filter(function(embed) {
return embed.page == page && embed.type =='inline';