This repo contains code to mirror other repos. It also contains the code that is getting mirrored.
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

187 linhas
4.7 KiB

  1. # -*- coding: utf-8 -*-
  2. from . import core as html5
  3. @html5.tag
  4. class Label(html5.Label):
  5. _parserTagName = "ignite-label"
  6. def __init__(self, *args, **kwargs):
  7. super(Label, self).__init__(style="label ignt-label", *args, **kwargs)
  8. @html5.tag
  9. class Input(html5.Input):
  10. _parserTagName = "ignite-input"
  11. def __init__(self, *args, **kwargs):
  12. super(Input, self).__init__(style="input ignt-input", *args, **kwargs)
  13. @html5.tag
  14. class Switch(html5.Div):
  15. _parserTagName = "ignite-switch"
  16. def __init__(self, *args, **kwargs):
  17. super(Switch, self).__init__(style="switch ignt-switch", *args, **kwargs)
  18. self.input = html5.Input(style="switch-input")
  19. self.appendChild(self.input)
  20. self.input["type"] = "checkbox"
  21. switchLabel = html5.Label(forElem=self.input)
  22. switchLabel.addClass("switch-label")
  23. self.appendChild(switchLabel)
  24. def _setChecked(self, value):
  25. self.input["checked"] = bool(value)
  26. def _getChecked(self):
  27. return self.input["checked"]
  28. @html5.tag
  29. class Check(html5.Input):
  30. _parserTagName = "ignite-check"
  31. def __init__(self, *args, **kwargs):
  32. super(Check, self).__init__(style="check ignt-check", *args, **kwargs)
  33. checkInput = html5.Input()
  34. checkInput.addClass("check-input")
  35. checkInput["type"] = "checkbox"
  36. self.appendChild(checkInput)
  37. checkLabel = html5.Label(forElem=checkInput)
  38. checkLabel.addClass("check-label")
  39. self.appendChild(checkLabel)
  40. @html5.tag
  41. class Radio(html5.Div):
  42. _parserTagName = "ignite-radio"
  43. def __init__(self, *args, **kwargs):
  44. super(Radio, self).__init__(style="radio ignt-radio", *args, **kwargs)
  45. radioInput = html5.Input()
  46. radioInput.addClass("radio-input")
  47. radioInput["type"] = "radio"
  48. self.appendChild(radioInput)
  49. radioLabel = html5.Label(forElem=radioInput)
  50. radioLabel.addClass("radio-label")
  51. self.appendChild(radioLabel)
  52. @html5.tag
  53. class Select(html5.Select):
  54. _parserTagName = "ignite-select"
  55. def __init__(self, *args, **kwargs):
  56. super(Select, self).__init__(style="select ignt-select", *args, **kwargs)
  57. defaultOpt = html5.Option()
  58. defaultOpt["selected"] = True
  59. defaultOpt["disabled"] = True
  60. defaultOpt.element.innerHTML = ""
  61. self.appendChild(defaultOpt)
  62. @html5.tag
  63. class Textarea(html5.Textarea):
  64. _parserTagName = "ignite-textarea"
  65. def __init__(self, *args, **kwargs):
  66. super(Textarea, self).__init__(style="textarea ignt-textarea", *args, **kwargs)
  67. @html5.tag
  68. class Progress(html5.Progress):
  69. _parserTagName = "ignite-progress"
  70. def __init__(self, *args, **kwargs):
  71. super(Progress, self).__init__(style="progress ignt-progress", *args, **kwargs)
  72. @html5.tag
  73. class Item(html5.Div):
  74. _parserTagName = "ignite-item"
  75. def __init__(self, title=None, descr=None, className=None, *args, **kwargs):
  76. super(Item, self).__init__(style="item ignt-item", *args, **kwargs)
  77. if className:
  78. self.addClass(className)
  79. self.fromHTML("""
  80. <div class="item-image ignt-item-image" [name]="itemImage">
  81. </div>
  82. <div class="item-content ignt-item-content" [name]="itemContent">
  83. <div class="item-headline ignt-item-headline" [name]="itemHeadline">
  84. </div>
  85. </div>
  86. """)
  87. if title:
  88. self.itemHeadline.appendChild(html5.TextNode(title))
  89. if descr:
  90. self.itemSubline = html5.Div()
  91. self.addClass("item-subline ignt-item-subline")
  92. self.itemSubline.appendChild(html5.TextNode(descr))
  93. self.appendChild(self.itemSubline)
  94. @html5.tag
  95. class Table(html5.Table):
  96. _parserTagName = "ignite-table"
  97. def __init__(self, *args, **kwargs):
  98. super(Table, self).__init__(*args, **kwargs)
  99. self.head.addClass("ignt-table-head")
  100. self.body.addClass("ignt-table-body")
  101. def prepareRow(self, row):
  102. assert row >= 0, "Cannot create rows with negative index"
  103. for child in self.body._children:
  104. row -= child["rowspan"]
  105. if row < 0:
  106. return
  107. while row >= 0:
  108. tableRow = html5.Tr()
  109. tableRow.addClass("ignt-table-body-row")
  110. self.body.appendChild(tableRow)
  111. row -= 1
  112. def prepareCol(self, row, col):
  113. assert col >= 0, "Cannot create cols with negative index"
  114. self.prepareRow(row)
  115. for rowChild in self.body._children:
  116. row -= rowChild["rowspan"]
  117. if row < 0:
  118. for colChild in rowChild._children:
  119. col -= colChild["colspan"]
  120. if col < 0:
  121. return
  122. while col >= 0:
  123. tableCell = html5.Td()
  124. tableCell.addClass("ignt-table-body-cell")
  125. rowChild.appendChild(tableCell)
  126. col -= 1
  127. return
  128. def fastGrid( self, rows, cols, createHidden=False ):
  129. colsstr = "".join(['<td class="ignt-table-body-cell"></td>' for i in range(0, cols)])
  130. tblstr = '<tbody [name]="body" class="ignt-table-body" >'
  131. for r in range(0, rows):
  132. tblstr += '<tr class="ignt-table-body-row %s">%s</tr>' %("is-hidden" if createHidden else "",colsstr)
  133. tblstr +="</tbody>"
  134. self.fromHTML(tblstr)