Skip to content

Commit

Permalink
Fix: links not working on map popups. Closes #23
Browse files Browse the repository at this point in the history
  • Loading branch information
sque committed Jan 3, 2014
1 parent 3100f1d commit f6ea1be
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions templates/basic/scripts/javascripts/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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) {

Expand All @@ -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 = $('<a class="link extra-ref" />').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);
});
Expand Down Expand Up @@ -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 = $('<iframe/>').attr('src', $(this).attr('href'));
$('<div class=\"map-node-action-popup\"/>').append(iframe)
.dialog({modal:true, width: 'auto', height: 'auto',});
event.preventDefault();
});

};

/**
* @brief Download network topology and update map
* @param focus_selected It will focus to selected node
Expand Down Expand Up @@ -597,7 +601,6 @@ var NetworkMapControlPicker = function(map, options) {
var pos = new OpenLayers.LonLat(this.options['position'][1], this.options['position'][0])
.transform('EPSG:4326', 'EPSG:3857');
this.options['position'] = pos;
console.log(this.options['zoom']);
if (!this.options['zoom'])
this.options['zoom'] = 17; // Auto zoom
} else {
Expand Down Expand Up @@ -687,4 +690,4 @@ NetworkMapControlPicker.prototype.getPosition = function() {
var pos = new OpenLayers.LonLat(this._marker.geometry.x, this._marker.geometry.y)
.transform('EPSG:3857', 'EPSG:4326');
return pos;
};
};

0 comments on commit f6ea1be

Please sign in to comment.