h2ocube_rails_assets 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/README.md +1 -1
  2. data/h2ocube_rails_assets.gemspec +2 -2
  3. data/lib/h2ocube_rails_assets.rb +1 -4
  4. data/vendor/assets/images/jquery.ui/animated-overlay.gif +0 -0
  5. data/vendor/assets/images/jquery.ui/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  6. data/vendor/assets/images/jquery.ui/ui-bg_flat_75_ffffff_40x100.png +0 -0
  7. data/vendor/assets/images/jquery.ui/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  8. data/vendor/assets/images/jquery.ui/ui-bg_glass_65_ffffff_1x400.png +0 -0
  9. data/vendor/assets/images/jquery.ui/ui-bg_glass_75_dadada_1x400.png +0 -0
  10. data/vendor/assets/images/jquery.ui/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  11. data/vendor/assets/images/jquery.ui/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  12. data/vendor/assets/images/jquery.ui/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  13. data/vendor/assets/images/jquery.ui/ui-icons_222222_256x240.png +0 -0
  14. data/vendor/assets/images/jquery.ui/ui-icons_2e83ff_256x240.png +0 -0
  15. data/vendor/assets/images/jquery.ui/ui-icons_454545_256x240.png +0 -0
  16. data/vendor/assets/images/jquery.ui/ui-icons_888888_256x240.png +0 -0
  17. data/vendor/assets/images/jquery.ui/ui-icons_cd0a0a_256x240.png +0 -0
  18. data/vendor/assets/javascripts/_bootstrap.js +189 -80
  19. data/vendor/assets/javascripts/_jquery.fancybox.js +1983 -0
  20. data/vendor/assets/javascripts/_jquery.fileupload.js +1164 -0
  21. data/vendor/assets/javascripts/_jquery.js +1 -1
  22. data/vendor/assets/javascripts/{jquery.ui/jquery-ui.custom.js → _jquery.ui.js} +3717 -3693
  23. data/vendor/assets/javascripts/_jquery.validate.js +1207 -0
  24. data/vendor/assets/javascripts/_sammy.js +2120 -0
  25. data/vendor/assets/javascripts/jquery/1.9.js +229 -187
  26. data/vendor/assets/javascripts/jquery.cookie.js +29 -11
  27. data/vendor/assets/javascripts/jquery.fancybox.js +2 -1985
  28. data/vendor/assets/javascripts/jquery.fileupload.js +4 -1114
  29. data/vendor/assets/javascripts/jquery.iframe-transport.js +20 -7
  30. data/vendor/assets/javascripts/jquery.ui/jquery.ui.accordion.js +131 -290
  31. data/vendor/assets/javascripts/jquery.ui/jquery.ui.autocomplete.js +43 -37
  32. data/vendor/assets/javascripts/jquery.ui/jquery.ui.button.js +9 -8
  33. data/vendor/assets/javascripts/jquery.ui/jquery.ui.core.js +19 -51
  34. data/vendor/assets/javascripts/jquery.ui/jquery.ui.datepicker.js +1082 -878
  35. data/vendor/assets/javascripts/jquery.ui/jquery.ui.dialog.js +483 -542
  36. data/vendor/assets/javascripts/jquery.ui/jquery.ui.draggable.js +319 -212
  37. data/vendor/assets/javascripts/jquery.ui/jquery.ui.droppable.js +177 -100
  38. data/vendor/assets/javascripts/jquery.ui/jquery.ui.effect-blind.js +2 -2
  39. data/vendor/assets/javascripts/jquery.ui/jquery.ui.effect-bounce.js +2 -2
  40. data/vendor/assets/javascripts/jquery.ui/jquery.ui.effect-clip.js +2 -2
  41. data/vendor/assets/javascripts/jquery.ui/jquery.ui.effect-drop.js +2 -2
  42. data/vendor/assets/javascripts/jquery.ui/jquery.ui.effect-explode.js +2 -2
  43. data/vendor/assets/javascripts/jquery.ui/jquery.ui.effect-fade.js +2 -2
  44. data/vendor/assets/javascripts/jquery.ui/jquery.ui.effect-fold.js +2 -2
  45. data/vendor/assets/javascripts/jquery.ui/jquery.ui.effect-highlight.js +2 -2
  46. data/vendor/assets/javascripts/jquery.ui/jquery.ui.effect-pulsate.js +2 -2
  47. data/vendor/assets/javascripts/jquery.ui/jquery.ui.effect-scale.js +2 -2
  48. data/vendor/assets/javascripts/jquery.ui/jquery.ui.effect-shake.js +2 -2
  49. data/vendor/assets/javascripts/jquery.ui/jquery.ui.effect-slide.js +2 -2
  50. data/vendor/assets/javascripts/jquery.ui/jquery.ui.effect-transfer.js +3 -3
  51. data/vendor/assets/javascripts/jquery.ui/jquery.ui.effect.js +93 -101
  52. data/vendor/assets/javascripts/jquery.ui/jquery.ui.menu.js +21 -10
  53. data/vendor/assets/javascripts/jquery.ui/jquery.ui.mouse.js +25 -25
  54. data/vendor/assets/javascripts/jquery.ui/jquery.ui.position.js +42 -62
  55. data/vendor/assets/javascripts/jquery.ui/jquery.ui.progressbar.js +73 -33
  56. data/vendor/assets/javascripts/jquery.ui/jquery.ui.resizable.js +461 -294
  57. data/vendor/assets/javascripts/jquery.ui/jquery.ui.selectable.js +67 -51
  58. data/vendor/assets/javascripts/jquery.ui/jquery.ui.slider.js +179 -151
  59. data/vendor/assets/javascripts/jquery.ui/jquery.ui.sortable.js +411 -257
  60. data/vendor/assets/javascripts/jquery.ui/jquery.ui.spinner.js +19 -5
  61. data/vendor/assets/javascripts/jquery.ui/jquery.ui.tabs.js +47 -567
  62. data/vendor/assets/javascripts/jquery.ui/jquery.ui.tooltip.js +14 -10
  63. data/vendor/assets/javascripts/jquery.ui/jquery.ui.widget.js +33 -40
  64. data/vendor/assets/javascripts/jquery.ui.js +1 -1
  65. data/vendor/assets/javascripts/jquery.validate.js +1 -1258
  66. data/vendor/assets/javascripts/sammy.js +1 -2107
  67. data/vendor/assets/javascripts/underscore.js +101 -75
  68. data/vendor/assets/stylesheets/bootstrap.responsive.css +24 -7
  69. data/vendor/assets/stylesheets/bootstrap.scss +238 -119
  70. data/vendor/assets/stylesheets/jquery.fancybox.scss +6 -6
  71. data/vendor/assets/stylesheets/jquery.ui.scss +918 -217
  72. data/vendor/assets/stylesheets/normalize.css +396 -0
  73. metadata +16 -20
