--- 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 <element> (resp. doesn't) matches <properties>
- */
-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<link.childNodes.length; i++) {
-// var node = link.childNodes[i];
-// if (isTextNode(node)) {
-// swapDOM(node, document.createTextNode(newText));
-// break;
-// }
-// }
}
@@ -248,6 +237,7 @@
}
}
+// XXX this looks unused
function limitTextAreaSize(textarea, size) {
var $area = jQuery(textarea);
$area.val($area.val().slice(0, size));
@@ -257,22 +247,19 @@
CubicWeb.rounded = [
['div.sideBoxBody', 'bottom 6px'],
- ['div.boxTitle, div.boxPrefTitle, div.sideBoxTitle, th.month', 'top 6px'],
+ ['div.boxTitle, div.boxPrefTitle, div.sideBoxTitle, th.month', 'top 6px']
];
-function roundedCornersOnLoad() {
- roundedCorners();
-}
+
function roundedCorners(node) {
- node == node || document.body;
node = jQuery(node);
- for(var r=0; r<CubicWeb.rounded.length;r++){
+ for(var r=0; r < CubicWeb.rounded.length; r++) {
node.find(CubicWeb.rounded[r][0]).corner(CubicWeb.rounded[r][1]);
}
}
-jQuery(document).ready(roundedCornersOnLoad);
+jQuery(document).ready(function () {roundedCorners(this.body)});
CubicWeb.provide('htmlhelpers.js');
--- a/web/formfields.py Thu Jul 09 16:15:22 2009 +0200
+++ b/web/formfields.py Thu Jul 09 16:15:52 2009 +0200
@@ -203,8 +203,6 @@
widget = Select()
elif self.max_length and self.max_length < 257:
widget = TextInput()
- widget.attrs.setdefault('size', min(45, self.max_length))
- widget.attrs.setdefault('maxlength', self.max_length)
super(StringField, self).init_widget(widget)
if isinstance(self.widget, TextArea):
--- a/web/formwidgets.py Thu Jul 09 16:15:22 2009 +0200
+++ b/web/formwidgets.py Thu Jul 09 16:15:52 2009 +0200
@@ -89,6 +89,13 @@
"""<input type='text'>"""
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):
"""<input type='password'> and its confirmation field (using