[Libreoffice-commits] online.git: Branch 'distro/collabora/milestone-7' - loleaflet/src
Jan Holesovsky
kendy at collabora.com
Tue Feb 9 17:12:37 UTC 2016
loleaflet/src/control/Control.Buttons.js | 4 ++--
loleaflet/src/control/Control.Presentation.js | 2 +-
loleaflet/src/control/Parts.js | 2 +-
loleaflet/src/control/Permission.js | 8 ++++----
loleaflet/src/control/Toolbar.js | 6 +++---
loleaflet/src/layer/tile/GridLayer.js | 2 +-
loleaflet/src/layer/tile/TileLayer.js | 4 +---
loleaflet/src/map/Map.js | 5 +----
loleaflet/src/map/handler/Map.Keyboard.js | 4 ++--
loleaflet/src/map/handler/Map.Mouse.js | 4 ++--
10 files changed, 18 insertions(+), 23 deletions(-)
New commits:
commit bfd6aa0eb83c9d3d21773572c8a4adeefbd72b20
Author: Jan Holesovsky <kendy at collabora.com>
Date: Tue Feb 9 18:12:02 2016 +0100
loleaflet: Move _permission to L.Map.
diff --git a/loleaflet/src/control/Control.Buttons.js b/loleaflet/src/control/Control.Buttons.js
index 0b0822c..9e93657 100644
--- a/loleaflet/src/control/Control.Buttons.js
+++ b/loleaflet/src/control/Control.Buttons.js
@@ -78,7 +78,7 @@ L.Control.Buttons = L.Control.extend({
callback: L.bind(this._onSaveAs, this)
});
}
- else if (button.uno && this._map._docLayer._permission === 'edit') {
+ else if (button.uno && this._map._permission === 'edit') {
if (button.unosheet && this._map.getDocType() === 'spreadsheet') {
this._map.toggleCommandState(button.unosheet);
}
@@ -121,7 +121,7 @@ L.Control.Buttons = L.Control.extend({
else if (state === 'false') {
L.DomUtil.removeClass(button.el.firstChild, 'leaflet-control-buttons-active');
}
- else if (state === 'enabled' && this._map._docLayer._permission === 'edit') {
+ else if (state === 'enabled' && this._map._permission === 'edit') {
L.DomUtil.removeClass(button.el.firstChild, 'leaflet-control-buttons-disabled');
}
else if (state === 'disabled') {
diff --git a/loleaflet/src/control/Control.Presentation.js b/loleaflet/src/control/Control.Presentation.js
index 6cac3ba..9678cde 100644
--- a/loleaflet/src/control/Control.Presentation.js
+++ b/loleaflet/src/control/Control.Presentation.js
@@ -87,7 +87,7 @@ L.Control.Presentation = L.Control.extend({
for (var key in this._buttons) {
var button = this._buttons[key];
if ('.uno:' + button.uno === commandName) {
- if (enabled === 'true' && this._map._docLayer._permission === 'edit') {
+ if (enabled === 'true' && this._map._permission === 'edit') {
L.DomUtil.removeClass(button.el.firstChild, 'leaflet-control-buttons-disabled');
}
else if (enabled === 'false') {
diff --git a/loleaflet/src/control/Parts.js b/loleaflet/src/control/Parts.js
index 8d41779..223d892 100644
--- a/loleaflet/src/control/Parts.js
+++ b/loleaflet/src/control/Parts.js
@@ -128,7 +128,7 @@ L.Map.include({
else if (typeof (page) === 'number' && page >= 0 && page < docLayer._pages) {
docLayer._currentPage = page;
}
- if (docLayer._permission !== 'edit' && docLayer._partPageRectanglesPixels.length > docLayer._currentPage) {
+ if (this._permission !== 'edit' && docLayer._partPageRectanglesPixels.length > docLayer._currentPage) {
// we can scroll to the desired page without having a LOK instance
var pageBounds = docLayer._partPageRectanglesPixels[docLayer._currentPage];
var pos = new L.Point(
diff --git a/loleaflet/src/control/Permission.js b/loleaflet/src/control/Permission.js
index b282ac3..5be2554 100644
--- a/loleaflet/src/control/Permission.js
+++ b/loleaflet/src/control/Permission.js
@@ -3,7 +3,7 @@
*/
L.Map.include({
setPermission: function (perm) {
- this._docLayer._permission = perm;
+ this._permission = perm;
if (perm === 'edit') {
this._socket.sendMessage('requestloksession');
this.dragging.disable();
@@ -19,7 +19,7 @@ L.Map.include({
},
enableSelection: function () {
- if (this._docLayer._permission === 'edit') {
+ if (this._permission === 'edit') {
return;
}
this._socket.sendMessage('requestloksession');
@@ -27,7 +27,7 @@ L.Map.include({
},
disableSelection: function () {
- if (this._docLayer._permission === 'edit') {
+ if (this._permission === 'edit') {
return;
}
this.dragging.enable();
@@ -38,6 +38,6 @@ L.Map.include({
},
getPermission: function () {
- return this._docLayer._permission;
+ return this._permission;
}
});
diff --git a/loleaflet/src/control/Toolbar.js b/loleaflet/src/control/Toolbar.js
index 2a95bc7..05bcf8a 100644
--- a/loleaflet/src/control/Toolbar.js
+++ b/loleaflet/src/control/Toolbar.js
@@ -68,7 +68,7 @@ L.Map.include({
this.fire('error', {cmd: 'setStyle', kind: 'incorrectparam'});
return;
}
- if (this._docLayer._permission === 'edit') {
+ if (this._permission === 'edit') {
var msg = 'uno .uno:StyleApply {' +
'"Style":{"type":"string", "value": "' + style + '"},' +
'"FamilyName":{"type":"string", "value":"' + familyName + '"}' +
@@ -78,13 +78,13 @@ L.Map.include({
},
sendUnoCommand: function (command, json) {
- if (this._docLayer._permission === 'edit') {
+ if (this._permission === 'edit') {
this._socket.sendMessage('uno ' + command + (json ? ' ' + JSON.stringify(json) : ''));
}
},
toggleCommandState: function (unoState) {
- if (this._docLayer._permission === 'edit') {
+ if (this._permission === 'edit') {
if (!unoState.startsWith('.uno:')) {
unoState = '.uno:' + unoState;
}
diff --git a/loleaflet/src/layer/tile/GridLayer.js b/loleaflet/src/layer/tile/GridLayer.js
index 8e3be8f..4f1d8c4 100644
--- a/loleaflet/src/layer/tile/GridLayer.js
+++ b/loleaflet/src/layer/tile/GridLayer.js
@@ -835,7 +835,7 @@ L.GridLayer = L.Layer.extend({
var tilesToFetch = 10;
var maxBorderWidth = 5;
- if (this._permission === 'edit') {
+ if (this._map._permission === 'edit') {
tilesToFetch = 5;
maxBorderWidth = 3;
}
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index f74e234..c81758e 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -79,8 +79,6 @@ L.TileLayer = L.GridLayer.extend({
// text, presentation, spreadsheet, etc
this._docType = options.docType;
this._documentInfo = '';
- // View, edit or readonly.
- this._permission = options.defaultPermission;
// Position and size of the visible cursor.
this._visibleCursor = new L.LatLngBounds(new L.LatLng(0, 0), new L.LatLng(0, 0));
// Cursor overlay is visible or hidden (for blinking).
@@ -824,7 +822,7 @@ L.TileLayer = L.GridLayer.extend({
}
}
- if (this._permission === 'edit' && this._isCursorVisible && this._isCursorOverlayVisible
+ if (this._map._permission === 'edit' && this._isCursorVisible && this._isCursorOverlayVisible
&& !this._isEmptyRectangle(this._visibleCursor)) {
if (this._cursorMarker) {
this._map.removeLayer(this._cursorMarker);
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index ddc05b3..2d0bee3 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -72,10 +72,7 @@ L.Map = L.Evented.extend({
this._socket = L.socket(this);
// when editing, we need the LOK session right away
- if (options.permission === 'edit') {
- this._socket.sendMessage('requestloksession');
- this.dragging.disable();
- }
+ this.setPermission(options.permission);
// Inhibit the context menu - the browser thinks that the document
// is just a bunch of images, hence the context menu is useless (tdf#94599)
diff --git a/loleaflet/src/map/handler/Map.Keyboard.js b/loleaflet/src/map/handler/Map.Keyboard.js
index 8b97241..b72c246 100644
--- a/loleaflet/src/map/handler/Map.Keyboard.js
+++ b/loleaflet/src/map/handler/Map.Keyboard.js
@@ -210,7 +210,7 @@ L.Map.Keyboard = L.Handler.extend({
},
_onMouseDown: function () {
- if (this._map._docLayer._permission === 'edit') {
+ if (this._map._permission === 'edit') {
return;
}
this._map._container.focus();
@@ -268,7 +268,7 @@ L.Map.Keyboard = L.Handler.extend({
}
}
- if (docLayer._permission === 'edit') {
+ if (this._map._permission === 'edit') {
docLayer._resetPreFetching();
if (e.type === 'keydown' && this.handleOnKeyDown[keyCode] && charCode === 0) {
docLayer._postKeyboardEvent('input', charCode, unoKeyCode);
diff --git a/loleaflet/src/map/handler/Map.Mouse.js b/loleaflet/src/map/handler/Map.Mouse.js
index 28919d6..9a19cdc 100644
--- a/loleaflet/src/map/handler/Map.Mouse.js
+++ b/loleaflet/src/map/handler/Map.Mouse.js
@@ -141,7 +141,7 @@ L.Map.Mouse = L.Handler.extend({
this._clickCount = 1;
mousePos = docLayer._latLngToTwips(e.latlng);
var timeOut = 250;
- if (docLayer._permission === 'edit') {
+ if (this._map._permission === 'edit') {
timeOut = 0;
}
this._mouseEventsQueue.push(L.bind(function() {
@@ -149,7 +149,7 @@ L.Map.Mouse = L.Handler.extend({
// if it's a click or mouseup after selecting
if (this._mouseEventsQueue.length > 1) {
// it's a click
- if (docLayer._permission === 'view') {
+ if (this._map._permission === 'view') {
docLayer._map.setPermission('edit');
}
}
More information about the Libreoffice-commits
mailing list