-
Notifications
You must be signed in to change notification settings - Fork 4
/
ui-button.html
110 lines (94 loc) · 4.15 KB
/
ui-button.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
<script type="text/x-red" data-template-name="ui_ui-button">
<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: Click, Disable, Enable, Hide, Show</span>
<input type="hidden" id="node-input-actionType">
</div>
<div class="form-row">
<label for="node-input-icon"><i class="fa fa-picture-o"></i> Icon</label>
<input type="text" id="node-input-icon" placeholder="optional icon ">
</div>
<div class="form-row">
<label for="node-input-label"><i class="fa fa-i-cursor"></i> Label</label>
<input type="text" id="node-input-label" placeholder="optional label">
</div>
<div class="form-row">
<label for="node-input-tooltip"><i class="fa fa-info-circle"></i> Tooltip</label>
<input type="text" id="node-input-tooltip" placeholder="optional tooltip">
</div>
<div class="form-row">
<label for="node-input-color"><i class="fa fa-tint"></i> Colour</label>
<input type="text" id="node-input-color" placeholder="optional text/icon color">
</div>
<div class="form-row">
<label for="node-input-bgcolor"><i class="fa fa-tint"></i> Background</label>
<input type="text" id="node-input-bgcolor" placeholder="optional background color">
</div>
<div class="form-row">
<label style="width:auto" for="node-input-passthru"><i class="fa fa-arrow-right"></i> If <code>msg</code> arrives on input, emulate a button click: </label>
<input type="checkbox" id="node-input-passthru" style="display:inline-block; width:auto; vertical-align:top;">
</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-button',{
category: 'ui',
color: 'rgb(176, 223, 227)',
defaults: {
action: { value: "click", required: true, validate: RED.validators.typedInput("actionType") },
actionType: { value: "str" },
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},
passthru: {value: false},
label: {value: 'button'},
tooltip: {value: ''},
color: {value: ''},
bgcolor: {value: ''},
icon: {value: ''}
},
inputs: 1,
outputs: 1,
icon: "button.png",
paletteLabel: 'button',
label: function () {
return this.name || "button";
},
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']
});
}
});
</script>