formula 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,378 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1323233710.53335: @value{ I" length:EFi�;I" digest;
2
+ F"%2caafa0c2617f9985c1a0b07ebaefadfI" source;
3
+ FI"�;(function($, undefined) {
4
+
5
+ /**
6
+ * Unobtrusive scripting adapter for jQuery
7
+ *
8
+ * Requires jQuery 1.6.0 or later.
9
+ * https://github.com/rails/jquery-ujs
10
+
11
+ * Uploading file using rails.js
12
+ * =============================
13
+ *
14
+ * By default, browsers do not allow files to be uploaded via AJAX. As a result, if there are any non-blank file fields
15
+ * in the remote form, this adapter aborts the AJAX submission and allows the form to submit through standard means.
16
+ *
17
+ * The `ajax:aborted:file` event allows you to bind your own handler to process the form submission however you wish.
18
+ *
19
+ * Ex:
20
+ * $('form').live('ajax:aborted:file', function(event, elements){
21
+ * // Implement own remote file-transfer handler here for non-blank file inputs passed in `elements`.
22
+ * // Returning false in this handler tells rails.js to disallow standard form submission
23
+ * return false;
24
+ * });
25
+ *
26
+ * The `ajax:aborted:file` event is fired when a file-type input is detected with a non-blank value.
27
+ *
28
+ * Third-party tools can use this hook to detect when an AJAX file upload is attempted, and then use
29
+ * techniques like the iframe method to upload the file instead.
30
+ *
31
+ * Required fields in rails.js
32
+ * ===========================
33
+ *
34
+ * If any blank required inputs (required="required") are detected in the remote form, the whole form submission
35
+ * is canceled. Note that this is unlike file inputs, which still allow standard (non-AJAX) form submission.
36
+ *
37
+ * The `ajax:aborted:required` event allows you to bind your own handler to inform the user of blank required inputs.
38
+ *
39
+ * !! Note that Opera does not fire the form's submit event if there are blank required inputs, so this event may never
40
+ * get fired in Opera. This event is what causes other browsers to exhibit the same submit-aborting behavior.
41
+ *
42
+ * Ex:
43
+ * $('form').live('ajax:aborted:required', function(event, elements){
44
+ * // Returning false in this handler tells rails.js to submit the form anyway.
45
+ * // The blank required inputs are passed to this function in `elements`.
46
+ * return ! confirm("Would you like to submit the form with missing info?");
47
+ * });
48
+ */
49
+
50
+ // Shorthand to make it a little easier to call public rails functions from within rails.js
51
+ var rails;
52
+
53
+ $.rails = rails = {
54
+ // Link elements bound by jquery-ujs
55
+ linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote], a[data-disable-with]',
56
+
57
+ // Select elements bound by jquery-ujs
58
+ inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]',
59
+
60
+ // Form elements bound by jquery-ujs
61
+ formSubmitSelector: 'form',
62
+
63
+ // Form input elements bound by jquery-ujs
64
+ formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not(button[type])',
65
+
66
+ // Form input elements disabled during form submission
67
+ disableSelector: 'input[data-disable-with], button[data-disable-with], textarea[data-disable-with]',
68
+
69
+ // Form input elements re-enabled after form submission
70
+ enableSelector: 'input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled',
71
+
72
+ // Form required input elements
73
+ requiredInputSelector: 'input[name][required]:not([disabled]),textarea[name][required]:not([disabled])',
74
+
75
+ // Form file input elements
76
+ fileInputSelector: 'input:file',
77
+
78
+ // Link onClick disable selector with possible reenable after remote submission
79
+ linkDisableSelector: 'a[data-disable-with]',
80
+
81
+ // Make sure that every Ajax request sends the CSRF token
82
+ CSRFProtection: function(xhr) {
83
+ var token = $('meta[name="csrf-token"]').attr('content');
84
+ if (token) xhr.setRequestHeader('X-CSRF-Token', token);
85
+ },
86
+
87
+ // Triggers an event on an element and returns false if the event result is false
88
+ fire: function(obj, name, data) {
89
+ var event = $.Event(name);
90
+ obj.trigger(event, data);
91
+ return event.result !== false;
92
+ },
93
+
94
+ // Default confirm dialog, may be overridden with custom confirm dialog in $.rails.confirm
95
+ confirm: function(message) {
96
+ return confirm(message);
97
+ },
98
+
99
+ // Default ajax function, may be overridden with custom function in $.rails.ajax
100
+ ajax: function(options) {
101
+ return $.ajax(options);
102
+ },
103
+
104
+ // Submits "remote" forms and links with ajax
105
+ handleRemote: function(element) {
106
+ var method, url, data,
107
+ crossDomain = element.data('cross-domain') || null,
108
+ dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType),
109
+ options;
110
+
111
+ if (rails.fire(element, 'ajax:before')) {
112
+
113
+ if (element.is('form')) {
114
+ method = element.attr('method');
115
+ url = element.attr('action');
116
+ data = element.serializeArray();
117
+ // memoized value from clicked submit button
118
+ var button = element.data('ujs:submit-button');
119
+ if (button) {
120
+ data.push(button);
121
+ element.data('ujs:submit-button', null);
122
+ }
123
+ } else if (element.is(rails.inputChangeSelector)) {
124
+ method = element.data('method');
125
+ url = element.data('url');
126
+ data = element.serialize();
127
+ if (element.data('params')) data = data + "&" + element.data('params');
128
+ } else {
129
+ method = element.data('method');
130
+ url = element.attr('href');
131
+ data = element.data('params') || null;
132
+ }
133
+
134
+ options = {
135
+ type: method || 'GET', data: data, dataType: dataType, crossDomain: crossDomain,
136
+ // stopping the "ajax:beforeSend" event will cancel the ajax request
137
+ beforeSend: function(xhr, settings) {
138
+ if (settings.dataType === undefined) {
139
+ xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script);
140
+ }
141
+ return rails.fire(element, 'ajax:beforeSend', [xhr, settings]);
142
+ },
143
+ success: function(data, status, xhr) {
144
+ element.trigger('ajax:success', [data, status, xhr]);
145
+ },
146
+ complete: function(xhr, status) {
147
+ element.trigger('ajax:complete', [xhr, status]);
148
+ },
149
+ error: function(xhr, status, error) {
150
+ element.trigger('ajax:error', [xhr, status, error]);
151
+ }
152
+ };
153
+ // Only pass url to `ajax` options if not blank
154
+ if (url) { options.url = url; }
155
+
156
+ return rails.ajax(options);
157
+ } else {
158
+ return false;
159
+ }
160
+ },
161
+
162
+ // Handles "data-method" on links such as:
163
+ // <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a>
164
+ handleMethod: function(link) {
165
+ var href = link.attr('href'),
166
+ method = link.data('method'),
167
+ target = link.attr('target'),
168
+ csrf_token = $('meta[name=csrf-token]').attr('content'),
169
+ csrf_param = $('meta[name=csrf-param]').attr('content'),
170
+ form = $('<form method="post" action="' + href + '"></form>'),
171
+ metadata_input = '<input name="_method" value="' + method + '" type="hidden" />';
172
+
173
+ if (csrf_param !== undefined && csrf_token !== undefined) {
174
+ metadata_input += '<input name="' + csrf_param + '" value="' + csrf_token + '" type="hidden" />';
175
+ }
176
+
177
+ if (target) { form.attr('target', target); }
178
+
179
+ form.hide().append(metadata_input).appendTo('body');
180
+ form.submit();
181
+ },
182
+
183
+ /* Disables form elements:
184
+ - Caches element value in 'ujs:enable-with' data store
185
+ - Replaces element text with value of 'data-disable-with' attribute
186
+ - Sets disabled property to true
187
+ */
188
+ disableFormElements: function(form) {
189
+ form.find(rails.disableSelector).each(function() {
190
+ var element = $(this), method = element.is('button') ? 'html' : 'val';
191
+ element.data('ujs:enable-with', element[method]());
192
+ element[method](element.data('disable-with'));
193
+ element.prop('disabled', true);
194
+ });
195
+ },
196
+
197
+ /* Re-enables disabled form elements:
198
+ - Replaces element text with cached value from 'ujs:enable-with' data store (created in `disableFormElements`)
199
+ - Sets disabled property to false
200
+ */
201
+ enableFormElements: function(form) {
202
+ form.find(rails.enableSelector).each(function() {
203
+ var element = $(this), method = element.is('button') ? 'html' : 'val';
204
+ if (element.data('ujs:enable-with')) element[method](element.data('ujs:enable-with'));
205
+ element.prop('disabled', false);
206
+ });
207
+ },
208
+
209
+ /* For 'data-confirm' attribute:
210
+ - Fires `confirm` event
211
+ - Shows the confirmation dialog
212
+ - Fires the `confirm:complete` event
213
+
214
+ Returns `true` if no function stops the chain and user chose yes; `false` otherwise.
215
+ Attaching a handler to the element's `confirm` event that returns a `falsy` value cancels the confirmation dialog.
216
+ Attaching a handler to the element's `confirm:complete` event that returns a `falsy` value makes this function
217
+ return false. The `confirm:complete` event is fired whether or not the user answered true or false to the dialog.
218
+ */
219
+ allowAction: function(element) {
220
+ var message = element.data('confirm'),
221
+ answer = false, callback;
222
+ if (!message) { return true; }
223
+
224
+ if (rails.fire(element, 'confirm')) {
225
+ answer = rails.confirm(message);
226
+ callback = rails.fire(element, 'confirm:complete', [answer]);
227
+ }
228
+ return answer && callback;
229
+ },
230
+
231
+ // Helper function which checks for blank inputs in a form that match the specified CSS selector
232
+ blankInputs: function(form, specifiedSelector, nonBlank) {
233
+ var inputs = $(), input,
234
+ selector = specifiedSelector || 'input,textarea';
235
+ form.find(selector).each(function() {
236
+ input = $(this);
237
+ // Collect non-blank inputs if nonBlank option is true, otherwise, collect blank inputs
238
+ if (nonBlank ? input.val() : !input.val()) {
239
+ inputs = inputs.add(input);
240
+ }
241
+ });
242
+ return inputs.length ? inputs : false;
243
+ },
244
+
245
+ // Helper function which checks for non-blank inputs in a form that match the specified CSS selector
246
+ nonBlankInputs: function(form, specifiedSelector) {
247
+ return rails.blankInputs(form, specifiedSelector, true); // true specifies nonBlank
248
+ },
249
+
250
+ // Helper function, needed to provide consistent behavior in IE
251
+ stopEverything: function(e) {
252
+ $(e.target).trigger('ujs:everythingStopped');
253
+ e.stopImmediatePropagation();
254
+ return false;
255
+ },
256
+
257
+ // find all the submit events directly bound to the form and
258
+ // manually invoke them. If anyone returns false then stop the loop
259
+ callFormSubmitBindings: function(form, event) {
260
+ var events = form.data('events'), continuePropagation = true;
261
+ if (events !== undefined && events['submit'] !== undefined) {
262
+ $.each(events['submit'], function(i, obj){
263
+ if (typeof obj.handler === 'function') return continuePropagation = obj.handler(event);
264
+ });
265
+ }
266
+ return continuePropagation;
267
+ },
268
+
269
+ // replace element's html with the 'data-disable-with' after storing original html
270
+ // and prevent clicking on it
271
+ disableElement: function(element) {
272
+ element.data('ujs:enable-with', element.html()); // store enabled state
273
+ element.html(element.data('disable-with')); // set to disabled state
274
+ element.bind('click.railsDisable', function(e) { // prevent further clicking
275
+ return rails.stopEverything(e)
276
+ });
277
+ },
278
+
279
+ // restore element to its original state which was disabled by 'disableElement' above
280
+ enableElement: function(element) {
281
+ if (element.data('ujs:enable-with') !== undefined) {
282
+ element.html(element.data('ujs:enable-with')); // set to old enabled state
283
+ // this should be element.removeData('ujs:enable-with')
284
+ // but, there is currently a bug in jquery which makes hyphenated data attributes not get removed
285
+ element.data('ujs:enable-with', false); // clean up cache
286
+ }
287
+ element.unbind('click.railsDisable'); // enable element
288
+ }
289
+
290
+ };
291
+
292
+ $.ajaxPrefilter(function(options, originalOptions, xhr){ if ( !options.crossDomain ) { rails.CSRFProtection(xhr); }});
293
+
294
+ $(document).delegate(rails.linkDisableSelector, 'ajax:complete', function() {
295
+ rails.enableElement($(this));
296
+ });
297
+
298
+ $(document).delegate(rails.linkClickSelector, 'click.rails', function(e) {
299
+ var link = $(this), method = link.data('method'), data = link.data('params');
300
+ if (!rails.allowAction(link)) return rails.stopEverything(e);
301
+
302
+ if (link.is(rails.linkDisableSelector)) rails.disableElement(link);
303
+
304
+ if (link.data('remote') !== undefined) {
305
+ if ( (e.metaKey || e.ctrlKey) && (!method || method === 'GET') && !data ) { return true; }
306
+
307
+ if (rails.handleRemote(link) === false) { rails.enableElement(link); }
308
+ return false;
309
+
310
+ } else if (link.data('method')) {
311
+ rails.handleMethod(link);
312
+ return false;
313
+ }
314
+ });
315
+
316
+ $(document).delegate(rails.inputChangeSelector, 'change.rails', function(e) {
317
+ var link = $(this);
318
+ if (!rails.allowAction(link)) return rails.stopEverything(e);
319
+
320
+ rails.handleRemote(link);
321
+ return false;
322
+ });
323
+
324
+ $(document).delegate(rails.formSubmitSelector, 'submit.rails', function(e) {
325
+ var form = $(this),
326
+ remote = form.data('remote') !== undefined,
327
+ blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector),
328
+ nonBlankFileInputs = rails.nonBlankInputs(form, rails.fileInputSelector);
329
+
330
+ if (!rails.allowAction(form)) return rails.stopEverything(e);
331
+
332
+ // skip other logic when required values are missing or file upload is present
333
+ if (blankRequiredInputs && form.attr("novalidate") == undefined && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) {
334
+ return rails.stopEverything(e);
335
+ }
336
+
337
+ if (remote) {
338
+ if (nonBlankFileInputs) {
339
+ return rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]);
340
+ }
341
+
342
+ // If browser does not support submit bubbling, then this live-binding will be called before direct
343
+ // bindings. Therefore, we should directly call any direct bindings before remotely submitting form.
344
+ if (!$.support.submitBubbles && $().jquery < '1.7' && rails.callFormSubmitBindings(form, e) === false) return rails.stopEverything(e);
345
+
346
+ rails.handleRemote(form);
347
+ return false;
348
+
349
+ } else {
350
+ // slight timeout so that the submit button gets properly serialized
351
+ setTimeout(function(){ rails.disableFormElements(form); }, 13);
352
+ }
353
+ });
354
+
355
+ $(document).delegate(rails.formInputClickSelector, 'click.rails', function(event) {
356
+ var button = $(this);
357
+
358
+ if (!rails.allowAction(button)) return rails.stopEverything(event);
359
+
360
+ // register the pressed submit button
361
+ var name = button.attr('name'),
362
+ data = name ? {name:name, value:button.val()} : null;
363
+
364
+ button.closest('form').data('ujs:submit-button', data);
365
+ });
366
+
367
+ $(document).delegate(rails.formSubmitSelector, 'ajax:beforeSend.rails', function(event) {
368
+ if (this == event.target) rails.disableFormElements($(this));
369
+ });
370
+
371
+ $(document).delegate(rails.formSubmitSelector, 'ajax:complete.rails', function(event) {
372
+ if (this == event.target) rails.enableFormElements($(this));
373
+ });
374
+
375
+ })( jQuery );
376
+ ;
377
+ FI"
378
+ F"%3ea40a8087cc8bf60a1ff143d9794c77
@@ -0,0 +1,394 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1323233710.5091178: @value{I"
2
+ class:EFI"BundledAsset;
3
+ FI"id;
4
+ F"%3ea40a8087cc8bf60a1ff143d9794c77I"logical_path;
5
+ F"jquery_ujs.jsI"
6
+ F"j/Users/kevin/.rvm/gems/ruby-1.9.3-p0/gems/jquery-rails-1.0.19/vendor/assets/javascripts/jquery_ujs.jsI"content_type;
7
+ FI"application/javascript;
8
+ FI"
9
+ mtime;
10
+ FI"2011-11-25T22:59:55-08:00;
11
+ FI" body;
12
+ FI"�;(function($, undefined) {
13
+
14
+ /**
15
+ * Unobtrusive scripting adapter for jQuery
16
+ *
17
+ * Requires jQuery 1.6.0 or later.
18
+ * https://github.com/rails/jquery-ujs
19
+
20
+ * Uploading file using rails.js
21
+ * =============================
22
+ *
23
+ * By default, browsers do not allow files to be uploaded via AJAX. As a result, if there are any non-blank file fields
24
+ * in the remote form, this adapter aborts the AJAX submission and allows the form to submit through standard means.
25
+ *
26
+ * The `ajax:aborted:file` event allows you to bind your own handler to process the form submission however you wish.
27
+ *
28
+ * Ex:
29
+ * $('form').live('ajax:aborted:file', function(event, elements){
30
+ * // Implement own remote file-transfer handler here for non-blank file inputs passed in `elements`.
31
+ * // Returning false in this handler tells rails.js to disallow standard form submission
32
+ * return false;
33
+ * });
34
+ *
35
+ * The `ajax:aborted:file` event is fired when a file-type input is detected with a non-blank value.
36
+ *
37
+ * Third-party tools can use this hook to detect when an AJAX file upload is attempted, and then use
38
+ * techniques like the iframe method to upload the file instead.
39
+ *
40
+ * Required fields in rails.js
41
+ * ===========================
42
+ *
43
+ * If any blank required inputs (required="required") are detected in the remote form, the whole form submission
44
+ * is canceled. Note that this is unlike file inputs, which still allow standard (non-AJAX) form submission.
45
+ *
46
+ * The `ajax:aborted:required` event allows you to bind your own handler to inform the user of blank required inputs.
47
+ *
48
+ * !! Note that Opera does not fire the form's submit event if there are blank required inputs, so this event may never
49
+ * get fired in Opera. This event is what causes other browsers to exhibit the same submit-aborting behavior.
50
+ *
51
+ * Ex:
52
+ * $('form').live('ajax:aborted:required', function(event, elements){
53
+ * // Returning false in this handler tells rails.js to submit the form anyway.
54
+ * // The blank required inputs are passed to this function in `elements`.
55
+ * return ! confirm("Would you like to submit the form with missing info?");
56
+ * });
57
+ */
58
+
59
+ // Shorthand to make it a little easier to call public rails functions from within rails.js
60
+ var rails;
61
+
62
+ $.rails = rails = {
63
+ // Link elements bound by jquery-ujs
64
+ linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote], a[data-disable-with]',
65
+
66
+ // Select elements bound by jquery-ujs
67
+ inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]',
68
+
69
+ // Form elements bound by jquery-ujs
70
+ formSubmitSelector: 'form',
71
+
72
+ // Form input elements bound by jquery-ujs
73
+ formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not(button[type])',
74
+
75
+ // Form input elements disabled during form submission
76
+ disableSelector: 'input[data-disable-with], button[data-disable-with], textarea[data-disable-with]',
77
+
78
+ // Form input elements re-enabled after form submission
79
+ enableSelector: 'input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled',
80
+
81
+ // Form required input elements
82
+ requiredInputSelector: 'input[name][required]:not([disabled]),textarea[name][required]:not([disabled])',
83
+
84
+ // Form file input elements
85
+ fileInputSelector: 'input:file',
86
+
87
+ // Link onClick disable selector with possible reenable after remote submission
88
+ linkDisableSelector: 'a[data-disable-with]',
89
+
90
+ // Make sure that every Ajax request sends the CSRF token
91
+ CSRFProtection: function(xhr) {
92
+ var token = $('meta[name="csrf-token"]').attr('content');
93
+ if (token) xhr.setRequestHeader('X-CSRF-Token', token);
94
+ },
95
+
96
+ // Triggers an event on an element and returns false if the event result is false
97
+ fire: function(obj, name, data) {
98
+ var event = $.Event(name);
99
+ obj.trigger(event, data);
100
+ return event.result !== false;
101
+ },
102
+
103
+ // Default confirm dialog, may be overridden with custom confirm dialog in $.rails.confirm
104
+ confirm: function(message) {
105
+ return confirm(message);
106
+ },
107
+
108
+ // Default ajax function, may be overridden with custom function in $.rails.ajax
109
+ ajax: function(options) {
110
+ return $.ajax(options);
111
+ },
112
+
113
+ // Submits "remote" forms and links with ajax
114
+ handleRemote: function(element) {
115
+ var method, url, data,
116
+ crossDomain = element.data('cross-domain') || null,
117
+ dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType),
118
+ options;
119
+
120
+ if (rails.fire(element, 'ajax:before')) {
121
+
122
+ if (element.is('form')) {
123
+ method = element.attr('method');
124
+ url = element.attr('action');
125
+ data = element.serializeArray();
126
+ // memoized value from clicked submit button
127
+ var button = element.data('ujs:submit-button');
128
+ if (button) {
129
+ data.push(button);
130
+ element.data('ujs:submit-button', null);
131
+ }
132
+ } else if (element.is(rails.inputChangeSelector)) {
133
+ method = element.data('method');
134
+ url = element.data('url');
135
+ data = element.serialize();
136
+ if (element.data('params')) data = data + "&" + element.data('params');
137
+ } else {
138
+ method = element.data('method');
139
+ url = element.attr('href');
140
+ data = element.data('params') || null;
141
+ }
142
+
143
+ options = {
144
+ type: method || 'GET', data: data, dataType: dataType, crossDomain: crossDomain,
145
+ // stopping the "ajax:beforeSend" event will cancel the ajax request
146
+ beforeSend: function(xhr, settings) {
147
+ if (settings.dataType === undefined) {
148
+ xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script);
149
+ }
150
+ return rails.fire(element, 'ajax:beforeSend', [xhr, settings]);
151
+ },
152
+ success: function(data, status, xhr) {
153
+ element.trigger('ajax:success', [data, status, xhr]);
154
+ },
155
+ complete: function(xhr, status) {
156
+ element.trigger('ajax:complete', [xhr, status]);
157
+ },
158
+ error: function(xhr, status, error) {
159
+ element.trigger('ajax:error', [xhr, status, error]);
160
+ }
161
+ };
162
+ // Only pass url to `ajax` options if not blank
163
+ if (url) { options.url = url; }
164
+
165
+ return rails.ajax(options);
166
+ } else {
167
+ return false;
168
+ }
169
+ },
170
+
171
+ // Handles "data-method" on links such as:
172
+ // <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a>
173
+ handleMethod: function(link) {
174
+ var href = link.attr('href'),
175
+ method = link.data('method'),
176
+ target = link.attr('target'),
177
+ csrf_token = $('meta[name=csrf-token]').attr('content'),
178
+ csrf_param = $('meta[name=csrf-param]').attr('content'),
179
+ form = $('<form method="post" action="' + href + '"></form>'),
180
+ metadata_input = '<input name="_method" value="' + method + '" type="hidden" />';
181
+
182
+ if (csrf_param !== undefined && csrf_token !== undefined) {
183
+ metadata_input += '<input name="' + csrf_param + '" value="' + csrf_token + '" type="hidden" />';
184
+ }
185
+
186
+ if (target) { form.attr('target', target); }
187
+
188
+ form.hide().append(metadata_input).appendTo('body');
189
+ form.submit();
190
+ },
191
+
192
+ /* Disables form elements:
193
+ - Caches element value in 'ujs:enable-with' data store
194
+ - Replaces element text with value of 'data-disable-with' attribute
195
+ - Sets disabled property to true
196
+ */
197
+ disableFormElements: function(form) {
198
+ form.find(rails.disableSelector).each(function() {
199
+ var element = $(this), method = element.is('button') ? 'html' : 'val';
200
+ element.data('ujs:enable-with', element[method]());
201
+ element[method](element.data('disable-with'));
202
+ element.prop('disabled', true);
203
+ });
204
+ },
205
+
206
+ /* Re-enables disabled form elements:
207
+ - Replaces element text with cached value from 'ujs:enable-with' data store (created in `disableFormElements`)
208
+ - Sets disabled property to false
209
+ */
210
+ enableFormElements: function(form) {
211
+ form.find(rails.enableSelector).each(function() {
212
+ var element = $(this), method = element.is('button') ? 'html' : 'val';
213
+ if (element.data('ujs:enable-with')) element[method](element.data('ujs:enable-with'));
214
+ element.prop('disabled', false);
215
+ });
216
+ },
217
+
218
+ /* For 'data-confirm' attribute:
219
+ - Fires `confirm` event
220
+ - Shows the confirmation dialog
221
+ - Fires the `confirm:complete` event
222
+
223
+ Returns `true` if no function stops the chain and user chose yes; `false` otherwise.
224
+ Attaching a handler to the element's `confirm` event that returns a `falsy` value cancels the confirmation dialog.
225
+ Attaching a handler to the element's `confirm:complete` event that returns a `falsy` value makes this function
226
+ return false. The `confirm:complete` event is fired whether or not the user answered true or false to the dialog.
227
+ */
228
+ allowAction: function(element) {
229
+ var message = element.data('confirm'),
230
+ answer = false, callback;
231
+ if (!message) { return true; }
232
+
233
+ if (rails.fire(element, 'confirm')) {
234
+ answer = rails.confirm(message);
235
+ callback = rails.fire(element, 'confirm:complete', [answer]);
236
+ }
237
+ return answer && callback;
238
+ },
239
+
240
+ // Helper function which checks for blank inputs in a form that match the specified CSS selector
241
+ blankInputs: function(form, specifiedSelector, nonBlank) {
242
+ var inputs = $(), input,
243
+ selector = specifiedSelector || 'input,textarea';
244
+ form.find(selector).each(function() {
245
+ input = $(this);
246
+ // Collect non-blank inputs if nonBlank option is true, otherwise, collect blank inputs
247
+ if (nonBlank ? input.val() : !input.val()) {
248
+ inputs = inputs.add(input);
249
+ }
250
+ });
251
+ return inputs.length ? inputs : false;
252
+ },
253
+
254
+ // Helper function which checks for non-blank inputs in a form that match the specified CSS selector
255
+ nonBlankInputs: function(form, specifiedSelector) {
256
+ return rails.blankInputs(form, specifiedSelector, true); // true specifies nonBlank
257
+ },
258
+
259
+ // Helper function, needed to provide consistent behavior in IE
260
+ stopEverything: function(e) {
261
+ $(e.target).trigger('ujs:everythingStopped');
262
+ e.stopImmediatePropagation();
263
+ return false;
264
+ },
265
+
266
+ // find all the submit events directly bound to the form and
267
+ // manually invoke them. If anyone returns false then stop the loop
268
+ callFormSubmitBindings: function(form, event) {
269
+ var events = form.data('events'), continuePropagation = true;
270
+ if (events !== undefined && events['submit'] !== undefined) {
271
+ $.each(events['submit'], function(i, obj){
272
+ if (typeof obj.handler === 'function') return continuePropagation = obj.handler(event);
273
+ });
274
+ }
275
+ return continuePropagation;
276
+ },
277
+
278
+ // replace element's html with the 'data-disable-with' after storing original html
279
+ // and prevent clicking on it
280
+ disableElement: function(element) {
281
+ element.data('ujs:enable-with', element.html()); // store enabled state
282
+ element.html(element.data('disable-with')); // set to disabled state
283
+ element.bind('click.railsDisable', function(e) { // prevent further clicking
284
+ return rails.stopEverything(e)
285
+ });
286
+ },
287
+
288
+ // restore element to its original state which was disabled by 'disableElement' above
289
+ enableElement: function(element) {
290
+ if (element.data('ujs:enable-with') !== undefined) {
291
+ element.html(element.data('ujs:enable-with')); // set to old enabled state
292
+ // this should be element.removeData('ujs:enable-with')
293
+ // but, there is currently a bug in jquery which makes hyphenated data attributes not get removed
294
+ element.data('ujs:enable-with', false); // clean up cache
295
+ }
296
+ element.unbind('click.railsDisable'); // enable element
297
+ }
298
+
299
+ };
300
+
301
+ $.ajaxPrefilter(function(options, originalOptions, xhr){ if ( !options.crossDomain ) { rails.CSRFProtection(xhr); }});
302
+
303
+ $(document).delegate(rails.linkDisableSelector, 'ajax:complete', function() {
304
+ rails.enableElement($(this));
305
+ });
306
+
307
+ $(document).delegate(rails.linkClickSelector, 'click.rails', function(e) {
308
+ var link = $(this), method = link.data('method'), data = link.data('params');
309
+ if (!rails.allowAction(link)) return rails.stopEverything(e);
310
+
311
+ if (link.is(rails.linkDisableSelector)) rails.disableElement(link);
312
+
313
+ if (link.data('remote') !== undefined) {
314
+ if ( (e.metaKey || e.ctrlKey) && (!method || method === 'GET') && !data ) { return true; }
315
+
316
+ if (rails.handleRemote(link) === false) { rails.enableElement(link); }
317
+ return false;
318
+
319
+ } else if (link.data('method')) {
320
+ rails.handleMethod(link);
321
+ return false;
322
+ }
323
+ });
324
+
325
+ $(document).delegate(rails.inputChangeSelector, 'change.rails', function(e) {
326
+ var link = $(this);
327
+ if (!rails.allowAction(link)) return rails.stopEverything(e);
328
+
329
+ rails.handleRemote(link);
330
+ return false;
331
+ });
332
+
333
+ $(document).delegate(rails.formSubmitSelector, 'submit.rails', function(e) {
334
+ var form = $(this),
335
+ remote = form.data('remote') !== undefined,
336
+ blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector),
337
+ nonBlankFileInputs = rails.nonBlankInputs(form, rails.fileInputSelector);
338
+
339
+ if (!rails.allowAction(form)) return rails.stopEverything(e);
340
+
341
+ // skip other logic when required values are missing or file upload is present
342
+ if (blankRequiredInputs && form.attr("novalidate") == undefined && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) {
343
+ return rails.stopEverything(e);
344
+ }
345
+
346
+ if (remote) {
347
+ if (nonBlankFileInputs) {
348
+ return rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]);
349
+ }
350
+
351
+ // If browser does not support submit bubbling, then this live-binding will be called before direct
352
+ // bindings. Therefore, we should directly call any direct bindings before remotely submitting form.
353
+ if (!$.support.submitBubbles && $().jquery < '1.7' && rails.callFormSubmitBindings(form, e) === false) return rails.stopEverything(e);
354
+
355
+ rails.handleRemote(form);
356
+ return false;
357
+
358
+ } else {
359
+ // slight timeout so that the submit button gets properly serialized
360
+ setTimeout(function(){ rails.disableFormElements(form); }, 13);
361
+ }
362
+ });
363
+
364
+ $(document).delegate(rails.formInputClickSelector, 'click.rails', function(event) {
365
+ var button = $(this);
366
+
367
+ if (!rails.allowAction(button)) return rails.stopEverything(event);
368
+
369
+ // register the pressed submit button
370
+ var name = button.attr('name'),
371
+ data = name ? {name:name, value:button.val()} : null;
372
+
373
+ button.closest('form').data('ujs:submit-button', data);
374
+ });
375
+
376
+ $(document).delegate(rails.formSubmitSelector, 'ajax:beforeSend.rails', function(event) {
377
+ if (this == event.target) rails.disableFormElements($(this));
378
+ });
379
+
380
+ $(document).delegate(rails.formSubmitSelector, 'ajax:complete.rails', function(event) {
381
+ if (this == event.target) rails.enableFormElements($(this));
382
+ });
383
+
384
+ })( jQuery );
385
+ ;
386
+ FI"asset_paths;
387
+ F["j/Users/kevin/.rvm/gems/ruby-1.9.3-p0/gems/jquery-rails-1.0.19/vendor/assets/javascripts/jquery_ujs.jsI"dependency_paths;
388
+ F[{I" path;
389
+ F"j/Users/kevin/.rvm/gems/ruby-1.9.3-p0/gems/jquery-rails-1.0.19/vendor/assets/javascripts/jquery_ujs.jsI"
390
+ mtime;
391
+ FIu: Time
392
+ T: offseti���I"hexdigest;
393
+ F"%2caafa0c2617f9985c1a0b07ebaefadfI"
394
+ F"%46dde6621c301f4928e3b34efee9e3b5