loleaflet/src/layer/tile/ImpressTileLayer.js | 10 ++++- loleaflet/src/layer/tile/TileLayer.js | 46 +++++++++++++++++++-------- loleaflet/src/layer/tile/WriterTileLayer.js | 7 +++- 3 files changed, 47 insertions(+), 16 deletions(-)
New commits: commit bb61033475fc1e8da370e137b50f14b00b59edd2 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Tue Jul 2 18:28:38 2019 +0200 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Tue Oct 29 20:41:44 2019 +0100 Use vex in comment modification Change-Id: Ifbd5516b6c40813931356377fad224c3f67d7936 diff --git a/loleaflet/src/layer/tile/ImpressTileLayer.js b/loleaflet/src/layer/tile/ImpressTileLayer.js index 1b362c218..2ad1ffed1 100644 --- a/loleaflet/src/layer/tile/ImpressTileLayer.js +++ b/loleaflet/src/layer/tile/ImpressTileLayer.js @@ -297,9 +297,13 @@ L.ImpressTileLayer = L.TileLayer.extend({ onAnnotationModify: function (annotation) { this.onAnnotationCancel(); this._selectedAnnotation = annotation._data.id; - annotation.edit(); - this.scrollUntilAnnotationIsVisible(annotation); - annotation.focus(); + if (window.mode.isMobile() || window.mode.isTablet) { + this.newAnnotationVex(annotation, this.onAnnotationSave, /* isMod */ true); + } else { + annotation.edit(); + this.scrollUntilAnnotationIsVisible(annotation); + annotation.focus(); + } }, onAnnotationReply: function (annotation) { diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index 7854b198d..2644a9215 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -354,13 +354,24 @@ L.TileLayer = L.GridLayer.extend({ return newEvent; }, - newAnnotationVex: function(comment, addCommentFn) { + newAnnotationVex: function(comment, addCommentFn, isMod) { var that = this; + var commentData = null; + var content = ''; + if (comment.author) { + // New comment - full data + commentData = comment; + } else { + // Modification + commentData = comment._data; + content = commentData.text; + } + var dialog = vex.dialog.open({ message: '', input: [ - '<textarea name="comment" content="' + comment.text + '" class="loleaflet-annotation-textarea" style="max-width: 400px" required />' + '<textarea name="comment" class="loleaflet-annotation-textarea" style="max-width: 400px" required>' + content + '</textarea>' ].join(''), buttons: [ $.extend({}, vex.dialog.buttons.YES, { text: _('Save') }), @@ -368,10 +379,19 @@ L.TileLayer = L.GridLayer.extend({ ], callback: function (data) { if (data) { - that._draft = L.annotation(L.latLng(0, 0), comment, {noMenu: true}).addTo(that._map); - that._draft._data.text = data.comment; + var annotation = null; + if (isMod) { + annotation = comment; + } else { + annotation = L.annotation(L.latLng(0, 0), comment, {noMenu: true}).addTo(that._map); + that._draft = annotation; + } + + annotation._data.text = data.comment; comment.text = data.comment; - addCommentFn.call(that, {annotation: that._draft}, comment); + + // FIXME: Unify annotation code in all modules... + addCommentFn.call(that, {annotation: annotation}, comment); } } }); @@ -392,18 +412,20 @@ L.TileLayer = L.GridLayer.extend({ this._contentAuthor = L.DomUtil.create(tagDiv, 'loleaflet-annotation-content-author', tdAuthor); this._contentDate = L.DomUtil.create(tagDiv, 'loleaflet-annotation-date', tdAuthor); - $(this._nodeModifyText).text(comment.text); - $(this._contentAuthor).text(comment.author); - $(this._authorAvatarImg).attr('src', comment.avatar); - var user = this._map.getViewId(comment.author); + $(this._nodeModifyText).text(commentData.text); + $(this._contentAuthor).text(commentData.author); + $(this._authorAvatarImg).attr('src', commentData.avatar); + var user = this._map.getViewId(commentData.author); if (user >= 0) { var color = L.LOUtil.rgbToHex(this._map.getViewColor(user)); $(this._authorAvatarImg).css('border-color', color); } - var d = new Date(comment.dateTime.replace(/,.*/, 'Z')); - var dateOptions = { weekday: 'short', year: 'numeric', month: 'short', day: 'numeric' }; - $(this._contentDate).text(isNaN(d.getTime()) ? comment.dateTime: d.toLocaleDateString(String.locale, dateOptions)); + if (commentData.dateTime) { + var d = new Date(commentData.dateTime.replace(/,.*/, 'Z')); + var dateOptions = { weekday: 'short', year: 'numeric', month: 'short', day: 'numeric' }; + $(this._contentDate).text(isNaN(d.getTime()) ? comment.dateTime: d.toLocaleDateString(String.locale, dateOptions)); + } dialog.contentEl.insertBefore(this._author, dialog.contentEl.childNodes[0]); diff --git a/loleaflet/src/layer/tile/WriterTileLayer.js b/loleaflet/src/layer/tile/WriterTileLayer.js index 3fd3e2c07..368cd89e4 100644 --- a/loleaflet/src/layer/tile/WriterTileLayer.js +++ b/loleaflet/src/layer/tile/WriterTileLayer.js @@ -208,7 +208,12 @@ L.WriterTileLayer = L.TileLayer.extend({ }, onAnnotationModify: function (annotation) { - this._annotations.modify(annotation); + if (window.mode.isMobile() || window.mode.isTablet) { + var that = this; + this.newAnnotationVex(annotation, function(annotation) { that._annotations._onAnnotationSave(annotation); }, /* isMod */ true); + } else { + this._annotations.modify(annotation); + } }, onAnnotationRemove: function (id) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits