# HG changeset patch # User Sylvain Thénault # Date 1247148952 -7200 # Node ID d78cf458670772ec0eac036abd93b51458f2d005 # Parent 9b4bac626977c7d8bc4a0c58ac2206d5f633c665# Parent fc79633402573a20300752de25f9b2d53ac1921a merge diff -r 9b4bac626977 -r d78cf4586707 web/data/cubicweb.htmlhelpers.js --- a/web/data/cubicweb.htmlhelpers.js Thu Jul 09 16:15:22 2009 +0200 +++ b/web/data/cubicweb.htmlhelpers.js Thu Jul 09 16:15:52 2009 +0200 @@ -16,6 +16,7 @@ return ''; } +// XXX this is used exactly ONCE in web/views/massmailing.py function insertText(text, areaId) { var textarea = jQuery('#' + areaId); if (document.selection) { // IE @@ -40,6 +41,7 @@ } /* taken from dojo toolkit */ +// XXX this looks unused function setCaretPos(element, start, end){ if(!end){ end = element.value.length; } // NOTE: Strange - should be able to put caret at start of text? // Mozilla @@ -72,30 +74,30 @@ } } + +// XXX this looks unused function setProgressMessage(label) { var body = document.getElementsByTagName('body')[0]; body.appendChild(DIV({id: 'progress'}, label)); jQuery('#progress').show(); } +// XXX this looks unused function resetProgressMessage() { var body = document.getElementsByTagName('body')[0]; jQuery('#progress').hide(); } -/* set body's cursor to 'progress' - */ +/* set body's cursor to 'progress' */ function setProgressCursor() { var body = document.getElementsByTagName('body')[0]; body.style.cursor = 'progress'; } -/* - * reset body's cursor to default (mouse cursor). The main +/* reset body's cursor to default (mouse cursor). The main * purpose of this function is to be used as a callback in the - * deferreds' callbacks chain. - */ + * deferreds' callbacks chain. */ function resetCursor(result) { var body = document.getElementsByTagName('body')[0]; body.style.cursor = 'default'; @@ -138,7 +140,7 @@ */ function firstSelected(selectNode) { var selection = filter(attrgetter('selected'), selectNode.options); - return (selection.length>0) ? getNodeAttribute(selection[0], 'value'):null; + return (selection.length > 0) ? getNodeAttribute(selection[0], 'value'):null; } /* toggle visibility of an element by its id @@ -149,22 +151,12 @@ /* toggles visibility of login popup div */ +// XXX used exactly ONCE function popupLoginBox() { toggleVisibility('popupLoginBox'); jQuery('#__login:visible').focus(); } -/* - * return true (resp. false) if (resp. doesn't) matches - */ -function elementMatches(properties, element) { - for (prop in properties) { - if (getNodeAttribute(element, prop) != properties[prop]) { - return false; - } - } - return true; -} /* returns the list of elements in the document matching the tag name * and the properties provided @@ -175,9 +167,13 @@ * list() function) */ function getElementsMatching(tagName, properties, /* optional */ parent) { - var filterfunc = partial(elementMatches, properties); parent = parent || document; - return filter(filterfunc, parent.getElementsByTagName(tagName)); + return filter(function elementMatches(element) { + for (prop in properties) { + if (getNodeAttribute(element, prop) != properties[prop]) { + return false;}} + return true;}, + parent.getElementsByTagName(tagName)); } /* @@ -197,9 +193,8 @@ forEach(filter(filterfunc, elements), function(cb) {cb.checked=checked;}); } -/* - * centers an HTML element on the screen - */ +/* centers an HTML element on the screen */ +// XXX looks unused function centerElement(obj){ var vpDim = getViewportDimensions(); var elemDim = getElementDimensions(obj); @@ -228,15 +223,9 @@ function isTextNode(domNode) { return domNode.nodeType == 3; } function isElementNode(domNode) { return domNode.nodeType == 1; } +// XXX this looks unused function changeLinkText(link, newText) { jQuery(link).text(newText); -// for (var i=0; i""" type = 'text' + def render(self, form, field): + if hasattr(field, 'max_length') and field.max_length: + self.attrs.setdefault('size', min(45, field.max_length)) + self.attrs.setdefault('maxlength', field.max_length) + return super(TextInput, self).render(form, field) + + class PasswordInput(Input): """ and its confirmation field (using