[Libreoffice-commits] online.git: loleaflet/src

Mihai Varga mihai.mv13 at gmail.com
Thu Jun 25 03:10:01 PDT 2015


 loleaflet/src/layer/tile/TileLayer.js |   23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

New commits:
commit d977411f0c54b6a2c68c5006d021889da07aaea3
Author: Mihai Varga <mihai.mv13 at gmail.com>
Date:   Thu Jun 25 13:06:20 2015 +0300

    Request selection content after selection and a time delta

diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index dca1acc..2033265 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -412,9 +412,18 @@ L.TileLayer = L.GridLayer.extend({
 						opacity: 0.25});
 					this._selections.addLayer(selection);
 				}
+				if (this._selectionContentRequest) {
+					clearTimeout(this._selectionContentRequest);
+				}
+				this._selectionContentRequest = setTimeout(L.bind(function () {
+					this._map.socket.send('gettextselection mimetype=text/plain;charset=utf-8');}, this), 100);
 			}
 			this._onUpdateTextSelection();
 		}
+		else if (textMsg.startsWith('textselectioncontent:')) {
+			this._selectionTextContent = textMsg.substr(22);
+			console.log(this._selectionTextContent);
+		}
 		else if (textMsg.startsWith('setpart:')) {
 			var part = parseInt(textMsg.match(/\d+/g)[0]);
 			if (part != this._currentPart) {
@@ -857,13 +866,17 @@ L.TileLayer = L.GridLayer.extend({
 	},
 
 	_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();
+		if (!this._selectionTextContent) {
+			alert('Oops, no content available yet');
+		}
+		else {
+			e.clipboardData.setData('text/plain', this._selectionTextContent);
+			var clipboardContainer = L.DomUtil.get('clipboard-container');
+			L.DomUtil.setStyle(clipboardContainer, 'display', 'none');
+			this._map._container.focus();
+		}
 	}
 });
 


More information about the Libreoffice-commits mailing list