c34d14c9135d7b0290bd48bfcc52015929d88304
[ccsdk/distribution.git] / dgbuilder / nodes / dge / dgemain / comment.html
1 <!--
2   Copyright 2013 IBM Corp.
3
4   Licensed under the Apache License, Version 2.0 (the "License");
5   you may not use this file except in compliance with the License.
6   You may obtain a copy of the License at
7
8   http://www.apache.org/licenses/LICENSE-2.0
9
10   Unless required by applicable law or agreed to in writing, software
11   distributed under the License is distributed on an "AS IS" BASIS,
12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   See the License for the specific language governing permissions and
14   limitations under the License.
15 -->
16
17 <script type="text/x-red" data-template-name="comment">
18     <div class="form-row">
19         <label for="node-input-name"><i class="fa fa-comment"></i> Comment</label>
20         <input type="text" id="node-input-name" placeholder="Comment">
21     </div>
22     <div class="form-row">
23         <label for="node-input-info" style="width: 100% !important;"><i class="fa fa-comments"></i> More</label>
24         <input type="hidden" id="node-input-info" autofocus="autofocus">
25         <div style="height: 250px;" class="node-text-editor" id="node-input-info-editor" ></div>
26         <input type="hidden" id="node-input-comments">
27     </div>
28     <div class="form-tips">Tip: this isn't meant for "War and Peace" - but useful notes can be kept here.</div>
29 </script>
30
31 <script type="text/x-red" data-help-name="comment">
32     <p>Simple comment block.</p>
33 </script>
34
35 <script type="text/javascript">
36     RED.nodes.registerType('comment',{
37         category: 'DGEmain',
38         color:"#ffffff",
39         defaults: {
40             name: {value:""},
41             info: {value:""},
42             comments:{value:""} 
43         },
44         inputs:0,
45         outputs:0,
46         icon: "comment.png",
47         label: function() {
48             return this.name||"";
49         },
50         labelStyle: function() {
51             return this.name?"node_label_italic":"";
52         },
53         oneditprepare: function() {
54             $( "#node-input-outputs" ).spinner({
55                 min:1
56             });
57
58              var comments = $( "#node-input-comments").val();
59              if(comments != null){
60                 comments = comments.trim();
61                 if(comments != ''){
62                         $("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>");
63                 }
64              }
65
66             function functionDialogResize(ev,ui) {
67                 $("#node-input-info-editor").css("height",(ui.size.height-235)+"px");
68             };
69             $( "#dialog" ).on("dialogresize", functionDialogResize);
70             $( "#dialog" ).one("dialogopen", function(ev) {
71                 var size = $( "#dialog" ).dialog('option','sizeCache-function');
72                 if (size) {
73                     functionDialogResize(null,{size:size});
74                 }
75             });
76             $( "#dialog" ).one("dialogclose", function(ev,ui) {
77                 var height = $( "#dialog" ).dialog('option','height');
78                 $( "#dialog" ).off("dialogresize",functionDialogResize);
79             });
80             var that = this;
81             require(["orion/editor/edit"], function(edit) {
82                 that.editor = edit({
83                     parent:document.getElementById('node-input-info-editor'),
84                     lang:"text",
85                     showLinesRuler:false,
86                     showFoldingRuler:false,
87                     contents: $("#node-input-info").val()
88                 });
89                 $("#node-input-name").focus();
90             });
91         },
92         oneditsave: function() {
93             $("#node-input-info").val(this.editor.getText());
94             delete this.editor;
95         }
96     });
97 </script>