loleaflet/build/deps.js                      |    6 +++
 loleaflet/src/control/Control.MobileSlide.js |   54 +++++++++++++++++++++++++++
 loleaflet/src/layer/tile/ImpressTileLayer.js |   21 ++++++++++
 3 files changed, 80 insertions(+), 1 deletion(-)

New commits:
commit ae89da611d295c30ca00d575d5ffd27b6c44c223
Author:     Henry Castro <hcas...@collabora.com>
AuthorDate: Fri Oct 11 11:11:51 2019 -0400
Commit:     Henry Castro <hcas...@collabora.com>
CommitDate: Fri Oct 11 17:17:30 2019 +0200

    iloleaflet: mobile: add a button to insert a slide in the Impress ...
    
    document
    
    A file is created Control.MobileSlide.js for the purpose to create a
    button control at the bottom right of the Impress document only if the 
client
    browser is identified as Mobile. The button has the function to create a new
    Slide.
    
    Change-Id: I494687a91cf4dc06d08e98c6844b06fb69b2448e
    Reviewed-on: https://gerrit.libreoffice.org/80665
    Reviewed-by: Henry Castro <hcas...@collabora.com>
    Tested-by: Henry Castro <hcas...@collabora.com>

diff --git a/loleaflet/build/deps.js b/loleaflet/build/deps.js
index 900ee2733..782ddfc84 100644
--- a/loleaflet/build/deps.js
+++ b/loleaflet/build/deps.js
@@ -405,6 +405,12 @@ var deps = {
                desc: 'Attribution control.'
        },
 
+       ControlMobileSlide: {
+               src: ['control/Control.js',
+                     'control/Control.MobileSlide.js'],
+               desc: 'Mobile control to add new slide.'
+       },
+
        ControlScale: {
                src: ['control/Control.js',
                      'control/Control.Scale.js'],
diff --git a/loleaflet/src/control/Control.MobileSlide.js 
b/loleaflet/src/control/Control.MobileSlide.js
new file mode 100644
index 000000000..db7fb2e5f
--- /dev/null
+++ b/loleaflet/src/control/Control.MobileSlide.js
@@ -0,0 +1,54 @@
+/*
+ * L.Control.MobileSlide is used to add new slide button on the Impress 
document.
+ */
+
+L.Control.MobileSlide = L.Control.extend({
+       options: {
+               position: 'bottomright'
+       },
+
+       onAdd: function (map) {
+               this._map = map;
+
+               if (!this._container) {
+                       this._initLayout();
+               }
+
+               return this._container;
+       },
+
+       onRemove: function () {
+               this._map = undefined;
+       },
+
+       _onAddSlide: function () {
+               this._map.insertPage();
+       },
+
+       _initLayout: function () {
+               this._container = L.DomUtil.create('div', 'leaflet-control-zoom 
leaflet-bar');
+               this._createButton('+', '', 'leaflet-control-zoom-in',  
this._container, this._onAddSlide,  this);
+               return this._container;
+       },
+
+       _createButton: function (html, title, className, container, fnOnClick, 
context) {
+               var button = L.DomUtil.create('a', className, container);
+               button.innerHTML = html;
+               button.href = '#';
+               button.title = title;
+
+               L.DomEvent
+                   .on(button, 'click', L.DomEvent.stopPropagation)
+                   .on(button, 'mousedown', L.DomEvent.stopPropagation)
+                   .on(button, 'click', L.DomEvent.preventDefault)
+                   .on(button, 'click', this._map.focus, this._map)
+                   .on(button, 'click', fnOnClick, context);
+
+               return button;
+       },
+});
+
+L.control.mobileSlide = function (options) {
+       return new L.Control.MobileSlide(options);
+};
+
diff --git a/loleaflet/src/layer/tile/ImpressTileLayer.js 
b/loleaflet/src/layer/tile/ImpressTileLayer.js
index a2d6b607b..9e77dc1ee 100644
--- a/loleaflet/src/layer/tile/ImpressTileLayer.js
+++ b/loleaflet/src/layer/tile/ImpressTileLayer.js
@@ -7,6 +7,14 @@
 L.ImpressTileLayer = L.TileLayer.extend({
        extraSize: L.point(290, 0),
 
+       initialize: function (url, options) {
+               L.TileLayer.prototype.initialize.call(this, url, options);
+
+               if (window.mode.isMobile()) {
+                       this._addButton = L.control.mobileSlide();
+               }
+       },
+
        newAnnotation: function (comment) {
                if (this._draft) {
                        return;
@@ -25,13 +33,14 @@ L.ImpressTileLayer = L.TileLayer.extend({
        beforeAdd: function (map) {
                map.on('zoomend', this._onAnnotationZoom, this);
                map.on('updateparts', this.onUpdateParts, this);
+               map.on('updatepermission', this.onUpdatePermission, this);
                map.on('AnnotationCancel', this.onAnnotationCancel, this);
                map.on('AnnotationReply', this.onReplyClick, this);
                map.on('AnnotationSave', this.onAnnotationSave, this);
                map.on('AnnotationScrollUp', this.onAnnotationScrollUp, this);
                map.on('AnnotationScrollDown', this.onAnnotationScrollDown, 
this);
                map.on('resize', this.onResize, this);
-               if (L.Browser.mobile) {
+               if (window.mode.isMobile()) {
                        map.on('doclayerinit', this.onMobileInit, this);
                }
        },
@@ -341,6 +350,16 @@ L.ImpressTileLayer = L.TileLayer.extend({
                }
        },
 
+       onUpdatePermission: function (e) {
+               if (window.mode.isMobile()) {
+                       if (e.perm === 'edit') {
+                               this._addButton.addTo(this._map);
+                       } else {
+                               this._addButton.remove();
+                       }
+               }
+       },
+
        clearAnnotations: function () {
                var annotation;
                var annotations;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to