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

Henry Castro hcastro at collabora.com
Thu Dec 14 12:56:25 UTC 2017


 loleaflet/src/layer/AnnotationManager.js |   25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

New commits:
commit 0209af3ee4105e0ccd6bae174cf8b674571da090
Author: Henry Castro <hcastro at collabora.com>
Date:   Tue May 30 15:59:00 2017 -0400

    loleaflet: merge comments and redlines items
    
    Comments and Redlines were mutually exclusive, but a document
    can contain both.
    
    Change-Id: Idb13f0c0e1216edc6bed3291c0c486b45ad74b56
    Reviewed-on: https://gerrit.libreoffice.org/38235
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/loleaflet/src/layer/AnnotationManager.js b/loleaflet/src/layer/AnnotationManager.js
index 7b1cdf4e..c3e9b9a2 100644
--- a/loleaflet/src/layer/AnnotationManager.js
+++ b/loleaflet/src/layer/AnnotationManager.js
@@ -27,21 +27,28 @@ L.AnnotationManager = L.Class.extend({
 
 	// Remove only text comments from the document (excluding change tracking comments)
 	clear: function () {
-		for (var key in this._items) {
-			if (!this._items[key].trackchange) {
-				this._map.removeLayer(this._items[key]);
+		var it = 0;
+		while (it < this._items.length) {
+			if (!this._items[it].trackchange) {
+				this._map.removeLayer(this._items[it]);
+				this._items.splice(it, 1);
+			} else {
+				it++;
 			}
 		}
-		this._items = [];
 		this._selected = null;
 		this._map.removeLayer(this._arrow);
 	},
 
 	// Remove only change tracking comments from the document
 	clearChanges: function() {
-		for (var key in this._items) {
-			if (this._items[key].trackchange) {
-				this._map.removeLayer(this._items[key]);
+		var it = 0;
+		while (it < this._items.length) {
+			if (this._items[it].trackchange) {
+				this._map.removeLayer(this._items[it]);
+				this._items.splice(it, 1);
+			} else {
+				it++;
 			}
 		}
 	},
@@ -121,7 +128,7 @@ L.AnnotationManager = L.Class.extend({
 		var comment;
 		this.clear();
 		// items contains redlines
-		var ordered = !this._items.length > 0;
+		var ordered = !this._items.length;
 		for (var index in comments) {
 			comment = comments[index];
 			this.adjustComment(comment);
@@ -145,7 +152,7 @@ L.AnnotationManager = L.Class.extend({
 		var changecomment;
 		this.clearChanges();
 		// items contains comments
-		var ordered = !this._items.length > 0;
+		var ordered = !this._items.length;
 		for (var idx in redlines) {
 			changecomment = redlines[idx];
 			if (!this.adjustRedLine(changecomment)) {


More information about the Libreoffice-commits mailing list