@atlassian/aui 9.12.2 → 9.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/aui/aui-prototyping-design-tokens-api-full.js +1 -1
  2. package/dist/aui/aui-prototyping-design-tokens-api.js +1 -1
  3. package/dist/aui/aui-prototyping-design-tokens-base-themes-css.css +1 -1
  4. package/dist/aui/aui-prototyping-design-tokens-base-themes-css.js +1 -1
  5. package/dist/aui/aui-prototyping-design-tokens-base-themes.js +1 -1
  6. package/dist/aui/aui-prototyping.css +1 -1
  7. package/dist/aui/aui-prototyping.js +2 -2
  8. package/dist/aui/aui-prototyping.js.map +1 -1
  9. package/dist/aui/aui-prototyping.nodeps.css +1 -1
  10. package/dist/aui/aui-prototyping.nodeps.js +2 -2
  11. package/dist/aui/aui-prototyping.nodeps.js.map +1 -1
  12. package/package.json +3 -8
  13. package/src/js/aui/internal/alignment.js +1 -1
  14. package/src/js-vendor-effective/jquery-aop/LICENSE +21 -0
  15. package/src/js-vendor-effective/jquery-aop/README.md +54 -0
  16. package/src/js-vendor-effective/jquery-aop/aop.js +395 -0
  17. package/src/js-vendor-effective/jquery-aop/jquery-aop.txt +5 -0
  18. package/src/js-vendor-effective/jquery-aop/package.json +16 -0
  19. package/src/js-vendor-effective/jquery-form/jquery.form.js +819 -0
  20. package/src/js-vendor-effective/jquery-form/package.json +15 -0
  21. package/src/js-vendor-effective/jquery.hotkeys/jquery.hotkeys.js +176 -0
  22. package/src/js-vendor-effective/jquery.hotkeys/package.json +14 -0
  23. package/src/js-vendor-effective/select2/CONTRIBUTING.md +107 -0
  24. package/src/js-vendor-effective/select2/LICENSE +18 -0
  25. package/src/js-vendor-effective/select2/README.md +115 -0
  26. package/src/js-vendor-effective/select2/bower.json +8 -0
  27. package/src/js-vendor-effective/select2/component.json +66 -0
  28. package/src/js-vendor-effective/select2/composer.json +29 -0
  29. package/src/js-vendor-effective/select2/package.json +20 -0
  30. package/src/js-vendor-effective/select2/release.sh +79 -0
  31. package/src/js-vendor-effective/select2/select2-bootstrap.css +87 -0
  32. package/src/js-vendor-effective/select2/select2-spinner.gif +0 -0
  33. package/src/js-vendor-effective/select2/select2.css +692 -0
  34. package/src/js-vendor-effective/select2/select2.jquery.json +36 -0
  35. package/src/js-vendor-effective/select2/select2.js +3729 -0
  36. package/src/js-vendor-effective/select2/select2.min.js +23 -0
  37. package/src/js-vendor-effective/select2/select2.png +0 -0
  38. package/src/js-vendor-effective/select2/select2_locale_ar.js +19 -0
  39. package/src/js-vendor-effective/select2/select2_locale_az.js +20 -0
  40. package/src/js-vendor-effective/select2/select2_locale_bg.js +20 -0
  41. package/src/js-vendor-effective/select2/select2_locale_ca.js +19 -0
  42. package/src/js-vendor-effective/select2/select2_locale_cs.js +51 -0
  43. package/src/js-vendor-effective/select2/select2_locale_da.js +19 -0
  44. package/src/js-vendor-effective/select2/select2_locale_de.js +18 -0
  45. package/src/js-vendor-effective/select2/select2_locale_el.js +19 -0
  46. package/src/js-vendor-effective/select2/select2_locale_en.js.template +20 -0
  47. package/src/js-vendor-effective/select2/select2_locale_es.js +19 -0
  48. package/src/js-vendor-effective/select2/select2_locale_et.js +19 -0
  49. package/src/js-vendor-effective/select2/select2_locale_eu.js +45 -0
  50. package/src/js-vendor-effective/select2/select2_locale_fa.js +21 -0
  51. package/src/js-vendor-effective/select2/select2_locale_fi.js +30 -0
  52. package/src/js-vendor-effective/select2/select2_locale_fr.js +18 -0
  53. package/src/js-vendor-effective/select2/select2_locale_gl.js +45 -0
  54. package/src/js-vendor-effective/select2/select2_locale_he.js +19 -0
  55. package/src/js-vendor-effective/select2/select2_locale_hr.js +24 -0
  56. package/src/js-vendor-effective/select2/select2_locale_hu.js +17 -0
  57. package/src/js-vendor-effective/select2/select2_locale_id.js +21 -0
  58. package/src/js-vendor-effective/select2/select2_locale_is.js +17 -0
  59. package/src/js-vendor-effective/select2/select2_locale_it.js +17 -0
  60. package/src/js-vendor-effective/select2/select2_locale_ja.js +17 -0
  61. package/src/js-vendor-effective/select2/select2_locale_ka.js +19 -0
  62. package/src/js-vendor-effective/select2/select2_locale_ko.js +19 -0
  63. package/src/js-vendor-effective/select2/select2_locale_lt.js +26 -0
  64. package/src/js-vendor-effective/select2/select2_locale_lv.js +19 -0
  65. package/src/js-vendor-effective/select2/select2_locale_mk.js +19 -0
  66. package/src/js-vendor-effective/select2/select2_locale_ms.js +21 -0
  67. package/src/js-vendor-effective/select2/select2_locale_nb.js +22 -0
  68. package/src/js-vendor-effective/select2/select2_locale_nl.js +17 -0
  69. package/src/js-vendor-effective/select2/select2_locale_pl.js +54 -0
  70. package/src/js-vendor-effective/select2/select2_locale_pt-BR.js +18 -0
  71. package/src/js-vendor-effective/select2/select2_locale_pt-PT.js +17 -0
  72. package/src/js-vendor-effective/select2/select2_locale_ro.js +17 -0
  73. package/src/js-vendor-effective/select2/select2_locale_rs.js +19 -0
  74. package/src/js-vendor-effective/select2/select2_locale_ru.js +23 -0
  75. package/src/js-vendor-effective/select2/select2_locale_sk.js +50 -0
  76. package/src/js-vendor-effective/select2/select2_locale_sv.js +19 -0
  77. package/src/js-vendor-effective/select2/select2_locale_th.js +19 -0
  78. package/src/js-vendor-effective/select2/select2_locale_tr.js +20 -0
  79. package/src/js-vendor-effective/select2/select2_locale_ug-CN.js +16 -0
  80. package/src/js-vendor-effective/select2/select2_locale_uk.js +25 -0
  81. package/src/js-vendor-effective/select2/select2_locale_vi.js +20 -0
  82. package/src/js-vendor-effective/select2/select2_locale_zh-CN.js +16 -0
  83. package/src/js-vendor-effective/select2/select2_locale_zh-TW.js +16 -0
  84. package/src/js-vendor-effective/select2/select2x2.png +0 -0
  85. package/src/js-vendor-effective/tablesorter/README.md +158 -0
  86. package/src/js-vendor-effective/tablesorter/jquery.tablesorter.js +1925 -0
  87. package/src/js-vendor-effective/tablesorter/package.json +43 -0
