diff options
author | Pranav Kant <pranavk@collabora.co.uk> | 2017-03-31 12:08:58 +0530 |
---|---|---|
committer | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2017-04-03 21:41:31 -0400 |
commit | b328f78657737e6ffb0fc8138779f5bdb7a7302e (patch) | |
tree | b14c43a8e98d3fccf1406d791e79820231fc57f8 /loleaflet | |
parent | 6ea752225c8581757b9abbb1485e57b32019f99c (diff) |
loleaflet: Store and hide readonly view cursors
Change-Id: Ib2bec3158275e77d883308e25f1984491309234f
(cherry picked from commit bc9823111902ec99aba7b3725e87dfc22a64b3d1)
Diffstat (limited to 'loleaflet')
-rw-r--r-- | loleaflet/reference.html | 3 | ||||
-rw-r--r-- | loleaflet/src/layer/tile/TileLayer.js | 18 | ||||
-rw-r--r-- | loleaflet/src/map/Map.js | 12 |
3 files changed, 19 insertions, 14 deletions
diff --git a/loleaflet/reference.html b/loleaflet/reference.html index 57d329c53..0db570d3e 100644 --- a/loleaflet/reference.html +++ b/loleaflet/reference.html @@ -2865,11 +2865,12 @@ Editor to WOPI Host <nobr>UserId: <String></nobr> <nobr>UserName: <String></nobr> <nobr>Color: <Number></nobr> + <nobr>ReadOnly: <Boolean></nobr> </code></td> <td>A new member is added. ViewId is unique integer identifying a session/view. UserId is user identity. UserName is display name of the user. Color is RGB color integer - value. + value. ReadOnly tells if the new view is opened as readonly. </td> </tr> <tr> diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index 05a6e5041..a5ea4bcdf 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -842,19 +842,19 @@ L.TileLayer = L.GridLayer.extend({ this._onUpdateViewCursor(viewId); }, - _addView: function(viewId, userid, username, color) { - if (color === 0 && this._map.getDocType() !== 'text') { - color = L.LOUtil.getViewIdColor(viewId); + _addView: function(viewInfo) { + if (viewInfo.color === 0 && this._map.getDocType() !== 'text') { + viewInfo.color = L.LOUtil.getViewIdColor(viewInfo.id); } - this._map.addView(viewId, userid, username, color); + this._map.addView(viewInfo); //TODO: We can initialize color and other properties here. - if (typeof this._viewCursors[viewId] !== 'undefined') { - this._viewCursors[viewId] = {}; + if (typeof this._viewCursors[viewInfo.id] !== 'undefined') { + this._viewCursors[viewInfo.id] = {}; } - this._onUpdateViewCursor(viewId); + this._onUpdateViewCursor(viewInfo.id); }, _removeView: function(viewId) { @@ -888,7 +888,7 @@ L.TileLayer = L.GridLayer.extend({ var viewIds = []; for (var viewInfoIdx in viewInfo) { if (!(parseInt(viewInfo[viewInfoIdx].id) in this._map._viewInfo)) { - this._addView(viewInfo[viewInfoIdx].id, viewInfo[viewInfoIdx].userid, viewInfo[viewInfoIdx].username, viewInfo[viewInfoIdx].color); + this._addView(viewInfo[viewInfoIdx]); } viewIds.push(viewInfo[viewInfoIdx].id); } @@ -1369,7 +1369,7 @@ L.TileLayer = L.GridLayer.extend({ var viewCursorVisible = this._viewCursors[viewId].visible; var viewPart = this._viewCursors[viewId].part; - if (viewCursorVisible && !this._isEmptyRectangle(this._viewCursors[viewId].bounds) && + if (!this._map.isViewReadOnly(viewId) && viewCursorVisible && !this._isEmptyRectangle(this._viewCursors[viewId].bounds) && (this._docType === 'text' || this._selectedPart === viewPart)) { if (!viewCursorMarker) { var viewCursorOptions = { diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js index 3d86db2b4..adeb8a83a 100644 --- a/loleaflet/src/map/Map.js +++ b/loleaflet/src/map/Map.js @@ -148,12 +148,12 @@ L.Map = L.Evented.extend({ // public methods that modify map state - addView: function(viewid, userid, username, color) { - this._viewInfo[viewid] = {'userid': userid, 'username': username, 'color': color}; - this.fire('postMessage', {msgId: 'View_Added', args: {ViewId: viewid, UserId: userid, UserName: username, Color: color}}); + addView: function(viewInfo) { + this._viewInfo[viewInfo.id] = viewInfo; + this.fire('postMessage', {msgId: 'View_Added', args: {ViewId: viewInfo.id, UserId: viewInfo.userid, UserName: viewInfo.username, Color: viewInfo.color, ReadOnly: viewInfo.readonly}}); // Fire last, otherwise not all events are handled correctly. - this.fire('addview', {viewId: viewid, username: username}); + this.fire('addview', {viewId: viewInfo.id, username: viewInfo.username, readonly: this.isViewReadOnly(viewInfo.id)}); }, removeView: function(viewid) { @@ -412,6 +412,10 @@ L.Map = L.Evented.extend({ return this._viewInfo[viewid].color; }, + isViewReadOnly: function(viewid) { + return this._viewInfo[viewid].readonly !== '0'; + }, + getCenter: function () { // (Boolean) -> LatLng this._checkIfLoaded(); |