rep.jquery 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/.gitignore +25 -0
  2. data/LICENSE +20 -0
  3. data/README +1 -0
  4. data/Rakefile +19 -0
  5. data/TODO +0 -0
  6. data/VERSION +1 -0
  7. data/lib/jquery.rb +1 -0
  8. data/public/images/jquery.tablesorter.blue/asc.gif +0 -0
  9. data/public/images/jquery.tablesorter.blue/bg.gif +0 -0
  10. data/public/images/jquery.tablesorter.blue/desc.gif +0 -0
  11. data/public/images/jquery.tablesorter.blue/style.css +39 -0
  12. data/public/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  13. data/public/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  14. data/public/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  15. data/public/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  16. data/public/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  17. data/public/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  18. data/public/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  19. data/public/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  20. data/public/images/ui-icons_222222_256x240.png +0 -0
  21. data/public/images/ui-icons_2e83ff_256x240.png +0 -0
  22. data/public/images/ui-icons_454545_256x240.png +0 -0
  23. data/public/images/ui-icons_888888_256x240.png +0 -0
  24. data/public/images/ui-icons_cd0a0a_256x240.png +0 -0
  25. data/public/javascripts/jquery/autogrow.js +134 -0
  26. data/public/javascripts/jquery/easing.js +207 -0
  27. data/public/javascripts/jquery/form.js +639 -0
  28. data/public/javascripts/jquery/jeditable.autogrow.js +41 -0
  29. data/public/javascripts/jquery/jeditable.js +545 -0
  30. data/public/javascripts/jquery/metadata.js +150 -0
  31. data/public/javascripts/jquery/scrollTo.js +217 -0
  32. data/public/javascripts/jquery/suggest.js +314 -0
  33. data/public/javascripts/jquery/tablesorter.patched.js +866 -0
  34. data/public/javascripts/jquery/template.js +93 -0
  35. data/public/javascripts/jquery/tooltip.js +296 -0
  36. data/public/javascripts/jquery/ui.all.js +300 -0
  37. data/public/javascripts/jquery.js +4376 -0
  38. data/public/stylesheets/jquery-ui.css +404 -0
  39. data/public/stylesheets/jquery.suggest.css +29 -0
  40. data/rep.jquery.gemspec +81 -0
  41. metadata +119 -0
