compass-jquery-plugin 0.3.2.3 → 0.3.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +54 -37
- data/VERSION.yml +1 -1
- data/lib/handle_attributes.rb +4 -4
- data/lib/handle_js_files.rb +5 -5
- data/lib/jqtouch_theme.rb +2 -2
- data/lib/jquery/dynatree.rb +2 -2
- data/lib/jquery/emulators.rb +1 -1
- data/lib/jquery/flash_messages.rb +6 -6
- data/lib/jquery/graphics.rb +5 -0
- data/lib/jquery/gridify/assertions.rb +1 -1
- data/lib/jquery/gridify/grid.rb +76 -59
- data/lib/jquery/gridify/grid_column.rb +73 -67
- data/lib/jquery/gridify/grid_finder.rb +79 -79
- data/lib/jquery/gridify/grid_options.rb +154 -149
- data/lib/jquery/gridify/grid_view.rb +143 -143
- data/lib/jquery/gridify.rb +25 -25
- data/lib/jquery/ical/calendar.rb +2 -2
- data/lib/jquery/ical/event.rb +48 -44
- data/lib/jquery/ical/helpers/ui_event_helper.rb +3 -3
- data/lib/jquery/jqgrid/jqgrid.rb +58 -58
- data/lib/jquery/jqgrid.rb +1 -1
- data/lib/jquery/jqtouch.rb +1 -1
- data/lib/jquery/jquery.rb +117 -117
- data/lib/jquery/jquery_auto_complete.rb +9 -9
- data/lib/jquery/jquery_json_response.rb +12 -12
- data/lib/jquery/jquery_selector_assertions.rb +55 -53
- data/lib/jquery/jstree.rb +2 -2
- data/lib/jquery/mobile.rb +1 -1
- data/lib/jquery/ribbon.rb +2 -2
- data/lib/jquery/secret_sauce/controller/ui_dialog_controls.rb +5 -5
- data/lib/jquery/secret_sauce/controller/ui_grid_controls.rb +5 -5
- data/lib/jquery/secret_sauce/helpers/ui_dialog_helper.rb +1 -1
- data/lib/jquery/secret_sauce/helpers/ui_form_helper.rb +39 -39
- data/lib/jquery/secret_sauce/helpers/ui_grid_helper.rb +74 -74
- data/lib/jquery/secret_sauce/model/find_for_grid.rb +21 -21
- data/lib/jquery/secret_sauce.rb +1 -1
- data/lib/jquery/tools.rb +1 -1
- data/lib/jquery_mobile_theme.rb +2 -2
- data/lib/jquery_ui_theme.rb +12 -12
- data/templates/dynatree/config/initializers/dynatree.rb +3 -3
- data/templates/dynatree/jquery/dynatree/aero.scss +16 -16
- data/templates/dynatree/jquery/dynatree/aqua.scss +16 -16
- data/templates/dynatree/jquery/dynatree/crystal.scss +16 -16
- data/templates/dynatree/jquery/dynatree/xp.scss +17 -17
- data/templates/dynatree/jquery.dynatree.js +2926 -2912
- data/templates/emulators/config/initializers/emulators.rb +6 -6
- data/templates/graphics/config/initializers/graphics.rb +5 -0
- data/templates/graphics/jquery/ganttView.scss +89 -0
- data/templates/graphics/jquery.ganttView.js +1669 -0
- data/templates/graphics/jquery.ganttView.min.js +70 -0
- data/templates/{jquery → graphics}/jquery.sparkline.js +466 -438
- data/templates/{jquery → graphics}/jquery.sparkline.min.js +0 -0
- data/templates/graphics/manifest.rb +9 -0
- data/templates/jqgrid/config/initializers/jqgrid.rb +1 -1
- data/templates/jqgrid/i18n/jqgrid/locale-ar.js +131 -125
- data/templates/jqgrid/i18n/jqgrid/locale-bg.js +135 -131
- data/templates/jqgrid/i18n/jqgrid/locale-bg1251.js +135 -131
- data/templates/jqgrid/i18n/jqgrid/locale-cat.js +132 -126
- data/templates/jqgrid/i18n/jqgrid/locale-cn.js +137 -131
- data/templates/jqgrid/i18n/jqgrid/locale-cs.js +133 -127
- data/templates/jqgrid/i18n/jqgrid/locale-da.js +132 -126
- data/templates/jqgrid/i18n/jqgrid/locale-de.js +138 -132
- data/templates/jqgrid/i18n/jqgrid/locale-el.js +131 -125
- data/templates/jqgrid/i18n/jqgrid/locale-en.js +133 -127
- data/templates/jqgrid/i18n/jqgrid/locale-es.js +133 -127
- data/templates/jqgrid/i18n/jqgrid/locale-fa.js +19 -16
- data/templates/jqgrid/i18n/jqgrid/locale-fi.js +132 -126
- data/templates/jqgrid/i18n/jqgrid/locale-fr.js +131 -125
- data/templates/jqgrid/i18n/jqgrid/locale-gl.js +131 -125
- data/templates/jqgrid/i18n/jqgrid/locale-he.js +132 -126
- data/templates/jqgrid/i18n/jqgrid/locale-hu.js +133 -127
- data/templates/jqgrid/i18n/jqgrid/locale-is.js +131 -125
- data/templates/jqgrid/i18n/jqgrid/locale-it.js +8 -1
- data/templates/jqgrid/i18n/jqgrid/locale-ja.js +139 -136
- data/templates/jqgrid/i18n/jqgrid/locale-nl.js +4 -1
- data/templates/jqgrid/i18n/jqgrid/locale-no.js +14 -1
- data/templates/jqgrid/i18n/jqgrid/locale-pl.js +132 -126
- data/templates/jqgrid/i18n/jqgrid/locale-pt-br.js +132 -126
- data/templates/jqgrid/i18n/jqgrid/locale-pt.js +130 -124
- data/templates/jqgrid/i18n/jqgrid/locale-ro.js +144 -138
- data/templates/jqgrid/i18n/jqgrid/locale-ru.js +132 -126
- data/templates/jqgrid/i18n/jqgrid/locale-sk.js +132 -126
- data/templates/jqgrid/i18n/jqgrid/locale-sr.js +133 -127
- data/templates/jqgrid/i18n/jqgrid/locale-sv.js +132 -126
- data/templates/jqgrid/i18n/jqgrid/locale-tr.js +131 -125
- data/templates/jqgrid/i18n/jqgrid/locale-ua.js +132 -126
- data/templates/jqgrid/jquery.jqGrid.js +12735 -10444
- data/templates/jqgrid/jquery.jqGrid.min.js +477 -469
- data/templates/jqgrid/public/stylesheets/ellipsis-xbl.xml +12 -10
- data/templates/jqtouch/config/initializers/jqtouch.rb +3 -3
- data/templates/jqtouch/jquery/touch/jqtouch.scss +1 -1
- data/templates/jqtouch/jquery.jqtouch.js +10025 -10043
- data/templates/jquery/config/initializers/jquery.rb +2 -4
- data/templates/jquery/history.adapter.jquery.js +71 -0
- data/templates/jquery/history.adapter.jquery.min.js +4 -0
- data/templates/jquery/history.html4.js +690 -0
- data/templates/jquery/history.html4.min.js +21 -0
- data/templates/jquery/history.js +1297 -0
- data/templates/jquery/history.min.js +29 -0
- data/templates/jquery/i18n/jquery.ui/datepicker-af.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-ar-DZ.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-ar.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-az.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-bg.js +8 -8
- data/templates/jquery/i18n/jquery.ui/datepicker-bs.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-ca.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-cs.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-da.js +14 -14
- data/templates/jquery/i18n/jquery.ui/datepicker-de.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-el.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-en-AU.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-en-GB.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-en-NZ.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-eo.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-es.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-et.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-eu.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-fa.js +18 -18
- data/templates/jquery/i18n/jquery.ui/datepicker-fi.js +15 -15
- data/templates/jquery/i18n/jquery.ui/datepicker-fo.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-fr-CH.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-fr.js +22 -22
- data/templates/jquery/i18n/jquery.ui/datepicker-gl.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-he.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-hr.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-hu.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-hu.min.js +1 -1
- data/templates/jquery/i18n/jquery.ui/datepicker-hy.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-id.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-is.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-it.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-ja.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-ko.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-kz.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-lt.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-lv.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-ml.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-ms.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-nl.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-no.js +16 -16
- data/templates/jquery/i18n/jquery.ui/datepicker-no.min.js +2 -2
- data/templates/jquery/i18n/jquery.ui/datepicker-pl.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-pt-BR.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-pt.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-rm.js +18 -18
- data/templates/jquery/i18n/jquery.ui/datepicker-ro.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-ru.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-sk.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-sl.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-sq.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-sr-SR.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-sr.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-sv.js +14 -14
- data/templates/jquery/i18n/jquery.ui/datepicker-ta.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-th.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-tr.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-uk.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-vi.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-zh-CN.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-zh-HK.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-zh-TW.js +20 -20
- data/templates/jquery/{partials → jquery/ui}/_flash_messages.scss +0 -0
- data/templates/jquery/jquery/ui/_theme.scss +14 -13
- data/templates/jquery/jquery/ui/contextMenu/configure.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/copy.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/cut.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/delete.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/edit.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/exit.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/new.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/paste.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/rename.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/show.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/trash.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu.scss +16 -10
- data/templates/jquery/jquery-ui.js +11839 -23066
- data/templates/jquery/jquery-ui.min.js +401 -795
- data/templates/jquery/jquery.bgiframe.js +27 -25
- data/templates/jquery/jquery.contextMenu.js +209 -196
- data/templates/jquery/jquery.cookie.js +3 -1
- data/templates/jquery/jquery.dotimeout.js +236 -228
- data/templates/jquery/jquery.dst.js +154 -151
- data/templates/jquery/jquery.farbtastic.js +293 -293
- data/templates/jquery/jquery.flashMessages.js +26 -0
- data/templates/jquery/jquery.flashMessages.min.js +1 -0
- data/templates/jquery/jquery.form.js +803 -786
- data/templates/jquery/jquery.haml.js +248 -247
- data/templates/jquery/jquery.hotkeys.js +89 -89
- data/templates/jquery/jquery.js +8141 -8106
- data/templates/jquery/jquery.layout.js +2451 -2415
- data/templates/jquery/jquery.min.js +167 -166
- data/templates/jquery/jquery.mousewheel.js +62 -54
- data/templates/jquery/jquery.offline.js +171 -171
- data/templates/jquery/jquery.pngFix.js +76 -76
- data/templates/jquery/jquery.replacetext.js +83 -83
- data/templates/jquery/jquery.themeswitchertool.js +202 -177
- data/templates/jquery/jquery.tmpl.js +478 -473
- data/templates/jquery/jquery.tmplPlus.js +82 -81
- data/templates/jquery/jrails.js +178 -175
- data/templates/jquery/json.js +77 -7
- data/templates/jquery/json2.js +480 -0
- data/templates/jquery/json2.min.js +7 -0
- data/templates/jquery/lib/tasks/haml.rake +2 -2
- data/templates/jquery/manifest.rb +21 -17
- data/templates/jstree/jquery.jstree.js +5967 -4536
- data/templates/mobile/config/initializers/mobile.rb +1 -1
- data/templates/mobile/jquery/mobile/_base.scss +944 -927
- data/templates/mobile/jquery/mobile/default.scss +61 -48
- data/templates/mobile/jquery/mobile/valencia.scss +56 -42
- data/templates/mobile/jquery.mobile.js +4461 -4347
- data/templates/mobile/jquery.mobile.min.js +11 -2
- data/templates/mobile/lib/tasks/jquery.mobile.rake +12 -12
- data/templates/ribbon/config/initializers/ribbon.rb +2 -2
- data/templates/ribbon/jquery.ribbon.js +50 -29
- data/templates/secret_sauce/secret_sauce.js +8 -8
- data/templates/tools/flowplayer.js +945 -1
- data/templates/tools/jquery.tools.js +4645 -4335
- data/templates/tools/jquery.tools.min.js +37 -37
- data/templates/tools/lib/tasks/jquery.tools.rake +4 -4
- data/templates/tools/swfobject.js +813 -773
- metadata +33 -21
- data/templates/jquery/haml.js +0 -506
- data/templates/jquery/haml.min.js +0 -5
- data/templates/jquery/jquery/ui/contextMenu/door.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/page_white_copy.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/page_white_delete.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/page_white_edit.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/page_white_new.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/page_white_paste.png +0 -0
- data/templates/jquery/jquery.compat-1.3.js +0 -291
- data/templates/jquery/jquery.compat-1.3.min.js +0 -6
- data/templates/jquery/jquery.flash_messages.js +0 -5
- data/templates/jquery/jquery.flash_messages.min.js +0 -1
- data/templates/jquery/jquery.history.js +0 -194
- data/templates/jquery/jquery.history.min.js +0 -5
@@ -0,0 +1,26 @@
|
|
1
|
+
//
|
2
|
+
// Adding some animation to flash messages
|
3
|
+
// Idea from http://stackoverflow.com/questions/316278/timeout-jquery-effects
|
4
|
+
//
|
5
|
+
// Copyright (c) 2011 Kosmas Schütz
|
6
|
+
//
|
7
|
+
|
8
|
+
(function($) {
|
9
|
+
|
10
|
+
// Parameters are:
|
11
|
+
// time for fadeIn
|
12
|
+
// time the message is shown
|
13
|
+
// time for fadeOut
|
14
|
+
|
15
|
+
$.fn.flashMessages = function(timeIn, timeStay, timeOut) {
|
16
|
+
|
17
|
+
var el = $(this.selector + " .success, " + this.selector + " .notice, " + this.selector + " .warning, " + this.selector + " .error");
|
18
|
+
el.fadeIn(timeIn);
|
19
|
+
el.queue(function() {
|
20
|
+
setTimeout(function() {
|
21
|
+
el.dequeue();
|
22
|
+
}, timeStay);
|
23
|
+
});
|
24
|
+
el.fadeOut(timeOut);
|
25
|
+
};
|
26
|
+
})(jQuery);
|
@@ -0,0 +1 @@
|
|
1
|
+
(function(b){b.fn.flashMessages=function(c,d,e){var a=b(this.selector+" .success, "+this.selector+" .notice, "+this.selector+" .warning, "+this.selector+" .error");a.fadeIn(c);a.queue(function(){setTimeout(function(){a.dequeue()},d)});a.fadeOut(e)}})(jQuery);
|
@@ -8,796 +8,813 @@
|
|
8
8
|
* http://www.opensource.org/licenses/mit-license.php
|
9
9
|
* http://www.gnu.org/licenses/gpl.html
|
10
10
|
*/
|
11
|
-
;
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
11
|
+
;
|
12
|
+
(function($) {
|
13
|
+
|
14
|
+
/*
|
15
|
+
Usage Note:
|
16
|
+
-----------
|
17
|
+
Do not use both ajaxSubmit and ajaxForm on the same form. These
|
18
|
+
functions are intended to be exclusive. Use ajaxSubmit if you want
|
19
|
+
to bind your own submit handler to the form. For example,
|
20
|
+
|
21
|
+
$(document).ready(function() {
|
22
|
+
$('#myForm').bind('submit', function(e) {
|
23
|
+
e.preventDefault(); // <-- important
|
24
|
+
$(this).ajaxSubmit({
|
25
|
+
target: '#output'
|
26
|
+
});
|
27
|
+
});
|
28
|
+
});
|
29
|
+
|
30
|
+
Use ajaxForm when you want the plugin to manage all the event binding
|
31
|
+
for you. For example,
|
32
|
+
|
33
|
+
$(document).ready(function() {
|
34
|
+
$('#myForm').ajaxForm({
|
35
|
+
target: '#output'
|
36
|
+
});
|
37
|
+
});
|
38
|
+
|
39
|
+
When using ajaxForm, the ajaxSubmit function will be invoked for you
|
40
|
+
at the appropriate time.
|
41
|
+
*/
|
42
|
+
|
43
|
+
/**
|
44
|
+
* ajaxSubmit() provides a mechanism for immediately submitting
|
45
|
+
* an HTML form using AJAX.
|
46
|
+
*/
|
47
|
+
$.fn.ajaxSubmit = function(options) {
|
48
|
+
// fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
|
49
|
+
if (!this.length) {
|
50
|
+
log('ajaxSubmit: skipping submit process - no element selected');
|
51
|
+
return this;
|
52
|
+
}
|
53
|
+
|
54
|
+
if (typeof options == 'function') {
|
55
|
+
options = { success: options };
|
56
|
+
}
|
57
|
+
|
58
|
+
var action = this.attr('action');
|
59
|
+
var url = (typeof action === 'string') ? $.trim(action) : '';
|
60
|
+
if (url) {
|
61
|
+
// clean url (don't include hash vaue)
|
62
|
+
url = (url.match(/^([^#]+)/) || [])[1];
|
63
|
+
}
|
64
|
+
url = url || window.location.href || '';
|
65
|
+
|
66
|
+
options = $.extend(true, {
|
67
|
+
url: url,
|
68
|
+
type: this[0].getAttribute('method') || 'GET', // IE7 massage (see issue 57)
|
69
|
+
iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank'
|
70
|
+
}, options);
|
71
|
+
|
72
|
+
// hook for manipulating the form data before it is extracted;
|
73
|
+
// convenient for use with rich editors like tinyMCE or FCKEditor
|
74
|
+
var veto = {};
|
75
|
+
this.trigger('form-pre-serialize', [this, options, veto]);
|
76
|
+
if (veto.veto) {
|
77
|
+
log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');
|
78
|
+
return this;
|
79
|
+
}
|
80
|
+
|
81
|
+
// provide opportunity to alter form data before it is serialized
|
82
|
+
if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {
|
83
|
+
log('ajaxSubmit: submit aborted via beforeSerialize callback');
|
84
|
+
return this;
|
85
|
+
}
|
86
|
+
|
87
|
+
var n,v,a = this.formToArray(options.semantic);
|
88
|
+
if (options.data) {
|
89
|
+
options.extraData = options.data;
|
90
|
+
for (n in options.data) {
|
91
|
+
if (options.data[n] instanceof Array) {
|
92
|
+
for (var k in options.data[n]) {
|
93
|
+
a.push({ name: n, value: options.data[n][k] });
|
94
|
+
}
|
95
|
+
}
|
96
|
+
else {
|
97
|
+
v = options.data[n];
|
98
|
+
v = $.isFunction(v) ? v() : v; // if value is fn, invoke it
|
99
|
+
a.push({ name: n, value: v });
|
100
|
+
}
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
// give pre-submit callback an opportunity to abort the submit
|
105
|
+
if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {
|
106
|
+
log('ajaxSubmit: submit aborted via beforeSubmit callback');
|
107
|
+
return this;
|
108
|
+
}
|
109
|
+
|
110
|
+
// fire vetoable 'validate' event
|
111
|
+
this.trigger('form-submit-validate', [a, this, options, veto]);
|
112
|
+
if (veto.veto) {
|
113
|
+
log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
|
114
|
+
return this;
|
115
|
+
}
|
116
|
+
|
117
|
+
var q = $.param(a);
|
118
|
+
|
119
|
+
if (options.type.toUpperCase() == 'GET') {
|
120
|
+
options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
|
121
|
+
options.data = null; // data is null for 'get'
|
122
|
+
}
|
123
|
+
else {
|
124
|
+
options.data = q; // data is the query string for 'post'
|
125
|
+
}
|
126
|
+
|
127
|
+
var $form = this, callbacks = [];
|
128
|
+
if (options.resetForm) {
|
129
|
+
callbacks.push(function() {
|
130
|
+
$form.resetForm();
|
131
|
+
});
|
132
|
+
}
|
133
|
+
if (options.clearForm) {
|
134
|
+
callbacks.push(function() {
|
135
|
+
$form.clearForm();
|
136
|
+
});
|
137
|
+
}
|
138
|
+
|
139
|
+
// perform a load on the target only if dataType is not provided
|
140
|
+
if (!options.dataType && options.target) {
|
141
|
+
var oldSuccess = options.success || function() {
|
142
|
+
};
|
143
|
+
callbacks.push(function(data) {
|
144
|
+
var fn = options.replaceTarget ? 'replaceWith' : 'html';
|
145
|
+
$(options.target)[fn](data).each(oldSuccess, arguments);
|
146
|
+
});
|
147
|
+
}
|
148
|
+
else if (options.success) {
|
149
|
+
callbacks.push(options.success);
|
150
|
+
}
|
151
|
+
|
152
|
+
options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg
|
153
|
+
var context = options.context || options; // jQuery 1.4+ supports scope context
|
154
|
+
for (var i = 0, max = callbacks.length; i < max; i++) {
|
155
|
+
callbacks[i].apply(context, [data, status, xhr || $form, $form]);
|
156
|
+
}
|
157
|
+
};
|
158
|
+
|
159
|
+
// are there files to upload?
|
160
|
+
var fileInputs = $('input:file', this).length > 0;
|
161
|
+
var mp = 'multipart/form-data';
|
162
|
+
var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp);
|
163
|
+
|
164
|
+
// options.iframe allows user to force iframe mode
|
165
|
+
// 06-NOV-09: now defaulting to iframe mode if file input is detected
|
166
|
+
if (options.iframe !== false && (fileInputs || options.iframe || multipart)) {
|
167
|
+
// hack to fix Safari hang (thanks to Tim Molendijk for this)
|
168
|
+
// see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
|
169
|
+
if (options.closeKeepAlive) {
|
170
|
+
$.get(options.closeKeepAlive, fileUpload);
|
171
|
+
}
|
172
|
+
else {
|
173
|
+
fileUpload();
|
174
|
+
}
|
175
|
+
}
|
176
|
+
else {
|
177
|
+
$.ajax(options);
|
178
|
+
}
|
179
|
+
|
180
|
+
// fire 'notify' event
|
181
|
+
this.trigger('form-submit-notify', [this, options]);
|
182
|
+
return this;
|
183
|
+
|
184
|
+
|
185
|
+
// private function for handling file uploads (hat tip to YAHOO!)
|
186
|
+
function fileUpload() {
|
187
|
+
var form = $form[0];
|
188
|
+
|
189
|
+
if ($(':input[name=submit],:input[id=submit]', form).length) {
|
190
|
+
// if there is an input with a name or id of 'submit' then we won't be
|
191
|
+
// able to invoke the submit fn on the form (at least not x-browser)
|
192
|
+
alert('Error: Form elements must not have name or id of "submit".');
|
193
|
+
return;
|
194
|
+
}
|
195
|
+
|
196
|
+
var s = $.extend(true, {}, $.ajaxSettings, options);
|
197
|
+
s.context = s.context || s;
|
198
|
+
var id = 'jqFormIO' + (new Date().getTime()), fn = '_' + id;
|
199
|
+
var $io = $('<iframe id="' + id + '" name="' + id + '" src="' + s.iframeSrc + '" />');
|
200
|
+
var io = $io[0];
|
201
|
+
|
202
|
+
$io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
|
203
|
+
|
204
|
+
var xhr = { // mock object
|
205
|
+
aborted: 0,
|
206
|
+
responseText: null,
|
207
|
+
responseXML: null,
|
208
|
+
status: 0,
|
209
|
+
statusText: 'n/a',
|
210
|
+
getAllResponseHeaders: function() {
|
211
|
+
},
|
212
|
+
getResponseHeader: function() {
|
213
|
+
},
|
214
|
+
setRequestHeader: function() {
|
215
|
+
},
|
216
|
+
abort: function() {
|
217
|
+
this.aborted = 1;
|
218
|
+
$io.attr('src', s.iframeSrc); // abort op in progress
|
219
|
+
}
|
220
|
+
};
|
221
|
+
|
222
|
+
var g = s.global;
|
223
|
+
// trigger ajax global events so that activity/block indicators work like normal
|
224
|
+
if (g && ! $.active++) {
|
225
|
+
$.event.trigger("ajaxStart");
|
226
|
+
}
|
227
|
+
if (g) {
|
228
|
+
$.event.trigger("ajaxSend", [xhr, s]);
|
229
|
+
}
|
230
|
+
|
231
|
+
if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) {
|
232
|
+
if (s.global) {
|
233
|
+
$.active--;
|
234
|
+
}
|
235
|
+
return;
|
236
|
+
}
|
237
|
+
if (xhr.aborted) {
|
238
|
+
return;
|
239
|
+
}
|
240
|
+
|
241
|
+
var timedOut = 0;
|
242
|
+
|
243
|
+
// add submitting element to data if we know it
|
244
|
+
var sub = form.clk;
|
245
|
+
if (sub) {
|
246
|
+
var n = sub.name;
|
247
|
+
if (n && !sub.disabled) {
|
248
|
+
s.extraData = s.extraData || {};
|
249
|
+
s.extraData[n] = sub.value;
|
250
|
+
if (sub.type == "image") {
|
251
|
+
s.extraData[n + '.x'] = form.clk_x;
|
252
|
+
s.extraData[n + '.y'] = form.clk_y;
|
253
|
+
}
|
254
|
+
}
|
255
|
+
}
|
256
|
+
|
257
|
+
// take a breath so that pending repaints get some cpu time before the upload starts
|
258
|
+
function doSubmit() {
|
259
|
+
// make sure form attrs are set
|
260
|
+
var t = $form.attr('target'), a = $form.attr('action');
|
261
|
+
|
262
|
+
// update form attrs in IE friendly way
|
263
|
+
form.setAttribute('target', id);
|
264
|
+
if (form.getAttribute('method') != 'POST') {
|
265
|
+
form.setAttribute('method', 'POST');
|
266
|
+
}
|
267
|
+
if (form.getAttribute('action') != s.url) {
|
268
|
+
form.setAttribute('action', s.url);
|
269
|
+
}
|
270
|
+
|
271
|
+
// ie borks in some cases when setting encoding
|
272
|
+
if (! s.skipEncodingOverride) {
|
273
|
+
$form.attr({
|
274
|
+
encoding: 'multipart/form-data',
|
275
|
+
enctype: 'multipart/form-data'
|
276
|
+
});
|
277
|
+
}
|
278
|
+
|
279
|
+
// support timout
|
280
|
+
if (s.timeout) {
|
281
|
+
setTimeout(function() {
|
282
|
+
timedOut = true;
|
283
|
+
cb();
|
284
|
+
}, s.timeout);
|
285
|
+
}
|
286
|
+
|
287
|
+
// add "extra" data to form if provided in options
|
288
|
+
var extraInputs = [];
|
289
|
+
try {
|
290
|
+
if (s.extraData) {
|
291
|
+
for (var n in s.extraData) {
|
292
|
+
extraInputs.push(
|
293
|
+
$('<input type="hidden" name="' + n + '" value="' + s.extraData[n] + '" />')
|
294
|
+
.appendTo(form)[0]);
|
295
|
+
}
|
296
|
+
}
|
297
|
+
|
298
|
+
// add iframe to doc and submit the form
|
299
|
+
$io.appendTo('body');
|
300
|
+
io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false);
|
301
|
+
form.submit();
|
302
|
+
}
|
303
|
+
finally {
|
304
|
+
// reset attrs and remove "extra" input elements
|
305
|
+
form.setAttribute('action', a);
|
306
|
+
if (t) {
|
307
|
+
form.setAttribute('target', t);
|
308
|
+
} else {
|
309
|
+
$form.removeAttr('target');
|
310
|
+
}
|
311
|
+
$(extraInputs).remove();
|
312
|
+
}
|
313
|
+
}
|
314
|
+
|
315
|
+
if (s.forceSync) {
|
316
|
+
doSubmit();
|
317
|
+
}
|
318
|
+
else {
|
319
|
+
setTimeout(doSubmit, 10); // this lets dom updates render
|
320
|
+
}
|
321
|
+
|
322
|
+
var data, doc, domCheckCount = 50;
|
323
|
+
|
324
|
+
function cb() {
|
325
|
+
doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;
|
326
|
+
if (!doc || doc.location.href == s.iframeSrc) {
|
327
|
+
// response not received yet
|
328
|
+
return;
|
329
|
+
}
|
330
|
+
io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false);
|
331
|
+
|
332
|
+
var ok = true;
|
333
|
+
try {
|
334
|
+
if (timedOut) {
|
335
|
+
throw 'timeout';
|
336
|
+
}
|
337
|
+
|
338
|
+
var isXml = s.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc);
|
339
|
+
log('isXml=' + isXml);
|
340
|
+
if (!isXml && window.opera && (doc.body == null || doc.body.innerHTML == '')) {
|
341
|
+
if (--domCheckCount) {
|
342
|
+
// in some browsers (Opera) the iframe DOM is not always traversable when
|
343
|
+
// the onload callback fires, so we loop a bit to accommodate
|
344
|
+
log('requeing onLoad callback, DOM not available');
|
345
|
+
setTimeout(cb, 250);
|
346
|
+
return;
|
347
|
+
}
|
348
|
+
// let this fall through because server response could be an empty document
|
349
|
+
//log('Could not access iframe DOM after mutiple tries.');
|
350
|
+
//throw 'DOMException: not available';
|
351
|
+
}
|
352
|
+
|
353
|
+
//log('response detected');
|
354
|
+
xhr.responseText = doc.body ? doc.body.innerHTML : doc.documentElement ? doc.documentElement.innerHTML : null;
|
355
|
+
xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
|
356
|
+
xhr.getResponseHeader = function(header) {
|
357
|
+
var headers = {'content-type': s.dataType};
|
358
|
+
return headers[header];
|
359
|
+
};
|
360
|
+
|
361
|
+
var scr = /(json|script)/.test(s.dataType);
|
362
|
+
if (scr || s.textarea) {
|
363
|
+
// see if user embedded response in textarea
|
364
|
+
var ta = doc.getElementsByTagName('textarea')[0];
|
365
|
+
if (ta) {
|
366
|
+
xhr.responseText = ta.value;
|
367
|
+
}
|
368
|
+
else if (scr) {
|
369
|
+
// account for browsers injecting pre around json response
|
370
|
+
var pre = doc.getElementsByTagName('pre')[0];
|
371
|
+
var b = doc.getElementsByTagName('body')[0];
|
372
|
+
if (pre) {
|
373
|
+
xhr.responseText = pre.textContent;
|
374
|
+
}
|
375
|
+
else if (b) {
|
376
|
+
xhr.responseText = b.innerHTML;
|
377
|
+
}
|
378
|
+
}
|
379
|
+
}
|
380
|
+
else if (s.dataType == 'xml' && !xhr.responseXML && xhr.responseText != null) {
|
381
|
+
xhr.responseXML = toXml(xhr.responseText);
|
382
|
+
}
|
383
|
+
|
384
|
+
data = httpData(xhr, s.dataType, s);
|
385
|
+
}
|
386
|
+
catch(e) {
|
387
|
+
log('error caught:', e);
|
388
|
+
ok = false;
|
389
|
+
xhr.error = e;
|
390
|
+
s.error.call(s.context, xhr, 'error', e);
|
391
|
+
g && $.event.trigger("ajaxError", [xhr, s, e]);
|
392
|
+
}
|
393
|
+
|
394
|
+
if (xhr.aborted) {
|
395
|
+
log('upload aborted');
|
396
|
+
ok = false;
|
397
|
+
}
|
398
|
+
|
399
|
+
// ordering of these callbacks/triggers is odd, but that's how $.ajax does it
|
400
|
+
if (ok) {
|
401
|
+
s.success.call(s.context, data, 'success', xhr);
|
402
|
+
g && $.event.trigger("ajaxSuccess", [xhr, s]);
|
403
|
+
}
|
404
|
+
|
405
|
+
g && $.event.trigger("ajaxComplete", [xhr, s]);
|
406
|
+
|
407
|
+
if (g && ! --$.active) {
|
408
|
+
$.event.trigger("ajaxStop");
|
409
|
+
}
|
410
|
+
|
411
|
+
s.complete && s.complete.call(s.context, xhr, ok ? 'success' : 'error');
|
412
|
+
|
413
|
+
// clean up
|
414
|
+
setTimeout(function() {
|
415
|
+
$io.removeData('form-plugin-onload');
|
416
|
+
$io.remove();
|
417
|
+
xhr.responseXML = null;
|
418
|
+
}, 100);
|
419
|
+
}
|
420
|
+
|
421
|
+
var toXml = $.parseXML || function(s, doc) { // use parseXML if available (jQuery 1.5+)
|
422
|
+
if (window.ActiveXObject) {
|
423
|
+
doc = new ActiveXObject('Microsoft.XMLDOM');
|
424
|
+
doc.async = 'false';
|
425
|
+
doc.loadXML(s);
|
426
|
+
}
|
427
|
+
else {
|
428
|
+
doc = (new DOMParser()).parseFromString(s, 'text/xml');
|
429
|
+
}
|
430
|
+
return (doc && doc.documentElement && doc.documentElement.nodeName != 'parsererror') ? doc : null;
|
431
|
+
};
|
432
|
+
var parseJSON = $.parseJSON || function(s) {
|
433
|
+
return window['eval']('(' + s + ')');
|
434
|
+
};
|
435
|
+
|
436
|
+
var httpData = function(xhr, type, s) { // mostly lifted from jq1.4.4
|
437
|
+
var ct = xhr.getResponseHeader('content-type') || '',
|
438
|
+
xml = type === 'xml' || !type && ct.indexOf('xml') >= 0,
|
439
|
+
data = xml ? xhr.responseXML : xhr.responseText;
|
440
|
+
|
441
|
+
if (xml && data.documentElement.nodeName === 'parsererror') {
|
442
|
+
$.error && $.error('parsererror');
|
443
|
+
}
|
444
|
+
if (s && s.dataFilter) {
|
445
|
+
data = s.dataFilter(data, type);
|
446
|
+
}
|
447
|
+
if (typeof data === 'string') {
|
448
|
+
if (type === 'json' || !type && ct.indexOf('json') >= 0) {
|
449
|
+
data = parseJSON(data);
|
450
|
+
} else if (type === "script" || !type && ct.indexOf("javascript") >= 0) {
|
451
|
+
$.globalEval(data);
|
452
|
+
}
|
453
|
+
}
|
454
|
+
return data;
|
455
|
+
};
|
456
|
+
}
|
457
|
+
};
|
458
|
+
|
459
|
+
/**
|
460
|
+
* ajaxForm() provides a mechanism for fully automating form submission.
|
461
|
+
*
|
462
|
+
* The advantages of using this method instead of ajaxSubmit() are:
|
463
|
+
*
|
464
|
+
* 1: This method will include coordinates for <input type="image" /> elements (if the element
|
465
|
+
* is used to submit the form).
|
466
|
+
* 2. This method will include the submit element's name/value data (for the element that was
|
467
|
+
* used to submit the form).
|
468
|
+
* 3. This method binds the submit() method to the form for you.
|
469
|
+
*
|
470
|
+
* The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely
|
471
|
+
* passes the options argument along after properly binding events for submit elements and
|
472
|
+
* the form itself.
|
473
|
+
*/
|
474
|
+
$.fn.ajaxForm = function(options) {
|
475
|
+
// in jQuery 1.3+ we can fix mistakes with the ready state
|
476
|
+
if (this.length === 0) {
|
477
|
+
var o = { s: this.selector, c: this.context };
|
478
|
+
if (!$.isReady && o.s) {
|
479
|
+
log('DOM not ready, queuing ajaxForm');
|
480
|
+
$(function() {
|
481
|
+
$(o.s, o.c).ajaxForm(options);
|
482
|
+
});
|
483
|
+
return this;
|
484
|
+
}
|
485
|
+
// is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
|
486
|
+
log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
|
487
|
+
return this;
|
488
|
+
}
|
489
|
+
|
490
|
+
return this.ajaxFormUnbind().bind('submit.form-plugin',
|
491
|
+
function(e) {
|
492
|
+
if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed
|
493
|
+
e.preventDefault();
|
494
|
+
$(this).ajaxSubmit(options);
|
495
|
+
}
|
496
|
+
}).bind('click.form-plugin', function(e) {
|
497
|
+
var target = e.target;
|
498
|
+
var $el = $(target);
|
499
|
+
if (!($el.is(":submit,input:image"))) {
|
500
|
+
// is this a child element of the submit el? (ex: a span within a button)
|
501
|
+
var t = $el.closest(':submit');
|
502
|
+
if (t.length == 0) {
|
503
|
+
return;
|
504
|
+
}
|
505
|
+
target = t[0];
|
506
|
+
}
|
507
|
+
var form = this;
|
508
|
+
form.clk = target;
|
509
|
+
if (target.type == 'image') {
|
510
|
+
if (e.offsetX != undefined) {
|
511
|
+
form.clk_x = e.offsetX;
|
512
|
+
form.clk_y = e.offsetY;
|
513
|
+
} else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin
|
514
|
+
var offset = $el.offset();
|
515
|
+
form.clk_x = e.pageX - offset.left;
|
516
|
+
form.clk_y = e.pageY - offset.top;
|
517
|
+
} else {
|
518
|
+
form.clk_x = e.pageX - target.offsetLeft;
|
519
|
+
form.clk_y = e.pageY - target.offsetTop;
|
520
|
+
}
|
521
|
+
}
|
522
|
+
// clear form vars
|
523
|
+
setTimeout(function() {
|
524
|
+
form.clk = form.clk_x = form.clk_y = null;
|
525
|
+
}, 100);
|
526
|
+
});
|
527
|
+
};
|
513
528
|
|
514
529
|
// ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
|
515
|
-
$.fn.ajaxFormUnbind = function() {
|
516
|
-
|
517
|
-
};
|
518
|
-
|
519
|
-
/**
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
$.fn.formToArray = function(semantic) {
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
};
|
581
|
-
|
582
|
-
/**
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
$.fn.formSerialize = function(semantic) {
|
587
|
-
|
588
|
-
|
589
|
-
};
|
590
|
-
|
591
|
-
/**
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
$.fn.fieldSerialize = function(successful) {
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
};
|
615
|
-
|
616
|
-
/**
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
$.fn.fieldValue = function(successful) {
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
};
|
665
|
-
|
666
|
-
/**
|
667
|
-
|
668
|
-
|
669
|
-
$.fieldValue = function(el, successful) {
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
};
|
707
|
-
|
708
|
-
/**
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
$.fn.clearForm = function() {
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
};
|
721
|
-
|
722
|
-
/**
|
723
|
-
|
724
|
-
|
725
|
-
$.fn.clearFields = $.fn.clearInputs = function() {
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
};
|
739
|
-
|
740
|
-
/**
|
741
|
-
|
742
|
-
|
743
|
-
$.fn.resetForm = function() {
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
};
|
752
|
-
|
753
|
-
/**
|
754
|
-
|
755
|
-
|
756
|
-
$.fn.enable = function(b) {
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
};
|
764
|
-
|
765
|
-
/**
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
$.fn.selected = function(select) {
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
};
|
530
|
+
$.fn.ajaxFormUnbind = function() {
|
531
|
+
return this.unbind('submit.form-plugin click.form-plugin');
|
532
|
+
};
|
533
|
+
|
534
|
+
/**
|
535
|
+
* formToArray() gathers form element data into an array of objects that can
|
536
|
+
* be passed to any of the following ajax functions: $.get, $.post, or load.
|
537
|
+
* Each object in the array has both a 'name' and 'value' property. An example of
|
538
|
+
* an array for a simple login form might be:
|
539
|
+
*
|
540
|
+
* [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
|
541
|
+
*
|
542
|
+
* It is this array that is passed to pre-submit callback functions provided to the
|
543
|
+
* ajaxSubmit() and ajaxForm() methods.
|
544
|
+
*/
|
545
|
+
$.fn.formToArray = function(semantic) {
|
546
|
+
var a = [];
|
547
|
+
if (this.length === 0) {
|
548
|
+
return a;
|
549
|
+
}
|
550
|
+
|
551
|
+
var form = this[0];
|
552
|
+
var els = semantic ? form.getElementsByTagName('*') : form.elements;
|
553
|
+
if (!els) {
|
554
|
+
return a;
|
555
|
+
}
|
556
|
+
|
557
|
+
var i,j,n,v,el,max,jmax;
|
558
|
+
for (i = 0,max = els.length; i < max; i++) {
|
559
|
+
el = els[i];
|
560
|
+
n = el.name;
|
561
|
+
if (!n) {
|
562
|
+
continue;
|
563
|
+
}
|
564
|
+
|
565
|
+
if (semantic && form.clk && el.type == "image") {
|
566
|
+
// handle image inputs on the fly when semantic == true
|
567
|
+
if (!el.disabled && form.clk == el) {
|
568
|
+
a.push({name: n, value: $(el).val()});
|
569
|
+
a.push({name: n + '.x', value: form.clk_x}, {name: n + '.y', value: form.clk_y});
|
570
|
+
}
|
571
|
+
continue;
|
572
|
+
}
|
573
|
+
|
574
|
+
v = $.fieldValue(el, true);
|
575
|
+
if (v && v.constructor == Array) {
|
576
|
+
for (j = 0,jmax = v.length; j < jmax; j++) {
|
577
|
+
a.push({name: n, value: v[j]});
|
578
|
+
}
|
579
|
+
}
|
580
|
+
else if (v !== null && typeof v != 'undefined') {
|
581
|
+
a.push({name: n, value: v});
|
582
|
+
}
|
583
|
+
}
|
584
|
+
|
585
|
+
if (!semantic && form.clk) {
|
586
|
+
// input type=='image' are not found in elements array! handle it here
|
587
|
+
var $input = $(form.clk), input = $input[0];
|
588
|
+
n = input.name;
|
589
|
+
if (n && !input.disabled && input.type == 'image') {
|
590
|
+
a.push({name: n, value: $input.val()});
|
591
|
+
a.push({name: n + '.x', value: form.clk_x}, {name: n + '.y', value: form.clk_y});
|
592
|
+
}
|
593
|
+
}
|
594
|
+
return a;
|
595
|
+
};
|
596
|
+
|
597
|
+
/**
|
598
|
+
* Serializes form data into a 'submittable' string. This method will return a string
|
599
|
+
* in the format: name1=value1&name2=value2
|
600
|
+
*/
|
601
|
+
$.fn.formSerialize = function(semantic) {
|
602
|
+
//hand off to jQuery.param for proper encoding
|
603
|
+
return $.param(this.formToArray(semantic));
|
604
|
+
};
|
605
|
+
|
606
|
+
/**
|
607
|
+
* Serializes all field elements in the jQuery object into a query string.
|
608
|
+
* This method will return a string in the format: name1=value1&name2=value2
|
609
|
+
*/
|
610
|
+
$.fn.fieldSerialize = function(successful) {
|
611
|
+
var a = [];
|
612
|
+
this.each(function() {
|
613
|
+
var n = this.name;
|
614
|
+
if (!n) {
|
615
|
+
return;
|
616
|
+
}
|
617
|
+
var v = $.fieldValue(this, successful);
|
618
|
+
if (v && v.constructor == Array) {
|
619
|
+
for (var i = 0,max = v.length; i < max; i++) {
|
620
|
+
a.push({name: n, value: v[i]});
|
621
|
+
}
|
622
|
+
}
|
623
|
+
else if (v !== null && typeof v != 'undefined') {
|
624
|
+
a.push({name: this.name, value: v});
|
625
|
+
}
|
626
|
+
});
|
627
|
+
//hand off to jQuery.param for proper encoding
|
628
|
+
return $.param(a);
|
629
|
+
};
|
630
|
+
|
631
|
+
/**
|
632
|
+
* Returns the value(s) of the element in the matched set. For example, consider the following form:
|
633
|
+
*
|
634
|
+
* <form><fieldset>
|
635
|
+
* <input name="A" type="text" />
|
636
|
+
* <input name="A" type="text" />
|
637
|
+
* <input name="B" type="checkbox" value="B1" />
|
638
|
+
* <input name="B" type="checkbox" value="B2"/>
|
639
|
+
* <input name="C" type="radio" value="C1" />
|
640
|
+
* <input name="C" type="radio" value="C2" />
|
641
|
+
* </fieldset></form>
|
642
|
+
*
|
643
|
+
* var v = $(':text').fieldValue();
|
644
|
+
* // if no values are entered into the text inputs
|
645
|
+
* v == ['','']
|
646
|
+
* // if values entered into the text inputs are 'foo' and 'bar'
|
647
|
+
* v == ['foo','bar']
|
648
|
+
*
|
649
|
+
* var v = $(':checkbox').fieldValue();
|
650
|
+
* // if neither checkbox is checked
|
651
|
+
* v === undefined
|
652
|
+
* // if both checkboxes are checked
|
653
|
+
* v == ['B1', 'B2']
|
654
|
+
*
|
655
|
+
* var v = $(':radio').fieldValue();
|
656
|
+
* // if neither radio is checked
|
657
|
+
* v === undefined
|
658
|
+
* // if first radio is checked
|
659
|
+
* v == ['C1']
|
660
|
+
*
|
661
|
+
* The successful argument controls whether or not the field element must be 'successful'
|
662
|
+
* (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
|
663
|
+
* The default value of the successful argument is true. If this value is false the value(s)
|
664
|
+
* for each element is returned.
|
665
|
+
*
|
666
|
+
* Note: This method *always* returns an array. If no valid value can be determined the
|
667
|
+
* array will be empty, otherwise it will contain one or more values.
|
668
|
+
*/
|
669
|
+
$.fn.fieldValue = function(successful) {
|
670
|
+
for (var val = [], i = 0, max = this.length; i < max; i++) {
|
671
|
+
var el = this[i];
|
672
|
+
var v = $.fieldValue(el, successful);
|
673
|
+
if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) {
|
674
|
+
continue;
|
675
|
+
}
|
676
|
+
v.constructor == Array ? $.merge(val, v) : val.push(v);
|
677
|
+
}
|
678
|
+
return val;
|
679
|
+
};
|
680
|
+
|
681
|
+
/**
|
682
|
+
* Returns the value of the field element.
|
683
|
+
*/
|
684
|
+
$.fieldValue = function(el, successful) {
|
685
|
+
var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
|
686
|
+
if (successful === undefined) {
|
687
|
+
successful = true;
|
688
|
+
}
|
689
|
+
|
690
|
+
if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
|
691
|
+
(t == 'checkbox' || t == 'radio') && !el.checked ||
|
692
|
+
(t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
|
693
|
+
tag == 'select' && el.selectedIndex == -1)) {
|
694
|
+
return null;
|
695
|
+
}
|
696
|
+
|
697
|
+
if (tag == 'select') {
|
698
|
+
var index = el.selectedIndex;
|
699
|
+
if (index < 0) {
|
700
|
+
return null;
|
701
|
+
}
|
702
|
+
var a = [], ops = el.options;
|
703
|
+
var one = (t == 'select-one');
|
704
|
+
var max = (one ? index + 1 : ops.length);
|
705
|
+
for (var i = (one ? index : 0); i < max; i++) {
|
706
|
+
var op = ops[i];
|
707
|
+
if (op.selected) {
|
708
|
+
var v = op.value;
|
709
|
+
if (!v) { // extra pain for IE...
|
710
|
+
v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value;
|
711
|
+
}
|
712
|
+
if (one) {
|
713
|
+
return v;
|
714
|
+
}
|
715
|
+
a.push(v);
|
716
|
+
}
|
717
|
+
}
|
718
|
+
return a;
|
719
|
+
}
|
720
|
+
return $(el).val();
|
721
|
+
};
|
722
|
+
|
723
|
+
/**
|
724
|
+
* Clears the form data. Takes the following actions on the form's input fields:
|
725
|
+
* - input text fields will have their 'value' property set to the empty string
|
726
|
+
* - select elements will have their 'selectedIndex' property set to -1
|
727
|
+
* - checkbox and radio inputs will have their 'checked' property set to false
|
728
|
+
* - inputs of type submit, button, reset, and hidden will *not* be effected
|
729
|
+
* - button elements will *not* be effected
|
730
|
+
*/
|
731
|
+
$.fn.clearForm = function() {
|
732
|
+
return this.each(function() {
|
733
|
+
$('input,select,textarea', this).clearFields();
|
734
|
+
});
|
735
|
+
};
|
736
|
+
|
737
|
+
/**
|
738
|
+
* Clears the selected form elements.
|
739
|
+
*/
|
740
|
+
$.fn.clearFields = $.fn.clearInputs = function() {
|
741
|
+
return this.each(function() {
|
742
|
+
var t = this.type, tag = this.tagName.toLowerCase();
|
743
|
+
if (t == 'text' || t == 'password' || tag == 'textarea') {
|
744
|
+
this.value = '';
|
745
|
+
}
|
746
|
+
else if (t == 'checkbox' || t == 'radio') {
|
747
|
+
this.checked = false;
|
748
|
+
}
|
749
|
+
else if (tag == 'select') {
|
750
|
+
this.selectedIndex = -1;
|
751
|
+
}
|
752
|
+
});
|
753
|
+
};
|
754
|
+
|
755
|
+
/**
|
756
|
+
* Resets the form data. Causes all form elements to be reset to their original value.
|
757
|
+
*/
|
758
|
+
$.fn.resetForm = function() {
|
759
|
+
return this.each(function() {
|
760
|
+
// guard against an input with the name of 'reset'
|
761
|
+
// note that IE reports the reset function as an 'object'
|
762
|
+
if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) {
|
763
|
+
this.reset();
|
764
|
+
}
|
765
|
+
});
|
766
|
+
};
|
767
|
+
|
768
|
+
/**
|
769
|
+
* Enables or disables any matching elements.
|
770
|
+
*/
|
771
|
+
$.fn.enable = function(b) {
|
772
|
+
if (b === undefined) {
|
773
|
+
b = true;
|
774
|
+
}
|
775
|
+
return this.each(function() {
|
776
|
+
this.disabled = !b;
|
777
|
+
});
|
778
|
+
};
|
779
|
+
|
780
|
+
/**
|
781
|
+
* Checks/unchecks any matching checkboxes or radio buttons and
|
782
|
+
* selects/deselects and matching option elements.
|
783
|
+
*/
|
784
|
+
$.fn.selected = function(select) {
|
785
|
+
if (select === undefined) {
|
786
|
+
select = true;
|
787
|
+
}
|
788
|
+
return this.each(function() {
|
789
|
+
var t = this.type;
|
790
|
+
if (t == 'checkbox' || t == 'radio') {
|
791
|
+
this.checked = select;
|
792
|
+
}
|
793
|
+
else if (this.tagName.toLowerCase() == 'option') {
|
794
|
+
var $sel = $(this).parent('select');
|
795
|
+
if (select && $sel[0] && $sel[0].type == 'select-one') {
|
796
|
+
// deselect all other options
|
797
|
+
$sel.find('option').selected(false);
|
798
|
+
}
|
799
|
+
this.selected = select;
|
800
|
+
}
|
801
|
+
});
|
802
|
+
};
|
788
803
|
|
789
804
|
// helper fn for console logging
|
790
805
|
// set $.fn.ajaxSubmit.debug to true to enable debug logging
|
791
|
-
function log() {
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
}
|
806
|
+
function log() {
|
807
|
+
if ($.fn.ajaxSubmit.debug) {
|
808
|
+
var msg = '[jquery.form] ' + Array.prototype.join.call(arguments, '');
|
809
|
+
if (window.console && window.console.log) {
|
810
|
+
window.console.log(msg);
|
811
|
+
}
|
812
|
+
else if (window.opera && window.opera.postError) {
|
813
|
+
window.opera.postError(msg);
|
814
|
+
}
|
815
|
+
}
|
816
|
+
}
|
817
|
+
|
818
|
+
;
|
802
819
|
|
803
820
|
})(jQuery);
|