Skip to content

Commit

Permalink
Merge pull request #6 from geobretagne/develop
Browse files Browse the repository at this point in the history
Theme update
  • Loading branch information
lbodiguel committed Jun 9, 2015
2 parents d7464a9 + 5670091 commit 9cd06b4
Show file tree
Hide file tree
Showing 15 changed files with 243 additions and 367 deletions.
220 changes: 0 additions & 220 deletions web/sites/all/modules/popp_utilities/js/LoadingPanel.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -135,39 +135,4 @@ Drupal.openlayers.addBehavior('openlayers_behavior_cluster_popp', function (data

layer.redraw();
});
});

/**
* Override of callback used by 'popup' behaviour to support clusters
*/
Drupal.theme.openlayersPopup = function (feature) {
if (feature.cluster) {
var output = '';
var visited = []; // to keep track of already-visited items
var classes = [];

for (var i = 0; i < feature.cluster.length; i++) {
var pf = feature.cluster[i]; // pseudo-feature
if (typeof pf.drupalFID != 'undefined') {
var mapwide_id = feature.layer.drupalID + pf.drupalFID;
if (mapwide_id in visited) continue;
visited[mapwide_id] = true;
}

classes = [];
if (i == 0) {
classes.push('first');
}
if (i == (feature.cluster.length - 1)) {
classes.push('last');
}

output += '<div class="'+classes.join(' ')+'">' +
Drupal.theme.prototype.openlayersPopup(pf) + '</div>';
}
return output;
}
else {
return Drupal.theme.prototype.openlayersPopup(feature);
}
};
});
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,42 @@ Drupal.theme.prototype.openlayersPopup = function (feature) {
return output;
};

/**
* Theming popup
*/
Drupal.theme.openlayersPopup = function (feature) {
if (feature.cluster) {
var output = '';
var visited = []; // to keep track of already-visited items
var classes = [];

for (var i = 0; i < feature.cluster.length; i++) {
var pf = feature.cluster[i]; // pseudo-feature
if (typeof pf.drupalFID != 'undefined') {
var mapwide_id = feature.layer.drupalID + pf.drupalFID;
if (mapwide_id in visited) continue;
visited[mapwide_id] = true;
}

classes = [];
if (i == 0) {
classes.push('first');
}
if (i == (feature.cluster.length - 1)) {
classes.push('last');
}

output += '<div class="'+classes.join(' ')+'">' +
Drupal.theme.prototype.openlayersPopup(pf) + '</div>';
}
return output;
}
else {
return Drupal.theme.prototype.openlayersPopup(feature);
}
};


// Make sure the namespace exists
Drupal.openlayers.popup = Drupal.openlayers.popup || {};
/**
Expand Down Expand Up @@ -61,14 +97,8 @@ Drupal.openlayers.addBehavior('openlayers_behavior_popp_popup', function (data,
renderIntent: 'temporary',
overFeature: function (feature) {
var lonlat;
if (options.popupAtPosition == 'mouse') {
lonlat = map.getLonLatFromPixel(
this.handlers.feature.evt.xy
);
} else {
lonlat = feature.geometry.getBounds().getCenterLonLat();
}

lonlat = feature.geometry.getBounds().getCenterLonLat();
var position = map.getPixelFromLonLat(lonlat);
// Create FramedCloud popup.
popup = new OpenLayers.Popup.FramedCloud(
'popup',
Expand All @@ -79,25 +109,30 @@ Drupal.openlayers.addBehavior('openlayers_behavior_popp_popup', function (data,
null,
true,
function (evt) {
while( map.popups.length ) {
while (map.popups.length) {
map.removePopup(map.popups[0]);
}
Drupal.openlayers.popup.popupSelect.unselect(selectedFeature);
}
);

// Assign popup to feature and map.
popup.panMapIfOutOfView = options.panMapIfOutOfView;
popup.keepInMap = options.keepInMap;
selectedFeature = feature;
feature.popup = popup;
map.addPopup(popup, true);
var top = parseInt(jQuery('#popup').css('top'));
if(popup.relativePosition == "tr" || popup.relativePosition == "tl"){
top -= 15;
}else{
console.log('BOTTOM');
top += 10;
}
jQuery("#popup").css('top', top);
Drupal.attachBehaviors();
},
outFeature: function (feature) {
/*map.removePopup(feature.popup);
feature.popup.destroy();
feature.popup = null;*/
feature.popup.destroy();
feature.popup = null;*/
}
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,16 @@ var doCenter = true;
var nid = point.attributes.nid;
var bound = new OpenLayers.Bounds();

for (var i in layers[0].features) {
if (layers[0].features[i].cluster != null) {
bound.extend(layers[0].features[i].cluster[0].geometry.getBounds());
} else {
bound.extend(layers[0].features[i].geometry.getBounds());
for (var l in layers){
for (var i in layers[l].features) {
if (layers[l].features[i].cluster != null) {
bound.extend(layers[l].features[i].cluster[0].geometry.getBounds());
} else {
bound.extend(layers[l].features[i].geometry.getBounds());
}
}
}

data.openlayers.setCenter(bound.getCenterLonLat());
data.openlayers.zoomToExtent(bound);
data.openlayers.zoomTo(data.openlayers.getZoom() - 1);
Expand Down
Loading

0 comments on commit 9cd06b4

Please sign in to comment.