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

Mihai Varga mihai.varga at collabora.com
Tue Sep 15 01:56:56 PDT 2015


 loleaflet/README                          |    4 +--
 loleaflet/spec/loleaflet/loleafletSpec.js |    2 -
 loleaflet/src/control/Control.Buttons.js  |   36 +++++++++++++++---------------
 loleaflet/src/control/Control.Fonts.js    |   12 +++++-----
 loleaflet/src/control/Control.Styles.js   |    4 +--
 loleaflet/src/layer/tile/TileLayer.js     |   13 ++++++----
 6 files changed, 37 insertions(+), 34 deletions(-)

New commits:
commit d6652930fd255d1bce6a1f6514e9d3ca63325b19
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Tue Sep 15 11:56:32 2015 +0300

    loleaflet: fixed js lint errors

diff --git a/loleaflet/src/control/Control.Buttons.js b/loleaflet/src/control/Control.Buttons.js
index 93668d4..eaacf6d 100644
--- a/loleaflet/src/control/Control.Buttons.js
+++ b/loleaflet/src/control/Control.Buttons.js
@@ -12,22 +12,22 @@ L.Control.Buttons = L.Control.extend({
 		    container = L.DomUtil.create('div', buttonsName + '-container' + ' leaflet-bar');
 
 		this._buttons = {
-			'bold':          {title: 'Bold',               uno: 'Bold',            iconName: 'bold.png'},
-			'italic':        {title: 'Italic',             uno: 'Italic',          iconName: 'italic.png'},
-			'underline':     {title: 'Underline',          uno: 'Underline',       iconName: 'underline.png'},
-			'strikethrough': {title: 'Strike-through',     uno: 'Strikeout',       iconName: 'strikethrough.png'},
-			'bullet'       : {title: 'Bullets ON/OFF',     uno: 'DefaultBullet',   iconName: 'defaultbullet.png'},
-			'numbering'    : {title: 'Numbering ON/OFF',   uno: 'DefaultNumbering',iconName: 'defaultnumbering.png'},
-			'alignleft':     {title: 'Align left',         uno: 'LeftPara',        iconName: 'alignleft.png'},
-			'aligncenter':   {title: 'Center horizontaly', uno: 'CenterPara',      iconName: 'aligncenter.png'},
-			'alignright':    {title: 'Align right',        uno: 'RightPara',       iconName: 'alignright.png'},
-			'alignblock':    {title: 'Justified',          uno: 'JustifyPara',     iconName: 'alignblock.png'},
-			'incindent':     {title: 'Increment indent',   uno: 'IncrementIndent', iconName: 'incrementindent.png'},
-			'decindent':     {title: 'Decrement indent',   uno: 'DecrementIndent', iconName: 'decrementindent.png'},
-			'save':          {title: 'Save',               uno: 'Save',            iconName: 'save.png'},
-			'saveas':        {title: 'Save As',                                    iconName: 'saveas.png'},
-			'edit':          {title: 'Enable editing',                             iconName: 'edit.png'},
-			'selection':     {title: 'Enable selection',                           iconName: 'selection.png'}
+			'bold':          {title: 'Bold',               uno: 'Bold',             iconName: 'bold.png'},
+			'italic':        {title: 'Italic',             uno: 'Italic',           iconName: 'italic.png'},
+			'underline':     {title: 'Underline',          uno: 'Underline',        iconName: 'underline.png'},
+			'strikethrough': {title: 'Strike-through',     uno: 'Strikeout',        iconName: 'strikethrough.png'},
+			'bullet'       : {title: 'Bullets ON/OFF',     uno: 'DefaultBullet',    iconName: 'defaultbullet.png'},
+			'numbering'    : {title: 'Numbering ON/OFF',   uno: 'DefaultNumbering', iconName: 'defaultnumbering.png'},
+			'alignleft':     {title: 'Align left',         uno: 'LeftPara',         iconName: 'alignleft.png'},
+			'aligncenter':   {title: 'Center horizontaly', uno: 'CenterPara',       iconName: 'aligncenter.png'},
+			'alignright':    {title: 'Align right',        uno: 'RightPara',        iconName: 'alignright.png'},
+			'alignblock':    {title: 'Justified',          uno: 'JustifyPara',      iconName: 'alignblock.png'},
+			'incindent':     {title: 'Increment indent',   uno: 'IncrementIndent',  iconName: 'incrementindent.png'},
+			'decindent':     {title: 'Decrement indent',   uno: 'DecrementIndent',  iconName: 'decrementindent.png'},
+			'save':          {title: 'Save',               uno: 'Save',             iconName: 'save.png'},
+			'saveas':        {title: 'Save As',                                     iconName: 'saveas.png'},
+			'edit':          {title: 'Enable editing',                              iconName: 'edit.png'},
+			'selection':     {title: 'Enable selection',                            iconName: 'selection.png'}
 		};
 		for (var key in this._buttons) {
 			var button = this._buttons[key];
diff --git a/loleaflet/src/control/Control.Fonts.js b/loleaflet/src/control/Control.Fonts.js
index 180d30f..a07c166 100644
--- a/loleaflet/src/control/Control.Fonts.js
+++ b/loleaflet/src/control/Control.Fonts.js
@@ -35,11 +35,11 @@ L.Control.Fonts = L.Control.extend({
 			var first = L.DomUtil.create('option', '', container);
 			first.innerHTML = this.options.fontsInfo;
 			var fonts = e.commandValues;
-			for (font in fonts) {
+			for (var font in fonts) {
 				var item = L.DomUtil.create('option', '', container);
 				item.value = font;
 				item.innerHTML = font;
-			};
+			}
 
 			// Don't show any font sizes yet
 			first = L.DomUtil.create('option', '', this._sizeSelect);
@@ -64,7 +64,7 @@ L.Control.Fonts = L.Control.extend({
 			return;
 		}
 		var container = this._sizeSelect;
-		for(var i = container.options.length - 1; i >= 0; i--) {
+		for (var i = container.options.length - 1; i >= 0; i--) {
 			container.remove(i);
 		}
 		var first = L.DomUtil.create('option', '', container);
@@ -90,7 +90,7 @@ L.Control.Fonts = L.Control.extend({
 		if (e.commandName === '.uno:CharFontName') {
 			for (var i = 0; i < this._fontSelect.length; i++) {
 				var value = this._fontSelect[i].value;
-				if (value && value.toLowerCase() == e.state.toLowerCase()) {
+				if (value && value.toLowerCase() === e.state.toLowerCase()) {
 					this._fontSelect.value = value;
 				}
 			}
diff --git a/loleaflet/src/control/Control.Styles.js b/loleaflet/src/control/Control.Styles.js
index 1645b26..b95f25c 100644
--- a/loleaflet/src/control/Control.Styles.js
+++ b/loleaflet/src/control/Control.Styles.js
@@ -72,7 +72,7 @@ L.Control.Styles = L.Control.extend({
 			// 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()) {
+				if (value && value.toLowerCase() === e.state.toLowerCase()) {
 					this._container.value = value;
 				}
 			}
commit bc72dcc32959e856a6e5eff6d318a9294b5a29a9
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Tue Sep 15 11:52:55 2015 +0300

    loleaflet: renamed unoCmd to commandName

diff --git a/loleaflet/README b/loleaflet/README
index 7fb7291..dade690 100644
--- a/loleaflet/README
+++ b/loleaflet/README
@@ -81,12 +81,12 @@ Edit, view, readOnly:
 
 Buttons like Bold, Italic, Strike through etc.
     - API:
-        map.toggleCommandState('Bold' | 'Italic' | 'Underline' | 'Strikeout' |
+        map.toggleCommandState('.uno:' + 'Bold' | 'Italic' | 'Underline' | 'Strikeout' |
             'LeftPara' | 'CenterPara' | 'RightPara' | 'JustifyPara' |
             'IncrementIndent' | 'DecrementIndent'
     - events:
         map.on('commandstatechanged', function (e) {}) where:
-            + e.unoCmd == 'Bold' | 'Italic' etc.
+            + e.commandName == '.uno:' + 'Bold' | 'Italic' | 'StyleApply' | 'CharFontName' | 'FontHeight' etc.
             + e.state = 'true' | 'false'
             + e.state = fontName | fontSize | styleName
 
diff --git a/loleaflet/spec/loleaflet/loleafletSpec.js b/loleaflet/spec/loleaflet/loleafletSpec.js
index f575693..4fbff63 100644
--- a/loleaflet/spec/loleaflet/loleafletSpec.js
+++ b/loleaflet/spec/loleaflet/loleafletSpec.js
@@ -79,7 +79,7 @@ describe('TileBench', function () {
 
 		it('Make a word Bold', function (done) {
 			map.once('commandstatechanged', function (e) {
-				expect(e.unoCmd).to.be('Bold');
+				expect(e.commandName).to.be('.uno:Bold');
 				expect(e.state).to.be('false');
 				done();
 			});
diff --git a/loleaflet/src/control/Control.Buttons.js b/loleaflet/src/control/Control.Buttons.js
index 01d1c69..93668d4 100644
--- a/loleaflet/src/control/Control.Buttons.js
+++ b/loleaflet/src/control/Control.Buttons.js
@@ -95,11 +95,11 @@ L.Control.Buttons = L.Control.extend({
 	},
 
 	_onStateChange: function (e) {
-		var unoCmd = e.unoCmd;
+		var commandName = e.commandName;
 		var state = e.state;
 		for (var key in this._buttons) {
 			var button = this._buttons[key];
-			if (button.uno === unoCmd) {
+			if ('.uno:' + button.uno === commandName) {
 				if (state === 'true') {
 					L.DomUtil.addClass(button.el.firstChild, 'leaflet-control-buttons-active');
 				}
diff --git a/loleaflet/src/control/Control.Fonts.js b/loleaflet/src/control/Control.Fonts.js
index 0712878..180d30f 100644
--- a/loleaflet/src/control/Control.Fonts.js
+++ b/loleaflet/src/control/Control.Fonts.js
@@ -87,7 +87,7 @@ L.Control.Fonts = L.Control.extend({
 	},
 
 	_onStateChange: function (e) {
-		if (e.unoCmd === 'CharFontName') {
+		if (e.commandName === '.uno:CharFontName') {
 			for (var i = 0; i < this._fontSelect.length; i++) {
 				var value = this._fontSelect[i].value;
 				if (value && value.toLowerCase() == e.state.toLowerCase()) {
@@ -95,7 +95,7 @@ L.Control.Fonts = L.Control.extend({
 				}
 			}
 		}
-		else if (e.unoCmd === 'FontHeight') {
+		else if (e.commandName === '.uno:FontHeight') {
 			this._sizeSelect.value = e.state;
 		}
 	}
diff --git a/loleaflet/src/control/Control.Styles.js b/loleaflet/src/control/Control.Styles.js
index fac3bd0..1645b26 100644
--- a/loleaflet/src/control/Control.Styles.js
+++ b/loleaflet/src/control/Control.Styles.js
@@ -68,7 +68,7 @@ L.Control.Styles = L.Control.extend({
 	},
 
 	_onStateChange: function (e) {
-		if (e.unoCmd === 'StyleApply') {
+		if (e.commandName === '.uno:StyleApply') {
 			// Fix 'Text Body' vs 'Text body'
 			for (var i = 0; i < this._container.length; i++) {
 				var value = this._container[i].value;
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index bd22086..89f4ed8 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -291,11 +291,14 @@ L.TileLayer = L.GridLayer.extend({
 	},
 
 	_onStateChangedMsg: function (textMsg) {
-		var unoMsg = textMsg.substr(14);
-		var unoCmd = unoMsg.match('.uno:(.*)=')[1];
-		var state = unoMsg.match('.*=(.*)')[1];
-		if (unoCmd && state) {
-			this._map.fire('commandstatechanged', {unoCmd : unoCmd, state : state});
+		var unoMsg = textMsg.substr(14).split('=');
+		if (unoMsg.length < 2) {
+			return;
+		}
+		var commandName = unoMsg[0];
+		var state = unoMsg[1];
+		if (commandName && state) {
+			this._map.fire('commandstatechanged', {commandName : commandName, state : state});
 		}
 	},
 


More information about the Libreoffice-commits mailing list