make external links work in info view

This commit is contained in:
rlx 2011-08-07 17:05:49 +00:00
parent ea343d68f0
commit 0855eafec0
2 changed files with 29 additions and 27 deletions

View File

@ -3,12 +3,11 @@
pandora.URL = (function() {
var old = {
user: {
ui: {}
}
},
regexps = {
var regexps = {
'^\\?url=': function(url) {
Ox.print('URL', url)
document.location = decodeURIComponent(url.substr(5));
},
'^\\?': function(url) {
pandora.Query.fromString(url);
pandora.UI.set({
@ -33,7 +32,7 @@ pandora.URL = (function() {
sitePage: url
});
},
'^(find)$': function() {
'^find$': function() {
pandora.Query.fromString('?find='); // fixme: silly hack
pandora.UI.set({
section: 'items',
@ -47,6 +46,11 @@ pandora.URL = (function() {
});
pandora.UI.set(['lists', pandora.user.ui.list, 'listView'].join('|'), url);
},
'^texts$': function() {
pandora.UI.set({
section: 'texts'
});
},
'^[0-9A-Z]': function(url) {
var split = url.split('/'),
item = split[0],
@ -61,11 +65,6 @@ pandora.URL = (function() {
item: item,
itemView: view
});
},
'^texts$': function() {
pandora.UI.set({
section: 'texts'
});
}
};
@ -75,8 +74,11 @@ pandora.URL = (function() {
if (arguments.length == 1) { // fixme: remove later
url = title;
}
history.pushState({}, pandora.site.site.name + (title ? ' - ' + title : ''), '/' + url);
old.user.ui = $.extend({}, pandora.user.ui); // make a clone
if (url[0] != '/') {
url = '/' + url;
}
history.pushState({}, pandora.site.site.name + (title ? ' - ' + title : ''), url);
oldUserUI = Ox.clone(pandora.user.ui);
this.update();
},
@ -97,29 +99,29 @@ pandora.URL = (function() {
update: function() {
this.parse();
if (pandora.user.ui.section != old.user.ui.section) {
if (pandora.user.ui.section != oldUserUI.section) {
pandora.$ui.appPanel.replaceElement(1, pandora.$ui.mainPanel = pandora.ui.mainPanel());
} else if (pandora.user.ui.sitePage != old.user.ui.sitePage) {
} else if (pandora.user.ui.sitePage != oldUserUI.sitePage) {
pandora.$ui.mainPanel.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel());
} else if (!pandora.user.ui.item || !old.user.ui.item) {
} else if (!pandora.user.ui.item || !oldUserUI.item) {
pandora.$ui.mainPanel.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel());
pandora.$ui.leftPanel.replaceElement(2, pandora.$ui.info = pandora.ui.info());
} else {
pandora.$ui.contentPanel.replaceElement(1, pandora.ui.item());
pandora.$ui.leftPanel.replaceElement(2, pandora.$ui.info = pandora.ui.info());
}
// fixme: should be 'editor', not 'timeline'
if (
old.user.ui.item &&
['player', 'timeline'].indexOf(old.user.ui.itemView) > -1
oldUserUI.item &&
['player', 'timeline'].indexOf(oldUserUI.itemView) > -1
) {
pandora.UI.set(
'videoPosition|' + old.user.ui.item,
'videoPosition|' + oldUserUI.item,
pandora.$ui[
old.user.ui.itemView == 'player' ? 'player' : 'editor'
oldUserUI.itemView == 'player' ? 'player' : 'editor'
].options('position')
);
}
//delete old.user.ui;
}
};

View File

@ -89,9 +89,9 @@ pandora.ui.infoView = function(data) {
.bind({
click: function(e) {
var $target = $(e.target);
if ($target.is('.OxLink')) {
Ox.print('LINK', $target.data('link'));
pandora.URL.set($target.data('link'));
if ($target.is('a')) {
pandora.URL.set($target.attr('href'));
return false;
}
}
})
@ -304,7 +304,7 @@ pandora.ui.infoView = function(data) {
.css(css)
.html(
formatKey(key) + data[key].map(function(value) {
return '<a href="' + value.url + '">' + value.source + '</a>'
return '<a href="/?url=' + encodeURIComponent(value.url) + '">' + value.source + '</a>'
}).join(', ')
)
.appendTo($text);
@ -431,7 +431,7 @@ pandora.ui.infoView = function(data) {
function formatValue(value, key) {
return (Ox.isArray(value) ? value : [value]).map(function(value) {
return key ?
'<span class="OxLink" data-link="?find=' + key + ':' + value + '">' + value + '</span>'
'<a href="/?find=' + key + ':' + value + '">' + value + '</a>'
: value;
//return key ? '<a href="/?find=' + key + ':' + value + '">' + value + '</a>' : value;
}).join(', ');