1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 from pyjamas import DOM
17 from pyjamas import Factory
18
19 from pyjamas.ui.TextBoxBase import TextBoxBase
20
21 -class TextBox(TextBoxBase):
22 '''
23 Use Kind to set a HTML5 type
24
25 Attributes supported:
26
27 * Kind
28 * MaxLength
29 * Min
30 * Max
31 * Placeholder
32 * Required
33 * Step
34 * VisibleLength
35 '''
36
37 _props = [("kind", "Kind", "Kind", None),
38 ("maxLength", "Max Length", "MaxLength", None),
39 ("min", "Min", "Min", None),
40 ("max", "Max", "Max", None),
41 ("placeholder", "Place Holder", "PlaceHolder", None),
42 ("step", "Step", "Step", None),
43 ("visibleLength", "Visible Length", "VisibleLength", None),
44 ]
45
46 - def __init__(self, **ka):
47 ka['StyleName'] = ka.get('StyleName', "gwt-TextBox")
48 element = ka.pop('Element', None) or DOM.createInputText()
49 TextBoxBase.__init__(self, element, **ka)
50
51 @classmethod
52 - def _getProps(self):
54
55 - def getMaxLength(self):
56 return DOM.getIntAttribute(self.getElement(), "maxLength")
57
59 return DOM.getAttribute(self.getElement(), "type")
60
62 return DOM.getAttribute(self.getElement(), "min")
63
65 return DOM.getAttribute(self.getElement(), "max")
66
67 - def getPlaceholder(self):
68 return DOM.getAttribute(self.getElement(), "placeholder")
69
71 return DOM.getAttribute(self.getElement(), "step")
72
74 return DOM.getIntAttribute(self.getElement(), "size")
75
76 - def setMaxLength(self, length):
78
79 - def setKind(self, kind):
81
82 - def setMin(self, min):
83 DOM.setAttribute(self.getElement(), "min", min)
84
85 - def setMax(self, max):
86 DOM.setAttribute(self.getElement(), "max", max)
87
88 - def setPlaceholder(self, placeholder):
89 DOM.setAttribute(self.getElement(), "placeholder", placeholder)
90
91 - def setStep(self, step):
92 DOM.setAttribute(self.getElement(), "step", step)
93
94 - def setVisibleLength(self, length):
96
97
98 Factory.registerClass('pyjamas.ui.TextBox', 'TextBox', TextBox)
99