Skip to content

Commit

Permalink
[build] 1.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
niceue committed May 6, 2018
1 parent 4feba20 commit 3e93ebe
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 33 deletions.
59 changes: 30 additions & 29 deletions dist/jquery.validator.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*! nice-validator 1.1.3
* (c) 2012-2017 Jony Zhang <[email protected]>, MIT Licensed
/*! nice-validator 1.1.4
* (c) 2012-2018 Jony Zhang <[email protected]>, MIT Licensed
* https://github.com/niceue/nice-validator
*/
;(function(factory) {
typeof module === "object" && module.exports ? module.exports = factory( require( "jquery" ) ) :
typeof module === 'object' && module.exports ? module.exports = factory( require( 'jquery' ) ) :
typeof define === 'function' && define.amd ? define(['jquery'], factory) :
factory(jQuery);
}(function($, undefined) {
"use strict";
'use strict';

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

Expand Down Expand Up @@ -336,19 +336,16 @@

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

function issetEvent(events, name, namespace) {
if ( events && events[name] &&
$.map(events[name], function(e){
return !!(
events && events[name]
&& $.map(events[name], function(e){
return ~e.namespace.indexOf(namespace) ? 1 : null;
}).length
) {
return true;
}
return false;
}).length )
}
},

Expand Down Expand Up @@ -464,9 +461,9 @@
var args = arguments;
args[4] = args[4] || args[5];
field._rules.push({
and: args[1] === "&",
not: args[2] === "!",
or: args[6] === "|",
and: args[1] === '&',
not: args[2] === '!',
or: args[6] === '|',
method: args[3],
params: args[4] ? $.map( args[4].split(', '), trim ) : undefined
});
Expand Down Expand Up @@ -781,7 +778,7 @@
me.showMsg(type)
}
else if ( type === 'tip' ) {
me.$el.find(INPUT_SELECTOR +"["+ DATA_TIP +"]", el).each(function(){
me.$el.find(INPUT_SELECTOR +'['+ DATA_TIP +']', el).each(function(){
me.showMsg(this, {type: type, msg: msg});
});
}
Expand Down Expand Up @@ -897,7 +894,7 @@
rule = field._rules[field._i];
if (rule.not) {
msg = undefined;
isValid = method === "required" || !isValid;
isValid = method === 'required' || !isValid;
}
if (rule.or) {
if (isValid) {
Expand Down Expand Up @@ -1002,7 +999,7 @@
field._r = method;

if (old && !field.must && !rule.must && rule.result !== undefined &&
old.ruleName === method && old.id === el.id &&
old.ruleName === method && old.id === el.id &&
field.value && old.value === field.value )
{
// get result from cache
Expand Down Expand Up @@ -1415,7 +1412,7 @@
},
getValue: function() {
var elem = this.element;
if (elem.type === "number" && elem.validity && elem.validity.badInput) {
if (elem.type === 'number' && elem.validity && elem.validity.badInput) {
return 'NaN';
}
return $(elem)[this._valHook()]();
Expand Down Expand Up @@ -1523,8 +1520,9 @@
var k, that = context ? context === true ? this : context : Rules.prototype;

for (k in obj) {
if (_checkRuleName(k))
if (_checkRuleName(k)) {
that[k] = _getRule(obj[k]);
}
}
}

Expand Down Expand Up @@ -1598,7 +1596,7 @@
function _getDataRule(el, method) {
var fn = trim(attr(el, DATA_RULE + '-' + method));

if ( fn && (fn = new Function("return " + fn)()) ) {
if ( fn && (fn = new Function('return ' + fn)()) ) {
return _getRule(fn);
}
}
Expand Down Expand Up @@ -1641,8 +1639,8 @@

// Translate field key to jQuery selector.
function _key2selector(key) {
var isID = key.charAt(0) === "#";
key = key.replace(/([:.{(|)}/\[\]])/g, "\\$1");
var isID = key.charAt(0) === '#';
key = key.replace(/([:.{(|)}/\[\]])/g, '\\$1');
return isID ? key : '[name="'+ key +'"]:first';
}

Expand Down Expand Up @@ -1683,7 +1681,7 @@
});

new Messages({
fallback: "This field is not valid.",
fallback: 'This field is not valid.',
loading: 'Validating...'
});

Expand All @@ -1696,6 +1694,7 @@
*
* @example:
required
required(jqSelector)
required(anotherRule)
required(not, -1)
required(from, .contact)
Expand Down Expand Up @@ -1836,7 +1835,7 @@
}

// If both fields are blank
if (!me.required && a === "" && b === "") {
if (!me.required && a === '' && b === '') {
return null;
}

Expand All @@ -1852,7 +1851,7 @@
}

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

Expand All @@ -1873,7 +1872,7 @@

return isValid || (
isObject(me.messages.match)
&& me.messages.match[type].replace( '{1}', me._getDisplay( element, field2.display || key ) )
&& me.messages.match[type].replace( '{1}', me._getDisplay( elem2, field2.display || key ) )
);
},

Expand Down Expand Up @@ -1957,6 +1956,8 @@
By GET: remote(get:path/to/server, name1, name2, ...);
Name proxy: remote(path/to/server, name1, proxyname2:name2, proxyname3:#id3, ...)
Query String remote(path/to/server, foo=1&bar=2, name1, name2, ...)
CORS remote(cors:path/to/server)
JSONP remote(jsonp:path/to/server)
*/
remote: function(element, params) {
if (!params) return;
Expand Down Expand Up @@ -2017,7 +2018,7 @@
*/
filter: function(element, params) {
var value = this.value,
temp = value.replace( params ? (new RegExp("[" + params[0] + "]", "gm")) : rUnsafe, '' );
temp = value.replace( params ? (new RegExp('[' + params[0] + ']', 'gm')) : rUnsafe, '' );
if (temp !== value) this.setValue(temp);
}
});
Expand Down
Loading

0 comments on commit 3e93ebe

Please sign in to comment.