[Libreoffice-commits] online.git: loleaflet/src
Henry Castro
hcastro at collabora.com
Tue May 30 19:58:53 UTC 2017
loleaflet/src/layer/AnnotationManager.js | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
New commits:
commit 143afd674a6a18d2a2618d419a3a1f259fc1a8b3
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
diff --git a/loleaflet/src/layer/AnnotationManager.js b/loleaflet/src/layer/AnnotationManager.js
index 3ef0dc8a..7dc2e5c6 100644
--- a/loleaflet/src/layer/AnnotationManager.js
+++ b/loleaflet/src/layer/AnnotationManager.js
@@ -118,12 +118,20 @@ L.AnnotationManager = L.Class.extend({
fill: function (comments) {
var comment;
this.clear();
+ // items contains redlines
+ var ordered = !this._items.length > 0;
for (var index in comments) {
comment = comments[index];
this.adjustComment(comment);
this._items.push(L.annotation(this._map.options.maxBounds.getSouthEast(), comment).addTo(this._map));
}
if (this._items.length > 0) {
+ if (!ordered) {
+ 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);
+ });
+ }
this._map._docLayer._updateMaxBounds(true);
this.layout();
}
@@ -132,6 +140,8 @@ L.AnnotationManager = L.Class.extend({
fillChanges: function(redlines) {
var changecomment;
this.clearChanges();
+ // items contains comments
+ var ordered = !this._items.length > 0;
for (var idx in redlines) {
changecomment = redlines[idx];
if (!this.adjustRedLine(changecomment)) {
@@ -141,6 +151,12 @@ L.AnnotationManager = L.Class.extend({
this._items.push(L.annotation(this._map.options.maxBounds.getSouthEast(), changecomment).addTo(this._map));
}
if (this._items.length > 0) {
+ if (!ordered) {
+ 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);
+ });
+ }
this._map._docLayer._updateMaxBounds(true);
this.layout();
}
More information about the Libreoffice-commits
mailing list