|
1 | 1 | <script type="text/javascript"> |
2 | 2 | // convert to i18 text |
3 | | - function c_(x) { |
| 3 | + function c_ui_tab(x) { |
4 | 4 | return RED._("node-red-dashboard/ui_tab:ui_tab."+x); |
5 | 5 | } |
6 | 6 |
|
7 | 7 | RED.nodes.registerType('ui_tab',{ |
8 | 8 | category: 'config', |
9 | 9 | defaults: { |
10 | | - name: {value: c_("label.home")}, |
| 10 | + name: {value: c_ui_tab("label.home")}, |
11 | 11 | icon: {value: 'dashboard'}, |
12 | | - order: {value: 0} |
| 12 | + order: {value: 0}, |
| 13 | + disabled: {value: false}, |
| 14 | + hidden: {value: false} |
13 | 15 | }, |
14 | 16 | paletteLabel: 'dashboard tab', |
15 | | - label: function() { return this.name || c_("label.tab"); }, |
| 17 | + label: function() { return this.name || c_ui_tab("label.tab"); }, |
16 | 18 | sort: function(A,B) { |
17 | 19 | return A.order - B.order; |
| 20 | + }, |
| 21 | + oneditprepare: function() { |
| 22 | + $("#node-config-input-disabled-btn").on("click", function(e) { |
| 23 | + var i = $(this).find("i"); |
| 24 | + var active = i.hasClass("fa-toggle-on"); |
| 25 | + var newCls = "fa fa-toggle-" + (active ? "off" : "on"); |
| 26 | + i.attr("class", newCls); |
| 27 | + $("#node-config-input-disabled").prop('checked',active); |
| 28 | + |
| 29 | + var newTxt = c_ui_tab(active ? "label.disabled" : "label.enabled"); |
| 30 | + $("#node-config-input-disabled-label").text(newTxt); |
| 31 | + |
| 32 | + var info = $("#node-config-input-disabled-info"); |
| 33 | + var done = active ? info.show() : info.hide(); |
| 34 | + }); |
| 35 | + if (this.disabled) { |
| 36 | + $("#node-config-input-disabled-btn").click(); |
| 37 | + } |
| 38 | + else { |
| 39 | + $("#node-config-input-disabled-label").text(c_ui_tab("label.enabled")); |
| 40 | + } |
| 41 | + |
| 42 | + $("#node-config-input-hidden-btn").on("click", function(e) { |
| 43 | + var i = $(this).find("i"); |
| 44 | + var active = i.hasClass("fa-toggle-on"); |
| 45 | + var newCls = "fa fa-toggle-" + (active ? "off" : "on"); |
| 46 | + i.attr("class", newCls); |
| 47 | + $("#node-config-input-hidden").prop('checked',active); |
| 48 | + |
| 49 | + var newTxt = c_ui_tab(active ? "label.hidden" : "label.visible"); |
| 50 | + $("#node-config-input-hidden-label").text(newTxt); |
| 51 | + |
| 52 | + var info = $("#node-config-input-hidden-info"); |
| 53 | + var done = active ? info.show() : info.hide(); |
| 54 | + }); |
| 55 | + if (this.hidden) { |
| 56 | + $("#node-config-input-hidden-btn").click(); |
| 57 | + } |
| 58 | + else { |
| 59 | + $("#node-config-input-hidden-label").text(c_ui_tab("label.visible")); |
| 60 | + } |
| 61 | + }, |
| 62 | + oneditsave: function() { |
| 63 | + this.disabled = $("#node-config-input-disabled").prop("checked"); |
| 64 | + this.hidden = $("#node-config-input-hidden").prop("checked"); |
18 | 65 | } |
19 | 66 | }); |
20 | 67 | </script> |
|
28 | 75 | <label for="node-config-input-icon"><i class="fa fa-file-image-o"></i> <span data-i18n="ui_tab.label.icon"></span></label> |
29 | 76 | <input type="text" id="node-config-input-icon"> |
30 | 77 | </div> |
| 78 | + <div class="form-row"> |
| 79 | + <label for="node-config-input-disabled-btn"><i class="fa fa-ban"></i> <span data-i18n="ui_tab.label.state"></span></label> |
| 80 | + <button id="node-config-input-disabled-btn" class="editor-button" style="width:100px; margin-right:6px;"><i class="fa fa-toggle-on"></i> <span id="node-config-input-disabled-label"></span></button> |
| 81 | + <input type="checkbox" id="node-config-input-disabled" style="display:none;"/> |
| 82 | + <span id="node-config-input-disabled-info" data-i18n="[html]ui_tab.info.disabled" style="display:none;"></span> |
| 83 | + </div> |
| 84 | + <div class="form-row"> |
| 85 | + <label for="node-config-input-hidden-btn"><i class="fa fa-eye-slash"></i> <span data-i18n="ui_tab.label.navmenu"></span></label> |
| 86 | + <button id="node-config-input-hidden-btn" class="editor-button" style="width:100px; margin-right:6px;"><i class="fa fa-toggle-on"></i> <span id="node-config-input-hidden-label"></span></button> |
| 87 | + <input type="checkbox" id="node-config-input-hidden" style="display:none;"/> |
| 88 | + <span id="node-config-input-hidden-info" data-i18n="[html]ui_tab.info.hidden" style="display:none;"></span> |
| 89 | + </div> |
31 | 90 | <div class="form-tips" data-i18n="[html]ui_tab.tip"></div> |
32 | 91 | </script> |
33 | 92 |
|
34 | 93 | <script type="text/x-red" data-help-name="ui_tab"> |
35 | 94 | <p>Tab configuration for Dashboard</p> |
| 95 | + <p><b>Disabled</b> pages are not included in the Dashboard app, and are therefore not functional. |
| 96 | + The tab name still appears in the Navigation Menu (unless it is also hidden). |
| 97 | + </p> |
| 98 | + <p><b>Hidden</b> pages are not listed in the Left-hand Navigation Menu. |
| 99 | + However, they are still active in the Dashboard, and can be shown by using a `ui_control` msg. |
| 100 | + </p> |
36 | 101 | <p>The <b>Icon</b> field can be either |
37 | 102 | <a href="https://design.google.com/icons/" target="_blank">Material Design icons</a> <i>(e.g. 'check', 'close')</i> |
38 | 103 | or <a href="https://fontawesome.com/v4.7.0/icons/" target="_blank">Font Awesome icons</a> <i>(e.g. 'fa-fire')</i>, |
|
0 commit comments