Node-Red configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ui_text.html 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <script type="text/javascript">
  2. RED.nodes.registerType('ui_text',{
  3. category: RED._("node-red-dashboard/ui_base:ui_base.label.category"),
  4. color: 'rgb(119, 198, 204)',
  5. defaults: {
  6. group: {type: 'ui_group', required:true},
  7. order: {value: 0},
  8. width: {value: 0, validate: function(v) {
  9. var width = v||0;
  10. var currentGroup = $('#node-input-group').val()||this.group;
  11. var groupNode = RED.nodes.node(currentGroup);
  12. var valid = !groupNode || +width <= +groupNode.width;
  13. $("#node-input-size").toggleClass("input-error",!valid);
  14. return valid;
  15. }
  16. },
  17. height: {value: 0},
  18. name: {value: ''},
  19. label: {value: 'text'},
  20. format: {value: '{{msg.payload}}'},
  21. layout: {value:'row-spread'},
  22. className: {value: ''}
  23. },
  24. inputs:1,
  25. outputs:0,
  26. align: "right",
  27. icon: "ui_text.png",
  28. paletteLabel: 'text',
  29. label: function() { return this.name || (~this.label.indexOf("{{") ? null : this.label) || 'text'; },
  30. labelStyle: function() { return this.name?"node_label_italic":""; },
  31. oneditprepare: function() {
  32. $("#node-input-size").elementSizer({
  33. width: "#node-input-width",
  34. height: "#node-input-height",
  35. group: "#node-input-group"
  36. });
  37. $(".nr-db-text-layout-"+(this.layout||'row-spread')).addClass('selected');
  38. [ ".nr-db-text-layout-row-left",".nr-db-text-layout-row-center",".nr-db-text-layout-row-right",
  39. ".nr-db-text-layout-row-spread",".nr-db-text-layout-col-center"].forEach(function(id) {
  40. $(id).click(function(e) {
  41. $(".nr-db-text-layout").removeClass('selected');
  42. $(this).addClass('selected');
  43. $('#node-input-layout').val(id.substring(".nr-db-text-layout-".length));
  44. e.preventDefault();
  45. })
  46. })
  47. }
  48. });
  49. </script>
  50. <script type="text/html" data-template-name="ui_text">
  51. <div class="form-row">
  52. <label for="node-input-group"><i class="fa fa-table"></i> Group</label>
  53. <input type="text" id="node-input-group">
  54. </div>
  55. <div class="form-row">
  56. <label><i class="fa fa-object-group"></i> Size</label>
  57. <input type="hidden" id="node-input-width">
  58. <input type="hidden" id="node-input-height">
  59. <button class="editor-button" id="node-input-size"></button>
  60. </div>
  61. <div class="form-row">
  62. <label for="node-input-label"><i class="fa fa-i-cursor"></i> Label</label>
  63. <input type="text" id="node-input-label">
  64. </div>
  65. <div class="form-row">
  66. <label for="node-input-format"><i class="fa fa-i-cursor"></i> Value format</label>
  67. <input type="text" id="node-input-format" placeholder="{{msg.payload}}">
  68. </div>
  69. <div class="form-row">
  70. <label style="vertical-align: top"><i class="fa fa-th-large"></i> Layout</label>
  71. <div style="display:inline-block">
  72. <input type="hidden" id="node-input-layout"><input type="hidden" id="node-input-layoutAlign">
  73. <div>
  74. <a href="#" class="nr-db-text-layout nr-db-text-layout-row nr-db-text-layout-row-left">
  75. <span class="nr-db-text-layout-label">label</span>
  76. <span class="nr-db-text-layout-value">value</span>
  77. <div class="nr-db-text-layout-checkbox"></div>
  78. </a>
  79. <a href="#" class="nr-db-text-layout nr-db-text-layout-row nr-db-text-layout-row-center">
  80. <span class="nr-db-text-layout-label">label</span>
  81. <span class="nr-db-text-layout-value">value</span>
  82. <div class="nr-db-text-layout-checkbox"></div>
  83. </a>
  84. <a href="#" class="nr-db-text-layout nr-db-text-layout-row nr-db-text-layout-row-right">
  85. <span class="nr-db-text-layout-label">label</span>
  86. <span class="nr-db-text-layout-value">value</span>
  87. <div class="nr-db-text-layout-checkbox"></div>
  88. </a>
  89. </div>
  90. <div>
  91. <a href="#" class="nr-db-text-layout nr-db-text-layout-row nr-db-text-layout-row-spread">
  92. <span class="nr-db-text-layout-label">label</span>
  93. <span class="nr-db-text-layout-value">value</span>
  94. <div class="nr-db-text-layout-checkbox"></div>
  95. </a>
  96. <a href="#" class="nr-db-text-layout nr-db-text-layout-col nr-db-text-layout-col-center">
  97. <span class="nr-db-text-layout-label">label</span>
  98. <span class="nr-db-text-layout-value">value</span>
  99. <div class="nr-db-text-layout-checkbox"></div>
  100. </a>
  101. </div>
  102. </div>
  103. </div>
  104. <div class="form-row">
  105. <label for="node-input-className"><i class="fa fa-code"></i> Class</label>
  106. <input type="text" id="node-input-className" placeholder="Optional CSS class name(s) for widget"/>
  107. </div>
  108. <div class="form-row">
  109. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  110. <input type="text" id="node-input-name">
  111. </div>
  112. </script>
  113. <style>
  114. .nr-db-text-layout {
  115. position:relative;
  116. display: inline-block;
  117. width: 90px;
  118. height: 60px;
  119. border-radius:3px;
  120. border:1px solid #bbb;
  121. cursor:pointer;
  122. color: #666;
  123. margin-right: 10px;
  124. margin-bottom: 10px;
  125. }
  126. .nr-db-text-layout.selected, .nr-db-text-layout:hover {
  127. border-color: #333;
  128. color: #333;
  129. }
  130. .nr-db-text-layout span {
  131. position: absolute;
  132. }
  133. .nr-db-text-layout-value {
  134. font-weight: bold;
  135. }
  136. .nr-db-text-layout-row span { top: 20px; }
  137. .nr-db-text-layout-row-left .nr-db-text-layout-label { left: 2px; }
  138. .nr-db-text-layout-row-left .nr-db-text-layout-value { left: 34px; }
  139. .nr-db-text-layout-row-spread .nr-db-text-layout-label { left: 2px; }
  140. .nr-db-text-layout-row-spread .nr-db-text-layout-value { right: 2px; }
  141. .nr-db-text-layout-row-center .nr-db-text-layout-label { left: 11px; }
  142. .nr-db-text-layout-row-center .nr-db-text-layout-value { right: 11px; }
  143. .nr-db-text-layout-row-right .nr-db-text-layout-label { right: 40px; }
  144. .nr-db-text-layout-row-right .nr-db-text-layout-value { right: 2px; }
  145. .nr-db-text-layout-col span { width: 90px; text-align: center; left: 0px;}
  146. .nr-db-text-layout-col-center .nr-db-text-layout-label { top: 12px; }
  147. .nr-db-text-layout-col-center .nr-db-text-layout-value { top: 26px; }
  148. .nr-db-text-layout-checkbox {
  149. display: none;
  150. width: 10px;
  151. height: 10px;
  152. border-radius: 10px;
  153. border: 1px solid #bbb;
  154. position: absolute;
  155. right: -5px;
  156. top: -5px;
  157. background: #fff;
  158. }
  159. .nr-db-text-layout.selected .nr-db-text-layout-checkbox {
  160. display:inline-block;
  161. box-shadow: inset 0px 0px 0px 2px #fff;
  162. background: #333;
  163. border-color: #333;
  164. }
  165. </style>