[Jifty-commit] r1654 - in jifty/trunk: share/web/static/js
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Mon Jul 24 12:38:07 EDT 2006
Author: trs
Date: Mon Jul 24 12:38:06 2006
New Revision: 1654
Modified:
jifty/trunk/ (props changed)
jifty/trunk/share/web/static/js/jifty.js
Log:
r14612 at zot: tom | 2006-07-21 12:21:50 -0400
* Fix placeholders on browser forward/back
* Replace hard tabs with spaces for consistency
Modified: jifty/trunk/share/web/static/js/jifty.js
==============================================================================
--- jifty/trunk/share/web/static/js/jifty.js (original)
+++ jifty/trunk/share/web/static/js/jifty.js Mon Jul 24 12:38:06 2006
@@ -38,38 +38,38 @@
// Returns an Array of all fields in this Action
fields: function() {
- if(!this.cached_fields) {
- var elements = new Array;
- var possible = Form.getElements(this.form);
- // Also pull from extra query parameters
- for (var i = 0; i < this.extras.length; i++)
- possible.push(this.extras[i]);
-
- for (var i = 0; i < possible.length; i++) {
- if (Form.Element.getMoniker(possible[i]) == this.moniker)
- elements.push(possible[i]);
- }
- this.cached_fields = elements;
- }
+ if(!this.cached_fields) {
+ var elements = new Array;
+ var possible = Form.getElements(this.form);
+ // Also pull from extra query parameters
+ for (var i = 0; i < this.extras.length; i++)
+ possible.push(this.extras[i]);
+
+ for (var i = 0; i < possible.length; i++) {
+ if (Form.Element.getMoniker(possible[i]) == this.moniker)
+ elements.push(possible[i]);
+ }
+ this.cached_fields = elements;
+ }
return this.cached_fields;
},
buttons: function() {
- var elements = new Array();
- var possible = Form.getElements(this.form);
- for(var i = 0; i < possible.length; i++) {
- if(possible[i].nodeName == 'INPUT' && possible[i].getAttribute("type") == 'submit') {
- actions = Form.Element.buttonActions(possible[i]);
- //If the button has no actions explicitly associated
- //with it, it's associated with all the actions in the
- //form
- if( actions.length == 0
- || actions.indexOf(this.moniker) >= 0) {
- elements.push(possible[i]);
- }
- }
- }
- return elements;
+ var elements = new Array();
+ var possible = Form.getElements(this.form);
+ for(var i = 0; i < possible.length; i++) {
+ if(possible[i].nodeName == 'INPUT' && possible[i].getAttribute("type") == 'submit') {
+ actions = Form.Element.buttonActions(possible[i]);
+ //If the button has no actions explicitly associated
+ //with it, it's associated with all the actions in the
+ //form
+ if( actions.length == 0
+ || actions.indexOf(this.moniker) >= 0) {
+ elements.push(possible[i]);
+ }
+ }
+ }
+ return elements;
},
getField: function(name) {
@@ -114,15 +114,16 @@
var f = fields[i];
if ( (Form.Element.getType(f) != "registration")
- && (Form.Element.getValue(f) != null)
- && (!Jifty.Placeholder.hasPlaceholder(f))) {
+ && (Form.Element.getValue(f) != null)
+ && (!Jifty.Placeholder.hasPlaceholder(f)))
+ {
if (! a['fields'][Form.Element.getField(f)])
a['fields'][Form.Element.getField(f)] = {};
- var field = Form.Element.getField(f);
- var type = Form.Element.getType(f);
-
+ var field = Form.Element.getField(f);
+ var type = Form.Element.getType(f);
+
a['fields'][field][type] = this._mergeValues(a['fields'][field][type],
- Form.Element.getValue(f));
+ Form.Element.getValue(f));
}
}
@@ -130,14 +131,14 @@
},
_mergeValues: function() {
- var oldval = arguments[0];
- var newval = arguments[1];
- if(!oldval) return newval;
- if(oldval.constructor != Array) {
- oldval = [oldval];
- }
- oldval.push(newval);
- return oldval;
+ var oldval = arguments[0];
+ var newval = arguments[1];
+ if(!oldval) return newval;
+ if(oldval.constructor != Array) {
+ oldval = [oldval];
+ }
+ oldval.push(newval);
+ return oldval;
},
// Validate the action
@@ -351,12 +352,12 @@
buttonActions: function(element) {
element = $(element);
- var actions = Form.Element.buttonArguments(element)['J:ACTIONS'];
- if(actions) {
- return actions.split(",");
- } else {
- return new Array();
- }
+ var actions = Form.Element.buttonArguments(element)['J:ACTIONS'];
+ if(actions) {
+ return actions.split(",");
+ } else {
+ return new Array();
+ }
},
buttonFormElements: function(element) {
@@ -384,7 +385,7 @@
elt.onblur = function () {
Form.Element.validate(this);
}
- elt = null; //Prevent IE from leaking memory
+ elt = null; //Prevent IE from leaking memory
},
'input.date': function(e) {
if ( !Element.hasClassName( e, 'has_calendar_link' ) ) {
@@ -712,7 +713,7 @@
alert("Unable to connect to server.\n\nTry again in a few minutes.");
- Jifty.failedRequest = transport;
+ Jifty.failedRequest = transport;
var keys = request["actions"].keys();
for ( var i = 0; i < keys.length; i++ ) {
@@ -853,8 +854,8 @@
beforeHide: this.beforeHide,
frequency: 0.1,
onShow: this.onShow,
- onHide: this.onHide,
- afterUpdateElement: this.afterUpdate
+ onHide: this.onHide,
+ afterUpdateElement: this.afterUpdate
});
},
@@ -949,7 +950,11 @@
},
onBlur: function() {
- if(this.element.value == '') {
+ /* 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) {
Element.addClassName(this.element, 'placeholder');
this.element.value = this.text;
}
More information about the Jifty-commit
mailing list