@@ -1,1259 +1,2 @@
1
1
  //= require jquery
2
-
3
- /**
4
- * jQuery Validation Plugin 1.10.0
5
- *
6
- * http://bassistance.de/jquery-plugins/jquery-plugin-validation/
7
- * http://docs.jquery.com/Plugins/Validation
8
- *
9
- * Copyright (c) 2012 Jörn Zaefferer
10
- *
11
- * Dual licensed under the MIT and GPL licenses:
12
- * http://www.opensource.org/licenses/mit-license.php
13
- * http://www.gnu.org/licenses/gpl.html
14
- */
15
-
16
- (function($) {
17
-
18
- $.extend($.fn, {
19
- // http://docs.jquery.com/Plugins/Validation/validate
20
- validate: function( options ) {
21
-
22
- // if nothing is selected, return nothing; can't chain anyway
23
- if (!this.length) {
24
- if (options && options.debug && window.console) {
25
- console.warn( "nothing selected, can't validate, returning nothing" );
26
- }
27
- return;
28
- }
29
-
30
- // check if a validator for this form was already created
31
- var validator = $.data(this[0], 'validator');
32
- if ( validator ) {
33
- return validator;
34
- }
35
-
36
- // Add novalidate tag if HTML5.
37
- this.attr('novalidate', 'novalidate');
38
-
39
- validator = new $.validator( options, this[0] );
40
- $.data(this[0], 'validator', validator);
41
-
42
- if ( validator.settings.onsubmit ) {
43
-
44
- this.validateDelegate( ":submit", "click", function(ev) {
45
- if ( validator.settings.submitHandler ) {
46
- validator.submitButton = ev.target;
47
- }
48
- // allow suppressing validation by adding a cancel class to the submit button
49
- if ( $(ev.target).hasClass('cancel') ) {
50
- validator.cancelSubmit = true;
51
- }
52
- });
53
-
54
- // validate the form on submit
55
- this.submit( function( event ) {
56
- if ( validator.settings.debug ) {
57
- // prevent form submit to be able to see console output
58
- event.preventDefault();
59
- }
60
- function handle() {
61
- var hidden;
62
- if ( validator.settings.submitHandler ) {
63
- if (validator.submitButton) {
64
- // insert a hidden input as a replacement for the missing submit button
65
- hidden = $("<input type='hidden'/>").attr("name", validator.submitButton.name).val(validator.submitButton.value).appendTo(validator.currentForm);
66
- }
67
- validator.settings.submitHandler.call( validator, validator.currentForm, event );
68
- if (validator.submitButton) {
69
- // and clean up afterwards; thanks to no-block-scope, hidden can be referenced
70
- hidden.remove();
71
- }
72
- return false;
73
- }
74
- return true;
75
- }
76
-
77
- // prevent submit for invalid forms or custom submit handlers
78
- if ( validator.cancelSubmit ) {
79
- validator.cancelSubmit = false;
80
- return handle();
81
- }
82
- if ( validator.form() ) {
83
- if ( validator.pendingRequest ) {
84
- validator.formSubmitted = true;
85
- return false;
86
- }
87
- return handle();
88
- } else {
89
- validator.focusInvalid();
90
- return false;
91
- }
92
- });
93
- }
94
-
95
- return validator;
96
- },
97
- // http://docs.jquery.com/Plugins/Validation/valid
98
- valid: function() {
99
- if ( $(this[0]).is('form')) {
100
- return this.validate().form();
101
- } else {
102
- var valid = true;
103
- var validator = $(this[0].form).validate();
104
- this.each(function() {
105
- valid &= validator.element(this);
106
- });
107
- return valid;
108
- }
109
- },
110
- // attributes: space seperated list of attributes to retrieve and remove
111
- removeAttrs: function(attributes) {
112
- var result = {},
113
- $element = this;
114
- $.each(attributes.split(/\s/), function(index, value) {
115
- result[value] = $element.attr(value);
116
- $element.removeAttr(value);
117
- });
118
- return result;
119
- },
120
- // http://docs.jquery.com/Plugins/Validation/rules
121
- rules: function(command, argument) {
122
- var element = this[0];
123
-
124
- if (command) {
125
- var settings = $.data(element.form, 'validator').settings;
126
- var staticRules = settings.rules;
127
- var existingRules = $.validator.staticRules(element);
128
- switch(command) {
129
- case "add":
130
- $.extend(existingRules, $.validator.normalizeRule(argument));
131
- staticRules[element.name] = existingRules;
132
- if (argument.messages) {
133
- settings.messages[element.name] = $.extend( settings.messages[element.name], argument.messages );
134
- }
135
- break;
136
- case "remove":
137
- if (!argument) {
138
- delete staticRules[element.name];
139
- return existingRules;
140
- }
141
- var filtered = {};
142
- $.each(argument.split(/\s/), function(index, method) {
143
- filtered[method] = existingRules[method];
144
- delete existingRules[method];
145
- });
146
- return filtered;
147
- }
148
- }
149
-
150
- var data = $.validator.normalizeRules(
151
- $.extend(
152
- {},
153
- $.validator.metadataRules(element),
154
- $.validator.classRules(element),
155
- $.validator.attributeRules(element),
156
- $.validator.staticRules(element)
157
- ), element);
158
-
159
- // make sure required is at front
160
- if (data.required) {
161
- var param = data.required;
162
- delete data.required;
163
- data = $.extend({required: param}, data);
164
- }
165
-
166
- return data;
167
- }
168
- });
169
-
170
- // Custom selectors
171
- $.extend($.expr[":"], {
172
- // http://docs.jquery.com/Plugins/Validation/blank
173
- blank: function(a) {return !$.trim("" + a.value);},
174
- // http://docs.jquery.com/Plugins/Validation/filled
175
- filled: function(a) {return !!$.trim("" + a.value);},
176
- // http://docs.jquery.com/Plugins/Validation/unchecked
177
- unchecked: function(a) {return !a.checked;}
178
- });
179
-
180
- // constructor for validator
181
- $.validator = function( options, form ) {
182
- this.settings = $.extend( true, {}, $.validator.defaults, options );
183
- this.currentForm = form;
184
- this.init();
185
- };
186
-
187
- $.validator.format = function(source, params) {
188
- if ( arguments.length === 1 ) {
189
- return function() {
190
- var args = $.makeArray(arguments);
191
- args.unshift(source);
192
- return $.validator.format.apply( this, args );
193
- };
194
- }
195
- if ( arguments.length > 2 && params.constructor !== Array ) {
196
- params = $.makeArray(arguments).slice(1);
197
- }
198
- if ( params.constructor !== Array ) {
199
- params = [ params ];
200
- }
201
- $.each(params, function(i, n) {
202
- source = source.replace(new RegExp("\\{" + i + "\\}", "g"), n);
203
- });
204
- return source;
205
- };
206
-
207
- $.extend($.validator, {
208
-
209
- defaults: {
210
- messages: {},
211
- groups: {},
212
- rules: {},
213
- errorClass: "error",
214
- validClass: "valid",
215
- errorElement: "label",
216
- focusInvalid: true,
217
- errorContainer: $( [] ),
218
- errorLabelContainer: $( [] ),
219
- onsubmit: true,
220
- ignore: ":hidden",
221
- ignoreTitle: false,
222
- onfocusin: function(element, event) {
223
- this.lastActive = element;
224
-
225
- // hide error label and remove error class on focus if enabled
226
- if ( this.settings.focusCleanup && !this.blockFocusCleanup ) {
227
- if ( this.settings.unhighlight ) {
228
- this.settings.unhighlight.call( this, element, this.settings.errorClass, this.settings.validClass );
229
- }
230
- this.addWrapper(this.errorsFor(element)).hide();
231
- }
232
- },
233
- onfocusout: function(element, event) {
234
- if ( !this.checkable(element) && (element.name in this.submitted || !this.optional(element)) ) {
235
- this.element(element);
236
- }
237
- },
238
- onkeyup: function(element, event) {
239
- if ( event.which === 9 && this.elementValue(element) === '' ) {
240
- return;
241
- } else if ( element.name in this.submitted || element === this.lastActive ) {
242
- this.element(element);
243
- }
244
- },
245
- onclick: function(element, event) {
246
- // click on selects, radiobuttons and checkboxes
247
- if ( element.name in this.submitted ) {
248
- this.element(element);
249
- }
250
- // or option elements, check parent select in that case
251
- else if (element.parentNode.name in this.submitted) {
252
- this.element(element.parentNode);
253
- }
254
- },
255
- highlight: function(element, errorClass, validClass) {
256
- if (element.type === 'radio') {
257
- this.findByName(element.name).addClass(errorClass).removeClass(validClass);
258
- } else {
259
- $(element).addClass(errorClass).removeClass(validClass);
260
- }
261
- },
262
- unhighlight: function(element, errorClass, validClass) {
263
- if (element.type === 'radio') {
264
- this.findByName(element.name).removeClass(errorClass).addClass(validClass);
265
- } else {
266
- $(element).removeClass(errorClass).addClass(validClass);
267
- }
268
- }
269
- },
270
-
271
- // http://docs.jquery.com/Plugins/Validation/Validator/setDefaults
272
- setDefaults: function(settings) {
273
- $.extend( $.validator.defaults, settings );
274
- },
275
-
276
- messages: {
277
- required: "This field is required.",
278
- remote: "Please fix this field.",
279
- email: "Please enter a valid email address.",
280
- url: "Please enter a valid URL.",
281
- date: "Please enter a valid date.",
282
- dateISO: "Please enter a valid date (ISO).",
283
- number: "Please enter a valid number.",
284
- digits: "Please enter only digits.",
285
- creditcard: "Please enter a valid credit card number.",
286
- equalTo: "Please enter the same value again.",
287
- maxlength: $.validator.format("Please enter no more than {0} characters."),
288
- minlength: $.validator.format("Please enter at least {0} characters."),
289
- rangelength: $.validator.format("Please enter a value between {0} and {1} characters long."),
290
- range: $.validator.format("Please enter a value between {0} and {1}."),
291
- max: $.validator.format("Please enter a value less than or equal to {0}."),
292
- min: $.validator.format("Please enter a value greater than or equal to {0}.")
293
- },
294
-
295
- autoCreateRanges: false,
296
-
297
- prototype: {
298
-
299
- init: function() {
300
- this.labelContainer = $(this.settings.errorLabelContainer);
301
- this.errorContext = this.labelContainer.length && this.labelContainer || $(this.currentForm);
302
- this.containers = $(this.settings.errorContainer).add( this.settings.errorLabelContainer );
303
- this.submitted = {};
304
- this.valueCache = {};
305
- this.pendingRequest = 0;
306
- this.pending = {};
307
- this.invalid = {};
308
- this.reset();
309
-
310
- var groups = (this.groups = {});
311
- $.each(this.settings.groups, function(key, value) {
312
- $.each(value.split(/\s/), function(index, name) {
313
- groups[name] = key;
314
- });
315
- });
316
- var rules = this.settings.rules;
317
- $.each(rules, function(key, value) {
318
- rules[key] = $.validator.normalizeRule(value);
319
- });
320
-
321
- function delegate(event) {
322
- var validator = $.data(this[0].form, "validator"),
323
- eventType = "on" + event.type.replace(/^validate/, "");
324
- if (validator.settings[eventType]) {
325
- validator.settings[eventType].call(validator, this[0], event);
326
- }
327
- }
328
- $(this.currentForm)
329
- .validateDelegate(":text, [type='password'], [type='file'], select, textarea, " +
330
- "[type='number'], [type='search'] ,[type='tel'], [type='url'], " +
331
- "[type='email'], [type='datetime'], [type='date'], [type='month'], " +
332
- "[type='week'], [type='time'], [type='datetime-local'], " +
333
- "[type='range'], [type='color'] ",
334
- "focusin focusout keyup", delegate)
335
- .validateDelegate("[type='radio'], [type='checkbox'], select, option", "click", delegate);
336
-
337
- if (this.settings.invalidHandler) {
338
- $(this.currentForm).bind("invalid-form.validate", this.settings.invalidHandler);
339
- }
340
- },
341
-
342
- // http://docs.jquery.com/Plugins/Validation/Validator/form
343
- form: function() {
344
- this.checkForm();
345
- $.extend(this.submitted, this.errorMap);
346
- this.invalid = $.extend({}, this.errorMap);
347
- if (!this.valid()) {
348
- $(this.currentForm).triggerHandler("invalid-form", [this]);
349
- }
350
- this.showErrors();
351
- return this.valid();
352
- },
353
-
354
- checkForm: function() {
355
- this.prepareForm();
356
- for ( var i = 0, elements = (this.currentElements = this.elements()); elements[i]; i++ ) {
357
- this.check( elements[i] );
358
- }
359
- return this.valid();
360
- },
361
-
362
- // http://docs.jquery.com/Plugins/Validation/Validator/element
363
- element: function( element ) {
364
- element = this.validationTargetFor( this.clean( element ) );
365
- this.lastElement = element;
366
- this.prepareElement( element );
367
- this.currentElements = $(element);
368
- var result = this.check( element ) !== false;
369
- if (result) {
370
- delete this.invalid[element.name];
371
- } else {
372
- this.invalid[element.name] = true;
373
- }
374
- if ( !this.numberOfInvalids() ) {
375
- // Hide error containers on last error
376
- this.toHide = this.toHide.add( this.containers );
377
- }
378
- this.showErrors();
379
- return result;
380
- },
381
-
382
- // http://docs.jquery.com/Plugins/Validation/Validator/showErrors
383
- showErrors: function(errors) {
384
- if(errors) {
385
- // add items to error list and map
386
- $.extend( this.errorMap, errors );
387
- this.errorList = [];
388
- for ( var name in errors ) {
389
- this.errorList.push({
390
- message: errors[name],
391
- element: this.findByName(name)[0]
392
- });
393
- }
394
- // remove items from success list
395
- this.successList = $.grep( this.successList, function(element) {
396
- return !(element.name in errors);
397
- });
398
- }
399
- if (this.settings.showErrors) {
400
- this.settings.showErrors.call( this, this.errorMap, this.errorList );
401
- } else {
402
- this.defaultShowErrors();
403
- }
404
- },
405
-
406
- // http://docs.jquery.com/Plugins/Validation/Validator/resetForm
407
- resetForm: function() {
408
- if ( $.fn.resetForm ) {
409
- $( this.currentForm ).resetForm();
410
- }
411
- this.submitted = {};
412
- this.lastElement = null;
413
- this.prepareForm();
414
- this.hideErrors();
415
- this.elements().removeClass( this.settings.errorClass ).removeData( "previousValue" );
416
- },
417
-
418
- numberOfInvalids: function() {
419
- return this.objectLength(this.invalid);
420
- },
421
-
422
- objectLength: function( obj ) {
423
- var count = 0;
424
- for ( var i in obj ) {
425
- count++;
426
- }
427
- return count;
428
- },
429
-
430
- hideErrors: function() {
431
- this.addWrapper( this.toHide ).hide();
432
- },
433
-
434
- valid: function() {
435
- return this.size() === 0;
436
- },
437
-
438
- size: function() {
439
- return this.errorList.length;
440
- },
441
-
442
- focusInvalid: function() {
443
- if( this.settings.focusInvalid ) {
444
- try {
445
- $(this.findLastActive() || this.errorList.length && this.errorList[0].element || [])
446
- .filter(":visible")
447
- .focus()
448
- // manually trigger focusin event; without it, focusin handler isn't called, findLastActive won't have anything to find
449
- .trigger("focusin");
450
- } catch(e) {
451
- // ignore IE throwing errors when focusing hidden elements
452
- }
453
- }
454
- },
455
-
456
- findLastActive: function() {
457
- var lastActive = this.lastActive;
458
- return lastActive && $.grep(this.errorList, function(n) {
459
- return n.element.name === lastActive.name;
460
- }).length === 1 && lastActive;
461
- },
462
-
463
- elements: function() {
464
- var validator = this,
465
- rulesCache = {};
466
-
467
- // select all valid inputs inside the form (no submit or reset buttons)
468
- return $(this.currentForm)
469
- .find("input, select, textarea")
470
- .not(":submit, :reset, :image, [disabled]")
471
- .not( this.settings.ignore )
472
- .filter(function() {
473
- if ( !this.name && validator.settings.debug && window.console ) {
474
- console.error( "%o has no name assigned", this);
475
- }
476
-
477
- // select only the first element for each name, and only those with rules specified
478
- if ( this.name in rulesCache || !validator.objectLength($(this).rules()) ) {
479
- return false;
480
- }
481
-
482
- rulesCache[this.name] = true;
483
- return true;
484
- });
485
- },
486
-
487
- clean: function( selector ) {
488
- return $( selector )[0];
489
- },
490
-
491
- errors: function() {
492
- var errorClass = this.settings.errorClass.replace(' ', '.');
493
- return $( this.settings.errorElement + "." + errorClass, this.errorContext );
494
- },
495
-
496
- reset: function() {
497
- this.successList = [];
498
- this.errorList = [];
499
- this.errorMap = {};
500
- this.toShow = $([]);
501
- this.toHide = $([]);
502
- this.currentElements = $([]);
503
- },
504
-
505
- prepareForm: function() {
506
- this.reset();
507
- this.toHide = this.errors().add( this.containers );
508
- },
509
-
510
- prepareElement: function( element ) {
511
- this.reset();
512
- this.toHide = this.errorsFor(element);
513
- },
514
-
515
- elementValue: function( element ) {
516
- var type = $(element).attr('type'),
517
- val = $(element).val();
518
-
519
- if ( type === 'radio' || type === 'checkbox' ) {
520
- return $('input[name="' + $(element).attr('name') + '"]:checked').val();
521
- }
522
-
523
- if ( typeof val === 'string' ) {
524
- return val.replace(/\r/g, "");
525
- }
526
- return val;
527
- },
528
-
529
- check: function( element ) {
530
- element = this.validationTargetFor( this.clean( element ) );
531
-
532
- var rules = $(element).rules();
533
- var dependencyMismatch = false;
534
- var val = this.elementValue(element);
535
- var result;
536
-
537
- for (var method in rules ) {
538
- var rule = { method: method, parameters: rules[method] };
539
- try {
540
-
541
- result = $.validator.methods[method].call( this, val, element, rule.parameters );
542
-
543
- // if a method indicates that the field is optional and therefore valid,
544
- // don't mark it as valid when there are no other rules
545
- if ( result === "dependency-mismatch" ) {
546
- dependencyMismatch = true;
547
- continue;
548
- }
549
- dependencyMismatch = false;
550
-
551
- if ( result === "pending" ) {
552
- this.toHide = this.toHide.not( this.errorsFor(element) );
553
- return;
554
- }
555
-
556
- if( !result ) {
557
- this.formatAndAdd( element, rule );
558
- return false;
559
- }
560
- } catch(e) {
561
- if ( this.settings.debug && window.console ) {
562
- console.log("exception occured when checking element " + element.id + ", check the '" + rule.method + "' method", e);
563
- }
564
- throw e;
565
- }
566
- }
567
- if (dependencyMismatch) {
568
- return;
569
- }
570
- if ( this.objectLength(rules) ) {
571
- this.successList.push(element);
572
- }
573
- return true;
574
- },
575
-
576
- // return the custom message for the given element and validation method
577
- // specified in the element's "messages" metadata
578
- customMetaMessage: function(element, method) {
579
- if (!$.metadata) {
580
- return;
581
- }
582
- var meta = this.settings.meta ? $(element).metadata()[this.settings.meta] : $(element).metadata();
583
- return meta && meta.messages && meta.messages[method];
584
- },
585
-
586
- // return the custom message for the given element and validation method
587
- // specified in the element's HTML5 data attribute
588
- customDataMessage: function(element, method) {
589
- return $(element).data('msg-' + method.toLowerCase()) || (element.attributes && $(element).attr('data-msg-' + method.toLowerCase()));
590
- },
591
-
592
- // return the custom message for the given element name and validation method
593
- customMessage: function( name, method ) {
594
- var m = this.settings.messages[name];
595
- return m && (m.constructor === String ? m : m[method]);
596
- },
597
-
598
- // return the first defined argument, allowing empty strings
599
- findDefined: function() {
600
- for(var i = 0; i < arguments.length; i++) {
601
- if (arguments[i] !== undefined) {
602
- return arguments[i];
603
- }
604
- }
605
- return undefined;
606
- },
607
-
608
- defaultMessage: function( element, method) {
609
- return this.findDefined(
610
- this.customMessage( element.name, method ),
611
- this.customDataMessage( element, method ),
612
- this.customMetaMessage( element, method ),
613
- // title is never undefined, so handle empty string as undefined
614
- !this.settings.ignoreTitle && element.title || undefined,
615
- $.validator.messages[method],
616
- "<strong>Warning: No message defined for " + element.name + "</strong>"
617
- );
618
- },
619
-
620
- formatAndAdd: function( element, rule ) {
621
- var message = this.defaultMessage( element, rule.method ),
622
- theregex = /\$?\{(\d+)\}/g;
623
- if ( typeof message === "function" ) {
624
- message = message.call(this, rule.parameters, element);
625
- } else if (theregex.test(message)) {
626
- message = $.validator.format(message.replace(theregex, '{$1}'), rule.parameters);
627
- }
628
- this.errorList.push({
629
- message: message,
630
- element: element
631
- });
632
-
633
- this.errorMap[element.name] = message;
634
- this.submitted[element.name] = message;
635
- },
636
-
637
- addWrapper: function(toToggle) {
638
- if ( this.settings.wrapper ) {
639
- toToggle = toToggle.add( toToggle.parent( this.settings.wrapper ) );
640
- }
641
- return toToggle;
642
- },
643
-
644
- defaultShowErrors: function() {
645
- var i, elements;
646
- for ( i = 0; this.errorList[i]; i++ ) {
647
- var error = this.errorList[i];
648
- if ( this.settings.highlight ) {
649
- this.settings.highlight.call( this, error.element, this.settings.errorClass, this.settings.validClass );
650
- }
651
- this.showLabel( error.element, error.message );
652
- }
653
- if( this.errorList.length ) {
654
- this.toShow = this.toShow.add( this.containers );
655
- }
656
- if (this.settings.success) {
657
- for ( i = 0; this.successList[i]; i++ ) {
658
- this.showLabel( this.successList[i] );
659
- }
660
- }
661
- if (this.settings.unhighlight) {
662
- for ( i = 0, elements = this.validElements(); elements[i]; i++ ) {
663
- this.settings.unhighlight.call( this, elements[i], this.settings.errorClass, this.settings.validClass );
664
- }
665
- }
666
- this.toHide = this.toHide.not( this.toShow );
667
- this.hideErrors();
668
- this.addWrapper( this.toShow ).show();
669
- },
670
-
671
- validElements: function() {
672
- return this.currentElements.not(this.invalidElements());
673
- },
674
-
675
- invalidElements: function() {
676
- return $(this.errorList).map(function() {
677
- return this.element;
678
- });
679
- },
680
-
681
- showLabel: function(element, message) {
682
- var label = this.errorsFor( element );
683
- if ( label.length ) {
684
- // refresh error/success class
685
- label.removeClass( this.settings.validClass ).addClass( this.settings.errorClass );
686
-
687
- // check if we have a generated label, replace the message then
688
- if ( label.attr("generated") ) {
689
- label.html(message);
690
- }
691
- } else {
692
- // create label
693
- label = $("<" + this.settings.errorElement + "/>")
694
- .attr({"for": this.idOrName(element), generated: true})
695
- .addClass(this.settings.errorClass)
696
- .html(message || "");
697
- if ( this.settings.wrapper ) {
698
- // make sure the element is visible, even in IE
699
- // actually showing the wrapped element is handled elsewhere
700
- label = label.hide().show().wrap("<" + this.settings.wrapper + "/>").parent();
701
- }
702
- if ( !this.labelContainer.append(label).length ) {
703
- if ( this.settings.errorPlacement ) {
704
- this.settings.errorPlacement(label, $(element) );
705
- } else {
706
- label.insertAfter(element);
707
- }
708
- }
709
- }
710
- if ( !message && this.settings.success ) {
711
- label.text("");
712
- if ( typeof this.settings.success === "string" ) {
713
- label.addClass( this.settings.success );
714
- } else {
715
- this.settings.success( label, element );
716
- }
717
- }
718
- this.toShow = this.toShow.add(label);
719
- },
720
-
721
- errorsFor: function(element) {
722
- var name = this.idOrName(element);
723
- return this.errors().filter(function() {
724
- return $(this).attr('for') === name;
725
- });
726
- },
727
-
728
- idOrName: function(element) {
729
- return this.groups[element.name] || (this.checkable(element) ? element.name : element.id || element.name);
730
- },
731
-
732
- validationTargetFor: function(element) {
733
- // if radio/checkbox, validate first element in group instead
734
- if (this.checkable(element)) {
735
- element = this.findByName( element.name ).not(this.settings.ignore)[0];
736
- }
737
- return element;
738
- },
739
-
740
- checkable: function( element ) {
741
- return (/radio|checkbox/i).test(element.type);
742
- },
743
-
744
- findByName: function( name ) {
745
- return $(this.currentForm).find('[name="' + name + '"]');
746
- },
747
-
748
- getLength: function(value, element) {
749
- switch( element.nodeName.toLowerCase() ) {
750
- case 'select':
751
- return $("option:selected", element).length;
752
- case 'input':
753
- if( this.checkable( element) ) {
754
- return this.findByName(element.name).filter(':checked').length;
755
- }
756
- }
757
- return value.length;
758
- },
759
-
760
- depend: function(param, element) {
761
- return this.dependTypes[typeof param] ? this.dependTypes[typeof param](param, element) : true;
762
- },
763
-
764
- dependTypes: {
765
- "boolean": function(param, element) {
766
- return param;
767
- },
768
- "string": function(param, element) {
769
- return !!$(param, element.form).length;
770
- },
771
- "function": function(param, element) {
772
- return param(element);
773
- }
774
- },
775
-
776
- optional: function(element) {
777
- var val = this.elementValue(element);
778
- return !$.validator.methods.required.call(this, val, element) && "dependency-mismatch";
779
- },
780
-
781
- startRequest: function(element) {
782
- if (!this.pending[element.name]) {
783
- this.pendingRequest++;
784
- this.pending[element.name] = true;
785
- }
786
- },
787
-
788
- stopRequest: function(element, valid) {
789
- this.pendingRequest--;
790
- // sometimes synchronization fails, make sure pendingRequest is never < 0
791
- if (this.pendingRequest < 0) {
792
- this.pendingRequest = 0;
793
- }
794
- delete this.pending[element.name];
795
- if ( valid && this.pendingRequest === 0 && this.formSubmitted && this.form() ) {
796
- $(this.currentForm).submit();
797
- this.formSubmitted = false;
798
- } else if (!valid && this.pendingRequest === 0 && this.formSubmitted) {
799
- $(this.currentForm).triggerHandler("invalid-form", [this]);
800
- this.formSubmitted = false;
801
- }
802
- },
803
-
804
- previousValue: function(element) {
805
- return $.data(element, "previousValue") || $.data(element, "previousValue", {
806
- old: null,
807
- valid: true,
808
- message: this.defaultMessage( element, "remote" )
809
- });
810
- }
811
-
812
- },
813
-
814
- classRuleSettings: {
815
- required: {required: true},
816
- email: {email: true},
817
- url: {url: true},
818
- date: {date: true},
819
- dateISO: {dateISO: true},
820
- number: {number: true},
821
- digits: {digits: true},
822
- creditcard: {creditcard: true}
823
- },
824
-
825
- addClassRules: function(className, rules) {
826
- if ( className.constructor === String ) {
827
- this.classRuleSettings[className] = rules;
828
- } else {
829
- $.extend(this.classRuleSettings, className);
830
- }
831
- },
832
-
833
- classRules: function(element) {
834
- var rules = {};
835
- var classes = $(element).attr('class');
836
- if ( classes ) {
837
- $.each(classes.split(' '), function() {
838
- if (this in $.validator.classRuleSettings) {
839
- $.extend(rules, $.validator.classRuleSettings[this]);
840
- }
841
- });
842
- }
843
- return rules;
844
- },
845
-
846
- attributeRules: function(element) {
847
- var rules = {};
848
- var $element = $(element);
849
-
850
- for (var method in $.validator.methods) {
851
- var value;
852
-
853
- // support for <input required> in both html5 and older browsers
854
- if (method === 'required') {
855
- value = $element.get(0).getAttribute(method);
856
- // Some browsers return an empty string for the required attribute
857
- // and non-HTML5 browsers might have required="" markup
858
- if (value === "") {
859
- value = true;
860
- }
861
- // force non-HTML5 browsers to return bool
862
- value = !!value;
863
- } else {
864
- value = $element.attr(method);
865
- }
866
-
867
- if (value) {
868
- rules[method] = value;
869
- } else if ($element[0].getAttribute("type") === method) {
870
- rules[method] = true;
871
- }
872
- }
873
-
874
- // maxlength may be returned as -1, 2147483647 (IE) and 524288 (safari) for text inputs
875
- if (rules.maxlength && /-1|2147483647|524288/.test(rules.maxlength)) {
876
- delete rules.maxlength;
877
- }
878
-
879
- return rules;
880
- },
881
-
882
- metadataRules: function(element) {
883
- if (!$.metadata) {
884
- return {};
885
- }
886
-
887
- var meta = $.data(element.form, 'validator').settings.meta;
888
- return meta ?
889
- $(element).metadata()[meta] :
890
- $(element).metadata();
891
- },
892
-
893
- staticRules: function(element) {
894
- var rules = {};
895
- var validator = $.data(element.form, 'validator');
896
- if (validator.settings.rules) {
897
- rules = $.validator.normalizeRule(validator.settings.rules[element.name]) || {};
898
- }
899
- return rules;
900
- },
901
-
902
- normalizeRules: function(rules, element) {
903
- // handle dependency check
904
- $.each(rules, function(prop, val) {
905
- // ignore rule when param is explicitly false, eg. required:false
906
- if (val === false) {
907
- delete rules[prop];
908
- return;
909
- }
910
- if (val.param || val.depends) {
911
- var keepRule = true;
912
- switch (typeof val.depends) {
913
- case "string":
914
- keepRule = !!$(val.depends, element.form).length;
915
- break;
916
- case "function":
917
- keepRule = val.depends.call(element, element);
918
- break;
919
- }
920
- if (keepRule) {
921
- rules[prop] = val.param !== undefined ? val.param : true;
922
- } else {
923
- delete rules[prop];
924
- }
925
- }
926
- });
927
-
928
- // evaluate parameters
929
- $.each(rules, function(rule, parameter) {
930
- rules[rule] = $.isFunction(parameter) ? parameter(element) : parameter;
931
- });
932
-
933
- // clean number parameters
934
- $.each(['minlength', 'maxlength', 'min', 'max'], function() {
935
- if (rules[this]) {
936
- rules[this] = Number(rules[this]);
937
- }
938
- });
939
- $.each(['rangelength', 'range'], function() {
940
- if (rules[this]) {
941
- rules[this] = [Number(rules[this][0]), Number(rules[this][1])];
942
- }
943
- });
944
-
945
- if ($.validator.autoCreateRanges) {
946
- // auto-create ranges
947
- if (rules.min && rules.max) {
948
- rules.range = [rules.min, rules.max];
949
- delete rules.min;
950
- delete rules.max;
951
- }
952
- if (rules.minlength && rules.maxlength) {
953
- rules.rangelength = [rules.minlength, rules.maxlength];
954
- delete rules.minlength;
955
- delete rules.maxlength;
956
- }
957
- }
958
-
959
- // To support custom messages in metadata ignore rule methods titled "messages"
960
- if (rules.messages) {
961
- delete rules.messages;
962
- }
963
-
964
- return rules;
965
- },
966
-
967
- // Converts a simple string to a {string: true} rule, e.g., "required" to {required:true}
968
- normalizeRule: function(data) {
969
- if( typeof data === "string" ) {
970
- var transformed = {};
971
- $.each(data.split(/\s/), function() {
972
- transformed[this] = true;
973
- });
974
- data = transformed;
975
- }
976
- return data;
977
- },
978
-
979
- // http://docs.jquery.com/Plugins/Validation/Validator/addMethod
980
- addMethod: function(name, method, message) {
981
- $.validator.methods[name] = method;
982
- $.validator.messages[name] = message !== undefined ? message : $.validator.messages[name];
983
- if (method.length < 3) {
984
- $.validator.addClassRules(name, $.validator.normalizeRule(name));
985
- }
986
- },
987
-
988
- methods: {
989
-
990
- // http://docs.jquery.com/Plugins/Validation/Methods/required
991
- required: function(value, element, param) {
992
- // check if dependency is met
993
- if ( !this.depend(param, element) ) {
994
- return "dependency-mismatch";
995
- }
996
- if ( element.nodeName.toLowerCase() === "select" ) {
997
- // could be an array for select-multiple or a string, both are fine this way
998
- var val = $(element).val();
999
- return val && val.length > 0;
1000
- }
1001
- if ( this.checkable(element) ) {
1002
- return this.getLength(value, element) > 0;
1003
- }
1004
- return $.trim(value).length > 0;
1005
- },
1006
-
1007
- // http://docs.jquery.com/Plugins/Validation/Methods/remote
1008
- remote: function(value, element, param) {
1009
- if ( this.optional(element) ) {
1010
- return "dependency-mismatch";
1011
- }
1012
-
1013
- var previous = this.previousValue(element);
1014
- if (!this.settings.messages[element.name] ) {
1015
- this.settings.messages[element.name] = {};
1016
- }
1017
- previous.originalMessage = this.settings.messages[element.name].remote;
1018
- this.settings.messages[element.name].remote = previous.message;
1019
-
1020
- param = typeof param === "string" && {url:param} || param;
1021
-
1022
- if ( this.pending[element.name] ) {
1023
- return "pending";
1024
- }
1025
- if ( previous.old === value ) {
1026
- return previous.valid;
1027
- }
1028
-
1029
- previous.old = value;
1030
- var validator = this;
1031
- this.startRequest(element);
1032
- var data = {};
1033
- data[element.name] = value;
1034
- $.ajax($.extend(true, {
1035
- url: param,
1036
- mode: "abort",
1037
- port: "validate" + element.name,
1038
- dataType: "json",
1039
- data: data,
1040
- success: function(response) {
1041
- validator.settings.messages[element.name].remote = previous.originalMessage;
1042
- var valid = response === true || response === "true";
1043
- if ( valid ) {
1044
- var submitted = validator.formSubmitted;
1045
- validator.prepareElement(element);
1046
- validator.formSubmitted = submitted;
1047
- validator.successList.push(element);
1048
- delete validator.invalid[element.name];
1049
- validator.showErrors();
1050
- } else {
1051
- var errors = {};
1052
- var message = response || validator.defaultMessage( element, "remote" );
1053
- errors[element.name] = previous.message = $.isFunction(message) ? message(value) : message;
1054
- validator.invalid[element.name] = true;
1055
- validator.showErrors(errors);
1056
- }
1057
- previous.valid = valid;
1058
- validator.stopRequest(element, valid);
1059
- }
1060
- }, param));
1061
- return "pending";
1062
- },
1063
-
1064
- // http://docs.jquery.com/Plugins/Validation/Methods/minlength
1065
- minlength: function(value, element, param) {
1066
- var length = $.isArray( value ) ? value.length : this.getLength($.trim(value), element);
1067
- return this.optional(element) || length >= param;
1068
- },
1069
-
1070
- // http://docs.jquery.com/Plugins/Validation/Methods/maxlength
1071
- maxlength: function(value, element, param) {
1072
- var length = $.isArray( value ) ? value.length : this.getLength($.trim(value), element);
1073
- return this.optional(element) || length <= param;
1074
- },
1075
-
1076
- // http://docs.jquery.com/Plugins/Validation/Methods/rangelength
1077
- rangelength: function(value, element, param) {
1078
- var length = $.isArray( value ) ? value.length : this.getLength($.trim(value), element);
1079
- return this.optional(element) || ( length >= param[0] && length <= param[1] );
1080
- },
1081
-
1082
- // http://docs.jquery.com/Plugins/Validation/Methods/min
1083
- min: function( value, element, param ) {
1084
- return this.optional(element) || value >= param;
1085
- },
1086
-
1087
- // http://docs.jquery.com/Plugins/Validation/Methods/max
1088
- max: function( value, element, param ) {
1089
- return this.optional(element) || value <= param;
1090
- },
1091
-
1092
- // http://docs.jquery.com/Plugins/Validation/Methods/range
1093
- range: function( value, element, param ) {
1094
- return this.optional(element) || ( value >= param[0] && value <= param[1] );
1095
- },
1096
-
1097
- // http://docs.jquery.com/Plugins/Validation/Methods/email
1098
- email: function(value, element) {
1099
- // contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
1100
- return this.optional(element) || /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(value);
1101
- },
1102
-
1103
- // http://docs.jquery.com/Plugins/Validation/Methods/url
1104
- url: function(value, element) {
1105
- // contributed by Scott Gonzalez: http://projects.scottsplayground.com/iri/
1106
- return this.optional(element) || /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value);
1107
- },
1108
-
1109
- // http://docs.jquery.com/Plugins/Validation/Methods/date
1110
- date: function(value, element) {
1111
- return this.optional(element) || !/Invalid|NaN/.test(new Date(value));
1112
- },
1113
-
1114
- // http://docs.jquery.com/Plugins/Validation/Methods/dateISO
1115
- dateISO: function(value, element) {
1116
- return this.optional(element) || /^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/.test(value);
1117
- },
1118
-
1119
- // http://docs.jquery.com/Plugins/Validation/Methods/number
1120
- number: function(value, element) {
1121
- return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(value);
1122
- },
1123
-
1124
- // http://docs.jquery.com/Plugins/Validation/Methods/digits
1125
- digits: function(value, element) {
1126
- return this.optional(element) || /^\d+$/.test(value);
1127
- },
1128
-
1129
- // http://docs.jquery.com/Plugins/Validation/Methods/creditcard
1130
- // based on http://en.wikipedia.org/wiki/Luhn
1131
- creditcard: function(value, element) {
1132
- if ( this.optional(element) ) {
1133
- return "dependency-mismatch";
1134
- }
1135
- // accept only spaces, digits and dashes
1136
- if (/[^0-9 \-]+/.test(value)) {
1137
- return false;
1138
- }
1139
- var nCheck = 0,
1140
- nDigit = 0,
1141
- bEven = false;
1142
-
1143
- value = value.replace(/\D/g, "");
1144
-
1145
- for (var n = value.length - 1; n >= 0; n--) {
1146
- var cDigit = value.charAt(n);
1147
- nDigit = parseInt(cDigit, 10);
1148
- if (bEven) {
1149
- if ((nDigit *= 2) > 9) {
1150
- nDigit -= 9;
1151
- }
1152
- }
1153
- nCheck += nDigit;
1154
- bEven = !bEven;
1155
- }
1156
-
1157
- return (nCheck % 10) === 0;
1158
- },
1159
-
1160
- // http://docs.jquery.com/Plugins/Validation/Methods/equalTo
1161
- equalTo: function(value, element, param) {
1162
- // bind to the blur event of the target in order to revalidate whenever the target field is updated
1163
- // TODO find a way to bind the event just once, avoiding the unbind-rebind overhead
1164
- var target = $(param);
1165
- if (this.settings.onfocusout) {
1166
- target.unbind(".validate-equalTo").bind("blur.validate-equalTo", function() {
1167
- $(element).valid();
1168
- });
1169
- }
1170
- return value === target.val();
1171
- }
1172
-
1173
- }
1174
-
1175
- });
1176
-
1177
- // deprecated, use $.validator.format instead
1178
- $.format = $.validator.format;
1179
-
1180
- }(jQuery));
1181
-
1182
- // ajax mode: abort
1183
- // usage: $.ajax({ mode: "abort"[, port: "uniqueport"]});
1184
- // if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort()
1185
- (function($) {
1186
- var pendingRequests = {};
1187
- // Use a prefilter if available (1.5+)
1188
- if ( $.ajaxPrefilter ) {
1189
- $.ajaxPrefilter(function(settings, _, xhr) {
1190
- var port = settings.port;
1191
- if (settings.mode === "abort") {
1192
- if ( pendingRequests[port] ) {
1193
- pendingRequests[port].abort();
1194
- }
1195
- pendingRequests[port] = xhr;
1196
- }
1197
- });
1198
- } else {
1199
- // Proxy ajax
1200
- var ajax = $.ajax;
1201
- $.ajax = function(settings) {
1202
- var mode = ( "mode" in settings ? settings : $.ajaxSettings ).mode,
1203
- port = ( "port" in settings ? settings : $.ajaxSettings ).port;
1204
- if (mode === "abort") {
1205
- if ( pendingRequests[port] ) {
1206
- pendingRequests[port].abort();
1207
- }
1208
- return (pendingRequests[port] = ajax.apply(this, arguments));
1209
- }
1210
- return ajax.apply(this, arguments);
1211
- };
1212
- }
1213
- }(jQuery));
1214
-
1215
- // provides cross-browser focusin and focusout events
1216
- // IE has native support, in other browsers, use event caputuring (neither bubbles)
1217
-
1218
- // provides delegate(type: String, delegate: Selector, handler: Callback) plugin for easier event delegation
1219
- // handler is only called when $(event.target).is(delegate), in the scope of the jquery-object for event.target
1220
- (function($) {
1221
- // only implement if not provided by jQuery core (since 1.4)
1222
- // TODO verify if jQuery 1.4's implementation is compatible with older jQuery special-event APIs
1223
- if (!jQuery.event.special.focusin && !jQuery.event.special.focusout && document.addEventListener) {
1224
- $.each({
1225
- focus: 'focusin',
1226
- blur: 'focusout'
1227
- }, function( original, fix ){
1228
- $.event.special[fix] = {
1229
- setup:function() {
1230
- this.addEventListener( original, handler, true );
1231
- },
1232
- teardown:function() {
1233
- this.removeEventListener( original, handler, true );
1234
- },
1235
- handler: function(e) {
1236
- var args = arguments;
1237
- args[0] = $.event.fix(e);
1238
- args[0].type = fix;
1239
- return $.event.handle.apply(this, args);
1240
- }
1241
- };
1242
- function handler(e) {
1243
- e = $.event.fix(e);
1244
- e.type = fix;
1245
- return $.event.handle.call(this, e);
1246
- }
1247
- });
1248
- }
1249
- $.extend($.fn, {
1250
- validateDelegate: function(delegate, type, handler) {
1251
- return this.bind(type, function(event) {
1252
- var target = $(event.target);
1253
- if (target.is(delegate)) {
1254
- return handler.apply(target, arguments);
1255
- }
1256
- });
1257
- }
1258
- });
1259
- }(jQuery));
2
+ //= require _jquery.validate