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, "showSitePosters": false,
"showTimeline": true, "showTimeline": true,
"sidebarSize": 256, "sidebarSize": 256,
"textPositions": {},
"theme": "oxdark", "theme": "oxdark",
"updateAdvancedFind": false, "updateAdvancedFind": false,
"videoMuted": false, "videoMuted": false,

View file

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

View file

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

View file

@ -54,6 +54,7 @@ pandora.UI = (function() {
self.previousUI = Ox.clone(pandora.user.ui, true); self.previousUI = Ox.clone(pandora.user.ui, true);
self.previousUI._list = pandora.getListState(self.previousUI.find); self.previousUI._list = pandora.getListState(self.previousUI.find);
if (args.section == 'texts') { if (args.section == 'texts') {
trigger['section'] = args['section']; trigger['section'] = args['section'];
trigger['text'] = args['text']; trigger['text'] = args['text'];

View file

@ -30,26 +30,31 @@ pandora.URL = (function() {
state.view = pandora.user.ui.itemView; state.view = pandora.user.ui.itemView;
state.sort = pandora.user.ui.itemSort; state.sort = pandora.user.ui.itemSort;
} }
} if (state.view == 'map') {
state.span = pandora.user.ui.mapFind
if (state.view == 'map') { ? '@' + pandora.user.ui.mapFind
state.span = pandora.user.ui.mapFind : pandora.user.ui.mapSelection
? '@' + pandora.user.ui.mapFind ? '@' + pandora.user.ui.mapSelection
: pandora.user.ui.mapSelection : '';
? '@' + pandora.user.ui.mapSelection } else if (state.view == 'calendar') {
: ''; // ...
} else if (state.view == 'calendar') { } else if (['timeline', 'player', 'editor'].indexOf(state.view) > -1) {
// ... var videoPoints = pandora.user.ui.videoPoints[state.item] || {};
} else if (['timeline', 'player', 'editor'].indexOf(state.view) > -1) { state.span = videoPoints.annotation || [].concat(
var videoPoints = pandora.user.ui.videoPoints[state.item] || {}; videoPoints.position
state.span = videoPoints.annotation || [].concat( ? videoPoints.position
videoPoints.position : [],
? videoPoints.position videoPoints['in'] || videoPoints.out
: [], ? [videoPoints['in'], videoPoints.out]
videoPoints['in'] || videoPoints.out : []
? [videoPoints['in'], videoPoints.out] );
: [] }
); } 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; set.find = pandora.site.user.ui.find;
} }
} }
} else if (state.type == 'texts') {
if (state.span) {
set['textPositions.' + state.item] = state.span;
}
} }
Ox.Request.cancel(); Ox.Request.cancel();
@ -275,7 +284,9 @@ pandora.URL = (function() {
} }
spanType['texts'] = { spanType['texts'] = {
list: [], list: [],
item: {} item: {
'text': 'number'
}
} }
sortKeys['texts'] = { sortKeys['texts'] = {
list: {}, list: {},

View file

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