loleaflet/src/layer/tile/ImpressTileLayer.js |  185 +++++++++++++++++++++++++++
 1 file changed, 185 insertions(+)

New commits:
commit f3c92a0c2134160a4ab6017bbdc0be8592aea7ed
Author:     Henry Castro <hcas...@collabora.com>
AuthorDate: Tue Jan 15 16:21:48 2019 -0400
Commit:     Henry Castro <hcas...@collabora.com>
CommitDate: Tue Mar 5 09:16:24 2019 -0400

    loleaflet: initialize the mobile toolbar of Impress document
    
    Change-Id: I5445cd5d9135c41d350e430af2a85cc5b7b64b7b

diff --git a/loleaflet/src/layer/tile/ImpressTileLayer.js 
b/loleaflet/src/layer/tile/ImpressTileLayer.js
index ceccc1696..87e89e899 100644
--- a/loleaflet/src/layer/tile/ImpressTileLayer.js
+++ b/loleaflet/src/layer/tile/ImpressTileLayer.js
@@ -3,6 +3,7 @@
  * Impress tile layer is used to display a presentation document
  */
 
+/* global $ _ w2ui w2utils _UNO */
 L.ImpressTileLayer = L.TileLayer.extend({
        extraSize: L.point(290, 0),
 
@@ -30,6 +31,9 @@ L.ImpressTileLayer = L.TileLayer.extend({
                map.on('AnnotationScrollUp', this.onAnnotationScrollUp, this);
                map.on('AnnotationScrollDown', this.onAnnotationScrollDown, 
this);
                map.on('resize', this.onResize, this);
+               if (L.Browser.mobile) {
+                       map.on('doclayerinit', this.onMobileInit, this);
+               }
        },
 
        getAnnotation: function (id) {
@@ -82,6 +86,187 @@ L.ImpressTileLayer = L.TileLayer.extend({
                this._isSlidePaneVisible = !(visible === 'none');
        },
 
+       onMobileInit: function () {
+               var map = this._map;
+               var toolItems = [
+                       {type: 'button',  id: 'bold',  img: 'bold', hint: 
_UNO('.uno:Bold'), uno: 'Bold'},
+                       {type: 'button',  id: 'italic', img: 'italic', hint: 
_UNO('.uno:Italic'), uno: 'Italic'},
+                       {type: 'button',  id: 'underline',  img: 'underline', 
hint: _UNO('.uno:Underline'), uno: 'Underline'},
+                       {type: 'button',  id: 'strikeout', img: 'strikeout', 
hint: _UNO('.uno:Strikeout'), uno: 'Strikeout'},
+                       {type: 'break'},
+                       {type: 'text-color',  id: 'fontcolor', img: 
'textcolor', hint: _UNO('.uno:FontColor')},
+                       {type: 'color',  id: 'backcolor', img: 'backcolor', 
hint: _UNO('.uno:BackgroundColor')},
+                       {type: 'break' , mobile:false},
+                       {type: 'button',  id: 'leftpara',  img: 'alignleft', 
hint: _UNO('.uno:LeftPara', '', true), uno: 'LeftPara', unosheet: 'AlignLeft', 
disabled: true},
+                       {type: 'button',  id: 'centerpara',  img: 
'alignhorizontal', hint: _UNO('.uno:CenterPara', '', true), uno: 'CenterPara', 
unosheet: 'AlignHorizontalCenter', disabled: true},
+                       {type: 'button',  id: 'rightpara',  img: 'alignright', 
hint: _UNO('.uno:RightPara', '', true), uno: 'RightPara', unosheet: 
'AlignRight', disabled: true},
+                       {type: 'button',  id: 'justifypara',  img: 
'alignblock', hint: _UNO('.uno:JustifyPara', '', true), uno: 'JustifyPara', 
unosheet: '', disabled: true},
+                       {type: 'break', id: 'breakpara'},
+                       {type: 'menu',  id: 'linespacing',  img: 'linespacing', 
hint: _UNO('.uno:FormatSpacingMenu'),
+                               items: [
+                                       {id: 'spacepara1', text: 
_UNO('.uno:SpacePara1'), uno: 'SpacePara1'},
+                                       {id: 'spacepara15', text: 
_UNO('.uno:SpacePara15'), uno: 'SpacePara15'},
+                                       {id: 'spacepara2', text: 
_UNO('.uno:SpacePara2'), uno: 'SpacePara2'},
+                                       {type: 'break'},
+                                       {id: 'paraspaceincrease', text: 
_UNO('.uno:ParaspaceIncrease'), uno: 'ParaspaceIncrease'},
+                                       {id: 'paraspacedecrease', text: 
_UNO('.uno:ParaspaceDecrease'), uno: 'ParaspaceDecrease'}
+                               ]},
+                       {type: 'break', id: 'breakspacing'},
+                       {type: 'button',  id: 'defaultbullet',  img: 'bullet', 
hint: _UNO('.uno:DefaultBullet', '', true), uno: 'DefaultBullet', disabled: 
true},
+                       {type: 'break', id: 'breakbullet'},
+                       {type: 'button',  id: 'insertannotation', img: 
'annotation', hint: _UNO('.uno:InsertAnnotation', '', true), hidden: true},
+                       {type: 'drop',  id: 'inserttable',  img: 'inserttable', 
hint: _('Insert table'), hidden: true, overlay: {onShow: window.insertTable},
+                        html: '<div id="inserttable-wrapper"><div 
id="inserttable-popup" class="inserttable-pop ui-widget ui-corner-all"><div 
class="inserttable-grid"></div><div id="inserttable-status" 
class="loleaflet-font" style="padding: 5px;"><br/></div></div></div>'},
+                       {type: 'button',  id: 'insertgraphic',  img: 
'insertgraphic', hint: _UNO('.uno:InsertGraphic', '', true)},
+                       {type: 'menu', id: 'menugraphic', img: 'insertgraphic', 
hint: _UNO('.uno:InsertGraphic', '', true),
+                               items: [
+                                       {id: 'localgraphic', text: _('Insert 
Local Image')},
+                                       {id: 'remotegraphic', text: 
_UNO('.uno:InsertGraphic', '', true)},
+                               ]},
+                       {type: 'button',  id: 'insertobjectchart',  img: 
'insertobjectchart', hint: _UNO('.uno:InsertObjectChart', '', true), uno: 
'InsertObjectChart'},
+                       {type: 'drop',  id: 'insertshapes',  img: 
'basicshapes_ellipse', hint: _('Insert shapes'), overlay: {onShow: 
window.insertShapes},
+                               html: '<div id="insertshape-wrapper"><div 
id="insertshape-popup" class="insertshape-pop ui-widget ui-corner-all"><div 
class="insertshape-grid"></div></div></div>'},
+
+                       {type: 'button',  id: 'link',  img: 'link', hint: 
_UNO('.uno:HyperlinkDialog'), uno: 'HyperlinkDialog', disabled: true},
+                       {type: 'button',  id: 'insertsymbol', img: 
'insertsymbol', hint: _UNO('.uno:InsertSymbol', '', true), uno: 'InsertSymbol'},
+                       {type: 'spacer'},
+                       {type: 'button',  id: 'modifypage', img: 
'sidebar_modify_page', hint: _UNO('.uno:ModifyPage', 'presentation', true), 
uno: '.uno:ModifyPage'},
+                       {type: 'button',  id: 'slidechangewindow', img: 
'sidebar_slide_change', hint: _UNO('.uno:SlideChangeWindow', 'presentation', 
true), uno: '.uno:SlideChangeWindow'},
+                       {type: 'button',  id: 'customanimation', img: 
'sidebar_custom_animation', hint: _UNO('.uno:CustomAnimation', 'presentation', 
true), uno: '.uno:CustomAnimation'},
+                       {type: 'button',  id: 'masterslidespanel', img: 
'sidebar_master_slides', hint: _('Master Slides'), uno: 
'.uno:MasterSlidesPanel'},
+                       {type: 'break', id: 'breaksidebar'}
+               ];
+
+               var toolbar = $('#toolbar-up');
+               toolbar.w2toolbar({
+                       name: 'actionbar',
+                       tooltip: 'bottom',
+                       items: [
+                               {type: 'button',  id: 'closemobile',  img: 
'closemobile'},
+                               {type: 'spacer'},
+                               {type: 'button',  id: 'prev', img: 'prev', 
hint: _UNO('.uno:PageUp', 'text')},
+                               {type: 'button',  id: 'next', img: 'next', 
hint: _UNO('.uno:PageDown', 'text')},
+                               {type: 'button',  id: 'undo',  img: 'undo', 
hint: _UNO('.uno:Undo'), uno: 'Undo', disabled: true},
+                               {type: 'button',  id: 'redo',  img: 'redo', 
hint: _UNO('.uno:Redo'), uno: 'Redo', disabled: true},
+                               {type: 'button',  id: 'fullscreen', img: 
'fullscreen', hint: _UNO('.uno:FullScreen', 'text')},
+                               {type: 'drop', id: 'userlist', img: 'users', 
hidden: true, html: '<div id="userlist_container"><table 
id="userlist_table"><tbody></tbody></table>' +
+                                       '<hr><table class="loleaflet-font" 
id="editor-btn">' +
+                                       '<tr>' +
+                                       '<td><input type="checkbox" 
name="alwaysFollow" id="follow-checkbox" onclick="editorUpdate(event)"></td>' +
+                                       '<td>' + _('Always follow the editor') 
+ '</td>' +
+                                       '</tr>' +
+                                       '</table>' +
+                                       '<p id="currently-msg">' + _('Current') 
+ ' - <b><span id="current-editor"></span></b></p>' +
+                                       '</div>'
+                               },
+                       ],
+                       onClick: function (e) {
+                               window.onClick(e, e.target);
+                               window.hideTooltip(this, e.target);
+                       },
+                       onRefresh: function() {
+                               var showUserList = map['wopi'].HideUserList !== 
null &&
+                                                                       
map['wopi'].HideUserList !== undefined &&
+                                                                       
$.inArray('true', map['wopi'].HideUserList) < 0 &&
+                                                                       
((window.mode.isMobile() && $.inArray('mobile', map['wopi'].HideUserList) < 0) 
||
+                                                                       
(window.mode.isTablet() && $.inArray('tablet', map['wopi'].HideUserList) < 0));
+                               if (this.get('userlist').hidden == true && 
showUserList) {
+                                       this.show('userlist');
+                                       this.show('userlistbreak');
+                                       map.on('deselectuser', 
window.deselectUser);
+                                       map.on('addview', window.onAddView);
+                                       map.on('removeview', 
window.onRemoveView);
+                               }
+                       }
+               });
+               toolbar.bind('touchstart', function(e) {
+                       w2ui['actionbar'].touchStarted = true;
+                       var touchEvent = e.originalEvent;
+                       if (touchEvent && touchEvent.touches.length > 1) {
+                               L.DomEvent.preventDefault(e);
+                       }
+               });
+
+               toolbar = $('#presentation-toolbar');
+               toolbar.w2toolbar({
+                       name: 'presentation-toolbar',
+                       tooltip: 'bottom',
+                       hidden: true,
+                       items: []
+               });
+
+               toolbar = $('#toolbar-down');
+               toolbar.w2toolbar({
+                       name: 'editbar',
+                       tooltip: 'top',
+                       items: toolItems,
+                       onClick: function (e) {
+                               window.onClick(e, e.target);
+                               window.hideTooltip(this, e.target);
+                       },
+                       onRefresh: function(edata) {
+                               if (edata.target === 'styles' || edata.target 
=== 'fonts' || edata.target === 'fontsizes') {
+                                       var toolItem = $(this.box).find('#tb_'+ 
this.name +'_item_'+ w2utils.escapeId(edata.item.id));
+                                       if (edata.item.hidden) {
+                                               toolItem.css('display', 'none');
+                                       } else {
+                                               toolItem.css('display', '');
+                                       }
+                                       
window.updateCommandValues(edata.target);
+                               }
+
+                               if (edata.target === 'editbar' && 
map.getDocType() === 'presentation') {
+                                       // Fill the style select box if not yet 
filled
+                                       if ($('.styles-select')[0] && 
$('.styles-select')[0].length === 1) {
+                                               var data = [''];
+                                               // Inserts a separator element
+                                               data = data.concat({text: 
'\u2500\u2500\u2500\u2500\u2500\u2500', disabled: true});
+
+                                               
L.Styles.impressLayout.forEach(function(layout) {
+                                                       data = data.concat({id: 
layout.id, text: _(layout.text)});
+                                               }, this);
+
+                                               $('.styles-select').select2({
+                                                       data: data,
+                                                       placeholder: 
_UNO('.uno:LayoutStatus', 'presentation')
+                                               });
+                                               
$('.styles-select').on('select2:select', window.onStyleSelect);
+                                       }
+                               }
+
+                               if (edata.target === 'inserttable')
+                                       window.insertTable();
+
+                               if (edata.target === 'insertshapes')
+                                       window.insertShapes();
+                       }
+               });
+               toolbar.bind('touchstart', function(e) {
+                       w2ui['editbar'].touchStarted = true;
+                       var touchEvent = e.originalEvent;
+                       if (touchEvent && touchEvent.touches.length > 1) {
+                               L.DomEvent.preventDefault(e);
+                       }
+               });
+
+               map.on('updatetoolbarcommandvalues', function() {
+                       w2ui['editbar'].refresh();
+               });
+
+               map.on('showbusy', function(e) {
+                       w2utils.lock(w2ui['actionbar'].box, e.label, true);
+               });
+
+               map.on('hidebusy', function() {
+                       // If locked, unlock
+                       if (w2ui['actionbar'].box.firstChild.className === 
'w2ui-lock') {
+                               w2utils.unlock(w2ui['actionbar'].box);
+                       }
+               });
+
+               this._map.on('updatepermission', window.onUpdatePermission);
+       },
+
        onAdd: function (map) {
                map.addControl(L.control.partsPreview());
                L.TileLayer.prototype.onAdd.call(this, map);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to