From 30db2b8b630029a1b55f63b6ba8ef599f0707966 Mon Sep 17 00:00:00 2001 From: rolux Date: Thu, 27 Oct 2011 18:47:52 +0000 Subject: [PATCH] move enhancement of links into utils --- static/js/init.js | 2 +- static/js/pandora/infoView.js | 25 ++++--------------------- static/js/pandora/siteDialog.js | 3 ++- static/js/pandora/utils.js | 27 +++++++++++++++++++-------- 4 files changed, 26 insertions(+), 31 deletions(-) diff --git a/static/js/init.js b/static/js/init.js index b01117e3..0504471b 100644 --- a/static/js/init.js +++ b/static/js/init.js @@ -109,7 +109,7 @@ window.onerror = function(error, url, line) { 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(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.className = 'OxScreen'; loadingScreen.style.position = 'absolute'; diff --git a/static/js/pandora/infoView.js b/static/js/pandora/infoView.js index 4cf78866..9ab57495 100644 --- a/static/js/pandora/infoView.js +++ b/static/js/pandora/infoView.js @@ -111,16 +111,6 @@ pandora.ui.infoView = function(data) { right: margin + statisticsWidth + margin + 'px', //background: 'green' }) - .bind({ - click: function() { - return false; - } - }) - .bindEvent({ - singleclick: function(e) { - $(e.target).is('a') && clickLink(e); - } - }) .appendTo($data.$element), $statistics = $('
') @@ -134,6 +124,8 @@ pandora.ui.infoView = function(data) { $browserImages = []; + pandora.createLinks($text); + // Title ------------------------------------------------------------------- $('
') @@ -174,7 +166,7 @@ pandora.ui.infoView = function(data) { }) .append( Ox.Editable({ - clickLink: clickLink, + clickLink: pandora.clickLink, editable: isEditable, format: function(value) { return value @@ -212,7 +204,7 @@ pandora.ui.infoView = function(data) { .html(formatKey(key).replace('', ' ')) .appendTo($div); Ox.Editable({ - clickLink: clickLink, + clickLink: pandora.clickLink, format: function(value) { return value ? formatValue(value.split(', '), key) @@ -490,15 +482,6 @@ pandora.ui.infoView = function(data) { 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) { if (value != data[key]) { var edit = {id: data.id}; diff --git a/static/js/pandora/siteDialog.js b/static/js/pandora/siteDialog.js index 556a540f..825b26b6 100644 --- a/static/js/pandora/siteDialog.js +++ b/static/js/pandora/siteDialog.js @@ -15,12 +15,13 @@ pandora.ui.siteDialog = function(section) { pandora.api.getPage({name: id}, function(result) { Ox.print('DATA::', result.data) Ox.Editable({ + clickLink: pandora.clickLink, editable: pandora.site.capabilities.canEditSitePages[pandora.user.level], tooltip: 'Doubleclick to edit', type: 'textarea', value: result.data.body }) - .css({width: '100%'}) + .css({width: '100%'/*, height: '100%'*/}) .bindEvent({ submit: function(data) { Ox.Request.clearCache('getPage'); diff --git a/static/js/pandora/utils.js b/static/js/pandora/utils.js index d1900460..7e2416c7 100644 --- a/static/js/pandora/utils.js +++ b/static/js/pandora/utils.js @@ -134,15 +134,26 @@ pandora.addList = function() { } }; +pandora.clickLink = function(e) { + if (e.target.hostname == document.location.hostname) { + pandora.URL.push(e.target.pathname); + } else { + document.location.href = '/url=' + encodeURIComponent(e.target.href); + } +}; + pandora.createLinks = function($element) { - $element.find('a').click(function(event) { - if (event.target.hostname == document.location.hostname) { - pandora.URL.push(event.target.pathname); - } else { - document.location.href = '/url=' + encodeURIComponent(event.target.href); - } - return false; - }); + $element + .bind({ + click: function() { + return false; + } + }) + .bindEvent({ + singleclick: function(e) { + $(e.target).is('a') && pandora.clickLink(e); + } + }); }; pandora.enableDragAndDrop = function($list, canMove) {