valibot 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/js/valibot.js +41 -4
  2. metadata +7 -7
data/js/valibot.js CHANGED
@@ -139,9 +139,7 @@ function Valibot(opts) {
139
139
  });
140
140
  }
141
141
 
142
- this.form = this.valitrons.concat(this.confirmomats)
143
- .concat(this.agreepeeohs)
144
- .concat(this.radiomatons)[0].tag.form;
142
+ this.form = this.minions()[0].tag.form;
145
143
  if (this.bindOnSubmit)
146
144
  $(this.form).submit(function(e){ e.preventDefault(); _this.onSubmit(); });
147
145
 
@@ -237,6 +235,20 @@ Valibot.prototype = {
237
235
  return has;
238
236
  },
239
237
 
238
+ minions:
239
+ function() {
240
+ return this.valitrons.concat(this.confirmomats)
241
+ .concat(this.agreepeeohs)
242
+ .concat(this.radiomatons);
243
+ },
244
+
245
+ die:
246
+ function() {
247
+ $(this.minions()).each(function(i,minion) {
248
+ minion.die();
249
+ });
250
+ },
251
+
240
252
  _defaultErrorTagPlacer:
241
253
  function(tag, errorTag, self, minion) {
242
254
  $(errorTag).insertAfter($(tag));
@@ -304,8 +316,9 @@ function Valitron(tag, model, field, bindEvent, valibot) {
304
316
  this.field = field;
305
317
  this.valibot = valibot;
306
318
  this.errorTag = null;
319
+ this.bindEvent = bindEvent;
307
320
  var _this = this;
308
- $(this.tag).bind(bindEvent, function(event){ _this.checkValue(event); });
321
+ $(this.tag).bind(this.bindEvent, function(event){ _this.checkValue(event); });
309
322
  $(this.tag).bind('keyup', function(event){ _this.reset(); });
310
323
  }
311
324
 
@@ -379,6 +392,12 @@ Valitron.prototype = {
379
392
  function() {
380
393
  this.valibot.removeValid(this);
381
394
  this.valid = false;
395
+ },
396
+
397
+ die:
398
+ function() {
399
+ $(this.tag).unbind(this.bindEvent);
400
+ $(this.tag).unbind('keyup');
382
401
  }
383
402
 
384
403
  };
@@ -449,6 +468,13 @@ Confirmomat.prototype = {
449
468
  // console.log('confirmomat resetting.');
450
469
  this.valibot.removeValid(this);
451
470
  this.valid = false;
471
+ },
472
+
473
+ die:
474
+ function() {
475
+ $(this.tag).unbind('blur');
476
+ $(this.tag).unbind('keyup');
477
+ $('#' + this.id).unbind('keyup');
452
478
  }
453
479
 
454
480
  };
@@ -514,7 +540,13 @@ AgreePeeOh.prototype = {
514
540
  function() {
515
541
  this.valibot.removeValid(this);
516
542
  this.valid = false;
543
+ },
544
+
545
+ die:
546
+ function() {
547
+ $(this.tag).unbind('change');
517
548
  }
549
+
518
550
  };
519
551
 
520
552
  // ---
@@ -604,6 +636,11 @@ Radiomaton.prototype = {
604
636
  function() {
605
637
  this.valibot.removeValid(this);
606
638
  this.valid = false;
639
+ },
640
+
641
+ die:
642
+ function() {
643
+ $(this.radioInputs).each(function(i,r){ $(r).unbind('change'); });
607
644
  }
608
645
 
609
646
  };
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: valibot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-08-18 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dm-core
16
- requirement: &70307150903600 !ruby/object:Gem::Requirement
16
+ requirement: &70160716649740 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70307150903600
24
+ version_requirements: *70160716649740
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: dm-validations
27
- requirement: &70307150902900 !ruby/object:Gem::Requirement
27
+ requirement: &70160716649020 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.0.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70307150902900
35
+ version_requirements: *70160716649020
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sinatra
38
- requirement: &70307150902160 !ruby/object:Gem::Requirement
38
+ requirement: &70160716648200 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 1.1.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70307150902160
46
+ version_requirements: *70160716648200
47
47
  description:
48
48
  email:
49
49
  - kenichi.nakamura@gmail.com