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

Mihai Varga mihai.varga at collabora.com
Mon Sep 14 10:15:43 PDT 2015


 loleaflet/README                        |    1 +
 loleaflet/src/control/Control.Fonts.js  |   15 +++++++++++++++
 loleaflet/src/control/Control.Styles.js |   13 +++++++++++++
 3 files changed, 29 insertions(+)

New commits:
commit 5fa9c364c88403db7848b917a7e7c92291502960
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Mon Sep 14 20:14:28 2015 +0300

    loleaflet: font / style feedback

diff --git a/loleaflet/README b/loleaflet/README
index 1ef0296..7fb7291 100644
--- a/loleaflet/README
+++ b/loleaflet/README
@@ -88,6 +88,7 @@ Buttons like Bold, Italic, Strike through etc.
         map.on('commandstatechanged', function (e) {}) where:
             + e.unoCmd == 'Bold' | 'Italic' etc.
             + e.state = 'true' | 'false'
+            + e.state = fontName | fontSize | styleName
 
 Parts (like slides in presentation, or sheets in spreadsheets):
     - API:
diff --git a/loleaflet/src/control/Control.Fonts.js b/loleaflet/src/control/Control.Fonts.js
index b341a4f..0712878 100644
--- a/loleaflet/src/control/Control.Fonts.js
+++ b/loleaflet/src/control/Control.Fonts.js
@@ -17,6 +17,7 @@ L.Control.Fonts = L.Control.extend({
 
 		map.on('updatepermission', this._onUpdatePermission, this);
 		map.on('updatetoolbarcommandvalues', this._initList, this);
+		map.on('commandstatechanged', this._onStateChange, this);
 		L.DomEvent.on(this._fontSelect, 'change', this._onChangeFont, this);
 		L.DomEvent.on(this._sizeSelect, 'change', this._onChangeSize, this);
 
@@ -83,6 +84,20 @@ L.Control.Fonts = L.Control.extend({
 			return;
 		}
 		this._map.applyFontSize(size);
+	},
+
+	_onStateChange: function (e) {
+		if (e.unoCmd === 'CharFontName') {
+			for (var i = 0; i < this._fontSelect.length; i++) {
+				var value = this._fontSelect[i].value;
+				if (value && value.toLowerCase() == e.state.toLowerCase()) {
+					this._fontSelect.value = value;
+				}
+			}
+		}
+		else if (e.unoCmd === 'FontHeight') {
+			this._sizeSelect.value = e.state;
+		}
 	}
 });
 
diff --git a/loleaflet/src/control/Control.Styles.js b/loleaflet/src/control/Control.Styles.js
index cfc4133..fac3bd0 100644
--- a/loleaflet/src/control/Control.Styles.js
+++ b/loleaflet/src/control/Control.Styles.js
@@ -13,6 +13,7 @@ L.Control.Styles = L.Control.extend({
 
 		map.on('updatepermission', this._onUpdatePermission, this);
 		map.on('updatetoolbarcommandvalues', this._initList, this);
+		map.on('commandstatechanged', this._onStateChange, this);
 		L.DomEvent.on(this._container, 'change', this._onChange, this);
 
 		return this._container;
@@ -64,6 +65,18 @@ L.Control.Styles = L.Control.extend({
 		else if (this._map.getDocType() === 'presentation') {
 			this._map.applyStyle(style, 'Default');
 		}
+	},
+
+	_onStateChange: function (e) {
+		if (e.unoCmd === 'StyleApply') {
+			// Fix 'Text Body' vs 'Text body'
+			for (var i = 0; i < this._container.length; i++) {
+				var value = this._container[i].value;
+				if (value && value.toLowerCase() == e.state.toLowerCase()) {
+					this._container.value = value;
+				}
+			}
+		}
 	}
 });
 


More information about the Libreoffice-commits mailing list