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

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Mon Apr 20 10:45:18 UTC 2020


 loleaflet/src/control/Ruler.js |   78 ++++++++++++++++++++++++++++++++---------
 1 file changed, 61 insertions(+), 17 deletions(-)

New commits:
commit 02505f1e8f4b40063bad66bbefdb892c3152d4e2
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Mon Apr 20 09:53:42 2020 +0200
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Apr 20 12:45:07 2020 +0200

    ruler: show context menu on longpress in touch environment
    
    Change-Id: I627977b7fc04df93e129bc2967bf966f6534a204
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92549
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/loleaflet/src/control/Ruler.js b/loleaflet/src/control/Ruler.js
index ea1bd1a01..e4251fd4d 100644
--- a/loleaflet/src/control/Ruler.js
+++ b/loleaflet/src/control/Ruler.js
@@ -81,6 +81,9 @@ L.Control.Ruler = L.Control.extend({
 		if (L.Browser.touch) {
 			this._hammer = new Hammer(this._rTSContainer);
 			this._hammer.add(new Hammer.Pan({ threshold: 0, pointers: 0 }));
+			this._hammer.get('press').set({
+				time: 500
+			});
 			this._hammer.on('panstart', function (event) {
 				self._initiateTabstopDrag(event);
 			});
@@ -90,6 +93,9 @@ L.Control.Ruler = L.Control.extend({
 			this._hammer.on('panend', function (event) {
 				self._endTabstopDrag(event);
 			});
+			this._hammer.on('press', function (event) {
+				self._onTabstopContainerLongPress(event);
+			});
 		}
 		return this._rWrapper;
 	},
@@ -512,6 +518,22 @@ L.Control.Ruler = L.Control.extend({
 		L.DomEvent.off(this._rTSContainer, 'mouseout', this._endTabstopDrag, this);
 	},
 
+	_onTabstopContainerLongPress: function(event) {
+		var pointX = event.center.x - event.target.getBoundingClientRect().left;
+		this.currentPositionInTwips = this._map._docLayer._pixelsToTwips({x: pointX, y:0}).x;
+
+		$.contextMenu({
+			selector: '.loleaflet-ruler-tabstopcontainer',
+			className: 'loleaflet-font',
+			items: {
+				inserttabstop: {
+					name: _('Insert tabstop'),
+					callback: (this._insertTabstop).bind(this)
+				}
+			}
+		});
+	},
+
 	_insertTabstop: function() {
 		if (this.currentPositionInTwips != null) {
 			var params = {
commit e11202ea49ca479630751c123083502db839451b
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Mon Apr 20 09:28:25 2020 +0200
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Apr 20 12:45:01 2020 +0200

    ruler: insert tabstop from a context menu (right click)
    
    Change-Id: I0699b53a6972b304f358948d49619a5004329eff
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92548
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/loleaflet/src/control/Ruler.js b/loleaflet/src/control/Ruler.js
index 3b9e52fb2..ea1bd1a01 100644
--- a/loleaflet/src/control/Ruler.js
+++ b/loleaflet/src/control/Ruler.js
@@ -388,11 +388,7 @@ L.Control.Ruler = L.Control.extend({
 
 	_initiateTabstopDrag: function(event) {
 		// console.log('===> _initiateTabstopDrag ' + event.type);
-		if (event.button !== 0) {
-			event.stopPropagation(); // prevent handling of the mother event elsewhere
-			return;
-		}
-		
+
 		var tabstopContainer = null;
 		var pointX = null;
 
@@ -405,6 +401,28 @@ L.Control.Ruler = L.Control.extend({
 			pointX = event.layerX;
 		}
 
+		if (event.button === 2) {
+			this.currentPositionInTwips = this._map._docLayer._pixelsToTwips({x: pointX, y:0}).x;
+
+			$.contextMenu({
+				selector: '.loleaflet-ruler-tabstopcontainer',
+				className: 'loleaflet-font',
+				items: {
+					inserttabstop: {
+						name: _('Insert tabstop'),
+						callback: (this._insertTabstop).bind(this)
+					}
+				}
+			});
+
+			event.stopPropagation();
+			return;
+		}
+		else if (event.button !== 0) {
+			event.stopPropagation(); // prevent handling of the mother event elsewhere
+			return;
+		}
+
 		// check if we hit any tabstop
 		var tabstop = null;
 		var margin = 10;
@@ -423,18 +441,6 @@ L.Control.Ruler = L.Control.extend({
 		}
 
 		if (tabstop == null) {
-			var positionTwip = this._map._docLayer._pixelsToTwips({x: pointX, y:0}).x;
-			var params = {
-				Index: {
-					type : 'int32',
-					value : -1
-				},
-				Position: {
-					type : 'int32',
-					value : positionTwip
-				}
-			};
-			this._map.sendUnoCommand('.uno:ChangeTabStop', params);
 			return;
 		}
 
@@ -506,6 +512,22 @@ L.Control.Ruler = L.Control.extend({
 		L.DomEvent.off(this._rTSContainer, 'mouseout', this._endTabstopDrag, this);
 	},
 
+	_insertTabstop: function() {
+		if (this.currentPositionInTwips != null) {
+			var params = {
+				Index: {
+					type : 'int32',
+					value : -1
+				},
+				Position: {
+					type : 'int32',
+					value : this.currentPositionInTwips
+				}
+			};
+			this._map.sendUnoCommand('.uno:ChangeTabStop', params);
+		}
+	},
+
 });
 
 


More information about the Libreoffice-commits mailing list