[Libreoffice-commits] online.git: loleaflet/src
Henry Castro
hcastro at collabora.com
Mon Mar 6 02:18:50 UTC 2017
loleaflet/src/layer/AnnotationManager.js | 55 +++++++-----------------
loleaflet/src/layer/tile/CalcTileLayer.js | 60 +++++++--------------------
loleaflet/src/layer/tile/ImpressTileLayer.js | 8 +++
loleaflet/src/layer/tile/TileLayer.js | 28 ++++++++++++
loleaflet/src/layer/tile/WriterTileLayer.js | 8 +++
5 files changed, 76 insertions(+), 83 deletions(-)
New commits:
commit 9af9ce98294ce141784469a79a3961d347197fcd
Author: Henry Castro <hcastro at collabora.com>
Date: Sun Mar 5 22:19:23 2017 -0400
loleaflet: simplify popup menu of the annotation objects
Change-Id: I2eee2e317afc01fdb9aff90481cb546e3edf8b39
diff --git a/loleaflet/src/layer/AnnotationManager.js b/loleaflet/src/layer/AnnotationManager.js
index c816700..c07ab03 100644
--- a/loleaflet/src/layer/AnnotationManager.js
+++ b/loleaflet/src/layer/AnnotationManager.js
@@ -17,26 +17,6 @@ L.AnnotationManager = L.Class.extend({
this._map.on('AnnotationCancel', this._onAnnotationCancel, this);
this._map.on('AnnotationClick', this._onAnnotationClick, this);
this._map.on('AnnotationSave', this._onAnnotationSave, this);
- var that = this;
- $.contextMenu({
- selector: '.loleaflet-annotation-menu',
- trigger: 'none',
- className: 'loleaflet-font',
- items: {
- modify: {
- name: _('Modify'),
- callback: function (key, options) {
- that._onAnnotationModify.call(that, options.$trigger.get(0).annotation);
- }
- },
- remove: {
- name: _('Remove'),
- callback: function (key, options) {
- that._onAnnotationRemove.call(that, options.$trigger.get(0).annotation._data.id);
- }
- }
- }
- });
},
clear: function () {
@@ -188,9 +168,23 @@ L.AnnotationManager = L.Class.extend({
}
},
+ modify: function (annotation) {
+ annotation.edit();
+ this.select(annotation);
+ annotation.focus();
+ },
+
remove: function (id) {
+ var comment = {
+ Id: {
+ type: 'string',
+ value: id
+ }
+ };
+ this._map.sendUnoCommand('.uno:DeleteComment', comment);
this._map.removeLayer(this.removeItem(id));
this.unselect();
+ this._map.focus();
},
onACKComment: function (textMsg) {
@@ -216,7 +210,8 @@ L.AnnotationManager = L.Class.extend({
this.layout();
} else if (obj.comment.action === 'Remove') {
if (this.getItem(obj.comment.id)) {
- this.remove(obj.comment.id);
+ this._map.removeLayer(this.removeItem(id));
+ this.unselect();
}
} else if (obj.comment.action === 'Modify') {
var modified = this.getItem(obj.comment.id);
@@ -241,24 +236,6 @@ L.AnnotationManager = L.Class.extend({
this.select(e.annotation);
},
- _onAnnotationModify: function (annotation) {
- annotation.edit();
- this.select(annotation);
- annotation.focus();
- },
-
- _onAnnotationRemove: function (id) {
- var comment = {
- Id: {
- type: 'string',
- value: id
- }
- };
- this._map.sendUnoCommand('.uno:DeleteComment', comment);
- this.remove(id);
- this._map.focus();
- },
-
_onAnnotationSave: function (e) {
var comment;
if (e.annotation._data.id === 'new') {
diff --git a/loleaflet/src/layer/tile/CalcTileLayer.js b/loleaflet/src/layer/tile/CalcTileLayer.js
index 000d795..4fbf4d1 100644
--- a/loleaflet/src/layer/tile/CalcTileLayer.js
+++ b/loleaflet/src/layer/tile/CalcTileLayer.js
@@ -63,36 +63,25 @@ L.CalcTileLayer = L.TileLayer.extend({
},
onAdd: function (map) {
- var that = this;
L.TileLayer.prototype.onAdd.call(this, map);
this._annotations = {};
- $.contextMenu({
- selector: '.loleaflet-annotation-menu',
- trigger: 'none',
- className: 'loleaflet-font',
- items: {
- modify: {
- name: _('Modify'),
- callback: function (key, options) {
- that._onAnnotationModify.call(that, options.$trigger.get(0).annotation);
- }
- },
- remove: {
- name: _('Remove'),
- callback: function (key, options) {
- that._onAnnotationRemove.call(that, options.$trigger.get(0).annotation._data.id);
- }
- }
- },
- events: {
- show: function (options) {
- options.$trigger.get(0).annotation._contextMenu = true;
- },
- hide: function (options) {
- options.$trigger.get(0).annotation._contextMenu = false;
- }
+ },
+
+ onAnnotationModify: function (annotation) {
+ annotation.edit();
+ annotation.focus();
+ },
+
+ onAnnotationRemove: function (id) {
+ var comment = {
+ Id: {
+ type: 'string',
+ value: id
}
- });
+ };
+ this._map.sendUnoCommand('.uno:DeleteComment', comment);
+ this.removeAnnotation(id);
+ this._map.focus();
},
removeAnnotation: function (id) {
@@ -139,23 +128,6 @@ L.CalcTileLayer = L.TileLayer.extend({
this._map.focus();
},
- _onAnnotationModify: function (annotation) {
- annotation.edit();
- annotation.focus();
- },
-
- _onAnnotationRemove: function (id) {
- var comment = {
- Id: {
- type: 'string',
- value: id
- }
- };
- this._map.sendUnoCommand('.uno:DeleteComment', comment);
- this.removeAnnotation(id);
- this._map.focus();
- },
-
_onMessage: function (textMsg, img) {
if (textMsg.startsWith('comment:')) {
var obj = JSON.parse(textMsg.substring('comment:'.length + 1));
diff --git a/loleaflet/src/layer/tile/ImpressTileLayer.js b/loleaflet/src/layer/tile/ImpressTileLayer.js
index 0c1b267..0c6f0ed 100644
--- a/loleaflet/src/layer/tile/ImpressTileLayer.js
+++ b/loleaflet/src/layer/tile/ImpressTileLayer.js
@@ -19,6 +19,14 @@ L.ImpressTileLayer = L.TileLayer.extend({
this._annotations = L.annotationManager(map);
},
+ onAnnotationModify: function (annotation) {
+ this._annotations.modify(annotation);
+ },
+
+ onAnnotationRemove: function (id) {
+ this._annotations.remove(id);
+ },
+
_onCommandValuesMsg: function (textMsg) {
var values = JSON.parse(textMsg.substring(textMsg.indexOf('{')));
if (!values) {
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 46acb29..6fb2f15 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -170,6 +170,34 @@ L.TileLayer = L.GridLayer.extend({
this._tiles = {};
this._tileCache = {};
this._map._socket.sendMessage('commandvalues command=.uno:ViewAnnotations');
+ var that = this;
+ $.contextMenu({
+ selector: '.loleaflet-annotation-menu',
+ trigger: 'none',
+ className: 'loleaflet-font',
+ items: {
+ modify: {
+ name: _('Modify'),
+ callback: function (key, options) {
+ that.onAnnotationModify.call(that, options.$trigger.get(0).annotation);
+ }
+ },
+ remove: {
+ name: _('Remove'),
+ callback: function (key, options) {
+ that.onAnnotationRemove.call(that, options.$trigger.get(0).annotation._data.id);
+ }
+ }
+ },
+ events: {
+ show: function (options) {
+ options.$trigger.get(0).annotation._contextMenu = true;
+ },
+ hide: function (options) {
+ options.$trigger.get(0).annotation._contextMenu = false;
+ }
+ }
+ });
map._fadeAnimated = false;
this._viewReset();
diff --git a/loleaflet/src/layer/tile/WriterTileLayer.js b/loleaflet/src/layer/tile/WriterTileLayer.js
index 4e78168..f198457 100644
--- a/loleaflet/src/layer/tile/WriterTileLayer.js
+++ b/loleaflet/src/layer/tile/WriterTileLayer.js
@@ -19,6 +19,14 @@ L.WriterTileLayer = L.TileLayer.extend({
this._annotations = L.annotationManager(map);
},
+ onAnnotationModify: function (annotation) {
+ this._annotations.modify(annotation);
+ },
+
+ onAnnotationRemove: function (id) {
+ this._annotations.remove(id);
+ },
+
_onCommandValuesMsg: function (textMsg) {
var values = JSON.parse(textMsg.substring(textMsg.indexOf('{')));
if (!values) {
More information about the Libreoffice-commits
mailing list