loleaflet/debug/document/document_simple_example.html |    7 ++----
 loleaflet/reference.html                              |   15 +++-----------
 loleaflet/src/core/Socket.js                          |    9 ++------
 loleaflet/src/layer/tile/TileLayer.js                 |   19 +++++++++---------
 4 files changed, 20 insertions(+), 30 deletions(-)

New commits:
commit 84347b2b2e92782e172f8847db92442544e2127e
Author: Mihai Varga <mihai.va...@collabora.com>
Date:   Wed Dec 16 18:47:12 2015 +0200

    loleaflet: remove edit/readOnly map init options, add permission
    
    And permission can be 'view', 'edit' or 'readonly'

diff --git a/loleaflet/debug/document/document_simple_example.html 
b/loleaflet/debug/document/document_simple_example.html
index be06964..f42eb48 100644
--- a/loleaflet/debug/document/document_simple_example.html
+++ b/loleaflet/debug/document/document_simple_example.html
@@ -55,7 +55,7 @@
 
     var filePath = getParameterByName('file_path');
     var host = getParameterByName('host');
-    var edit = getParameterByName('edit') === 'true';
+    var permission = getParameterByName('permission');
     var timestamp = getParameterByName('timestamp');
     if (filePath === '') {
         vex.dialog.alert('Wrong file_path, usage: file_path=/path/to/doc/');
@@ -75,10 +75,9 @@
             doc: filePath,
             renderingOptions: renderingOptions,
             server: host,
-            edit: edit,
+            permission: permission,
             timestamp: timestamp,
-            documentContainer: 'document-container',
-            readOnly: false
+            documentContainer: 'document-container'
         });
 
     ////// Controls /////
diff --git a/loleaflet/reference.html b/loleaflet/reference.html
index ef4a708..a151044 100644
--- a/loleaflet/reference.html
+++ b/loleaflet/reference.html
@@ -1401,7 +1401,6 @@ var map = L.map('map', {
 var map = L.map('map', {
     doc: 'file:///path/to/document',
     server: 'ws://localhost',
-    edit: true,
     documentContainer: 'document-container'
 });</code></pre>
 
@@ -1448,16 +1447,10 @@ unexpected behaviour.</h4>
                <td>The server hosting loolwsd.</td>
        </tr>
        <tr>
-               <td><code><b>edit</b></code></td>
-               <td><code>Boolean</code></td>
-               <td><code><span class="literal">false</span></code></td>
-               <td>Whether the documet starts in viewing or editing mode.</td>
-       </tr>
-       <tr>
-               <td><code><b>readOnly</b></code></td>
-               <td><code>Boolean</code></td>
-               <td><code><span class="literal">false</span></code></td>
-               <td>Whether the documet is read-only.</td>
+               <td><code><b>permission</b></code></td>
+               <td><code>String</code></td>
+               <td><code><span class="literal">'view'</span></code></td>
+        <td>The document's <a 
href="#documentpermission-values">permission</a>.</td>
        </tr>
        <tr>
                <td><code><b>timestamp</b></code></td>
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 744ca6f..1c7397f2 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -111,15 +111,13 @@ L.Socket = {
                        var docLayer = null;
                        if (command.type === 'text') {
                                docLayer = new L.WriterTileLayer('', {
-                                       edit: this._map.options.edit,
-                                       readOnly: this._map.options.readOnly,
+                                       permission: 
this._map.options.permission,
                                        docType: command.type
                                });
                        }
                        else if (command.type === 'spreadsheet') {
                                docLayer = new L.CalcTileLayer('', {
-                                       edit: this._map.options.edit,
-                                       readOnly: this._map.options.readOnly,
+                                       permission: 
this._map.options.permission,
                                        docType: command.type
                                });
                        }
@@ -132,8 +130,7 @@ L.Socket = {
                                        tileTwipsSize = 3000;
                                }
                                docLayer = new L.ImpressTileLayer('', {
-                                       edit: this._map.options.edit,
-                                       readOnly: this._map.options.readOnly,
+                                       permission: 
this._map.options.permission,
                                        tileWidthTwips: tileTwipsSize,
                                        tileHeightTwips: tileTwipsSize,
                                        docType: command.type
diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index d68df14..1a3ef06 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -26,7 +26,8 @@ L.TileLayer = L.GridLayer.extend({
                detectRetina: false,
                crossOrigin: false,
                preFetchOtherParts: false,
-               previewInvalidationTimeout: 1000
+               previewInvalidationTimeout: 1000,
+               defaultPermission: 'view'
        },
 
        initialize: function (url, options) {
@@ -56,8 +57,8 @@ L.TileLayer = L.GridLayer.extend({
                // text, presentation, spreadsheet, etc
                this._docType = options.docType;
                this._documentInfo = '';
-               // View or edit mode.
-               this._permission = 'view';
+               // 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).
@@ -143,15 +144,15 @@ L.TileLayer = L.GridLayer.extend({
                }
                this._textArea = map._textArea;
                this._textArea.focus();
-               if (this.options.readOnly) {
-                       map.setPermission('readonly');
-               }
-               else if (this.options.edit) {
-                       map.setPermission('edit');
+               if (this.options.permission === 'edit' ||
+                               this.options.permission === 'view' ||
+                               this.options.permission === 'readonly') {
+                       map.setPermission(this.options.permission);
                }
                else {
-                       map.setPermission('view');
+                       map.setPermission(this.options.defaultPermission);
                }
+
                map.fire('statusindicator', {statusType: 'loleafletloaded'});
        },
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to