[Libreoffice-commits] online.git: loleaflet/debug loleaflet/dist loleaflet/src
Mihai Varga
mihai.mv13 at gmail.com
Wed Jun 24 03:37:08 PDT 2015
loleaflet/debug/document/document_simple_example.html | 1 +
loleaflet/dist/leaflet.css | 18 +++++++++++++++++-
loleaflet/src/layer/tile/TileLayer.js | 11 +++++++++++
loleaflet/src/map/Map.js | 3 ++-
loleaflet/src/map/handler/Map.Keyboard.js | 8 ++++++++
5 files changed, 39 insertions(+), 2 deletions(-)
New commits:
commit 4b996b644d1c6b26888aa52871addaa4094a3191
Author: Mihai Varga <mihai.mv13 at gmail.com>
Date: Wed Jun 24 13:32:56 2015 +0300
Copy event handler
I implemented the solution found here
http://stackoverflow.com/questions/17527870/how-does-trello-access-the-users-clipboard#answer-17528590
which basically creates an invisible text area, sets focus to it,
selects the text, enables firing the oncopy then focus is restored to
the document.
diff --git a/loleaflet/debug/document/document_simple_example.html b/loleaflet/debug/document/document_simple_example.html
index 9f49456..8e2fb3f 100644
--- a/loleaflet/debug/document/document_simple_example.html
+++ b/loleaflet/debug/document/document_simple_example.html
@@ -32,6 +32,7 @@
only zoom and search:</p>
</div>
<div id="document-container" style="top:100px">
+ <div id="clipboard-container"><textarea id="clipboard"></textarea></div>
<div id="map"></div>
<div id="scroll-container">
<div id="mock-document">
diff --git a/loleaflet/dist/leaflet.css b/loleaflet/dist/leaflet.css
index a6a6007..104b7ff 100644
--- a/loleaflet/dist/leaflet.css
+++ b/loleaflet/dist/leaflet.css
@@ -101,7 +101,7 @@
.leaflet-top,
.leaflet-bottom {
position: absolute;
- z-index: 1000;
+ z-index: 10;
pointer-events: none;
}
.leaflet-top {
@@ -611,3 +611,19 @@
color: black;
}
}
+
+#clipboard-container {
+ position: fixed;
+ left: 0px;
+ top: 0px;
+ width: 0px;
+ height: 0px;
+ z-index: 100;
+ display: none;
+ opacity: 0;
+}
+#clipboard {
+ width: 1px;
+ height: 1px;
+ padding: 0px;
+}
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 3ad06a9..a21481b 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -174,6 +174,7 @@ L.TileLayer = L.GridLayer.extend({
this._onMouseEvent, this);
this._map.on('viewmode editmode', this._updateEditViewMode, this);
this._map.on('drag', this._updateScrollOffset, this);
+ this._map.on('copy', this._onCopy, this);
this._startMarker.on('drag dragend', this._onSelectionHandleDrag, this);
this._endMarker.on('drag dragend', this._onSelectionHandleDrag, this);
},
@@ -852,6 +853,16 @@ L.TileLayer = L.GridLayer.extend({
this._map.removeLayer(this._startMarker);
this._map.removeLayer(this._endMarker);
}
+ },
+
+ _onCopy: function (e) {
+ console.log(e);
+ e = e.originalEvent;
+ e.preventDefault();
+ e.clipboardData.setData('text', 'test copy');
+ var clipboardContainer = L.DomUtil.get('clipboard-container');
+ L.DomUtil.setStyle(clipboardContainer, 'display', 'none');
+ this._map._container.focus();
}
});
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index dcb3b2a..6d07799 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -584,6 +584,7 @@ L.Map = L.Evented.extend({
L.DomEvent[onOff](this._container, 'click dblclick mousedown mouseup ' +
'mouseover mouseout mousemove contextmenu keydown keypress keyup', this._handleDOMEvent, this);
+ L.DomEvent[onOff](L.DomUtil.get('clipboard'), 'copy', this._handleDOMEvent, this);
if (this.options.trackResize) {
L.DomEvent[onOff](window, 'resize', this._onResize, this);
@@ -636,7 +637,7 @@ L.Map = L.Evented.extend({
var data = {
originalEvent: e
};
- if (e.type !== 'keypress' && e.type !== 'keyup' && e.type !== 'keydown') {
+ if (e.type !== 'keypress' && e.type !== 'keyup' && e.type !== 'keydown' && e.type != 'copy') {
data.containerPoint = target instanceof L.Marker ?
this.latLngToContainerPoint(target.getLatLng()) : this.mouseEventToContainerPoint(e);
data.layerPoint = this.containerPointToLayerPoint(data.containerPoint);
diff --git a/loleaflet/src/map/handler/Map.Keyboard.js b/loleaflet/src/map/handler/Map.Keyboard.js
index e524ce8..afc0763 100644
--- a/loleaflet/src/map/handler/Map.Keyboard.js
+++ b/loleaflet/src/map/handler/Map.Keyboard.js
@@ -125,6 +125,14 @@ L.Map.Keyboard = L.Handler.extend({
},
_onKeyDown: function (e) {
+ if (e.ctrlKey) {
+ var clipboardContainer = L.DomUtil.get('clipboard-container');
+ var textArea = L.DomUtil.get('clipboard');
+ L.DomUtil.setStyle(clipboardContainer, 'display', 'inline');
+ textArea.value = 'dummy text';
+ textArea.focus();
+ textArea.select();
+ }
if (this._map._bDisableKeyboard || e.altKey || e.ctrlKey || e.metaKey) { return; }
var key = e.keyCode,
More information about the Libreoffice-commits
mailing list