From ca7db2ff677acb48c6f65d8c652910b994ddbe7d Mon Sep 17 00:00:00 2001 From: Michael Mathews Date: Wed, 2 Sep 2009 15:27:17 +0100 Subject: [PATCH 1/3] Fixed bug that caused error when validating a form with an input element named "submit". [#29 state:review] --- src/forms/forms.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/forms/forms.js b/src/forms/forms.js index 4792c3f..dd43fed 100755 --- a/src/forms/forms.js +++ b/src/forms/forms.js @@ -79,8 +79,9 @@ glow.forms.Form = function(formNode, opts) { /*debug*///console.log("glow.forms. this.formNode, "submit", function(){ + thisForm._allowSubmit = false; thisForm.validate('submit'); - return false; + return thisForm._allowSubmit; } ); } @@ -117,7 +118,7 @@ glow.forms.Form.prototype.validate = function(eventName, fieldName) { /*debug*// glow.forms.Form.prototype._nextTest = function() { /*debug*///console.log("glow.forms.Form#_nextTest()"); this._testCur++; if (this._testCur >= this._fields[this._fieldCur]._tests.length) { // run out of tests for the current field? - if (!this._nextField()) return false; + if (!this._nextField()) return; } var currentTest = this._fields[this._fieldCur]._tests[this._testCur]; // shortcut @@ -180,11 +181,13 @@ glow.forms.Form.prototype._nextField = function() { /*debug*///console.log("glow this._fieldCur = 0; // ready to fire the validate event now glow.events.fire(this, "validate", this._result); - if (this.eventName == "submit" && this._result && !this._result.defaultPrevented()) this.formNode[0].submit(); - return false; + if (this.eventName == "submit" && this._result && !this._result.defaultPrevented()) { + this._allowSubmit = true; + } + return false; // don't keep going } - return true; + return true; // do keep going } /** From c34aec90f8fbf2f892b76c410227786d50f14465 Mon Sep 17 00:00:00 2001 From: Michael Mathews Date: Wed, 2 Sep 2009 15:29:39 +0100 Subject: [PATCH 2/3] Added manual test page for glow.forms. --- manualtests/form/index.html | 104 ++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 manualtests/form/index.html diff --git a/manualtests/form/index.html b/manualtests/form/index.html new file mode 100644 index 0000000..5526499 --- /dev/null +++ b/manualtests/form/index.html @@ -0,0 +1,104 @@ + + + + glow.forms + + + + + + + + +

glow.forms

+ +

Test Title

+ +

Issue #29 - expando named submit breaks validation.

+ +
+

+ +

+ +

+ +

+ + + +

+ +

+ +

+ +

+
+ + + + + + + + \ No newline at end of file From b956d205d431558cf5fe8e7cf5b846ad0bd8cd7f Mon Sep 17 00:00:00 2001 From: jakearchibald Date: Thu, 3 Sep 2009 09:33:17 +0100 Subject: [PATCH 3/3] Timetable: improving template docs [#80 state:review] --- src/widgets/timetable/timetable.js | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/widgets/timetable/timetable.js b/src/widgets/timetable/timetable.js index 941ccb3..e433a9d 100755 --- a/src/widgets/timetable/timetable.js +++ b/src/widgets/timetable/timetable.js @@ -247,6 +247,8 @@ As in, take up the same space. This must be false if you want your tracks to be separated by a margin. @param {Boolean} [opts.keepItemContentInView=true] Should the content of an item that is partially in view be moved into view? @param {String | glow.dom.NodeList | Function} [opts.itemTemplate] Template for each Item on a Track in the Timetable + The {@link glow.widgets.Timetable.Item item} will be passed into the template. +

A default template is used if this is not provided, which displays just the item title

  • If a String is provided, it is passed through glow.lang.interpolate, with the Item as the data parameter, and the output is used.
  • @@ -254,9 +256,13 @@
  • If a function is provided it should take the Item as its only argument, and return the HTML or a NodeList to use.
@param {String | glow.dom.NodeList | Function} [opts.trackHeader] Template for the header section the each Track in the Timetable + The {@link glow.widgets.Timetable.Track track} will be passed into the template. + Defaults to no header. See itemTemplate above for a description of how the different values are treated. @param {String | glow.dom.NodeList | Function} [opts.trackFooter] Template for the footer section the each Track in the Timetable + The {@link glow.widgets.Timetable.Track track} will be passed into the template. + Defaults to no footer. See itemTemplate above for a description of how the different values are treated. @param {Function} [opts.onChange] Event shortcut @@ -497,18 +503,25 @@ @param {String} [opts.id=auto-generated] An id for the Track @param {String} [opts.className] A class name for the Track's container element @param {String | glow.dom.NodeList | Function} [opts.itemTemplate] Template for each Item on this Track. -

Overrides any template specified at Timetable level.

+ The {@link glow.widgets.Timetable.Item item} will be passed into the template. +
  1. If a String is provided, it is passed through glow.lang.interpolate, with the Item as the other parameter, and the output is used.
  2. If a NodeList is provided it is used directly.
  3. If a function is provided it should take the Item as its only argument, and return the HTML or a NodeList to use.
@param {String | glow.dom.NodeList | Function} [opts.trackHeader] Template for the header section the this Track. -

Overrides any template specified at Timetable level.

-

See itemTemplate above for a description of how the different values are treated.

+ The {@link glow.widgets.Timetable.Track track} will be passed into the template. + + Overrides any template specified at Timetable level. + + See itemTemplate above for a description of how the different values are treated. @param {String | glow.dom.NodeList | Function} [opts.trackFooter] Template for the footer section the this Track. -

Overrides any template specified at Timetable level.

-

See itemTemplate above for a description of how the different values are treated.

+ The {@link glow.widgets.Timetable.Track track} will be passed into the template. + + Overrides any template specified at Timetable level. + + See itemTemplate above for a description of how the different values are treated. @param {Object} [opts.data] An object of arbitrary data to be attached to the Track. @param {Boolean} [opts.disabled=false] A disabled track is not rendered in the view @param {Array} [opts.items] An array of Items to create the Track with @@ -639,6 +652,7 @@ @name glow.widgets.Timetable#setItemTemplate @function @description Sets the Default Item template for the Timetable + The {@link glow.widgets.Timetable.Item item} will be passed into the template. @param {String | glow.dom.NodeList | function} template The template to use @returns this @@ -654,6 +668,7 @@ @name glow.widgets.Timetable#setTrackHeaderTemplate @function @description Sets the default Track header template for the Timetable + The {@link glow.widgets.Timetable.Track track} will be passed into the template. @param {String | glow.dom.NodeList | Function} template The template to use @returns this @@ -668,6 +683,7 @@ @name glow.widgets.Timetable#setTrackFooterTemplate @function @description Sets the default Track footer template for the Timetable + The {@link glow.widgets.Timetable.Track track} will be passed into the template. @param {String | glow.dom.NodeList | Function} template The template to use @returns this @@ -1208,6 +1224,7 @@ @name glow.widgets.Timetable.Track#setItemTemplate @function @description Sets the Default Item template for this track + The {@link glow.widgets.Timetable.Item item} will be passed into the template. @param {String | glow.dom.NodeList | function} template The template to use @returns this @@ -1223,6 +1240,7 @@ @name glow.widgets.Timetable.Track#setTrackHeaderTemplate @function @description Sets the header template for this track + The {@link glow.widgets.Timetable.Track track} will be passed into the template. @param {String | glow.dom.NodeList | function} template The template to use @returns this @@ -1238,6 +1256,7 @@ @name glow.widgets.Timetable.Track#setTrackFooterTemplate @function @description Sets the footer template for this track + The {@link glow.widgets.Timetable.Track track} will be passed into the template. @param {String | glow.dom.NodeList | function} template The template to use @returns this @@ -1360,6 +1379,7 @@ @name glow.widgets.Timetable.Item#setItemTemplate @function @description Sets the Default Item template for the Timetable + The {@link glow.widgets.Timetable.Item item} will be passed into the template. @param {String | glow.dom.NodeList | function} template The template to use @returns this