node-red/nodes/core/core/90-comment.html

82 lines
3.1 KiB
HTML
Raw Normal View History

2013-09-05 16:02:48 +02:00
<!--
Copyright JS Foundation and other contributors, http://js.foundation
2013-09-05 16:02:48 +02:00
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.
-->
<script type="text/x-red" data-template-name="comment">
<div class="form-row">
2015-05-28 00:07:31 +02:00
<label for="node-input-name"><i class="fa fa-comment"></i> <span data-i18n="comment.label.title"></span></label>
<input type="text" id="node-input-name">
</div>
2014-11-13 18:21:12 +01:00
<div class="form-row" style="margin-bottom: 0px;">
2015-05-28 00:07:31 +02:00
<label for="node-input-info" style="width: 100% !important;"><i class="fa fa-comments"></i> <span data-i18n="comment.label.body"></span></label>
2013-10-09 23:12:06 +02:00
<input type="hidden" id="node-input-info" autofocus="autofocus">
2014-11-13 18:21:12 +01:00
</div>
<div class="form-row node-text-editor-row">
<div style="height: 250px; min-height:150px;" class="node-text-editor" id="node-input-info-editor"></div>
</div>
2015-05-28 00:07:31 +02:00
<div class="form-tips" data-i18n="[html]comment.tip"></div>
2013-09-05 16:02:48 +02:00
</script>
<script type="text/x-red" data-help-name="comment">
<p>A node you can use to add comments to your flows.</p>
2013-09-05 16:02:48 +02:00
</script>
<script type="text/javascript">
RED.nodes.registerType('comment',{
category: 'function',
color:"#ffffff",
defaults: {
name: {value:""},
info: {value:""}
2013-09-05 16:02:48 +02:00
},
inputs:0,
outputs:0,
icon: "comment.png",
2013-09-05 16:02:48 +02:00
label: function() {
return this.name||"";
2013-09-05 16:02:48 +02:00
},
labelStyle: function() {
return this.name?"node_label_italic":"";
},
info: function() {
2015-07-14 00:21:03 +02:00
return (this.name?"# "+this.name+"\n":"")+(this.info||"");
},
oneditprepare: function() {
2015-02-13 01:15:07 +01:00
var that = this;
this.editor = RED.editor.createEditor({
id: 'node-input-info-editor',
mode: 'ace/mode/markdown',
value: $("#node-input-info").val()
});
this.editor.focus();
},
oneditsave: function() {
2015-02-13 01:15:07 +01:00
$("#node-input-info").val(this.editor.getValue());
delete this.editor;
2016-01-04 17:53:32 +01:00
},
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();
2013-09-05 16:02:48 +02:00
}
});
</script>