widgets.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. /*
  2. * Cell widgets
  3. */
  4. class Widgets {
  5. constructor() {
  6. console.log("widget constructor")
  7. }
  8. get divider(){
  9. return {
  10. $cell: true,
  11. $type: "hr",
  12. class: "mdc-list-divider",
  13. }
  14. }
  15. headerH3(headertype, label, cssclass) {
  16. return {
  17. $cell: true,
  18. $type: headertype,
  19. class: cssclass,
  20. $text: label
  21. }
  22. }
  23. simpleCard(obj){
  24. let style = 'background-image: url(' + obj.imgSrc + '); background-size: cover; background-repeat: no-repeat; height:' + obj.imgHeight + ';';
  25. var addonClass = obj.addonClass;
  26. if (!addonClass){
  27. addonClass = ''
  28. }
  29. return {
  30. $cell: true,
  31. $type: "div",
  32. $components:[
  33. {
  34. $cell: true,
  35. $type: "div",
  36. class: "mdc-card" +' '+ addonClass,
  37. onclick: obj.onclickfunc,
  38. $components:[
  39. {
  40. $cell: true,
  41. $type: "section",
  42. class: "mdc-card__media",
  43. style: style
  44. },
  45. {
  46. $cell: true,
  47. $type: "section",
  48. class: "mdc-card__supporting-text",
  49. $text: obj.text
  50. }
  51. ]
  52. }
  53. ]
  54. }
  55. }
  56. listDivider() {
  57. return {
  58. $cell: true,
  59. $type: "hr",
  60. class: "mdc-list-divider mdc-list-divider--inset"
  61. }
  62. }
  63. createListItem(obj) {
  64. return {
  65. $cell: true,
  66. $type: "li",
  67. class: "mdc-list-item",
  68. $components: [
  69. {
  70. $cell: true,
  71. $type: "span",
  72. class: "mdc-list-item__graphic",
  73. $components: [
  74. {
  75. $cell: true,
  76. class: "createItems",
  77. $type: "img",
  78. src: obj.imgSrc,
  79. onclick: obj.onclickfunc
  80. }
  81. ]
  82. },
  83. {
  84. $cell: true,
  85. $type: "span",
  86. class: "mdc-list-item__text",
  87. $text: obj.title
  88. // $components: [
  89. // {
  90. // $text: obj.title
  91. // },
  92. // {
  93. // $cell: true,
  94. // $type: "span",
  95. // class: "mdc-list-item__secondary-text",
  96. // $text: obj.subTitle
  97. // }
  98. // ]
  99. }
  100. ]
  101. }
  102. }
  103. createCard(obj){
  104. return {
  105. $cell: true,
  106. $type: "div",
  107. $components:[
  108. {
  109. $cell: true,
  110. $type: "div",
  111. class: "mdc-card",
  112. $components:[
  113. {
  114. $cell: true,
  115. $type: "div",
  116. class: "mdc-card__horizontal-block",
  117. $components:[
  118. {
  119. $cell: true,
  120. $type: "section",
  121. class: "mdc-card__primary",
  122. $components:[
  123. {
  124. $cell: true,
  125. $type: "h1",
  126. class: "mdc-card__title mdc-card__title--large",
  127. $text: obj.title
  128. },
  129. {
  130. $cell: true,
  131. $type: "h2",
  132. class: "mdc-card__subtitle",
  133. $text: obj.subTitle
  134. }
  135. ]
  136. },
  137. {
  138. $cell: true,
  139. $type: "img",
  140. class: "",
  141. src: obj.imgSrc
  142. }
  143. ]
  144. },
  145. {
  146. $cell: true,
  147. $type: "section",
  148. class: "mdc-card__actions",
  149. $components:[
  150. {
  151. $cell: true,
  152. $type: "button",
  153. class: "mdc-button mdc-button--compact mdc-card__action",
  154. $text: obj.actionLabel
  155. }
  156. ]
  157. }
  158. ]
  159. }
  160. ]
  161. }
  162. }
  163. buttonStroked(obj){
  164. return {
  165. $cell: true,
  166. $type: "button",
  167. class: "mdc-button mdc-button--outlined",
  168. $text: obj.label,
  169. onclick: obj.onclick
  170. }
  171. }
  172. buttonRaised(obj){
  173. return {
  174. $cell: true,
  175. $type: "button",
  176. class: "mdc-button mdc-button--raised mdc-ripple-upgraded",
  177. $text: obj.label,
  178. onclick: obj.onclick
  179. }
  180. }
  181. buttonSimple(obj){
  182. return {
  183. $cell: true,
  184. $type: "button",
  185. class: "mdc-button",
  186. $text: obj.label,
  187. onclick: obj.onclick
  188. }
  189. }
  190. sliderDiscrete(obj) {
  191. return {
  192. $cell: true,
  193. $type: "div",
  194. class: "mdc-slider mdc-slider--discrete",
  195. role: "slider",
  196. 'aria-valuemin': obj.min,
  197. 'aria-valuemax': obj.max,
  198. 'aria-label': obj.label,
  199. $init: obj.init,
  200. $components: [
  201. {
  202. $cell: true,
  203. $type: "div",
  204. class: "mdc-slider__track-container",
  205. $components: [
  206. {
  207. $cell: true,
  208. $type: "div",
  209. class: "mdc-slider__track",
  210. }
  211. ]
  212. },
  213. {
  214. $cell: true,
  215. $type: "div",
  216. class: "mdc-slider__thumb-container",
  217. $components: [
  218. {
  219. $cell: true,
  220. $type: "div",
  221. class: "mdc-slider__pin",
  222. $components: [
  223. {
  224. $cell: true,
  225. $type: "span",
  226. class: "mdc-slider__pin-value-marker",
  227. }
  228. ]
  229. },
  230. {
  231. $cell: true,
  232. $type: "svg",
  233. class: "mdc-slider__thumb",
  234. width: 21,
  235. height: 21,
  236. $components: [
  237. {
  238. $cell: true,
  239. $type: "circle",
  240. cx: 10.5,
  241. cy: 10.5,
  242. r: 7.875
  243. }
  244. ]
  245. },
  246. {
  247. $cell: true,
  248. $type: "div",
  249. class: "mdc-slider__focus-ring"
  250. }
  251. ]
  252. }
  253. ]
  254. }
  255. }
  256. sliderContinuous(obj) {
  257. return {
  258. $cell: true,
  259. $type: "div",
  260. class: "mdc-slider",
  261. role: "slider",
  262. tabindex: 0,
  263. 'id': obj.id,
  264. 'aria-valuemin': obj.min,
  265. 'aria-valuemax': obj.max,
  266. 'aria-label': obj.label,
  267. 'aria-valuenow': obj.value,
  268. 'data-step': obj.step,
  269. $init: obj.init,
  270. $components: [
  271. {
  272. $cell: true,
  273. $type: "div",
  274. class: "mdc-slider__track-container",
  275. $components: [
  276. {
  277. $cell: true,
  278. $type: "div",
  279. class: "mdc-slider__track",
  280. }
  281. ]
  282. },
  283. {
  284. $cell: true,
  285. $type: "div",
  286. class: "mdc-slider__thumb-container",
  287. $components: [
  288. {
  289. $cell: true,
  290. $type: "svg",
  291. class: "mdc-slider__thumb",
  292. width: 21,
  293. height: 21,
  294. $components: [
  295. {
  296. $cell: true,
  297. $type: "circle",
  298. cx: 10.5,
  299. cy: 10.5,
  300. r: 7.875
  301. }
  302. ]
  303. },
  304. {
  305. $cell: true,
  306. $type: "div",
  307. class: "mdc-slider__focus-ring"
  308. }
  309. ]
  310. }
  311. ]
  312. }
  313. }
  314. textField(obj) {
  315. return {
  316. class: "mdc-text-field",
  317. style: "width: 100%",
  318. $cell: true,
  319. $type: "div",
  320. $components: [
  321. {
  322. class: "mdc-text-field__input prop-text-field-input",
  323. id: obj.id,
  324. $cell: true,
  325. $type: "input",
  326. type: "text",
  327. value: obj.value,
  328. onchange: obj.funconchange
  329. }
  330. ]
  331. }
  332. }
  333. icontoggle(obj) {
  334. var addClass = "";
  335. if (obj.styleClass){
  336. addClass = obj.styleClass;
  337. }
  338. return {
  339. $type: "i",
  340. class: addClass + " mdc-icon-toggle material-icons",
  341. role: "button",
  342. $text: obj.label,
  343. id: obj.id,
  344. 'data-toggle-on': obj.on,
  345. 'data-toggle-off': obj.off,
  346. 'aria-pressed': obj.state,
  347. 'aria-hidden': true,
  348. $init: obj.init
  349. }
  350. }
  351. floatActionButton(obj) {
  352. var addClass = "";
  353. if (obj.styleClass){
  354. addClass = obj.styleClass;
  355. }
  356. return {
  357. $cell: true,
  358. $type: "button",
  359. class: "mdc-fab material-icons " + addClass,
  360. onclick: obj.onclickfunc,
  361. $components:[
  362. {
  363. $cell: true,
  364. $type: "span",
  365. class: "mdc-fab__icon",
  366. $text: obj.label
  367. }
  368. ]
  369. }
  370. }
  371. iconButton(obj) {
  372. var addClass = "";
  373. if (obj.styleClass){
  374. addClass = obj.styleClass;
  375. }
  376. return {
  377. $cell: true,
  378. $type: "button",
  379. class: "mdc-button" + addClass,
  380. onclick: obj.onclickfunc,
  381. $components:[
  382. {
  383. $cell: true,
  384. $type: "i",
  385. class: "material-icons mdc-button__icon",
  386. $text: obj.label
  387. }
  388. ]
  389. }
  390. }
  391. imageButton(obj){
  392. return {
  393. $cell: true,
  394. $type: "button",
  395. class: "mdc-button mdc-button--compact",
  396. onclick: obj.onclickfunc,
  397. $components:[
  398. {
  399. $cell: true,
  400. class: obj.styleClass,
  401. $type: "img",
  402. src: obj.imgSrc
  403. }
  404. ]
  405. }
  406. }
  407. gridListItem(obj) {
  408. return {
  409. $cell: true,
  410. $type: "li",
  411. class: "mdc-grid-tile " + obj.styleClass,
  412. $components:[
  413. {
  414. $cell: true,
  415. class: "mdc-grid-tile__primary",
  416. $type: "div",
  417. style: "background-color: transparent;",
  418. $components:[
  419. {
  420. $cell: true,
  421. class: "mdc-grid-tile__primary-content tooltip",
  422. $type: "div",
  423. 'aria-label': obj.title,
  424. alt: obj.title,
  425. style: "background-image: url("+ obj.imgSrc + ");",
  426. onclick: obj.onclickfunc,
  427. $components:[
  428. {
  429. $cell: true,
  430. class: "tooltiptext",
  431. $type: "span",
  432. $text: obj.title
  433. }
  434. ]
  435. }
  436. ]
  437. }
  438. ]
  439. }
  440. }
  441. switch(obj) {
  442. return {
  443. $cell: true,
  444. $type: "div",
  445. class: "mdc-switch",
  446. $components: [
  447. {
  448. $type: "div",
  449. class: "mdc-switch__track",
  450. },
  451. {
  452. $type: "div",
  453. class: "mdc-switch__thumb-underlay",
  454. $components:[
  455. {
  456. $type: "div",
  457. class: "mdc-switch__thumb",
  458. $components:[
  459. {
  460. $type: "input",
  461. type: "checkbox",
  462. class: "mdc-switch__native-control",
  463. id: obj.id,
  464. $init: obj.init,
  465. //id: "basic-switch",
  466. onchange: obj.onchange,
  467. role: "switch"
  468. }
  469. ]
  470. }
  471. ]
  472. }
  473. // {
  474. // $type: "div",
  475. // class: "mdc-switch__background",
  476. // $components: [
  477. // {
  478. // $type: "div",
  479. // class: "mdc-switch__knob"
  480. // }
  481. // ]
  482. // }
  483. ]
  484. }
  485. }
  486. }
  487. export { Widgets }