iobroker.vis2-materialdesign 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +198 -0
  3. package/admin/admin.d.ts +93 -0
  4. package/admin/i18n/de.json +985 -0
  5. package/admin/i18n/en.json +985 -0
  6. package/admin/i18n/es.json +985 -0
  7. package/admin/i18n/fr.json +985 -0
  8. package/admin/i18n/it.json +985 -0
  9. package/admin/i18n/nl.json +985 -0
  10. package/admin/i18n/pl.json +985 -0
  11. package/admin/i18n/pt.json +985 -0
  12. package/admin/i18n/ru.json +985 -0
  13. package/admin/i18n/uk.json +985 -0
  14. package/admin/i18n/zh-cn.json +985 -0
  15. package/admin/img/info-big.png +0 -0
  16. package/admin/index_m.html +456 -0
  17. package/admin/index_m.js +1018 -0
  18. package/admin/lib/clipboard-polyfill.promise.js +16 -0
  19. package/admin/lib/colors.json +1304 -0
  20. package/admin/lib/colorsDark.json +1304 -0
  21. package/admin/lib/defaultcolors.json +22 -0
  22. package/admin/lib/defaultcolorsDark.json +22 -0
  23. package/admin/lib/defaultfontSizes.json +14 -0
  24. package/admin/lib/defaultfonts.json +14 -0
  25. package/admin/lib/fontSizes.json +380 -0
  26. package/admin/lib/fonts.json +386 -0
  27. package/admin/lib/monolith.min.css +1 -0
  28. package/admin/lib/pickr.min.js +5 -0
  29. package/admin/materialdesign-widgets-click-sound.mp3 +0 -0
  30. package/admin/style.css +31 -0
  31. package/admin/tsconfig.json +9 -0
  32. package/admin/vis-materialdesign.png +0 -0
  33. package/admin/vis-materialdesign_16_9.png +0 -0
  34. package/admin/words.js +11949 -0
  35. package/io-package.json +184 -0
  36. package/package.json +71 -0
  37. package/widgets/materialdesign/css/widgets.css +7174 -0
  38. package/widgets/materialdesign/css/widgets.min.css +1 -0
  39. package/widgets/materialdesign/img/IoBroker_Logo.png +0 -0
  40. package/widgets/materialdesign/img/bar_chart.png +0 -0
  41. package/widgets/materialdesign/img/calendar.png +0 -0
  42. package/widgets/materialdesign/img/pie_chart.png +0 -0
  43. package/widgets/materialdesign/img/prev_alerts.png +0 -0
  44. package/widgets/materialdesign/img/prev_autocomplete.png +0 -0
  45. package/widgets/materialdesign/img/prev_color_schemes.png +0 -0
  46. package/widgets/materialdesign/img/prev_dialog_view.png +0 -0
  47. package/widgets/materialdesign/img/prev_grid_views.png +0 -0
  48. package/widgets/materialdesign/img/prev_icon.png +0 -0
  49. package/widgets/materialdesign/img/prev_iconlist.png +0 -0
  50. package/widgets/materialdesign/img/prev_input.png +0 -0
  51. package/widgets/materialdesign/img/prev_json_chart.png +0 -0
  52. package/widgets/materialdesign/img/prev_line_history_chart.png +0 -0
  53. package/widgets/materialdesign/img/prev_list.png +0 -0
  54. package/widgets/materialdesign/img/prev_masonry_views.png +0 -0
  55. package/widgets/materialdesign/img/prev_select_bool.png +0 -0
  56. package/widgets/materialdesign/img/prev_select_value.png +0 -0
  57. package/widgets/materialdesign/img/prev_table.png +0 -0
  58. package/widgets/materialdesign/img/prev_top_app_bar_nav_drawer.png +0 -0
  59. package/widgets/materialdesign/img/prev_version.png +0 -0
  60. package/widgets/materialdesign/img/preview.jpg +0 -0
  61. package/widgets/materialdesign/js/materialdesign.js +56 -0
  62. package/widgets/materialdesign/js/widgets/materialdesign.00.helper.js +1229 -0
  63. package/widgets/materialdesign/js/widgets/materialdesign.00.vue.helper.js +710 -0
  64. package/widgets/materialdesign/js/widgets/materialdesign.alerts.js +177 -0
  65. package/widgets/materialdesign/js/widgets/materialdesign.autocomplete.js +263 -0
  66. package/widgets/materialdesign/js/widgets/materialdesign.button.js +1617 -0
  67. package/widgets/materialdesign/js/widgets/materialdesign.calendar.js +472 -0
  68. package/widgets/materialdesign/js/widgets/materialdesign.card.js +276 -0
  69. package/widgets/materialdesign/js/widgets/materialdesign.chart.bar.js +389 -0
  70. package/widgets/materialdesign/js/widgets/materialdesign.chart.helper.js +494 -0
  71. package/widgets/materialdesign/js/widgets/materialdesign.chart.json.js +621 -0
  72. package/widgets/materialdesign/js/widgets/materialdesign.chart.line.js +552 -0
  73. package/widgets/materialdesign/js/widgets/materialdesign.chart.pie.js +380 -0
  74. package/widgets/materialdesign/js/widgets/materialdesign.checkbox.js +281 -0
  75. package/widgets/materialdesign/js/widgets/materialdesign.colorschemes.js +129 -0
  76. package/widgets/materialdesign/js/widgets/materialdesign.dialog.js +384 -0
  77. package/widgets/materialdesign/js/widgets/materialdesign.iconList.js +873 -0
  78. package/widgets/materialdesign/js/widgets/materialdesign.list.js +503 -0
  79. package/widgets/materialdesign/js/widgets/materialdesign.materialdesignicons.js +7055 -0
  80. package/widgets/materialdesign/js/widgets/materialdesign.progress.js +413 -0
  81. package/widgets/materialdesign/js/widgets/materialdesign.roundslider.js +267 -0
  82. package/widgets/materialdesign/js/widgets/materialdesign.select.js +243 -0
  83. package/widgets/materialdesign/js/widgets/materialdesign.slider.js +363 -0
  84. package/widgets/materialdesign/js/widgets/materialdesign.switch.js +284 -0
  85. package/widgets/materialdesign/js/widgets/materialdesign.table.js +688 -0
  86. package/widgets/materialdesign/js/widgets/materialdesign.textfield.js +260 -0
  87. package/widgets/materialdesign/js/widgets/materialdesign.topappbarnav.js +747 -0
  88. package/widgets/materialdesign/js/widgets/materialdesign.value.js +369 -0
  89. package/widgets/materialdesign/js/widgets/materialdesign.views.js +827 -0
  90. package/widgets/materialdesign/js/widgets/materialdesign.viseditor.js +1088 -0
  91. package/widgets/materialdesign/js/widgets.min.js +1 -0
  92. package/widgets/materialdesign/lib/Chart.css +47 -0
  93. package/widgets/materialdesign/lib/Chart.js +16151 -0
  94. package/widgets/materialdesign/lib/VueTheMask.umd.js +556 -0
  95. package/widgets/materialdesign/lib/chartjs-plugin-datalabels.js +1385 -0
  96. package/widgets/materialdesign/lib/chroma.js +3225 -0
  97. package/widgets/materialdesign/lib/fonts/material-design-icons/materialdesignicons-webfont.ttf +0 -0
  98. package/widgets/materialdesign/lib/fonts/material-design-icons/materialdesignicons.css +27457 -0
  99. package/widgets/materialdesign/lib/fonts/material-design-icons/materialdesignicons.min.css +1 -0
  100. package/widgets/materialdesign/lib/fonts/material-icons/MaterialIcons-Regular.ttf +0 -0
  101. package/widgets/materialdesign/lib/fonts/material-icons/material-icons.css +31 -0
  102. package/widgets/materialdesign/lib/he.js +345 -0
  103. package/widgets/materialdesign/lib/jquery.initialize.js +156 -0
  104. package/widgets/materialdesign/lib/jquery.knob.js +820 -0
  105. package/widgets/materialdesign/lib/jquery.mobile-events.js +940 -0
  106. package/widgets/materialdesign/lib/material-components-web.css +10011 -0
  107. package/widgets/materialdesign/lib/material-components-web.js +22651 -0
  108. package/widgets/materialdesign/lib/math.js +41 -0
  109. package/widgets/materialdesign/lib/moment-duration-format.js +1737 -0
  110. package/widgets/materialdesign/lib/myUnderscore.js +1695 -0
  111. package/widgets/materialdesign/lib/raw/moment-with-locales.min.js +28 -0
  112. package/widgets/materialdesign/lib/raw/round-slider.js +271 -0
  113. package/widgets/materialdesign/lib/raw/sentry/bundle.min.js +3 -0
  114. package/widgets/materialdesign/lib/raw/sentry/captureconsole.min.js +2 -0
  115. package/widgets/materialdesign/lib/raw/sentry/dedupe.min.js +2 -0
  116. package/widgets/materialdesign/lib/svg-inject.js +697 -0
  117. package/widgets/materialdesign/lib/vue.js +11965 -0
  118. package/widgets/materialdesign/lib/vuetify.js +43729 -0
  119. package/widgets/materialdesign/lib.min.css +1 -0
  120. package/widgets/materialdesign/lib.min.js +6285 -0
  121. package/widgets/materialdesign.html +1063 -0
  122. package/widgets/vis2-materialdesign/assets/MaterialDesignButtonAdition-BOasvewn.js +1 -0
  123. package/widgets/vis2-materialdesign/assets/MaterialDesignButtonAditionVertical-CfxLrjtz.js +1 -0
  124. package/widgets/vis2-materialdesign/assets/MaterialDesignButtonLink-DFOHalVe.js +1 -0
  125. package/widgets/vis2-materialdesign/assets/MaterialDesignButtonLinkVertical-bLBc2Zj6.js +1 -0
  126. package/widgets/vis2-materialdesign/assets/MaterialDesignButtonNavigation-loocTeHA.js +1 -0
  127. package/widgets/vis2-materialdesign/assets/MaterialDesignButtonNavigationVertical-wKivh3mz.js +1 -0
  128. package/widgets/vis2-materialdesign/assets/MaterialDesignButtonState-DyuzNIZY.js +1 -0
  129. package/widgets/vis2-materialdesign/assets/MaterialDesignButtonStateMulti-D9YVumU3.js +1 -0
  130. package/widgets/vis2-materialdesign/assets/MaterialDesignButtonStateMultiVertical-J7SUuXNA.js +1 -0
  131. package/widgets/vis2-materialdesign/assets/MaterialDesignButtonStateVertical-EhVri-Bj.js +1 -0
  132. package/widgets/vis2-materialdesign/assets/MaterialDesignButtonToggle-CLxaT9SA.js +1 -0
  133. package/widgets/vis2-materialdesign/assets/MaterialDesignButtonToggleVertical-4zI4T-cI.js +1 -0
  134. package/widgets/vis2-materialdesign/assets/MaterialDesignButtons-BHDA55zY.js +1 -0
  135. package/widgets/vis2-materialdesign/assets/MaterialDesignCheckbox-Dwl43BB6.js +1 -0
  136. package/widgets/vis2-materialdesign/assets/MaterialDesignIcon-07Jl1QSv.js +1 -0
  137. package/widgets/vis2-materialdesign/assets/MaterialDesignIconButtonAdition-DkyLUAuu.js +1 -0
  138. package/widgets/vis2-materialdesign/assets/MaterialDesignIconButtonLink-CFh_41FT.js +1 -0
  139. package/widgets/vis2-materialdesign/assets/MaterialDesignIconButtonNavigation-CLvhcORZ.js +1 -0
  140. package/widgets/vis2-materialdesign/assets/MaterialDesignIconButtonSlider-TfUJKNib.js +1 -0
  141. package/widgets/vis2-materialdesign/assets/MaterialDesignIconButtonState-Con_l2iN.js +1 -0
  142. package/widgets/vis2-materialdesign/assets/MaterialDesignIconButtonStateMulti-DuakGd7h.js +1 -0
  143. package/widgets/vis2-materialdesign/assets/MaterialDesignIconButtonToggle-B3Yxo-Ii.js +1 -0
  144. package/widgets/vis2-materialdesign/assets/MaterialDesignSwitch-BPSYRrDe.js +1 -0
  145. package/widgets/vis2-materialdesign/assets/MaterialDesignValue-D5sJ-iyi.js +1 -0
  146. package/widgets/vis2-materialdesign/assets/_virtual_mf-localSharedImportMap___mfe_internal__vis2MaterialDesignWidgets-BFI0756z.js +1 -0
  147. package/widgets/vis2-materialdesign/assets/_virtual_mf___mfe_internal__vis2MaterialDesignWidgets__loadShare__react__loadShare__.js-4V-ZaKyJ.js +1 -0
  148. package/widgets/vis2-materialdesign/assets/_virtual_mf___mfe_internal__vis2MaterialDesignWidgets__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.js-Eu2aWCKd.js +1 -0
  149. package/widgets/vis2-materialdesign/assets/_virtual_mf___mfe_internal__vis2MaterialDesignWidgets__loadShare__react_mf_2_dom__loadShare__.js-D3wyrTEe.js +8 -0
  150. package/widgets/vis2-materialdesign/assets/hostInit-CP4jqDxy.js +1 -0
  151. package/widgets/vis2-materialdesign/assets/index-jMDUG1V1.js +1 -0
  152. package/widgets/vis2-materialdesign/assets/mf-entry-bootstrap-0-5bdbe7bd.js +35 -0
  153. package/widgets/vis2-materialdesign/assets/rolldown-runtime-CNC7AqOf.js +1 -0
  154. package/widgets/vis2-materialdesign/assets/translations-CYT3A7CQ.js +1 -0
  155. package/widgets/vis2-materialdesign/assets/virtualExposes-BFTZrXtp.js +1 -0
  156. package/widgets/vis2-materialdesign/assets/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__vis2MaterialDesignWidgets__customWidgets_js-BOvf1QCd.js +4 -0
  157. package/widgets/vis2-materialdesign/assets/virtual_mf-exposes-ssr___mfe_internal__vis2MaterialDesignWidgets__customWidgets_js-vY7qHvFF.js +2 -0
  158. package/widgets/vis2-materialdesign/assets/virtual_mf-exposes___mfe_internal__vis2MaterialDesignWidgets__customWidgets_js-C28iDRsy.js +2 -0
  159. package/widgets/vis2-materialdesign/assets/vite-preload-helper-DuG8C5Si.js +1 -0
  160. package/widgets/vis2-materialdesign/assets/widgetUtils-D_-xivaB.js +1 -0
  161. package/widgets/vis2-materialdesign/customWidgets.js +1 -0
  162. package/widgets/vis2-materialdesign/customWidgets.ssr.js +1 -0
  163. package/widgets/vis2-materialdesign/materialdesign-widgets-click-sound.mp3 +0 -0
  164. package/widgets/vis2-materialdesign/mf-stats.json +1 -0
