[Libreoffice-commits] online.git: loleaflet/src

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Mar 5 13:27:09 UTC 2019


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

New commits:
commit a29bd6449a7f62bb05ad53512dde046b553daece
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Tue Jan 15 16:22:57 2019 -0400
Commit:     Henry Castro <hcastro at collabora.com>
CommitDate: Tue Mar 5 09:26:38 2019 -0400

    loleaflet: initialize the mobile toolbar of Writer document
    
    Change-Id: I6bb601d4587105b674815d9556b9461d3f8bb812

diff --git a/loleaflet/src/layer/tile/WriterTileLayer.js b/loleaflet/src/layer/tile/WriterTileLayer.js
index f7bca842b..ed002aa7a 100644
--- a/loleaflet/src/layer/tile/WriterTileLayer.js
+++ b/loleaflet/src/layer/tile/WriterTileLayer.js
@@ -3,6 +3,7 @@
  * Writer tile layer is used to display a text document
  */
 
+/* global $ _ w2ui w2utils _UNO */
 L.WriterTileLayer = L.TileLayer.extend({
 
 	newAnnotation: function (comment) {
@@ -27,12 +28,168 @@ L.WriterTileLayer = L.TileLayer.extend({
 		map.off('updatemaxbounds', this._onUpdateMaxBounds, this);
 	},
 
+	beforeAdd: function (map) {
+		if (L.Browser.mobile) {
+			map.on('doclayerinit', this.onMobileInit, this);
+		}
+	},
+
 	onAdd: function (map) {
 		L.TileLayer.prototype.onAdd.call(this, map);
 		this._annotations = L.annotationManager(map);
 		map.on('updatemaxbounds', this._onUpdateMaxBounds, this);
 	},
 
+	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: '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: '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},
+			{type: 'break', id: 'breakindent'},
+			{type: 'button',  id: 'insertannotation', img: 'annotation', hint: _UNO('.uno:InsertAnnotation', '', 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: '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'}
+		];
+
+		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', 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 = $('#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);
+			}
+		});
+
+	},
+
 	onAnnotationModify: function (annotation) {
 		this._annotations.modify(annotation);
 	},


More information about the Libreoffice-commits mailing list