autonumeric-rails 1.9.33 → 1.9.37

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5fec256118f38c9fab3e38a17e0deb8e447eacee
4
+ data.tar.gz: 6b02d02eca8c48a242cf23504d0dfdea1db39140
5
+ SHA512:
6
+ metadata.gz: b7e794fa721b2d3b1ee171dc5895c9dbc2885bfc1375b7ef19e52be1ef9208ddebb6bad548c47250c071155899bd9ecb4033890b4b7faf425412d1bc7cf37830
7
+ data.tar.gz: 7bf4acc7b2ef696a3f8239f857f4816f6607d47c2cdc7d4aded93c01548b4cb317f98211822fa11fe5832e25ecf32dbb43b6dfe9a11e24d2794551257a3c9ca9
@@ -1,39 +1,51 @@
1
- # 1.9.27
1
+ ### 1.9.37
2
+
3
+ - Update autoNumeric v 1.9.37
4
+
5
+ ### 1.9.33.1
6
+
7
+ - add class method delete_autonumeric_object
8
+
9
+ ### 1.9.33
10
+
11
+ - Update autoNumeric v 1.9.33
12
+
13
+ ### 1.9.27
2
14
 
3
15
  - Update autoNumeric v 1.9.27
4
16
  - Update development gems and rspec syntax to v3
5
17
 
6
- # 1.9.25.0
18
+ ### 1.9.25.0
7
19
 
8
20
  - Update autoNumeric v 1.9.25
9
21
 
10
- # 1.9.24.0
22
+ ### 1.9.24.0
11
23
 
12
24
  - Update autoNumeric v 1.9.24
13
25
 
14
- # 1.9.22.1
26
+ ### 1.9.22.1
15
27
 
16
28
  - Merge PR #4 "Sanitize hidden input on blur event" - Thanks to @tiagoamaro
17
29
 
18
- # 1.9.22
30
+ ### 1.9.22
19
31
 
20
32
  - Update autoNumeric v 1.9.22
21
33
  - autoNumeric fields now automatically initialize after AJAX requests.
22
34
  Manual DOM modification (through JavaScript) must still trigger `refresh_autonumeric` event manually
23
35
 
24
- # 1.9.21
36
+ ### 1.9.21
25
37
 
26
38
  - Update autoNumeric v 1.9.21
27
39
 
28
- # 1.9.19.0
40
+ ### 1.9.19.0
29
41
 
30
42
  - Update autoNumeric v 1.9.19
31
43
 
32
- # 1.9.18.1
44
+ ### 1.9.18.1
33
45
 
34
46
  - Improved support for dynamically generated DOM elements
35
47
 
36
- # 1.9.18.0
48
+ ### 1.9.18.0
37
49
 
38
50
  - Update autoNumeric v 1.9.18
39
51
  - Rewrite JS code using Javascript class, to keep things clean
@@ -41,10 +53,10 @@ Manual DOM modification (through JavaScript) must still trigger `refresh_autonum
41
53
  - Write proper tests
42
54
  - Fix bug when value of an existing record could be lost
43
55
 
44
- # 0.1.9.17
56
+ ### 0.1.9.17
45
57
 
46
58
  - Update autoNumeric v 1.9.17
47
59
 
48
- # 0.1.9.15
60
+ ### 0.1.9.15
49
61
 
50
62
  - Initial version, wrapping autoNumeric v 1.9.15
data/README.md CHANGED
@@ -64,6 +64,17 @@ To do so you must trigger the `refresh_autonumeric` event on `document` after yo
64
64
  ``` javascript
65
65
  $(document).trigger('refresh_autonumeric');
