-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathui-iro-color-picker.html
908 lines (877 loc) · 48.8 KB
/
ui-iro-color-picker.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
<!--
Copyright 2018, Seth350
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!--
***********************************************************************************
** My Little UI Node
** This is a template to help you create your very own ui node. This is meant as
** a quickstart template that will show you what code is required and what code
** and sections are free for you to change or make additions to.
**
***********************************************************************************
-->
<!--
***********************************************************************************
** !!REQUIRED!!
** The .html file must ALWAYS begin with
** <script type="text/javascript">
***********************************************************************************
-->
<script type="text/javascript">
iroOptionsState = [];
iroVisibilityOptions = {
'.node-input-option-component' : {
'picker' : ['.node-label-option-picker','.node-input-option-wheelAngle','.node-input-option-wheelLightness','.node-input-option-wheelDirection'],
'box' : ['.node-label-option-box','.node-input-option-boxHeight'],
'slider' : ['.node-label-option-type','.node-input-option-type',{}]
},
'.node-input-option-type' : {
'kelvin' : ['.node-input-option-minTemperature','.node-input-option-maxTemperature','.node-label-option-minmax']
}
};
function updateIroOptions(node) {
var options = $("#node-input-option-container").editableList('items');
function switchVisibility(option,classId,state) {
var done = [];
// debugger;
Object.keys(iroVisibilityOptions[classId]).forEach(element => {
iroVisibilityOptions[classId][element].forEach(classToSwitch => {
if (!done.includes(classToSwitch)) {
if (state) {
option.find(classToSwitch).show();
} else {
option.find(classToSwitch).hide();
}
done.push(classToSwitch);
}
});
});
}
function setIroOptionVisibility(index,option,classId,force = false) {
var component = option.find(classId);
if (force || component.val()!=iroOptionsState[index][classId]) {
Object.keys(iroVisibilityOptions[classId]).forEach(element => {
if (element!=component.val()) {
iroVisibilityOptions[classId][element].forEach(classToHide => {
option.find(classToHide).hide();
if (iroVisibilityOptions.hasOwnProperty(classToHide)) {
switchVisibility(option,classToHide,false);
}
})
} else {
iroVisibilityOptions[classId][element].forEach(classToShow => {option.find(classToShow).show()})
}
});
iroOptionsState[index][classId]=component.val();
}
}
options.each(function (i) {
var option = $(this);
setIroOptionVisibility(i,option,".node-input-option-type",true); // force update on children
setIroOptionVisibility(i,option,".node-input-option-component");
});
}
function iroResizeList () {
var height = $("#dialog-form").height();
var formRows = $("#dialog-form>div:not(#node-iro-config-tabs-content)");
for (let i=0; i<formRows.size(); i++) {
height -= $(formRows[i]).outerHeight(true);
}
// resize editableList
tabRows = $(`#iro-tab-config>div:not(.node-input-option-container-row)`);
for (let i=0; i<tabRows.size(); i++) {
height -= $(tabRows[i]).outerHeight(true);
}
$("#node-input-option-container").editableList('height',height-30);
}
//*********************************************************************************
// !!REQUIRED!!
// This line is where you will register your node with a name and configuration.
// Your name must be all lower-case letters and without spaces.
// Your name must also begin with "ui_", otherwise it will not show up in the
// dashboard tab under it's assigned group.
// Should you need a space, use a hypen ( - ) instead.
RED.nodes.registerType('ui_iro-color-picker',{
//*********************************************************************************
//*********************************************************************************
// !!!!!!!!!NOTE!!!!!!!!!
// The following lines will determine your node's configuration and parameters.
//
//*********************************************************************************
//*********************************************************************************
// !!REQUIRED!!
//
// Node Category
//
// The category value should be left as 'dashboard', it does not need to be changed.
category: 'dashboard',
//*********************************************************************************
//*********************************************************************************
// !!REQUIRED!!
//
// Node Color
//
// The color value determines what color your node will be in the flow editor.
// Typically, all UI Nodes are rgb( 63, 173, 181), but you can freely edit this if
// you prefer a different color.
// TODO what about the preferred colors (https://nodered.org/docs/creating-nodes/appearance#background-colour)?
// Please use the rgb format only.
color: 'rgb( 63, 173, 181)',
//*********************************************************************************
//*********************************************************************************
// !!!!!!!!!NOTE!!!!!!!!!
// In the following lines all the node properties are defined. For every property you
// can (optionally) specify a default value and whether the value is required or not.
// When the standard 'required' is not sufficient, a custom validator function can be added.
// Only properties in this 'defaults' list will be remembered in time.
//
// The first 5 properties are required in all ui nodes.
//
//*********************************************************************************
// !!REQUIRED!!
//
// Node Default Settings
//
defaults: {
//*********************************************************************************
//*********************************************************************************
// !!REQUIRED!!
//
// Node Group
//
// The group value should be left as {type: 'ui_group', required:true}
// There is no need to edit this line.
group: {type: 'ui_group', required:true},
//*********************************************************************************
//*********************************************************************************
// !!REQUIRED!!
//
// Node Order
//
// The order value should be left as {value: 0}
// There is no need to edit this line.
order: {value: 0},
//*********************************************************************************
//*********************************************************************************
// !!REQUIRED!!
//
// Node Width
//
// Sets the default width of your node and how wide it will appear on the dashboard.
// This setting is set from the Size setting in the node editor, within in the flow editor.
// There is no need to edit these lines.
width: {
value: 0,
validate: function(v) {
var valid = true
var width = v||0;
var currentGroup = $('#node-input-group').val()|| this.group;
var groupNode = RED.nodes.node(currentGroup);
valid = !groupNode || +width <= +groupNode.width;
$("#node-input-size").toggleClass("input-error",!valid);
return valid;
}},
//*********************************************************************************
//*********************************************************************************
// !!REQUIRED!!
//
// Node Height
//
// Sets the default height of your node and how tall it will appear on the dashboard.
// This setting is set from the Size setting in the node editor, within the flow editor.
// There is no need to edit this line.
height: {value: 0},
//*********************************************************************************
//*********************************************************************************
// !!REQUIRED!!
//
// Node Name
//
// Sets the default name of the node in the node editor.
// Typically, this is left as {value:''}, and gives the user the option to enter
// a name if they choose to do so.
// There is no need to edit this line.
name: {value: ''},
//*********************************************************************************
//*********************************************************************************
// !!!!!!!!!NOTE!!!!!!!!!
// Until here we have covered the required default values every ui node must have,
// and now we will start adding our own custom properties for our node.
// For instance, you may want to set a default text color or some other custom property.
// It is advised to specify a default value for as much properties as possible, to make sure
// that users can setup your node up quick and easy.
// Remember to place a comma at the end of each line of default values, except after the last line!
// For example:
// property1: {value: True}, <--comma
// property2: {value: 'black'}, <--comma
// property2: {value: ('2B' || NOT('2B')) } <--NO comma
// },
//
//********************************************************************************* BEGIN USER DEFINED DEFAULT VALUES
label: {value:''},
placement: {value: 'left'},
hAlign: {value: 'flex-start'},
vAlign: {value: 'flex-start'},
stateField: {value: 'payload'},
enableField: {value: 'enable'},
layoutDirection: {value:'vertical'},
widgetIndent: {
value: '3',
validate: function(v) {
var valid = true
var width = v||0;
var currentGroup = $('#node-input-group').val()|| this.group;
var groupNode = RED.nodes.node(currentGroup);
valid = !groupNode || +width <= +groupNode.width;
$("#node-input-sizeWidgetIndent").toggleClass("input-error",!valid);
return valid;
}},
buttonWidth: {
value: '2',
validate: function(v) {
var valid = true
var width = v||0;
var currentGroup = $('#node-input-group').val()|| this.group;
var groupNode = RED.nodes.node(currentGroup);
valid = !groupNode || +width <= +groupNode.width-((this.label!=='')?this.widgetIndent:0);
$("#node-input-sizeButtonWidth").toggleClass("input-error",!valid);
return valid;
}},
pickerType: {value: 'widget'},
popupWidth: {value: 0},
popupHeight: {value: 0},
pickerSize: {value: '100'},
backgroundDim: {value: '50'},
backgroundColor: {value: '#000000'},
backgroundVariable: {value: false},
components: {value: []},
format: {value: 'hex'},
outFormat: {value: 'rgb'},
dynOutput: {value: "input:end"},
outputConfirmed: {value: false},
outputLimit: {value: '10'},
passthru: {value: false},
topic: {value: 'topic', validate: (RED.validators.hasOwnProperty('typedInput')?RED.validators.typedInput('topicType'):function(v) { return true})},
topicType: {value: 'msg'},
iroColorValue: {value: '#FF0000'},
},
//********************************************************************************* END USER DEFINED DEFAULT VALUES
//*********************************************************************************
// !!REQUIRED!!
//
// Inputs & Outputs
//
// The default number of inputs (0or1) and outputs (0-n) are set here.
inputs:1,
outputs:1,
//*********************************************************************************
//*********************************************************************************
// !!REQUIRED!!
//
// Node Icon
//
// The default icon to display on your node in the flow editor. You may use any of
// the icons found here: (TODO: Verify path to icon files with team.)
icon: "iro-color.png",
//*********************************************************************************
//*********************************************************************************
// !!REQUIRED!!
//
// Node Name
//
// The name of your node as it would appear in the node selection side bar.
// Lowercase & spaces are only permitted here.
paletteLabel:"iro.js color",
//*********************************************************************************
// !!REQUIRED!!
//
// Node Label
//
// The default label that will be displayed on your node in the flow editor.
// Typically, set this to the same name of your node.
// Spaces are permitted.
label: function() {
return this.name || this.label || "iro-color-picker";
// return this.name || (~this.label.indexOf("{{") ? null : this.label) || "iro-color-picker";
},
labelStyle: function() {
return this.name?"node_label_italic":"";
},
//*********************************************************************************
//*********************************************************************************
// !!REQUIRED!!
//
// Node Edit Preparation
//
// While editing your node in the node editor within the flow editor, you may need
// to perform some functions to verify the proper settings and syntax have been set.
//
// TODO: Verify with team on what this actually does.
// Typically, you will not need to edit the oneditprepare.
// You must atleast have your oneditprepare as such:
// oneditprepare: function() {
// $("#node-input-size").elementSizer({
// width: "#node-input-width",
// height: "#node-input-height",
// group: "#node-input-group"
// });
// }
//
oneditprepare: function() {
var node = this;
$("#node-input-size").elementSizer({
width: "#node-input-width",
height: "#node-input-height",
group: "#node-input-group"
});
node.tabs = RED.tabs.create({
id: "node-iro-config-tabs",
onchange: function(tab) {
$("#node-iro-config-tabs-content").children().hide();
$("#" + tab.id).show();
if (tab.id==='iro-tab-config') iroResizeList();
}
});
node.tabs.addTab({
id: "iro-tab-general",
node: this,
label: this._("iro-color.label.general")
});
node.tabs.addTab({
id: "iro-tab-config",
node: this,
label: this._("iro-color.label.components")
});
$('#node-input-option-container')
.css('min-height','250px').css('min-width','400px')
.editableList({
sortable: true,
removable: true,
addButton: true,
addItem: function(row, index, data) {
iroOptionsState[index]={};
if (!data.hasOwnProperty('options')) data.options={};
$(`<div><span>${node._("iro-color.label.component")}</span></div>`).css('display','inline-block').css('width','80px').appendTo(row);
var component = $('<select/>', {
class: 'node-input-option-component',
style: "margin-left:5px; width:70%"
}).appendTo(row);
component.append($('<option></option>').val('picker').text(node._("iro-color.componentDropdown.component.0")));
component.append($('<option></option>').val('box').text(node._("iro-color.componentDropdown.component.1")));
component.append($('<option></option>').val('slider').text(node._("iro-color.componentDropdown.component.2")));
if (data.componentId) {
component.val(data.componentId);
}
$('<br>').appendTo(row);
$(`<div><span>${node._("iro-color.label.border")}</span></div>`).css('display','inline-block').css('width','80px').appendTo(row);
var borderColor = $('<input/>', {
class: 'node-input-option-borderColor',
type: 'color',
min: 0,
max: 20,
style: "margin-left:5px; width:20%;",
placeholder: ""
}).appendTo(row);
if (data.options.borderColor) {
borderColor.val(data.options.borderColor);
}
$(`<div><span>${node._("iro-color.label.width")}</span></div>`).css('display','inline-block').css('margin-left','5px').css('width','40px').appendTo(row);
var borderWidth = $('<input/>', {
class: 'node-input-option-borderWidth',
type: 'number',
min: 0,
max: 20,
style: "margin-left:5px; width:20%;",
placeholder: ""
}).appendTo(row);
$('<div><span> px</span></div>')
.css('display','inline-block')
.appendTo(row);
if (data.options.borderWidth) {
borderWidth.val(data.options.borderWidth);
}
//wheelLightness
$('<br>')
.addClass('node-label-option-picker')
.appendTo(row);
$(`<div><span>${node._("iro-color.label.lightness")}</span></div>`)
.addClass('node-label-option-picker')
.css('display','inline-block')
.css('width','35%')
.css('text-align','right')
.appendTo(row);
var wheelLightness = $('<select/>', {
class: 'node-input-option-wheelLightness',
style: "margin-left:5px; width:50%"
}).appendTo(row);
wheelLightness.append($('<option></option>').val('true').text(node._("iro-color.componentDropdown.lightness.0")));
wheelLightness.append($('<option></option>').val('false').text(node._("iro-color.componentDropdown.lightness.1")));
if (data.options.wheelLightness!==undefined) {
wheelLightness.val((data.options.wheelLightness) ? 'true' : 'false');
}
//wheelAngle
$('<br>')
.addClass('node-label-option-picker')
.appendTo(row);
$(`<div><span>${node._("iro-color.label.startingAngle")}</span></div>`)
.addClass('node-label-option-picker')
.css('display','inline-block')
.css('width','35%')
.css('text-align','right')
.appendTo(row);
var wheelAngle = $('<input/>', {
class: 'node-input-option-wheelAngle',
type: 'number',
min: 0,
max: 359,
style: "margin-left:5px; width:40%;",
placeholder: "0°"
}).appendTo(row);
$('<div><span> °</span></div>')
.addClass('node-label-option-picker')
.css('display','inline-block')
.appendTo(row);
if (data.options.wheelAngle) {
wheelAngle.val(data.options.wheelAngle);
}
//wheelDirection
$('<br>')
.addClass('node-label-option-picker')
.appendTo(row);
$(`<div><span>${node._("iro-color.label.direction")}</span></div>`)
.addClass('node-label-option-picker')
.css('display','inline-block')
.css('width','35%')
.css('text-align','right')
.appendTo(row);
var wheelDirection = $('<select/>', {
class: 'node-input-option-wheelDirection',
style: "margin-left:5px; width:50%"
}).appendTo(row);
wheelDirection.append($('<option></option>').val('anticlockwise').text(node._("iro-color.componentDropdown.direction.0")));
wheelDirection.append($('<option></option>').val('clockwise').text(node._("iro-color.componentDropdown.direction.1")));
if (data.options.wheelDirection) {
wheelDirection.val(data.options.wheelDirection);
}
//boxHeight
$('<br>')
.addClass('node-label-option-box')
.appendTo(row);
$(`<div><span>${node._("iro-color.label.boxHeight")}</span></div>`)
.addClass('node-label-option-box')
.css('display','inline-block')
.css('width','25%')
.css('text-align','right')
.appendTo(row);
var boxHeight = $('<input/>', {
class: 'node-input-option-boxHeight',
type: 'number',
min: 0,
max: 1000,
style: "margin-left:5px; width:40%;",
placeholder: "empty for square"
}).appendTo(row);
$('<div><span> px</span></div>')
.addClass('node-label-option-box')
.css('display','inline-block')
.appendTo(row);
if (data.options.boxHeight) {
boxHeight.val(data.options.boxHeight);
}
//sliderTypes
$('<br>')
.addClass('node-label-option-type')
.appendTo(row);
$(`<div><span>${node._("iro-color.label.sliderShows")}</span></div>`)
.addClass('node-label-option-type')
.css('display','inline-block')
.css('width','80px')
.appendTo(row);
var type = $('<select/>', {
class: 'node-input-option-type',
style: "margin-left:5px; width:70%;"
}).appendTo(row);
type.append($('<option></option>').val('hue').text(node._("iro-color.componentDropdown.slider.0")));
type.append($('<option></option>').val('saturation').text(node._("iro-color.componentDropdown.slider.1")));
type.append($('<option></option>').val('value').text(node._("iro-color.componentDropdown.slider.2")));
type.append($('<option></option>').val('red').text(node._("iro-color.componentDropdown.slider.3")));
type.append($('<option></option>').val('green').text(node._("iro-color.componentDropdown.slider.4")));
type.append($('<option></option>').val('blue').text(node._("iro-color.componentDropdown.slider.5")));
type.append($('<option></option>').val('alpha').text(node._("iro-color.componentDropdown.slider.6")));
type.append($('<option></option>').val('kelvin').text(node._("iro-color.componentDropdown.slider.7")));
if (data.options.sliderType) {
type.val(data.options.sliderType);
}
//slider min
$('<br>')
.addClass('node-label-option-minmax')
.appendTo(row);
$(`<div><span>${node._("iro-color.label.min")}</span></div>`)
.addClass('node-label-option-minmax')
.css('display','inline-block')
.css('width','25%')
.css('text-align','right')
.appendTo(row);
var min = $('<input/>', {
class: 'node-input-option-minTemperature',
type: 'number',
style: "margin-left:5px; width:40%;",
placeholder: " ° Kelvin"
}).appendTo(row);
if (!data.options.minTemperature) data.options.minTemperature = 3000;
min.val(data.options.minTemperature);
//slider max
$('<br>')
.addClass('node-label-option-minmax')
.appendTo(row);
$(`<div><span>${node._("iro-color.label.max")}</span></div>`)
.addClass('node-label-option-minmax')
.css('display','inline-block')
.css('width','25%')
.css('text-align','right')
.appendTo(row);
var max = $('<input/>', {
class: 'node-input-option-maxTemperature',
type: 'number',
style: "margin-left:5px; width:40%;",
placeholder: " ° Kelvin"
}).appendTo(row);
if (!data.options.maxTemperature) data.options.maxTemperature = 6000;
max.val(data.options.maxTemperature);
updateIroOptions(this);
}
});
$("#node-input-option-container").editableList('addItems', this.components);
$('#node-input-option-container').change(function(ev) {
updateIroOptions(this);
});
$('#node-input-topic').typedInput({
default: 'str',
typeField: $("#node-input-topicType"),
types: ['str','msg','flow','global']
});
$('#node-input-pickerType').change(function(ev) {
if ($('#node-input-pickerType').val().startsWith('popup')) {
$("#node-options-picker").show();
} else {
$("#node-options-picker").hide();
}
});
$('#node-input-dynOutput').change(function(ev) {
if ($('#node-input-dynOutput').val().startsWith('input:move')) {
$("#node-options-dynOutput").show();
} else {
$("#node-options-dynOutput").hide();
}
});
$('#node-input-outputConfirmed').change(function(ev) {
if ($('#node-input-outputConfirmed').is(':checked')) {
$("#node-options-dynOutputMin").show();
$("#node-options-dynOutputMax").hide();
} else {
$("#node-options-dynOutputMin").hide();
$("#node-options-dynOutputMax").show();
}
});
$('#node-input-outFormat').change(function(ev) {
if ($('#node-input-outFormat').val().startsWith('tuneable')) {
$("#node-options-outFormat-note").show();
} else {
$("#node-options-outFormat-note").hide();
}
});
$('#node-input-label').change(function(ev) {
if ($('#node-input-label').val().length>0) {
$("#node-options-label-options").show();
} else {
$("#node-options-label-options").hide();
}
});
$("#node-input-sizeWidgetIndent").elementSizer({
width: "#node-input-widgetIndent",
auto: true
});
$("#node-input-sizePopup").elementSizer({
width: "#node-input-popupWidth",
auto: true
});
$("#node-input-sizeButtonWidth").elementSizer({
width: "#node-input-buttonWidth",
auto: true
});
setTimeout(function() { node.tabs.resize();},0);
},
oneditsave: function() {
var components = $("#node-input-option-container").editableList('items');
var node = this;
node.components = [];
components.each(function (i) {
var slider = $(this);
var c = {options:{}};
c.componentId = slider.find(".node-input-option-component").val();
c.options.borderColor = slider.find(".node-input-option-borderColor").val();
c.options.borderWidth = Number(slider.find(".node-input-option-borderWidth").val());
if (c.options.borderWidth === NaN ) c.options.borderWidth=0;
switch (c.componentId) {
case "picker":
c.options.wheelLightness = (slider.find(".node-input-option-wheelLightness").val()==='true') ? true : false;
c.options.wheelAngle = Number(slider.find(".node-input-option-wheelAngle").val());
if (c.options.wheelAngle === NaN ) c.options.wheelAngle=0;
c.options.wheelDirection = slider.find(".node-input-option-wheelDirection").val();
break;
case "box":
c.options.boxHeight = Number(slider.find(".node-input-option-boxHeight").val());
if (c.options.boxHeight === NaN || c.options.boxHeight<10) c.options.boxHeight=null;
break;
case "slider":
c.options.sliderType = slider.find(".node-input-option-type").val();
if (c.options.sliderType === "kelvin") {
c.options.minTemperature = Number(slider.find(".node-input-option-minTemperature").val());
if (!c.options.minTemperature || c.options.minTemperature === NaN ) c.options.minTemperature=3000;
c.options.maxTemperature = Number(slider.find(".node-input-option-maxTemperature").val());
if (!c.options.maxTemperature || c.options.maxTemperature === NaN ) c.options.maxTemperature=6000;
}
break;
}
node.components.push(c);
});
node.outputs = 1;
},
oneditresize: function(size) {
iroResizeList();
}
});
</script>
<!--
***********************************************************************************
** The following section creates the content of your node's config screen (to visualize
** the node properties), which is displayed when you double click your node in the flow
** editor. The config screen contains both the required widgets (group dropdown, size
** selector, name text box) and widgets to visualise your own custom properties (see
** User Defined Default Values section above).
***********************************************************************************
-->
<!--
***********************************************************************************
** This section must begin with:
** It should be the same name that you are registering with Node-RED (see line #26).
***********************************************************************************
-->
<script type="text/html" data-template-name="ui_iro-color-picker">
<!--***************************************************************************
** !!REQUIRED!!
**
** Group Dropdown
**
** These lines of HTML code will define how the Group dropdown selector looks.
** It is best that this stays as it is so that it is the same across all of the
** nodes.
** There is no need to edit these lines.
*******************************************************************************-->
<div class="form-row" id="template-row-group">
<label for="node-input-group"><i class="fa fa-table"></i> <span data-i18n='iro-color.label.group'></span></label>
<input type="text" id="node-input-group">
</div>
<!--***************************************************************************-->
<!--***************************************************************************
** !!REQUIRED!!
**
** Size Selector
**
** The following lines will define how the Size Selector looks.
** It is best that this stays as it is so that it is the same across all of the
** nodes.
** There is no need to edit these lines.
*******************************************************************************-->
<div class="form-row" id="template-row-size">
<label><i class="fa fa-object-group"></i> <span data-i18n='iro-color.label.size'></span></label>
<input type="hidden" id="node-input-width">
<input type="hidden" id="node-input-height">
<button class="editor-button" id="node-input-size"></button>
</div>
<!--***************************************************************************
** !!!!!NOTE!!!!!
** The </br> tag will skip a line leaving a horizontal space. Use this to space
** out your confiuration inputs into groups. Still, it is totally your preference.
** The following </br> will seperate the Group dropdown and Size Selector from the
** rest of our configuration.
*******************************************************************************-->
<!--***************************************************************************
** </br>
** !!!!!!!!!NOTE!!!!!!!!!
**
** Html elements to visualise our own custom node properties.
**
** Here we will reference visualise the properties in the 'default' list (see lines #152 & #153):
** textColor & textLabel
** The id's of the html elements must EXACTLY match the names in the 'default' list, to make
** sure that the html elements are automatically linked to the values of the properties in the
** 'default' list. For example the html id 'node-input-textColor' is linked to property 'textColor'.
**
** A line like <label for="node-input-textColor"> simply defines a textual label for the html
** input element with the correspoding id: <input type="text" id="node-input-textColor">
**
** You may use any of the FontAwesome v4 icons, here: https://fontawesome.com/v4.7.0/icons/
**
** The input 'type' specifies which kind of data is allowed in the input element.
** For example type="color" means that the user can only enter color values (via a color picker).
** Check here for a full list: https://www.w3schools.com/tags/att_input_type.asp
******************************************************************************** BEGIN USER DEFINED DEFAULT INPUTS -->
<div class="form-row">
<ul style="min-width: 420px; margin-bottom: 20px;" id="node-iro-config-tabs"></ul>
</div>
<div id="node-iro-config-tabs-content" style="min-height: 170px;">
<div id="iro-tab-general" style="display:none">
<div class="form-row">
<label for="node-input-label"><i class="fa fa-i-cursor"></i> <span data-i18n='iro-color.label.label'></span></label>
<input type="text" style="width: 40%;" id="node-input-label"/>
<label for="node-input-widgetIndent" style="width: 20%;"><i class="fa fa-indent"></i> <span data-i18n='iro-color.label.indent'></span></label>
<input type="hidden" id="node-input-widgetIndent">
<button class="editor-button" id="node-input-sizeWidgetIndent"></button>
</div>
<div class="form-row" id="node-options-label-options" style="display:none">
<label for="node-input-placement"><i class="fa fa-exchange"></i> <span data-i18n='iro-color.label.placement'></span></label>
<select id="node-input-placement" style="width: 17%;">
<option value="left" data-i18n='iro-color.dropdown.placement.0'></option>
<option value="above" data-i18n='iro-color.dropdown.placement.1'></option>
</select>
<label for="node-input-hAlign" style="width: 23%;"> <i class="fa fa-th"></i> <span data-i18n='iro-color.label.align'></span></label>
<select id="node-input-hAlign" style="width: 16%;">
<option value="flex-start" data-i18n='iro-color.dropdown.hAlign.0'></option>
<option value="center" data-i18n='iro-color.dropdown.hAlign.1'></option>
<option value="flex-end" data-i18n='iro-color.dropdown.hAlign.2'></option>
</select>
<select id="node-input-vAlign" style="width: 16%;">
<option value="flex-start" data-i18n='iro-color.dropdown.vAlign.0'></option>
<option value="center" data-i18n='iro-color.dropdown.vAlign.1'></option>
<option value="flex-end" data-i18n='iro-color.dropdown.vAlign.2'></option>
</select>
</div>
<hr>
<div class="form-row">
<label for="node-input-iroColorValue"><i class="fa fa-circle-o-notch "></i> <span data-i18n='iro-color.label.initialColor'></span></label>
<input id="node-input-iroColorValue" type="color" style="width: 15%;"/>
</div>
<hr>
<div class="form-row">
<label for="node-input-pickerType"><i class="fa fa-tachometer"></i> <span data-i18n='iro-color.label.type'></span></label>
<select id="node-input-pickerType">
<option value="widget" data-i18n='iro-color.dropdown.type.0'></option>
<option value="popupCC" data-i18n='iro-color.dropdown.type.1'></option>
<option value="popupCG" data-i18n='iro-color.dropdown.type.2'></option>
<option value="popupCW" data-i18n='iro-color.dropdown.type.3'></option>
</select>
</div>
<div id="node-options-picker" style="display:none">
<div class="form-row">
<label for="node-input-sizePopup" style="padding-left: 25px; margin-right: -25px"><i class="fa fa-fa-object-group"></i> <span data-i18n='iro-color.label.popupSize'></span></label>
<input type="hidden" id="node-input-popupWidth">
<input type="hidden" id="node-input-popupHeight">
<button class="editor-button" id="node-input-sizePopup"></button>
<label for="node-input-pickerSize" style="padding-left: 10px; width:unset; padding-right: 10px;"><i class="fa fa-arrows-alt"></i> <span data-i18n='iro-color.label.width'></span></label>
<input id="node-input-pickerSize" type="number" min=10 max=500 step=10 style="width: 15%;"/>
<label for="node-input-pickerSize" style="width: 5%;"> <span data-i18n='iro-color.label.ofGroup'></label>
<label for="node-input-buttonWidth" style="width: 17%;"><i class="fa fa-mouse-pointer"></i> <span data-i18n='iro-color.label.button'></span></label>
<input type="hidden" id="node-input-buttonWidth"/>
<button class="editor-button" id="node-input-sizeButtonWidth"></button>
</div>
<div class="form-row">
<label for="node-input-backgroundColor" style="padding-left: 25px; margin-right: -25px"><i class="fa fa-circle-o-notch "></i> <span data-i18n='iro-color.label.color'></span></label>
<input id="node-input-backgroundColor" type="color" style="width: 15%;"/>
<input type="checkbox" checked id="node-input-backgroundVariable" style="display:inline-block; width:auto; vertical-align:middle;">
<label for="node-input-backgroundVariable" style="width: 20%;"> <span data-i18n='iro-color.label.picked'></span></label>
<label for="node-input-backgroundDim" style="width: 12%;"> <span data-i18n='iro-color.label.alpha'></span></label>
<input id="node-input-backgroundDim" type="number" min=0 max=100 step=1 style="width: 10%;"/>
<label for="node-input-backgroundDim" style="width: 5%;"> %</label>
</div>
</div>
<hr>
<div class="form-row">
<label style="width:auto" for="node-input-passthru"><i class="fa fa-arrow-right"></i> <span data-i18n='iro-color.label.passThru'></span></label>
<input type="checkbox" checked id="node-input-passthru" style="display:inline-block; width:auto; vertical-align:top;">
</div>
<div class="form-row">
<label for="node-input-dynOutput"><i class="fa fa-envelope-o"></i> <span data-i18n='iro-color.label.send'></label>
<select id="node-input-dynOutput" style="width:60%">
<option value="input:end" data-i18n='iro-color.dropdown.dynOutput.0'></option>
<option value="input:move" data-i18n='iro-color.dropdown.dynOutput.1'></option>
</select>
</div>
<div id="node-options-dynOutput" style="display:none">
<div class="form-row">
<label for="node-input-outputConfirmed" style="padding-left: 25px; margin-right: -25px"><i class="fa fa-play"></i> <span data-i18n='iro-color.label.send'></span></label>
<input type="checkbox" checked id="node-input-outputConfirmed" style="display:inline-block; width:auto; vertical-align:middle;">
<label style="width:auto" for="node-input-outputConfirmed"> <span data-i18n='iro-color.label.whenConfirmed'></span></label>
<label for="node-input-outputLimit" id="node-options-dynOutputMin" style="width: 15%; text-align: right; display:none;"><i class="fa fa-step-forward"></i> min</label>
<label for="node-input-outputLimit" id="node-options-dynOutputMax" style="width: 15%; text-align: right; display:none;"><i class="fa fa-step-forward"></i> max</label>
<input id="node-input-outputLimit" type="number" min=0 max=100 step=1 style="width: 10%;"/>
<label for="node-input-outputLimit"> msg/s</label>
</div>
</div>
<div class="form-row">
<label for="node-input-outFormat" style="padding-left: 25px; margin-right: -25px"><span data-i18n='iro-color.label.payload'></span></label>
<select id="node-input-outFormat" style="width:60%">
<option value="hexString" data-i18n='iro-color.dropdown.outFormat.0'></option>
<option value="hex8String" data-i18n='iro-color.dropdown.outFormat.1'></option>
<option value="rgbString" data-i18n='iro-color.dropdown.outFormat.2'></option>
<option value="rgbaString" data-i18n='iro-color.dropdown.outFormat.3'></option>
<option value="hslString" data-i18n='iro-color.dropdown.outFormat.4'></option>
<option value="hslaString" data-i18n='iro-color.dropdown.outFormat.5'></option>
<option value="rgb" data-i18n='iro-color.dropdown.outFormat.6'></option>
<option value="rgba" data-i18n='iro-color.dropdown.outFormat.7'></option>
<option value="hsl" data-i18n='iro-color.dropdown.outFormat.8'></option>
<option value="hsla" data-i18n='iro-color.dropdown.outFormat.9'></option>
<option value="hsv" data-i18n='iro-color.dropdown.outFormat.10'></option>
<option value="hsva" data-i18n='iro-color.dropdown.outFormat.11'></option>
<option value="red" data-i18n='iro-color.dropdown.outFormat.12'></option>
<option value="green" data-i18n='iro-color.dropdown.outFormat.13'></option>
<option value="blue" data-i18n='iro-color.dropdown.outFormat.14'></option>
<option value="alpha" data-i18n='iro-color.dropdown.outFormat.15'></option>
<option value="hue" data-i18n='iro-color.dropdown.outFormat.16'></option>
<option value="saturation" data-i18n='iro-color.dropdown.outFormat.17'></option>
<option value="value" data-i18n='iro-color.dropdown.outFormat.18'></option>
<option value="kelvin" data-i18n='iro-color.dropdown.outFormat.19'></option>
<option value="tuneable" data-i18n='iro-color.dropdown.outFormat.20'></option>
<option value="rgbw" data-i18n='iro-color.dropdown.outFormat.21'></option>
<option value="hsi" data-i18n='iro-color.dropdown.outFormat.22'></option>
</select>
</div>
<div class="form-row">
<label for="node-input-topic" style="padding-left: 25px; margin-right: -25px"><span data-i18n='iro-color.label.topic'></span></label>
<input type="text" id="node-input-topic" placeholder="optional topic">
<input type="hidden" id="node-input-topicType">
</div>
</br>
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> <span data-i18n='iro-color.label.name'></span></label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</br>
<div id="node-options-outFormat-note" class="form-tips" style="max-width: 450px; display:none; color:orangered">
<p><span data-i18n='iro-color.notes.tuneable'></p>
</div>
</div>
<div id="iro-tab-config" style="display:none">
<div class="form-row">
<label for="node-input-layoutDirection"><i class="fa fa-repeat"></i> <span data-i18n='iro-color.label.stacking'></span></label>
<select id="node-input-layoutDirection">
<option value="horizontal" data-i18n='iro-color.dropdown.layoutDirection.0'></option>
<option value="vertical" data-i18n='iro-color.dropdown.layoutDirection.1'></option>
</select>
</div>
<div class="form-row node-input-option-container-row">
<label for="node-input-option-container" style="vertical-align:top"><i class="fa fa-list-alt"></i> <span data-i18n='iro-color.label.options'></span></label>
<ol id="node-input-option-container"></ol>
</div>
</div>
</div>
</script>