jsdialogs: added callback for color picker

Change-Id: I6457917a1e6a451568072f985c85bab021c38b47
This commit is contained in:
Szymon Kłos 2019-10-25 10:56:45 +02:00
parent b0403c7d45
commit e048f366ed
2 changed files with 11 additions and 2 deletions

View file

@ -9,7 +9,8 @@
L.ColorPicker = L.Class.extend({
options: {
selectedColor: '#CC0814',
noColorControl: true
noColorControl: true,
selectionCallback: function () {}
},
statics: {
@ -46,6 +47,7 @@ L.ColorPicker = L.Class.extend({
this._createBasicColorSelectionMark();
this._selectedColorElement = selectedColorSample;
this._selectedColor = this.options.selectedColor;
this._selectionCallback = this.options.selectionCallback;
this._initIndexes();
this._container = this._createControl();
this._initialized = true;
@ -233,6 +235,7 @@ L.ColorPicker = L.Class.extend({
this._selectedColor = '#' + this._getColorCode(this._selectedTintIndex, L.ColorPicker.TINT);
this._updateNoColorControl(false);
this._updateSelectedColorElement();
this._selectionCallback(this._getColorCode(this._selectedTintIndex, L.ColorPicker.TINT));
},
_updateSelectedSample: function (colorIndex, selectedColorIndex, colorType) {

View file

@ -732,11 +732,17 @@ L.Control.JSDialogBuilder = L.Control.extend({
var iconPath = builder._createIconPath(data.command);
var noColorControl = data.command !== '.uno:FontColor';
var callback = function(color) {
var command = data.command + '?Color:string=' + color;
builder.map.sendUnoCommand(command);
};
var colorPickerControl = new L.ColorPicker(
valueNode,
{
selectedColor: selectedColor,
noColorControl: noColorControl
noColorControl: noColorControl,
selectionCallback: callback
});
builder._colorPickers.push(colorPickerControl);