r13377 - in Products.Archetypes/branches/1.6: . Products/Archetypes Products/Archetypes/skins/archetypes/widgets Products/Archetypes/skins/archetypes/widgets/js

"Tom Gross" <[email protected]>
Newsgroups gmane.comp.web.zope.plone.archetypes.cvs
Message-ID <[email protected]>
Author: tom_gross
Date: Mon Dec 20 13:41:19 2010
New Revision: 13377

Modified:
   Products.Archetypes/branches/1.6/   (props changed)
   Products.Archetypes/branches/1.6/Products/Archetypes/   (props changed)
   Products.Archetypes/branches/1.6/Products/Archetypes/skins/archetypes/widgets/js/textcount.js
   Products.Archetypes/branches/1.6/Products/Archetypes/skins/archetypes/widgets/textarea.pt
Log:
merged -r13374:13376 from trunk


Modified: Products.Archetypes/branches/1.6/Products/Archetypes/skins/archetypes/widgets/js/textcount.js
==============================================================================
--- Products.Archetypes/branches/1.6/Products/Archetypes/skins/archetypes/widgets/js/textcount.js	(original)
+++ Products.Archetypes/branches/1.6/Products/Archetypes/skins/archetypes/widgets/js/textcount.js	Mon Dec 20 13:41:19 2010
@@ -2,18 +2,12 @@
 <!-- Dynamic 'fix' by: Nannette Thacker -->
 
 function textCounter(field, countfield, maxlimit) {
-
-	if (field.value.length > maxlimit) {
-	
-		// if too long...trim it!
-		field.value = field.value.substring(0, maxlimit);
-		
-        alert( 'This field is limited to ' + maxlimit + ' characters in length.' );
-        		
-	} else {
-	
-		// otherwise, update 'characters left' counter	
-		countfield.value = maxlimit - field.value.length;
-		
-	}
-}
\ No newline at end of file
+  var fieldval = jq(field).attr('value');
+  if (fieldval.length > maxlimit) {
+      // if too long...trim it!
+      jq(field).attr('value',  fieldval.substring(0, maxlimit));
+      alert( 'This field is limited to ' + maxlimit + ' characters in length.' );
+  } 
+  // update 'characters left' counter	
+  jq('input[name="' + countfield + '"]').attr('value', Math.max(maxlimit - fieldval.length, 0));
+}

Modified: Products.Archetypes/branches/1.6/Products/Archetypes/skins/archetypes/widgets/textarea.pt
==============================================================================
--- Products.Archetypes/branches/1.6/Products/Archetypes/skins/archetypes/widgets/textarea.pt	(original)
+++ Products.Archetypes/branches/1.6/Products/Archetypes/skins/archetypes/widgets/textarea.pt	Mon Dec 20 13:41:19 2010
@@ -30,8 +30,8 @@
                   content python: not not base and value.getRaw() or value;
                   content python: not binary and content or '';
                   content_length python:len(content);
-                  append_only python: getattr(widget, 'append_only', None);
-                  maxlength python: getattr(widget, 'maxlength', None);
+                  append_only widget/append_only|nothing;
+                  maxlength widget/maxlength|nothing;
                   keypress string:textCounter(this, this.form.textCounter_${fieldName}, ${maxlength});">
 
         <textarea
@@ -54,12 +54,9 @@
                        size="4"
                        value=""
                        i18n:name="count"
-                       tal:define="remaining python:(int(maxlength) - content_length) + content.count('\n');
-                                   inputsize string:4"
+                       tal:define="remaining python:(int(maxlength) - content_length) + content.count('\n')"
                        tal:attributes="name string:textCounter_${fieldName};
                                        value remaining;
-                                       maxlength inputsize;
-                                       size inputsize;
                                        id string:maxlength_${fieldName};" />
                 characters remaining
             </div>

------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.