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

2015-09-14 Thread Mihai Varga
 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 
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;
+   }
+   }
+   }
}
 });
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2015-08-11 Thread Mihai Varga
 loleaflet/README|4 +++-
 loleaflet/src/control/Control.Dialog.js |9 -
 loleaflet/src/layer/tile/TileLayer.js   |9 -
 3 files changed, 19 insertions(+), 3 deletions(-)

New commits:
commit 396efe4806f8bd5300bd6bb13328c7f7c6b75a85
Author: Mihai Varga mihai.va...@collabora.com
Date:   Tue Aug 11 11:37:26 2015 +0300

loleaflet: parse the error cmd before firing the error event

diff --git a/loleaflet/README b/loleaflet/README
index 2b35a9e..2b1c2f8 100644
--- a/loleaflet/README
+++ b/loleaflet/README
@@ -158,7 +158,9 @@ Writer pages:
 Error:
 - events
 map.on('error', function (e) {}) where
-+ e.msg = a message describing the error
++ [e.msg] = a message describing the error
++ [e.cmd] = the command that caused the error
++ [e.kind] = the kind of error
 
 Contributing
 
diff --git a/loleaflet/src/control/Control.Dialog.js 
b/loleaflet/src/control/Control.Dialog.js
index 98a6b48..31f9654 100644
--- a/loleaflet/src/control/Control.Dialog.js
+++ b/loleaflet/src/control/Control.Dialog.js
@@ -9,7 +9,14 @@ L.Control.Dialog = L.Control.extend({
},
 
_onError: function (e) {
-   vex.dialog.alert(e.msg);
+   if (e.msg) {
+   vex.dialog.alert(e.msg);
+   }
+   else if (e.cmd  e.kind) {
+   var msg = 'The server encountered a \'' + e.kind + '\' 
error while' +
+   ' parsing the \'' + e.cmd + '\' 
command.';
+   vex.dialog.alert(msg);
+   }
}
 });
 
diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index f85b3d2..a7b0d4a 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -509,7 +509,8 @@ L.TileLayer = L.GridLayer.extend({
this._map.fire('searchnotfound');
}
else if (textMsg.startsWith('error:')) {
-   this._map.fire('error', {msg: textMsg.substring(7)});
+   command = this._parseServerCmd(textMsg);
+   this._map.fire('error', {cmd: command.errorCmd, kind: 
command.errorKind});
}
},
 
@@ -578,6 +579,12 @@ L.TileLayer = L.GridLayer.extend({
else if (tokens[i].substring(0, 9) === 'prefetch=') {
command.preFetch = tokens[i].substring(9);
}
+   else if (tokens[i].substring(0, 4) === 'cmd=') {
+   command.errorCmd = tokens[i].substring(4);
+   }
+   else if (tokens[i].substring(0, 5) === 'kind=') {
+   command.errorKind= tokens[i].substring(5);
+   }
}
if (command.tileWidth  command.tileHeight) {
var scale = command.tileWidth / 
this.options.tileWidthTwips;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits