-
Notifications
You must be signed in to change notification settings - Fork 1
/
validate.html
85 lines (81 loc) · 2.99 KB
/
validate.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
<script type="text/html" data-template-name="validate">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="validate.label.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]validate.label.name" style="max-width: 400px;"/>
</div>
<div class="form-row">
<label for="node-input-field"><i class="fa fa-ellipsis-h"></i> <span
data-i18n="validate.label.property"></span></label>
<input type="text" id="node-input-field" placeholder="payload" style="width: 70%; max-width: 400px;">
<input type="hidden" id="node-input-fieldType">
</div>
<input type="hidden" id="node-input-validate" autofocus="autofocus">
<label for="node-input-validate-editor">
<i class="fa fa-file-code-o"></i> <span data-i18n="validate.label.template"></span>
</label>
<div class="form-row node-text-editor-row">
<div style="height: 250px; min-height:150px;" class="node-text-editor" id="node-input-validate-editor"></div>
</div>
</script>
<script>
RED.nodes.registerType('validate', {
color: "rgb(255, 214, 252)",
category: 'advanced-function',
defaults: {
name: { value: "" },
field: { value: "payload", validate: RED.validators.typedInput("fieldType") },
validate: { value: "" },
fieldType: { value: 'msg' }
},
inputs: 1,
outputs: 2,
icon: "validate.png",
label: function () {
return this.name || this._("validate.label.title");;
},
labelStyle: function () {
return this.name ? "node_label_italic" : "";
},
oneditprepare: function () {
if (!this.field) {
this.field = 'payload';
$("#node-input-field").val("payload");
}
if (!this.fieldType) {
this.fieldType = 'msg';
}
$("#node-input-field").typedInput({
default: 'msg',
types: ['msg', 'flow', 'global'],
typeField: $("#node-input-fieldType")
});
$("#node-input-field").next(".red-ui-typedInput-container").css({ "width": "70%", "max-width": "400px" });
this.editor = RED.editor.createEditor({
id: 'node-input-validate-editor',
mode: 'ace/mode/json',
value: $("#node-input-validate").val()
});
this.editor.focus();
},
oneditsave: function () {
$("#node-input-validate").val(this.editor.getValue());
this.editor.destroy();
delete this.editor;
},
oneditcancel: function () {
this.editor.destroy();
delete this.editor;
},
oneditresize: function (size) {
var rows = $("#dialog-form>div:not(.node-text-editor-row)");
var height = $("#dialog-form").height();
for (var i = 0; i < rows.size(); i++) {
height -= $(rows[i]).outerHeight(true);
}
var editorRow = $("#dialog-form>div.node-text-editor-row");
height -= (parseInt(editorRow.css("marginTop")) + parseInt(editorRow.css("marginBottom")));
$(".node-text-editor").css("height", height + "px");
this.editor.resize();
}
});
</script>