widgets.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. 'use strict';
  2. define(function () {
  3. /*
  4. * Cell widgets
  5. */
  6. class Widgets {
  7. constructor() {
  8. console.log("widget constructor")
  9. }
  10. get divider(){
  11. return {
  12. $cell: true,
  13. $type: "hr",
  14. class: "mdc-list-divider",
  15. }
  16. }
  17. headerH3(headertype, label, cssclass) {
  18. return {
  19. $cell: true,
  20. $type: headertype,
  21. class: cssclass,
  22. $text: label
  23. }
  24. }
  25. icontoggle(obj) {
  26. return {
  27. $cell: true,
  28. $type: "i",
  29. class: "mdc-icon-toggle material-icons",
  30. role: "button",
  31. $text: obj.label,
  32. id: obj.id,
  33. 'data-toggle-on': obj.on,
  34. 'data-toggle-off': obj.off,
  35. 'aria-pressed': obj.state,
  36. //'aria-hidden': true,
  37. $init: obj.init
  38. }
  39. }
  40. switch(obj) {
  41. return {
  42. $cell: true,
  43. $type: "div",
  44. class: "mdc-switch",
  45. $components: [
  46. {
  47. $type: "input",
  48. type: "checkbox",
  49. class: "mdc-switch__native-control",
  50. id: obj.id,
  51. $init: obj.init,
  52. //id: "basic-switch",
  53. onchange: obj.onchange
  54. },
  55. {
  56. $type: "div",
  57. class: "mdc-switch__background",
  58. $components: [
  59. {
  60. $type: "div",
  61. class: "mdc-switch__knob"
  62. }
  63. ]
  64. }
  65. ]
  66. }
  67. }
  68. }
  69. return new Widgets;
  70. })