loleaflet/Makefile.am | 1 loleaflet/src/control/Control.MobileBottomBar.js | 137 +++++++++++++++++++++++ loleaflet/src/layer/tile/CalcTileLayer.js | 53 -------- loleaflet/src/layer/tile/ImpressTileLayer.js | 48 -------- loleaflet/src/layer/tile/WriterTileLayer.js | 55 --------- 5 files changed, 144 insertions(+), 150 deletions(-)
New commits: commit a4201e929e9d75ff746492f57e619798a31e8b40 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Fri Apr 10 19:44:21 2020 +0200 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Wed Apr 15 15:27:09 2020 +0200 Move bottom mobile toolbar to separate file Change-Id: I32e8fe251fcabd5d1c5af19cd7a72f60250c2851 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92159 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/loleaflet/Makefile.am b/loleaflet/Makefile.am index 303e53d6b..a57e9ebd4 100644 --- a/loleaflet/Makefile.am +++ b/loleaflet/Makefile.am @@ -265,6 +265,7 @@ LOLEAFLET_JS =\ src/control/Control.StatusBar.js \ src/control/Control.SearchBar.js \ src/control/Control.MobileTopBar.js \ + src/control/Control.MobileBottomBar.js \ src/control/Control.Layers.js \ src/control/Search.js \ src/control/Permission.js \ diff --git a/loleaflet/src/control/Control.MobileBottomBar.js b/loleaflet/src/control/Control.MobileBottomBar.js new file mode 100644 index 000000000..078e8d880 --- /dev/null +++ b/loleaflet/src/control/Control.MobileBottomBar.js @@ -0,0 +1,137 @@ +/* -*- js-indent-level: 8 -*- */ +/* + * L.Control.MobileBottomBar + */ + +/* global $ w2ui _ _UNO */ +L.Control.MobileBottomBar = L.Control.extend({ + + options: { + doctype: 'text' + }, + + initialize: function (docType) { + L.setOptions(this, {docType: docType}); + }, + + onAdd: function (map) { + this.map = map; + this.create(); + }, + + getToolItems: function(docType) { + if (docType == 'text') { + return [ + {type: 'button', id: 'showsearchbar', img: 'search', hint: _('Show the search bar')}, + {type: 'break'}, + {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: 'button', id: 'fontcolor', img: 'textcolor', hint: _UNO('.uno:FontColor')}, + {type: 'button', id: 'backcolor', img: 'backcolor', hint: _UNO('.uno:BackgroundColor')}, + {type: 'button', id: 'leftpara', img: 'alignleft', hint: _UNO('.uno:LeftPara', '', true), + uno: {textCommand: 'LeftPara', objectCommand: 'ObjectAlignLeft'}, + unosheet: 'AlignLeft', disabled: true}, + {type: 'button', id: 'centerpara', img: 'alignhorizontal', hint: _UNO('.uno:CenterPara', '', true), + uno: {textCommand: 'CenterPara', objectCommand: 'AlignCenter'}, + unosheet: 'AlignHorizontalCenter', disabled: true}, + {type: 'button', id: 'rightpara', img: 'alignright', hint: _UNO('.uno:RightPara', '', true), + uno: {textCommand: 'RightPara', objectCommand: 'ObjectAlignRight'}, + unosheet: 'AlignRight', disabled: true}, + {type: 'button', id: 'justifypara', img: 'alignblock', hint: _UNO('.uno:JustifyPara', '', true), uno: 'JustifyPara', unosheet: '', disabled: true}, + {type: 'break', id: 'breakspacing'}, + {type: 'button', id: 'defaultnumbering', img: 'numbering', hint: _UNO('.uno:DefaultNumbering', '', true),uno: 'DefaultNumbering', disabled: true}, + {type: 'button', id: 'defaultbullet', img: 'bullet', hint: _UNO('.uno:DefaultBullet', '', true), uno: 'DefaultBullet', disabled: true}, + {type: 'break', id: 'breakbullet', hidden: true}, + {type: 'button', id: 'incrementindent', img: 'incrementindent', hint: _UNO('.uno:IncrementIndent', '', true), uno: 'IncrementIndent', disabled: true}, + {type: 'button', id: 'decrementindent', img: 'decrementindent', hint: _UNO('.uno:DecrementIndent', '', true), uno: 'DecrementIndent', disabled: true}, + ]; + } else if (docType == 'spreadsheet') { + return [ + {type: 'button', id: 'showsearchbar', img: 'search', hint: _('Show the search bar')}, + {type: 'break'}, + {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: 'button', id: 'fontcolor', img: 'textcolor', hint: _UNO('.uno:FontColor')}, + {type: 'button', id: 'backcolor', img: 'backcolor', hint: _UNO('.uno:BackgroundColor')}, + {type: 'button', id: 'togglemergecells', img: 'togglemergecells', hint: _UNO('.uno:ToggleMergeCells', 'spreadsheet', true), uno: 'ToggleMergeCells', disabled: true}, + // {type: 'break', id: 'breakmergecells'}, + {type: 'break'}, + {type: 'button', id: 'alignleft', img: 'alignleft', hint: _UNO('.uno:AlignLeft', 'spreadsheet', true), uno: 'AlignLeft'}, + {type: 'button', id: 'alignhorizontalcenter', img: 'alignhorizontal', hint: _UNO('.uno:AlignHorizontalCenter', 'spreadsheet', true), uno: 'AlignHorizontalCenter'}, + {type: 'button', id: 'alignright', img: 'alignright', hint: _UNO('.uno:AlignRight', 'spreadsheet', true), uno: 'AlignRight'}, + {type: 'button', id: 'alignblock', img: 'alignblock', hint: _UNO('.uno:AlignBlock', 'spreadsheet', true), uno: 'AlignBlock'}, + {type: 'break'}, + {type: 'button', id: 'wraptext', img: 'wraptext', hint: _UNO('.uno:WrapText', 'spreadsheet', true), uno: 'WrapText', disabled: true}, + {type: 'button', id: 'insertrowsafter', img: 'insertrowsafter', hint: _UNO('.uno:InsertRowsAfter'), uno: 'InsertRowsAfter'}, + {type: 'button', id: 'insertcolumnsafter', img: 'insertcolumnsafter', hint: _UNO('.uno:InsertColumnsAfter'), uno: 'InsertColumnsAfter'}, + /* {type: 'button', id: 'numberformatcurrency', img: 'numberformatcurrency', hint: _UNO('.uno:NumberFormatCurrency', 'spreadsheet', true), uno: 'NumberFormatCurrency', disabled: true}, + {type: 'button', id: 'numberformatpercent', img: 'numberformatpercent', hint: _UNO('.uno:NumberFormatPercent', 'spreadsheet', true), uno: 'NumberFormatPercent', disabled: true}, + {type: 'button', id: 'numberformatdecdecimals', img: 'numberformatdecdecimals', hint: _UNO('.uno:NumberFormatDecDecimals', 'spreadsheet', true), hidden: true, uno: 'NumberFormatDecDecimals', disabled: true}, + {type: 'button', id: 'numberformatincdecimals', img: 'numberformatincdecimals', hint: _UNO('.uno:NumberFormatIncDecimals', 'spreadsheet', true), hidden: true, uno: 'NumberFormatIncDecimals', disabled: true}, + {type: 'button', id: 'sum', img: 'autosum', hint: _('Sum')}, + {type: 'break', id: 'break-number'}, */ + ]; + } else if (docType == 'presentation') { + return [ + {type: 'button', id: 'showsearchbar', img: 'search', hint: _('Show the search bar')}, + {type: 'break'}, + {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: 'button', id: 'fontcolor', img: 'textcolor', hint: _UNO('.uno:FontColor')}, + {type: 'button', id: 'backcolor', img: 'backcolor', hint: _UNO('.uno:BackgroundColor')}, + {type: 'break'}, + {type: 'button', id: 'leftpara', img: 'alignleft', hint: _UNO('.uno:LeftPara', '', true), + uno: {textCommand: 'LeftPara', objectCommand: 'ObjectAlignLeft'}}, + {type: 'button', id: 'centerpara', img: 'alignhorizontal', hint: _UNO('.uno:CenterPara', '', true), + uno: {textCommand: 'CenterPara', objectCommand: 'AlignCenter'}}, + {type: 'button', id: 'rightpara', img: 'alignright', hint: _UNO('.uno:RigthPara', '', true), + uno: {textCommand: 'RightPara', objectCommand: 'ObjectAlignRight'}}, + {type: 'button', id: 'justifypara', img: 'alignblock', hint: _UNO('.uno:JustifyPara', '', true), uno: 'JustifyPara'}, + {type: 'break'}, + {type: 'button', id: 'defaultbullet', img: 'bullet', hint: _UNO('.uno:DefaultBullet', '', true), uno: 'DefaultBullet', disabled: true}, + ]; + } + }, + + create: function() { + var toolItems = this.getToolItems(this.options.docType); + + var toolbar = $('#toolbar-down'); + toolbar.w2toolbar({ + name: 'editbar', + tooltip: 'top', + items: toolItems, + onClick: function (e) { + // use global handler + window.onClick(e, e.target); + window.hideTooltip(this, e.target); + }, + onRefresh: function(edata) { + 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); + } + }); + } +}); + +L.control.mobileBottomBar = function (docType) { + return new L.Control.MobileBottomBar(docType); +}; diff --git a/loleaflet/src/layer/tile/CalcTileLayer.js b/loleaflet/src/layer/tile/CalcTileLayer.js index 446e339eb..e6cb0ec1a 100644 --- a/loleaflet/src/layer/tile/CalcTileLayer.js +++ b/loleaflet/src/layer/tile/CalcTileLayer.js @@ -3,7 +3,7 @@ * Calc tile layer is used to display a spreadsheet document */ -/* global $ _ w2ui w2utils _UNO */ +/* global $ _ w2ui w2utils */ L.CalcTileLayer = L.TileLayer.extend({ STD_EXTRA_WIDTH: 113, /* 2mm extra for optimal width, * 0.1986cm with TeX points, @@ -71,35 +71,6 @@ L.CalcTileLayer = L.TileLayer.extend({ }, onMobileInit: function (map) { - var toolItems = [ - {type: 'button', id: 'showsearchbar', img: 'search', hint: _('Show the search bar')}, - {type: 'break'}, - {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: 'button', id: 'fontcolor', img: 'textcolor', hint: _UNO('.uno:FontColor')}, - {type: 'button', id: 'backcolor', img: 'backcolor', hint: _UNO('.uno:BackgroundColor')}, - {type: 'button', id: 'togglemergecells', img: 'togglemergecells', hint: _UNO('.uno:ToggleMergeCells', 'spreadsheet', true), uno: 'ToggleMergeCells', disabled: true}, -// {type: 'break', id: 'breakmergecells'}, - {type: 'break'}, - {type: 'button', id: 'alignleft', img: 'alignleft', hint: _UNO('.uno:AlignLeft', 'spreadsheet', true), uno: 'AlignLeft'}, - {type: 'button', id: 'alignhorizontalcenter', img: 'alignhorizontal', hint: _UNO('.uno:AlignHorizontalCenter', 'spreadsheet', true), uno: 'AlignHorizontalCenter'}, - {type: 'button', id: 'alignright', img: 'alignright', hint: _UNO('.uno:AlignRight', 'spreadsheet', true), uno: 'AlignRight'}, - {type: 'button', id: 'alignblock', img: 'alignblock', hint: _UNO('.uno:AlignBlock', 'spreadsheet', true), uno: 'AlignBlock'}, - {type: 'break'}, - {type: 'button', id: 'wraptext', img: 'wraptext', hint: _UNO('.uno:WrapText', 'spreadsheet', true), uno: 'WrapText', disabled: true}, - {type: 'button', id: 'insertrowsafter', img: 'insertrowsafter', hint: _UNO('.uno:InsertRowsAfter'), uno: 'InsertRowsAfter'}, - {type: 'button', id: 'insertcolumnsafter', img: 'insertcolumnsafter', hint: _UNO('.uno:InsertColumnsAfter'), uno: 'InsertColumnsAfter'}, -/* {type: 'button', id: 'numberformatcurrency', img: 'numberformatcurrency', hint: _UNO('.uno:NumberFormatCurrency', 'spreadsheet', true), uno: 'NumberFormatCurrency', disabled: true}, - {type: 'button', id: 'numberformatpercent', img: 'numberformatpercent', hint: _UNO('.uno:NumberFormatPercent', 'spreadsheet', true), uno: 'NumberFormatPercent', disabled: true}, - {type: 'button', id: 'numberformatdecdecimals', img: 'numberformatdecdecimals', hint: _UNO('.uno:NumberFormatDecDecimals', 'spreadsheet', true), hidden: true, uno: 'NumberFormatDecDecimals', disabled: true}, - {type: 'button', id: 'numberformatincdecimals', img: 'numberformatincdecimals', hint: _UNO('.uno:NumberFormatIncDecimals', 'spreadsheet', true), hidden: true, uno: 'NumberFormatIncDecimals', disabled: true}, - {type: 'button', id: 'sum', img: 'autosum', hint: _('Sum')}, - {type: 'break', id: 'break-number'}, */ - ]; - map.addControl(L.control.mobileTopBar('spreadsheet')); var toolbar = $('#formulabar'); @@ -153,27 +124,7 @@ L.CalcTileLayer = L.TileLayer.extend({ }); toolbar.show(); - 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 === '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.addControl(L.control.mobileBottomBar('spreadsheet')); map.addControl(L.control.searchBar()); diff --git a/loleaflet/src/layer/tile/ImpressTileLayer.js b/loleaflet/src/layer/tile/ImpressTileLayer.js index 36dabf7ba..30648c179 100644 --- a/loleaflet/src/layer/tile/ImpressTileLayer.js +++ b/loleaflet/src/layer/tile/ImpressTileLayer.js @@ -3,7 +3,7 @@ * Impress tile layer is used to display a presentation document */ -/* global $ _ w2ui w2utils _UNO L */ +/* global $ w2ui w2utils L */ L.ImpressTileLayer = L.TileLayer.extend({ extraSize: L.point(290, 0), @@ -114,27 +114,6 @@ L.ImpressTileLayer = L.TileLayer.extend({ }, onMobileInit: function (map) { - var toolItems = [ - {type: 'button', id: 'showsearchbar', img: 'search', hint: _('Show the search bar')}, - {type: 'break'}, - {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: 'button', id: 'fontcolor', img: 'textcolor', hint: _UNO('.uno:FontColor')}, - {type: 'button', id: 'backcolor', img: 'backcolor', hint: _UNO('.uno:BackgroundColor')}, - {type: 'break'}, - {type: 'button', id: 'leftpara', img: 'alignleft', hint: _UNO('.uno:LeftPara', '', true), - uno: {textCommand: 'LeftPara', objectCommand: 'ObjectAlignLeft'}}, - {type: 'button', id: 'centerpara', img: 'alignhorizontal', hint: _UNO('.uno:CenterPara', '', true), - uno: {textCommand: 'CenterPara', objectCommand: 'AlignCenter'}}, - {type: 'button', id: 'rightpara', img: 'alignright', hint: _UNO('.uno:RigthPara', '', true), - uno: {textCommand: 'RightPara', objectCommand: 'ObjectAlignRight'}}, - {type: 'button', id: 'justifypara', img: 'alignblock', hint: _UNO('.uno:JustifyPara', '', true), uno: 'JustifyPara'}, - {type: 'break'}, - {type: 'button', id: 'defaultbullet', img: 'bullet', hint: _UNO('.uno:DefaultBullet', '', true), uno: 'DefaultBullet', disabled: true}, - ]; - map.addControl(L.control.mobileTopBar('presentation')); var toolbar = $('#presentation-toolbar'); @@ -145,30 +124,7 @@ L.ImpressTileLayer = L.TileLayer.extend({ 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 === '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.addControl(L.control.mobileBottomBar('presentation')); map.addControl(L.control.searchBar()); diff --git a/loleaflet/src/layer/tile/WriterTileLayer.js b/loleaflet/src/layer/tile/WriterTileLayer.js index e9e89ddbc..72e7561fb 100644 --- a/loleaflet/src/layer/tile/WriterTileLayer.js +++ b/loleaflet/src/layer/tile/WriterTileLayer.js @@ -3,7 +3,7 @@ * Writer tile layer is used to display a text document */ -/* global $ _ w2ui _UNO */ +/* global */ L.WriterTileLayer = L.TileLayer.extend({ newAnnotation: function (comment) { @@ -52,58 +52,7 @@ L.WriterTileLayer = L.TileLayer.extend({ }, onMobileInit: function (map) { - var toolItems = [ - {type: 'button', id: 'showsearchbar', img: 'search', hint: _('Show the search bar')}, - {type: 'break'}, - {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: 'button', id: 'fontcolor', img: 'textcolor', hint: _UNO('.uno:FontColor')}, - {type: 'button', id: 'backcolor', img: 'backcolor', hint: _UNO('.uno:BackgroundColor')}, - {type: 'button', id: 'leftpara', img: 'alignleft', hint: _UNO('.uno:LeftPara', '', true), - uno: {textCommand: 'LeftPara', objectCommand: 'ObjectAlignLeft'}, - unosheet: 'AlignLeft', disabled: true}, - {type: 'button', id: 'centerpara', img: 'alignhorizontal', hint: _UNO('.uno:CenterPara', '', true), - uno: {textCommand: 'CenterPara', objectCommand: 'AlignCenter'}, - unosheet: 'AlignHorizontalCenter', disabled: true}, - {type: 'button', id: 'rightpara', img: 'alignright', hint: _UNO('.uno:RightPara', '', true), - uno: {textCommand: 'RightPara', objectCommand: 'ObjectAlignRight'}, - unosheet: 'AlignRight', disabled: true}, - {type: 'button', id: 'justifypara', img: 'alignblock', hint: _UNO('.uno:JustifyPara', '', true), uno: 'JustifyPara', unosheet: '', disabled: true}, - {type: 'break', id: 'breakspacing'}, - {type: 'button', id: 'defaultnumbering', img: 'numbering', hint: _UNO('.uno:DefaultNumbering', '', true),uno: 'DefaultNumbering', disabled: true}, - {type: 'button', id: 'defaultbullet', img: 'bullet', hint: _UNO('.uno:DefaultBullet', '', true), uno: 'DefaultBullet', disabled: true}, - {type: 'break', id: 'breakbullet', hidden: true}, - {type: 'button', id: 'incrementindent', img: 'incrementindent', hint: _UNO('.uno:IncrementIndent', '', true), uno: 'IncrementIndent', disabled: true}, - {type: 'button', id: 'decrementindent', img: 'decrementindent', hint: _UNO('.uno:DecrementIndent', '', true), uno: 'DecrementIndent', disabled: true}, - ]; - - var 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 === '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.addControl(L.control.mobileBottomBar('text')); map.addControl(L.control.mobileTopBar('text')); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits