edifice 0.6.5 → 0.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/edifice/version.rb
CHANGED
@@ -72,6 +72,14 @@ var methods = {
|
|
72
72
|
}
|
73
73
|
},
|
74
74
|
|
75
|
+
label_for: function($field) {
|
76
|
+
return this.find('label[for=' + $field.attr('id') + ']');
|
77
|
+
},
|
78
|
+
|
79
|
+
error_on: function($field) {
|
80
|
+
return this.label_for($field).parents('.field_with_errors').next('.formError');
|
81
|
+
},
|
82
|
+
|
75
83
|
has_error: function($field) {
|
76
84
|
return $field.parent('.field_with_errors').length > 0;
|
77
85
|
},
|
@@ -28,6 +28,8 @@ function form() {
|
|
28
28
|
}
|
29
29
|
var methods = {
|
30
30
|
initialize: function() {
|
31
|
+
// I don't know why, but FF seems to helpful remember that these are disabled
|
32
|
+
this.submits().removeAttr('disabled');
|
31
33
|
this.prepare_validators();
|
32
34
|
this.prepare_submit();
|
33
35
|
},
|
@@ -47,7 +49,7 @@ var methods = {
|
|
47
49
|
|
48
50
|
// listen to validator
|
49
51
|
this.fields().live('change.ajax_form focusout.ajax_form', function() {
|
50
|
-
$form.validate($(this));
|
52
|
+
if ($form.validate($(this)) === false) { $form.trigger('invalid', [$form, $(this)]); }
|
51
53
|
});
|
52
54
|
},
|
53
55
|
|
@@ -56,8 +58,7 @@ var methods = {
|
|
56
58
|
this.submit(function(event) {
|
57
59
|
// do pre-submit validations
|
58
60
|
if (!$form.valid()) {
|
59
|
-
$form.
|
60
|
-
$form.focus_error();
|
61
|
+
$form.invalid();
|
61
62
|
return false; // we are done.
|
62
63
|
}
|
63
64
|
|
@@ -73,24 +74,24 @@ var methods = {
|
|
73
74
|
cache: false,
|
74
75
|
error: function (x, t, e) { $form.error(x, t, e); },
|
75
76
|
success: function (data, status) {
|
76
|
-
$form.trigger('success', data, status);
|
77
|
+
$form.trigger('success', [data, status, $form]);
|
77
78
|
},
|
78
79
|
complete: function (request, text_status) {
|
79
|
-
$form.trigger('complete', request, text_status);
|
80
|
+
$form.trigger('complete', [request, text_status, $form]);
|
80
81
|
|
81
82
|
$form.submits().removeAttr('disabled');
|
82
83
|
}
|
83
84
|
});
|
84
85
|
event.preventDefault();
|
85
|
-
return false;
|
86
86
|
}
|
87
87
|
|
88
88
|
});
|
89
89
|
},
|
90
90
|
|
91
|
-
|
92
|
-
|
91
|
+
invalid: function() {
|
92
|
+
// focus the first error
|
93
93
|
this.error_fields().eq(0).focus();
|
94
|
+
this.trigger('invalid', [this]);
|
94
95
|
},
|
95
96
|
|
96
97
|
error: function(request, text_status, error) {
|
@@ -99,7 +100,7 @@ var methods = {
|
|
99
100
|
// handle the different possible errors that we can see
|
100
101
|
if (request.status >= 400 && request.status < 500) {
|
101
102
|
// CLIENT ERROR -- server-side validation failed.
|
102
|
-
this.trigger('client_error', request, status, error);
|
103
|
+
this.trigger('client_error', [request, status, error, this]);
|
103
104
|
|
104
105
|
// if data is html, we replace this content of the form with the content
|
105
106
|
// of the form that we've just received back
|
@@ -117,10 +118,10 @@ var methods = {
|
|
117
118
|
throw "Don't know how to handle dataType " + this.settings.dataType;
|
118
119
|
}
|
119
120
|
|
120
|
-
this.
|
121
|
+
this.invalid();
|
121
122
|
} else if (request.status >= 500 && request.status < 600) {
|
122
123
|
// a SERVER ERROR -- something unrecoverable happened on the server
|
123
|
-
this.trigger('server_error', request, status, error);
|
124
|
+
this.trigger('server_error', [request, status, error, this]);
|
124
125
|
|
125
126
|
// we aren't going to do anything here.
|
126
127
|
// FIXME: we should probably have a way to set this behaviour at the application level.
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: edifice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 6
|
10
|
+
version: 0.6.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tom Coleman
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2011-07-
|
20
|
+
date: 2011-07-20 00:00:00 +10:00
|
21
21
|
default_executable:
|
22
22
|
dependencies: []
|
23
23
|
|