parsley-rails 2.0.0.1 → 2.0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/parsley-rails/version.rb +1 -1
- data/vendor/assets/javascripts/parsley.i18n.ar.js +33 -0
- data/vendor/assets/javascripts/parsley.i18n.fi.extra.js +6 -0
- data/vendor/assets/javascripts/parsley.i18n.fi.js +33 -0
- data/vendor/assets/javascripts/parsley.i18n.id.extra.js +6 -0
- data/vendor/assets/javascripts/parsley.i18n.nl.js +1 -0
- data/vendor/assets/javascripts/parsley.i18n.pt-br.js +1 -1
- data/vendor/assets/javascripts/parsley.i18n.ru.extra.js +6 -0
- data/vendor/assets/javascripts/parsley.i18n.th.js +33 -0
- data/vendor/assets/javascripts/parsley.i18n.tr.js +33 -0
- data/vendor/assets/javascripts/parsley.js +57 -29
- data/vendor/assets/javascripts/parsley.remote.js +63 -31
- data/vendor/assets/stylesheets/parsley.css +1 -1
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7b531f0bdbf8c9d14f63a4ba8a44f0de20eac14
|
4
|
+
data.tar.gz: ba8fb75a8d0f67e1170345ff592d43e0897d53fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ae49fb759fe058a914813359a73674ea20628502464c5d811093b7a29f3ee14f86b72567c5068a8f89224061da5db2e8848e8330fe6fea64b1a8f54877de868
|
7
|
+
data.tar.gz: d14a57ee5d615f314af7908bbe0daae4d68b7e7b120f054312c39a8f4d1e4f42b734c77806d534f9672406408552575a0d236ea917902fb2c1be4b7e5b512a92
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Parsley.js
|
1
|
+
# Parsley.js for Rails Asset Pipeline
|
2
2
|
|
3
3
|
[Parsley.js](https://github.com/guillaumepotier/Parsley.js) is an awesome form validation library ([documentation](http://parsleyjs.org/doc/index.html)).
|
4
4
|
This gem makes it easy to use it with Rails Asset Pipeline.
|
@@ -0,0 +1,33 @@
|
|
1
|
+
// ParsleyConfig definition if not already set
|
2
|
+
window.ParsleyConfig = window.ParsleyConfig || {};
|
3
|
+
window.ParsleyConfig.i18n = window.ParsleyConfig.i18n || {};
|
4
|
+
|
5
|
+
// Define then the messages
|
6
|
+
window.ParsleyConfig.i18n.ar = $.extend(window.ParsleyConfig.i18n.ar || {}, {
|
7
|
+
defaultMessage: "تأكد من صحة القيمة المدخل",
|
8
|
+
type: {
|
9
|
+
email: "تأكد من إدخال بريد الكتروني صحيح",
|
10
|
+
url: "تأكد من إدخال رابط صحيح",
|
11
|
+
number: "تأكد من إدخال رقم",
|
12
|
+
integer: "تأكد من إدخال عدد صحيح بدون كسور",
|
13
|
+
digits: "تأكد من إدخال رقم",
|
14
|
+
alphanum: "تأكد من إدخال حروف وأرقام فقط"
|
15
|
+
},
|
16
|
+
notblank: "تأكد من تعبئة الحقل",
|
17
|
+
required: "هذا الحقل مطلوب",
|
18
|
+
pattern: "القيمة المدخلة غير صحيحة",
|
19
|
+
min: "القيمة المدخلة يجب أن تكون أكبر من %s.",
|
20
|
+
max: "القيمة المدخلة يجب أن تكون أصغر من %s.",
|
21
|
+
range: "القيمة المدخلة يجب أن تكون بين %s و %s.",
|
22
|
+
minlength: "القيمة المدخلة قصيرة جداً . تأكد من إدخال %s حرف أو أكثر",
|
23
|
+
maxlength: "القيمة المدخلة طويلة . تأكد من إدخال %s حرف أو أقل",
|
24
|
+
length: "القيمة المدخلة غير صحيحة. تأكد من إدخال بين %s و %s خانة",
|
25
|
+
mincheck: "يجب اختيار %s خيار على الأقل.",
|
26
|
+
maxcheck: "يجب اختيار%s خيار أو أقل",
|
27
|
+
check: "يجب اختيار بين %s و %s خيار.",
|
28
|
+
equalto: "تأكد من تطابق القيمتين المدخلة."
|
29
|
+
});
|
30
|
+
|
31
|
+
// If file is loaded after Parsley main file, auto-load locale
|
32
|
+
if ('undefined' !== typeof window.ParsleyValidator)
|
33
|
+
window.ParsleyValidator.addCatalog('ar', window.ParsleyConfig.i18n.ar, true);
|
@@ -0,0 +1,6 @@
|
|
1
|
+
window.ParsleyConfig = window.ParsleyConfig || {};
|
2
|
+
window.ParsleyConfig.i18n = window.ParsleyConfig.i18n || {};
|
3
|
+
|
4
|
+
window.ParsleyConfig.i18n.fi = $.extend(window.ParsleyConfig.i18n.fi || {}, {
|
5
|
+
dateiso: "Syötä oikea päivämäärä (YYYY-MM-DD)."
|
6
|
+
});
|
@@ -0,0 +1,33 @@
|
|
1
|
+
// ParsleyConfig definition if not already set
|
2
|
+
window.ParsleyConfig = window.ParsleyConfig || {};
|
3
|
+
window.ParsleyConfig.i18n = window.ParsleyConfig.i18n || {};
|
4
|
+
|
5
|
+
// Define then the messages
|
6
|
+
window.ParsleyConfig.i18n.fi = $.extend(window.ParsleyConfig.i18n.fi || {}, {
|
7
|
+
defaultMessage: "Syötetty arvo on virheellinen.",
|
8
|
+
type: {
|
9
|
+
email: "Sähköpostiosoite on virheellinen.",
|
10
|
+
url: "Url-osoite on virheellinen.",
|
11
|
+
number: "Syötä numero.",
|
12
|
+
integer: "Syötä kokonaisluku.",
|
13
|
+
digits: "Syötä ainoastaan numeroita.",
|
14
|
+
alphanum: "Syötä ainoastaan kirjaimia tai numeroita."
|
15
|
+
},
|
16
|
+
notblank: "Tämä kenttää ei voi jättää tyhjäksi.",
|
17
|
+
required: "Tämä kenttä on pakollinen.",
|
18
|
+
pattern: "Syötetty arvo on virheellinen.",
|
19
|
+
min: "Syötä arvo joka on yhtä suuri tai suurempi kuin %s.",
|
20
|
+
max: "Syötä arvo joka on pienempi tai yhtä suuri kuin %s.",
|
21
|
+
range: "Syötä arvo väliltä: %s-%s.",
|
22
|
+
minlength: "Syötetyn arvon täytyy olla vähintään %s merkkiä pitkä.",
|
23
|
+
maxlength: "Syötetty arvo saa olla enintään %s merkkiä pitkä.",
|
24
|
+
length: "Syötetyn arvon täytyy olla vähintään %s ja enintään %s merkkiä pitkä.",
|
25
|
+
mincheck: "Valitse vähintään %s vaihtoehtoa.",
|
26
|
+
maxcheck: "Valitse enintään %s vaihtoehtoa.",
|
27
|
+
check: "Valitse %s-%s vaihtoehtoa.",
|
28
|
+
equalto: "Salasanat eivät täsmää."
|
29
|
+
});
|
30
|
+
|
31
|
+
// If file is loaded after Parsley main file, auto-load locale
|
32
|
+
if ('undefined' !== typeof window.ParsleyValidator)
|
33
|
+
window.ParsleyValidator.addCatalog('fi', window.ParsleyConfig.i18n.fi, true);
|
@@ -11,6 +11,7 @@ window.ParsleyConfig.i18n.nl = $.extend(window.ParsleyConfig.i18n.nl || {}, {
|
|
11
11
|
, url: "Dit lijkt geen geldige URL te zijn."
|
12
12
|
, urlstrict: "Dit is geen geldige URL."
|
13
13
|
, number: "Deze waarde moet een nummer zijn."
|
14
|
+
, integer: "Deze waarde moet een nummer zijn."
|
14
15
|
, digits: "Deze waarde moet numeriek zijn."
|
15
16
|
, dateIso: "Deze waarde moet een datum in het volgende formaat zijn: (YYYY-MM-DD)."
|
16
17
|
, alphanum: "Deze waarde moet alfanumeriek zijn."
|
@@ -4,7 +4,7 @@ window.ParsleyConfig.i18n = window.ParsleyConfig.i18n || {};
|
|
4
4
|
|
5
5
|
// Define then the messages
|
6
6
|
window.ParsleyConfig.i18n['pt-br'] = $.extend(window.ParsleyConfig.i18n['pt-br'] || {}, {
|
7
|
-
defaultMessage: "
|
7
|
+
defaultMessage: "Este valor parece ser inválido.",
|
8
8
|
type: {
|
9
9
|
email: "Esse campo deve ser um email válido.",
|
10
10
|
url: "Esse campo deve ser uma url válida.",
|
@@ -0,0 +1,6 @@
|
|
1
|
+
window.ParsleyConfig = window.ParsleyConfig || {};
|
2
|
+
window.ParsleyConfig.i18n = window.ParsleyConfig.i18n || {};
|
3
|
+
|
4
|
+
window.ParsleyConfig.i18n.ru = $.extend(window.ParsleyConfig.i18n.ru || {}, {
|
5
|
+
dateiso: "Это значение должно быть корректной датой (ГГГГ-ММ-ДД)."
|
6
|
+
});
|
@@ -0,0 +1,33 @@
|
|
1
|
+
// ParsleyConfig definition if not already set
|
2
|
+
window.ParsleyConfig = window.ParsleyConfig || {};
|
3
|
+
window.ParsleyConfig.i18n = window.ParsleyConfig.i18n || {};
|
4
|
+
|
5
|
+
// Define then the messages
|
6
|
+
window.ParsleyConfig.i18n.th = $.extend(window.ParsleyConfig.i18n.th || {}, {
|
7
|
+
defaultMessage: "ค่านี้ดูเหมือนว่าจะไม่ถูกต้อง",
|
8
|
+
type: {
|
9
|
+
email: "ค่านี้ควรจะเป็นอีเมลที่ถูกต้อง",
|
10
|
+
url: "ค่านี้ควรจะเป็น url ที่ถูกต้อง",
|
11
|
+
number: "ค่านี้ควรจะเป็นตัวเลขที่ถูกต้อง",
|
12
|
+
integer: "ค่านี้ควรจะเป็นจำนวนเต็มที่ถูกต้อง",
|
13
|
+
digits: "ค่านี้ควรเป็นทศนิยมที่ถูกต้อง",
|
14
|
+
alphanum: "ค่านี้ควรเป็นอักขระตัวอักษรหรือตัวเลขที่ถูกต้อง"
|
15
|
+
},
|
16
|
+
notblank: "ค่านี้ไม่ควรจะว่าง",
|
17
|
+
required: "ค่านี้จำเป็น",
|
18
|
+
pattern: "ค่านี้ดูเหมือนว่าจะไม่ถูกต้อง",
|
19
|
+
min: "ค่านี้ควรมากกว่าหรือเท่ากับ %s.",
|
20
|
+
max: "ค่านี้ควรจะน้อยกว่าหรือเท่ากับ %s.",
|
21
|
+
range: "ค่ายี้ควรจะอยู่ระหว่าง %s และ %s.",
|
22
|
+
minlength: "ค่านี้สั้นเกินไป ควรจะมี %s อักขระหรือมากกว่า",
|
23
|
+
maxlength: "ค่านี้ยาวเกินไป ควรจะมี %s อักขระหรือน้อยกว่า",
|
24
|
+
length: "ความยาวของค่านี้ไม่ถูกต้อง ควรมีความยาวอยู่ระหว่าง %s และ %s อักขระ",
|
25
|
+
mincheck: "คุณควรเลือกอย่างน้อย %s ตัวเลือก",
|
26
|
+
maxcheck: "คุณควรเลือก %s ตัวเลือกหรือน้อยกว่า",
|
27
|
+
check: "คุณควรเลือกระหว่าง %s และ %s ตัวเลือก",
|
28
|
+
equalto: "ค่านี้ควรจะเหมือนกัน"
|
29
|
+
});
|
30
|
+
|
31
|
+
// If file is loaded after Parsley main file, auto-load locale
|
32
|
+
if ('undefined' !== typeof window.ParsleyValidator)
|
33
|
+
window.ParsleyValidator.addCatalog('th', window.ParsleyConfig.i18n.th, true);
|
@@ -0,0 +1,33 @@
|
|
1
|
+
// ParsleyConfig definition if not already set
|
2
|
+
window.ParsleyConfig = window.ParsleyConfig || {};
|
3
|
+
window.ParsleyConfig.i18n = window.ParsleyConfig.i18n || {};
|
4
|
+
|
5
|
+
// Define then the messages
|
6
|
+
window.ParsleyConfig.i18n.tr = $.extend(window.ParsleyConfig.i18n.tr || {}, {
|
7
|
+
defaultMessage: "Bu değer geçerli değil.",
|
8
|
+
type: {
|
9
|
+
email: "Geçerli bir e-posta adresi yazınız.",
|
10
|
+
url: "Geçerli bir bağlantı adresi yazınız.",
|
11
|
+
number: "Geçerli bir sayı yazınız.",
|
12
|
+
integer: "Geçerli bir tamsayı yazınız.",
|
13
|
+
digits: "Geçerli bir rakam yazınız.",
|
14
|
+
alphanum: "Geçerli bir alfanümerik değer yazınız."
|
15
|
+
},
|
16
|
+
notblank: "Bu alan boş bırakılmamalıdır.",
|
17
|
+
required: "Bu alan gereklidir.",
|
18
|
+
pattern: "Girdiğiniz değer geçerli değil.",
|
19
|
+
min: "Bu alan %s değerinden büyük ya da eşit olmalıdır.",
|
20
|
+
max: "Bu alan %s değerinden küçük ya da eşit olmalıdır.",
|
21
|
+
range: "Bu alan %s ve %s değerleri arasında olmalıdır.",
|
22
|
+
minlength: "Girdiğiniz değer çok kısa. Bu alan %s değerine eşit ya da fazla olmalıdır.",
|
23
|
+
maxlength: "Girdiğiniz değer çok uzun. Bu alan %s değerine eşit ya da az olmalıdır.",
|
24
|
+
length: "Girdiğiniz değerin uzunluğu geçersiz. Bu alanın uzunluğu %s ve %s arasında olmalıdır.",
|
25
|
+
mincheck: "En az %s adet seçim yapmalısınız.",
|
26
|
+
maxcheck: "En fazla %s ya da daha az seçim yapmalısınız.",
|
27
|
+
check: "Bu alan için en az %s en fazla %s seçim yapmalısınız.",
|
28
|
+
equalto: "Bu alanın değeri aynı olmalıdır."
|
29
|
+
});
|
30
|
+
|
31
|
+
// If file is loaded after Parsley main file, auto-load locale
|
32
|
+
if ('undefined' !== typeof window.ParsleyValidator)
|
33
|
+
window.ParsleyValidator.addCatalog('tr', window.ParsleyConfig.i18n.tr, true);
|
@@ -1,11 +1,19 @@
|
|
1
1
|
/*!
|
2
2
|
* Parsleyjs
|
3
3
|
* Guillaume Potier - <guillaume@wisembly.com>
|
4
|
-
* Version 2.0.
|
4
|
+
* Version 2.0.2 - built Tue Jun 17 2014 15:25:35
|
5
5
|
* MIT Licensed
|
6
6
|
*
|
7
7
|
*/
|
8
|
-
!(function(
|
8
|
+
!(function (factory) {
|
9
|
+
if (typeof define === 'function' && define.amd) {
|
10
|
+
// AMD. Register as an anonymous module depending on jQuery.
|
11
|
+
define(['jquery'], factory);
|
12
|
+
} else {
|
13
|
+
// No AMD. Register plugin with global jQuery object.
|
14
|
+
factory(jQuery);
|
15
|
+
}
|
16
|
+
}(function () {
|
9
17
|
var ParsleyUtils = {
|
10
18
|
// Parsley DOM-API
|
11
19
|
// returns object from dom attributes and values
|
@@ -14,12 +22,13 @@
|
|
14
22
|
var
|
15
23
|
attribute,
|
16
24
|
obj = {},
|
25
|
+
msie = this.msieversion(),
|
17
26
|
regex = new RegExp('^' + namespace, 'i');
|
18
27
|
if ('undefined' === typeof $element || 'undefined' === typeof $element[0])
|
19
28
|
return {};
|
20
29
|
for (var i in $element[0].attributes) {
|
21
30
|
attribute = $element[0].attributes[i];
|
22
|
-
if ('undefined' !== typeof attribute && null !== attribute && attribute.specified && regex.test(attribute.name)) {
|
31
|
+
if ('undefined' !== typeof attribute && null !== attribute && (!msie || msie >= 8 || attribute.specified) && regex.test(attribute.name)) {
|
23
32
|
if ('undefined' !== typeof checkAttr && new RegExp(checkAttr + '$', 'i').test(attribute.name))
|
24
33
|
return true;
|
25
34
|
obj[this.camelize(attribute.name.replace(namespace, ''))] = this.deserializeValue(attribute.value);
|
@@ -81,7 +90,17 @@
|
|
81
90
|
.replace(/([a-z\d])([A-Z])/g, '$1_$2')
|
82
91
|
.replace(/_/g, '-')
|
83
92
|
.toLowerCase();
|
84
|
-
}
|
93
|
+
},
|
94
|
+
// http://support.microsoft.com/kb/167820
|
95
|
+
// http://stackoverflow.com/questions/19999388/jquery-check-if-user-is-using-ie
|
96
|
+
msieversion: function () {
|
97
|
+
var
|
98
|
+
ua = window.navigator.userAgent,
|
99
|
+
msie = ua.indexOf('MSIE ');
|
100
|
+
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))
|
101
|
+
return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
|
102
|
+
return 0;
|
103
|
+
}
|
85
104
|
};
|
86
105
|
// All these options could be overriden and specified directly in DOM using
|
87
106
|
// `data-parsley-` default DOM-API
|
@@ -929,7 +948,7 @@
|
|
929
948
|
init: function (validators, catalog) {
|
930
949
|
this.catalog = catalog;
|
931
950
|
for (var name in validators)
|
932
|
-
this.addValidator(name, validators[name].fn, validators[name].priority);
|
951
|
+
this.addValidator(name, validators[name].fn, validators[name].priority, validators[name].requirementsTransformer);
|
933
952
|
$.emit('parsley:validator:init');
|
934
953
|
},
|
935
954
|
// Set new messages locale if we have dictionary loaded in ParsleyConfig.i18n
|
@@ -958,14 +977,17 @@
|
|
958
977
|
return new this.Validator.Validator().validate.apply(new Validator.Validator(), arguments);
|
959
978
|
},
|
960
979
|
// Add a new validator
|
961
|
-
addValidator: function (name, fn, priority) {
|
980
|
+
addValidator: function (name, fn, priority, requirementsTransformer) {
|
962
981
|
this.validators[name.toLowerCase()] = function (requirements) {
|
963
|
-
return $.extend(new Validator.Assert().Callback(fn, requirements), {
|
982
|
+
return $.extend(new Validator.Assert().Callback(fn, requirements), {
|
983
|
+
priority: priority,
|
984
|
+
requirementsTransformer: requirementsTransformer
|
985
|
+
});
|
964
986
|
};
|
965
987
|
return this;
|
966
988
|
},
|
967
|
-
updateValidator: function (name, fn, priority) {
|
968
|
-
return addValidator(name, fn, priority);
|
989
|
+
updateValidator: function (name, fn, priority, requirementsTransformer) {
|
990
|
+
return this.addValidator(name, fn, priority, requirementsTransformer);
|
969
991
|
},
|
970
992
|
removeValidator: function (name) {
|
971
993
|
delete this.validators[name];
|
@@ -1005,6 +1027,8 @@
|
|
1005
1027
|
case 'email':
|
1006
1028
|
assert = new Validator.Assert().Email();
|
1007
1029
|
break;
|
1030
|
+
// range type just ensure we have a number here
|
1031
|
+
case 'range':
|
1008
1032
|
case 'number':
|
1009
1033
|
assert = new Validator.Assert().Regexp('^-?(?:\\d+|\\d{1,3}(?:,\\d{3})+)?(?:\\.\\d+)?$');
|
1010
1034
|
break;
|
@@ -1308,13 +1332,13 @@
|
|
1308
1332
|
},
|
1309
1333
|
_insertErrorWrapper: function (fieldInstance) {
|
1310
1334
|
var $errorsContainer;
|
1311
|
-
if ('string' === typeof fieldInstance.options.errorsContainer
|
1312
|
-
if ($(fieldInstance.options.errorsContainer
|
1335
|
+
if ('string' === typeof fieldInstance.options.errorsContainer) {
|
1336
|
+
if ($(fieldInstance.options.errorsContainer).length)
|
1313
1337
|
return $(fieldInstance.options.errorsContainer).append(fieldInstance._ui.$errorsWrapper);
|
1314
1338
|
else if (window.console && window.console.warn)
|
1315
1339
|
window.console.warn('The errors container `' + fieldInstance.options.errorsContainer + '` does not exist in DOM');
|
1316
|
-
|
1317
|
-
if ('function' === typeof fieldInstance.options.errorsContainer)
|
1340
|
+
}
|
1341
|
+
else if ('function' === typeof fieldInstance.options.errorsContainer)
|
1318
1342
|
$errorsContainer = fieldInstance.options.errorsContainer(fieldInstance);
|
1319
1343
|
if ('undefined' !== typeof $errorsContainer && $errorsContainer.length)
|
1320
1344
|
return $errorsContainer.append(fieldInstance._ui.$errorsWrapper);
|
@@ -1401,7 +1425,8 @@
|
|
1401
1425
|
this.reset(parsleyInstance);
|
1402
1426
|
if ('ParsleyForm' === parsleyInstance.__class__)
|
1403
1427
|
return;
|
1404
|
-
parsleyInstance._ui
|
1428
|
+
if ('undefined' !== typeof parsleyInstance._ui)
|
1429
|
+
parsleyInstance._ui.$errorsWrapper.remove();
|
1405
1430
|
delete parsleyInstance._ui;
|
1406
1431
|
},
|
1407
1432
|
_successClass: function (fieldInstance) {
|
@@ -1752,6 +1777,11 @@
|
|
1752
1777
|
}
|
1753
1778
|
// Gather all constraints for each input in the multiple group
|
1754
1779
|
for (var i = 0; i < this.$elements.length; i++) {
|
1780
|
+
// Check if element have not been dynamically removed since last binding
|
1781
|
+
if (!$('html').has(this.$elements[i]).length) {
|
1782
|
+
this.$elements.splice(i, 1);
|
1783
|
+
continue;
|
1784
|
+
}
|
1755
1785
|
fieldConstraints = this.$elements[i].data('ParsleyFieldMultiple').refreshConstraints().constraints;
|
1756
1786
|
for (var j = 0; j < fieldConstraints.length; j++)
|
1757
1787
|
this.addConstraint(fieldConstraints[j].name, fieldConstraints[j].requirements, fieldConstraints[j].priority, fieldConstraints[j].isDomConstraint);
|
@@ -1896,7 +1926,7 @@ window.ParsleyConfig.i18n.en = $.extend(window.ParsleyConfig.i18n.en || {}, {
|
|
1896
1926
|
if ('undefined' !== typeof window.ParsleyValidator)
|
1897
1927
|
window.ParsleyValidator.addCatalog('en', window.ParsleyConfig.i18n.en, true);
|
1898
1928
|
|
1899
|
-
// Parsley.js 2.0.
|
1929
|
+
// Parsley.js 2.0.2
|
1900
1930
|
// http://parsleyjs.org
|
1901
1931
|
// (c) 20012-2014 Guillaume Potier, Wisembly
|
1902
1932
|
// Parsley may be freely distributed under the MIT license.
|
@@ -1904,7 +1934,7 @@ if ('undefined' !== typeof window.ParsleyValidator)
|
|
1904
1934
|
// ### Parsley factory
|
1905
1935
|
var Parsley = function (element, options, parsleyFormInstance) {
|
1906
1936
|
this.__class__ = 'Parsley';
|
1907
|
-
this.__version__ = '2.0.
|
1937
|
+
this.__version__ = '2.0.2';
|
1908
1938
|
this.__id__ = ParsleyUtils.hash(4);
|
1909
1939
|
// Parsley must be instanciated with a DOM element or jQuery $element
|
1910
1940
|
if ('undefined' === typeof element)
|
@@ -1951,13 +1981,12 @@ if ('undefined' !== typeof window.ParsleyValidator)
|
|
1951
1981
|
// Get parsleyFormInstance options if exist, mixed with element attributes
|
1952
1982
|
this.options = $.extend(this.options, parsleyFormInstance ? parsleyFormInstance.OptionsFactory.get(parsleyFormInstance) : {}, ParsleyUtils.attr(this.$element, this.options.namespace));
|
1953
1983
|
// Handle multiple name
|
1954
|
-
if (this.options.multiple)
|
1984
|
+
if (this.options.multiple)
|
1955
1985
|
multiple = this.options.multiple;
|
1956
|
-
|
1986
|
+
else if ('undefined' !== typeof this.$element.attr('name') && this.$element.attr('name').length)
|
1957
1987
|
multiple = name = this.$element.attr('name');
|
1958
|
-
|
1988
|
+
else if ('undefined' !== typeof this.$element.attr('id') && this.$element.attr('id').length)
|
1959
1989
|
multiple = this.$element.attr('id');
|
1960
|
-
}
|
1961
1990
|
// Special select multiple input
|
1962
1991
|
if (this.$element.is('select') && 'undefined' !== typeof this.$element.attr('multiple')) {
|
1963
1992
|
return this.bind('parsleyFieldMultiple', parsleyFormInstance, multiple || this.__id__);
|
@@ -1969,15 +1998,16 @@ if ('undefined' !== typeof window.ParsleyValidator)
|
|
1969
1998
|
}
|
1970
1999
|
// Remove special chars
|
1971
2000
|
multiple = multiple.replace(/(:|\.|\[|\]|\$)/g, '');
|
1972
|
-
// Add proper `data-parsley-multiple` to siblings if we
|
1973
|
-
if ('undefined' !== typeof name)
|
2001
|
+
// Add proper `data-parsley-multiple` to siblings if we have a valid multiple name
|
2002
|
+
if ('undefined' !== typeof name) {
|
1974
2003
|
$('input[name="' + name + '"]').each(function () {
|
1975
2004
|
if ($(this).is('input[type=radio], input[type=checkbox]'))
|
1976
2005
|
$(this).attr(that.options.namespace + 'multiple', multiple);
|
1977
2006
|
});
|
2007
|
+
}
|
1978
2008
|
// Check here if we don't already have a related multiple instance saved
|
1979
|
-
if ($('[' + this.options.namespace + 'multiple=' + multiple +']').length)
|
1980
|
-
for (var i = 0; i < $('[' + this.options.namespace + 'multiple=' + multiple +']').length; i++)
|
2009
|
+
if ($('[' + this.options.namespace + 'multiple=' + multiple +']').length) {
|
2010
|
+
for (var i = 0; i < $('[' + this.options.namespace + 'multiple=' + multiple +']').length; i++) {
|
1981
2011
|
if ('undefined' !== typeof $($('[' + this.options.namespace + 'multiple=' + multiple +']').get(i)).data('Parsley')) {
|
1982
2012
|
parsleyMultipleInstance = $($('[' + this.options.namespace + 'multiple=' + multiple +']').get(i)).data('Parsley');
|
1983
2013
|
if (!this.$element.data('ParsleyFieldMultiple')) {
|
@@ -1986,6 +2016,8 @@ if ('undefined' !== typeof window.ParsleyValidator)
|
|
1986
2016
|
}
|
1987
2017
|
break;
|
1988
2018
|
}
|
2019
|
+
}
|
2020
|
+
}
|
1989
2021
|
// Create a secret ParsleyField instance for every multiple field. It would be stored in `data('ParsleyFieldMultiple')`
|
1990
2022
|
// And would be useful later to access classic `ParsleyField` stuff while being in a `ParsleyFieldMultiple` instance
|
1991
2023
|
this.bind('parsleyField', parsleyFormInstance, multiple, true);
|
@@ -2090,8 +2122,4 @@ if ('undefined' !== typeof window.ParsleyValidator)
|
|
2090
2122
|
if ($('[data-parsley-validate]').length)
|
2091
2123
|
$('[data-parsley-validate]').parsley();
|
2092
2124
|
});
|
2093
|
-
|
2094
|
-
// AMD Compliance
|
2095
|
-
if ('function' === typeof define && define.amd)
|
2096
|
-
define('parsley', function() { return window.Parsley; } );
|
2097
|
-
})(window.jQuery);
|
2125
|
+
}));
|
@@ -24,10 +24,11 @@ window.ParsleyExtend = $.extend(window.ParsleyExtend, {
|
|
24
24
|
}
|
25
25
|
}, window.ParsleyExtend.asyncValidators),
|
26
26
|
|
27
|
-
addAsyncValidator: function (name, fn, url) {
|
27
|
+
addAsyncValidator: function (name, fn, url, options) {
|
28
28
|
this.asyncValidators[name.toLowerCase()] = {
|
29
29
|
fn: fn,
|
30
|
-
url: url || false
|
30
|
+
url: url || false,
|
31
|
+
options: options || {}
|
31
32
|
};
|
32
33
|
|
33
34
|
return this;
|
@@ -179,6 +180,9 @@ window.ParsleyExtend = $.extend(window.ParsleyExtend, {
|
|
179
180
|
// Fill data with current value
|
180
181
|
data[this.$element.attr('name') || this.$element.attr('id')] = this.getValue();
|
181
182
|
|
183
|
+
// Merge options passed in from the function with the ones in the attribute
|
184
|
+
this.options.remoteOptions = $.extend(true, this.options.remoteOptions || {} , this.asyncValidators[validator].options);
|
185
|
+
|
182
186
|
// All `$.ajax(options)` could be overridden or extended directly from DOM in `data-parsley-remote-options`
|
183
187
|
ajaxOptions = $.extend(true, {}, {
|
184
188
|
url: this.asyncValidators[validator].url || this.options.remote,
|
@@ -255,11 +259,19 @@ window.ParsleyConfig.validators.remote = {
|
|
255
259
|
/*!
|
256
260
|
* Parsleyjs
|
257
261
|
* Guillaume Potier - <guillaume@wisembly.com>
|
258
|
-
* Version 2.0.
|
262
|
+
* Version 2.0.2 - built Tue Jun 17 2014 15:25:35
|
259
263
|
* MIT Licensed
|
260
264
|
*
|
261
265
|
*/
|
262
|
-
!(function(
|
266
|
+
!(function (factory) {
|
267
|
+
if (typeof define === 'function' && define.amd) {
|
268
|
+
// AMD. Register as an anonymous module depending on jQuery.
|
269
|
+
define(['jquery'], factory);
|
270
|
+
} else {
|
271
|
+
// No AMD. Register plugin with global jQuery object.
|
272
|
+
factory(jQuery);
|
273
|
+
}
|
274
|
+
}(function () {
|
263
275
|
var ParsleyUtils = {
|
264
276
|
// Parsley DOM-API
|
265
277
|
// returns object from dom attributes and values
|
@@ -268,12 +280,13 @@ window.ParsleyConfig.validators.remote = {
|
|
268
280
|
var
|
269
281
|
attribute,
|
270
282
|
obj = {},
|
283
|
+
msie = this.msieversion(),
|
271
284
|
regex = new RegExp('^' + namespace, 'i');
|
272
285
|
if ('undefined' === typeof $element || 'undefined' === typeof $element[0])
|
273
286
|
return {};
|
274
287
|
for (var i in $element[0].attributes) {
|
275
288
|
attribute = $element[0].attributes[i];
|
276
|
-
if ('undefined' !== typeof attribute && null !== attribute && attribute.specified && regex.test(attribute.name)) {
|
289
|
+
if ('undefined' !== typeof attribute && null !== attribute && (!msie || msie >= 8 || attribute.specified) && regex.test(attribute.name)) {
|
277
290
|
if ('undefined' !== typeof checkAttr && new RegExp(checkAttr + '$', 'i').test(attribute.name))
|
278
291
|
return true;
|
279
292
|
obj[this.camelize(attribute.name.replace(namespace, ''))] = this.deserializeValue(attribute.value);
|
@@ -335,7 +348,17 @@ window.ParsleyConfig.validators.remote = {
|
|
335
348
|
.replace(/([a-z\d])([A-Z])/g, '$1_$2')
|
336
349
|
.replace(/_/g, '-')
|
337
350
|
.toLowerCase();
|
338
|
-
}
|
351
|
+
},
|
352
|
+
// http://support.microsoft.com/kb/167820
|
353
|
+
// http://stackoverflow.com/questions/19999388/jquery-check-if-user-is-using-ie
|
354
|
+
msieversion: function () {
|
355
|
+
var
|
356
|
+
ua = window.navigator.userAgent,
|
357
|
+
msie = ua.indexOf('MSIE ');
|
358
|
+
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))
|
359
|
+
return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
|
360
|
+
return 0;
|
361
|
+
}
|
339
362
|
};
|
340
363
|
// All these options could be overriden and specified directly in DOM using
|
341
364
|
// `data-parsley-` default DOM-API
|
@@ -1183,7 +1206,7 @@ window.ParsleyConfig.validators.remote = {
|
|
1183
1206
|
init: function (validators, catalog) {
|
1184
1207
|
this.catalog = catalog;
|
1185
1208
|
for (var name in validators)
|
1186
|
-
this.addValidator(name, validators[name].fn, validators[name].priority);
|
1209
|
+
this.addValidator(name, validators[name].fn, validators[name].priority, validators[name].requirementsTransformer);
|
1187
1210
|
$.emit('parsley:validator:init');
|
1188
1211
|
},
|
1189
1212
|
// Set new messages locale if we have dictionary loaded in ParsleyConfig.i18n
|
@@ -1212,14 +1235,17 @@ window.ParsleyConfig.validators.remote = {
|
|
1212
1235
|
return new this.Validator.Validator().validate.apply(new Validator.Validator(), arguments);
|
1213
1236
|
},
|
1214
1237
|
// Add a new validator
|
1215
|
-
addValidator: function (name, fn, priority) {
|
1238
|
+
addValidator: function (name, fn, priority, requirementsTransformer) {
|
1216
1239
|
this.validators[name.toLowerCase()] = function (requirements) {
|
1217
|
-
return $.extend(new Validator.Assert().Callback(fn, requirements), {
|
1240
|
+
return $.extend(new Validator.Assert().Callback(fn, requirements), {
|
1241
|
+
priority: priority,
|
1242
|
+
requirementsTransformer: requirementsTransformer
|
1243
|
+
});
|
1218
1244
|
};
|
1219
1245
|
return this;
|
1220
1246
|
},
|
1221
|
-
updateValidator: function (name, fn, priority) {
|
1222
|
-
return addValidator(name, fn, priority);
|
1247
|
+
updateValidator: function (name, fn, priority, requirementsTransformer) {
|
1248
|
+
return this.addValidator(name, fn, priority, requirementsTransformer);
|
1223
1249
|
},
|
1224
1250
|
removeValidator: function (name) {
|
1225
1251
|
delete this.validators[name];
|
@@ -1259,6 +1285,8 @@ window.ParsleyConfig.validators.remote = {
|
|
1259
1285
|
case 'email':
|
1260
1286
|
assert = new Validator.Assert().Email();
|
1261
1287
|
break;
|
1288
|
+
// range type just ensure we have a number here
|
1289
|
+
case 'range':
|
1262
1290
|
case 'number':
|
1263
1291
|
assert = new Validator.Assert().Regexp('^-?(?:\\d+|\\d{1,3}(?:,\\d{3})+)?(?:\\.\\d+)?$');
|
1264
1292
|
break;
|
@@ -1562,13 +1590,13 @@ window.ParsleyConfig.validators.remote = {
|
|
1562
1590
|
},
|
1563
1591
|
_insertErrorWrapper: function (fieldInstance) {
|
1564
1592
|
var $errorsContainer;
|
1565
|
-
if ('string' === typeof fieldInstance.options.errorsContainer
|
1566
|
-
if ($(fieldInstance.options.errorsContainer
|
1593
|
+
if ('string' === typeof fieldInstance.options.errorsContainer) {
|
1594
|
+
if ($(fieldInstance.options.errorsContainer).length)
|
1567
1595
|
return $(fieldInstance.options.errorsContainer).append(fieldInstance._ui.$errorsWrapper);
|
1568
1596
|
else if (window.console && window.console.warn)
|
1569
1597
|
window.console.warn('The errors container `' + fieldInstance.options.errorsContainer + '` does not exist in DOM');
|
1570
|
-
|
1571
|
-
if ('function' === typeof fieldInstance.options.errorsContainer)
|
1598
|
+
}
|
1599
|
+
else if ('function' === typeof fieldInstance.options.errorsContainer)
|
1572
1600
|
$errorsContainer = fieldInstance.options.errorsContainer(fieldInstance);
|
1573
1601
|
if ('undefined' !== typeof $errorsContainer && $errorsContainer.length)
|
1574
1602
|
return $errorsContainer.append(fieldInstance._ui.$errorsWrapper);
|
@@ -1655,7 +1683,8 @@ window.ParsleyConfig.validators.remote = {
|
|
1655
1683
|
this.reset(parsleyInstance);
|
1656
1684
|
if ('ParsleyForm' === parsleyInstance.__class__)
|
1657
1685
|
return;
|
1658
|
-
parsleyInstance._ui
|
1686
|
+
if ('undefined' !== typeof parsleyInstance._ui)
|
1687
|
+
parsleyInstance._ui.$errorsWrapper.remove();
|
1659
1688
|
delete parsleyInstance._ui;
|
1660
1689
|
},
|
1661
1690
|
_successClass: function (fieldInstance) {
|
@@ -2006,6 +2035,11 @@ window.ParsleyConfig.validators.remote = {
|
|
2006
2035
|
}
|
2007
2036
|
// Gather all constraints for each input in the multiple group
|
2008
2037
|
for (var i = 0; i < this.$elements.length; i++) {
|
2038
|
+
// Check if element have not been dynamically removed since last binding
|
2039
|
+
if (!$('html').has(this.$elements[i]).length) {
|
2040
|
+
this.$elements.splice(i, 1);
|
2041
|
+
continue;
|
2042
|
+
}
|
2009
2043
|
fieldConstraints = this.$elements[i].data('ParsleyFieldMultiple').refreshConstraints().constraints;
|
2010
2044
|
for (var j = 0; j < fieldConstraints.length; j++)
|
2011
2045
|
this.addConstraint(fieldConstraints[j].name, fieldConstraints[j].requirements, fieldConstraints[j].priority, fieldConstraints[j].isDomConstraint);
|
@@ -2150,7 +2184,7 @@ window.ParsleyConfig.i18n.en = $.extend(window.ParsleyConfig.i18n.en || {}, {
|
|
2150
2184
|
if ('undefined' !== typeof window.ParsleyValidator)
|
2151
2185
|
window.ParsleyValidator.addCatalog('en', window.ParsleyConfig.i18n.en, true);
|
2152
2186
|
|
2153
|
-
// Parsley.js 2.0.
|
2187
|
+
// Parsley.js 2.0.2
|
2154
2188
|
// http://parsleyjs.org
|
2155
2189
|
// (c) 20012-2014 Guillaume Potier, Wisembly
|
2156
2190
|
// Parsley may be freely distributed under the MIT license.
|
@@ -2158,7 +2192,7 @@ if ('undefined' !== typeof window.ParsleyValidator)
|
|
2158
2192
|
// ### Parsley factory
|
2159
2193
|
var Parsley = function (element, options, parsleyFormInstance) {
|
2160
2194
|
this.__class__ = 'Parsley';
|
2161
|
-
this.__version__ = '2.0.
|
2195
|
+
this.__version__ = '2.0.2';
|
2162
2196
|
this.__id__ = ParsleyUtils.hash(4);
|
2163
2197
|
// Parsley must be instanciated with a DOM element or jQuery $element
|
2164
2198
|
if ('undefined' === typeof element)
|
@@ -2205,13 +2239,12 @@ if ('undefined' !== typeof window.ParsleyValidator)
|
|
2205
2239
|
// Get parsleyFormInstance options if exist, mixed with element attributes
|
2206
2240
|
this.options = $.extend(this.options, parsleyFormInstance ? parsleyFormInstance.OptionsFactory.get(parsleyFormInstance) : {}, ParsleyUtils.attr(this.$element, this.options.namespace));
|
2207
2241
|
// Handle multiple name
|
2208
|
-
if (this.options.multiple)
|
2242
|
+
if (this.options.multiple)
|
2209
2243
|
multiple = this.options.multiple;
|
2210
|
-
|
2244
|
+
else if ('undefined' !== typeof this.$element.attr('name') && this.$element.attr('name').length)
|
2211
2245
|
multiple = name = this.$element.attr('name');
|
2212
|
-
|
2246
|
+
else if ('undefined' !== typeof this.$element.attr('id') && this.$element.attr('id').length)
|
2213
2247
|
multiple = this.$element.attr('id');
|
2214
|
-
}
|
2215
2248
|
// Special select multiple input
|
2216
2249
|
if (this.$element.is('select') && 'undefined' !== typeof this.$element.attr('multiple')) {
|
2217
2250
|
return this.bind('parsleyFieldMultiple', parsleyFormInstance, multiple || this.__id__);
|
@@ -2223,15 +2256,16 @@ if ('undefined' !== typeof window.ParsleyValidator)
|
|
2223
2256
|
}
|
2224
2257
|
// Remove special chars
|
2225
2258
|
multiple = multiple.replace(/(:|\.|\[|\]|\$)/g, '');
|
2226
|
-
// Add proper `data-parsley-multiple` to siblings if we
|
2227
|
-
if ('undefined' !== typeof name)
|
2259
|
+
// Add proper `data-parsley-multiple` to siblings if we have a valid multiple name
|
2260
|
+
if ('undefined' !== typeof name) {
|
2228
2261
|
$('input[name="' + name + '"]').each(function () {
|
2229
2262
|
if ($(this).is('input[type=radio], input[type=checkbox]'))
|
2230
2263
|
$(this).attr(that.options.namespace + 'multiple', multiple);
|
2231
2264
|
});
|
2265
|
+
}
|
2232
2266
|
// Check here if we don't already have a related multiple instance saved
|
2233
|
-
if ($('[' + this.options.namespace + 'multiple=' + multiple +']').length)
|
2234
|
-
for (var i = 0; i < $('[' + this.options.namespace + 'multiple=' + multiple +']').length; i++)
|
2267
|
+
if ($('[' + this.options.namespace + 'multiple=' + multiple +']').length) {
|
2268
|
+
for (var i = 0; i < $('[' + this.options.namespace + 'multiple=' + multiple +']').length; i++) {
|
2235
2269
|
if ('undefined' !== typeof $($('[' + this.options.namespace + 'multiple=' + multiple +']').get(i)).data('Parsley')) {
|
2236
2270
|
parsleyMultipleInstance = $($('[' + this.options.namespace + 'multiple=' + multiple +']').get(i)).data('Parsley');
|
2237
2271
|
if (!this.$element.data('ParsleyFieldMultiple')) {
|
@@ -2240,6 +2274,8 @@ if ('undefined' !== typeof window.ParsleyValidator)
|
|
2240
2274
|
}
|
2241
2275
|
break;
|
2242
2276
|
}
|
2277
|
+
}
|
2278
|
+
}
|
2243
2279
|
// Create a secret ParsleyField instance for every multiple field. It would be stored in `data('ParsleyFieldMultiple')`
|
2244
2280
|
// And would be useful later to access classic `ParsleyField` stuff while being in a `ParsleyFieldMultiple` instance
|
2245
2281
|
this.bind('parsleyField', parsleyFormInstance, multiple, true);
|
@@ -2344,8 +2380,4 @@ if ('undefined' !== typeof window.ParsleyValidator)
|
|
2344
2380
|
if ($('[data-parsley-validate]').length)
|
2345
2381
|
$('[data-parsley-validate]').parsley();
|
2346
2382
|
});
|
2347
|
-
|
2348
|
-
// AMD Compliance
|
2349
|
-
if ('function' === typeof define && define.amd)
|
2350
|
-
define('parsley', function() { return window.Parsley; } );
|
2351
|
-
})(window.jQuery);
|
2383
|
+
}));
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parsley-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0
|
4
|
+
version: 2.0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jiri Pospisil
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -40,16 +40,20 @@ files:
|
|
40
40
|
- lib/parsley-rails/version.rb
|
41
41
|
- parsley-rails.gemspec
|
42
42
|
- update.sh
|
43
|
+
- vendor/assets/javascripts/parsley.i18n.ar.js
|
43
44
|
- vendor/assets/javascripts/parsley.i18n.bg.js
|
44
45
|
- vendor/assets/javascripts/parsley.i18n.da.js
|
45
46
|
- vendor/assets/javascripts/parsley.i18n.de.js
|
46
47
|
- vendor/assets/javascripts/parsley.i18n.en.extra.js
|
47
48
|
- vendor/assets/javascripts/parsley.i18n.en.js
|
48
49
|
- vendor/assets/javascripts/parsley.i18n.es.js
|
50
|
+
- vendor/assets/javascripts/parsley.i18n.fi.extra.js
|
51
|
+
- vendor/assets/javascripts/parsley.i18n.fi.js
|
49
52
|
- vendor/assets/javascripts/parsley.i18n.fr.extra.js
|
50
53
|
- vendor/assets/javascripts/parsley.i18n.fr.js
|
51
54
|
- vendor/assets/javascripts/parsley.i18n.he.extra.js
|
52
55
|
- vendor/assets/javascripts/parsley.i18n.he.js
|
56
|
+
- vendor/assets/javascripts/parsley.i18n.id.extra.js
|
53
57
|
- vendor/assets/javascripts/parsley.i18n.id.js
|
54
58
|
- vendor/assets/javascripts/parsley.i18n.it.extra.js
|
55
59
|
- vendor/assets/javascripts/parsley.i18n.it.js
|
@@ -57,9 +61,12 @@ files:
|
|
57
61
|
- vendor/assets/javascripts/parsley.i18n.nl.js
|
58
62
|
- vendor/assets/javascripts/parsley.i18n.pl.js
|
59
63
|
- vendor/assets/javascripts/parsley.i18n.pt-br.js
|
64
|
+
- vendor/assets/javascripts/parsley.i18n.ru.extra.js
|
60
65
|
- vendor/assets/javascripts/parsley.i18n.ru.js
|
61
66
|
- vendor/assets/javascripts/parsley.i18n.sv.extra.js
|
62
67
|
- vendor/assets/javascripts/parsley.i18n.sv.js
|
68
|
+
- vendor/assets/javascripts/parsley.i18n.th.js
|
69
|
+
- vendor/assets/javascripts/parsley.i18n.tr.js
|
63
70
|
- vendor/assets/javascripts/parsley.i18n.zh_cn.extra.js
|
64
71
|
- vendor/assets/javascripts/parsley.i18n.zh_cn.js
|
65
72
|
- vendor/assets/javascripts/parsley.js
|