[Libreoffice-commits] online.git: loleaflet/src
Marco Cecchetti
marco.cecchetti at collabora.com
Mon Feb 1 21:22:39 UTC 2016
loleaflet/src/layer/marker/Cursor.js | 32 ++++++++++++++++++--------------
loleaflet/src/layer/tile/TileLayer.js | 2 +-
loleaflet/src/map/Map.js | 8 ++++++++
3 files changed, 27 insertions(+), 15 deletions(-)
New commits:
commit e88d2f5ae78661ed8d6cbecbbc24bf726aadf942
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date: Mon Feb 1 22:18:13 2016 +0100
loleaflet: custom cursor properties can be passed as map options
Change-Id: I0213278becc63bbd66e202c870cb55268c1bcd2b
diff --git a/loleaflet/src/layer/marker/Cursor.js b/loleaflet/src/layer/marker/Cursor.js
index f98e323..6d9a47a 100644
--- a/loleaflet/src/layer/marker/Cursor.js
+++ b/loleaflet/src/layer/marker/Cursor.js
@@ -107,22 +107,26 @@ L.Cursor.imagePath = (function () {
}
}());
-L.Cursor.getCustomCursor = function( cursorName ) {
- var customCursor,
- isCustomCursor = true,
- top = 0,
- left = 0;
-
- if ( cursorName === 'fill' ) {
- top = 16; left = 7;
- } else {
- isCustomCursor = false;
- }
+L.Cursor.hotSpot = {
+ fill: {x: 7, y: 16}
+};
+
+L.Cursor.customCursors = [
+ 'fill'
+];
+
+L.Cursor.isCustomCursor = function (cursorName) {
+ return (L.Cursor.customCursors.indexOf(cursorName) !== -1);
+};
+
+L.Cursor.getCustomCursor = function (cursorName) {
+ var customCursor;
- if (isCustomCursor) {
+ if (L.Cursor.isCustomCursor(cursorName)) {
+ var cursorHotSpot = L.Cursor.hotSpot[cursorName] || {x: 0, y: 0};
customCursor = L.Browser.ie ? // IE10 does not like item with left/top position in the url list
'url(' + L.Cursor.imagePath + '/' + cursorName + '.cur), default' :
- 'url(' + L.Cursor.imagePath + '/' + cursorName + '.png) ' + left + ' ' + top + ', default';
+ 'url(' + L.Cursor.imagePath + '/' + cursorName + '.png) ' + cursorHotSpot.x + ' ' + cursorHotSpot.y + ', default';
}
- return customCursor
+ return customCursor;
};
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index fc46e6e..832f531 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -441,7 +441,7 @@ L.TileLayer = L.GridLayer.extend({
_onMousePointerMsg: function (textMsg) {
textMsg = textMsg.substring(14); // "mousepointer: "
textMsg = L.Cursor.getCustomCursor(textMsg) || textMsg;
- if (this._map._container.style.cursor != textMsg) {
+ if (this._map._container.style.cursor !== textMsg) {
this._map._container.style.cursor = textMsg;
}
},
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index eb430a9..daec441 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -46,6 +46,14 @@ L.Map = L.Evented.extend({
this.setView(L.latLng(options.center), options.zoom, {reset: true});
}
+ if (options.cursorURL !== undefined) {
+ L.Cursor.imagePath = options.cursorURL;
+ }
+
+ if (options.cursorHotSpot !== undefined) {
+ L.Cursor.hotSpot = options.cursorHotSpot;
+ }
+
if (options.webserver === undefined) {
var protocol = window.location.protocol === 'file:' ? 'http:' : window.location.protocol;
options.webserver = options.server.replace(/^ws:/i, protocol);
More information about the Libreoffice-commits
mailing list