@@ -0,0 +1,819 @@
1
+ /*!
2
+ * jQuery Form Plugin
3
+ * version: 2.67 (12-MAR-2011)
4
+ * @requires jQuery v1.3.2 or later
5
+ *
6
+ * Examples and documentation at: http://malsup.com/jquery/form/
7
+ * Dual licensed under the MIT and GPL licenses:
8
+ * http://www.opensource.org/licenses/mit-license.php
9
+ * http://www.gnu.org/licenses/gpl.html
10
+ */
11
+ ;(function($) {
12
+
13
+ /*
14
+ Usage Note:
15
+ -----------
16
+ Do not use both ajaxSubmit and ajaxForm on the same form. These
17
+ functions are intended to be exclusive. Use ajaxSubmit if you want
18
+ to bind your own submit handler to the form. For example,
19
+
20
+ $(document).ready(function() {
21
+ $('#myForm').bind('submit', function(e) {
22
+ e.preventDefault(); // <-- important
23
+ $(this).ajaxSubmit({
24
+ target: '#output'
25
+ });
26
+ });
27
+ });
28
+
29
+ Use ajaxForm when you want the plugin to manage all the event binding
30
+ for you. For example,
31
+
32
+ $(document).ready(function() {
33
+ $('#myForm').ajaxForm({
34
+ target: '#output'
35
+ });
36
+ });
37
+
38
+ When using ajaxForm, the ajaxSubmit function will be invoked for you
39
+ at the appropriate time.
40
+ */
41
+
42
+ /**
43
+ * ajaxSubmit() provides a mechanism for immediately submitting
44
+ * an HTML form using AJAX.
45
+ */
46
+ $.fn.ajaxSubmit = function(options) {
47
+ // fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
48
+ if (!this.length) {
49
+ log('ajaxSubmit: skipping submit process - no element selected');
50
+ return this;
51
+ }
52
+
53
+ if (typeof options == 'function') {
54
+ options = { success: options };
55
+ }
56
+
57
+ var action = this.attr('action');
58
+ var url = (typeof action === 'string') ? $.trim(action) : '';
59
+ if (url) {
60
+ // clean url (don't include hash vaue)
61
+ url = (url.match(/^([^#]+)/)||[])[1];
62
+ }
63
+ url = url || window.location.href || '';
64
+
65
+ options = $.extend(true, {
66
+ url: url,
67
+ type: this[0].getAttribute('method') || 'GET', // IE7 massage (see issue 57)
68
+ iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank'
69
+ }, options);
70
+
71
+ // hook for manipulating the form data before it is extracted;
72
+ // convenient for use with rich editors like tinyMCE or FCKEditor
73
+ var veto = {};
74
+ this.trigger('form-pre-serialize', [this, options, veto]);
75
+ if (veto.veto) {
76
+ log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');
77
+ return this;
78
+ }
79
+
80
+ // provide opportunity to alter form data before it is serialized
81
+ if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {
82
+ log('ajaxSubmit: submit aborted via beforeSerialize callback');
83
+ return this;
84
+ }
85
+
86
+ var n,v,a = this.formToArray(options.semantic);
87
+ if (options.data) {
88
+ options.extraData = options.data;
89
+ for (n in options.data) {
90
+ if(options.data[n] instanceof Array) {
91
+ for (var k in options.data[n]) {
92
+ a.push( { name: n, value: options.data[n][k] } );
93
+ }
94
+ }
95
+ else {
96
+ v = options.data[n];
97
+ v = $.isFunction(v) ? v() : v; // if value is fn, invoke it
98
+ a.push( { name: n, value: v } );
99
+ }
100
+ }
101
+ }
102
+
103
+ // give pre-submit callback an opportunity to abort the submit
104
+ if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {
105
+ log('ajaxSubmit: submit aborted via beforeSubmit callback');
106
+ return this;
107
+ }
108
+
109
+ // fire vetoable 'validate' event
110
+ this.trigger('form-submit-validate', [a, this, options, veto]);
111
+ if (veto.veto) {
112
+ log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
113
+ return this;
114
+ }
115
+
116
+ var q = $.param(a);
117
+
118
+ if (options.type.toUpperCase() == 'GET') {
119
+ options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
120
+ options.data = null; // data is null for 'get'
121
+ }
122
+ else {
123
+ options.data = q; // data is the query string for 'post'
124
+ }
125
+
126
+ var $form = this, callbacks = [];
127
+ if (options.resetForm) {
128
+ callbacks.push(function() { $form.resetForm(); });
129
+ }
130
+ if (options.clearForm) {
131
+ callbacks.push(function() { $form.clearForm(); });
132
+ }
133
+
134
+ // perform a load on the target only if dataType is not provided
135
+ if (!options.dataType && options.target) {
136
+ var oldSuccess = options.success || function(){};
137
+ callbacks.push(function(data) {
138
+ var fn = options.replaceTarget ? 'replaceWith' : 'html';
139
+ // Validate `data` through `HTML encoding` when passed `data` is passed
140
+ // to `html()`, as suggested in https://github.com/jquery-form/form/issues/464
141
+ fn == 'html' ? data = $.parseHTML($("<div>").text(data).html()) : '';
142
+ $(options.target)[fn](data).each(oldSuccess, arguments);
143
+ });
144
+ }
145
+ else if (options.success) {
146
+ callbacks.push(options.success);
147
+ }
148
+
149
+ options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg
150
+ var context = options.context || options; // jQuery 1.4+ supports scope context
151
+ for (var i=0, max=callbacks.length; i < max; i++) {
152
+ callbacks[i].apply(context, [data, status, xhr || $form, $form]);
153
+ }
154
+ };
155
+
156
+ // are there files to upload?
157
+ var fileInputs = $('input:file', this).length > 0;
158
+ var mp = 'multipart/form-data';
159
+ var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp);
160
+
161
+ // options.iframe allows user to force iframe mode
162
+ // 06-NOV-09: now defaulting to iframe mode if file input is detected
163
+ if (options.iframe !== false && (fileInputs || options.iframe || multipart)) {
164
+ // hack to fix Safari hang (thanks to Tim Molendijk for this)
165
+ // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
166
+ if (options.closeKeepAlive) {
167
+ $.get(options.closeKeepAlive, fileUpload);
168
+ }
169
+ else {
170
+ fileUpload();
171
+ }
172
+ }
173
+ else {
174
+ $.ajax(options);
175
+ }
176
+
177
+ // fire 'notify' event
178
+ this.trigger('form-submit-notify', [this, options]);
179
+ return this;
180
+
181
+
182
+ // private function for handling file uploads (hat tip to YAHOO!)
183
+ function fileUpload() {
184
+ var form = $form[0];
185
+
186
+ if ($(':input[name=submit],:input[id=submit]', form).length) {
187
+ // if there is an input with a name or id of 'submit' then we won't be
188
+ // able to invoke the submit fn on the form (at least not x-browser)
189
+ alert('Error: Form elements must not have name or id of "submit".');
190
+ return;
191
+ }
192
+
193
+ var s = $.extend(true, {}, $.ajaxSettings, options);
194
+ s.context = s.context || s;
195
+ var id = 'jqFormIO' + (new Date().getTime()), fn = '_'+id;
196
+ var $io = $('<iframe id="' + id + '" name="' + id + '" src="'+ s.iframeSrc +'" />');
197
+ var io = $io[0];
198
+
199
+ $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
200
+
201
+ var xhr = { // mock object
202
+ aborted: 0,
203
+ responseText: null,
204
+ responseXML: null,
205
+ status: 0,
206
+ statusText: 'n/a',
207
+ getAllResponseHeaders: function() {},
208
+ getResponseHeader: function() {},
209
+ setRequestHeader: function() {},
210
+ abort: function() {
211
+ log('aborting upload...');
212
+ var e = 'aborted';
213
+ this.aborted = 1;
214
+ $io.attr('src', s.iframeSrc); // abort op in progress
215
+ xhr.error = e;
216
+ s.error && s.error.call(s.context, xhr, 'error', e);
217
+ g && $.event.trigger("ajaxError", [xhr, s, e]);
218
+ s.complete && s.complete.call(s.context, xhr, 'error');
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() { timedOut = true; cb(); }, s.timeout);
282
+ }
283
+
284
+ // add "extra" data to form if provided in options
285
+ var extraInputs = [];
286
+ try {
287
+ if (s.extraData) {
288
+ for (var n in s.extraData) {
289
+ extraInputs.push(
290
+ $('<input type="hidden" name="'+n+'" value="'+s.extraData[n]+'" />')
291
+ .appendTo(form)[0]);
292
+ }
293
+ }
294
+
295
+ // add iframe to doc and submit the form
296
+ $io.appendTo('body');
297
+ io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false);
298
+ form.submit();
299
+ }
300
+ finally {
301
+ // reset attrs and remove "extra" input elements
302
+ form.setAttribute('action',a);
303
+ if(t) {
304
+ form.setAttribute('target', t);
305
+ } else {
306
+ $form.removeAttr('target');
307
+ }
308
+ $(extraInputs).remove();
309
+ }
310
+ }
311
+
312
+ if (s.forceSync) {
313
+ doSubmit();
314
+ }
315
+ else {
316
+ setTimeout(doSubmit, 10); // this lets dom updates render
317
+ }
318
+
319
+ var data, doc, domCheckCount = 50;
320
+
321
+ function cb() {
322
+ if (xhr.aborted) {
323
+ return;
324
+ }
325
+
326
+ var doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;
327
+ if (!doc || doc.location.href == s.iframeSrc) {
328
+ // response not received yet
329
+ return;
330
+ }
331
+ io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false);
332
+
333
+ var ok = true;
334
+ try {
335
+ if (timedOut) {
336
+ throw 'timeout';
337
+ }
338
+
339
+ var isXml = s.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc);
340
+ log('isXml='+isXml);
341
+ if (!isXml && window.opera && (doc.body == null || doc.body.innerHTML == '')) {
342
+ if (--domCheckCount) {
343
+ // in some browsers (Opera) the iframe DOM is not always traversable when
344
+ // the onload callback fires, so we loop a bit to accommodate
345
+ log('requeing onLoad callback, DOM not available');
346
+ setTimeout(cb, 250);
347
+ return;
348
+ }
349
+ // let this fall through because server response could be an empty document
350
+ //log('Could not access iframe DOM after mutiple tries.');
351
+ //throw 'DOMException: not available';
352
+ }
353
+
354
+ //log('response detected');
355
+ xhr.responseText = doc.body ? doc.body.innerHTML : doc.documentElement ? doc.documentElement.innerHTML : null;
356
+ xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
357
+ xhr.getResponseHeader = function(header){
358
+ var headers = {'content-type': s.dataType};
359
+ return headers[header];
360
+ };
361
+
362
+ var scr = /(json|script)/.test(s.dataType);
363
+ if (scr || s.textarea) {
364
+ // see if user embedded response in textarea
365
+ var ta = doc.getElementsByTagName('textarea')[0];
366
+ if (ta) {
367
+ xhr.responseText = ta.value;
368
+ }
369
+ else if (scr) {
370
+ // account for browsers injecting pre around json response
371
+ var pre = doc.getElementsByTagName('pre')[0];
372
+ var b = doc.getElementsByTagName('body')[0];
373
+ if (pre) {
374
+ xhr.responseText = pre.textContent;
375
+ }
376
+ else if (b) {
377
+ xhr.responseText = b.innerHTML;
378
+ }
379
+ }
380
+ }
381
+ else if (s.dataType == 'xml' && !xhr.responseXML && xhr.responseText != null) {
382
+ xhr.responseXML = toXml(xhr.responseText);
383
+ }
384
+
385
+ data = httpData(xhr, s.dataType, s);
386
+ }
387
+ catch(e){
388
+ log('error caught:',e);
389
+ ok = false;
390
+ xhr.error = e;
391
+ s.error && s.error.call(s.context, xhr, 'error', e);
392
+ g && $.event.trigger("ajaxError", [xhr, s, e]);
393
+ }
394
+
395
+ if (xhr.aborted) {
396
+ log('upload aborted');
397
+ ok = false;
398
+ }
399
+
400
+ // ordering of these callbacks/triggers is odd, but that's how $.ajax does it
401
+ if (ok) {
402
+ s.success && s.success.call(s.context, data, 'success', xhr);
403
+ g && $.event.trigger("ajaxSuccess", [xhr, s]);
404
+ }
405
+
406
+ g && $.event.trigger("ajaxComplete", [xhr, s]);
407
+
408
+ if (g && ! --$.active) {
409
+ $.event.trigger("ajaxStop");
410
+ }
411
+
412
+ s.complete && s.complete.call(s.context, xhr, ok ? 'success' : 'error');
413
+
414
+ // clean up
415
+ setTimeout(function() {
416
+ $io.removeData('form-plugin-onload');
417
+ $io.remove();
418
+ xhr.responseXML = null;
419
+ }, 100);
420
+ }
421
+
422
+ var toXml = $.parseXML || function(s, doc) { // use parseXML if available (jQuery 1.5+)
423
+ if (window.ActiveXObject) {
424
+ doc = new ActiveXObject('Microsoft.XMLDOM');
425
+ doc.async = 'false';
426
+ doc.loadXML(s);
427
+ }
428
+ else {
429
+ doc = (new DOMParser()).parseFromString(s, 'text/xml');
430
+ }
431
+ return (doc && doc.documentElement && doc.documentElement.nodeName != 'parsererror') ? doc : null;
432
+ };
433
+ var parseJSON = $.parseJSON || function(s) {
434
+ // Arise an error resolvable including jquery instead of
435
+ // making a new function using unsanitized inputs
436
+ window.console.error('jquery.parseJSON is undefined');
437
+ return null;
438
+ };
439
+
440
+ var httpData = function( xhr, type, s ) { // mostly lifted from jq1.4.4
441
+ var ct = xhr.getResponseHeader('content-type') || '',
442
+ xml = type === 'xml' || !type && ct.indexOf('xml') >= 0,
443
+ data = xml ? xhr.responseXML : xhr.responseText;
444
+
445
+ if (xml && data.documentElement.nodeName === 'parsererror') {
446
+ $.error && $.error('parsererror');
447
+ }
448
+ if (s && s.dataFilter) {
449
+ data = s.dataFilter(data, type);
450
+ }
451
+ if (typeof data === 'string') {
452
+ if (type === 'json' || !type && ct.indexOf('json') >= 0) {
453
+ data = parseJSON(data);
454
+ } else if (type === "script" || !type && ct.indexOf("javascript") >= 0) {
455
+ $.globalEval(data);
456
+ }
457
+ }
458
+ return data;
459
+ };
460
+ }
461
+ };
462
+
463
+ /**
464
+ * ajaxForm() provides a mechanism for fully automating form submission.
465
+ *
466
+ * The advantages of using this method instead of ajaxSubmit() are:
467
+ *
468
+ * 1: This method will include coordinates for <input type="image" /> elements (if the element
469
+ * is used to submit the form).
470
+ * 2. This method will include the submit element's name/value data (for the element that was
471
+ * used to submit the form).
472
+ * 3. This method binds the submit() method to the form for you.
473
+ *
474
+ * The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely
475
+ * passes the options argument along after properly binding events for submit elements and
476
+ * the form itself.
477
+ */
478
+ $.fn.ajaxForm = function(options) {
479
+ // in jQuery 1.3+ we can fix mistakes with the ready state
480
+ if (this.length === 0) {
481
+ var o = { s: this.selector, c: this.context };
482
+ if (!$.isReady && o.s) {
483
+ log('DOM not ready, queuing ajaxForm');
484
+ $(function() {
485
+ $(o.s,o.c).ajaxForm(options);
486
+ });
487
+ return this;
488
+ }
489
+ // is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
490
+ log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
491
+ return this;
492
+ }
493
+
494
+ return this.ajaxFormUnbind().bind('submit.form-plugin', function(e) {
495
+ if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed
496
+ e.preventDefault();
497
+ $(this).ajaxSubmit(options);
498
+ }
499
+ }).bind('click.form-plugin', function(e) {
500
+ var target = e.target;
501
+ var $el = $(target);
502
+ if (!($el.is(":submit,input:image"))) {
503
+ // is this a child element of the submit el? (ex: a span within a button)
504
+ var t = $el.closest(':submit');
505
+ if (t.length == 0) {
506
+ return;
507
+ }
508
+ target = t[0];
509
+ }
510
+ var form = this;
511
+ form.clk = target;
512
+ if (target.type == 'image') {
513
+ if (e.offsetX != undefined) {
514
+ form.clk_x = e.offsetX;
515
+ form.clk_y = e.offsetY;
516
+ } else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin
517
+ var offset = $el.offset();
518
+ form.clk_x = e.pageX - offset.left;
519
+ form.clk_y = e.pageY - offset.top;
520
+ } else {
521
+ form.clk_x = e.pageX - target.offsetLeft;
522
+ form.clk_y = e.pageY - target.offsetTop;
523
+ }
524
+ }
525
+ // clear form vars
526
+ setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 100);
527
+ });
528
+ };
529
+
530
+ // ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
531
+ $.fn.ajaxFormUnbind = function() {
532
+ return this.unbind('submit.form-plugin click.form-plugin');
533
+ };
534
+
535
+ /**
536
+ * formToArray() gathers form element data into an array of objects that can
537
+ * be passed to any of the following ajax functions: $.get, $.post, or load.
538
+ * Each object in the array has both a 'name' and 'value' property. An example of
539
+ * an array for a simple login form might be:
540
+ *
541
+ * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
542
+ *
543
+ * It is this array that is passed to pre-submit callback functions provided to the
544
+ * ajaxSubmit() and ajaxForm() methods.
545
+ */
546
+ $.fn.formToArray = function(semantic) {
547
+ var a = [];
548
+ if (this.length === 0) {
549
+ return a;
550
+ }
551
+
552
+ var form = this[0];
553
+ var els = semantic ? form.getElementsByTagName('*') : form.elements;
554
+ if (!els) {
555
+ return a;
556
+ }
557
+
558
+ var i,j,n,v,el,max,jmax;
559
+ for(i=0, max=els.length; i < max; i++) {
560
+ el = els[i];
561
+ n = el.name;
562
+ if (!n) {
563
+ continue;
564
+ }
565
+
566
+ if (semantic && form.clk && el.type == "image") {
567
+ // handle image inputs on the fly when semantic == true
568
+ if(!el.disabled && form.clk == el) {
569
+ a.push({name: n, value: $(el).val()});
570
+ a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
571
+ }
572
+ continue;
573
+ }
574
+
575
+ v = $.fieldValue(el, true);
576
+ if (v && v.constructor == Array) {
577
+ for(j=0, jmax=v.length; j < jmax; j++) {
578
+ a.push({name: n, value: v[j]});
579
+ }
580
+ }
581
+ else if (v !== null && typeof v != 'undefined') {
582
+ a.push({name: n, value: v});
583
+ }
584
+ }
585
+
586
+ if (!semantic && form.clk) {
587
+ // input type=='image' are not found in elements array! handle it here
588
+ var $input = $(form.clk), input = $input[0];
589
+ n = input.name;
590
+ if (n && !input.disabled && input.type == 'image') {
591
+ a.push({name: n, value: $input.val()});
592
+ a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
593
+ }
594
+ }
595
+ return a;
596
+ };
597
+
598
+ /**
599
+ * Serializes form data into a 'submittable' string. This method will return a string
600
+ * in the format: name1=value1&amp;name2=value2
601
+ */
602
+ $.fn.formSerialize = function(semantic) {
603
+ //hand off to jQuery.param for proper encoding
604
+ return $.param(this.formToArray(semantic));
605
+ };
606
+
607
+ /**
608
+ * Serializes all field elements in the jQuery object into a query string.
609
+ * This method will return a string in the format: name1=value1&amp;name2=value2
610
+ */
611
+ $.fn.fieldSerialize = function(successful) {
612
+ var a = [];
613
+ this.each(function() {
614
+ var n = this.name;
615
+ if (!n) {
616
+ return;
617
+ }
618
+ var v = $.fieldValue(this, successful);
619
+ if (v && v.constructor == Array) {
620
+ for (var i=0,max=v.length; i < max; i++) {
621
+ a.push({name: n, value: v[i]});
622
+ }
623
+ }
624
+ else if (v !== null && typeof v != 'undefined') {
625
+ a.push({name: this.name, value: v});
626
+ }
627
+ });
628
+ //hand off to jQuery.param for proper encoding
629
+ return $.param(a);
630
+ };
631
+
632
+ /**
633
+ * Returns the value(s) of the element in the matched set. For example, consider the following form:
634
+ *
635
+ * <form><fieldset>
636
+ * <input name="A" type="text" />
637
+ * <input name="A" type="text" />
638
+ * <input name="B" type="checkbox" value="B1" />
639
+ * <input name="B" type="checkbox" value="B2"/>
640
+ * <input name="C" type="radio" value="C1" />
641
+ * <input name="C" type="radio" value="C2" />
642
+ * </fieldset></form>
643
+ *
644
+ * var v = $(':text').fieldValue();
645
+ * // if no values are entered into the text inputs
646
+ * v == ['','']
647
+ * // if values entered into the text inputs are 'foo' and 'bar'
648
+ * v == ['foo','bar']
649
+ *
650
+ * var v = $(':checkbox').fieldValue();
651
+ * // if neither checkbox is checked
652
+ * v === undefined
653
+ * // if both checkboxes are checked
654
+ * v == ['B1', 'B2']
655
+ *
656
+ * var v = $(':radio').fieldValue();
657
+ * // if neither radio is checked
658
+ * v === undefined
659
+ * // if first radio is checked
660
+ * v == ['C1']
661
+ *
662
+ * The successful argument controls whether or not the field element must be 'successful'
663
+ * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
664
+ * The default value of the successful argument is true. If this value is false the value(s)
665
+ * for each element is returned.
666
+ *
667
+ * Note: This method *always* returns an array. If no valid value can be determined the
668
+ * array will be empty, otherwise it will contain one or more values.
669
+ */
670
+ $.fn.fieldValue = function(successful) {
671
+ for (var val=[], i=0, max=this.length; i < max; i++) {
672
+ var el = this[i];
673
+ var v = $.fieldValue(el, successful);
674
+ if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) {
675
+ continue;
676
+ }
677
+ v.constructor == Array ? $.merge(val, v) : val.push(v);
678
+ }
679
+ return val;
680
+ };
681
+
682
+ /**
683
+ * Returns the value of the field element.
684
+ */
685
+ $.fieldValue = function(el, successful) {
686
+ var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
687
+ if (successful === undefined) {
688
+ successful = true;
689
+ }
690
+
691
+ if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
692
+ (t == 'checkbox' || t == 'radio') && !el.checked ||
693
+ (t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
694
+ tag == 'select' && el.selectedIndex == -1)) {
695
+ return null;
696
+ }
697
+
698
+ if (tag == 'select') {
699
+ var index = el.selectedIndex;
700
+ if (index < 0) {
701
+ return null;
702
+ }
703
+ var a = [], ops = el.options;
704
+ var one = (t == 'select-one');
705
+ var max = (one ? index+1 : ops.length);
706
+ for(var i=(one ? index : 0); i < max; i++) {
707
+ var op = ops[i];
708
+ if (op.selected) {
709
+ var v = op.value;
710
+ if (!v) { // extra pain for IE...
711
+ v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value;
712
+ }
713
+ if (one) {
714
+ return v;
715
+ }
716
+ a.push(v);
717
+ }
718
+ }
719
+ return a;
720
+ }
721
+ return $(el).val();
722
+ };
723
+
724
+ /**
725
+ * Clears the form data. Takes the following actions on the form's input fields:
726
+ * - input text fields will have their 'value' property set to the empty string
727
+ * - select elements will have their 'selectedIndex' property set to -1
728
+ * - checkbox and radio inputs will have their 'checked' property set to false
729
+ * - inputs of type submit, button, reset, and hidden will *not* be effected
730
+ * - button elements will *not* be effected
731
+ */
732
+ $.fn.clearForm = function() {
733
+ return this.each(function() {
734
+ $('input,select,textarea', this).clearFields();
735
+ });
736
+ };
737
+
738
+ /**
739
+ * Clears the selected form elements.
740
+ */
741
+ $.fn.clearFields = $.fn.clearInputs = function() {
742
+ return this.each(function() {
743
+ var t = this.type, tag = this.tagName.toLowerCase();
744
+ if (t == 'text' || t == 'password' || tag == 'textarea') {
745
+ this.value = '';
746
+ }
747
+ else if (t == 'checkbox' || t == 'radio') {
748
+ this.checked = false;
749
+ }
750
+ else if (tag == 'select') {
751
+ this.selectedIndex = -1;
752
+ }
753
+ });
754
+ };
755
+
756
+ /**
757
+ * Resets the form data. Causes all form elements to be reset to their original value.
758
+ */
759
+ $.fn.resetForm = function() {
760
+ return this.each(function() {
761
+ // guard against an input with the name of 'reset'
762
+ // note that IE reports the reset function as an 'object'
763
+ if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) {
764
+ this.reset();
765
+ }
766
+ });
767
+ };
768
+
769
+ /**
770
+ * Enables or disables any matching elements.
771
+ */
772
+ $.fn.enable = function(b) {
773
+ if (b === undefined) {
774
+ b = true;
775
+ }
776
+ return this.each(function() {
777
+ this.disabled = !b;
778
+ });
779
+ };
780
+
781
+ /**
782
+ * Checks/unchecks any matching checkboxes or radio buttons and
783
+ * selects/deselects and matching option elements.
784
+ */
785
+ $.fn.selected = function(select) {
786
+ if (select === undefined) {
787
+ select = true;
788
+ }
789
+ return this.each(function() {
790
+ var t = this.type;
791
+ if (t == 'checkbox' || t == 'radio') {
792
+ this.checked = select;
793
+ }
794
+ else if (this.tagName.toLowerCase() == 'option') {
795
+ var $sel = $(this).parent('select');
796
+ if (select && $sel[0] && $sel[0].type == 'select-one') {
797
+ // deselect all other options
798
+ $sel.find('option').selected(false);
799
+ }
800
+ this.selected = select;
801
+ }
802
+ });
803
+ };
804
+
805
+ // helper fn for console logging
806
+ // set $.fn.ajaxSubmit.debug to true to enable debug logging
807
+ function log() {
808
+ if ($.fn.ajaxSubmit.debug) {
809
+ var msg = '[jquery.form] ' + Array.prototype.join.call(arguments,'');
810
+ if (window.console && window.console.log) {
811
+ window.console.log(msg);
812
+ }
813
+ else if (window.opera && window.opera.postError) {
814
+ window.opera.postError(msg);
815
+ }
816
+ }
817
+ };
818
+
819
+ })(jQuery);