From 42f14a94b2e90890c0753b54402bc9d18c066d27 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Wed, 30 Aug 2017 11:12:51 +0200
Subject: [PATCH] when opening submap db markers are refreshed (so they become
 visible)

---
 frontend-js/src/main/js/map/CustomMap.js | 394 +++++++++++------------
 1 file changed, 197 insertions(+), 197 deletions(-)

diff --git a/frontend-js/src/main/js/map/CustomMap.js b/frontend-js/src/main/js/map/CustomMap.js
index 0ad9cc8620..645cb13f7a 100644
--- a/frontend-js/src/main/js/map/CustomMap.js
+++ b/frontend-js/src/main/js/map/CustomMap.js
@@ -28,7 +28,7 @@ var TouchMap = require('./TouchMap');
 
 /**
  * Default constructor.
- * 
+ *
  * @param options
  *          CustomMapOptions object representing all parameters needed for map
  *          creation
@@ -75,12 +75,12 @@ CustomMap.prototype.constructor = CustomMap;
 /**
  * This code must be run after the object is created. It requires to download
  * some data via promises.
- * 
+ *
  * @return promise with empty result
  */
-CustomMap.prototype.init = function() {
+CustomMap.prototype.init = function () {
   var self = this;
-  return ServerConnector.getLogoImg().then(function(url) {
+  return ServerConnector.getLogoImg().then(function (url) {
     var logo2 = self.getControl(ControlType.LOGO_2_IMG);
     if (!/^(f|ht)tps?:\/\//i.test(url)) {
       url = GuiConnector.getImgPrefix() + url;
@@ -92,7 +92,7 @@ CustomMap.prototype.init = function() {
 /**
  * Create submaps.
  */
-CustomMap.prototype.createSubmaps = function() {
+CustomMap.prototype.createSubmaps = function () {
   this.submaps = [];
   for (var i = 0; i < this.getModel().getSubmodels().length; i++) {
     this.submaps.push(new Submap(this, this.getModel().getSubmodels()[i]));
@@ -102,7 +102,7 @@ CustomMap.prototype.createSubmaps = function() {
 /**
  * Creates logo and put it on the google map.
  */
-CustomMap.prototype.createLogo = function() {
+CustomMap.prototype.createLogo = function () {
   var logoControlDiv2 = document.createElement('DIV');
   var logo2 = document.createElement('IMG');
   logo2.style.cursor = 'pointer';
@@ -111,8 +111,8 @@ CustomMap.prototype.createLogo = function() {
   this.addControl(logo2);
 
   logoControlDiv2.appendChild(logo2);
-  google.maps.event.addDomListener(logo2, 'click', function() {
-    return ServerConnector.getLogoLink().then(function(url) {
+  google.maps.event.addDomListener(logo2, 'click', function () {
+    return ServerConnector.getLogoLink().then(function (url) {
       var win = window.open(url, '_blank');
       win.focus();
     });
@@ -130,7 +130,7 @@ CustomMap.prototype.createLogo = function() {
   this.addControl(logo);
 
   logoControlDiv.appendChild(logo);
-  google.maps.event.addDomListener(logo, 'click', function() {
+  google.maps.event.addDomListener(logo, 'click', function () {
     var win = window.open('http://wwwen.uni.lu/lcsb/', '_blank');
     win.focus();
   });
@@ -142,9 +142,9 @@ CustomMap.prototype.createLogo = function() {
 /**
  * Clear all AbstractDbOverlay.
  */
-CustomMap.prototype.clearDbOverlays = function() {
+CustomMap.prototype.clearDbOverlays = function () {
   var promises = [];
-  for ( var overlayName in this.overlayCollections) {
+  for (var overlayName in this.overlayCollections) {
     if (this.overlayCollections.hasOwnProperty(overlayName)) {
       var collection = this.overlayCollections[overlayName];
       promises.push(collection.clear());
@@ -155,11 +155,11 @@ CustomMap.prototype.clearDbOverlays = function() {
 
 /**
  * Open data overlay given in the parameter.
- * 
+ *
  * @param param
  *          identifier or LayoutData identifing data overlay to open
  */
-CustomMap.prototype.openDataOverlay = function(param) {
+CustomMap.prototype.openDataOverlay = function (param) {
   logger.debug("Opening data overlay: " + param);
 
   var self = this;
@@ -186,14 +186,14 @@ CustomMap.prototype.openDataOverlay = function(param) {
   if (index === null) {
     throw new SecurityError("You have no privileges for selected overlay");
   } else {
-    return overlayToOpen.init().then(function() {
+    return overlayToOpen.init().then(function () {
       if (overlayToOpen.getInputDataAvailable()) {
         if (self._selectedOverlays[identifier] === true) {
           logger.warn("Overlay " + identifier + " already selected");
           return Promise.resolve();
         } else {
           self._selectedOverlays[identifier] = true;
-          return self.getVisibleDataOverlays().then(function(visibleDataOverlays) {
+          return self.getVisibleDataOverlays().then(function (visibleDataOverlays) {
             var ids = [];
             for (var i = 0; i < visibleDataOverlays.length; i++) {
               ids.push(visibleDataOverlays[i].getId());
@@ -220,7 +220,7 @@ CustomMap.prototype.openDataOverlay = function(param) {
 /**
  * Returns data overlay that is used as a background.
  */
-CustomMap.prototype.getBackgroundDataOverlay = function() {
+CustomMap.prototype.getBackgroundDataOverlay = function () {
   var identifier = parseInt(this.getGoogleMap().getMapTypeId());
   for (var i = 0; i < this.getLayouts().length; i++) {
     var layout = this.getLayouts()[i];
@@ -233,54 +233,54 @@ CustomMap.prototype.getBackgroundDataOverlay = function() {
 
 /**
  * Register AbstractDbOverlay in the map.
- * 
+ *
  * @param dbOverlay
  *          database overlay to be connected to the map
  */
-CustomMap.prototype.registerDbOverlay = function(dbOverlay) {
+CustomMap.prototype.registerDbOverlay = function (dbOverlay) {
   var self = this;
 
   this.overlayCollections[dbOverlay.getName()] = dbOverlay;
 
   dbOverlay.markers = {
-    ALIAS : [],
-    REACTION : [],
-    POINT : []
+    ALIAS: [],
+    REACTION: [],
+    POINT: []
   };
   dbOverlay.mapOverlays = {
-    ALIAS : [],
-    REACTION : [],
-    POINT : []
+    ALIAS: [],
+    REACTION: [],
+    POINT: []
   };
 
   if (dbOverlay.getName() === "search" || dbOverlay.getName() === "user") {
-    dbOverlay.addListener("onSearch", function(e) {
+    dbOverlay.addListener("onSearch", function (e) {
       return self.renderOverlayCollection({
-        overlayCollection : dbOverlay,
-        fitBounds : e.arg.fitBounds
+        overlayCollection: dbOverlay,
+        fitBounds: e.arg.fitBounds
       });
     });
   }
   if (dbOverlay.getName() === "drug" || dbOverlay.getName() === "chemical" || dbOverlay.getName() === "mirna") {
-    dbOverlay.addListener("onSearch", function(e) {
+    dbOverlay.addListener("onSearch", function (e) {
       return self.renderOverlayCollection({
-        overlayCollection : dbOverlay,
-        fitBounds : e.arg.fitBounds
+        overlayCollection: dbOverlay,
+        fitBounds: e.arg.fitBounds
       });
     });
 
-    dbOverlay.addListener("onTargetVisibilityChange", function() {
+    dbOverlay.addListener("onTargetVisibilityChange", function () {
       return self.renderOverlayCollection({
-        overlayCollection : dbOverlay,
-        fitBounds : false
+        overlayCollection: dbOverlay,
+        fitBounds: false
       });
     });
   }
   if (dbOverlay.getName() === "comment") {
-    var listener = function() {
+    var listener = function () {
       return self.renderOverlayCollection({
-        overlayCollection : dbOverlay,
-        fitBounds : false
+        overlayCollection: dbOverlay,
+        fitBounds: false
       });
     };
     dbOverlay.addListener("onRefresh", listener);
@@ -291,10 +291,10 @@ CustomMap.prototype.registerDbOverlay = function(dbOverlay) {
 
 /**
  * Refresh comment list.
- * 
+ *
  * @return promise that is resolved when comment list is refreshed
  */
-CustomMap.prototype.refreshComments = function() {
+CustomMap.prototype.refreshComments = function () {
   var self = this;
 
   var commentDbOverlay = self.getOverlayByName("comment");
@@ -311,7 +311,7 @@ CustomMap.prototype.refreshComments = function() {
 /**
  * Turns on/off drawing module on google maps.
  */
-CustomMap.prototype.turnOnOffDrawing = function() {
+CustomMap.prototype.turnOnOffDrawing = function () {
   var model = this.getSubmapById(this.getActiveSubmapId());
   if (model !== undefined) {
     model._turnOnOffDrawing();
@@ -320,24 +320,24 @@ CustomMap.prototype.turnOnOffDrawing = function() {
   }
 };
 
-CustomMap.prototype.refreshMarkers = function() {
+CustomMap.prototype.refreshMarkers = function (force) {
   logger.debug("Refresh Markers: ");
-  for ( var overlayName in this.overlayCollections) {
+  for (var overlayName in this.overlayCollections) {
     if (this.overlayCollections.hasOwnProperty(overlayName)) {
       var collection = this.overlayCollections[overlayName];
-      this.refreshOverlayMarkers(collection);
+      this.refreshOverlayMarkers(collection, force);
     }
   }
 };
 
-CustomMap.prototype.refreshOverlayMarkers = function(overlay) {
+CustomMap.prototype.refreshOverlayMarkers = function (overlay, force) {
   logger.debug("Refresh overlay: " + overlay.name);
 
-  if (!this.isMarkerOptimization()) {
-    for ( var markerType in overlay.markers) {
+  if (!this.isMarkerOptimization() || force) {
+    for (var markerType in overlay.markers) {
       if (overlay.markers.hasOwnProperty(markerType)) {
         var markers = overlay.markers[markerType];
-        for ( var key in markers) {
+        for (var key in markers) {
           if (markers.hasOwnProperty(key)) {
             var marker = markers[key];
             marker.hide();
@@ -352,11 +352,11 @@ CustomMap.prototype.refreshOverlayMarkers = function(overlay) {
 /**
  * Returns HTML div that is attached to jQuery dialog that should be used for
  * opening submap.
- * 
+ *
  * @param id
  *          identifier of the submap
  */
-CustomMap.prototype.getSubmapDialogDiv = function(id) {
+CustomMap.prototype.getSubmapDialogDiv = function (id) {
   var dialogDiv = this._dialogs[id];
 
   if (dialogDiv === undefined) {
@@ -366,7 +366,7 @@ CustomMap.prototype.getSubmapDialogDiv = function(id) {
     this._dialogs[id] = dialogDiv;
 
     $(dialogDiv).dialog({
-      autoOpen : false
+      autoOpen: false
     });
   }
   return dialogDiv;
@@ -375,7 +375,7 @@ CustomMap.prototype.getSubmapDialogDiv = function(id) {
 /**
  * Opens a dialog with a submodel.
  */
-CustomMap.prototype.openSubmap = function(id) {
+CustomMap.prototype.openSubmap = function (id) {
   var self = this;
   var submap = self.getSubmapById(id);
   if (submap === null) {
@@ -388,12 +388,12 @@ CustomMap.prototype.openSubmap = function(id) {
     submap.open(dialogDiv);
 
     // we have to perform it on top map, because on submaps id is different
-    return this.openDataOverlay(self.getGoogleMap().getMapTypeId()).then(function() {
+    return this.openDataOverlay(self.getGoogleMap().getMapTypeId()).then(function () {
       // now we have to visualize layouts
       var layouts = [];
 
       // get list of layouts
-      for ( var key in self._selectedOverlays) {
+      for (var key in self._selectedOverlays) {
         if (self._selectedOverlays.hasOwnProperty(key) && self._selectedOverlays[key] === true) {
           layouts.push(key);
         }
@@ -405,14 +405,14 @@ CustomMap.prototype.openSubmap = function(id) {
         submap._showSelectedLayout(layoutId, i, layouts.length);
       }
       if (!wasInitialized) {
-        return self.refreshMarkers();
+        return self.refreshMarkers(true);
       }
     });
   }
 
 };
 
-CustomMap.prototype.customizeGoogleMapView = function(div) {
+CustomMap.prototype.customizeGoogleMapView = function (div) {
   var mapOptions = this.creatMapOptions();
   this.setGoogleMap(new google.maps.Map(div, mapOptions));
   this.setupLayouts();
@@ -440,7 +440,7 @@ CustomMap.prototype.customizeGoogleMapView = function(div) {
  * Creates listeners for google.maps.Map object that will actualize the data in
  * user session.
  */
-CustomMap.prototype.createMapChangedCallbacks = function() {
+CustomMap.prototype.createMapChangedCallbacks = function () {
   this._createMapChangedCallbacks();
   var self = this;
   var sessionData = ServerConnector.getSessionData(self.getProject());
@@ -455,7 +455,7 @@ CustomMap.prototype.createMapChangedCallbacks = function() {
   }
 
   // listener for changing type of layout
-  google.maps.event.addListener(self.getGoogleMap(), 'maptypeid_changed', function() {
+  google.maps.event.addListener(self.getGoogleMap(), 'maptypeid_changed', function () {
     sessionData.setSelectedBackgroundOverlay(self.getGoogleMap().getMapTypeId());
   });
 
@@ -477,12 +477,12 @@ CustomMap.prototype.createMapChangedCallbacks = function() {
 
 /**
  * Returns submap (or this map) by id.
- * 
+ *
  * @param identifier
  *          identifier of the submap
  * @returns submap (or this map) with given identfier of the model
  */
-CustomMap.prototype.getSubmapById = function(identifier) {
+CustomMap.prototype.getSubmapById = function (identifier) {
   identifier = parseInt(identifier);
   if (this.getId() === identifier) {
     return this;
@@ -496,7 +496,7 @@ CustomMap.prototype.getSubmapById = function(identifier) {
   return null;
 };
 
-CustomMap.prototype.removeSelection = function() {
+CustomMap.prototype.removeSelection = function () {
   var model = this.getSubmapById(this.getActiveSubmapId());
   if (model !== null) {
     model._removeSelection();
@@ -507,12 +507,12 @@ CustomMap.prototype.removeSelection = function() {
 
 /**
  * Removes layout from visualization.
- * 
+ *
  * @param identifier
  *          identifier of layout to remove
- * 
+ *
  */
-CustomMap.prototype.removeSelectedLayout = function(identifier) {
+CustomMap.prototype.removeSelectedLayout = function (identifier) {
   var self = this;
   logger.debug("Removing layout: " + identifier);
 
@@ -521,9 +521,9 @@ CustomMap.prototype.removeSelectedLayout = function(identifier) {
     return Promise.resolve();
   } else {
     self._selectedOverlays[identifier] = false;
-    return self.refreshSelectedLayouts().then(function() {
+    return self.refreshSelectedLayouts().then(function () {
       return self.getVisibleDataOverlays();
-    }).then(function(visibleDataOverlays) {
+    }).then(function (visibleDataOverlays) {
       var ids = [];
       for (var i = 0; i < visibleDataOverlays.length; i++) {
         ids.push(visibleDataOverlays[i].getId());
@@ -537,10 +537,10 @@ CustomMap.prototype.removeSelectedLayout = function(identifier) {
 /**
  * Refresh visualization of selected layouts.
  */
-CustomMap.prototype.refreshSelectedLayouts = function() {
+CustomMap.prototype.refreshSelectedLayouts = function () {
   logger.debug("Refreshing layouts");
   var self = this;
-  return self.getVisibleDataOverlays().then(function(visibleDataOverlays) {
+  return self.getVisibleDataOverlays().then(function (visibleDataOverlays) {
     // show layouts that should be visualized (resize or show them)
     var promises = [];
     for (var i = 0; i < visibleDataOverlays.length; i++) {
@@ -552,9 +552,9 @@ CustomMap.prototype.refreshSelectedLayouts = function() {
         promises.push(self.showSelectedLayout(layoutId, i, visibleDataOverlays.length));
       }
     }
-    return Promise.all(promises).then(function() {
+    return Promise.all(promises).then(function () {
       // remove layouts that were
-      for ( var key in self.selectedLayoutOverlays) {
+      for (var key in self.selectedLayoutOverlays) {
         if (!self._selectedOverlays.hasOwnProperty(key) || self._selectedOverlays[key] === false) {
           if (self.layoutContainsOverlays(key)) {
             self.hideSelectedLayout(key);
@@ -568,11 +568,11 @@ CustomMap.prototype.refreshSelectedLayouts = function() {
 
 /**
  * Hides layout from the map and all submaps
- * 
+ *
  * @param layoutId
  *          identifier of a layout to hide
  */
-CustomMap.prototype.hideSelectedLayout = function(layoutId) {
+CustomMap.prototype.hideSelectedLayout = function (layoutId) {
   this._hideSelectedLayout(layoutId);
   for (var i = 0; i < this.submaps.length; i++) {
     this.submaps[i]._hideSelectedLayout(layoutId);
@@ -582,7 +582,7 @@ CustomMap.prototype.hideSelectedLayout = function(layoutId) {
 /**
  * Resize(refresh) layout on the map and all submaps. Resizing should be called
  * when number of layouts to visualize change.
- * 
+ *
  * @param layoutId
  *          identifier of layout to refresh
  * @param index
@@ -590,7 +590,7 @@ CustomMap.prototype.hideSelectedLayout = function(layoutId) {
  * @param length
  *          number of layouts that we currently visualize
  */
-CustomMap.prototype.resizeSelectedLayout = function(layoutId, index, length) {
+CustomMap.prototype.resizeSelectedLayout = function (layoutId, index, length) {
   logger.debug("Resize layout: " + layoutId);
   var promises = [];
   promises.push(this._resizeSelectedLayout(layoutId, index, length));
@@ -602,7 +602,7 @@ CustomMap.prototype.resizeSelectedLayout = function(layoutId, index, length) {
 
 /**
  * Show layout on the map and all submaps.
- * 
+ *
  * @param layoutId
  *          identifier of layout to show
  * @param index
@@ -610,7 +610,7 @@ CustomMap.prototype.resizeSelectedLayout = function(layoutId, index, length) {
  * @param length
  *          number of layouts that we currently visualize
  */
-CustomMap.prototype.showSelectedLayout = function(layoutId, index, length) {
+CustomMap.prototype.showSelectedLayout = function (layoutId, index, length) {
   logger.debug("Resize layout: " + layoutId);
   var promises = [];
   promises.push(this._showSelectedLayout(layoutId, index, length));
@@ -624,13 +624,13 @@ CustomMap.prototype.showSelectedLayout = function(layoutId, index, length) {
 /**
  * This method checks if the layout contains any overlays (like AliasSurface or
  * ReactionSurface) that is currently visible on the map.
- * 
+ *
  * @param layoutId
  *          identifier of the layout
  * @returns {Boolean}: <code>true</code> if the layout contains overlays to
  *          visualize, <code>false</code> otherwise
  */
-CustomMap.prototype.layoutContainsOverlays = function(layoutId) {
+CustomMap.prototype.layoutContainsOverlays = function (layoutId) {
 
   // first, check top map
   if (this.selectedLayoutOverlays.hasOwnProperty(layoutId) && this.selectedLayoutOverlays[layoutId].length > 0) {
@@ -641,7 +641,7 @@ CustomMap.prototype.layoutContainsOverlays = function(layoutId) {
   for (var i = 0; i < this.submaps.length; i++) {
     if (this.submaps[i].initialized) {
       if (this.submaps[i].selectedLayoutOverlays.hasOwnProperty(layoutId)
-          && this.submaps[i].selectedLayoutOverlays[layoutId].length > 0) {
+        && this.submaps[i].selectedLayoutOverlays[layoutId].length > 0) {
         return true;
       }
     }
@@ -652,7 +652,7 @@ CustomMap.prototype.layoutContainsOverlays = function(layoutId) {
 /**
  * Refresh content of all {@link AliasInfoWindow} in this map and all submaps.
  */
-CustomMap.prototype.refreshInfoWindows = function() {
+CustomMap.prototype.refreshInfoWindows = function () {
   var promises = [];
   promises.push(this._refreshInfoWindows());
   // now check all submaps
@@ -664,13 +664,13 @@ CustomMap.prototype.refreshInfoWindows = function() {
 
 /**
  * Opens {@link AliasInfoWindow} for an {@link Alias} in a given model/submodel.
- * 
+ *
  * @param aliasId
  *          identifier of {@link Alias}
  * @param modelId
  *          identifier of {@link AbstractCustomMap}
  */
-CustomMap.prototype.openInfoWindowForAlias = function(alias, marker) {
+CustomMap.prototype.openInfoWindowForAlias = function (alias, marker) {
   logger.debug("Opening info window for alias: " + alias.getId() + ", model: " + alias.getModelId());
   var submap = this.getSubmapById(alias.getModelId());
   return submap._openInfoWindowForAlias(alias, marker);
@@ -678,14 +678,14 @@ CustomMap.prototype.openInfoWindowForAlias = function(alias, marker) {
 
 /**
  * Renders markers, lines, etc. for elements highlighted in OverlayCollection.
- * 
+ *
  * @param overlayCollection
  *          {@link OverlayCollection} to be processed
  * @param fitBounds
  *          <code>true</code> if the borders should fit bounds after creating
  *          all elements
  */
-CustomMap.prototype.renderOverlayCollection = function(params) {
+CustomMap.prototype.renderOverlayCollection = function (params) {
   var self = this;
   var fitBounds = params.fitBounds;
   var overlayCollection = params.overlayCollection;
@@ -693,33 +693,33 @@ CustomMap.prototype.renderOverlayCollection = function(params) {
   var elements;
   var markers = [];
 
-  return overlayCollection.getIdentifiedElements().then(function(identifiedElements) {
+  return overlayCollection.getIdentifiedElements().then(function (identifiedElements) {
     elements = identifiedElements;
 
-    return Promise.each(elements, function(element) {
+    return Promise.each(elements, function (element) {
       var icon = element.getIcon();
       if (icon !== null && icon !== undefined) {
-        return self.createMarkerForDbOverlay(element, overlayCollection).then(function(marker) {
+        return self.createMarkerForDbOverlay(element, overlayCollection).then(function (marker) {
           markers.push(marker);
         });
       } else {
-        return self.createSurfaceForDbOverlay(element, overlayCollection).then(function(mapOverlay) {
+        return self.createSurfaceForDbOverlay(element, overlayCollection).then(function (mapOverlay) {
           markers.push(mapOverlay);
         });
       }
     });
-  }).then(function() {
+  }).then(function () {
     self.removeUnmodifiedMarkersAndSurfaces(markers, overlayCollection);
 
-    return Promise.each(elements, function(element) {
+    return Promise.each(elements, function (element) {
       var infoWindow = self.getInfoWindowForIdentifiedElement(element);
       if (infoWindow !== null && infoWindow !== undefined) {
-        return self.retrieveOverlayDetailDataForElement(element, infoWindow.getOverlayFullViewArray()).then(function() {
+        return self.retrieveOverlayDetailDataForElement(element, infoWindow.getOverlayFullViewArray()).then(function () {
           return self.updateInfoWindowForIdentifiedElement(element);
         });
       }
     });
-  }).then(function() {
+  }).then(function () {
     if (elements.length > 0 && fitBounds) {
       self.fitBounds(markers);
       for (var j = 0; j < self.submaps.length; j++) {
@@ -729,16 +729,16 @@ CustomMap.prototype.renderOverlayCollection = function(params) {
   });
 };
 
-CustomMap.prototype.removeUnmodifiedMarkersAndSurfaces = function(modifiedMarkersAndSurfaces, dbOverlay) {
+CustomMap.prototype.removeUnmodifiedMarkersAndSurfaces = function (modifiedMarkersAndSurfaces, dbOverlay) {
   var modifiedMarkers = {
-    "ALIAS" : [],
-    "REACTION" : [],
-    "POINT" : [],
+    "ALIAS": [],
+    "REACTION": [],
+    "POINT": [],
   };
   var modifiedSurfaces = {
-    "ALIAS" : [],
-    "REACTION" : [],
-    "POINT" : [],
+    "ALIAS": [],
+    "REACTION": [],
+    "POINT": [],
   };
 
   for (var i = 0; i < modifiedMarkersAndSurfaces.length; i++) {
@@ -781,17 +781,17 @@ CustomMap.prototype.removeUnmodifiedMarkersAndSurfaces = function(modifiedMarker
 
 /**
  * Opens {@link AbstractInfoWindow} for a marker.
- * 
+ *
  * @param marker
  *          {@link AbstractMarker} for which info window should be opened
  */
-CustomMap.prototype.openInfoWindowForIdentifiedElement = function(element, marker) {
+CustomMap.prototype.openInfoWindowForIdentifiedElement = function (element, marker) {
   var self = this;
   var submap = self.getSubmapById(element.getModelId());
   logger.debug(element + ": Opening info window");
 
   // open AliasInfoWindow in a right model
-  return submap._openInfoWindowForIdentifiedElement(element, marker).then(function() {
+  return submap._openInfoWindowForIdentifiedElement(element, marker).then(function () {
     var infoWindow = submap.returnInfoWindowForIdentifiedElement(element);
     return self.retrieveOverlayDetailDataForElement(element, infoWindow.getOverlayFullViewArray());
   });
@@ -801,17 +801,17 @@ CustomMap.prototype.openInfoWindowForIdentifiedElement = function(element, marke
 /**
  * Sends requestes to download detailed data about element in all
  * {@link OverlayCollection}.
- * 
+ *
  * @param element
  *          element for which we want to have detailed information
  */
-CustomMap.prototype.retrieveOverlayDetailDataForElement = function(element, general) {
+CustomMap.prototype.retrieveOverlayDetailDataForElement = function (element, general) {
   var promises = [];
   if (general === undefined) {
     logger.warn("general param is undefined!");
     general = [];
   }
-  for ( var overlayName in this.overlayCollections) {
+  for (var overlayName in this.overlayCollections) {
     if (this.overlayCollections.hasOwnProperty(overlayName)) {
       var overlay = this.overlayCollections[overlayName];
 
@@ -830,11 +830,11 @@ CustomMap.prototype.retrieveOverlayDetailDataForElement = function(element, gene
 
 /**
  * Updates info window identified by element given as a parameter.
- * 
+ *
  * @param identifiedElement
  *          element for which info window should be updated
  */
-CustomMap.prototype.updateInfoWindowForIdentifiedElement = function(identifiedElement) {
+CustomMap.prototype.updateInfoWindowForIdentifiedElement = function (identifiedElement) {
   var infoWindow = this.getInfoWindowForIdentifiedElement(identifiedElement);
   if (infoWindow === null || infoWindow === undefined) {
     return Promise.resolve();
@@ -845,7 +845,7 @@ CustomMap.prototype.updateInfoWindowForIdentifiedElement = function(identifiedEl
 
 /**
  * Returns data from all {@link OverlayCollection} for a given alias.
- * 
+ *
  * @param alias
  *          {@link Alias} for which overlay data will be returned
  * @param general
@@ -853,14 +853,14 @@ CustomMap.prototype.updateInfoWindowForIdentifiedElement = function(identifiedEl
  *          availble right now in the overlay
  * @returns data from all {@link OverlayCollection} for a given alias
  */
-CustomMap.prototype.getOverlayDataForAlias = function(alias, general) {
+CustomMap.prototype.getOverlayDataForAlias = function (alias, general) {
   var identifiedElement = new IdentifiedElement(alias);
   return this.getOverlayDataForIdentifiedElement(identifiedElement, general);
 };
 
 /**
  * Returns data from all {@link OverlayCollection} for a given reaction.
- * 
+ *
  * @param reaction
  *          {@link Reaction} for which overlay data will be returned
  * @param general
@@ -868,20 +868,20 @@ CustomMap.prototype.getOverlayDataForAlias = function(alias, general) {
  *          availble right now in the overlay
  * @returns data from all {@link OverlayCollection} for a given alias
  */
-CustomMap.prototype.getOverlayDataForReaction = function(reaction, general) {
+CustomMap.prototype.getOverlayDataForReaction = function (reaction, general) {
   var identifiedElement = new IdentifiedElement(reaction);
   return this.getOverlayDataForIdentifiedElement(identifiedElement, general);
 };
 
 /**
  * Returns data from all {@link OverlayCollection} for a given {@link PointData}
- * 
+ *
  * @param point
  *          {@link PointData} for which overlay data will be returned
  * @returns data from all {@link OverlayCollection} for a given
  *          {@link PointData}
  */
-CustomMap.prototype.getOverlayDataForPoint = function(point, general) {
+CustomMap.prototype.getOverlayDataForPoint = function (point, general) {
   var identifiedElement = new IdentifiedElement(point);
   return this.getOverlayDataForIdentifiedElement(identifiedElement, general);
 };
@@ -889,20 +889,20 @@ CustomMap.prototype.getOverlayDataForPoint = function(point, general) {
 /**
  * Returns data from all {@link OverlayCollection} for element identified by the
  * parameter
- * 
+ *
  * @param identifiedElement
  *          {@link IdentifiedElement} for which overlay data will be returned
  * @returns data from all {@link OverlayCollection} for a given
  *          {@link IdentifiedElement}
  */
-CustomMap.prototype.getOverlayDataForIdentifiedElement = function(identifiedElement, general) {
+CustomMap.prototype.getOverlayDataForIdentifiedElement = function (identifiedElement, general) {
   if (general === undefined) {
     logger.warn("general parameter must be defined");
     general = [];
   }
   var promises = [];
   var overlays = [];
-  for ( var overlayName in this.overlayCollections) {
+  for (var overlayName in this.overlayCollections) {
     if (this.overlayCollections.hasOwnProperty(overlayName)) {
       var overlay = this.overlayCollections[overlayName];
       if (overlay.allowGeneralSearch() || overlay.allowSearchById()) {
@@ -913,29 +913,29 @@ CustomMap.prototype.getOverlayDataForIdentifiedElement = function(identifiedElem
         }
         overlays.push(overlay);
         promises.push(overlay.getDetailDataByIdentifiedElement(identifiedElement, !overlay.allowSearchById()
-            || generalFlag));
+          || generalFlag));
       }
     }
   }
-  return Promise.all(promises).then(function(values) {
+  return Promise.all(promises).then(function (values) {
     var result = [];
     for (var i = 0; i < values.length; i++) {
       result.push({
-        overlay : overlays[i],
-        data : values[i]
+        overlay: overlays[i],
+        data: values[i]
       });
     }
     return result;
   });
 };
 
-CustomMap.prototype.getOverlayByName = function(name) {
+CustomMap.prototype.getOverlayByName = function (name) {
   return this.overlayCollections[name];
 };
 
-CustomMap.prototype.getDbOverlays = function() {
+CustomMap.prototype.getDbOverlays = function () {
   var result = [];
-  for ( var overlayName in this.overlayCollections) {
+  for (var overlayName in this.overlayCollections) {
     if (this.overlayCollections.hasOwnProperty(overlayName)) {
       result.push(this.overlayCollections[overlayName]);
     }
@@ -945,13 +945,13 @@ CustomMap.prototype.getDbOverlays = function() {
 
 /**
  * Returns {@link AbstractInfoWindow} for element identified by the parameter.
- * 
+ *
  * @param identifiedElement
  *          {@link IdentifiedElement} that determines for which element we want
  *          {@link AbstractInfoWindow}
  * @returns {@link AbstractInfoWindow} for element identified by the parameter
  */
-CustomMap.prototype.getInfoWindowForIdentifiedElement = function(identifiedElement) {
+CustomMap.prototype.getInfoWindowForIdentifiedElement = function (identifiedElement) {
   var model = this.getSubmapById(identifiedElement.modelId);
   var infoWindow = null;
   if (identifiedElement.type === "ALIAS") {
@@ -966,25 +966,25 @@ CustomMap.prototype.getInfoWindowForIdentifiedElement = function(identifiedEleme
   return infoWindow;
 };
 
-CustomMap.prototype.getActiveSubmapId = function() {
+CustomMap.prototype.getActiveSubmapId = function () {
   return this._activeSubmapId;
 };
 
-CustomMap.prototype.setActiveSubmapId = function(submapId) {
+CustomMap.prototype.setActiveSubmapId = function (submapId) {
   this._activeSubmapId = submapId;
 };
 
-CustomMap.prototype.setActiveSubmapClickCoordinates = function(coordinates) {
+CustomMap.prototype.setActiveSubmapClickCoordinates = function (coordinates) {
   if (!(coordinates instanceof google.maps.Point)) {
     throw new Error("Coordinates must be provided as google.maps.Point object, but found: " + coordinates);
   }
   this._activeSubmapCoordinates = coordinates;
 };
-CustomMap.prototype.getActiveSubmapClickCoordinates = function() {
+CustomMap.prototype.getActiveSubmapClickCoordinates = function () {
   return this._activeSubmapCoordinates;
 };
 
-CustomMap.prototype.getReferenceGenome = function(type, version) {
+CustomMap.prototype.getReferenceGenome = function (type, version) {
   var self = this;
   if (self.getProject().getOrganism() === undefined) {
     return Promise.resolve(new ReferenceGenome(null));
@@ -995,10 +995,10 @@ CustomMap.prototype.getReferenceGenome = function(type, version) {
   }
   if (self._referenceGenome[type][version] === undefined) {
     return ServerConnector.getReferenceGenome({
-      type : type,
-      version : version,
-      organism : self.getProject().getOrganism().getResource(),
-    }).then(function(genome) {
+      type: type,
+      version: version,
+      organism: self.getProject().getOrganism().getResource(),
+    }).then(function (genome) {
       self._referenceGenome[type][version] = genome;
       return genome;
     });
@@ -1007,22 +1007,22 @@ CustomMap.prototype.getReferenceGenome = function(type, version) {
   }
 };
 
-CustomMap.prototype.getTopMap = function() {
+CustomMap.prototype.getTopMap = function () {
   return this;
 };
 
-CustomMap.prototype.setProject = function(project) {
+CustomMap.prototype.setProject = function (project) {
   this._project = project;
 };
-CustomMap.prototype.getProject = function() {
+CustomMap.prototype.getProject = function () {
   return this._project;
 };
 
-CustomMap.prototype.getTopOverviewImage = function() {
+CustomMap.prototype.getTopOverviewImage = function () {
   return this.getProject().getTopOverviewImage();
 };
 
-CustomMap.prototype.addControl = function(element) {
+CustomMap.prototype.addControl = function (element) {
   if (this._controls[element.id] !== undefined) {
     throw new Error("Element with id " + element.id + " already added to controls");
   }
@@ -1032,52 +1032,52 @@ CustomMap.prototype.addControl = function(element) {
   this._controls[element.id] = element;
 };
 
-CustomMap.prototype.getControl = function(type) {
+CustomMap.prototype.getControl = function (type) {
   if (ControlType[type] === undefined) {
     throw new Error("Unknown control type: " + type);
   }
   return this._controls[type];
 };
 
-CustomMap.prototype.setCommentDialog = function(commentDialog) {
+CustomMap.prototype.setCommentDialog = function (commentDialog) {
   this._commentDialog = commentDialog;
 };
 
-CustomMap.prototype.getCommentDialog = function() {
+CustomMap.prototype.getCommentDialog = function () {
   return this._commentDialog;
 };
 
-CustomMap.prototype.setContextMenu = function(contextMenu) {
+CustomMap.prototype.setContextMenu = function (contextMenu) {
   this._contextMenu = contextMenu;
 };
 
-CustomMap.prototype.getContextMenu = function() {
+CustomMap.prototype.getContextMenu = function () {
   return this._contextMenu;
 };
 
-CustomMap.prototype.setSelectionContextMenu = function(selectionContextMenu) {
+CustomMap.prototype.setSelectionContextMenu = function (selectionContextMenu) {
   this._selectionContextMenu = selectionContextMenu;
 };
 
-CustomMap.prototype.getSelectionContextMenu = function() {
+CustomMap.prototype.getSelectionContextMenu = function () {
   return this._selectionContextMenu;
 };
 
-CustomMap.prototype.openCommentDialog = function() {
+CustomMap.prototype.openCommentDialog = function () {
   var self = this;
   return ServerConnector.getClosestElementsByCoordinates({
-    modelId : this.getActiveSubmapId(),
-    coordinates : this.getActiveSubmapClickCoordinates()
-  }).then(function(elements) {
+    modelId: this.getActiveSubmapId(),
+    coordinates: this.getActiveSubmapClickCoordinates()
+  }).then(function (elements) {
     var commentDialog = self.getCommentDialog();
     if (commentDialog === undefined) {
       var div = Functions.createElement({
-        type : "div"
+        type: "div"
       });
       self.getElement().appendChild(div);
       commentDialog = new CommentDialog({
-        element : div,
-        customMap : self
+        element: div,
+        customMap: self
       });
       self.setCommentDialog(commentDialog);
     }
@@ -1087,7 +1087,7 @@ CustomMap.prototype.openCommentDialog = function() {
   });
 };
 
-CustomMap.prototype.fetchIdentifiedElements = function(elements, complete) {
+CustomMap.prototype.fetchIdentifiedElements = function (elements, complete) {
   var modelIds = [];
   var modelElements = [];
   var i;
@@ -1109,10 +1109,10 @@ CustomMap.prototype.fetchIdentifiedElements = function(elements, complete) {
 
 };
 
-CustomMap.prototype.refreshSearchAutocomplete = function() {
+CustomMap.prototype.refreshSearchAutocomplete = function () {
   var self = this;
   self._searchAutocomplete = [];
-  return ServerConnector.getSuggestedQueryList().then(function(queries) {
+  return ServerConnector.getSuggestedQueryList().then(function (queries) {
     for (var i = 0; i < queries.length; i++) {
       var mainString = queries[i];
       for (var j = 0; j < mainString.length; j++) {
@@ -1137,7 +1137,7 @@ CustomMap.prototype.refreshSearchAutocomplete = function() {
   });
 };
 
-CustomMap.prototype.getSearchAutocomplete = function(query) {
+CustomMap.prototype.getSearchAutocomplete = function (query) {
   if (this._searchAutocomplete === undefined) {
     this.refreshSearchAutocomplete();
     return [];
@@ -1146,15 +1146,15 @@ CustomMap.prototype.getSearchAutocomplete = function(query) {
   return this._searchAutocomplete[query];
 };
 
-CustomMap.prototype.setSelectedPolygon = function(polygonData) {
+CustomMap.prototype.setSelectedPolygon = function (polygonData) {
   this._selectedPolygon = polygonData;
 };
 
-CustomMap.prototype.getSelectedPolygon = function() {
+CustomMap.prototype.getSelectedPolygon = function () {
   return this._selectedPolygon;
 };
 
-CustomMap.prototype.getDistance = function(params) {
+CustomMap.prototype.getDistance = function (params) {
   var self = this;
   var ie = params.element;
   var model = self.getSubmapById(ie.getModelId()).getModel();
@@ -1164,21 +1164,21 @@ CustomMap.prototype.getDistance = function(params) {
   var x = params.coordinates.x;
   var y = params.coordinates.y;
   var p1 = new google.maps.Point(x, y);
-  return model.getByIdentifiedElement(ie).then(function(element) {
+  return model.getByIdentifiedElement(ie).then(function (element) {
     if (element instanceof Alias) {
       if (element.getX() <= x && element.getX() + element.getWidth() >= x) {
         if (element.getY() <= y && element.getY() + element.getHeight() >= y) {
           return 0;
         } else {
           return Math.min( //
-          Math.abs(element.getY() - y), //
-          Math.abs(element.getY() + element.getHeight() - y) // 
+            Math.abs(element.getY() - y), //
+            Math.abs(element.getY() + element.getHeight() - y) //
           );
         }
       } else if (element.getY() <= y && element.getY() + element.getHeight() >= y) {
         return Math.min( //
-        Math.abs(element.getX() - x), //
-        Math.abs(element.getX() + element.getWidth() - x) // 
+          Math.abs(element.getX() - x), //
+          Math.abs(element.getX() + element.getWidth() - x) //
         );
       } else {
         var elementX = element.getX();
@@ -1186,10 +1186,10 @@ CustomMap.prototype.getDistance = function(params) {
         var elementWidth = element.getWidth();
         var elementHeight = element.getHeight();
         return Math.min( //
-        Functions.distance(p1, new google.maps.Point(elementX, y)), //
-        Functions.distance(p1, new google.maps.Point(elementX + elementWidth, elementY)), //
-        Functions.distance(p1, new google.maps.Point(elementX, elementY + elementHeight)), //
-        Functions.distance(p1, new google.maps.Point(elementX + elementWidth, elementY + elementHeight)) //
+          Functions.distance(p1, new google.maps.Point(elementX, y)), //
+          Functions.distance(p1, new google.maps.Point(elementX + elementWidth, elementY)), //
+          Functions.distance(p1, new google.maps.Point(elementX, elementY + elementHeight)), //
+          Functions.distance(p1, new google.maps.Point(elementX + elementWidth, elementY + elementHeight)) //
         );
       }
     } else if (element instanceof Reaction) {
@@ -1205,7 +1205,7 @@ CustomMap.prototype.getDistance = function(params) {
   });
 };
 
-CustomMap.prototype.getSubmaps = function() {
+CustomMap.prototype.getSubmaps = function () {
   var submaps = this.submaps;
   if (submaps === undefined) {
     submaps = [];
@@ -1213,7 +1213,7 @@ CustomMap.prototype.getSubmaps = function() {
   return submaps;
 };
 
-CustomMap.prototype.destroy = function() {
+CustomMap.prototype.destroy = function () {
   var self = this;
   var commentDialog = self.getCommentDialog();
   if (commentDialog !== undefined) {
@@ -1221,11 +1221,11 @@ CustomMap.prototype.destroy = function() {
   }
 };
 
-CustomMap.prototype.getVisibleDataOverlays = function() {
+CustomMap.prototype.getVisibleDataOverlays = function () {
   var dataOverlayPromises = [];
 
   // get list of layouts
-  for ( var key in this._selectedOverlays) {
+  for (var key in this._selectedOverlays) {
     if (this._selectedOverlays.hasOwnProperty(key) && this._selectedOverlays[key] === true) {
       dataOverlayPromises.push(this.getModel().getLayoutDataById(key));
     }
@@ -1234,7 +1234,7 @@ CustomMap.prototype.getVisibleDataOverlays = function() {
   return Promise.all(dataOverlayPromises);
 };
 
-CustomMap.prototype.createMarkerForDbOverlay = function(element, dbOverlay) {
+CustomMap.prototype.createMarkerForDbOverlay = function (element, dbOverlay) {
   var self = this;
 
   var result = dbOverlay.markers[element.getType()][element.getId()];
@@ -1255,21 +1255,21 @@ CustomMap.prototype.createMarkerForDbOverlay = function(element, dbOverlay) {
     throw new Error("Unknown type of the element in overlay: " + element.type);
   }
   result = new MarkerConstructor({
-    element : element,
-    map : submap,
-    onClick : [ function() {
+    element: element,
+    map: submap,
+    onClick: [function () {
       return self._openInfoWindowForIdentifiedElement(element, result.getGoogleMarker());
-    }, function() {
+    }, function () {
       return self.callListeners("onBioEntityClick", element);
-    }, ]
+    },]
   });
-  return result.init().then(function() {
+  return result.init().then(function () {
     dbOverlay.markers[element.getType()][element.getId()] = result;
     return result;
   });
 };
 
-CustomMap.prototype.createSurfaceForDbOverlay = function(element, dbOverlay) {
+CustomMap.prototype.createSurfaceForDbOverlay = function (element, dbOverlay) {
   var self = this;
 
   var result = dbOverlay.mapOverlays[element.getType()][element.getId()];
@@ -1281,30 +1281,30 @@ CustomMap.prototype.createSurfaceForDbOverlay = function(element, dbOverlay) {
   var map = self.getSubmapById(element.getModelId());
   if (element.getType() === "ALIAS") {
     return AliasSurface.createFromIdentifiedElement({
-      element : element,
-      map : self,
-      onClick : [ function() {
+      element: element,
+      map: self,
+      onClick: [function () {
         return self.openInfoWindowForIdentifiedElement(element, result.getGoogleMarker());
-      }, function() {
+      }, function () {
         return self.callListeners("onBioEntityClick", element);
-      } ]
-    }).then(function(surface) {
+      }]
+    }).then(function (surface) {
       result = surface;
       dbOverlay.mapOverlays[element.getType()][element.getId()] = result;
       return result;
     });
   } else if (element.getType() === "REACTION") {
-    return map.getModel().getReactionById(element.getId()).then(function(reactionData) {
+    return map.getModel().getReactionById(element.getId()).then(function (reactionData) {
       var result = new ReactionSurface({
-        reaction : reactionData,
-        map : map,
-        customized : true,
-        color : element.getColor(),
-        onClick : [ function() {
+        reaction: reactionData,
+        map: map,
+        customized: true,
+        color: element.getColor(),
+        onClick: [function () {
           return self.openInfoWindowForIdentifiedElement(element, result.getGoogleMarker());
-        }, function() {
+        }, function () {
           return self.callListeners("onBioEntityClick", element);
-        } ]
+        }]
       });
       result.show();
       dbOverlay.mapOverlays[element.getType()][element.getId()] = result;
@@ -1319,21 +1319,21 @@ CustomMap.prototype.createSurfaceForDbOverlay = function(element, dbOverlay) {
 
 /**
  * Opens {@link AbstractInfoWindow} for a marker.
- * 
+ *
  * @param marker
  *          marker for which we are opening window
  */
-CustomMap.prototype._openInfoWindowForIdentifiedElement = function(element, googleMarker) {
+CustomMap.prototype._openInfoWindowForIdentifiedElement = function (element, googleMarker) {
   var self = this;
   var submap = self.getSubmapById(element.getModelId());
   if (element.getType() === "ALIAS") {
-    return submap.getModel().getByIdentifiedElement(element).then(function(alias) {
+    return submap.getModel().getByIdentifiedElement(element).then(function (alias) {
       return submap._openInfoWindowForAlias(alias, googleMarker);
     });
   } else if (element.getType() === "POINT") {
     return submap._openInfoWindowForPoint(new PointData(element), googleMarker);
   } else if (element.getType() === "REACTION") {
-    return submap.getModel().getByIdentifiedElement(element).then(function(reaction) {
+    return submap.getModel().getByIdentifiedElement(element).then(function (reaction) {
       return submap._openInfoWindowForReaction(reaction, googleMarker);
     });
   } else {
-- 
GitLab