[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - 2 commits - loleaflet/dist loleaflet/src

Henry Castro hcastro at collabora.com
Tue Oct 3 08:25:05 UTC 2017


 loleaflet/dist/toolbar/toolbar.js        |    6 ++++
 loleaflet/src/control/Control.Menubar.js |   40 ++++++++++++++++++++++++++-----
 loleaflet/src/layer/tile/TileLayer.js    |    2 -
 3 files changed, 41 insertions(+), 7 deletions(-)

New commits:
commit 327e4094de414444078717584524606f7a721627
Author: Henry Castro <hcastro at collabora.com>
Date:   Sun Oct 1 10:58:11 2017 -0400

    loleaflet: add tools -> language menu items
    
    Change-Id: Ie79a03b53bdbb248788e444115cf7d7e159bb964

diff --git a/loleaflet/src/control/Control.Menubar.js b/loleaflet/src/control/Control.Menubar.js
index 4a3671f2..6c7afaac 100644
--- a/loleaflet/src/control/Control.Menubar.js
+++ b/loleaflet/src/control/Control.Menubar.js
@@ -10,7 +10,8 @@ L.Control.Menubar = L.Control.extend({
 			{name: _('File'), disabled: true},
 			{name: _('Edit'), disabled: true},
 			{name: _('View'), disabled: true},
-			{name: _('Insert'), disabled: true}
+			{name: _('Insert'), disabled: true},
+			{name: _('Tools'), disabled: true},
 		],
 		text:  [
 			{name: _('File'), id: 'file', type: 'menu', menu: [
@@ -171,7 +172,9 @@ L.Control.Menubar = L.Control.extend({
 					{name: _('Merge cells'), type: 'unocommand', uno: '.uno:MergeCells'}]
 			},
 			{name: _('Tools'), id: 'tools', type: 'menu', menu: [
-				{name: _('Automatic Spell Checking'), type: 'unocommand', uno: '.uno:SpellOnline'}
+				{name: _('Automatic Spell Checking'), type: 'unocommand', uno: '.uno:SpellOnline'},
+				{name: _('Language'), type: 'menu', menu: [
+					{name: _('Reset to Default Language'), id: 'resetlanguage', type: 'unocommand', uno:'.uno:LanguageStatus?Language:string=Default_RESET_LANGUAGES'}]}
 			]},
 			{name: _('Help'), id: 'help', type: 'menu', menu: [
 				{name: _('Keyboard shortcuts'), id: 'keyboard-shortcuts', type: 'action'},
@@ -316,9 +319,10 @@ L.Control.Menubar = L.Control.extend({
 
 		map.on('doclayerinit', this._onDocLayerInit, this);
 		map.on('addmenu', this._addMenu, this);
+		map.on('commandvalues', this._onInitMenu, this);
 	},
 
-	_addMenu: function(e) {
+	_addMenu: function (e) {
 		var alreadyExists = L.DomUtil.get('menu-' + e.id);
 		if (alreadyExists)
 			return;
@@ -336,6 +340,21 @@ L.Control.Menubar = L.Control.extend({
 		this._menubarCont.insertBefore(liItem, this._menubarCont.firstChild);
 	},
 
+	_onInitMenu: function (e) {
+		if (e.commandName === '.uno:LanguageStatus') {
+			var liItem, aItem;
+			$menuParent = $('#menu-resetlanguage').parent();
+			for (var lang in e.commandValues) {
+				liItem = L.DomUtil.create('li', '');
+				aItem = L.DomUtil.create('a', '', liItem);
+				$(aItem).text(e.commandValues[lang]);
+				$(aItem).data('type', 'unocommand');
+				$(aItem).data('uno', '.uno:LanguageStatus?Language:string=' + encodeURIComponent('Default_' + e.commandValues[lang]));
+				$menuParent.append(liItem);
+			}
+		}
+	},
+
 	_onDocLayerInit: function() {
 		// clear initial menu
 		while (this._menubarCont.hasChildNodes()) {
@@ -416,13 +435,22 @@ L.Control.Menubar = L.Control.extend({
 			if (map._permission === 'edit') {
 				if (type === 'unocommand') { // enable all depending on stored commandStates
 					var unoCommand = $(aItem).data('uno');
-					if (map['stateChangeHandler'].getItemValue(unoCommand) === 'disabled') {
+					var itemState = map['stateChangeHandler'].getItemValue(unoCommand);
+					if (itemState === 'disabled') {
 						$(aItem).addClass('disabled');
 					} else {
 						$(aItem).removeClass('disabled');
 					}
-
-					if (map['stateChangeHandler'].getItemValue(unoCommand) === 'true') {
+					if (unoCommand.indexOf('.uno:LanguageStatus') !== -1) {
+						var lang = map['stateChangeHandler'].getItemValue('.uno:LanguageStatus');
+						var label = $(aItem).html();
+						if (label === lang) {
+							$(aItem).addClass('lo-menu-item-checked');
+						} else {
+							$(aItem).removeClass('lo-menu-item-checked');
+						}
+					}
+					else if (itemState === 'true') {
 						$(aItem).addClass('lo-menu-item-checked');
 					} else {
 						$(aItem).removeClass('lo-menu-item-checked');
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 1069e38b..55102d7d 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -171,6 +171,7 @@ L.TileLayer = L.GridLayer.extend({
 		this._levels = {};
 		this._tiles = {};
 		this._tileCache = {};
+		this._map._socket.sendMessage('commandvalues command=.uno:LanguageStatus');
 		this._map._socket.sendMessage('commandvalues command=.uno:ViewAnnotations');
 		var that = this;
 		$.contextMenu({
@@ -1006,7 +1007,6 @@ L.TileLayer = L.GridLayer.extend({
 		var index = textMsg.indexOf('=');
 		var commandName = index !== -1 ? textMsg.substr(0, index) : '';
 		var state = index !== -1 ? textMsg.substr(index + 1) : '';
-
 		this._map.fire('commandstatechanged', {commandName : commandName, state : state});
 	},
 
commit dafc325c4c5e4835f5b8f9d9310ec880a76ec7fa
Author: Henry Castro <hcastro at collabora.com>
Date:   Sun Oct 1 10:53:36 2017 -0400

    loleaflet: add language status bar item
    
    Change-Id: I6615373a27b1a32561f3c5fba2f9c7765dbf9bef

diff --git a/loleaflet/dist/toolbar/toolbar.js b/loleaflet/dist/toolbar/toolbar.js
index f54127ba..e540f608 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -660,6 +660,9 @@ $(function () {
 			{type: 'button',  id: 'cancelsearch', img: 'cancel', hint: _('Cancel the search'), hidden: true},
 			{type: 'html',  id: 'left'},
 			{type: 'html',  id: 'right'},
+			{type: 'html',  id: 'LanguageStatus',
+			 html: '<div id="LanguageStatus" class="loleaflet-font" title="'+_('Text Language')+ '" style="padding: 5px 5px;">    &nbsp</div>' },
+			{type: 'break', id: 'languagestatusbreak'},
 			{type: 'html',    id: 'modifiedstatuslabel', html: '<div id="modifiedstatuslabel" class="loleaflet-font"></div>'},
 			{type: 'break', id: 'modifiedstatuslabelbreak'},
 			{type: 'drop', id: 'userlist', text: _('No users'), html: '<div id="userlist_container"><table id="userlist_table"><tbody></tbody></table></div>' },
@@ -1172,6 +1175,9 @@ map.on('commandstatechanged', function (e) {
 			L.DomUtil.setStyle(div, 'background', color);
 		}
 	}
+	else if (commandName === '.uno:LanguageStatus') {
+		$('#LanguageStatus').html(state);
+	}
 	else if (commandName === '.uno:ModifiedStatus') {
 		var modifiedStatus = e.state === 'true';
 		if (modifiedStatus) {


More information about the Libreoffice-commits mailing list