Package library :: Package pyjamas :: Package ui :: Module TextBox
[hide private]
[frames] | no frames]

Source Code for Module library.pyjamas.ui.TextBox

  1  # Copyright 2006 James Tauber and contributors 
  2  # Copyright (C) 2009 Luke Kenneth Casson Leighton <lkcl@lkcl.net> 
  3  # Copyright (C) 2012 Vsevolod Fedorov <vsevolod.fedorov@gmail.com> 
  4  # 
  5  # Licensed under the Apache License, Version 2.0 (the "License"); 
  6  # you may not use this file except in compliance with the License. 
  7  # You may obtain a copy of the License at 
  8  # 
  9  #     http://www.apache.org/licenses/LICENSE-2.0 
 10  # 
 11  # Unless required by applicable law or agreed to in writing, software 
 12  # distributed under the License is distributed on an "AS IS" BASIS, 
 13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 14  # See the License for the specific language governing permissions and 
 15  # limitations under the License. 
 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):
53 return TextBoxBase._getProps() + self._props
54
55 - def getMaxLength(self):
56 return DOM.getIntAttribute(self.getElement(), "maxLength")
57
58 - def getKind(self):
59 return DOM.getAttribute(self.getElement(), "type")
60
61 - def getMin(self):
62 return DOM.getAttribute(self.getElement(), "min")
63
64 - def getMax(self):
65 return DOM.getAttribute(self.getElement(), "max")
66
67 - def getPlaceholder(self):
68 return DOM.getAttribute(self.getElement(), "placeholder")
69
70 - def getStep(self):
71 return DOM.getAttribute(self.getElement(), "step")
72
73 - def getVisibleLength(self):
74 return DOM.getIntAttribute(self.getElement(), "size")
75
76 - def setMaxLength(self, length):
77 DOM.setIntAttribute(self.getElement(), "maxLength", length)
78
79 - def setKind(self, kind):
80 DOM.setAttribute(self.getElement(), "type", 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):
95 DOM.setIntAttribute(self.getElement(), "size", length)
96 97 98 Factory.registerClass('pyjamas.ui.TextBox', 'TextBox', TextBox) 99