From f6ea1beb37e791b0e941782bb41202c6b6424a57 Mon Sep 17 00:00:00 2001 From: sque Date: Fri, 3 Jan 2014 20:36:31 +0200 Subject: [PATCH] Fix: links not working on map popups. Closes #23 --- templates/basic/scripts/javascripts/map.js | 41 ++++++++++++---------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/templates/basic/scripts/javascripts/map.js b/templates/basic/scripts/javascripts/map.js index 5327122..90172fd 100644 --- a/templates/basic/scripts/javascripts/map.js +++ b/templates/basic/scripts/javascripts/map.js @@ -37,10 +37,10 @@ NetworkMap = function(el_id, options) { }; // Default filter this._filter = $.extend({}, this._default_filter); - this._node_popup = null // The current Node popup - this._olControls = {}; // All used OL controls - this._olLayers = {}; // All used OL layers - this._controls = []; // All active NetworkMap controls + this._node_popup = null; // The current Node popup + this._olControls = {}; // All used OL controls + this._olLayers = {}; // All used OL layers + this._controls = []; // All active NetworkMap controls // Process options this._default_options = { @@ -119,12 +119,12 @@ NetworkMap.prototype._constructMap = function() { popup_body.html(), false ); - popup.autoSize = true; popup.panMapIfOutOfView = true; networkMapObject._node_popup = popup; networkMapObject._olMap.addPopup(popup); - + networkMapObject._popupInjectJS(popup.contentDiv); + }, onUnselect : function(feature) { if (networkMapObject._node_popup) @@ -177,7 +177,7 @@ NetworkMap.prototype._constructMap = function() { }; /** - * @brief Construct and return DOM Element for a node popup + * @brief Construct and return HTML for a node popup */ NetworkMap.prototype._constructNodePopup = function(feature) { @@ -193,21 +193,12 @@ NetworkMap.prototype._constructNodePopup = function(feature) { popup_body.find('.id').text('#'+String(feature.attributes['id'])); popup_body.find('a.node-info').text(lang['node_info']).attr('href', feature.attributes['url']); - $('body').delegate('.olPopupContent .extra-ref', 'click', function(e){ - e.preventDefault(); - console.log('clicked'); - }); - // Add extra references $.each(feature.attributes['extra_refs'], function(index, ref) { var ref_anchor = $('').text(ref['title']).attr('href', ref['href']); if (ref['popup']) { - var js_href = "javascript: t = window.open('" + ref['href'] - +"', 'popup_plot_link', 'width=600,height=450,toolbar=0,resizable=1,scrollbars=1'); t.focus(); return false;"; - console.log(js_href); - ref_anchor.attr('href', js_href); - + ref_anchor.addClass('popup'); } popup_body.append(ref_anchor); }); @@ -241,6 +232,19 @@ NetworkMap.prototype._constructNodePopup = function(feature) { return popup_body; }; +/** + * @brief Add extra javascript on DOM Element + */ +NetworkMap.prototype._popupInjectJS = function(popup) { + $(popup).find('a.extra-ref.popup').click(function(event){ + var iframe = $('