loleaflet/debug/document/document_simple_example.html |    6 ++--
 loleaflet/reference.html                              |   23 +++++++++---------
 loleaflet/src/control/Control.ColumnHeader.js         |    1 
 loleaflet/src/control/Control.Dialog.js               |    1 
 loleaflet/src/control/Control.PartsPreview.js         |    1 
 loleaflet/src/control/Control.RowHeader.js            |    1 
 loleaflet/src/control/Control.Scroll.js               |    1 
 loleaflet/src/control/Control.Tabs.js                 |    1 
 loleaflet/src/control/Control.js                      |    9 ++++---
 loleaflet/src/core/Socket.js                          |    9 ++-----
 loleaflet/src/layer/tile/TileLayer.js                 |   19 +++++++-------
 11 files changed, 34 insertions(+), 38 deletions(-)

New commits:
commit 8fcc26d9a267507e989be962ebe97e16e97c6f34
Author: Mihai Varga <mihai.va...@collabora.com>
Date:   Wed Dec 16 19:50:59 2015 +0200

    loleaflet: specify the toolbar container + don't add empty controls

diff --git a/loleaflet/debug/document/document_simple_example.html 
b/loleaflet/debug/document/document_simple_example.html
index f42eb48..861b05f 100644
--- a/loleaflet/debug/document/document_simple_example.html
+++ b/loleaflet/debug/document/document_simple_example.html
@@ -77,7 +77,8 @@
             server: host,
             permission: permission,
             timestamp: timestamp,
-            documentContainer: 'document-container'
+            documentContainer: 'document-container',
+            toolbarContainer: 'toolbar'
         });
 
     ////// Controls /////
diff --git a/loleaflet/reference.html b/loleaflet/reference.html
index a151044..5409c99 100644
--- a/loleaflet/reference.html
+++ b/loleaflet/reference.html
@@ -1465,6 +1465,14 @@ unexpected behaviour.</h4>
                <td>An outer div, containing the map div, that is used 
internally for the creation of the toolbar.</td>
        </tr>
        <tr>
+               <td><code><b>toolbarContainer</b></code></td>
+               <td><code>String / DOM element</code></td>
+               <td><code><span class="literal">undefined</span></code></td>
+               <td>A div used by the default toolbar elements (bold, italic, 
search, etc.) in loleaflet. If you implement
+           your own toolbar and use controls that do not require a toolbar 
(like the dialog or scroll control) you
+          can ignore this.</td>
+       </tr>
+       <tr>
                <td><code><b>renderingOptions</b></code></td>
                <td><code>Object</code></td>
                <td><code><span class="literal">undefined</span></code></td>
diff --git a/loleaflet/src/control/Control.ColumnHeader.js 
b/loleaflet/src/control/Control.ColumnHeader.js
index f8a406a..fcd8064 100644
--- a/loleaflet/src/control/Control.ColumnHeader.js
+++ b/loleaflet/src/control/Control.ColumnHeader.js
@@ -6,7 +6,6 @@ L.Control.ColumnHeader = L.Control.extend({
        onAdd: function (map) {
                map.on('updatepermission', this._onUpdatePermission, this);
                this._initialized = false;
-               return document.createElement('div');
        },
 
        _initialize: function () {
diff --git a/loleaflet/src/control/Control.Dialog.js 
b/loleaflet/src/control/Control.Dialog.js
index bcd9024..4907107 100644
--- a/loleaflet/src/control/Control.Dialog.js
+++ b/loleaflet/src/control/Control.Dialog.js
@@ -7,7 +7,6 @@ L.Control.Dialog = L.Control.extend({
        onAdd: function (map) {
                map.on('error', this._onError, this);
                map.on('print', this._onPrint, this);
-               return document.createElement('div');
        },
 
        _onError: function (e) {
diff --git a/loleaflet/src/control/Control.PartsPreview.js 
b/loleaflet/src/control/Control.PartsPreview.js
index 30989e3..9630373 100644
--- a/loleaflet/src/control/Control.PartsPreview.js
+++ b/loleaflet/src/control/Control.PartsPreview.js
@@ -17,7 +17,6 @@ L.Control.PartsPreview = L.Control.extend({
                map.on('updateparts', this._updateDisabled, this);
                map.on('updatepart', this._updatePart, this);
                map.on('tilepreview', this._updatePreview, this);
-               return document.createElement('div');
        },
 
        _updateDisabled: function (e) {
diff --git a/loleaflet/src/control/Control.RowHeader.js 
b/loleaflet/src/control/Control.RowHeader.js
index 1484958..42f45fd 100644
--- a/loleaflet/src/control/Control.RowHeader.js
+++ b/loleaflet/src/control/Control.RowHeader.js
@@ -6,7 +6,6 @@ L.Control.RowHeader = L.Control.extend({
        onAdd: function (map) {
                map.on('updatepermission', this._onUpdatePermission, this);
                this._initialized = false;
-               return document.createElement('div');
        },
 
        _initialize: function () {
diff --git a/loleaflet/src/control/Control.Scroll.js 
b/loleaflet/src/control/Control.Scroll.js
index 5cde0c4..f251ca4 100644
--- a/loleaflet/src/control/Control.Scroll.js
+++ b/loleaflet/src/control/Control.Scroll.js
@@ -32,7 +32,6 @@ L.Control.Scroll = L.Control.extend({
                                alwaysTriggerOffsets: false
                        }
                });
-               return document.createElement('div');
        },
 
        _onScroll: function (e) {
diff --git a/loleaflet/src/control/Control.Tabs.js 
b/loleaflet/src/control/Control.Tabs.js
index 685ce4f..33df796 100644
--- a/loleaflet/src/control/Control.Tabs.js
+++ b/loleaflet/src/control/Control.Tabs.js
@@ -11,7 +11,6 @@ L.Control.Tabs = L.Control.extend({
                this._tabsCont = L.DomUtil.create('div', 'spreadsheet-tab', 
docContainer.parentElement);
 
                map.on('updateparts', this._updateDisabled, this);
-               return document.createElement('div');
        },
 
        _updateDisabled: function (e) {
diff --git a/loleaflet/src/control/Control.js b/loleaflet/src/control/Control.js
index fe6021c..aa7f9c1 100644
--- a/loleaflet/src/control/Control.js
+++ b/loleaflet/src/control/Control.js
@@ -87,12 +87,15 @@ L.Map.include({
        addControl: function (control) {
                control._map = this;
                var controlDiv = control.onAdd(this);
-               var controlContainer = L.DomUtil.get('toolbar');
-               controlContainer.appendChild(controlDiv);
+               var controlContainer = 
L.DomUtil.get(this.options.toolbarContainer);
                if (!this._controls) {
                        this._controls = [];
                }
-               this._controls.push({div: controlDiv});
+
+               if (controlContainer && controlDiv) {
+                       controlContainer.appendChild(controlDiv);
+                       this._controls.push({div: controlDiv});
+               }
                return this;
        },
 
commit 2f40bd06b93a713a4c1ea498c2432e34a46a91c7
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