@@ -0,0 +1,639 @@
1
+ //= require "../jquery"
2
+
3
+ /*
4
+ * jQuery Form Plugin
5
+ * version: 2.24 (10-MAR-2009)
6
+ * @requires jQuery v1.2.2 or later
7
+ *
8
+ * Examples and documentation at: http://malsup.com/jquery/form/
9
+ * Dual licensed under the MIT and GPL licenses:
10
+ * http://www.opensource.org/licenses/mit-license.php
11
+ * http://www.gnu.org/licenses/gpl.html
12
+ */
13
+ ;(function($) {
14
+
15
+ /*
16
+ Usage Note:
17
+ -----------
18
+ Do not use both ajaxSubmit and ajaxForm on the same form. These
19
+ functions are intended to be exclusive. Use ajaxSubmit if you want
20
+ to bind your own submit handler to the form. For example,
21
+
22
+ $(document).ready(function() {
23
+ $('#myForm').bind('submit', function() {
24
+ $(this).ajaxSubmit({
25
+ target: '#output'
26
+ });
27
+ return false; // <-- important!
28
+ });
29
+ });
30
+
31
+ Use ajaxForm when you want the plugin to manage all the event binding
32
+ for you. For example,
33
+
34
+ $(document).ready(function() {
35
+ $('#myForm').ajaxForm({
36
+ target: '#output'
37
+ });
38
+ });
39
+
40
+ When using ajaxForm, the ajaxSubmit function will be invoked for you
41
+ at the appropriate time.
42
+ */
43
+
44
+ /**
45
+ * ajaxSubmit() provides a mechanism for immediately submitting
46
+ * an HTML form using AJAX.
47
+ */
48
+ $.fn.ajaxSubmit = function(options) {
49
+ // fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
50
+ if (!this.length) {
51
+ log('ajaxSubmit: skipping submit process - no element selected');
52
+ return this;
53
+ }
54
+
55
+ if (typeof options == 'function')
56
+ options = { success: options };
57
+
58
+ // clean url (don't include hash vaue)
59
+ var url = this.attr('action') || window.location.href;
60
+ url = (url.match(/^([^#]+)/)||[])[1];
61
+ url = url || '';
62
+
63
+ options = $.extend({
64
+ url: url,
65
+ type: this.attr('method') || 'GET'
66
+ }, options || {});
67
+
68
+ // hook for manipulating the form data before it is extracted;
69
+ // convenient for use with rich editors like tinyMCE or FCKEditor
70
+ var veto = {};
71
+ this.trigger('form-pre-serialize', [this, options, veto]);
72
+ if (veto.veto) {
73
+ log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');
74
+ return this;
75
+ }
76
+
77
+ // provide opportunity to alter form data before it is serialized
78
+ if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {
79
+ log('ajaxSubmit: submit aborted via beforeSerialize callback');
80
+ return this;
81
+ }
82
+
83
+ var a = this.formToArray(options.semantic);
84
+ if (options.data) {
85
+ options.extraData = options.data;
86
+ for (var n in options.data) {
87
+ if(options.data[n] instanceof Array) {
88
+ for (var k in options.data[n])
89
+ a.push( { name: n, value: options.data[n][k] } );
90
+ }
91
+ else
92
+ a.push( { name: n, value: options.data[n] } );
93
+ }
94
+ }
95
+
96
+ // give pre-submit callback an opportunity to abort the submit
97
+ if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {
98
+ log('ajaxSubmit: submit aborted via beforeSubmit callback');
99
+ return this;
100
+ }
101
+
102
+ // fire vetoable 'validate' event
103
+ this.trigger('form-submit-validate', [a, this, options, veto]);
104
+ if (veto.veto) {
105
+ log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
106
+ return this;
107
+ }
108
+
109
+ var q = $.param(a);
110
+
111
+ if (options.type.toUpperCase() == 'GET') {
112
+ options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
113
+ options.data = null; // data is null for 'get'
114
+ }
115
+ else
116
+ options.data = q; // data is the query string for 'post'
117
+
118
+ var $form = this, callbacks = [];
119
+ if (options.resetForm) callbacks.push(function() { $form.resetForm(); });
120
+ if (options.clearForm) callbacks.push(function() { $form.clearForm(); });
121
+
122
+ // perform a load on the target only if dataType is not provided
123
+ if (!options.dataType && options.target) {
124
+ var oldSuccess = options.success || function(){};
125
+ callbacks.push(function(data) {
126
+ $(options.target).html(data).each(oldSuccess, arguments);
127
+ });
128
+ }
129
+ else if (options.success)
130
+ callbacks.push(options.success);
131
+
132
+ options.success = function(data, status) {
133
+ for (var i=0, max=callbacks.length; i < max; i++)
134
+ callbacks[i].apply(options, [data, status, $form]);
135
+ };
136
+
137
+ // are there files to upload?
138
+ var files = $('input:file', this).fieldValue();
139
+ var found = false;
140
+ for (var j=0; j < files.length; j++)
141
+ if (files[j])
142
+ found = true;
143
+
144
+ // options.iframe allows user to force iframe mode
145
+ if (options.iframe || found) {
146
+ // hack to fix Safari hang (thanks to Tim Molendijk for this)
147
+ // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
148
+ if (options.closeKeepAlive)
149
+ $.get(options.closeKeepAlive, fileUpload);
150
+ else
151
+ fileUpload();
152
+ }
153
+ else
154
+ $.ajax(options);
155
+
156
+ // fire 'notify' event
157
+ this.trigger('form-submit-notify', [this, options]);
158
+ return this;
159
+
160
+
161
+ // private function for handling file uploads (hat tip to YAHOO!)
162
+ function fileUpload() {
163
+ var form = $form[0];
164
+
165
+ if ($(':input[name=submit]', form).length) {
166
+ alert('Error: Form elements must not be named "submit".');
167
+ return;
168
+ }
169
+
170
+ var opts = $.extend({}, $.ajaxSettings, options);
171
+ var s = jQuery.extend(true, {}, $.extend(true, {}, $.ajaxSettings), opts);
172
+
173
+ var id = 'jqFormIO' + (new Date().getTime());
174
+ var $io = $('<iframe id="' + id + '" name="' + id + '" src="about:blank" />');
175
+ var io = $io[0];
176
+
177
+ $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
178
+
179
+ var xhr = { // mock object
180
+ aborted: 0,
181
+ responseText: null,
182
+ responseXML: null,
183
+ status: 0,
184
+ statusText: 'n/a',
185
+ getAllResponseHeaders: function() {},
186
+ getResponseHeader: function() {},
187
+ setRequestHeader: function() {},
188
+ abort: function() {
189
+ this.aborted = 1;
190
+ $io.attr('src','about:blank'); // abort op in progress
191
+ }
192
+ };
193
+
194
+ var g = opts.global;
195
+ // trigger ajax global events so that activity/block indicators work like normal
196
+ if (g && ! $.active++) $.event.trigger("ajaxStart");
197
+ if (g) $.event.trigger("ajaxSend", [xhr, opts]);
198
+
199
+ if (s.beforeSend && s.beforeSend(xhr, s) === false) {
200
+ s.global && jQuery.active--;
201
+ return;
202
+ }
203
+ if (xhr.aborted)
204
+ return;
205
+
206
+ var cbInvoked = 0;
207
+ var timedOut = 0;
208
+
209
+ // add submitting element to data if we know it
210
+ var sub = form.clk;
211
+ if (sub) {
212
+ var n = sub.name;
213
+ if (n && !sub.disabled) {
214
+ options.extraData = options.extraData || {};
215
+ options.extraData[n] = sub.value;
216
+ if (sub.type == "image") {
217
+ options.extraData[name+'.x'] = form.clk_x;
218
+ options.extraData[name+'.y'] = form.clk_y;
219
+ }
220
+ }
221
+ }
222
+
223
+ // take a breath so that pending repaints get some cpu time before the upload starts
224
+ setTimeout(function() {
225
+ // make sure form attrs are set
226
+ var t = $form.attr('target'), a = $form.attr('action');
227
+
228
+ // update form attrs in IE friendly way
229
+ form.setAttribute('target',id);
230
+ if (form.getAttribute('method') != 'POST')
231
+ form.setAttribute('method', 'POST');
232
+ if (form.getAttribute('action') != opts.url)
233
+ form.setAttribute('action', opts.url);
234
+
235
+ // ie borks in some cases when setting encoding
236
+ if (! options.skipEncodingOverride) {
237
+ $form.attr({
238
+ encoding: 'multipart/form-data',
239
+ enctype: 'multipart/form-data'
240
+ });
241
+ }
242
+
243
+ // support timout
244
+ if (opts.timeout)
245
+ setTimeout(function() { timedOut = true; cb(); }, opts.timeout);
246
+
247
+ // add "extra" data to form if provided in options
248
+ var extraInputs = [];
249
+ try {
250
+ if (options.extraData)
251
+ for (var n in options.extraData)
252
+ extraInputs.push(
253
+ $('<input type="hidden" name="'+n+'" value="'+options.extraData[n]+'" />')
254
+ .appendTo(form)[0]);
255
+
256
+ // add iframe to doc and submit the form
257
+ $io.appendTo('body');
258
+ io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false);
259
+ form.submit();
260
+ }
261
+ finally {
262
+ // reset attrs and remove "extra" input elements
263
+ form.setAttribute('action',a);
264
+ t ? form.setAttribute('target', t) : $form.removeAttr('target');
265
+ $(extraInputs).remove();
266
+ }
267
+ }, 10);
268
+
269
+ var nullCheckFlag = 0;
270
+
271
+ function cb() {
272
+ if (cbInvoked++) return;
273
+
274
+ io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false);
275
+
276
+ var ok = true;
277
+ try {
278
+ if (timedOut) throw 'timeout';
279
+ // extract the server response from the iframe
280
+ var data, doc;
281
+
282
+ doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;
283
+
284
+ if ((doc.body == null || doc.body.innerHTML == '') && !nullCheckFlag) {
285
+ // in some browsers (cough, Opera 9.2.x) the iframe DOM is not always traversable when
286
+ // the onload callback fires, so we give them a 2nd chance
287
+ nullCheckFlag = 1;
288
+ cbInvoked--;
289
+ setTimeout(cb, 100);
290
+ return;
291
+ }
292
+
293
+ xhr.responseText = doc.body ? doc.body.innerHTML : null;
294
+ xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
295
+ xhr.getResponseHeader = function(header){
296
+ var headers = {'content-type': opts.dataType};
297
+ return headers[header];
298
+ };
299
+
300
+ if (opts.dataType == 'json' || opts.dataType == 'script') {
301
+ var ta = doc.getElementsByTagName('textarea')[0];
302
+ xhr.responseText = ta ? ta.value : xhr.responseText;
303
+ }
304
+ else if (opts.dataType == 'xml' && !xhr.responseXML && xhr.responseText != null) {
305
+ xhr.responseXML = toXml(xhr.responseText);
306
+ }
307
+ data = $.httpData(xhr, opts.dataType);
308
+ }
309
+ catch(e){
310
+ ok = false;
311
+ $.handleError(opts, xhr, 'error', e);
312
+ }
313
+
314
+ // ordering of these callbacks/triggers is odd, but that's how $.ajax does it
315
+ if (ok) {
316
+ opts.success(data, 'success');
317
+ if (g) $.event.trigger("ajaxSuccess", [xhr, opts]);
318
+ }
319
+ if (g) $.event.trigger("ajaxComplete", [xhr, opts]);
320
+ if (g && ! --$.active) $.event.trigger("ajaxStop");
321
+ if (opts.complete) opts.complete(xhr, ok ? 'success' : 'error');
322
+
323
+ // clean up
324
+ setTimeout(function() {
325
+ $io.remove();
326
+ xhr.responseXML = null;
327
+ }, 100);
328
+ };
329
+
330
+ function toXml(s, doc) {
331
+ if (window.ActiveXObject) {
332
+ doc = new ActiveXObject('Microsoft.XMLDOM');
333
+ doc.async = 'false';
334
+ doc.loadXML(s);
335
+ }
336
+ else
337
+ doc = (new DOMParser()).parseFromString(s, 'text/xml');
338
+ return (doc && doc.documentElement && doc.documentElement.tagName != 'parsererror') ? doc : null;
339
+ };
340
+ };
341
+ };
342
+
343
+ /**
344
+ * ajaxForm() provides a mechanism for fully automating form submission.
345
+ *
346
+ * The advantages of using this method instead of ajaxSubmit() are:
347
+ *
348
+ * 1: This method will include coordinates for <input type="image" /> elements (if the element
349
+ * is used to submit the form).
350
+ * 2. This method will include the submit element's name/value data (for the element that was
351
+ * used to submit the form).
352
+ * 3. This method binds the submit() method to the form for you.
353
+ *
354
+ * The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely
355
+ * passes the options argument along after properly binding events for submit elements and
356
+ * the form itself.
357
+ */
358
+ $.fn.ajaxForm = function(options) {
359
+ return this.ajaxFormUnbind().bind('submit.form-plugin',function() {
360
+ $(this).ajaxSubmit(options);
361
+ return false;
362
+ }).each(function() {
363
+ // store options in hash
364
+ $(":submit,input:image", this).bind('click.form-plugin',function(e) {
365
+ var form = this.form;
366
+ form.clk = this;
367
+ if (this.type == 'image') {
368
+ if (e.offsetX != undefined) {
369
+ form.clk_x = e.offsetX;
370
+ form.clk_y = e.offsetY;
371
+ } else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin
372
+ var offset = $(this).offset();
373
+ form.clk_x = e.pageX - offset.left;
374
+ form.clk_y = e.pageY - offset.top;
375
+ } else {
376
+ form.clk_x = e.pageX - this.offsetLeft;
377
+ form.clk_y = e.pageY - this.offsetTop;
378
+ }
379
+ }
380
+ // clear form vars
381
+ setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 10);
382
+ });
383
+ });
384
+ };
385
+
386
+ // ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
387
+ $.fn.ajaxFormUnbind = function() {
388
+ this.unbind('submit.form-plugin');
389
+ return this.each(function() {
390
+ $(":submit,input:image", this).unbind('click.form-plugin');
391
+ });
392
+
393
+ };
394
+
395
+ /**
396
+ * formToArray() gathers form element data into an array of objects that can
397
+ * be passed to any of the following ajax functions: $.get, $.post, or load.
398
+ * Each object in the array has both a 'name' and 'value' property. An example of
399
+ * an array for a simple login form might be:
400
+ *
401
+ * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
402
+ *
403
+ * It is this array that is passed to pre-submit callback functions provided to the
404
+ * ajaxSubmit() and ajaxForm() methods.
405
+ */
406
+ $.fn.formToArray = function(semantic) {
407
+ var a = [];
408
+ if (this.length == 0) return a;
409
+
410
+ var form = this[0];
411
+ var els = semantic ? form.getElementsByTagName('*') : form.elements;
412
+ if (!els) return a;
413
+ for(var i=0, max=els.length; i < max; i++) {
414
+ var el = els[i];
415
+ var n = el.name;
416
+ if (!n) continue;
417
+
418
+ if (semantic && form.clk && el.type == "image") {
419
+ // handle image inputs on the fly when semantic == true
420
+ if(!el.disabled && form.clk == el)
421
+ a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
422
+ continue;
423
+ }
424
+
425
+ var v = $.fieldValue(el, true);
426
+ if (v && v.constructor == Array) {
427
+ for(var j=0, jmax=v.length; j < jmax; j++)
428
+ a.push({name: n, value: v[j]});
429
+ }
430
+ else if (v !== null && typeof v != 'undefined')
431
+ a.push({name: n, value: v});
432
+ }
433
+
434
+ if (!semantic && form.clk) {
435
+ // input type=='image' are not found in elements array! handle them here
436
+ var inputs = form.getElementsByTagName("input");
437
+ for(var i=0, max=inputs.length; i < max; i++) {
438
+ var input = inputs[i];
439
+ var n = input.name;
440
+ if(n && !input.disabled && input.type == "image" && form.clk == input)
441
+ a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
442
+ }
443
+ }
444
+ return a;
445
+ };
446
+
447
+ /**
448
+ * Serializes form data into a 'submittable' string. This method will return a string
449
+ * in the format: name1=value1&amp;name2=value2
450
+ */
451
+ $.fn.formSerialize = function(semantic) {
452
+ //hand off to jQuery.param for proper encoding
453
+ return $.param(this.formToArray(semantic));
454
+ };
455
+
456
+ /**
457
+ * Serializes all field elements in the jQuery object into a query string.
458
+ * This method will return a string in the format: name1=value1&amp;name2=value2
459
+ */
460
+ $.fn.fieldSerialize = function(successful) {
461
+ var a = [];
462
+ this.each(function() {
463
+ var n = this.name;
464
+ if (!n) return;
465
+ var v = $.fieldValue(this, successful);
466
+ if (v && v.constructor == Array) {
467
+ for (var i=0,max=v.length; i < max; i++)
468
+ a.push({name: n, value: v[i]});
469
+ }
470
+ else if (v !== null && typeof v != 'undefined')
471
+ a.push({name: this.name, value: v});
472
+ });
473
+ //hand off to jQuery.param for proper encoding
474
+ return $.param(a);
475
+ };
476
+
477
+ /**
478
+ * Returns the value(s) of the element in the matched set. For example, consider the following form:
479
+ *
480
+ * <form><fieldset>
481
+ * <input name="A" type="text" />
482
+ * <input name="A" type="text" />
483
+ * <input name="B" type="checkbox" value="B1" />
484
+ * <input name="B" type="checkbox" value="B2"/>
485
+ * <input name="C" type="radio" value="C1" />
486
+ * <input name="C" type="radio" value="C2" />
487
+ * </fieldset></form>
488
+ *
489
+ * var v = $(':text').fieldValue();
490
+ * // if no values are entered into the text inputs
491
+ * v == ['','']
492
+ * // if values entered into the text inputs are 'foo' and 'bar'
493
+ * v == ['foo','bar']
494
+ *
495
+ * var v = $(':checkbox').fieldValue();
496
+ * // if neither checkbox is checked
497
+ * v === undefined
498
+ * // if both checkboxes are checked
499
+ * v == ['B1', 'B2']
500
+ *
501
+ * var v = $(':radio').fieldValue();
502
+ * // if neither radio is checked
503
+ * v === undefined
504
+ * // if first radio is checked
505
+ * v == ['C1']
506
+ *
507
+ * The successful argument controls whether or not the field element must be 'successful'
508
+ * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
509
+ * The default value of the successful argument is true. If this value is false the value(s)
510
+ * for each element is returned.
511
+ *
512
+ * Note: This method *always* returns an array. If no valid value can be determined the
513
+ * array will be empty, otherwise it will contain one or more values.
514
+ */
515
+ $.fn.fieldValue = function(successful) {
516
+ for (var val=[], i=0, max=this.length; i < max; i++) {
517
+ var el = this[i];
518
+ var v = $.fieldValue(el, successful);
519
+ if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length))
520
+ continue;
521
+ v.constructor == Array ? $.merge(val, v) : val.push(v);
522
+ }
523
+ return val;
524
+ };
525
+
526
+ /**
527
+ * Returns the value of the field element.
528
+ */
529
+ $.fieldValue = function(el, successful) {
530
+ var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
531
+ if (typeof successful == 'undefined') successful = true;
532
+
533
+ if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
534
+ (t == 'checkbox' || t == 'radio') && !el.checked ||
535
+ (t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
536
+ tag == 'select' && el.selectedIndex == -1))
537
+ return null;
538
+
539
+ if (tag == 'select') {
540
+ var index = el.selectedIndex;
541
+ if (index < 0) return null;
542
+ var a = [], ops = el.options;
543
+ var one = (t == 'select-one');
544
+ var max = (one ? index+1 : ops.length);
545
+ for(var i=(one ? index : 0); i < max; i++) {
546
+ var op = ops[i];
547
+ if (op.selected) {
548
+ var v = op.value;
549
+ if (!v) // extra pain for IE...
550
+ v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value;
551
+ if (one) return v;
552
+ a.push(v);
553
+ }
554
+ }
555
+ return a;
556
+ }
557
+ return el.value;
558
+ };
559
+
560
+ /**
561
+ * Clears the form data. Takes the following actions on the form's input fields:
562
+ * - input text fields will have their 'value' property set to the empty string
563
+ * - select elements will have their 'selectedIndex' property set to -1
564
+ * - checkbox and radio inputs will have their 'checked' property set to false
565
+ * - inputs of type submit, button, reset, and hidden will *not* be effected
566
+ * - button elements will *not* be effected
567
+ */
568
+ $.fn.clearForm = function() {
569
+ return this.each(function() {
570
+ $('input,select,textarea', this).clearFields();
571
+ });
572
+ };
573
+
574
+ /**
575
+ * Clears the selected form elements.
576
+ */
577
+ $.fn.clearFields = $.fn.clearInputs = function() {
578
+ return this.each(function() {
579
+ var t = this.type, tag = this.tagName.toLowerCase();
580
+ if (t == 'text' || t == 'password' || tag == 'textarea')
581
+ this.value = '';
582
+ else if (t == 'checkbox' || t == 'radio')
583
+ this.checked = false;
584
+ else if (tag == 'select')
585
+ this.selectedIndex = -1;
586
+ });
587
+ };
588
+
589
+ /**
590
+ * Resets the form data. Causes all form elements to be reset to their original value.
591
+ */
592
+ $.fn.resetForm = function() {
593
+ return this.each(function() {
594
+ // guard against an input with the name of 'reset'
595
+ // note that IE reports the reset function as an 'object'
596
+ if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType))
597
+ this.reset();
598
+ });
599
+ };
600
+
601
+ /**
602
+ * Enables or disables any matching elements.
603
+ */
604
+ $.fn.enable = function(b) {
605
+ if (b == undefined) b = true;
606
+ return this.each(function() {
607
+ this.disabled = !b;
608
+ });
609
+ };
610
+
611
+ /**
612
+ * Checks/unchecks any matching checkboxes or radio buttons and
613
+ * selects/deselects and matching option elements.
614
+ */
615
+ $.fn.selected = function(select) {
616
+ if (select == undefined) select = true;
617
+ return this.each(function() {
618
+ var t = this.type;
619
+ if (t == 'checkbox' || t == 'radio')
620
+ this.checked = select;
621
+ else if (this.tagName.toLowerCase() == 'option') {
622
+ var $sel = $(this).parent('select');
623
+ if (select && $sel[0] && $sel[0].type == 'select-one') {
624
+ // deselect all other options
625
+ $sel.find('option').selected(false);
626
+ }
627
+ this.selected = select;
628
+ }
629
+ });
630
+ };
631
+
632
+ // helper fn for console logging
633
+ // set $.fn.ajaxSubmit.debug to true to enable debug logging
634
+ function log() {
635
+ if ($.fn.ajaxSubmit.debug && window.console && window.console.log)
636
+ window.console.log('[jquery.form] ' + Array.prototype.join.call(arguments,''));
637
+ };
638
+
639
+ })(jQuery);
@@ -0,0 +1,41 @@
1
+ //= require "../jquery"
2
+ //= require "jeditable"
3
+
4
+ /*
5
+ * Autogrow textarea for Jeditable
6
+ *
7
+ * Copyright (c) 2008 Mika Tuupola
8
+ *
9
+ * Licensed under the MIT license:
10
+ * http://www.opensource.org/licenses/mit-license.php
11
+ *
12
+ * Depends on Autogrow jQuery plugin by Chrys Bader:
13
+ * http://www.aclevercookie.com/facebook-like-auto-growing-textarea/
14
+ *
15
+ * Project home:
16
+ * http://www.appelsiini.net/projects/jeditable
17
+ *
18
+ * Revision: $Id$
19
+ *
20
+ */
21
+
22
+ $.editable.addInputType('autogrow', {
23
+ element : function(settings, original) {
24
+ var textarea = $('<textarea />');
25
+ if (settings.rows) {
26
+ textarea.attr('rows', settings.rows);
27
+ } else {
28
+ textarea.height(settings.height);
29
+ }
30
+ if (settings.cols) {
31
+ textarea.attr('cols', settings.cols);
32
+ } else {
33
+ textarea.width(settings.width);
34
+ }
35
+ $(this).append(textarea);
36
+ return(textarea);
37
+ },
38
+ plugin : function(settings, original) {
39
+ $('textarea', this).autogrow(settings.autogrow);
40
+ }
41
+ });