@@ -0,0 +1,1617 @@
1
+ /*
2
+ ioBroker.vis vis-materialdesign Widget-Set
3
+
4
+ Copyright 2019 Scrounger scrounger@gmx.net
5
+ */
6
+ "use strict";
7
+
8
+ vis.binds.materialdesign.button = {
9
+ types: {
10
+ navigation: {
11
+ default: 'navigation_default',
12
+ vertical: 'navigation_vertical',
13
+ icon: 'navigation_icon'
14
+ },
15
+ link: {
16
+ default: 'link_default',
17
+ vertical: 'link_vertical',
18
+ icon: 'link_icon'
19
+ },
20
+ state: {
21
+ default: 'state_default',
22
+ vertical: 'state_vertical',
23
+ icon: 'state_icon'
24
+ },
25
+ multiState: {
26
+ default: 'multiState_default',
27
+ vertical: 'multiState_vertical',
28
+ icon: 'multiState_icon'
29
+ },
30
+ addition: {
31
+ default: 'addition_default',
32
+ vertical: 'addition_vertical',
33
+ icon: 'addition_icon'
34
+ },
35
+ toggle: {
36
+ default: 'toggle_default',
37
+ vertical: 'toggle_vertical',
38
+ icon: 'toggle_icon'
39
+ },
40
+ slider: {
41
+ icon: 'slider_icon'
42
+ }
43
+ },
44
+ initialize: function (el, data, type) {
45
+ let widgetName = 'Button';
46
+
47
+ if (type.includes('icon')) {
48
+ widgetName = 'Icon Button';
49
+ }
50
+
51
+ try {
52
+ let $this = $(el);
53
+ let containerClass = 'materialdesign-button-body';
54
+
55
+ myMdwHelper.subscribeThemesAtRuntime(data, widgetName);
56
+
57
+ vis.binds.materialdesign.button.useTheme(el, data, type, widgetName);
58
+
59
+ $this.addClass(data.buttonStyle !== 'text' ? 'materialdesign-button--' + data.buttonStyle : '');
60
+
61
+ if (type.includes('vertical')) {
62
+ $this.append(vis.binds.materialdesign.button.initializeVerticalButton($this, data, type));
63
+ } else if (type.includes('default')) {
64
+ $this.append(vis.binds.materialdesign.button.initializeButton($this, data, type));
65
+ } else if (type.includes('icon')) {
66
+ $this.append(vis.binds.materialdesign.button.initializeButton($this, data, type, true));
67
+ }
68
+
69
+ myMdwHelper.waitForElement($this, `.${containerClass}`, data.wid, widgetName, function () {
70
+ if (type.includes('navigation')) {
71
+ vis.binds.materialdesign.button.handleNavigation(el, data, type.includes('icon'));
72
+ } else if (type.includes('link')) {
73
+ vis.binds.materialdesign.button.handleLink(el, data, type.includes('icon'));
74
+ } else if (type.includes('state')) {
75
+ vis.binds.materialdesign.button.handleState(el, data, false, type.includes('icon'));
76
+ } else if (type.includes('multiState')) {
77
+ vis.binds.materialdesign.button.handleState(el, data, true, type.includes('icon'));
78
+ } else if (type.includes('addition')) {
79
+ vis.binds.materialdesign.button.handleAddition(el, data, type.includes('icon'));
80
+ } else if (type.includes('toggle')) {
81
+ vis.binds.materialdesign.button.handleToggle(el, data, type.includes('icon'));
82
+ } else if (type.includes('slider')) {
83
+ vis.binds.materialdesign.button.handleToggle(el, data, type.includes('icon'), true);
84
+ }
85
+ });
86
+
87
+ } catch (ex) {
88
+ console.error(`[${widgetName} ${type} - ${data.wid}] initialize: error: ${ex.message}, stack: ${ex.stack}`);
89
+ }
90
+ },
91
+ initializeButton: function ($this, data, type, isIconButton = false) {
92
+ try {
93
+ let buttonElementsList = [];
94
+
95
+ $this.attr('isLocked', myMdwHelper.getBooleanFromData(data.lockEnabled, false));
96
+
97
+ let lockIcon = '';
98
+ if (!isIconButton) {
99
+ if (myMdwHelper.getBooleanFromData(data.lockEnabled) === true) {
100
+ lockIcon = `<span class="mdi mdi-${myMdwHelper.getValueFromData(data.lockIcon, 'lock-outline')} materialdesign-lock-icon"
101
+ style="${(myMdwHelper.getNumberFromData(data.lockIconSize, undefined) !== '0') ? `width: ${data.lockIconSize}px; height: ${data.lockIconSize}px; font-size: ${data.lockIconSize}px;` : ''};"></span>`;
102
+ }
103
+ } else {
104
+ if (myMdwHelper.getBooleanFromData(data.lockEnabled) === true) {
105
+ let iconSize = myMdwHelper.getNumberFromData(data.lockIconSize, 16);
106
+ let elementSize = iconSize * myMdwHelper.getNumberFromData(data.lockBackgroundSizeFactor, 1);
107
+
108
+ lockIcon = `<span class="mdi mdi-${myMdwHelper.getValueFromData(data.lockIcon, 'lock-outline')} materialdesign-lock-icon"
109
+ style="position: absolute; left: ${myMdwHelper.getNumberFromData(data.lockIconLeft, 5)}%; top: ${myMdwHelper.getNumberFromData(data.lockIconTop, 5)}%; width: ${elementSize}px; height: ${elementSize}px; line-height: ${elementSize}px; text-align: center; font-size: ${iconSize}px; color: ${myMdwHelper.getValueFromData(data.lockIconColor, '#B22222')}; background: ${myMdwHelper.getValueFromData(data.lockIconBackground, '')}; border-radius: ${elementSize}px;"></span>`;
110
+ }
111
+ }
112
+
113
+ buttonElementsList.push(`<div
114
+ class="materialdesign-button-body"
115
+ style="display:flex; justify-content: center; align-items: center; width: 100%; height: 100%;">`);
116
+
117
+ let imageElement = myMdwHelper.getIconElement(data.image, 'auto', myMdwHelper.getValueFromData(data.iconHeight, 'auto', '', 'px'), myMdwHelper.getValueFromData(data.imageColor, ''));
118
+
119
+ let labelElement = '';
120
+ if (myMdwHelper.getValueFromData(data.buttontext, null) != null && !isIconButton) {
121
+ labelElement = `<span
122
+ class="materialdesign-button__label" style="${myMdwHelper.getValueFromData(data.labelWidth, 0) > 0 ? `width: ${data.labelWidth}%;` : ''} color: ${myMdwHelper.getValueFromData(data.labelColorFalse, '')};">
123
+ ${data.buttontext}
124
+ </span>`;
125
+ }
126
+
127
+ if (type.includes('toggle')) {
128
+ var val = vis.states.attr(data.oid + '.val');
129
+
130
+ if (vis.binds.materialdesign.button.getToggleState(val, data)) {
131
+ imageElement = myMdwHelper.getIconElement(myMdwHelper.getValueFromData(data.imageTrue, myMdwHelper.getValueFromData(data.image, '')), 'auto', myMdwHelper.getValueFromData(data.iconHeight, 'auto', '', 'px'), myMdwHelper.getValueFromData(data.imageTrueColor, myMdwHelper.getValueFromData(data.imageColor, '')));
132
+ $this.css('background', myMdwHelper.getValueFromData(data.colorBgTrue, myMdwHelper.getValueFromData(data.colorBgFalse, '')));
133
+
134
+ if (myMdwHelper.getValueFromData(data.buttontext, null) != null && !isIconButton) {
135
+ labelElement = `<span
136
+ class="materialdesign-button__label" style="${myMdwHelper.getValueFromData(data.labelWidth, 0) > 0 ? `width: ${data.labelWidth}%;` : ''} color: ${myMdwHelper.getValueFromData(data.labelColorTrue, myMdwHelper.getValueFromData(data.labelColorFalse, ''))};">
137
+ ${data.buttontext}
138
+ </span>`;
139
+ }
140
+ }
141
+ }
142
+
143
+ if (data.iconPosition === 'left') {
144
+ buttonElementsList.push(`${imageElement} ${labelElement} ${lockIcon}</div>`);
145
+ } else {
146
+ buttonElementsList.push(`${lockIcon} ${labelElement} ${imageElement}</div>`);
147
+ }
148
+
149
+ return buttonElementsList.join('');
150
+ } catch (ex) {
151
+ console.error(`[Button - ${data.wid}] initialize: error: ${ex.message}, stack: ${ex.stack}`);
152
+ }
153
+ },
154
+ initializeVerticalButton: function ($this, data, type) {
155
+ try {
156
+ let buttonElementsList = [];
157
+
158
+ $this.attr('isLocked', myMdwHelper.getBooleanFromData(data.lockEnabled, false));
159
+
160
+ let lockIcon = '';
161
+ if (myMdwHelper.getBooleanFromData(data.lockEnabled) === true) {
162
+ lockIcon = `<span class="mdi mdi-${myMdwHelper.getValueFromData(data.lockIcon, 'lock-outline')} materialdesign-lock-icon"
163
+ style="position: absolute; left: ${myMdwHelper.getNumberFromData(data.lockIconLeft, 5)}%; top: ${myMdwHelper.getNumberFromData(data.lockIconTop, 5)}%; ${(myMdwHelper.getNumberFromData(data.lockIconSize, undefined) !== '0') ? `width: ${data.lockIconSize}px; height: ${data.lockIconSize}px; font-size: ${data.lockIconSize}px;` : ''}"></span>`;
164
+ }
165
+
166
+ buttonElementsList.push(`<div
167
+ class="materialdesign-button-body"
168
+ style="display:flex; flex-direction: column; justify-content: center; align-items: ${myMdwHelper.getValueFromData(data.alignment, 'center')}; width: 100%; height: 100%; ">`);
169
+
170
+ let imageElement = myMdwHelper.getIconElement(data.image, 'auto', myMdwHelper.getValueFromData(data.iconHeight, 'auto', '', 'px'), myMdwHelper.getValueFromData(data.imageColor, ''));
171
+
172
+ let labelElement = '';
173
+ if (myMdwHelper.getValueFromData(data.buttontext, null) != null) {
174
+ labelElement = `<span
175
+ class="materialdesign-button__label" style="text-align: center; color: ${myMdwHelper.getValueFromData(data.labelColorFalse, '')};">
176
+ ${data.buttontext}
177
+ </span>`;
178
+ }
179
+
180
+ if (type.includes('toggle')) {
181
+ var val = vis.states.attr(data.oid + '.val');
182
+
183
+ if (vis.binds.materialdesign.button.getToggleState(val, data)) {
184
+ imageElement = myMdwHelper.getIconElement(myMdwHelper.getValueFromData(data.imageTrue, myMdwHelper.getValueFromData(data.image, '')), 'auto', myMdwHelper.getValueFromData(data.iconHeight, 'auto', '', 'px'), myMdwHelper.getValueFromData(data.imageTrueColor, myMdwHelper.getValueFromData(data.imageColor, '')));
185
+ $this.css('background', myMdwHelper.getValueFromData(data.colorBgTrue, myMdwHelper.getValueFromData(data.colorBgFalse, '')));
186
+ labelElement = `<span
187
+ class="materialdesign-button__label" style="text-align: center; color: ${myMdwHelper.getValueFromData(data.labelColorTrue, myMdwHelper.getValueFromData(data.labelColorFalse, ''))};">
188
+ ${data.buttontext}
189
+ </span>`;
190
+ }
191
+ }
192
+
193
+ if (data.iconPosition === 'top') {
194
+ buttonElementsList.push(`${imageElement}${labelElement}</div>`);
195
+ } else {
196
+ buttonElementsList.push(`${labelElement}${imageElement}</div>`);
197
+ }
198
+
199
+ buttonElementsList.push(lockIcon);
200
+
201
+ return buttonElementsList.join('')
202
+ } catch (ex) {
203
+ console.error(`[Button - ${data.wid}] vertical initialize: error: ${ex.message}, stack: ${ex.stack}`);
204
+ }
205
+ },
206
+ handleLink: function (el, data, isIconButton = false) {
207
+ try {
208
+ let $this = $(el);
209
+
210
+ $this.on('click', function (e) {
211
+ // Protect against two events
212
+ event.preventDefault();
213
+
214
+ myMdwHelper.hapticFeedback(data, true, false);
215
+
216
+ if (!vis.editMode && data.href) {
217
+ if (data.openNewWindow) {
218
+ window.open(data.href);
219
+ } else {
220
+ window.location.href = data.href;
221
+ }
222
+ }
223
+ });
224
+
225
+ $this.on('tapstart', function (e) {
226
+ myMdwHelper.hapticFeedback(data, false, true);
227
+ });
228
+ } catch (ex) {
229
+ console.error(`[Button - ${data.wid}] handleLink: error: ${ex.message}, stack: ${ex.stack}`);
230
+ }
231
+ },
232
+ handleNavigation: function (el, data, isIconButton = false) {
233
+ try {
234
+ let $this = $(el);
235
+
236
+ if (!vis.editMode && data.nav_view) {
237
+ let moved = false;
238
+ $this.on('click', function (e) {
239
+ // Protect against two events
240
+ event.preventDefault();
241
+
242
+ myMdwHelper.hapticFeedback(data, true, false);
243
+
244
+ if (moved) return;
245
+ vis.changeView(data.nav_view, data.nav_view);
246
+ //e.preventDefault();
247
+ //return false;
248
+ }).on('touchmove', function (e) {
249
+ moved = true;
250
+ }).on('touchstart', function (e) {
251
+ moved = false;
252
+ });
253
+
254
+ $this.on('tapstart', function (e) {
255
+ myMdwHelper.hapticFeedback(data, false, true);
256
+ });
257
+ }
258
+ } catch (ex) {
259
+ console.error(`[Button - ${data.wid}] handleNavigation: error: ${ex.message}, stack: ${ex.stack}`);
260
+ }
261
+ },
262
+ handleAddition: function (el, data, isIconButton = false) {
263
+ try {
264
+ let $this = $(el);
265
+
266
+ $this.on('click', function (e) {
267
+ // Protect against two events
268
+ event.preventDefault();
269
+
270
+ myMdwHelper.hapticFeedback(data, true, false);
271
+
272
+ let val = vis.states.attr(data.oid + '.val');
273
+ if (!data.minmax || val != data.minmax) {
274
+ myMdwHelper.setValue(data.oid, parseFloat(val) + parseFloat(data.value));
275
+ }
276
+ });
277
+
278
+ $this.on('tapstart', function (e) {
279
+ myMdwHelper.hapticFeedback(data, false, true);
280
+ });
281
+ } catch (ex) {
282
+ console.error(`[Button - ${data.wid}] handleAddition: error:: ${ex.message}, stack: ${ex.stack}`);
283
+ }
284
+ },
285
+ handleState: function (el, data, isMulti = false, isIconButton = false) {
286
+ try {
287
+ // modified from vis adapter -> https://github.com/ioBroker/ioBroker.vis/blob/2a08ee6da626a65b9d0b42b8679563e74272bfc6/www/widgets/basic.html#L480
288
+ var $this = $(el);
289
+ var val = data.value;
290
+
291
+ if (val === 'true') val = true;
292
+ if (val === 'false') val = false;
293
+
294
+ if ($this.attr('isLocked') === 'true') {
295
+ $this.find('.materialdesign-button-body').css('filter', `grayscale(${myMdwHelper.getNumberFromData(data.lockFilterGrayscale, 0)}%)`);
296
+ }
297
+
298
+ if (!isMulti) {
299
+ vis.states.bind(data.oid + '.val', function (e, newVal, oldVal) {
300
+ setLayout(newVal);
301
+ });
302
+
303
+ $(document).on("mdwSubscribe", function (e, oids) {
304
+ if (myMdwHelper.isLayoutRefreshNeeded('Button', data, oids, data.debug)) {
305
+ setLayout(vis.states.attr(data.oid + '.val'));
306
+ }
307
+ });
308
+ }
309
+
310
+ if (!vis.editMode) {
311
+ var moved = false;
312
+ $this.on('click', function (e) {
313
+ // Protect against two events
314
+ event.preventDefault();
315
+
316
+ myMdwHelper.hapticFeedback(data, true, false);
317
+
318
+ if (moved) return;
319
+
320
+ if ($this.attr('isLocked') === 'false' || $this.attr('isLocked') === undefined) {
321
+ if (!isMulti) {
322
+ setValue(data.oid, data.value);
323
+ setLayout(formatInputValue(data.value));
324
+ } else {
325
+ for (var i = 0; i <= data.countOids; i++) {
326
+ let oid = data['oid' + i]
327
+ let value = data['value' + i];
328
+
329
+ setTimeout(function () {
330
+ setValue(oid, value);
331
+ }, myMdwHelper.getNumberFromData(data['delayInMs' + i], 0));
332
+ }
333
+ }
334
+ } else {
335
+ unlockButton();
336
+ }
337
+ }).on('touchmove', function (e) {
338
+ moved = true;
339
+ }).on('touchstart', function (e) {
340
+ moved = false;
341
+ });
342
+
343
+ $this.on('tapstart', function (e) {
344
+ myMdwHelper.hapticFeedback(data, false, true);
345
+ });
346
+
347
+ function unlockButton() {
348
+ $this.find('.materialdesign-lock-icon').fadeOut();
349
+ $this.attr('isLocked', false);
350
+ $this.find('.materialdesign-button-body').css('filter', 'grayscale(0%)');
351
+
352
+ setTimeout(function () {
353
+ $this.attr('isLocked', true);
354
+ $this.find('.materialdesign-lock-icon').show();
355
+ $this.find('.materialdesign-button-body').css('filter', `grayscale(${myMdwHelper.getNumberFromData(data.lockFilterGrayscale, 0)}%)`);
356
+ }, myMdwHelper.getNumberFromData(data.autoLockAfter, 10) * 1000);
357
+ }
358
+
359
+ function setValue(oid, value) {
360
+ if (oid) {
361
+ let val = formatInputValue(value);
362
+ if (oid) myMdwHelper.setValue(oid, val);
363
+ }
364
+ }
365
+ }
366
+
367
+ if (!isMulti) {
368
+ setLayout(vis.states.attr(data.oid + '.val'));
369
+ }
370
+
371
+ function setLayout(val) {
372
+ var formatVal = formatInputValue(data.value);
373
+
374
+ if (val === formatVal) {
375
+ if (!isIconButton) {
376
+ $this.find('.materialdesign-button-body').css('background', myMdwHelper.getValueFromData(data.colorBgTrue, ''));
377
+ } else {
378
+ $this.css('background', myMdwHelper.getValueFromData(data.colorBgTrue, ''));
379
+ }
380
+ } else {
381
+ if (!isIconButton) {
382
+ $this.find('.materialdesign-button-body').css('background', '');
383
+ } else {
384
+ $this.css('background', myMdwHelper.getValueFromData(data.colorBgFalse, ''));
385
+ }
386
+ }
387
+ }
388
+
389
+ function formatInputValue(value) {
390
+ // format data.value to correct format
391
+ var val = value;
392
+ if (val === undefined || val === null) val = false;
393
+ if (val === 'true') val = true;
394
+ if (val === 'false') val = false;
395
+ if (parseFloat(val).toString() == val) val = parseFloat(val);
396
+
397
+ return val;
398
+ }
399
+
400
+ } catch (ex) {
401
+ console.error(`[Button - ${data.wid}] handleState: error:: ${ex.message}, stack: ${ex.stack}`);
402
+ }
403
+ },
404
+ handleToggle: function (el, data, isIconButton = false, hasSlider = false) {
405
+ try {
406
+ var $this = $(el);
407
+
408
+ let $scalaInput;
409
+ let $knobDiv;
410
+ let $linkedValueWidget;
411
+
412
+ if ($this.attr('isLocked') === 'true') {
413
+ $this.find('.materialdesign-button-body').css('filter', `grayscale(${myMdwHelper.getNumberFromData(data.lockFilterGrayscale, 0)}%)`);
414
+ }
415
+
416
+ let bgColor = myMdwHelper.getValueFromData(data.colorBgFalse, '');
417
+ let bgColorTrue = myMdwHelper.getValueFromData(data.colorBgTrue, bgColor);
418
+
419
+ let textFalse = myMdwHelper.getValueFromData(data.buttontext, '');
420
+ let textTrue = myMdwHelper.getValueFromData(data.labelTrue, textFalse);
421
+
422
+ let textColorFalse = myMdwHelper.getValueFromData(data.labelColorFalse, '');
423
+ let textColorTrue = myMdwHelper.getValueFromData(data.labelColorTrue, textColorFalse);
424
+
425
+ if (hasSlider) {
426
+ data.toggleType = "value";
427
+ intializeSlider();
428
+ }
429
+
430
+ setButtonState();
431
+
432
+ if (data.readOnly && !vis.editMode) {
433
+ $this.css('pointer-events', 'none');
434
+ }
435
+
436
+ vis.states.bind(data.oid + '.val', function (e, newVal, oldVal) {
437
+ setButtonState(newVal);
438
+ });
439
+
440
+ if (!vis.editMode) {
441
+ if (myMdwHelper.getBooleanFromData(data.pushButton, false) === false) {
442
+
443
+ if (!hasSlider) {
444
+ $this.on('click', function (e) {
445
+ // Protect against two events
446
+ e.preventDefault();
447
+
448
+ myMdwHelper.hapticFeedback(data, true, false);
449
+
450
+ if ($this.attr('isLocked') === 'false' || $this.attr('isLocked') === false || $this.attr('isLocked') === undefined) {
451
+ if (myMdwHelper.getValueFromData(data.toggleType, 'boolean') === 'boolean') {
452
+ myMdwHelper.setValue(data.oid, !vis.states.attr(data.oid + '.val'));
453
+ } else {
454
+ if ($this.attr('toggled') === true || $this.attr('toggled') === 'true') {
455
+ myMdwHelper.setValue(data.oid, data.valueOff);
456
+ } else {
457
+ myMdwHelper.setValue(data.oid, data.valueOn);
458
+ }
459
+ }
460
+ } else {
461
+ unlockButton();
462
+ }
463
+ });
464
+
465
+ $this.on('tapstart', function (e) {
466
+ myMdwHelper.hapticFeedback(data, false, true);
467
+ });
468
+ } else {
469
+ sliderEvents();
470
+ }
471
+ } else {
472
+ // Button from type push (Taster)
473
+ $this.on('mousedown touchstart', function (e) {
474
+ myMdwHelper.hapticFeedback(data);
475
+
476
+ if ($this.attr('isLocked') === 'false' || $this.attr('isLocked') === false || $this.attr('isLocked') === undefined) {
477
+ if (data.toggleType === 'boolean') {
478
+ myMdwHelper.setValue(data.oid, true);
479
+ } else {
480
+ myMdwHelper.setValue(data.oid, data.valueOn);
481
+ }
482
+ } else {
483
+ unlockButton();
484
+ }
485
+ });
486
+
487
+ $this.on('mouseup touchend', function (e) {
488
+ if ($this.attr('isLocked') === 'false' || $this.attr('isLocked') === false || $this.attr('isLocked') === undefined) {
489
+ if (data.toggleType === 'boolean') {
490
+ myMdwHelper.setValue(data.oid, false);
491
+ } else {
492
+ myMdwHelper.setValue(data.oid, data.valueOff);
493
+ }
494
+ } else {
495
+ unlockButton();
496
+ }
497
+ });
498
+ }
499
+ }
500
+
501
+ function setButtonState(val) {
502
+ if (!val || val === null) {
503
+ val = vis.states.attr(data.oid + '.val');
504
+ }
505
+
506
+ let buttonState = vis.binds.materialdesign.button.getToggleState(val, data);
507
+
508
+ if (buttonState) {
509
+ $this.attr('toggled', true);
510
+
511
+ if (isIconButton) {
512
+ $this.css('background', bgColorTrue);
513
+ } else {
514
+ $this.find('.materialdesign-button-body').css('background', bgColorTrue);
515
+ }
516
+
517
+ myMdwHelper.changeIconElement($this, myMdwHelper.getValueFromData(data.imageTrue, myMdwHelper.getValueFromData(data.image, '')), 'auto', myMdwHelper.getValueFromData(data.iconHeight, 'auto', '', 'px'), myMdwHelper.getValueFromData(data.imageTrueColor, myMdwHelper.getValueFromData(data.imageColor, '')));
518
+
519
+ $this.find('.materialdesign-button__label').html(textTrue).css('color', textColorTrue);
520
+ } else {
521
+ $this.attr('toggled', false);
522
+
523
+ if (isIconButton) {
524
+ $this.css('background', bgColor);
525
+ } else {
526
+ $this.find('.materialdesign-button-body').css('background', bgColor);
527
+ }
528
+
529
+ myMdwHelper.changeIconElement($this, data.image, 'auto', myMdwHelper.getValueFromData(data.iconHeight, 'auto', '', 'px'), myMdwHelper.getValueFromData(data.imageColor, ''));
530
+
531
+ $this.find('.materialdesign-button__label').html(textFalse).css('color', textColorFalse);
532
+ }
533
+
534
+ if (hasSlider) {
535
+ sliderSetValue(val, false);
536
+ setLinkedValueWidgetState(val);
537
+ }
538
+ }
539
+
540
+ function unlockButton() {
541
+ $this.find('.materialdesign-lock-icon').fadeOut();
542
+ $this.attr('isLocked', false);
543
+ $this.find('.materialdesign-button-body').css('filter', 'grayscale(0%)');
544
+
545
+ setTimeout(function () {
546
+ $this.attr('isLocked', true);
547
+ $this.find('.materialdesign-lock-icon').show();
548
+ $this.find('.materialdesign-button-body').css('filter', `grayscale(${myMdwHelper.getNumberFromData(data.lockFilterGrayscale, 0)}%)`);
549
+ }, myMdwHelper.getNumberFromData(data.autoLockAfter, 10) * 1000);
550
+ }
551
+
552
+ function intializeSlider() {
553
+ $this.css('overflow', 'visible');
554
+ // $this.css('padding', 0);
555
+ $this.find('.materialdesign-button-body').css('position', 'relative');
556
+
557
+ var divW = parseInt(window.getComputedStyle($this.get(0), null).width.replace('px', ''));
558
+ var divH = parseInt(window.getComputedStyle($this.get(0), null).height.replace('px', ''));
559
+ var divMax = ((divW > divH) ? divW : divH);
560
+
561
+ // calculate thickness
562
+ let sliderwith = Math.round(divMax + myMdwHelper.getNumberFromData(data.sliderWidth, 20)) + '';
563
+ let optThickness = 1 - (divMax / sliderwith);
564
+
565
+ if (data.showInFront) {
566
+ sliderwith = Math.round(divMax - myMdwHelper.getNumberFromData(data.sliderWidth, 0)) + '';
567
+ optThickness = 0.15;
568
+
569
+ if (sliderwith <= 0) {
570
+ sliderwith = 1;
571
+ }
572
+ }
573
+
574
+ let thickness = myMdwHelper.getNumberFromData(data.sliderThikness, undefined) ? data.sliderThikness : optThickness;
575
+
576
+ let sliderElement = `
577
+ <div class="materialdesign-icon-button-slider-container" style="position: absolute; left: calc(50% - ${sliderwith}px / 2); top: calc(50% - ${sliderwith}px / 2);">
578
+ <input type="text" class="scalaInput" value="66" data-width="${sliderwith}" data-height="${sliderwith}" data-thickness="${thickness}"
579
+ style="width: 0px;
580
+ height: 0px;
581
+ display: hidden;
582
+ background: rgba(0, 0, 0, 0) none repeat scroll 0% 0%;">
583
+ </div>`
584
+
585
+ if (!data.showInFront) {
586
+ $this.prepend(sliderElement);
587
+ $this.find('.materialdesign-button-body').css('pointer-events', 'none !important');
588
+ } else {
589
+ $this.find('.materialdesign-button-body').append(sliderElement);
590
+ }
591
+
592
+ $scalaInput = $this.find('.scalaInput');
593
+ let dataMax = myMdwHelper.getNumberFromData(data.valueOn, 100);
594
+ let dataMin = myMdwHelper.getNumberFromData(data.valueOff, 0);
595
+
596
+ let knobObj = {
597
+ displayInput: false,
598
+ min: dataMin,
599
+ max: dataMax,
600
+ step: 1,
601
+ fgColor: myMdwHelper.getValueFromData(data.foregroundColor, "#44739e"),
602
+ bgColor: myMdwHelper.getValueFromData(data.backgroundColor, "#eeeeee"),
603
+ relative: true,
604
+ angleOffset: myMdwHelper.getNumberFromData(data.angleOffset, 0),
605
+ angleArc: myMdwHelper.getNumberFromData(data.angleArc, 360),
606
+ change: function (value) {
607
+ if (vis.editMode) {
608
+ return false;
609
+ }
610
+
611
+ if (!($this.attr('isLocked') === 'false' || $this.attr('isLocked') === false || $this.attr('isLocked') === undefined)) {
612
+ return false;
613
+ }
614
+
615
+ setLinkedValueWidgetState(value);
616
+ }
617
+ }
618
+
619
+ if (data.colorize) {
620
+ knobObj.colorize = function (color, value) {
621
+ return getColors(color, value, dataMin, dataMax, myMdwHelper.getNumberFromData(data.colorizeFactor, 0.5));
622
+ }
623
+ }
624
+
625
+ $knobDiv = $scalaInput.knobHQ(knobObj);
626
+
627
+ if (myMdwHelper.getBooleanFromData(data.enable, false) && myMdwHelper.getValueFromData(data.widgetId)) {
628
+ myMdwHelper.waitForElement($('#vis_container'), `#${data.widgetId}`, data.widgetId, 'Value - Linked', function (element) {
629
+ $linkedValueWidget = element;
630
+ }, 0, data.debug);
631
+ }
632
+ }
633
+
634
+ function sliderEvents() {
635
+ if (!vis.editMode) {
636
+ $knobDiv._click = false;
637
+ $knobDiv._mousedown = false;
638
+
639
+ $this.on('mouseenter', function (e) {
640
+ e.preventDefault();
641
+
642
+ if (!$knobDiv._mousedown) {
643
+ sliderShow();
644
+ }
645
+ });
646
+
647
+ $this.on('mouseleave', function (e) {
648
+ e.preventDefault();
649
+
650
+ if (!$knobDiv._mousedown) {
651
+ sliderHide();
652
+ }
653
+ });
654
+
655
+ $this.on('tap', function (e) {
656
+ e.preventDefault();
657
+
658
+ $knobDiv._click = true;
659
+ $knobDiv._mousedown = false;
660
+ });
661
+
662
+ $this.on('tapstart', function (e) {
663
+ e.preventDefault();
664
+
665
+ myMdwHelper.hapticFeedback(data);
666
+
667
+ $knobDiv._mousedown = true;
668
+ $knobDiv._click = false;
669
+
670
+ sliderShow();
671
+ linkedValueWidgetShow();
672
+ });
673
+
674
+ $this.on('touchstart', function (e) {
675
+ if ($knobDiv._mousedown) {
676
+ if (e.simulated) {
677
+ e.preventDefault();
678
+ return;
679
+ }
680
+
681
+ e.simulated = true;
682
+ $knobDiv.find('canvas').trigger(e);
683
+ e.preventDefault();
684
+ }
685
+ }).on('mousedown', function (e) {
686
+ if ($knobDiv._mousedown) {
687
+ if (e.simulated) {
688
+ e.preventDefault();
689
+ return;
690
+ }
691
+
692
+ e.simulated = true;
693
+ $knobDiv.find('canvas').trigger(e);
694
+ e.preventDefault();
695
+ }
696
+ });
697
+
698
+ $('body').on('tapend', function (e) {
699
+ if ($knobDiv._click) {
700
+ if (!data.sliderOnly) {
701
+ if ($this.attr('isLocked') === 'false' || $this.attr('isLocked') === false || $this.attr('isLocked') === undefined) {
702
+ if ($this.attr('toggled') === true || $this.attr('toggled') === 'true') {
703
+ let dataVal = myMdwHelper.getNumberFromData(data.valueOff, 100);
704
+ myMdwHelper.setValue(data.oid, dataVal);
705
+ sliderSetValue(dataVal);
706
+ } else {
707
+ let dataVal = myMdwHelper.getNumberFromData(data.valueOn, 100);
708
+ myMdwHelper.setValue(data.oid, dataVal);
709
+ sliderSetValue(dataVal);
710
+ }
711
+ } else {
712
+ unlockButton();
713
+ }
714
+ sliderHide();
715
+ linkedValueWidgetHide();
716
+ }
717
+ } else {
718
+ if ($knobDiv._mousedown) {
719
+ myMdwHelper.hapticFeedback(data);
720
+
721
+ if ($this.attr('isLocked') === 'false' || $this.attr('isLocked') === false || $this.attr('isLocked') === undefined) {
722
+ myMdwHelper.setValue(data.oid, $scalaInput.val());
723
+ }
724
+ sliderHide();
725
+ linkedValueWidgetHide();
726
+ }
727
+ }
728
+
729
+ $knobDiv._click = false;
730
+ $knobDiv._mousedown = false;
731
+ });
732
+
733
+ sliderHide();
734
+ }
735
+ }
736
+
737
+ function sliderSetValue(val, setByUser = true) {
738
+ if (val || val === 0) {
739
+ $scalaInput.data('setByUser', setByUser);
740
+ $scalaInput.val(val).trigger('change');
741
+ }
742
+ }
743
+
744
+ function sliderShow() {
745
+ if (!data.showAlways) {
746
+ $knobDiv.show();
747
+ }
748
+ }
749
+
750
+ function sliderHide() {
751
+ if (!data.showAlways) {
752
+ setTimeout(function () {
753
+ $knobDiv.hide();
754
+ }, 150);
755
+ }
756
+ }
757
+
758
+ function linkedValueWidgetShow() {
759
+ if ($linkedValueWidget && $linkedValueWidget.length === 1) {
760
+
761
+ if (myMdwHelper.getValueFromData(data.prepandText, undefined)) {
762
+ $linkedValueWidget.find('.prepand-text').html(data.prepandText);
763
+ }
764
+
765
+ if (myMdwHelper.getValueFromData(data.appendText, undefined)) {
766
+ $linkedValueWidget.find('.append-text').html(data.appendText);
767
+ }
768
+
769
+ if (myMdwHelper.getValueFromData(data.imageValueWidgetLink, undefined)) {
770
+ let iconElement = $linkedValueWidget.find('.materialdesign-value-icon .mdi')
771
+
772
+ iconElement.attr('class', function (i, c) {
773
+ return c.replace(/(^|\s)mdi-\S+/, ` mdi-${data.imageValueWidgetLink}`);
774
+ });
775
+
776
+ if (myMdwHelper.getValueFromData(data.imageColorValueWidgetLink, undefined)) {
777
+ iconElement.css('color', data.imageColorValueWidgetLink);
778
+ }
779
+ }
780
+
781
+ $linkedValueWidget.show();
782
+ }
783
+ }
784
+
785
+ function linkedValueWidgetHide() {
786
+ if ($linkedValueWidget && $linkedValueWidget.length === 1) {
787
+ setTimeout(function () {
788
+ $linkedValueWidget.hide();
789
+ }, 300);
790
+ }
791
+ }
792
+
793
+ function setLinkedValueWidgetState(val) {
794
+ if ($linkedValueWidget && $linkedValueWidget.length === 1) {
795
+ let formatedValue = myMdwHelper.formatNumber(val, 0, 0);
796
+ let dataMax = myMdwHelper.getNumberFromData(data.valueOn, 100);
797
+ let dataMin = myMdwHelper.getNumberFromData(data.valueOff, 0);
798
+
799
+ if (formatedValue <= dataMin && myMdwHelper.getValueFromData(data.valueLabelMin, undefined)) {
800
+ $linkedValueWidget.find('.value-text').html(data.valueLabelMin);
801
+ } else if (formatedValue >= dataMax && myMdwHelper.getValueFromData(data.valueLabelMax, undefined)) {
802
+ $linkedValueWidget.find('.value-text').html(data.valueLabelMax);
803
+ } else {
804
+ $linkedValueWidget.find('.value-text').html(`${formatedValue}${myMdwHelper.getValueFromData(data.unit, '')}`);
805
+ }
806
+ }
807
+ }
808
+
809
+ function getColors(color, value, min, max, alpha) {
810
+ let myColors;
811
+ let ratio = (value - min) / (max - min);
812
+ alpha = ratio + alpha;
813
+
814
+ if (color.includes(';')) {
815
+ myColors = chroma.scale(color.split(';'))
816
+
817
+ return myColors(ratio).alpha(alpha).css();
818
+ } else {
819
+ myColors = chroma(color);
820
+ return myColors.alpha(alpha).css();
821
+ }
822
+ }
823
+ } catch (ex) {
824
+ console.error(`[Button - ${data.wid}] handleToggle: error:: ${ex.message}, stack: ${ex.stack}`);
825
+ }
826
+ },
827
+ getToggleState(val, data) {
828
+ let buttonState = false;
829
+
830
+ if (data.toggleType === 'boolean') {
831
+ buttonState = val;
832
+ } else {
833
+ if (!isNaN(val) && !isNaN(data.valueOn)) {
834
+ if (parseFloat(val) === parseFloat(data.valueOn)) {
835
+ buttonState = true;
836
+ } else if (parseFloat(val) !== parseFloat(data.valueOn) && parseFloat(val) !== parseFloat(data.valueOff) && data.stateIfNotTrueValue === 'on') {
837
+ buttonState = true;
838
+ }
839
+ } else if (val === parseInt(data.valueOn) || val === data.valueOn) {
840
+ buttonState = true;
841
+ } else if (val !== parseInt(data.valueOn) && val !== data.valueOn && val !== parseInt(data.valueOff) && val !== data.valueOff && data.stateIfNotTrueValue === 'on') {
842
+ buttonState = true;
843
+ }
844
+ }
845
+
846
+ return buttonState;
847
+ },
848
+ useTheme: function (el, data, type, widgetName) {
849
+ var $this = $(el);
850
+ let btn = $this.parent().get(0) ? $this.parent().get(0) : $this.parent().context;
851
+
852
+ $(document).on("mdwSubscribe", function (e, oids) {
853
+ if (myMdwHelper.isLayoutRefreshNeeded(widgetName, data, oids, data.debug)) {
854
+ setLayout();
855
+ }
856
+ });
857
+
858
+ vis.states.bind('vis-materialdesign.0.colors.darkTheme.val', function (e, newVal, oldVal) {
859
+ setLayout();
860
+ });
861
+
862
+ vis.states.bind('vis-materialdesign.0.lastchange.val', function (e, newVal, oldVal) {
863
+ setLayout();
864
+ });
865
+
866
+ setLayout();
867
+ function setLayout() {
868
+ btn.style.setProperty("--materialdesign-color-primary", myMdwHelper.getValueFromData(data.mdwButtonPrimaryColor, '#44739e'));
869
+ btn.style.setProperty("--materialdesign-color-secondary", myMdwHelper.getValueFromData(data.mdwButtonSecondaryColor, '#fff'));
870
+ btn.style.setProperty("--materialdesign-font-button", myMdwHelper.getValueFromData(data.textFontFamily, ''));
871
+ btn.style.setProperty("--materialdesign-font-size-button", myMdwHelper.getStringFromNumberData(data.textFontSize, 'inherit', '', 'px'));
872
+ btn.style.setProperty("--materialdesign-font-button-vertical-text-distance-image", myMdwHelper.getNumberFromData(data.distanceBetweenTextAndImage, 2) + 'px');
873
+ btn.style.setProperty("--materialdesign-button-lockicon-color", myMdwHelper.getValueFromData(data.lockIconColor, '#B22222'));
874
+
875
+ if (!type.includes('icon')) {
876
+ btn.style.setProperty("--materialdesign-color-button-pressed", myMdwHelper.getValueFromData(data.mdwButtonColorPress, ''));
877
+ } else {
878
+ // icon Buttons
879
+ $this.css('background', myMdwHelper.getValueFromData(data.colorBgFalse, ''));
880
+
881
+ if ($this.attr('toggled') && ($this.attr('toggled') === true || $this.attr('toggled') === 'true')) {
882
+ $this.css('background', myMdwHelper.getValueFromData(data.colorBgTrue, myMdwHelper.getValueFromData(data.colorBgFalse, '')));
883
+ $this.find('.materialdesign-icon-image').css('color', myMdwHelper.getValueFromData(data.imageTrueColor, myMdwHelper.getValueFromData(data.imageColor, '')));
884
+ } else {
885
+ $this.find('.materialdesign-icon-image').css('color', myMdwHelper.getValueFromData(data.imageColor, '#44739e'));
886
+ $this.css('background', myMdwHelper.getValueFromData(data.colorBgFalse, ''));
887
+ }
888
+
889
+ $this.find('.materialdesign-lock-icon').css('background', myMdwHelper.getValueFromData(data.lockIconBackground, '')).css('color', myMdwHelper.getValueFromData(data.lockIconColor, '#B22222'));
890
+
891
+ btn.style.setProperty("--materialdesign-color-icon-button-hover", myMdwHelper.getValueFromData(data.colorPress, ''));
892
+
893
+ if (type.includes('slider')) {
894
+ $this.find('.scalaInput').trigger(
895
+ 'configure',
896
+ {
897
+ fgColor: myMdwHelper.getValueFromData(data.foregroundColor, "#44739e"),
898
+ bgColor: myMdwHelper.getValueFromData(data.backgroundColor, "#eeeeee"),
899
+ }
900
+ );
901
+ }
902
+ }
903
+ }
904
+ },
905
+ getDataFromJson(obj, widgetId, type, itemCounter = 0) {
906
+ if (type === this.types.toggle.default) {
907
+ return {
908
+ wid: widgetId,
909
+ debug: obj.debug,
910
+
911
+ // Common
912
+ oid: obj.oid,
913
+ buttonStyle: obj.buttonStyle,
914
+ readOnly: obj.readOnly,
915
+ toggleType: obj.toggleType,
916
+ pushButton: obj.pushButton,
917
+ valueOff: obj.valueOff,
918
+ valueOn: obj.valueOn,
919
+ stateIfNotTrueValue: obj.stateIfNotTrueValue,
920
+ vibrateOnMobilDevices: obj.vibrateOnMobilDevices,
921
+ clickSoundPlay: obj.clickSoundPlay,
922
+ clickSoundVolume: obj.clickSoundVolume,
923
+
924
+ // labeling
925
+ buttontext: obj.buttontext,
926
+ labelTrue: obj.labelTrue,
927
+ labelColorFalse: obj.labelColorFalse,
928
+ labelColorTrue: obj.labelColorTrue,
929
+ textFontFamily: obj.textFontFamily,
930
+ textFontSize: obj.textFontSize,
931
+ labelWidth: obj.labelWidth,
932
+
933
+ // colors
934
+ mdwButtonPrimaryColor: obj.mdwButtonPrimaryColor,
935
+ mdwButtonSecondaryColor: obj.mdwButtonSecondaryColor,
936
+ mdwButtonColorPress: obj.mdwButtonColorPress,
937
+ colorBgFalse: obj.colorBgFalse,
938
+ colorBgTrue: obj.colorBgTrue,
939
+
940
+ // icon
941
+ image: obj.image,
942
+ imageColor: obj.imageColor,
943
+ imageTrue: obj.imageTrue,
944
+ imageTrueColor: obj.imageTrueColor,
945
+ iconPosition: obj.iconPosition,
946
+ iconHeight: obj.iconHeight,
947
+
948
+ // Locking
949
+ lockEnabled: obj.lockEnabled,
950
+ autoLockAfter: obj.autoLockAfter,
951
+ lockIcon: obj.lockIcon,
952
+ lockIconSize: obj.lockIconSize,
953
+ lockIconColor: obj.lockIconColor,
954
+ lockFilterGrayscale: obj.lockFilterGrayscale
955
+ };
956
+ } else if (type === this.types.toggle.vertical) {
957
+ return {
958
+ wid: widgetId,
959
+ debug: obj.debug,
960
+
961
+ // Common
962
+ oid: obj.oid,
963
+ buttonStyle: obj.buttonStyle,
964
+ readOnly: obj.readOnly,
965
+ toggleType: obj.toggleType,
966
+ pushButton: obj.pushButton,
967
+ valueOff: obj.valueOff,
968
+ valueOn: obj.valueOn,
969
+ stateIfNotTrueValue: obj.stateIfNotTrueValue,
970
+ vibrateOnMobilDevices: obj.vibrateOnMobilDevices,
971
+ clickSoundPlay: obj.clickSoundPlay,
972
+ clickSoundVolume: obj.clickSoundVolume,
973
+
974
+ // labeling
975
+ buttontext: obj.buttontext,
976
+ labelTrue: obj.labelTrue,
977
+ labelColorFalse: obj.labelColorFalse,
978
+ labelColorTrue: obj.labelColorTrue,
979
+ textFontFamily: obj.textFontFamily,
980
+ textFontSize: obj.textFontSize,
981
+ alignment: obj.alignment,
982
+ distanceBetweenTextAndImage: obj.distanceBetweenTextAndImage,
983
+
984
+ // colors
985
+ mdwButtonPrimaryColor: obj.mdwButtonPrimaryColor,
986
+ mdwButtonSecondaryColor: obj.mdwButtonSecondaryColor,
987
+ colorBgFalse: obj.colorBgFalse,
988
+ colorBgTrue: obj.colorBgTrue,
989
+
990
+ // icon
991
+ image: obj.image,
992
+ imageColor: obj.imageColor,
993
+ imageTrue: obj.imageTrue,
994
+ imageTrueColor: obj.imageTrueColor,
995
+ iconPosition: obj.iconPosition,
996
+ iconHeight: obj.iconHeight,
997
+
998
+ // Locking
999
+ lockEnabled: obj.lockEnabled,
1000
+ autoLockAfter: obj.autoLockAfter,
1001
+ lockIcon: obj.lockIcon,
1002
+ lockIconTop: obj.lockIconTop,
1003
+ lockIconLeft: obj.lockIconLeft,
1004
+ lockIconSize: obj.lockIconSize,
1005
+ lockIconColor: obj.lockIconColor,
1006
+ lockFilterGrayscale: obj.lockFilterGrayscale
1007
+ }
1008
+ } else if (type === this.types.toggle.icon) {
1009
+ return {
1010
+ wid: widgetId,
1011
+ debug: obj.debug,
1012
+
1013
+ // Common
1014
+ oid: obj.oid,
1015
+ readOnly: obj.readOnly,
1016
+ toggleType: obj.toggleType,
1017
+ pushButton: obj.pushButton,
1018
+ valueOff: obj.valueOff,
1019
+ valueOn: obj.valueOn,
1020
+ stateIfNotTrueValue: obj.stateIfNotTrueValue,
1021
+ vibrateOnMobilDevices: obj.vibrateOnMobilDevices,
1022
+ clickSoundPlay: obj.clickSoundPlay,
1023
+ clickSoundVolume: obj.clickSoundVolume,
1024
+
1025
+ // icon
1026
+ image: obj.image,
1027
+ imageColor: obj.imageColor,
1028
+ imageTrue: obj.imageTrue,
1029
+ imageTrueColor: obj.imageTrueColor,
1030
+ iconHeight: obj.iconHeight,
1031
+
1032
+ // colors
1033
+ colorBgFalse: obj.colorBgFalse,
1034
+ colorBgTrue: obj.colorBgTrue,
1035
+ colorPress: obj.colorPress,
1036
+
1037
+ // Locking
1038
+ lockEnabled: obj.lockEnabled,
1039
+ autoLockAfter: obj.autoLockAfter,
1040
+ lockIcon: obj.lockIcon,
1041
+ lockIconTop: obj.lockIconTop,
1042
+ lockIconLeft: obj.lockIconLeft,
1043
+ lockIconSize: obj.lockIconSize,
1044
+ lockIconColor: obj.lockIconColor,
1045
+ lockIconBackground: obj.lockIconBackground,
1046
+ lockBackgroundSizeFactor: obj.lockBackgroundSizeFactor,
1047
+ lockFilterGrayscale: obj.lockFilterGrayscale
1048
+ }
1049
+ } else if (type === this.types.state.default) {
1050
+ return {
1051
+ wid: widgetId,
1052
+
1053
+ // Common
1054
+ oid: obj.oid,
1055
+ buttonStyle: obj.buttonStyle,
1056
+ value: obj.value,
1057
+ vibrateOnMobilDevices: obj.vibrateOnMobilDevices,
1058
+ clickSoundPlay: obj.clickSoundPlay,
1059
+ clickSoundVolume: obj.clickSoundVolume,
1060
+ debug: obj.debug,
1061
+
1062
+ // labeling
1063
+ buttontext: obj.buttontext,
1064
+ textFontFamily: obj.textFontFamily,
1065
+ textFontSize: obj.textFontSize,
1066
+ labelWidth: obj.labelWidth,
1067
+
1068
+ // colors
1069
+ mdwButtonPrimaryColor: obj.mdwButtonPrimaryColor,
1070
+ mdwButtonSecondaryColor: obj.mdwButtonSecondaryColor,
1071
+ mdwButtonColorPress: obj.mdwButtonColorPress,
1072
+ colorBgTrue: obj.colorBgTrue,
1073
+
1074
+ // icon
1075
+ image: obj.image,
1076
+ imageColor: obj.imageColor,
1077
+ iconPosition: obj.iconPosition,
1078
+ iconHeight: obj.iconHeight,
1079
+
1080
+ // Locking
1081
+ lockEnabled: obj.lockEnabled,
1082
+ autoLockAfter: obj.autoLockAfter,
1083
+ lockIcon: obj.lockIcon,
1084
+ lockIconSize: obj.lockIconSize,
1085
+ lockIconColor: obj.lockIconColor,
1086
+ lockFilterGrayscale: obj.lockFilterGrayscale
1087
+
1088
+ }
1089
+ } else if (type === this.types.state.vertical) {
1090
+ return {
1091
+ wid: widgetId,
1092
+
1093
+ // Common
1094
+ oid: obj.oid,
1095
+ buttonStyle: obj.buttonStyle,
1096
+ value: obj.value,
1097
+ vibrateOnMobilDevices: obj.vibrateOnMobilDevices,
1098
+ clickSoundPlay: obj.clickSoundPlay,
1099
+ clickSoundVolume: obj.clickSoundVolume,
1100
+ debug: obj.debug,
1101
+
1102
+ // labeling
1103
+ buttontext: obj.buttontext,
1104
+ textFontFamily: obj.textFontFamily,
1105
+ textFontSize: obj.textFontSize,
1106
+ alignment: obj.alignment,
1107
+ distanceBetweenTextAndImage: obj.distanceBetweenTextAndImage,
1108
+
1109
+ // colors
1110
+ mdwButtonPrimaryColor: obj.mdwButtonPrimaryColor,
1111
+ mdwButtonSecondaryColor: obj.mdwButtonSecondaryColor,
1112
+ mdwButtonColorPress: obj.mdwButtonColorPress,
1113
+ colorBgTrue: obj.colorBgTrue,
1114
+
1115
+ // icon
1116
+ image: obj.image,
1117
+ imageColor: obj.imageColor,
1118
+ iconPosition: obj.iconPosition,
1119
+ iconHeight: obj.iconHeight,
1120
+
1121
+ // Locking
1122
+ lockEnabled: obj.lockEnabled,
1123
+ autoLockAfter: obj.autoLockAfter,
1124
+ lockIcon: obj.lockIcon,
1125
+ lockIconTop: obj.lockIconTop,
1126
+ lockIconLeft: obj.lockIconLeft,
1127
+ lockIconSize: obj.lockIconSize,
1128
+ lockIconColor: obj.lockIconColor,
1129
+ lockFilterGrayscale: obj.lockFilterGrayscale
1130
+ }
1131
+ } else if (type === this.types.state.icon) {
1132
+ return {
1133
+ wid: widgetId,
1134
+ debug: obj.debug,
1135
+
1136
+ // Common
1137
+ oid: obj.oid,
1138
+ value: obj.value,
1139
+ vibrateOnMobilDevices: obj.vibrateOnMobilDevices,
1140
+ clickSoundPlay: obj.clickSoundPlay,
1141
+ clickSoundVolume: obj.clickSoundVolume,
1142
+
1143
+ // icon
1144
+ image: obj.image,
1145
+ imageColor: obj.imageColor,
1146
+ iconHeight: obj.iconHeight,
1147
+
1148
+ // colors
1149
+ colorBgFalse: obj.colorBgFalse,
1150
+ colorPress: obj.colorPress,
1151
+
1152
+ // Locking
1153
+ lockEnabled: obj.lockEnabled,
1154
+ autoLockAfter: obj.autoLockAfter,
1155
+ lockIcon: obj.lockIcon,
1156
+ lockIconTop: obj.lockIconTop,
1157
+ lockIconLeft: obj.lockIconLeft,
1158
+ lockIconSize: obj.lockIconSize,
1159
+ lockIconColor: obj.lockIconColor,
1160
+ lockIconBackground: obj.lockIconBackground,
1161
+ lockBackgroundSizeFactor: obj.lockBackgroundSizeFactor,
1162
+ lockFilterGrayscale: obj.lockFilterGrayscale
1163
+ }
1164
+ } else if (type === this.types.link.default) {
1165
+ return {
1166
+ wid: widgetId,
1167
+ debug: obj.debug,
1168
+
1169
+ // Common
1170
+ buttonStyle: obj.buttonStyle,
1171
+ href: obj.href,
1172
+ openNewWindow: obj.openNewWindow,
1173
+ vibrateOnMobilDevices: obj.vibrateOnMobilDevices,
1174
+ clickSoundPlay: obj.clickSoundPlay,
1175
+ clickSoundVolume: obj.clickSoundVolume,
1176
+ generateHtmlControl: obj.generateHtmlControl,
1177
+
1178
+ // labeling
1179
+ buttontext: obj.buttontext,
1180
+ textFontFamily: obj.textFontFamily,
1181
+ textFontSize: obj.textFontSize,
1182
+ labelWidth: obj.labelWidth,
1183
+
1184
+ // colors
1185
+ mdwButtonPrimaryColor: obj.mdwButtonPrimaryColor,
1186
+ mdwButtonSecondaryColor: obj.mdwButtonSecondaryColor,
1187
+ mdwButtonColorPress: obj.mdwButtonColorPress,
1188
+
1189
+ // icon
1190
+ image: obj.image,
1191
+ imageColor: obj.imageColor,
1192
+ iconPosition: obj.iconPosition,
1193
+ iconHeight: obj.iconHeight,
1194
+ }
1195
+ } else if (type === this.types.link.vertical) {
1196
+ return {
1197
+ wid: widgetId,
1198
+ debug: obj.debug,
1199
+
1200
+ // Common
1201
+ buttonStyle: obj.buttonStyle,
1202
+ href: obj.href,
1203
+ openNewWindow: obj.openNewWindow,
1204
+ vibrateOnMobilDevices: obj.vibrateOnMobilDevices,
1205
+ clickSoundPlay: obj.clickSoundPlay,
1206
+ clickSoundVolume: obj.clickSoundVolume,
1207
+
1208
+ // labeling
1209
+ buttontext: obj.buttontext,
1210
+ textFontFamily: obj.textFontFamily,
1211
+ textFontSize: obj.textFontSize,
1212
+ alignment: obj.alignment,
1213
+ distanceBetweenTextAndImage: obj.distanceBetweenTextAndImage,
1214
+
1215
+ // colors
1216
+ mdwButtonPrimaryColor: obj.mdwButtonPrimaryColor,
1217
+ mdwButtonSecondaryColor: obj.mdwButtonSecondaryColor,
1218
+ mdwButtonColorPress: obj.mdwButtonColorPress,
1219
+
1220
+ // icon
1221
+ image: obj.image,
1222
+ imageColor: obj.imageColor,
1223
+ iconPosition: obj.iconPosition,
1224
+ iconHeight: obj.iconHeight
1225
+ }
1226
+ } else if (type === this.types.link.icon) {
1227
+ return {
1228
+ wid: widgetId,
1229
+ debug: obj.debug,
1230
+
1231
+ // Common
1232
+ href: obj.href,
1233
+ openNewWindow: obj.openNewWindow,
1234
+ vibrateOnMobilDevices: obj.vibrateOnMobilDevices,
1235
+ clickSoundPlay: obj.clickSoundPlay,
1236
+ clickSoundVolume: obj.clickSoundVolume,
1237
+
1238
+ // icon
1239
+ image: obj.image,
1240
+ imageColor: obj.imageColor,
1241
+ iconHeight: obj.iconHeight,
1242
+
1243
+ // colors
1244
+ colorBgFalse: obj.colorBgFalse,
1245
+ colorPress: obj.colorPress
1246
+ }
1247
+ } else if (type === this.types.navigation.vertical) {
1248
+ return {
1249
+ wid: widgetId,
1250
+
1251
+ // Common
1252
+ buttonStyle: obj.buttonStyle,
1253
+ nav_view: obj.nav_view,
1254
+ vibrateOnMobilDevices: obj.vibrateOnMobilDevices,
1255
+ clickSoundPlay: obj.clickSoundPlay,
1256
+ clickSoundVolume: obj.clickSoundVolume,
1257
+ debug: obj.debug,
1258
+
1259
+ // labeling
1260
+ buttontext: obj.buttontext,
1261
+ textFontFamily: obj.textFontFamily,
1262
+ textFontSize: obj.textFontSize,
1263
+ alignment: obj.alignment,
1264
+ distanceBetweenTextAndImage: obj.distanceBetweenTextAndImage,
1265
+
1266
+ // colors
1267
+ mdwButtonPrimaryColor: obj.mdwButtonPrimaryColor,
1268
+ mdwButtonSecondaryColor: obj.mdwButtonSecondaryColor,
1269
+ mdwButtonColorPress: obj.mdwButtonColorPress,
1270
+
1271
+ // icon
1272
+ image: obj.image,
1273
+ imageColor: obj.imageColor,
1274
+ iconPosition: obj.iconPosition,
1275
+ iconHeight: obj.iconHeight,
1276
+ }
1277
+ } else if (type === this.types.navigation.default) {
1278
+ return {
1279
+ wid: widgetId,
1280
+
1281
+ // Common
1282
+ buttonStyle: obj.buttonStyle,
1283
+ nav_view: obj.nav_view,
1284
+ vibrateOnMobilDevices: obj.vibrateOnMobilDevices,
1285
+ clickSoundPlay: obj.clickSoundPlay,
1286
+ clickSoundVolume: obj.clickSoundVolume,
1287
+ debug: obj.debug,
1288
+
1289
+ // labeling
1290
+ buttontext: obj.buttontext,
1291
+ textFontFamily: obj.textFontFamily,
1292
+ textFontSize: obj.textFontSize,
1293
+ labelWidth: obj.labelWidth,
1294
+
1295
+ // colors
1296
+ mdwButtonPrimaryColor: obj.mdwButtonPrimaryColor,
1297
+ mdwButtonSecondaryColor: obj.mdwButtonSecondaryColor,
1298
+ mdwButtonColorPress: obj.mdwButtonColorPress,
1299
+
1300
+ // icon
1301
+ image: obj.image,
1302
+ imageColor: obj.imageColor,
1303
+ iconPosition: obj.iconPosition,
1304
+ iconHeight: obj.iconHeight
1305
+ }
1306
+ } else if (type === this.types.navigation.icon) {
1307
+ return {
1308
+ wid: widgetId,
1309
+
1310
+ // Common
1311
+ nav_view: obj.nav_view,
1312
+ vibrateOnMobilDevices: obj.vibrateOnMobilDevices,
1313
+ clickSoundPlay: obj.clickSoundPlay,
1314
+ clickSoundVolume: obj.clickSoundVolume,
1315
+ debug: obj.debug,
1316
+
1317
+ // icon
1318
+ image: obj.image,
1319
+ imageColor: obj.imageColor,
1320
+ iconHeight: obj.iconHeight,
1321
+
1322
+ // colors
1323
+ colorBgFalse: obj.colorBgFalse,
1324
+ colorPress: obj.colorPress
1325
+ }
1326
+ } else if (type === this.types.multiState.vertical) {
1327
+ let data = {
1328
+ wid: widgetId,
1329
+
1330
+ // Common
1331
+ countOids: obj.countOids,
1332
+ buttonStyle: obj.buttonStyle,
1333
+ vibrateOnMobilDevices: obj.vibrateOnMobilDevices,
1334
+ clickSoundPlay: obj.clickSoundPlay,
1335
+ clickSoundVolume: obj.clickSoundVolume,
1336
+ debug: obj.debug,
1337
+
1338
+ // labeling
1339
+ buttontext: obj.buttontext,
1340
+ textFontFamily: obj.textFontFamily,
1341
+ textFontSize: obj.textFontSize,
1342
+ alignment: obj.alignment,
1343
+ distanceBetweenTextAndImage: obj.distanceBetweenTextAndImage,
1344
+
1345
+ // colors
1346
+ mdwButtonPrimaryColor: obj.mdwButtonPrimaryColor,
1347
+ mdwButtonSecondaryColor: obj.mdwButtonSecondaryColor,
1348
+ mdwButtonColorPress: obj.mdwButtonColorPress,
1349
+
1350
+ // icon
1351
+ image: obj.image,
1352
+ imageColor: obj.imageColor,
1353
+ iconPosition: obj.iconPosition,
1354
+ iconHeight: obj.iconHeight,
1355
+
1356
+ // Locking
1357
+ lockEnabled: obj.lockEnabled,
1358
+ autoLockAfter: obj.autoLockAfter,
1359
+ lockIcon: obj.lockIcon,
1360
+ lockIconTop: obj.lockIconTop,
1361
+ lockIconLeft: obj.lockIconLeft,
1362
+ lockIconSize: obj.lockIconSize,
1363
+ lockIconColor: obj.lockIconColor,
1364
+ lockFilterGrayscale: obj.lockFilterGrayscale
1365
+ }
1366
+
1367
+ let counter = itemCounter === 0 ? obj.countOids : itemCounter;
1368
+ for (var i = 0; i <= counter; i++) {
1369
+ data['oid' + i] = obj['oid' + i];
1370
+ data['value' + i] = obj['value' + i];
1371
+ data['delayInMs' + i] = obj['delayInMs' + i];
1372
+ }
1373
+
1374
+ return data;
1375
+ } else if (type === this.types.multiState.default) {
1376
+ let data = {
1377
+ wid: widgetId,
1378
+
1379
+ // Common
1380
+ countOids: obj.countOids,
1381
+ buttonStyle: obj.buttonStyle,
1382
+ vibrateOnMobilDevices: obj.vibrateOnMobilDevices,
1383
+ clickSoundPlay: obj.clickSoundPlay,
1384
+ clickSoundVolume: obj.clickSoundVolume,
1385
+ debug: obj.debug,
1386
+
1387
+ // labeling
1388
+ buttontext: obj.buttontext,
1389
+ textFontFamily: obj.textFontFamily,
1390
+ textFontSize: obj.textFontSize,
1391
+ labelWidth: obj.labelWidth,
1392
+
1393
+ // colors
1394
+ mdwButtonPrimaryColor: obj.mdwButtonPrimaryColor,
1395
+ mdwButtonSecondaryColor: obj.mdwButtonSecondaryColor,
1396
+ mdwButtonColorPress: obj.mdwButtonColorPress,
1397
+
1398
+ // icon
1399
+ image: obj.image,
1400
+ imageColor: obj.imageColor,
1401
+ iconPosition: obj.iconPosition,
1402
+ iconHeight: obj.iconHeight,
1403
+
1404
+ // Locking
1405
+ lockEnabled: obj.lockEnabled,
1406
+ autoLockAfter: obj.autoLockAfter,
1407
+ lockIcon: obj.lockIcon,
1408
+ lockIconSize: obj.lockIconSize,
1409
+ lockIconColor: obj.lockIconColor,
1410
+ lockFilterGrayscale: obj.lockFilterGrayscale
1411
+ }
1412
+
1413
+ let counter = itemCounter === 0 ? obj.countOids : itemCounter;
1414
+ for (var i = 0; i <= counter; i++) {
1415
+ data['oid' + i] = obj['oid' + i];
1416
+ data['value' + i] = obj['value' + i];
1417
+ data['delayInMs' + i] = obj['delayInMs' + i];
1418
+ }
1419
+
1420
+ return data;
1421
+ } else if (type === this.types.multiState.icon) {
1422
+ let data = {
1423
+ wid: widgetId,
1424
+
1425
+ // Common
1426
+ countOids: obj.countOids,
1427
+ vibrateOnMobilDevices: obj.vibrateOnMobilDevices,
1428
+ clickSoundPlay: obj.clickSoundPlay,
1429
+ clickSoundVolume: obj.clickSoundVolume,
1430
+ debug: obj.debug,
1431
+
1432
+ // icon
1433
+ image: obj.image,
1434
+ imageColor: obj.imageColor,
1435
+ iconHeight: obj.iconHeight,
1436
+
1437
+ // colors
1438
+ colorBgFalse: obj.colorBgFalse,
1439
+ colorPress: obj.colorPress,
1440
+
1441
+ // Locking
1442
+ lockEnabled: obj.lockEnabled,
1443
+ autoLockAfter: obj.autoLockAfter,
1444
+ lockIcon: obj.lockIcon,
1445
+ lockIconTop: obj.lockIconTop,
1446
+ lockIconLeft: obj.lockIconLeft,
1447
+ lockIconSize: obj.lockIconSize,
1448
+ lockIconColor: obj.lockIconColor,
1449
+ lockIconBackground: obj.lockIconBackground,
1450
+ lockBackgroundSizeFactor: obj.lockBackgroundSizeFactor,
1451
+ lockFilterGrayscale: obj.lockFilterGrayscale
1452
+ }
1453
+
1454
+ let counter = itemCounter === 0 ? obj.countOids : itemCounter;
1455
+ for (var i = 0; i <= counter; i++) {
1456
+ data['oid' + i] = obj['oid' + i];
1457
+ data['value' + i] = obj['value' + i];
1458
+ data['delayInMs' + i] = obj['delayInMs' + i];
1459
+ }
1460
+
1461
+ return data;
1462
+ } else if (type === this.types.addition.vertical) {
1463
+ return {
1464
+ wid: widgetId,
1465
+
1466
+ // Common
1467
+ oid: obj.oid,
1468
+ buttonStyle: obj.buttonStyle,
1469
+ value: obj.value,
1470
+ minmax: obj.minmax,
1471
+ vibrateOnMobilDevices: obj.vibrateOnMobilDevices,
1472
+ clickSoundPlay: obj.clickSoundPlay,
1473
+ clickSoundVolume: obj.clickSoundVolume,
1474
+ debug: obj.debug,
1475
+
1476
+ // labeling
1477
+ buttontext: obj.buttontext,
1478
+ textFontFamily: obj.textFontFamily,
1479
+ textFontSize: obj.textFontSize,
1480
+ alignment: obj.alignment,
1481
+ distanceBetweenTextAndImage: obj.distanceBetweenTextAndImage,
1482
+
1483
+ // colors
1484
+ mdwButtonPrimaryColor: obj.mdwButtonPrimaryColor,
1485
+ mdwButtonSecondaryColor: obj.mdwButtonSecondaryColor,
1486
+ mdwButtonColorPress: obj.mdwButtonColorPress,
1487
+
1488
+ // icon
1489
+ image: obj.image,
1490
+ imageColor: obj.imageColor,
1491
+ iconPosition: obj.iconPosition,
1492
+ iconHeight: obj.iconHeight,
1493
+
1494
+ }
1495
+ } else if (type === this.types.addition.default) {
1496
+ return {
1497
+ wid: widgetId,
1498
+
1499
+ // Common
1500
+ oid: obj.oid,
1501
+ buttonStyle: obj.buttonStyle,
1502
+ value: obj.value,
1503
+ minmax: obj.minmax,
1504
+ vibrateOnMobilDevices: obj.vibrateOnMobilDevices,
1505
+ clickSoundPlay: obj.clickSoundPlay,
1506
+ clickSoundVolume: obj.clickSoundVolume,
1507
+ debug: obj.debug,
1508
+
1509
+ // labeling
1510
+ buttontext: obj.buttontext,
1511
+ textFontFamily: obj.textFontFamily,
1512
+ textFontSize: obj.textFontSize,
1513
+ labelWidth: obj.labelWidth,
1514
+
1515
+ // colors
1516
+ mdwButtonPrimaryColor: obj.mdwButtonPrimaryColor,
1517
+ mdwButtonSecondaryColor: obj.mdwButtonSecondaryColor,
1518
+ mdwButtonColorPress: obj.mdwButtonColorPress,
1519
+
1520
+ // icon
1521
+ image: obj.image,
1522
+ imageColor: obj.imageColor,
1523
+ iconPosition: obj.iconPosition,
1524
+ iconHeight: obj.iconHeight
1525
+ }
1526
+ } else if (type === this.types.addition.icon) {
1527
+ return {
1528
+ wid: widgetId,
1529
+
1530
+ // Common
1531
+ oid: obj.oid,
1532
+ value: obj.value,
1533
+ minmax: obj.minmax,
1534
+ vibrateOnMobilDevices: obj.vibrateOnMobilDevices,
1535
+ clickSoundPlay: obj.clickSoundPlay,
1536
+ clickSoundVolume: obj.clickSoundVolume,
1537
+ debug: obj.debug,
1538
+
1539
+ // icon
1540
+ image: obj.image,
1541
+ imageColor: obj.imageColor,
1542
+ iconHeight: obj.iconHeight,
1543
+
1544
+ // colors
1545
+ colorBgFalse: obj.colorBgFalse,
1546
+ colorPress: obj.colorPress
1547
+ }
1548
+ }
1549
+ },
1550
+ getHtmlConstructor(widgetData, type) {
1551
+ try {
1552
+ let html;
1553
+
1554
+ let mdwData = myMdwHelper.getHtmlmdwData(`mdw-type='${type}'` + '\n',
1555
+ vis.binds.materialdesign.button.getDataFromJson(widgetData, 0, type));
1556
+
1557
+ if (type.includes('default') || type.includes('vertical')) {
1558
+ let width = widgetData.width ? widgetData.width : '100%';
1559
+ let height = widgetData.height ? widgetData.height : '100%';
1560
+
1561
+ delete widgetData.width;
1562
+ delete widgetData.height;
1563
+
1564
+ html = `<div class='vis-widget materialdesign-widget materialdesign-button materialdesign-button-html-element'` + '\n' +
1565
+ '\t' + `style='width: ${width}; height: ${height}; position: relative; padding: 0px;'` + '\n' +
1566
+ '\t' + mdwData + ">";
1567
+ }
1568
+
1569
+ if (type.includes('icon')) {
1570
+ let width = widgetData.width ? widgetData.width : '48px';
1571
+ let height = widgetData.height ? widgetData.height : '48px';
1572
+
1573
+ delete widgetData.width;
1574
+ delete widgetData.height;
1575
+
1576
+ html = `<div class='vis-widget materialdesign-widget materialdesign-icon-button materialdesign-button-html-element'` + '\n' +
1577
+ '\t' + `style='width: ${width}; height: ${height}; position: relative; padding: 0px;'` + '\n' +
1578
+ '\t' + mdwData + ">";
1579
+ }
1580
+
1581
+ return html + `</div>`;
1582
+
1583
+ } catch (ex) {
1584
+ console.error(`[Button: getHtmlConstructor - ${type}] error: ${ex.message}, stack: ${ex.stack} `);
1585
+ }
1586
+ }
1587
+ }
1588
+
1589
+ $.initialize(".materialdesign-button-html-element", function () {
1590
+ let $this = $(this);
1591
+ let type = $this.attr('mdw-type');
1592
+ let debug = myMdwHelper.getBooleanFromData($this.attr('mdw-debug'), false);
1593
+ let parentId = 'unknown';
1594
+ let logPrefix = `[Button HTML Element - ${parentId.replace('w', 'p')} - ${type}]`;
1595
+
1596
+ try {
1597
+ let typeSplitted = type.split("_")
1598
+ let widgetName = `Button HTML Element '${type}'`;
1599
+
1600
+ parentId = myMdwHelper.getHtmlParentId($this);
1601
+ logPrefix = `[Button HTML Element - ${parentId.replace('w', 'p')} - ${type}]`;
1602
+
1603
+ if (debug) console.log(`${logPrefix} initialize html element from type '${type}'`);
1604
+
1605
+ myMdwHelper.extractHtmlWidgetData($this,
1606
+ vis.binds.materialdesign.button.getDataFromJson({}, `${parentId}`, vis.binds.materialdesign.button.types[typeSplitted[0]][typeSplitted[1]], $this.attr('mdw-countOids')),
1607
+ parentId, widgetName, logPrefix, initializeHtml);
1608
+
1609
+ function initializeHtml(widgetData) {
1610
+ vis.binds.materialdesign.addRippleEffect($this.children(), widgetData, type.includes('_icon'));
1611
+ vis.binds.materialdesign.button.initialize($this, widgetData, type);
1612
+ }
1613
+ } catch (ex) {
1614
+ console.error(`${logPrefix} $.initialize: error: ${ex.message}, stack: ${ex.stack} `);
1615
+ $this.append(`<div style = "background: FireBrick; color: white;">Error ${ex.message}</div >`);
1616
+ }
1617
+ });