loleaflet/src/layer/marker/Annotation.js | 2 loleaflet/src/layer/tile/ImpressTileLayer.js | 86 ++++++++++++++------------- 2 files changed, 48 insertions(+), 40 deletions(-)
New commits: commit 02e4f26bbb24c9891e01b55e0196b996e4de5a91 Author: Tomaž Vajngerl <[email protected]> AuthorDate: Wed Jun 24 21:31:28 2020 +0200 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Sun Jun 28 00:38:16 2020 +0200 move handling of comments/annotations into own functions This isn't a functional change, only making code more readable and easiert to search. Change-Id: I56c4b699782cfc997ae89b80add67c365e5b9009 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97334 Tested-by: Jenkins CollaboraOffice <[email protected]> Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <[email protected]> diff --git a/loleaflet/src/layer/tile/ImpressTileLayer.js b/loleaflet/src/layer/tile/ImpressTileLayer.js index cc02e444d..b24ee5ccf 100644 --- a/loleaflet/src/layer/tile/ImpressTileLayer.js +++ b/loleaflet/src/layer/tile/ImpressTileLayer.js @@ -405,57 +405,65 @@ L.ImpressTileLayer = L.TileLayer.extend({ } if (values.comments) { - this.clearAnnotations(); - for (var index in values.comments) { - var comment = values.comments[index]; - if (!this._annotations[comment.parthash]) { - this._annotations[comment.parthash] = []; - } - this._annotations[comment.parthash].push(L.annotation(this._map.options.maxBounds.getSouthEast(), comment).addTo(this._map)); - } - if (!this._topAnnotation) { - this._topAnnotation = []; - } - this._topAnnotation[this._selectedPart] = 0; - if (this.hasAnnotations(this._selectedPart)) { - this._map._docLayer._updateMaxBounds(true); - } - this.layoutAnnotations(); + this._addCommentsFromCommandValues(values.comments); } else { L.TileLayer.prototype._onCommandValuesMsg.call(this, textMsg); } }, + _addCommentsFromCommandValues: function (comments) { + this.clearAnnotations(); + for (var index in comments) { + var comment = comments[index]; + if (!this._annotations[comment.parthash]) { + this._annotations[comment.parthash] = []; + } + this._annotations[comment.parthash].push(L.annotation(this._map.options.maxBounds.getSouthEast(), comment).addTo(this._map)); + } + if (!this._topAnnotation) { + this._topAnnotation = []; + } + this._topAnnotation[this._selectedPart] = 0; + if (this.hasAnnotations(this._selectedPart)) { + this._map._docLayer._updateMaxBounds(true); + } + this.layoutAnnotations(); + }, + _onMessage: function (textMsg, img) { if (textMsg.startsWith('comment:')) { - var obj = JSON.parse(textMsg.substring('comment:'.length + 1)); - if (obj.comment.action === 'Add') { - if (!this._annotations[obj.comment.parthash]) { - this._annotations[obj.comment.parthash] = []; - } - this._annotations[obj.comment.parthash].push(L.annotation(this._map.options.maxBounds.getSouthEast(), obj.comment).addTo(this._map)); - this._topAnnotation[this._selectedPart] = Math.min(this._topAnnotation[this._selectedPart], this._annotations[this._partHashes[this._selectedPart]].length - 1); - this.updateDocBounds(1, this.extraSize); - this.layoutAnnotations(); - } else if (obj.comment.action === 'Remove') { - this.removeAnnotation(obj.comment.id); - this._topAnnotation[this._selectedPart] = Math.min(this._topAnnotation[this._selectedPart], this._annotations[this._partHashes[this._selectedPart]].length - 1); - this.updateDocBounds(0); - this.layoutAnnotations(); - } else if (obj.comment.action === 'Modify') { - var modified = this.getAnnotation(obj.comment.id); - if (modified) { - modified._data = obj.comment; - modified.update(); - this._selectedAnnotation = undefined; - this.layoutAnnotations(); - } - } + var object = JSON.parse(textMsg.substring('comment:'.length + 1)); + this._processCommentMessage(object.comment); } else { L.TileLayer.prototype._onMessage.call(this, textMsg, img); } }, + _processCommentMessage: function (comment) { + if (comment.action === 'Add') { + if (!this._annotations[comment.parthash]) { + this._annotations[comment.parthash] = []; + } + this._annotations[comment.parthash].push(L.annotation(this._map.options.maxBounds.getSouthEast(), comment).addTo(this._map)); + this._topAnnotation[this._selectedPart] = Math.min(this._topAnnotation[this._selectedPart], this._annotations[this._partHashes[this._selectedPart]].length - 1); + this.updateDocBounds(1, this.extraSize); + this.layoutAnnotations(); + } else if (comment.action === 'Remove') { + this.removeAnnotation(comment.id); + this._topAnnotation[this._selectedPart] = Math.min(this._topAnnotation[this._selectedPart], this._annotations[this._partHashes[this._selectedPart]].length - 1); + this.updateDocBounds(0); + this.layoutAnnotations(); + } else if (comment.action === 'Modify') { + var modified = this.getAnnotation(comment.id); + if (modified) { + modified._data = comment; + modified.update(); + this._selectedAnnotation = undefined; + this.layoutAnnotations(); + } + } + }, + _onInvalidateTilesMsg: function (textMsg) { var command = this._map._socket.parseServerCmd(textMsg); if (command.x === undefined || command.y === undefined || command.part === undefined) { commit 484b29744dd894c590048272df5cce7dfadf2d31 Author: Tomaž Vajngerl <[email protected]> AuthorDate: Wed Jun 24 21:27:18 2020 +0200 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Sun Jun 28 00:38:02 2020 +0200 there is no user.svg file, only user.png Change-Id: I6ce38578065817f219f6b17d223f37e479ee937c Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97333 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <[email protected]> diff --git a/loleaflet/src/layer/marker/Annotation.js b/loleaflet/src/layer/marker/Annotation.js index 4766687a3..6224007f8 100644 --- a/loleaflet/src/layer/marker/Annotation.js +++ b/loleaflet/src/layer/marker/Annotation.js @@ -203,7 +203,7 @@ L.Annotation = L.Layer.extend({ var tdImg = L.DomUtil.create(tagTd, 'loleaflet-annotation-img', tr); var tdAuthor = L.DomUtil.create(tagTd, 'loleaflet-annotation-author', tr); var imgAuthor = L.DomUtil.create('img', 'avatar-img', tdImg); - imgAuthor.setAttribute('src', L.LOUtil.getImageURL('user.svg')); + imgAuthor.setAttribute('src', L.LOUtil.getImageURL('user.png')); imgAuthor.setAttribute('width', this.options.imgSize.x); imgAuthor.setAttribute('height', this.options.imgSize.y); this._authorAvatarImg = imgAuthor; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
