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

Pranav Kant pranavk at collabora.co.uk
Fri Apr 14 08:23:21 UTC 2017


 loleaflet/dist/loleaflet.css             |    1 
 loleaflet/src/layer/AnnotationManager.js |   34 +++++++++++++++++++++++++++++--
 2 files changed, 32 insertions(+), 3 deletions(-)

New commits:
commit 86be5a24a50907a31049bc59c30991b384612428
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Apr 14 13:46:01 2017 +0530

    loleaflet: Remove box-shadow from comments
    
    This box-shadow interferes with direct comment children and breaks the
    root-children comment block UI. Lets remove the shadow for now.
    
    Change-Id: Idda659bcfca76093c148400b2ab311bc39861e84

diff --git a/loleaflet/dist/loleaflet.css b/loleaflet/dist/loleaflet.css
index cd7ae6a0..f1ea80bd 100644
--- a/loleaflet/dist/loleaflet.css
+++ b/loleaflet/dist/loleaflet.css
@@ -145,7 +145,6 @@ body {
 	text-align: left;
 	border-radius: 5px;
 	background-color: #efefef;
-	box-shadow: 0px 3px 6px rgba(0,0,0,0.2);
 	color: #222;
 	border: none;
 	border-radius: 2px;
commit 3f397584aa0a46f0303019b6fd533030b351e94e
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Apr 14 13:45:16 2017 +0530

    loleaflet: Adjust parent,children when comment is added/removed
    
    ... in between comments.
    
    Change-Id: I7b707d04adb045df43c66a29ccc9d2c3e702fca5

diff --git a/loleaflet/src/layer/AnnotationManager.js b/loleaflet/src/layer/AnnotationManager.js
index 09148ad9..d662bb48 100644
--- a/loleaflet/src/layer/AnnotationManager.js
+++ b/loleaflet/src/layer/AnnotationManager.js
@@ -349,10 +349,15 @@ L.AnnotationManager = L.Class.extend({
 
 	add: function (comment) {
 		var annotation = L.annotation(this._map.options.maxBounds.getSouthEast(), comment).addTo(this._map);
-		this._items.push(annotation);
+		if (comment.parent && comment.parent > '0') {
+			var parentIdx = this.getIndexOf(comment.parent);
+			this._items.splice(parentIdx + 1, 0, annotation);
+		} else {
+			this._items.push(annotation);
+		}
 		this._items.sort(function(a, b) {
 			return Math.abs(a._data.anchorPos.min.y) - Math.abs(b._data.anchorPos.min.y) ||
-			       Math.abs(a._data.anchorPos.min.x) - Math.abs(b._data.anchorPos.min.x);
+				Math.abs(a._data.anchorPos.min.x) - Math.abs(b._data.anchorPos.min.x);
 		});
 		return annotation;
 	},
@@ -411,6 +416,29 @@ L.AnnotationManager = L.Class.extend({
 		this._map.focus();
 	},
 
+	// Adjust parent-child relationship, if required, after `comment` is added
+	adjustParentAdd: function(comment) {
+		if (comment.parent && comment.parent > '0') {
+			var parentIdx = this.getIndexOf(comment.parent);
+			if (this._items[parentIdx + 1] && this._items[parentIdx + 1]._data.parent === this._items[parentIdx]._data.id) {
+				this._items[parentIdx + 1]._data.parent = comment.id;
+			}
+		}
+	},
+
+	// Adjust parent-child relationship, if required, after `comment` is removed
+	adjustParentRemove: function(comment) {
+		var newId = '0';
+		var parentIdx = this.getIndexOf(comment._data.parent);
+		if (parentIdx >= 0) {
+			newId = this._items[parentIdx]._data.id;
+		}
+		var currentIdx = this.getIndexOf(comment._data.id);
+		if (this._items[currentIdx + 1]) {
+			this._items[currentIdx + 1]._data.parent = newId;
+		}
+	},
+
 	onACKComment: function (obj) {
 		var id;
 		var changetrack = obj.redline ? true : false;
@@ -421,6 +449,7 @@ L.AnnotationManager = L.Class.extend({
 				this.add(obj.redline);
 			} else {
 				this.adjustComment(obj.comment);
+				this.adjustParentAdd(obj.comment);
 				this.add(obj.comment);
 			}
 			if (this._selected && !this._selected.isEdit()) {
@@ -431,6 +460,7 @@ L.AnnotationManager = L.Class.extend({
 			id = changetrack ? 'change-' + obj.redline.index : obj.comment.id;
 			var removed = this.getItem(id);
 			if (removed) {
+				this.adjustParentRemove(removed);
 				this._map.removeLayer(this.removeItem(id));
 				if (this._selected === removed) {
 					this.unselect();


More information about the Libreoffice-commits mailing list