66
66
  ```
67
+
68
+ ## Disable autonumeric-rails and autoNumeric
69
+
70
+ You can disable autonumeric-rails and autoNumeric from an object and turn it back into a simple input element by calling
71
+ `AutonumericRails.delete_autonumeric_object` and passing the targeted jQuery object to it:
72
+ ``` javascript
73
+ var element = $("#field");
74
+ AutonumericRails.delete_autonumeric_object(element);
75
+ ```
76
+ **Note**: This will not un-sanitize the field's value, and you must do it manually.
77
+
67
78
  ## Internal
68
79
 
69
80
  Autonumeric-rails creates in the DOM an hidden input with the same name as the text field.
@@ -74,6 +85,9 @@ When validating the form, the hidden field value is sent to the server as it is
74
85
 
75
86
  For a full list of change, see the [CHANGELOG.md](https://github.com/randoum/autonumeric-rails/blob/master/CHANGELOG.md) file
76
87
 
88
+ ### 1.9.33.1
89
+ Add class method `delete_autonumeric_object` to disable autonumeric-rails and autoNumeric attributes from an object
90
+
77
91
  ### 1.9.22
78
92
  Bind on `ajaxComplete` event, so each jQuery ajax event automatically refresh autonumeric fields. Manually triggering `refresh_autonumeric` is not necessary for rails-ujs (i.e `data-remote`) anymore
79
93
 
@@ -1,5 +1,5 @@
1
1
  module Autonumeric
2
2
  module Rails
3
- VERSION = '1.9.33'
3
+ VERSION = '1.9.37'
4
4
  end
5
5
  end
@@ -1,4 +1,5 @@
1
1
  ENV['RAILS_ENV'] ||= 'test'
2
+ LOCAL_PLATFORM = (Gem::Platform.local.os == 'darwin' ? :mac : :linux)
2
3
 
3
4
  # Load environment
4
5
  require File.expand_path('../dummy/config/environment', __FILE__)
@@ -46,9 +47,11 @@ RSpec.configure do |config|
46
47
  config.after(:each) { DatabaseCleaner.clean }
47
48
 
48
49
  # Headless for selenium driver
49
- config.before(:each, js: true) {
50
- headless = Headless.new
51
- headless.start
52
- at_exit { headless.destroy }
53
- }
50
+ if LOCAL_PLATFORM == :linux
51
+ config.before(:each, js: true) {
52
+ headless = Headless.new
53
+ headless.start
54
+ at_exit { headless.destroy }
55
+ }
56
+ end
54
57
  end
@@ -3,18 +3,18 @@ shared_examples 'all autonumeric-rails tests' do
3
3
  let(:record_id) { '' }
4
4
 
5
5
  it 'Input tag' do
6
- assert_selector("input#record_field1[name='record[field1]'][data-autonumeric='true']")
6
+ assert_selector(%q{input#record_field1[name='record[field1]'][data-autonumeric='true']})
7
7
  assert_selector("input#record_field2[name='record[field2]'][data-autonumeric='#{params}']")
8
8
  end
9
9
 
10
10
  it 'Hidden tags' do
11
- assert_selector("input#record_field1_val[name='record[field1]'][type='hidden']")
12
- assert_selector("input#record_field2_val[name='record[field2]'][type='hidden']")
11
+ assert_selector(%q{input#record_field1_val[name='record[field1]'][type='hidden']})
12
+ assert_selector(%q{input#record_field2_val[name='record[field2]'][type='hidden']})
13
13
  end
14
14
 
15
15
  it 'Hidden tag is located after Input tag' do
16
- expect(find(:xpath, ".//*[@id='record_field1']/following-sibling::*[1]")['id']).to eq('record_field1_val')
17
- expect(find(:xpath, ".//*[@id='record_field2']/following-sibling::*[1]")['id']).to eq('record_field2_val')
16
+ expect(find(:xpath, %q{.//*[@id='record_field1']/following-sibling::*[1]})['id']).to eq('record_field1_val')
17
+ expect(find(:xpath, %q{.//*[@id='record_field2']/following-sibling::*[1]})['id']).to eq('record_field2_val')
18
18
  end
19
19
 
20
20
  it 'Set empty default values' do
@@ -85,4 +85,32 @@ shared_examples 'all autonumeric-rails tests' do
85
85
  expect(from_db.field2).to eq(776655.4)
86
86
  end
87
87
  end
88
+
89
+ context 'deleting autonumeric object' do
90
+ let(:record_id) { '' }
91
+
92
+ before { execute_script 'AutonumericRails.delete_autonumeric_object($("#record_field1"));' }
93
+
94
+ it 'Input tag' do
95
+ assert_selector(%q{input#record_field1[name='record[field1]']:not([data-autonumeric])})
96
+ assert_selector("input#record_field2[name='record[field2]'][data-autonumeric='#{params}']")
97
+ end
98
+
99
+ it 'Hidden tags' do
100
+ assert_no_selector('input#record_field1_val')
101
+ assert_selector(%q{input#record_field2_val[name='record[field2]'][type='hidden']})
102
+ end
103
+
104
+ it 'Typing value after delete_autonumeric_object' do
105
+
106
+ find('#record_field1').set '12345'
107
+ find('#record_field2').set '54321.987'
108
+
109
+ expect(find('#record_field1').value).to eq('12345')
110
+ expect(all('#record_field1_val').count).to eq(0)
111
+
112
+ expect(find('#record_field2').value).to eq('USD 54,321.9')
113
+ expect(find('#record_field2_val').value).to eq('54321.9')
114
+ end
115
+ end
88
116
  end
@@ -2,10 +2,10 @@
2
2
  * autoNumeric.js
3
3
  * @author: Bob Knothe
4
4
  * @author: Sokolov Yura
5
- * @version: 1.9.33 - 2015-02-15 GMT 11:00 PM
5
+ * @version: 1.9.37 - 2015-05-24 GMT 7:00 PM / 19:00
6
6
  *
7
7
  * Created by Robert J. Knothe on 2010-10-25. Please report any bugs to https://github.com/BobKnothe/autoNumeric
8
- * Created by Sokolov Yura on 2010-11-07
8
+ * Contributor by Sokolov Yura on 2010-11-07
9
9
  *
10
10
  * Copyright (c) 2011 Robert J. Knothe http://www.decorplanit.com/plugin/
11
11
  *
@@ -38,6 +38,10 @@
38
38
  /*global jQuery: false*/
39
39
  /*Cross browser routine for getting selected range/cursor position
40
40
  */
41
+
42
+ /**
43
+ * Cross browser routine for getting selected range/cursor position
44
+ */
41
45
  function getElementSelection(that) {
42
46
  var position = {};
43
47
  if (that.selectionStart === undefined) {
@@ -54,6 +58,7 @@
54
58
  }
55
59
  return position;
56
60
  }
61
+
57
62
  /**
58
63
  * Cross browser routine for setting selected range/cursor position
59
64
  */
@@ -70,6 +75,7 @@
70
75
  that.selectionEnd = end;
71
76
  }
72
77
  }
78
+
73
79
  /**
74
80
  * run callbacks in parameters if any
75
81
  * any parameter could be a callback:
@@ -93,11 +99,16 @@
93
99
  }
94
100
  });
95
101
  }
102
+
103
+ /**
104
+ * Converts the vMin, vMax & mDec string to numeric value
105
+ */
96
106
  function convertKeyToNumber(settings, key) {
97
107
  if (typeof (settings[key]) === 'string') {
98
108
  settings[key] *= 1;
99
109
  }
100
110
  }
111
+
101
112
  /**
102
113
  * Preparing user defined options for further usage
103
114
  * merge them with defaults appropriately
@@ -144,8 +155,9 @@
144
155
  settings.numRegAutoStrip = new RegExp(aNegReg + '(?:\\' + settings.aDec + '?(\\d+\\' + settings.aDec + '\\d+)|(\\d*(?:\\' + settings.aDec + '\\d*)?))');
145
156
  return settings;
146
157
  }
158
+
147
159
  /**
148
- * strip all unwanted characters and leave only a number alert
160
+ * strips all unwanted characters and leave only a number alert
149
161
  */
150
162
  function autoStrip(s, settings, strip_zero) {
151
163
  if (settings.aSign) { /** remove currency sign */
@@ -181,35 +193,25 @@
181
193
  }
182
194
  return s;
183
195
  }
196
+
184
197
  /**
185
198
  * places or removes brackets on negative values
199
+ * works only when with pSign: 'p'
186
200
  */
187
- function negativeBracket(s, nBracket, hasFocus) {
188
- nBracket = nBracket.split(',');
189
- if (hasFocus === false && s.charAt(0) === '-') {
190
- s = s.replace('-', '');
191
- s = nBracket[0] + s + nBracket[1];
192
- } else if (hasFocus === true && s.charAt(0) === nBracket[0]) {
193
- s = s.replace(nBracket[0], '-');
194
- s = s.replace(nBracket[1], '');
195
- }
196
- return s;
197
- }
198
- /**
199
- * prepare number string to be converted to real number
200
- */
201
- function fixNumber(s, aDec, aNeg) {
202
- if (aDec && aDec !== '.') {
203
- s = s.replace(aDec, '.');
204
- }
205
- if (aNeg && aNeg !== '-') {
206
- s = s.replace(aNeg, '-');
207
- }
208
- if (!s.match(/\d/)) {
209
- s += '0';
201
+ function negativeBracket(s, settings) {
202
+ if (settings.pSign === 'p') {
203
+ var brackets = settings.nBracket.split(',');
204
+ if (!settings.hasFocus && !settings.removeBrackets) {
205
+ s = s.replace(settings.aNeg, '');
206
+ s = brackets[0] + s + brackets[1];
207
+ } else if ((settings.hasFocus && s.charAt(0) === brackets[0]) || (settings.removeBrackets && s.charAt(0) === brackets[0])) {
208
+ s = s.replace(brackets[0], settings.aNeg);
209
+ s = s.replace(brackets[1], '');
210
+ }
210
211
  }
211
212
  return s;
212
213
  }
214
+
213
215
  /**
214
216
  * function to handle numbers less than 0 that are stored in Exponential notation ex: .0000001 stored as 1e-7
215
217
  */
@@ -241,6 +243,23 @@
241
243
  }
242
244
  return (settings.lZero === 'keep') ? value : value.replace(/^0*(\d)/, '$1');
243
245
  }
246
+
247
+ /**
248
+ * prepare number string to be converted to real number
249
+ */
250
+ function fixNumber(s, aDec, aNeg) {
251
+ if (aDec && aDec !== '.') {
252
+ s = s.replace(aDec, '.');
253
+ }
254
+ if (aNeg && aNeg !== '-') {
255
+ s = s.replace(aNeg, '-');
256
+ }
257
+ if (!s.match(/\d/)) {
258
+ s += '0';
259
+ }
260
+ return s;
261
+ }
262
+
244
263
  /**
245
264
  * prepare real number to be converted to our format
246
265
  */
@@ -253,6 +272,7 @@
253
272
  }
254
273
  return s;
255
274
  }
275
+
256
276
  /**
257
277
  * private function to check for empty value
258
278
  */
@@ -268,6 +288,7 @@
268
288
  }
269
289
  return null;
270
290
  }
291
+
271
292
  /**
272
293
  * private function that formats our number
273
294
  */
@@ -312,12 +333,12 @@
312
333
  iv = settings.aNeg + iv;
313
334
  }
314
335
  }
315
- if (settings.setEvent && testNeg < 0 && settings.nBracket !== null) { /** removes the negative sign and places brackets */
316
- iv = negativeBracket(iv, settings.nBracket, settings.hasFocus);
317
- settings.setEvent = false;
336
+ if (testNeg < 0 && settings.nBracket !== null) { /** removes the negative sign and places brackets */
337
+ iv = negativeBracket(iv, settings);
318
338
  }
319
339
  return iv;
320
340
  }
341
+
321
342
  /**
322
343
  * round number after setting by pasting or $().autoNumericSet()
323
344
  * private function for round the number
@@ -394,18 +415,20 @@
394
415
  if (odd !== 1) {
395
416
  odd = (odd === 0 && (iv.substring(rLength + 2, iv.length) > 0)) ? 1 : 0;
396
417
  }
397
- if ((tRound > 4 && settings.mRound === 'S') || /** Round half up symmetric */
398
- (tRound > 4 && settings.mRound === 'A' && nSign === '') || /** Round half up asymmetric positive values */
399
- (tRound > 5 && settings.mRound === 'A' && nSign === '-') || /** Round half up asymmetric negative values */
400
- (tRound > 5 && settings.mRound === 's') || /** Round half down symmetric */
401
- (tRound > 5 && settings.mRound === 'a' && nSign === '') || /** Round half down asymmetric positive values */
402
- (tRound > 4 && settings.mRound === 'a' && nSign === '-') || /** Round half down asymmetric negative values */
403
- (tRound > 5 && settings.mRound === 'B') || /** Round half even "Banker's Rounding" */
404
- (tRound === 5 && settings.mRound === 'B' && odd === 1) || /** Round half even "Banker's Rounding" */
405
- (tRound > 0 && settings.mRound === 'C' && nSign === '') || /** Round to ceiling toward positive infinite */
406
- (tRound > 0 && settings.mRound === 'F' && nSign === '-') || /** Round to floor toward negative infinite */
407
- (tRound > 0 && settings.mRound === 'U') ||
408
- (settings.mRound === 'CHF')) { /** round up away from zero */
418
+ /*jslint white: true*/
419
+ if ((tRound > 4 && settings.mRound === 'S') || /** Round half up symmetric */
420
+ (tRound > 4 && settings.mRound === 'A' && nSign === '') || /** Round half up asymmetric positive values */
421
+ (tRound > 5 && settings.mRound === 'A' && nSign === '-') || /** Round half up asymmetric negative values */
422
+ (tRound > 5 && settings.mRound === 's') || /** Round half down symmetric */
423
+ (tRound > 5 && settings.mRound === 'a' && nSign === '') || /** Round half down asymmetric positive values */
424
+ (tRound > 4 && settings.mRound === 'a' && nSign === '-') || /** Round half down asymmetric negative values */
425
+ (tRound > 5 && settings.mRound === 'B') || /** Round half even "Banker's Rounding" */
426
+ (tRound === 5 && settings.mRound === 'B' && odd === 1) || /** Round half even "Banker's Rounding" */
427
+ (tRound > 0 && settings.mRound === 'C' && nSign === '') || /** Round to ceiling toward positive infinite */
428
+ (tRound > 0 && settings.mRound === 'F' && nSign === '-') || /** Round to floor toward negative infinite */
429
+ (tRound > 0 && settings.mRound === 'U') || /** round up away from zero */
430
+ (settings.mRound === 'CHF')) { /** Round Swiss FRanc */
431
+ /*jslint white: false*/
409
432
  for (i = (ivArray.length - 1); i >= 0; i -= 1) { /** Round up the last digit if required, and continue until no more 9's are found */
410
433
  if (ivArray[i] !== '.') {
411
434
  if (settings.mRound === 'CHF' && ivArray[i] <= 2 && onePass) {
@@ -437,6 +460,7 @@
437
460
  ivRounded = truncateZeros(ivArray.join('')); /** return rounded value */
438
461
  return (+ivRounded === 0) ? ivRounded : nSign + ivRounded;
439
462
  }
463
+
440
464
  /**
441
465
  * truncate decimal part of a number
442
466
  */
@@ -459,6 +483,7 @@
459
483
  }
460
484
  return s;
461
485
  }
486
+
462
487
  /**
463
488
  * checking that number satisfy format conditions
464
489
  * and lays between settings.vMin and settings.vMax
@@ -471,6 +496,7 @@
471
496
  var value = +s;
472
497
  return value >= settings.vMin && value <= settings.vMax;
473
498
  }
499
+
474
500
  /**
475
501
  * Holder object for field properties
476
502
  */
@@ -524,6 +550,7 @@
524
550
  parts[1] = autoStrip(parts[1], this.settingsClone);
525
551
  return parts;
526
552
  },
553
+
527
554
  /**
528
555
  * strip parts from excess characters and leading zeroes
529
556
  */
@@ -551,6 +578,7 @@
551
578
  }
552
579
  return [left, right];
553
580
  },
581
+
554
582
  /**
555
583
  * set part of number to value keeping position of cursor
556
584
  */
@@ -570,6 +598,7 @@
570
598
  }
571
599
  return false;
572
600
  },
601
+
573
602
  /**
574
603
  * helper function for expandSelectionOnSign
575
604
  * returns sign position of a formatted value
@@ -589,6 +618,7 @@
589
618
  }
590
619
  return [1000, -1];
591
620
  },
621
+
592
622
  /**
593
623
  * expands selection to cover whole sign
594
624
  * prevents partial deletion/copying/overwriting of a sign
@@ -608,12 +638,14 @@
608
638
  }
609
639
  }
610
640
  },
641
+
611
642
  /**
612
643
  * try to strip pasted value to digits
613
644
  */
614
645
  checkPaste: function () {
615
646
  if (this.valuePartsBeforePaste !== undefined) {
616
647
  var parts = this.getBeforeAfter(),
648
+
617
649
  oldParts = this.valuePartsBeforePaste;
618
650
  delete this.valuePartsBeforePaste; /** try to strip pasted value first */
619
651
  parts[0] = parts[0].substr(0, oldParts[0].length) + autoStrip(parts[0].substr(oldParts[0].length), this.settingsClone);
@@ -623,6 +655,7 @@
623
655
  }
624
656
  }
625
657
  },
658
+
626
659
  /**
627
660
  * process pasting, cursor moving and skipping of not interesting keys
628
661
  * if returns true, further processing is not performed
@@ -639,8 +672,9 @@
639
672
  }
640
673
  /** codes are taken from http://www.cambiaresearch.com/c4/702b8cd1-e5b0-42e6-83ac-25f0306e3e25/Javascript-Char-Codes-Key-Codes.aspx
641
674
  * skip Fx keys, windows keys, other special keys
675
+ * Thanks Ney Estrabelli for the FF for Mac meta key support "keycode 224"
642
676
  */
643
- if ((kdCode >= 112 && kdCode <= 123) || (kdCode >= 91 && kdCode <= 93) || (kdCode >= 9 && kdCode <= 31) || (kdCode < 8 && (which === 0 || which === kdCode)) || kdCode === 144 || kdCode === 145 || kdCode === 45) {
677
+ if ((kdCode >= 112 && kdCode <= 123) || (kdCode >= 91 && kdCode <= 93) || (kdCode >= 9 && kdCode <= 31) || (kdCode < 8 && (which === 0 || which === kdCode)) || kdCode === 144 || kdCode === 145 || kdCode === 45 || kdCode === 224) {
644
678
  return true;
645
679
  }
646
680
  if ((ctrlKey || cmdKey) && kdCode === 65) { /** if select all (a=65)*/
@@ -682,6 +716,7 @@
682
716
  }
683
717
  return false;
684
718
  },
719
+
685
720
  /**
686
721
  * process deletion of characters
687
722
  * returns true if processing performed
@@ -706,6 +741,7 @@
706
741
  }
707
742
  return false;
708
743
  },
744
+
709
745
  /**
710
746
  * process insertion of characters
711
747
  * returns true if processing performed
@@ -768,6 +804,7 @@
768
804
  } /** prevent any other character */
769
805
  return true;
770
806
  },
807
+
771
808
  /**
772
809
  * formatting of just processed value with keeping of cursor position
773
810
  */
@@ -821,7 +858,10 @@
821
858
  this.formatted = true;
822
859
  }
823
860
  };
824
- /** thanks to Anthony & Evan C */
861
+
862
+ /**
863
+ * thanks to Anthony & Evan C
864
+ */
825
865
  function autoGet(obj) {
826
866
  if (typeof obj === 'string') {
827
867
  obj = obj.replace(/\[/g, "\\[").replace(/\]/g, "\\]");
@@ -831,6 +871,11 @@
831
871
  }
832
872
  return $(obj);
833
873
  }
874
+
875
+ /**
876
+ * function to attach data to the element
877
+ * and imitate the holder
878
+ */
834
879
  function getHolder($that, settings, update) {
835
880
  var data = $that.data('autoNumeric');
836
881
  if (!data) {
@@ -844,31 +889,49 @@
844
889
  }
845
890
  return holder;
846
891
  }
892
+
847
893
  var methods = {
894
+
895
+ /**
896
+ * Method to initiate autoNumeric and attached the settings (default and options passed as a parameter
897
+ * $(someSelector).autoNumeric('init'); // initiate autoNumeric with defaults
898
+ * $(someSelector).autoNumeric('init', {option}); // initiate autoNumeric with options
899
+ * $(someSelector).autoNumeric(); // initiate autoNumeric with defaults
900
+ * $(someSelector).autoNumeric({option}); // initiate autoNumeric with options
901
+ * options passes as a parameter example '{aSep: '.', aDec: ',', aSign: '€ '}
902
+ */
848
903
  init: function (options) {
849
904
  return this.each(function () {
850
905
  var $this = $(this),
851
- settings = $this.data('autoNumeric'),
852
- /** attempt to grab 'autoNumeric' settings, if they don't exist returns "undefined". */
853
- tagData = $this.data(); /** attempt to grab HTML5 data, if they don't exist we'll get "undefined".*/
906
+ settings = $this.data('autoNumeric'), /** attempt to grab 'autoNumeric' settings, if they don't exist returns "undefined". */
907
+ tagData = $this.data(), /** attempt to grab HTML5 data, if they don't exist we'll get "undefined".*/
908
+ $input = $this.is('input[type=text], input[type=hidden], input[type=tel], input:not([type])');
854
909
  if (typeof settings !== 'object') { /** If we couldn't grab settings, create them from defaults and passed options. */
855
- settings = $.extend({}, $.fn.autoNumeric.defaults, tagData, options, {setEvent: false, hasFocus: false}); /** Merge defaults, tagData and options */
910
+ settings = $.extend({}, $.fn.autoNumeric.defaults, tagData, options, {
911
+ aNum: '0123456789',
912
+ hasFocus: false,
913
+ removeBrackets: false,
914
+ runOnce: false,
915
+ tagList: ['b', 'caption', 'cite', 'code', 'dd', 'del', 'div', 'dfn', 'dt', 'em', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ins', 'kdb', 'label', 'li', 'output', 'p', 'q', 's', 'sample', 'span', 'strong', 'td', 'th', 'u', 'var']
916
+ }); /** Merge defaults, tagData and options */
856
917
  if (settings.aDec === settings.aSep) {
857
918
  $.error("autoNumeric will not function properly when the decimal character aDec: '" + settings.aDec + "' and thousand separator aSep: '" + settings.aSep + "' are the same character");
858
- return this;
859
919
  }
860
920
  $this.data('autoNumeric', settings); /** Save our new settings */
861
921
  } else {
862
922
  return this;
863
923
  }
864
- settings.runOnce = false;
865
924
  var holder = getHolder($this, settings);
925
+ if (!$input && $this.prop('tagName').toLowerCase() === 'input') { /** checks for non-supported input types */
926
+ $.error('The input type "' + $this.prop('type') + '" is not supported by autoNumeric()');
927
+
928
+ }
866
929
  if ($.inArray($this.prop('tagName').toLowerCase(), settings.tagList) === -1 && $this.prop('tagName').toLowerCase() !== 'input') {
867
930
  $.error("The <" + $this.prop('tagName').toLowerCase() + "> is not supported by autoNumeric()");
868
- return this;
931
+
869
932
  }
870
933
  if (settings.runOnce === false && settings.aForm) { /** routine to format default value on page load */
871
- if ($this.is('input[type=text], input[type=hidden], input[type=tel], input:not([type])')) {
934
+ if ($input) {
872
935
  var setValue = true;
873
936
  if ($this[0].value === '' && settings.wEmpty === 'empty') {
874
937
  $this[0].value = '';
@@ -878,7 +941,12 @@
878
941
  $this[0].value = settings.aSign;
879
942
  setValue = false;
880
943
  }
881
- if (setValue && $this[0].value === $this.prop('defaultValue')) {
944
+ /** checks for page reload from back button
945
+ * also checks for ASP.net form post back
946
+ * the following HTML data attribute is REQUIRED (data-an-default="same value as the value attribute")
947
+ * example: <asp:TextBox runat="server" id="someID" value="1234.56" data-an-default="1234.56">
948
+ */
949
+ if (setValue && $this.val() !== '' && ((settings.anDefault === undefined && $this[0].value === $this.prop('defaultValue')) || (settings.anDefault !== undefined && settings.anDefault.toString() === $this.val()))) {
882
950
  $this.autoNumeric('set', $this.val());
883
951
  }
884
952
  }
@@ -892,7 +960,6 @@
892
960
  holder = getHolder($this);
893
961
  if (holder.settings.aDec === holder.settings.aSep) {
894
962
  $.error("autoNumeric will not function properly when the decimal character aDec: '" + holder.settings.aDec + "' and thousand separator aSep: '" + holder.settings.aSep + "' are the same character");
895
- return this;
896
963
  }
897
964
  if (holder.that.readOnly) {
898
965
  holder.processed = true;
@@ -918,8 +985,8 @@
918
985
  return true;
919
986
  });
920
987
  $this.on('keypress.autoNumeric', function (e) {
921
- var holder = getHolder($this),
922
- processed = holder.processed;
988
+ holder = getHolder($this);
989
+ var processed = holder.processed;
923
990
  holder.init(e);
924
991
  if (holder.skipAllways(e)) {
925
992
  return true;
@@ -936,7 +1003,7 @@
936
1003
  holder.formatted = false;
937
1004
  });
938
1005
  $this.on('keyup.autoNumeric', function (e) {
939
- var holder = getHolder($this);
1006
+ holder = getHolder($this);
940
1007
  holder.init(e);
941
1008
  var skip = holder.skipAllways(e);
942
1009
  holder.kdCode = 0;
@@ -959,61 +1026,59 @@
959
1026
  }
960
1027
  });
961
1028
  $this.on('focusin.autoNumeric', function () {
962
- var holder = getHolder($this);
963
- holder.settingsClone.hasFocus = true;
964
- if (holder.settingsClone.nBracket !== null) {
1029
+ holder = getHolder($this);
1030
+ var $settings = holder.settingsClone;
1031
+ $settings.hasFocus = true;
1032
+ if ($settings.nBracket !== null) {
965
1033
  var checkVal = $this.val();
966
- $this.val(negativeBracket(checkVal, holder.settingsClone.nBracket, holder.settingsClone.hasFocus));
1034
+ $this.val(negativeBracket(checkVal, $settings));
967
1035
  }
968
1036
  holder.inVal = $this.val();
969
- var onempty = checkEmpty(holder.inVal, holder.settingsClone, true);
970
- if (onempty !== null) {
971
- $this.val(onempty);
972
- if (holder.settings.pSign === 's') {
973
- setElementSelection(this, 0, 0);
974
- } else {
975
- setElementSelection(this, holder.settings.aSign.length, holder.settings.aSign.length);
976
- }
1037
+ var onEmpty = checkEmpty(holder.inVal, $settings, true);
1038
+ if (onEmpty !== null && onEmpty !== '') {
1039
+ $this.val(onEmpty);
977
1040
  }
978
1041
  });
979
1042
  $this.on('focusout.autoNumeric', function () {
980
- var holder = getHolder($this),
981
- settingsClone = holder.settingsClone,
1043
+ holder = getHolder($this);
1044
+ var $settings = holder.settingsClone,
982
1045
  value = $this.val(),
983
1046
  origValue = value;
984
- holder.settingsClone.hasFocus = false;
1047
+ $settings.hasFocus = false;
985
1048
  var strip_zero = ''; /** added to control leading zero */
986
- if (settingsClone.lZero === 'allow') { /** added to control leading zero */
987
- settingsClone.allowLeading = false;
1049
+ if ($settings.lZero === 'allow') { /** added to control leading zero */
1050
+ $settings.allowLeading = false;
988
1051
  strip_zero = 'leading';
989
1052
  }
990
1053
  if (value !== '') {
991
- value = autoStrip(value, settingsClone, strip_zero);
992
- if (checkEmpty(value, settingsClone) === null && autoCheck(value, settingsClone, $this[0])) {
993
- value = fixNumber(value, settingsClone.aDec, settingsClone.aNeg);
994
- value = autoRound(value, settingsClone);
995
- value = presentNumber(value, settingsClone.aDec, settingsClone.aNeg);
1054
+ value = autoStrip(value, $settings, strip_zero);
1055
+ if (checkEmpty(value, $settings) === null && autoCheck(value, $settings, $this[0])) {
1056
+ value = fixNumber(value, $settings.aDec, $settings.aNeg);
1057
+ value = autoRound(value, $settings);
1058
+ value = presentNumber(value, $settings.aDec, $settings.aNeg);
996
1059
  } else {
997
1060
  value = '';
998
1061
  }
999
1062
  }
1000
- var groupedValue = checkEmpty(value, settingsClone, false);
1063
+ var groupedValue = checkEmpty(value, $settings, false);
1001
1064
  if (groupedValue === null) {
1002
- groupedValue = autoGroup(value, settingsClone);
1065
+ groupedValue = autoGroup(value, $settings);
1003
1066
  }
1004
1067
  if (groupedValue !== holder.inVal || groupedValue !== origValue) {
1005
1068
  $this.change();
1006
1069
  $this.val(groupedValue);
1007
1070
  delete holder.inVal;
1008
1071
  }
1009
- if (settingsClone.nBracket !== null && $this.autoNumeric('get') < 0) {
1010
- $this.val(negativeBracket($this.val(), settingsClone.nBracket, settingsClone.hasFocus));
1011
- }
1012
1072
  });
1013
1073
  }
1014
1074
  });
1015
1075
  },
1016
- /** method to remove settings and stop autoNumeric() */
1076
+
1077
+ /**
1078
+ * method to remove settings and stop autoNumeric() - does not remove the formatting
1079
+ * $(someSelector).autoNumeric('destroy'); // destroy autoNumeric
1080
+ * no parameters accepted
1081
+ */
1017
1082
  destroy: function () {
1018
1083
  return $(this).each(function () {
1019
1084
  var $this = $(this);
@@ -1021,21 +1086,24 @@
1021
1086
  $this.removeData('autoNumeric');
1022
1087
  });
1023
1088
  },
1024
- /** method to update settings - can call as many times */
1089
+
1090
+ /**
1091
+ * method to update settings - can be call as many times
1092
+ * $(someSelector).autoNumeric('update', {options}); // updates the settings
1093
+ * options passes as a parameter example '{aSep: '.', aDec: ',', aSign: '€ '}
1094
+ */
1025
1095
  update: function (options) {
1026
1096
  return $(this).each(function () {
1027
1097
  var $this = autoGet($(this)),
1028
1098
  settings = $this.data('autoNumeric');
1029
1099
  if (typeof settings !== 'object') {
1030
1100
  $.error("You must initialize autoNumeric('init', {options}) prior to calling the 'update' method");
1031
- return this;
1032
1101
  }
1033
1102
  var strip = $this.autoNumeric('get');
1034
1103
  settings = $.extend(settings, options);
1035
1104
  getHolder($this, settings, true);
1036
1105
  if (settings.aDec === settings.aSep) {
1037
1106
  $.error("autoNumeric will not function properly when the decimal character aDec: '" + settings.aDec + "' and thousand separator aSep: '" + settings.aSep + "' are the same character");
1038
- return this;
1039
1107
  }
1040
1108
  $this.data('autoNumeric', settings);
1041
1109
  if ($this.val() !== '' || $this.text() !== '') {
@@ -1044,7 +1112,13 @@
1044
1112
  return;
1045
1113
  });
1046
1114
  },
1047
- /** returns a formatted strings for "input:text" fields Uses jQuery's .val() method*/
1115
+
1116
+ /**
1117
+ * method to format value sent as a parameter ""
1118
+ * $(someSelector).autoNumeric('set', 'value'}); // formats the value being passed
1119
+ * value passed as a string - can be a integer '1234' or double '1234.56789'
1120
+ * must contain only numbers and one decimal (period) character
1121
+ */
1048
1122
  set: function (valueIn) {
1049
1123
  if (valueIn === null) {
1050
1124
  return;
@@ -1053,23 +1127,17 @@
1053
1127
  var $this = autoGet($(this)),
1054
1128
  settings = $this.data('autoNumeric'),
1055
1129
  value = valueIn.toString(),
1056
- testValue = valueIn.toString();
1130
+ testValue = valueIn.toString(),
1131
+ $input = $this.is('input[type=text], input[type=hidden], input[type=tel], input:not([type])');
1057
1132
  if (typeof settings !== 'object') {
1058
1133
  $.error("You must initialize autoNumeric('init', {options}) prior to calling the 'set' method");
1059
- return this;
1060
- }
1061
- /** routine to handle page re-load from back button */
1062
- if (testValue !== $this.attr('value') && $this.prop('tagName').toLowerCase() === 'input' && settings.runOnce === false) {
1063
- value = (settings.nBracket !== null) ? negativeBracket($this.val(), settings.nBracket, settings.hasFocus) : value;
1064
- value = autoStrip(value, settings);
1065
1134
  }
1066
1135
  /** allows locale decimal separator to be a comma */
1067
1136
  if ((testValue === $this.attr('value') || testValue === $this.text()) && settings.runOnce === false) {
1068
1137
  value = value.replace(',', '.');
1069
1138
  }
1070
- /** returns a empty string if the value being 'set' contains non-numeric characters and or more than decimal point (full stop) and will not be formatted */
1071
1139
  if (!$.isNumeric(+value)) {
1072
- return '';
1140
+ $.error("The value (" + value + ") being 'set' is not numeric and has caused a error to be thrown");
1073
1141
  }
1074
1142
  value = checkValue(value, settings);
1075
1143
  settings.setEvent = true;
@@ -1082,25 +1150,28 @@
1082
1150
  value = autoRound('', settings);
1083
1151
  }
1084
1152
  value = autoGroup(value, settings);
1085
- if ($this.is('input[type=text], input[type=hidden], input[type=tel], input:not([type])')) { /**added hidden type */
1153
+ if ($input) {
1086
1154
  return $this.val(value);
1087
1155
  }
1088
1156
  if ($.inArray($this.prop('tagName').toLowerCase(), settings.tagList) !== -1) {
1089
1157
  return $this.text(value);
1090
1158
  }
1091
- $.error("The <" + $this.prop('tagName').toLowerCase() + "> is not supported by autoNumeric()");
1092
1159
  return false;
1093
1160
  });
1094
1161
  },
1095
- /** method to get the unformatted value from a specific input field, returns a numeric value */
1162
+
1163
+ /**
1164
+ * method to get the unformatted that accepts up to one parameter
1165
+ * $(someSelector).autoNumeric('get'); no parameters accepted
1166
+ * values returned as ISO numeric string "1234.56" where the decimal character is a period
1167
+ * only the first element in the selector is returned
1168
+ */
1096
1169
  get: function () {
1097
1170
  var $this = autoGet($(this)),
1098
1171
  settings = $this.data('autoNumeric');
1099
1172
  if (typeof settings !== 'object') {
1100
1173
  $.error("You must initialize autoNumeric('init', {options}) prior to calling the 'get' method");
1101
- return this;
1102
1174
  }
1103
- settings.setEvent = false;
1104
1175
  var getValue = '';
1105
1176
  /** determine the element type then use .eq(0) selector to grab the value of the first element in selector */
1106
1177
  if ($this.is('input[type=text], input[type=hidden], input[type=tel], input:not([type])')) { /**added hidden type */
@@ -1109,13 +1180,14 @@
1109
1180
  getValue = $this.eq(0).text();
1110
1181
  } else {
1111
1182
  $.error("The <" + $this.prop('tagName').toLowerCase() + "> is not supported by autoNumeric()");
1112
- return false;
1113
1183
  }
1114
1184
  if ((getValue === '' && settings.wEmpty === 'empty') || (getValue === settings.aSign && (settings.wEmpty === 'sign' || settings.wEmpty === 'empty'))) {
1115
1185
  return '';
1116
1186
  }
1117
- if (settings.nBracket !== null && getValue !== '') {
1118
- getValue = negativeBracket(getValue, settings.nBracket, true);
1187
+ if (getValue !== '' && settings.nBracket !== null) {
1188
+ settings.removeBrackets = true;
1189
+ getValue = negativeBracket(getValue, settings);
1190
+ settings.removeBrackets = false;
1119
1191
  }
1120
1192
  if (settings.runOnce || settings.aForm === false) {
1121
1193
  getValue = autoStrip(getValue, settings);
@@ -1130,78 +1202,146 @@
1130
1202
  getValue = checkValue(getValue, settings);
1131
1203
  return getValue; /** returned Numeric String */
1132
1204
  },
1133
- /** method to get the unformatted value from multiple fields */
1205
+
1206
+ /**
1207
+ * The 'getString' method used jQuerys .serialize() method that creates a text string in standard URL-encoded notation
1208
+ * it then loops through the string and un-formats the inputs with autoNumeric
1209
+ * $(someSelector).autoNumeric('getString'); no parameter accepted
1210
+ * values returned as ISO numeric string "1234.56" where the decimal character is a period
1211
+ */
1134
1212
  getString: function () {
1135
1213
  var isAutoNumeric = false,
1136
1214
  $this = autoGet($(this)),
1137
- str = $this.serialize(),
1138
- parts = str.split('&'),
1215
+ formFields = $this.serialize(),
1216
+ formParts = formFields.split('&'),
1139
1217
  formIndex = $('form').index($this),
1140
- inputIndex = [],
1141
- i = 0;
1142
- for (i; i < parts.length; i += 1) {
1143
- var miniParts = parts[i].split('='),
1144
- $field = $('form:eq(' + formIndex + ') input[name="' + decodeURIComponent(miniParts[0]) + '"]'),
1145
- settings = $field.data('autoNumeric');
1146
- if ($field.length > 1) {
1147
- if (inputIndex[decodeURIComponent(miniParts[0])] === undefined) {
1148
- inputIndex[decodeURIComponent(miniParts[0])] = 0;
1149
- } else {
1150
- inputIndex[decodeURIComponent(miniParts[0])]++;
1218
+ allFormElements = $('form:eq(' + formIndex + ')'),
1219
+ aiIndex = [], /* all input index */
1220
+ scIndex = [], /* successful control index */
1221
+ rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, /* from jQuery serialize method */
1222
+ rsubmittable = /^(?:input|select|textarea|keygen)/i, /* from jQuery serialize method */
1223
+ rcheckableType = /^(?:checkbox|radio)$/i,
1224
+ rnonAutoNumericTypes = /^(?:button|checkbox|color|date|datetime|datetime-local|email|file|image|month|number|password|radio|range|reset|search|submit|time|url|week)/i,
1225
+ count = 0;
1226
+ /*jslint unparam: true*/
1227
+ /* index of successful elements */
1228
+ $.each(allFormElements[0], function (i, field) {
1229
+ if (field.name !== '' && rsubmittable.test(field.localName) && !rsubmitterTypes.test(field.type) && !field.disabled && (field.checked || !rcheckableType.test(field.type))) {
1230
+ scIndex.push(count);
1231
+ count = count + 1;
1232
+ } else {
1233
+ scIndex.push(-1);
1234
+ }
1235
+ });
1236
+ /* index of all inputs tags except checkbox */
1237
+ count = 0;
1238
+ $.each(allFormElements[0], function (i, field) {
1239
+ if (field.localName === 'input' && (field.type === '' || field.type === 'text' || field.type === 'hidden' || field.type === 'tel')) {
1240
+ aiIndex.push(count);
1241
+ count = count + 1;
1242
+ } else {
1243
+ aiIndex.push(-1);
1244
+ if (field.localName === 'input' && rnonAutoNumericTypes.test(field.type)) {
1245
+ count = count + 1;
1151
1246
  }
1152
- $field = $field.eq(inputIndex[decodeURIComponent(miniParts[0])]);
1153
1247
  }
1154
- if (typeof settings === 'object') {
1155
- if (miniParts[1] !== null) {
1156
- miniParts[1] = $field.autoNumeric('get');
1157
- parts[i] = miniParts.join('=');
1158
- isAutoNumeric = true;
1248
+ });
1249
+ $.each(formParts, function (i, miniParts) {
1250
+ miniParts = formParts[i].split('=');
1251
+ var scElement = $.inArray(i, scIndex);
1252
+ if (scElement > -1 && aiIndex[scElement] > -1) {
1253
+ var testInput = $('form:eq(' + formIndex + ') input:eq(' + aiIndex[scElement] + ')'),
1254
+ settings = testInput.data('autoNumeric');
1255
+ if (typeof settings === 'object') {
1256
+ if (miniParts[1] !== null) {
1257
+ miniParts[1] = $('form:eq(' + formIndex + ') input:eq(' + aiIndex[scElement] + ')').autoNumeric('get').toString();
1258
+ formParts[i] = miniParts.join('=');
1259
+ isAutoNumeric = true;
1260
+ }
1159
1261
  }
1160
1262
  }
1263
+ });
1264
+ /*jslint unparam: false*/
1265
+ if (!isAutoNumeric) {
1266
+ $.error("You must initialize autoNumeric('init', {options}) prior to calling the 'getString' method");
1161
1267
  }
1162
- if (isAutoNumeric === true) {
1163
- return parts.join('&');
1164
- }
1165
- return str;
1268
+ return formParts.join('&');
1166
1269
  },
1167
- /** method to get the unformatted value from multiple fields */
1270
+
1271
+ /**
1272
+ * The 'getString' method used jQuerys .serializeArray() method that creates array or objects that can be encoded as a JSON string
1273
+ * it then loops through the string and un-formats the inputs with autoNumeric
1274
+ * $(someSelector).autoNumeric('getArray'); no parameter accepted
1275
+ * values returned as ISO numeric string "1234.56" where the decimal character is a period
1276
+ */
1168
1277
  getArray: function () {
1169
1278
  var isAutoNumeric = false,
1170
1279
  $this = autoGet($(this)),
1171
1280
  formFields = $this.serializeArray(),
1172
1281
  formIndex = $('form').index($this),
1173
- inputIndex = [];
1282
+ allFormElements = $('form:eq(' + formIndex + ')'),
1283
+ aiIndex = [], /* all input index */
1284
+ scIndex = [], /* successful control index */
1285
+ rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, /* from jQuery serialize method */
1286
+ rsubmittable = /^(?:input|select|textarea|keygen)/i, /* from jQuery serialize method */
1287
+ rcheckableType = /^(?:checkbox|radio)$/i,
1288
+ rnonAutoNumericTypes = /^(?:button|checkbox|color|date|datetime|datetime-local|email|file|image|month|number|password|radio|range|reset|search|submit|time|url|week)/i,
1289
+ count = 0;
1174
1290
  /*jslint unparam: true*/
1175
- $.each(formFields, function (i, field) {
1176
- var $field = $('form:eq(' + formIndex + ') input[name="' + decodeURIComponent(field.name) + '"]'),
1177
- settings = $field.data('autoNumeric');
1178
- if ($field.length > 1) {
1179
- if (inputIndex[decodeURIComponent(field.name)] === undefined) {
1180
- inputIndex[decodeURIComponent(field.name)] = 0;
1181
- } else {
1182
- inputIndex[decodeURIComponent(field.name)]++;
1291
+ /* index of successful elements */
1292
+ $.each(allFormElements[0], function (i, field) {
1293
+ if (field.name !== '' && rsubmittable.test(field.localName) && !rsubmitterTypes.test(field.type) && !field.disabled && (field.checked || !rcheckableType.test(field.type))) {
1294
+ scIndex.push(count);
1295
+ count = count + 1;
1296
+ } else {
1297
+ scIndex.push(-1);
1298
+ }
1299
+ });
1300
+ /* index of all inputs tags */
1301
+ count = 0;
1302
+ $.each(allFormElements[0], function (i, field) {
1303
+ if (field.localName === 'input' && (field.type === '' || field.type === 'text' || field.type === 'hidden' || field.type === 'tel')) {
1304
+ aiIndex.push(count);
1305
+ count = count + 1;
1306
+ } else {
1307
+ aiIndex.push(-1);
1308
+ if (field.localName === 'input' && rnonAutoNumericTypes.test(field.type)) {
1309
+ count = count + 1;
1183
1310
  }
1184
- $field = $field.eq(inputIndex[decodeURIComponent(field.name)]);
1185
1311
  }
1186
- if (typeof settings === 'object') {
1187
- if (field.value !== '') {
1188
- field.value = $field.autoNumeric('get').toString();
1312
+ });
1313
+ $.each(formFields, function (i, field) {
1314
+ var scElement = $.inArray(i, scIndex);
1315
+ if (scElement > -1 && aiIndex[scElement] > -1) {
1316
+ var testInput = $('form:eq(' + formIndex + ') input:eq(' + aiIndex[scElement] + ')'),
1317
+ settings = testInput.data('autoNumeric');
1318
+ if (typeof settings === 'object') {
1319
+ field.value = $('form:eq(' + formIndex + ') input:eq(' + aiIndex[scElement] + ')').autoNumeric('get').toString();
1320
+ isAutoNumeric = true;
1189
1321
  }
1190
- isAutoNumeric = true;
1191
1322
  }
1192
1323
  });
1193
1324
  /*jslint unparam: false*/
1194
- if (isAutoNumeric === true) {
1195
- return formFields;
1325
+ if (!isAutoNumeric) {
1326
+ $.error("None of the successful form inputs are initialized by autoNumeric.");
1196
1327
  }
1197
- return this;
1328
+ return formFields;
1198
1329
  },
1199
- /** returns the settings object for those who need to look under the hood */
1330
+
1331
+ /**
1332
+ * The 'getSteetings returns the object with autoNumeric settings for those who need to look under the hood
1333
+ * $(someSelector).autoNumeric('getSettings'); // no parameters accepted
1334
+ * $(someSelector).autoNumeric('getSettings').aDec; // return the aDec setting as a string - ant valid setting can be used
1335
+ */
1200
1336
  getSettings: function () {
1201
1337
  var $this = autoGet($(this));
1202
1338
  return $this.eq(0).data('autoNumeric');
1203
1339
  }
1204
1340
  };
1341
+
1342
+ /**
1343
+ * autoNumeric function
1344
+ */
1205
1345
  $.fn.autoNumeric = function (method) {
1206
1346
  if (methods[method]) {
1207
1347
  return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
@@ -1211,12 +1351,14 @@
1211
1351
  }
1212
1352
  $.error('Method "' + method + '" is not supported by autoNumeric()');
1213
1353
  };
1214
- /** Make defaults public */
1354
+
1355
+ /**
1356
+ * Defaults are public - these can be overridden by the following:
1357
+ * HTML5 data attributes
1358
+ * Options passed by the 'init' or 'update' methods
1359
+ * Use jQuery's $.extend method - great way to pass ASP.NET current culture settings
1360
+ */
1215
1361
  $.fn.autoNumeric.defaults = {
1216
- /** allowed numeric values
1217
- * please do not modify
1218
- */
1219
- aNum: '0123456789',
1220
1362
  /** allowed thousand separator characters
1221
1363
  * comma = ','
1222
1364
  * period "full stop" = '.'
@@ -1260,7 +1402,7 @@
1260
1402
  * value must be enclosed in quotes and use the period for the decimal point
1261
1403
  * value must be smaller than vMax
1262
1404
  */
1263
- vMin: '0.00',
1405
+ vMin: '-9999999999999.99',
1264
1406
  /** max number of decimal places = used to override decimal places set by the vMin & vMax values
1265
1407
  * value must be enclosed in quotes example mDec: '3',
1266
1408
  * This can also set the value via a call back function mDec: 'css:#
@@ -1306,8 +1448,6 @@
1306
1448
  * true = automatically formats the default value on page ready
1307
1449
  * false = will not format the default value
1308
1450
  */
1309
- aForm: true,
1310
- /** future use */
1311
- onSomeEvent: function () {}
1451
+ aForm: true
1312
1452
  };
1313
1453
  }(jQuery));