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

Mihai Varga mihai.varga at collabora.com
Tue Sep 15 03:45:29 PDT 2015


 loleaflet/src/control/Control.Fonts.js |   34 ++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)

New commits:
commit aa6b70f574acd3d0962bd38bd9e4e95546d00e76
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Tue Sep 15 13:44:38 2015 +0300

    loleaflet: fixed the font size select
    
    Sizes were not updated correctly

diff --git a/loleaflet/src/control/Control.Fonts.js b/loleaflet/src/control/Control.Fonts.js
index a07c166..8a5201e 100644
--- a/loleaflet/src/control/Control.Fonts.js
+++ b/loleaflet/src/control/Control.Fonts.js
@@ -63,6 +63,19 @@ L.Control.Fonts = L.Control.extend({
 		if (font === this.options.fontsInfo) {
 			return;
 		}
+		this._updateSizeList(font);
+		this._map.applyFont(font);
+	},
+
+	_onChangeSize: function (e) {
+		var size = e.target.value;
+		if (size === this.options.sizesInfo) {
+			return;
+		}
+		this._map.applyFontSize(size);
+	},
+
+	_updateSizeList: function (font) {
 		var container = this._sizeSelect;
 		for (var i = container.options.length - 1; i >= 0; i--) {
 			container.remove(i);
@@ -75,15 +88,6 @@ L.Control.Fonts = L.Control.extend({
 			item.value = size;
 			item.innerHTML = size;
 		});
-		this._map.applyFont(font);
-	},
-
-	_onChangeSize: function (e) {
-		var size = e.target.value;
-		if (size === this.options.sizesInfo) {
-			return;
-		}
-		this._map.applyFontSize(size);
 	},
 
 	_onStateChange: function (e) {
@@ -92,10 +96,22 @@ L.Control.Fonts = L.Control.extend({
 				var value = this._fontSelect[i].value;
 				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);
+			item.value = e.state;
+			item.innerHTML = e.state;
 			this._sizeSelect.value = e.state;
 		}
 	}


More information about the Libreoffice-commits mailing list