Permalink
Browse files

Moving elements to constructor, added reset method for onRespond

  • Loading branch information...
1 parent 8303e75 commit 3d820188594dc0f0936e2f215fadcbdcbd27d155 Winton Welsh committed Apr 28, 2008
Showing with 12 additions and 6 deletions.
  1. +12 −6 Dialog.js
View
18 Dialog.js
@@ -70,30 +70,31 @@ Example:
*/
var Dialog = Base.extend({
- elements: {
- load: {}, container: {}, dialog: { close: '.close', form: 'form', submit: '.submit' }
- },
options: {
elements: {}, events: {},
onShow: Class.empty, // must call dialog.show(), this.ready()
onHide: Class.empty,
onSubmit: Class.empty,
- onRespond: Class.empty,
+ onRespond: Class.empty,
onValidationFailed: Class.empty,
onValidationReset: Class.empty,
centered: false,
lightbox: false,
- inside: null,
+ inside: null,
trigger: null,
dialog_template: '#template_dialog',
method: 'post'
},
initialize: function(template, options) {
+ this.elements = {
+ load: {}, container: {}, dialog: { close: '.close', form: 'form', submit: '.submit' }
+ };
+
this.options.trigger = '#' + template;
this.elements.load.template = '#template_' + template;
this.elements.load.dialog_template = this.options.dialog_template;
@@ -121,7 +122,7 @@ var Dialog = Base.extend({
this.hide();
},
onFormKeyDown: function(e) {
- if (e.key == 'esc') this.hide();
+ if (e.key == 'esc') this.hide();
if (e.key == 'enter' && e.target.tagName != 'TEXTAREA') this.submit(e);
},
onFormSubmit: function(e) {
@@ -210,6 +211,11 @@ var Dialog = Base.extend({
return this;
},
+ reset: function() {
+ this.el.form.reset();
+ $ES('input, textarea', this.el.form).each(function(item) { this.fireEvent('onValidationReset', item); }, this);
+ },
+
resize: function() {
if (!this.el.dialog) return false;
if (this.el.dialog && this.el.dialog.visible())

0 comments on commit 3d82018

Please sign in to comment.