[Jifty-commit] jifty branch, master, updated. 1.10518-33-gd9985e5

Jifty commits jifty-commit at lists.jifty.org
Fri Jun 24 14:53:12 EDT 2011


The branch, master has been updated
       via  d9985e531f5d66a7adb012ade943de4c8c75dbed (commit)
       via  0916fd3bb044978b6da587a4d11e94d826e0d5e3 (commit)
      from  28d51a14e4b334f0a2e6bb487c53c7a098abe64f (commit)

Summary of changes:
 share/web/static/js/jifty.js |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

- Log -----------------------------------------------------------------
commit 0916fd3bb044978b6da587a4d11e94d826e0d5e3
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Jun 24 14:48:20 2011 -0400

    Refactor the placeholder onblur handler so it can be called separately
    
    We already store the placeholder text in the DOM and use it for clearing
    placeholders, so we might as well do the same for replacing them.  This
    means external code can call replacePlaceholder directly if needed.

diff --git a/share/web/static/js/jifty.js b/share/web/static/js/jifty.js
index 5279837..b48cf4c 100644
--- a/share/web/static/js/jifty.js
+++ b/share/web/static/js/jifty.js
@@ -1872,13 +1872,7 @@ jQuery.extend(Jifty.Placeholder.prototype, {
   },
 
   onBlur: function() {
-     /* On browser back/forward, the placeholder text will be remembered
-        for the field, so we want to add the class if the value is the same
-        as the placeholder text.  This does have the effect of making it
-        impossible to submit a field with the same value as the placeholder. */
-     if (this.element.value == '' || this.element.value == this.text) {
-         jQuery(this.element).addClass('placeholder').val(this.text);
-     }
+    Jifty.Placeholder.replacePlaceholder(this.element);
   },
 
   onFocus: function() {
@@ -1892,6 +1886,16 @@ jQuery.extend(Jifty.Placeholder, {
        return jQuery(elt).hasClass('placeholder');
   },
 
+  replacePlaceholder: function(elt) {
+     /* On browser back/forward, the placeholder text will be remembered
+        for the field, so we want to add the class if the value is the same
+        as the placeholder text.  This does have the effect of making it
+        impossible to submit a field with the same value as the placeholder. */
+     if (elt.value == '' || elt.value == elt.placeholderText) {
+         jQuery(elt).addClass('placeholder').val(elt.placeholderText);
+     }
+  },
+
   clearPlaceholder: function(elt) {
      // If the element's text isn't the same as its placeholder text, then the
      // browser screwed up and didn't clear our placeholder. Opera on Mac with

commit d9985e531f5d66a7adb012ade943de4c8c75dbed
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Jun 24 14:50:36 2011 -0400

    Clear placeholders before we serialize a form
    
    Otherwise placeholders can sneak into ajax canonicalization and
    validation which serialize() but don't trigger the onsubmit hook that
    normally clears placeholders.

diff --git a/share/web/static/js/jifty.js b/share/web/static/js/jifty.js
index b48cf4c..7077909 100644
--- a/share/web/static/js/jifty.js
+++ b/share/web/static/js/jifty.js
@@ -175,7 +175,9 @@ Action.prototype = {
         var serialized = new Array;
 
         jQuery.each(fields, function() {
+            Jifty.Placeholder.clearPlaceholder(this);
             serialized.push( jQuery(this).serialize() )
+            Jifty.Placeholder.replacePlaceholder(this);
         });
 
         return serialized.join('&');

-----------------------------------------------------------------------


More information about the Jifty-commit mailing list