-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathui-light.html
88 lines (76 loc) · 3.19 KB
/
ui-light.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
<script type="text/x-red" data-template-name="ui_ui-light">
<div class="form-row">
<label for="node-input-group"><i class="fa fa-table"></i> Group</label>
<input type="text" id="node-input-group">
</div>
<div class="form-row">
<label><i class="fa fa-object-group"></i> Size</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>
<div class="form-row">
<label for="node-input-action"><i class="fa fa-tag"></i> Action</label>
<input type="text" id="node-input-action" placeholder="" style="width: 70%;">
<span style="display: block; padding-left: 106px; color: gray; font-size: x-small;">Available actions: Set, Hide, Show</span>
<input type="hidden" id="node-input-actionType">
</div>
<div class="form-row">
<label for="node-input-write"><i class="fa fa-pencil"></i> Color</label>
<input type="text" id="node-input-write" style="width:70%;" />
<input type="hidden" id="node-input-writeType">
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name">
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType('ui_ui-light',{
category: 'ui',
color: 'rgb(176, 223, 227)',
defaults: {
action: { value: "set", required: true, validate: RED.validators.typedInput("actionType") },
actionType: { value: "str" },
write: { value: "payload", required: false, validate: RED.validators.typedInput("writeType") },
writeType: { value: "msg" },
name: {value: ''},
group: {type: 'ui_group', required: true},
order: {value: 0},
width: {value: 0, validate: function(v) {
var width = v||0;
var currentGroup = $('#node-input-group').val()||this.group;
var groupNode = RED.nodes.node(currentGroup);
var valid = !groupNode || +width <= +groupNode.width;
$("#node-input-size").toggleClass("input-error",!valid);
return valid;
}
},
height: {value: 0},
},
inputs: 1,
outputs: 1,
icon: "light.png",
paletteLabel: 'light',
label: function () {
return this.name || "light";
},
oneditprepare: function() {
$("#node-input-size").elementSizer({
width: "#node-input-width",
height: "#node-input-height",
group: "#node-input-group"
});
$("#node-input-action").typedInput({
default: 'str',
typeField: $("#node-input-actionType"),
types: ['str', 'msg', 'flow', 'global', 'env']
});
$("#node-input-write").typedInput({
default: 'str',
typeField: $("#node-input-writeType"),
types: ['str', 'msg', 'flow', 'global', 'env']
});
}
});
</script>