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_colour_picker.html 7.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <script type="text/javascript">
  2. RED.nodes.registerType('ui_colour_picker',{
  3. category: RED._("node-red-dashboard/ui_base:ui_base.label.category"),
  4. color: 'rgb(176, 223, 227)',
  5. defaults: {
  6. name: {value: ''},
  7. label: {value: ''},
  8. group: {type: 'ui_group', required: true},
  9. format: {value: 'hex'},
  10. outformat: {value: 'string'},
  11. showSwatch: {value: true},
  12. showPicker: {value: false},
  13. showValue: {value: false},
  14. showHue: {value: false},
  15. showAlpha: {value: false},
  16. showLightness: {value: true},
  17. square: {value: "false"},
  18. dynOutput: {value: "false"},
  19. order: {value: 0},
  20. width: {value: 0, validate: function(v) {
  21. var width = v||0;
  22. var currentGroup = $('#node-input-group').val()||this.group;
  23. var groupNode = RED.nodes.node(currentGroup);
  24. var valid = !groupNode || +width <= +groupNode.width;
  25. $("#node-input-size").toggleClass("input-error",!valid);
  26. return valid;
  27. }
  28. },
  29. height: {value: 0},
  30. passthru: {value: true},
  31. topic: {value: 'topic', validate: (RED.validators.hasOwnProperty('typedInput')?RED.validators.typedInput('topicType'):function(v) { return true})},
  32. topicType: {value: 'msg'},
  33. className: {value: ''}
  34. },
  35. inputs:1,
  36. outputs:1,
  37. outputLabels: function() { return this.format; },
  38. icon: "ui_colour_picker.png",
  39. paletteLabel: 'colour picker',
  40. label: function() { return this.name || (~this.label.indexOf("{{") ? null : this.label) || 'colour picker'; },
  41. labelStyle: function() { return this.name?"node_label_italic":""; },
  42. oneditprepare: function() {
  43. if (this.square === undefined) {
  44. this.square = "false";
  45. $("#node-input-square").val("false");
  46. }
  47. $("#node-input-square").on("change", function() {
  48. if ($("#node-input-square").val() === "false") {
  49. $("#node-input-showLightness").prop('checked', true);
  50. $("#node-input-showHue").prop('checked', false);
  51. }
  52. else {
  53. $("#node-input-showLightness").prop('checked', false);
  54. $("#node-input-showHue").prop('checked', true);
  55. }
  56. });
  57. $("#node-input-size").elementSizer({
  58. width: "#node-input-width",
  59. height: "#node-input-height",
  60. group: "#node-input-group"
  61. });
  62. $("#node-input-format").on("change", function() {
  63. if ($(this).val() === "hex") {
  64. $("#node-alpha-control").hide();
  65. }
  66. else {
  67. $("#node-alpha-control").show();
  68. }
  69. });
  70. $('#node-input-topic').typedInput({
  71. default: 'str',
  72. typeField: $("#node-input-topicType"),
  73. types: ['str','msg','flow','global']
  74. });
  75. },
  76. oneditsave: function() {
  77. if (!$("#node-input-showPicker").is(':checked') && !$("#node-input-showValue").is(':checked')) {
  78. $("#node-input-showSwatch").prop('checked', true);
  79. this.showSwatch = true;
  80. }
  81. }
  82. });
  83. </script>
  84. <script type="text/html" data-template-name="ui_colour_picker">
  85. <div class="form-row">
  86. <label for="node-input-group"><i class="fa fa-table"></i> Group</label>
  87. <input type="text" id="node-input-group">
  88. </div>
  89. <div class="form-row">
  90. <label><i class="fa fa-object-group"></i> Size</label>
  91. <input type="hidden" id="node-input-width">
  92. <input type="hidden" id="node-input-height">
  93. <button class="editor-button" id="node-input-size"></button>
  94. </div>
  95. <div class="form-row">
  96. <label for="node-input-label"><i class="fa fa-i-cursor"></i> Label</label>
  97. <input type="text" id="node-input-label">
  98. </div>
  99. <div class="form-row">
  100. <label for="node-input-format"><i class="fa fa-keyboard-o"></i> Format</label>
  101. <select id="node-input-format" style="width:156px;">
  102. <option value="hex">hex</option>
  103. <option value="hex8">hex8</option>
  104. <option value="hsl">hsl</option>
  105. <option value="hsv">hsv</option>
  106. <option value="rgb">rgb</option>
  107. </select>
  108. <select id="node-input-square" style="width:130px; margin-left:30px">
  109. <option value="false">round</option>
  110. <option value="true">square</option>
  111. </select>
  112. </div>
  113. <div class="form-row">
  114. <label>&nbsp;</label> Show hue slider : <input type="checkbox" id="node-input-showHue" style="display:inline-block; width:auto; vertical-align:baseline;">
  115. <br/>
  116. <label>&nbsp;</label> Show lightness slider : <input type="checkbox" id="node-input-showLightness" style="display:inline-block; width:auto; vertical-align:baseline;">
  117. <br/>
  118. <span id="node-alpha-control"><label>&nbsp;</label> Show transparency slider : <input type="checkbox" id="node-input-showAlpha" style="display:inline-block; width:auto; vertical-align:baseline;"></span>
  119. </div>
  120. <div class="form-row">
  121. If width is 4 or greater:<br/>
  122. <label>&nbsp;</label>
  123. Always show swatch : <input type="checkbox" checked id="node-input-showSwatch" style="display:inline-block; width:auto; vertical-align:top;">
  124. <br/>
  125. <label>&nbsp;</label>
  126. Always show picker : <input type="checkbox" checked id="node-input-showPicker" style="display:inline-block; width:auto; vertical-align:top;">
  127. <br/>
  128. <label>&nbsp;</label>
  129. Always show value field : <input type="checkbox" checked id="node-input-showValue" style="display:inline-block; width:auto; vertical-align:top;">
  130. </div>
  131. <div class="form-row">
  132. <label style="width:auto" for="node-input-passthru"><i class="fa fa-arrow-right"></i> If <code>msg</code> arrives on input, pass through to output: </label>
  133. <input type="checkbox" checked id="node-input-passthru" style="display:inline-block; width:auto; vertical-align:top;">
  134. </div>
  135. <div class="form-row">
  136. <label for="node-input-dynOutput"><i class="fa fa-envelope-o"></i> Send</label>
  137. <select id="node-input-dynOutput" style="width:60%">
  138. <option value="false">one value when released/closed</option>
  139. <option value="true">multiple values during editing</option>
  140. </select>
  141. </div>
  142. <div class="form-row">
  143. <label for="node-input-outformat" style="padding-left: 25px; margin-right: -25px">Payload</label>
  144. <select id="node-input-outformat" style="width:60%">
  145. <option value="string">current value as a string</option>
  146. <option value="object">current value as an object</option>
  147. </select>
  148. </div>
  149. <div class="form-row">
  150. <label for="node-input-topic" style="padding-left: 25px; margin-right: -25px">Topic</label>
  151. <input type="text" id="node-input-topic" placeholder="optional topic">
  152. <input type="hidden" id="node-input-topicType">
  153. </div>
  154. <div class="form-row">
  155. <label for="node-input-className"><i class="fa fa-code"></i> Class</label>
  156. <input type="text" id="node-input-className" placeholder="Optional CSS class name(s) for widget"/>
  157. </div>
  158. <div class="form-row">
  159. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  160. <input type="text" id="node-input-name">
  161. </div>
  162. </script>