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

Mihai Varga mihai.varga at collabora.com
Wed Sep 16 01:58:09 PDT 2015


 loleaflet/src/control/Control.Fonts.js |   34 ++++++++++++++++++++++-----------
 loleaflet/src/layer/tile/TileLayer.js  |   13 ++++++------
 2 files changed, 30 insertions(+), 17 deletions(-)

New commits:
commit efaba387ad0dd296a4aee47539e982176c50f7bb
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Wed Sep 16 11:57:11 2015 +0300

    loleaflet: handle multiple a multiple font selection

diff --git a/loleaflet/src/control/Control.Fonts.js b/loleaflet/src/control/Control.Fonts.js
index 4695011..2c6944e 100644
--- a/loleaflet/src/control/Control.Fonts.js
+++ b/loleaflet/src/control/Control.Fonts.js
@@ -79,6 +79,7 @@ L.Control.Fonts = L.Control.extend({
 
 	_updateSizeList: function (font) {
 		var container = this._sizeSelect;
+		var oldSize = this._sizeSelect.value;
 		for (var i = container.options.length - 1; i >= 0; i--) {
 			container.remove(i);
 		}
@@ -90,6 +91,22 @@ L.Control.Fonts = L.Control.extend({
 			item.value = size;
 			item.innerHTML = size;
 		});
+		this._setFontSize(oldSize);
+	},
+
+	_setFontSize: function (fontSize) {
+		for (i = 0; i < this._sizeSelect.length; i++) {
+			var value = this._sizeSelect[i].value;
+			if (value === fontSize) {
+				this._sizeSelect.value = fontSize;
+				return;
+			}
+		}
+		// we have a new font size, like 18.2
+		var item = L.DomUtil.create('option', '', this._sizeSelect);
+		item.value = fontSize;
+		item.innerHTML = fontSize;
+		this._sizeSelect.value = fontSize;
 	},
 
 	_onStateChange: function (e) {
@@ -99,22 +116,17 @@ L.Control.Fonts = L.Control.extend({
 				if (value && value.toLowerCase() === e.state.toLowerCase()) {
 					this._fontSelect.value = value;
 					this._updateSizeList(value);
-				}
-			}
-		}
-		else if (e.commandName === '.uno:FontHeight') {
-			for (i = 0; i < this._sizeSelect.length; i++) {
-				var value = this._sizeSelect[i].value;
-				if (value === e.state) {
-					this._sizeSelect.value = e.state;
 					return;
 				}
 			}
-			// we have a new font size, like 18.2
-			var item = L.DomUtil.create('option', '', this._sizeSelect);
+			// we have a new font name
+			var item = L.DomUtil.create('option', '', this._fontSelect);
 			item.value = e.state;
 			item.innerHTML = e.state;
-			this._sizeSelect.value = e.state;
+			this._fontSelect.value = e.state;
+		}
+		else if (e.commandName === '.uno:FontHeight') {
+			this._setFontSize(e.state);
 		}
 	}
 });
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index a78dc23..71d5b77 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -300,14 +300,15 @@ L.TileLayer = L.GridLayer.extend({
 
 	_onStateChangedMsg: function (textMsg) {
 		var unoMsg = textMsg.substr(14).split('=');
-		if (unoMsg.length < 2) {
-			return;
+		var commandName = '',
+			state = '';
+		if (unoMsg.length > 0) {
+			commandName = unoMsg[0];
 		}
-		var commandName = unoMsg[0];
-		var state = unoMsg[1];
-		if (commandName && state) {
-			this._map.fire('commandstatechanged', {commandName : commandName, state : state});
+		if (unoMsg.length > 1) {
+			state = unoMsg[1];
 		}
+		this._map.fire('commandstatechanged', {commandName : commandName, state : state});
 	},
 
 	_onStatusIndicatorMsg: function (textMsg) {


More information about the Libreoffice-commits mailing list