def insertComponentDescription(self, div): # Description if self.description: description = Element('div', { 'id':self.id+'-description', 'class':self.descriptionClass }) description.update(self.description) div.insert(description) return div
def insertComponentTip(self, div): # Create the tip div if not empty if self.tip: tipDiv = Element('div', { 'id':self.id+'-tip', 'style':'display: none', 'class':self.tipClass, }) tipDiv.update(self.tip) div.insert(tipDiv) return div
def __str__(self): # Generate the component div div = self.generateComponentDiv() # Add the input tag textArea = Element('textarea', { 'id':self.id, 'name':self.name, 'class':self.inputClass}) if self.width: if self.width in self.widthArray.keys(): textArea.setAttribute('style', 'width: '+self.widthArray[self.width]+'') else: textArea.setAttribute('style', 'width: '+str(self.width)+'') if self.height: if self.height in self.heightArray.keys(): textArea.addToAttribute('style', 'height: '+self.heightArray[self.height]+'') else: textArea.addToAttribute('style', 'height: '+str(self.height)+'') if self.style: textArea.addToAttribute('style', self.style) if self.disabled: textArea.setAttribute('disabled', 'disabled') if self.readOnly: textArea.setAttribute('readonly', 'readonly') if self.wrap: textArea.setAttribute('wrap', self.wrap) if self.initialValue: textArea.update(self.initialValue) div.insert(textArea) # Add any description (optional) div = self.insertComponentDescription(div) # Add a tip (optional) div = self.insertComponentTip(div) return div.__str__()
def generateComponentLabel(self): if self.label == None: return '' label = Element('label', { 'id':self.id+'-label', 'for':self.id, 'class':self.labelClass }) label.update(self.label) # Add the required star to the label if 'required' in self.validationOptions: labelRequiredStarSpan = Element('span', {'class':self.labelRequiredStarClass}) labelRequiredStarSpan.update(self.requiredText) label.insert(labelRequiredStarSpan) return label