[Libreoffice-commits] online.git: loleaflet/src
Szymon Kłos (via logerrit)
logerrit at kemper.freedesktop.org
Tue Nov 5 15:42:09 UTC 2019
loleaflet/src/control/ColorPicker.js | 2 +
loleaflet/src/control/Control.JSDialogBuilder.js | 32 +++++++++++++++++++++--
2 files changed, 32 insertions(+), 2 deletions(-)
New commits:
commit dacfda2b1a2b43e9f91dea3d93e2025317a2920b
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Tue Nov 5 16:33:51 2019 +0100
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Tue Nov 5 16:41:46 2019 +0100
jsdialogs: set current value for color picker
It works for font color and highlight now.
Change-Id: I253483eabe567b32f48bf47fbb8489e07d0f3a52
diff --git a/loleaflet/src/control/ColorPicker.js b/loleaflet/src/control/ColorPicker.js
index 9f1ea0e42..0ba1ba2cd 100644
--- a/loleaflet/src/control/ColorPicker.js
+++ b/loleaflet/src/control/ColorPicker.js
@@ -75,6 +75,8 @@ L.ColorPicker = L.Class.extend({
_initIndexes: function () {
for (var i = 0; i < this._getBasicColorCount(); ++i) {
var tintSet = this._getTintSet(i);
+ if (!tintSet)
+ return;
for (var j = 0; j < tintSet.length; ++j) {
var tint = tintSet[j];
if (tint === this._selectedColor) {
diff --git a/loleaflet/src/control/Control.JSDialogBuilder.js b/loleaflet/src/control/Control.JSDialogBuilder.js
index 82549d346..0dff47ae3 100644
--- a/loleaflet/src/control/Control.JSDialogBuilder.js
+++ b/loleaflet/src/control/Control.JSDialogBuilder.js
@@ -723,11 +723,40 @@ L.Control.JSDialogBuilder = L.Control.extend({
return false;
},
+ _getDefaultColorForCommand: function(command) {
+ if (command == '.uno:BackColor')
+ return '#';
+ else if (command == '.uno:CharBackColor')
+ return '#';
+ else if (command == '.uno:BackgroundColor')
+ return '#';
+ return 0;
+ },
+
+ _getCurrentColor: function(data, builder) {
+ var selectedColor = parseInt(builder.map['stateChangeHandler'].getItemValue(data.command));
+
+ if (!selectedColor || selectedColor < 0)
+ selectedColor = builder._getDefaultColorForCommand(data.command);
+
+ selectedColor = selectedColor.toString(16);
+
+ while (selectedColor != '#' && selectedColor.length < 6) {
+ selectedColor = '0' + selectedColor;
+ }
+
+ if (selectedColor[0] != '#')
+ selectedColor = '#' + selectedColor;
+
+ return selectedColor;
+ },
+
_colorControl: function(parentContainer, data, builder) {
var title = data.text;
title = builder._cleanText(title);
- var selectedColor = L.ColorPicker.BASIC_COLORS[1];
+ var selectedColor = builder._getCurrentColor(data, builder);
+
var valueNode = L.DomUtil.create('div', 'color-sample-selected', null);
valueNode.style.backgroundColor = selectedColor;
@@ -736,7 +765,6 @@ L.Control.JSDialogBuilder = L.Control.extend({
var callback = function(color) {
var command = data.command + '?Color:string=' + color;
- console.log(command);
builder.map.sendUnoCommand(command);
};
More information about the Libreoffice-commits
mailing list