* // JS :
* var element = document.getElementById("element");
- * var header = document.getElementById("header");
* Draggable.dragElement(element, header, container);
*/
dragElement : function (element, header, container) {
- var offsetX, offsetY, constraints;
+ var offsetX, offsetY;
var isDragReady = false;
@@ -38,26 +37,21 @@ var Draggable = {
};
if (header) {
- header.onmousedown = dragMouseDown;
+ header.addEventListener("mousedown", dragMouseDown, true);
} else {
- element.onmousedown = dragMouseDown;
+ element.addEventListener("mousedown", dragMouseDown, true);
}
- if (!container) {
- constraints = {
- width : document.body.clientWidth,
- height : document.body.clientHeight,
- top : document.body.offsetTop,
- left : document.body.offsetLeft
- };
- } else {
- constraints = {
- width : container.clientWidth,
- height : container.clientHeight,
- top : container.offsetTop,
- left : container.offsetLeft
- };
- }
+ // TODO mettre en place les contraintes
+ // var constraints = {};
+ // if (container) {
+ // constraints = {
+ // width : container.clientWidth,
+ // height : container.clientHeight,
+ // top : container.offsetTop,
+ // left : container.offsetLeft
+ // };
+ // }
function dragMouseDown (e) {
e = e || window.event;
@@ -65,54 +59,53 @@ var Draggable = {
isDragReady = true;
- // get the mouse cursor position at startup:
- dragoffset.x = e.clientX - element.offsetLeft;
- dragoffset.y = e.clientY - element.offsetTop;
- logger.trace("dragoffset", dragoffset.x, dragoffset.y);
+ // get the mouse cursor position at startup
+ e._pageX = e._pageX || e.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
+ e._pageY = e._pageY || e.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
+ dragoffset.x = e._pageX - element.offsetLeft;
+ dragoffset.y = e._pageY - element.offsetTop;
- document.onmouseup = closeDragElement;
- document.onmousemove = elementDrag;
+ document.addEventListener("mouseup", closeDragElement, true);
+ document.addEventListener("mousemove", elementDrag, true);
}
function closeDragElement () {
/* stop moving when mouse button is released: */
isDragReady = false;
- document.onmouseup = null;
- document.onmousemove = null;
+ document.removeEventListener("mouseup", closeDragElement, true);
+ document.removeEventListener("mousemove", elementDrag, true);
}
function elementDrag (e) {
e = e || window.event;
- e.preventDefault();
+ // e.preventDefault();
// cf. https://jsfiddle.net/nbbg08mg/2/
if (isDragReady) {
- // calculate the new cursor position:
- var parentLeft = container ? element.parentElement.offsetLeft : 0;
- var parentTop = container ? element.parentElement.offsetTop : 0;
+ e._pageX = e._pageX || e.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
+ e._pageY = e._pageY || e.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
+
+ var parentLeft = element.parentElement.offsetLeft;
+ var parentTop = element.parentElement.offsetTop;
logger.trace("parent offset", parentLeft, parentTop);
// left/right constraint
- if (e.clientX - dragoffset.x < -parentLeft) {
- logger.trace("minx", e.clientX - dragoffset.x);
- offsetX = -parentLeft;
- } else if (e.clientX - dragoffset.x > constraints.width - constraints.left - element.clientWidth) {
- logger.trace("maxx:", e.clientX - dragoffset.x);
- offsetX = constraints.width - element.clientWidth - constraints.left;
+ if (e._pageX - dragoffset.x < 0 - parentLeft) {
+ offsetX = 0 - parentLeft;
+ } else if (e._pageX - dragoffset.x + element.clientWidth > document.body.clientWidth) {
+ offsetX = document.body.clientWidth - element.clientWidth;
} else {
- offsetX = e.clientX - dragoffset.x;
+ offsetX = e._pageX - dragoffset.x;
}
logger.trace("left/right constraint", offsetX);
// top/bottom constraint
- if (e.clientY - dragoffset.y < -parentTop) {
- logger.trace("miny:", e.clientY - dragoffset.y);
- offsetY = -parentTop;
- } else if (e.clientY - dragoffset.y > constraints.height - constraints.top - element.clientHeight) {
- logger.trace("maxy:", e.clientY - dragoffset.y);
- offsetY = constraints.height - element.clientHeight - constraints.top;
+ if (e._pageY - dragoffset.y < 0 - parentTop) {
+ offsetY = 0 - parentTop;
+ } else if (e._pageY - dragoffset.y + element.clientHeight > document.body.clientHeight) {
+ offsetY = document.body.clientHeight - element.clientHeight;
} else {
- offsetY = e.clientY - dragoffset.y;
+ offsetY = e._pageY - dragoffset.y;
}
logger.trace("top/bottom constraint", offsetY);
diff --git a/src/Leaflet/Layers/WMS.js b/src/Leaflet/Layers/WMS.js
index 3be74f7bf..eaf4937f7 100644
--- a/src/Leaflet/Layers/WMS.js
+++ b/src/Leaflet/Layers/WMS.js
@@ -15,7 +15,7 @@ var logger = Logger.getLogger("wms");
/**
* @namespace
- * @alias L.geoportalLayer.WMS
+ * @alias L.geoportalLayers.WMS
* @classdesc
*
* Leaflet Layer Class for Geoportal or INSPIRE WMS Layers.
diff --git a/src/Leaflet/Layers/WMTS.js b/src/Leaflet/Layers/WMTS.js
index 2add0bf8d..32570c846 100644
--- a/src/Leaflet/Layers/WMTS.js
+++ b/src/Leaflet/Layers/WMTS.js
@@ -14,7 +14,7 @@ var logger = Logger.getLogger("wmts");
/**
* @namespace
- * @alias L.geoportalLayer.WMTS
+ * @alias L.geoportalLayers.WMTS
* @classdesc
*
* Leaflet Layer Class for Geoportal WMTS Layers.
diff --git a/src/Leaflet/Styles.js b/src/Leaflet/Styles.js
index 95fdeadd6..ebd725cfa 100644
--- a/src/Leaflet/Styles.js
+++ b/src/Leaflet/Styles.js
@@ -1,3 +1,5 @@
+// en module ES6, on n'a pas besoin de ces CSS..., on utile le CSS géneré avec WebPack,
+// l'utilisation de ces imports est utile lors de la compilation du bundle
import "./CSS/GPgeneralWidgetLeaflet.css";
import "./CSS/Controls/ElevationPath/GPelevationPathLeaflet.css";
@@ -9,5 +11,7 @@ import "./CSS/Controls/ReverseGeocoding/GPreverseGeocodingLeaflet.css";
import "./CSS/Controls/Route/GProuteLeaflet.css";
import "./CSS/Controls/SearchEngine/GPsearchEngineLeaflet.css";
-// FIXME how to do with plugin leaflet-draw !?
-import "../../node_modules/leaflet-draw/dist/leaflet.draw-src.css";
+// plugin leaflet-draw !
+if ("__COMPILATION__".match(/true/)) {
+ require("../../node_modules/leaflet-draw/dist/leaflet.draw-src.css");
+}
diff --git a/src/Leaflet/index.js b/src/Leaflet/index.js
index 1c983bf9c..672005e16 100644
--- a/src/Leaflet/index.js
+++ b/src/Leaflet/index.js
@@ -43,6 +43,8 @@ import "./Styles";
import Controls from "./Controls/Controls";
import ElevationPath from "./Controls/ElevationPath";
import Layers from "./Layers/Layers";
+// import WMTS from "./Layers/WMTS";
+// import WMS from "./Layers/WMS";
import CRS from "./CRS/CRS";
@@ -101,6 +103,9 @@ export { default as MathUtils } from "../Common/Utils/MathUtils";
// creation du namespace pour les extensions leaflet
L.geoportalLayer = Layers; // WMS et WMTS
+// L.geoportalLayers = {};
+// L.geoportalLayers.WMTS = WMTS;
+// L.geoportalLayers.WMS = WMS;
L.geoportalControl = Controls; // IsoChrone, SearchEngine, ...
L.geoportalControl.ElevationPath.DISPLAY_PROFILE_LIB_D3 = ElevationPath.DISPLAY_PROFILE_LIB_D3;
diff --git a/src/OpenLayers/CSS/Controls/MousePosition/GPmousePositionOpenLayers.css b/src/OpenLayers/CSS/Controls/MousePosition/GPmousePositionOpenLayers.css
index 21667094c..a95370537 100644
--- a/src/OpenLayers/CSS/Controls/MousePosition/GPmousePositionOpenLayers.css
+++ b/src/OpenLayers/CSS/Controls/MousePosition/GPmousePositionOpenLayers.css
@@ -15,7 +15,9 @@ span[id^=GPshowMousePositionOpen] {
div[id^=GPmousePositionPanel-] {
/* on desactive le mode draggable de la fenêtre : */
- /* position: absolute; */
+ position: absolute;
+ left: 10px;
+ top: calc(-8px + -118px); /* FIXME !?*/
}
div[id^=GPmousePositionPanelClose] {
diff --git a/src/OpenLayers/Controls/Measures/MeasureArea.js b/src/OpenLayers/Controls/Measures/MeasureArea.js
index 9b38011b9..d8bf70322 100644
--- a/src/OpenLayers/Controls/Measures/MeasureArea.js
+++ b/src/OpenLayers/Controls/Measures/MeasureArea.js
@@ -259,8 +259,6 @@ var MeasureArea = (function (Control) {
MeasureArea.prototype.format = function (polygon) {
logger.trace("call MeasureArea::format()");
- var map = this.getMap();
-
var measure;
if (this.options.geodesic) {
var geom = polygon.clone();
diff --git a/src/OpenLayers/Controls/MousePosition.js b/src/OpenLayers/Controls/MousePosition.js
index d566492ef..3d9ff7248 100644
--- a/src/OpenLayers/Controls/MousePosition.js
+++ b/src/OpenLayers/Controls/MousePosition.js
@@ -497,7 +497,7 @@ var MousePosition = (function (Control) {
this.options.draggable = (options.draggable !== undefined) ? options.draggable : false;
/** {Boolean} specify if MousePosition control is draggable (true) or not (false) */
this.draggable = this.options.draggable;
-
+
// position marker
this._markerOverlay = null;
this._markerUrl = null;
diff --git a/src/OpenLayers/Controls/ReverseGeocode.js b/src/OpenLayers/Controls/ReverseGeocode.js
index 6f0508066..c5ede949e 100644
--- a/src/OpenLayers/Controls/ReverseGeocode.js
+++ b/src/OpenLayers/Controls/ReverseGeocode.js
@@ -169,7 +169,6 @@ var ReverseGeocode = (function (Control) {
map.getTargetElement()
);
}
-
} else {
var _map = this.getMap();
// on remet à zéro = on efface les géométries + interactions + valeurs stockées
diff --git a/src/OpenLayers/Controls/Route.js b/src/OpenLayers/Controls/Route.js
index 014f03320..a171135f5 100644
--- a/src/OpenLayers/Controls/Route.js
+++ b/src/OpenLayers/Controls/Route.js
@@ -190,7 +190,6 @@ var Route = (function (Control) {
map.getTargetElement()
);
}
-
}
// on appelle la méthode setMap originale d'OpenLayers
diff --git a/test/spec/Common/Controls/test-common-controls-drawingdom.js b/test/spec/Common/Controls/test-common-controls-drawingdom.js
index c5acc7251..7286af842 100644
--- a/test/spec/Common/Controls/test-common-controls-drawingdom.js
+++ b/test/spec/Common/Controls/test-common-controls-drawingdom.js
@@ -57,11 +57,19 @@ describe("-- Test Drawing DOM --", function () {
expect(DrawingDOM._createShowDrawingPictoElement().outerHTML).to.be.equal('');
});
it('_createDrawingPanelElement', function () {
- expect(DrawingDOM._createDrawingPanelElement().outerHTML).to.be.equal('
Annoter la carte
Outils de création
Outils d\'édition
');
+ expect(DrawingDOM._createDrawingPanelElement().outerHTML).to.be.equal('');
});
it('_createDrawingPanelHeaderElement', function () {
expect(DrawingDOM._createDrawingPanelHeaderElement().outerHTML).to.be.equal('
Annoter la carte
');
});
+ it('_createDrawingToolsSections', function () {
+ var container = document.createElement("div");
+ var tools = DrawingDOM._createDrawingToolsSections();
+ for (var i = 0; i < tools.length; i++) {
+ container.appendChild(tools[i]);
+ }
+ expect(container.outerHTML).to.be.equal('
Outils de création
Outils d\'édition
');
+ });
it('_createDrawingToolSection', function () {
var sectionLabel = "Outils de création", panelType = "draw";
expect(DrawingDOM._createDrawingToolSection(sectionLabel, panelType).outerHTML).to.be.equal('
Outils de création
');
diff --git a/test/spec/openlayers/Controls/test_ol-controls-drawing.js b/test/spec/openlayers/Controls/test_ol-controls-drawing.js
index ad96ee14d..dc5bd7f29 100644
--- a/test/spec/openlayers/Controls/test_ol-controls-drawing.js
+++ b/test/spec/openlayers/Controls/test_ol-controls-drawing.js
@@ -45,7 +45,7 @@ describe("-- Test Plugin OpenLayers Drawing --", function () {
div = null;
});
- it('I should add a control Isochron into map (with default parameters)', function () {
+ it('I should add a control Drawing into map (with default parameters)', function () {
var drawing = new Drawing();
@@ -65,7 +65,7 @@ describe("-- Test Plugin OpenLayers Drawing --", function () {
expect(map.getTargetElement().querySelector("div[id^=\"GPdrawing\"]")).to.be.ok;
});
- it('I should remove a control Isochron into map (with default parameters)', function () {
+ it('I should remove a control Drawing into map (with default parameters)', function () {
var drawing = new Drawing();