formize 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/assets/javascripts/formize-dialog.js +23 -22
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.2
|
@@ -1,20 +1,23 @@
|
|
1
1
|
//= require formize-behave
|
2
2
|
|
3
3
|
(function ($) {
|
4
|
+
"use strict";
|
4
5
|
|
5
6
|
$.ajaxDialogCount = 0;
|
6
7
|
|
7
8
|
$.ajaxDialog = function (url, settings) {
|
8
|
-
var frame_id = "dialog-" + $.ajaxDialogCount, width = $(document).width();
|
9
|
-
|
9
|
+
var frame_id = "dialog-" + $.ajaxDialogCount, width = $(document).width(), data, defaultSettings;
|
10
|
+
defaultSettings = {
|
10
11
|
header: "X-Return-Code",
|
11
12
|
width: 0.6,
|
12
13
|
height: 0.8
|
13
14
|
};
|
14
15
|
if (settings === null || settings === undefined) { settings = {}; }
|
15
16
|
settings = $.extend({}, defaultSettings, settings);
|
17
|
+
data = settings.data || {};
|
18
|
+
data.dialog = frame_id;
|
16
19
|
$.ajax(url, {
|
17
|
-
data:
|
20
|
+
data: data,
|
18
21
|
success: function(data, textStatus, jqXHR) {
|
19
22
|
var frame = $(document.createElement('div')), width, height;
|
20
23
|
frame.attr({id: frame_id, 'class': 'dialog ajax-dialog', style: 'display:none;'});
|
@@ -46,7 +49,7 @@
|
|
46
49
|
frame.dialog("open");
|
47
50
|
},
|
48
51
|
error: function(jqXHR, textStatus, errorThrown) {
|
49
|
-
alert("FAILURE (Error "+textStatus+"): "+errorThrown);
|
52
|
+
alert("FAILURE (Error " + textStatus + "): " + errorThrown);
|
50
53
|
var frame = $("#" + frame_id);
|
51
54
|
frame.dialog("close");
|
52
55
|
frame.remove();
|
@@ -56,12 +59,11 @@
|
|
56
59
|
};
|
57
60
|
|
58
61
|
$.ajaxDialogInitialize = function(frame) {
|
59
|
-
var frame_id = frame.attr("id");
|
60
|
-
var title = frame.prop("dialogSettings")["title"];
|
62
|
+
var frame_id = frame.attr("id"), title = frame.prop("dialogSettings").title, h1;
|
61
63
|
if (title === null || title === undefined) {
|
62
|
-
|
64
|
+
h1 = $("#" + frame_id + " h1");
|
63
65
|
if (h1[0] !== null && h1[0] !== undefined) {
|
64
|
-
title = h1.text()
|
66
|
+
title = h1.text();
|
65
67
|
h1.remove();
|
66
68
|
}
|
67
69
|
}
|
@@ -74,12 +76,12 @@
|
|
74
76
|
};
|
75
77
|
|
76
78
|
$.submitAjaxForm = function () {
|
77
|
-
var form = $(this);
|
78
|
-
|
79
|
-
|
80
|
-
|
79
|
+
var form = $(this), frame_id, frame, settings, field;
|
80
|
+
frame_id = form.attr('data-dialog');
|
81
|
+
frame = $('#'+frame_id);
|
82
|
+
settings = frame.prop("dialogSettings");
|
81
83
|
|
82
|
-
|
84
|
+
field = $(document.createElement('input'));
|
83
85
|
field.attr({ type: 'hidden', name: 'dialog', value: frame_id });
|
84
86
|
form.append(field);
|
85
87
|
|
@@ -87,10 +89,9 @@
|
|
87
89
|
type: form.attr('method') || 'POST',
|
88
90
|
data: form.serialize(),
|
89
91
|
success: function(data, textStatus, request) {
|
90
|
-
var returnCode = request.getResponseHeader(settings
|
91
|
-
|
92
|
-
|
93
|
-
if (returnCode == code && $.isFunction(returns[code])) {
|
92
|
+
var returnCode = request.getResponseHeader(settings.header), returns = settings.returns, unknownReturnCode = true, code;
|
93
|
+
for (code in returns) {
|
94
|
+
if (returns.hasOwnProperty(code) && returnCode === code && $.isFunction(returns[code])) {
|
94
95
|
returns[code].call(form, frame, data, textStatus, request);
|
95
96
|
unknownReturnCode = false;
|
96
97
|
$.ajaxDialogInitialize(frame);
|
@@ -98,19 +99,19 @@
|
|
98
99
|
}
|
99
100
|
}
|
100
101
|
if (unknownReturnCode) {
|
101
|
-
if ($.isFunction(settings
|
102
|
-
settings
|
102
|
+
if ($.isFunction(settings.defaultReturn)) {
|
103
|
+
settings.defaultReturn.call(form, frame);
|
103
104
|
} else {
|
104
|
-
alert("FAILURE (Unknown return code for header " + settings
|
105
|
+
alert("FAILURE (Unknown return code for header " + settings.header + "): " + returnCode);
|
105
106
|
}
|
106
107
|
}
|
107
108
|
},
|
108
109
|
error: function(jqXHR, textStatus, errorThrown) {
|
109
|
-
alert("FAILURE (Error "+textStatus+"): "+errorThrown);
|
110
|
+
alert("FAILURE (Error " + textStatus + "): " + errorThrown);
|
110
111
|
var frame = $("#" + frame_id);
|
111
112
|
frame.dialog("close");
|
112
113
|
frame.remove();
|
113
|
-
// if ($.isFunction(settings
|
114
|
+
// if ($.isFunction(settings.error)) { settings.error.call(form, frame, jqXHR, textStatus, errorThrown); }
|
114
115
|
}
|
115
116
|
});
|
116
117
|
return false;
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: formize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
version: !binary |-
|
5
|
-
|
5
|
+
MS4wLjI=
|
6
6
|
prerelease:
|
7
7
|
platform: ruby
|
8
8
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-03-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|