move enhancement of links into utils

This commit is contained in:
rolux 2011-10-27 18:47:52 +00:00
parent d30c2ba78e
commit 30db2b8b63
4 changed files with 26 additions and 31 deletions

View file

@ -109,7 +109,7 @@ window.onerror = function(error, url, line) {
gradient.style.background = theme == 'classic' gradient.style.background = theme == 'classic'
? '-webkit-linear-gradient(top, rgba(224, 224, 224, 0.75), rgba(224, 224, 224, 1), rgba(224, 224, 224, 1))' ? '-webkit-linear-gradient(top, rgba(224, 224, 224, 0.75), rgba(224, 224, 224, 1), rgba(224, 224, 224, 1))'
: '-webkit-linear-gradient(top, rgba(32, 32, 32, 0.75), rgba(32, 32, 32, 1), rgba(32, 32, 32, 1))'; : '-webkit-linear-gradient(top, rgba(32, 32, 32, 0.75), rgba(32, 32, 32, 1), rgba(32, 32, 32, 1))';
loadingScreen = document.createElement('div'); var loadingScreen = document.createElement('div');
loadingScreen.setAttribute('id', 'loadingScreen'); loadingScreen.setAttribute('id', 'loadingScreen');
loadingScreen.className = 'OxScreen'; loadingScreen.className = 'OxScreen';
loadingScreen.style.position = 'absolute'; loadingScreen.style.position = 'absolute';

View file

@ -111,16 +111,6 @@ pandora.ui.infoView = function(data) {
right: margin + statisticsWidth + margin + 'px', right: margin + statisticsWidth + margin + 'px',
//background: 'green' //background: 'green'
}) })
.bind({
click: function() {
return false;
}
})
.bindEvent({
singleclick: function(e) {
$(e.target).is('a') && clickLink(e);
}
})
.appendTo($data.$element), .appendTo($data.$element),
$statistics = $('<div>') $statistics = $('<div>')
@ -134,6 +124,8 @@ pandora.ui.infoView = function(data) {
$browserImages = []; $browserImages = [];
pandora.createLinks($text);
// Title ------------------------------------------------------------------- // Title -------------------------------------------------------------------
$('<div>') $('<div>')
@ -174,7 +166,7 @@ pandora.ui.infoView = function(data) {
}) })
.append( .append(
Ox.Editable({ Ox.Editable({
clickLink: clickLink, clickLink: pandora.clickLink,
editable: isEditable, editable: isEditable,
format: function(value) { format: function(value) {
return value return value
@ -212,7 +204,7 @@ pandora.ui.infoView = function(data) {
.html(formatKey(key).replace('</span>', '&nbsp;</span>')) .html(formatKey(key).replace('</span>', '&nbsp;</span>'))
.appendTo($div); .appendTo($div);
Ox.Editable({ Ox.Editable({
clickLink: clickLink, clickLink: pandora.clickLink,
format: function(value) { format: function(value) {
return value return value
? formatValue(value.split(', '), key) ? formatValue(value.split(', '), key)
@ -490,15 +482,6 @@ pandora.ui.infoView = function(data) {
renderList(); renderList();
} }
function clickLink(e) {
if (e.target.hostname == document.location.hostname) {
pandora.URL.push(e.target.pathname);
} else {
document.location.href = '/url=' + encodeURIComponent(e.target.href);
}
return false;
}
function editMetadata(key, value) { function editMetadata(key, value) {
if (value != data[key]) { if (value != data[key]) {
var edit = {id: data.id}; var edit = {id: data.id};

View file

@ -15,12 +15,13 @@ pandora.ui.siteDialog = function(section) {
pandora.api.getPage({name: id}, function(result) { pandora.api.getPage({name: id}, function(result) {
Ox.print('DATA::', result.data) Ox.print('DATA::', result.data)
Ox.Editable({ Ox.Editable({
clickLink: pandora.clickLink,
editable: pandora.site.capabilities.canEditSitePages[pandora.user.level], editable: pandora.site.capabilities.canEditSitePages[pandora.user.level],
tooltip: 'Doubleclick to edit', tooltip: 'Doubleclick to edit',
type: 'textarea', type: 'textarea',
value: result.data.body value: result.data.body
}) })
.css({width: '100%'}) .css({width: '100%'/*, height: '100%'*/})
.bindEvent({ .bindEvent({
submit: function(data) { submit: function(data) {
Ox.Request.clearCache('getPage'); Ox.Request.clearCache('getPage');

View file

@ -134,14 +134,25 @@ pandora.addList = function() {
} }
}; };
pandora.createLinks = function($element) { pandora.clickLink = function(e) {
$element.find('a').click(function(event) { if (e.target.hostname == document.location.hostname) {
if (event.target.hostname == document.location.hostname) { pandora.URL.push(e.target.pathname);
pandora.URL.push(event.target.pathname);
} else { } else {
document.location.href = '/url=' + encodeURIComponent(event.target.href); document.location.href = '/url=' + encodeURIComponent(e.target.href);
} }
};
pandora.createLinks = function($element) {
$element
.bind({
click: function() {
return false; return false;
}
})
.bindEvent({
singleclick: function(e) {
$(e.target).is('a') && pandora.clickLink(e);
}
}); });
}; };