Skip to content

Commit 3e93ebe

Browse files
committed
[build] 1.1.4
1 parent 4feba20 commit 3e93ebe

File tree

3 files changed

+34
-33
lines changed

3 files changed

+34
-33
lines changed

dist/jquery.validator.js

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
/*! nice-validator 1.1.3
2-
* (c) 2012-2017 Jony Zhang <[email protected]>, MIT Licensed
1+
/*! nice-validator 1.1.4
2+
* (c) 2012-2018 Jony Zhang <[email protected]>, MIT Licensed
33
* https://github.com/niceue/nice-validator
44
*/
55
;(function(factory) {
6-
typeof module === "object" && module.exports ? module.exports = factory( require( "jquery" ) ) :
6+
typeof module === 'object' && module.exports ? module.exports = factory( require( 'jquery' ) ) :
77
typeof define === 'function' && define.amd ? define(['jquery'], factory) :
88
factory(jQuery);
99
}(function($, undefined) {
10-
"use strict";
10+
'use strict';
1111

1212
var NS = 'validator',
1313
CLS_NS = '.' + NS,
@@ -286,7 +286,7 @@
286286
}
287287
options = me._opt = options || {};
288288
dataOpt = attr(element, 'data-'+ NS +'-option');
289-
dataOpt = me._dataOpt = dataOpt && dataOpt.charAt(0) === '{' ? (new Function("return " + dataOpt))() : {};
289+
dataOpt = me._dataOpt = dataOpt && dataOpt.charAt(0) === '{' ? (new Function('return ' + dataOpt))() : {};
290290
themeOpt = me._themeOpt = themes[ options.theme || dataOpt.theme || defaults.theme ];
291291
opt = me.options = $.extend({}, defaults, fieldDefaults, themeOpt, me.options, options, dataOpt);
292292

@@ -336,19 +336,16 @@
336336

337337
if ( !(me.isAjaxSubmit = !!me.options.valid) ) {
338338
// if there is a "valid.form" event
339-
var events = ($._data || $.data)(form, "events");
339+
var events = ($._data || $.data)(form, 'events');
340340
me.isAjaxSubmit = issetEvent(events, 'valid', 'form') || issetEvent(events, 'submit', 'form-plugin');
341341
}
342342

343343
function issetEvent(events, name, namespace) {
344-
if ( events && events[name] &&
345-
$.map(events[name], function(e){
344+
return !!(
345+
events && events[name]
346+
&& $.map(events[name], function(e){
346347
return ~e.namespace.indexOf(namespace) ? 1 : null;
347-
}).length
348-
) {
349-
return true;
350-
}
351-
return false;
348+
}).length )
352349
}
353350
},
354351

@@ -464,9 +461,9 @@
464461
var args = arguments;
465462
args[4] = args[4] || args[5];
466463
field._rules.push({
467-
and: args[1] === "&",
468-
not: args[2] === "!",
469-
or: args[6] === "|",
464+
and: args[1] === '&',
465+
not: args[2] === '!',
466+
or: args[6] === '|',
470467
method: args[3],
471468
params: args[4] ? $.map( args[4].split(', '), trim ) : undefined
472469
});
@@ -781,7 +778,7 @@
781778
me.showMsg(type)
782779
}
783780
else if ( type === 'tip' ) {
784-
me.$el.find(INPUT_SELECTOR +"["+ DATA_TIP +"]", el).each(function(){
781+
me.$el.find(INPUT_SELECTOR +'['+ DATA_TIP +']', el).each(function(){
785782
me.showMsg(this, {type: type, msg: msg});
786783
});
787784
}
@@ -897,7 +894,7 @@
897894
rule = field._rules[field._i];
898895
if (rule.not) {
899896
msg = undefined;
900-
isValid = method === "required" || !isValid;
897+
isValid = method === 'required' || !isValid;
901898
}
902899
if (rule.or) {
903900
if (isValid) {
@@ -1002,7 +999,7 @@
1002999
field._r = method;
10031000

10041001
if (old && !field.must && !rule.must && rule.result !== undefined &&
1005-
old.ruleName === method && old.id === el.id &&
1002+
old.ruleName === method && old.id === el.id &&
10061003
field.value && old.value === field.value )
10071004
{
10081005
// get result from cache
@@ -1415,7 +1412,7 @@
14151412
},
14161413
getValue: function() {
14171414
var elem = this.element;
1418-
if (elem.type === "number" && elem.validity && elem.validity.badInput) {
1415+
if (elem.type === 'number' && elem.validity && elem.validity.badInput) {
14191416
return 'NaN';
14201417
}
14211418
return $(elem)[this._valHook()]();
@@ -1523,8 +1520,9 @@
15231520
var k, that = context ? context === true ? this : context : Rules.prototype;
15241521

15251522
for (k in obj) {
1526-
if (_checkRuleName(k))
1523+
if (_checkRuleName(k)) {
15271524
that[k] = _getRule(obj[k]);
1525+
}
15281526
}
15291527
}
15301528

@@ -1598,7 +1596,7 @@
15981596
function _getDataRule(el, method) {
15991597
var fn = trim(attr(el, DATA_RULE + '-' + method));
16001598

1601-
if ( fn && (fn = new Function("return " + fn)()) ) {
1599+
if ( fn && (fn = new Function('return ' + fn)()) ) {
16021600
return _getRule(fn);
16031601
}
16041602
}
@@ -1641,8 +1639,8 @@
16411639

16421640
// Translate field key to jQuery selector.
16431641
function _key2selector(key) {
1644-
var isID = key.charAt(0) === "#";
1645-
key = key.replace(/([:.{(|)}/\[\]])/g, "\\$1");
1642+
var isID = key.charAt(0) === '#';
1643+
key = key.replace(/([:.{(|)}/\[\]])/g, '\\$1');
16461644
return isID ? key : '[name="'+ key +'"]:first';
16471645
}
16481646

@@ -1683,7 +1681,7 @@
16831681
});
16841682

16851683
new Messages({
1686-
fallback: "This field is not valid.",
1684+
fallback: 'This field is not valid.',
16871685
loading: 'Validating...'
16881686
});
16891687

@@ -1696,6 +1694,7 @@
16961694
*
16971695
* @example:
16981696
required
1697+
required(jqSelector)
16991698
required(anotherRule)
17001699
required(not, -1)
17011700
required(from, .contact)
@@ -1836,7 +1835,7 @@
18361835
}
18371836

18381837
// If both fields are blank
1839-
if (!me.required && a === "" && b === "") {
1838+
if (!me.required && a === '' && b === '') {
18401839
return null;
18411840
}
18421841

@@ -1852,7 +1851,7 @@
18521851
}
18531852

18541853
// If the compared field is incorrect, we only ensure that this field is correct.
1855-
if (type !== "eq" && !isNaN(+a) && isNaN(+b)) {
1854+
if (type !== 'eq' && !isNaN(+a) && isNaN(+b)) {
18561855
return true;
18571856
}
18581857

@@ -1873,7 +1872,7 @@
18731872

18741873
return isValid || (
18751874
isObject(me.messages.match)
1876-
&& me.messages.match[type].replace( '{1}', me._getDisplay( element, field2.display || key ) )
1875+
&& me.messages.match[type].replace( '{1}', me._getDisplay( elem2, field2.display || key ) )
18771876
);
18781877
},
18791878

@@ -1957,6 +1956,8 @@
19571956
By GET: remote(get:path/to/server, name1, name2, ...);
19581957
Name proxy: remote(path/to/server, name1, proxyname2:name2, proxyname3:#id3, ...)
19591958
Query String remote(path/to/server, foo=1&bar=2, name1, name2, ...)
1959+
CORS remote(cors:path/to/server)
1960+
JSONP remote(jsonp:path/to/server)
19601961
*/
19611962
remote: function(element, params) {
19621963
if (!params) return;
@@ -2017,7 +2018,7 @@
20172018
*/
20182019
filter: function(element, params) {
20192020
var value = this.value,
2020-
temp = value.replace( params ? (new RegExp("[" + params[0] + "]", "gm")) : rUnsafe, '' );
2021+
temp = value.replace( params ? (new RegExp('[' + params[0] + ']', 'gm')) : rUnsafe, '' );
20212022
if (temp !== value) this.setValue(temp);
20222023
}
20232024
});

0 commit comments

Comments
 (0)