guardsjs-rails 1.4.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/guards.js +31 -9
- data/lib/guardsjs-rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc2348983238ae6b8ea63aed9f0a0fb57ffe6c69
|
4
|
+
data.tar.gz: 2c7fc38a40a9f2bda81572b05184ad13b2e3954d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42f99bc0262db77bc545fe39d57c065d18c510702ee2d092b6365554d44b9335c811a22902eef8f88ba4371c71248af0315ac3be9985b7693b78e687cd682cd6
|
7
|
+
data.tar.gz: 3a34db039739705c71b727bd2a40eef5bc2c120bd28279512abde936769afd6e2f571af8ec7b6ed414492831e4864de1acb676b53e573f3703846b927c357f45
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
* Guards JavaScript jQuery Plugin v1.4.
|
2
|
+
* Guards JavaScript jQuery Plugin v1.4.2
|
3
3
|
* https://github.com/on-site/guards.js
|
4
4
|
*
|
5
5
|
* Copyright 2010-2014, On-Site.com, http://www.on-site.com/
|
@@ -8,7 +8,7 @@
|
|
8
8
|
* Includes code for email and phone number validation from the jQuery
|
9
9
|
* Validation plugin. http://docs.jquery.com/Plugins/Validation
|
10
10
|
*
|
11
|
-
* Date:
|
11
|
+
* Date: Fri Nov 14 01:44:15 2014 -0800
|
12
12
|
*/
|
13
13
|
|
14
14
|
/**
|
@@ -48,7 +48,7 @@
|
|
48
48
|
return $.guards.add(selector);
|
49
49
|
};
|
50
50
|
|
51
|
-
$.guard.version = "1.4.
|
51
|
+
$.guard.version = "1.4.2";
|
52
52
|
|
53
53
|
$.Guards = function() {
|
54
54
|
var self = this;
|
@@ -745,7 +745,7 @@
|
|
745
745
|
* This version of guards.js library as a string, like <code>"1.0.0"</code>.
|
746
746
|
* </p>
|
747
747
|
*/
|
748
|
-
$.Guards.prototype.version = "1.4.
|
748
|
+
$.Guards.prototype.version = "1.4.2";
|
749
749
|
|
750
750
|
$.Guards.prototype.parentContext = function(element) {
|
751
751
|
var $element = $(element);
|
@@ -2619,7 +2619,9 @@
|
|
2619
2619
|
}
|
2620
2620
|
|
2621
2621
|
if (!result) {
|
2622
|
-
|
2622
|
+
var check = new NotUsedExternally();
|
2623
|
+
this.triggerError($elements, check);
|
2624
|
+
result = !!check.defaultPrevented;
|
2623
2625
|
}
|
2624
2626
|
|
2625
2627
|
return result;
|
@@ -2688,19 +2690,26 @@
|
|
2688
2690
|
*/
|
2689
2691
|
$.Guard.prototype.triggerError = function() {
|
2690
2692
|
var elements;
|
2693
|
+
var check = null;
|
2691
2694
|
|
2692
2695
|
if (arguments.length === 0) {
|
2693
2696
|
elements = this._selector;
|
2697
|
+
} else if (arguments.length === 1 && arguments[0].constructor === NotUsedExternally) {
|
2698
|
+
elements = this._selector;
|
2699
|
+
check = arguments[0];
|
2694
2700
|
} else if (arguments.length === 1) {
|
2695
2701
|
elements = arguments[0];
|
2702
|
+
} else if (arguments.length === 2 && arguments[1].constructor === NotUsedExternally) {
|
2703
|
+
elements = arguments[0];
|
2704
|
+
check = arguments[1];
|
2696
2705
|
} else {
|
2697
2706
|
throw new Error("Expected 0 or 1 argument to triggerError, got " + arguments.length);
|
2698
2707
|
}
|
2699
2708
|
|
2700
2709
|
if (this.isGrouped()) {
|
2701
|
-
$(elements).addSingleError(this);
|
2710
|
+
$(elements).addSingleError(this, check || new NotUsedExternally());
|
2702
2711
|
} else {
|
2703
|
-
$(elements).addError(this);
|
2712
|
+
$(elements).addError(this, check || new NotUsedExternally());
|
2704
2713
|
}
|
2705
2714
|
|
2706
2715
|
return this;
|
@@ -2787,6 +2796,14 @@
|
|
2787
2796
|
}
|
2788
2797
|
};
|
2789
2798
|
|
2799
|
+
/**
|
2800
|
+
* Simple object that can be type checked so it is guaranteed to
|
2801
|
+
* not be used externally, and can pass information back to
|
2802
|
+
* callers.
|
2803
|
+
*/
|
2804
|
+
function NotUsedExternally() {
|
2805
|
+
}
|
2806
|
+
|
2790
2807
|
/**
|
2791
2808
|
* Find any applicable fields for this selected item. Applicable
|
2792
2809
|
* fields are any inputs, textareas or selects.
|
@@ -2867,6 +2884,10 @@
|
|
2867
2884
|
var guardFormErrorPrevented = guard.sendEvent("guardFormError", this, true).isDefaultPrevented();
|
2868
2885
|
|
2869
2886
|
if (guardErrorPrevented || guardFormErrorPrevented) {
|
2887
|
+
if (arguments.length === 2 && arguments[1].constructor === NotUsedExternally) {
|
2888
|
+
arguments[1].defaultPrevented = true;
|
2889
|
+
}
|
2890
|
+
|
2870
2891
|
return this;
|
2871
2892
|
}
|
2872
2893
|
|
@@ -2897,6 +2918,7 @@
|
|
2897
2918
|
* target.
|
2898
2919
|
*/
|
2899
2920
|
$.fn.addError = function(guard) {
|
2921
|
+
var check = arguments[1] || new NotUsedExternally();
|
2900
2922
|
var radiosAdded = {};
|
2901
2923
|
|
2902
2924
|
return this.each(function() {
|
@@ -2912,9 +2934,9 @@
|
|
2912
2934
|
radiosAdded[name] = true;
|
2913
2935
|
var context = guard._guards.parentContext($this);
|
2914
2936
|
var radios = $("input[name='" + name + "']:radio", context);
|
2915
|
-
radios.addSingleError(guard);
|
2937
|
+
radios.addSingleError(guard, check);
|
2916
2938
|
} else {
|
2917
|
-
$this.addSingleError(guard);
|
2939
|
+
$this.addSingleError(guard, check);
|
2918
2940
|
}
|
2919
2941
|
});
|
2920
2942
|
};
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guardsjs-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Virata-Stone
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|