Skip to content

Commit edc4e11

Browse files
committed
统一代码风格
1 parent 4356485 commit edc4e11

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

src/jquery.validator.js

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
;(function(factory) {
2-
typeof module === "object" && module.exports ? module.exports = factory( require( "jquery" ) ) :
2+
typeof module === 'object' && module.exports ? module.exports = factory( require( 'jquery' ) ) :
33
typeof define === 'function' && define.amd ? define(['jquery'], factory) :
44
factory(jQuery);
55
}(function($, undefined) {
6-
"use strict";
6+
'use strict';
77

88
var NS = 'validator',
99
CLS_NS = '.' + NS,
@@ -282,7 +282,7 @@
282282
}
283283
options = me._opt = options || {};
284284
dataOpt = attr(element, 'data-'+ NS +'-option');
285-
dataOpt = me._dataOpt = dataOpt && dataOpt.charAt(0) === '{' ? (new Function("return " + dataOpt))() : {};
285+
dataOpt = me._dataOpt = dataOpt && dataOpt.charAt(0) === '{' ? (new Function('return ' + dataOpt))() : {};
286286
themeOpt = me._themeOpt = themes[ options.theme || dataOpt.theme || defaults.theme ];
287287
opt = me.options = $.extend({}, defaults, fieldDefaults, themeOpt, me.options, options, dataOpt);
288288

@@ -332,7 +332,7 @@
332332

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

@@ -457,9 +457,9 @@
457457
var args = arguments;
458458
args[4] = args[4] || args[5];
459459
field._rules.push({
460-
and: args[1] === "&",
461-
not: args[2] === "!",
462-
or: args[6] === "|",
460+
and: args[1] === '&',
461+
not: args[2] === '!',
462+
or: args[6] === '|',
463463
method: args[3],
464464
params: args[4] ? $.map( args[4].split(', '), trim ) : undefined
465465
});
@@ -774,7 +774,7 @@
774774
me.showMsg(type)
775775
}
776776
else if ( type === 'tip' ) {
777-
me.$el.find(INPUT_SELECTOR +"["+ DATA_TIP +"]", el).each(function(){
777+
me.$el.find(INPUT_SELECTOR +'['+ DATA_TIP +']', el).each(function(){
778778
me.showMsg(this, {type: type, msg: msg});
779779
});
780780
}
@@ -890,7 +890,7 @@
890890
rule = field._rules[field._i];
891891
if (rule.not) {
892892
msg = undefined;
893-
isValid = method === "required" || !isValid;
893+
isValid = method === 'required' || !isValid;
894894
}
895895
if (rule.or) {
896896
if (isValid) {
@@ -995,7 +995,7 @@
995995
field._r = method;
996996

997997
if (old && !field.must && !rule.must && rule.result !== undefined &&
998-
old.ruleName === method && old.id === el.id &&
998+
old.ruleName === method && old.id === el.id &&
999999
field.value && old.value === field.value )
10001000
{
10011001
// get result from cache
@@ -1408,7 +1408,7 @@
14081408
},
14091409
getValue: function() {
14101410
var elem = this.element;
1411-
if (elem.type === "number" && elem.validity && elem.validity.badInput) {
1411+
if (elem.type === 'number' && elem.validity && elem.validity.badInput) {
14121412
return 'NaN';
14131413
}
14141414
return $(elem)[this._valHook()]();
@@ -1516,8 +1516,9 @@
15161516
var k, that = context ? context === true ? this : context : Rules.prototype;
15171517

15181518
for (k in obj) {
1519-
if (_checkRuleName(k))
1519+
if (_checkRuleName(k)) {
15201520
that[k] = _getRule(obj[k]);
1521+
}
15211522
}
15221523
}
15231524

@@ -1591,7 +1592,7 @@
15911592
function _getDataRule(el, method) {
15921593
var fn = trim(attr(el, DATA_RULE + '-' + method));
15931594

1594-
if ( fn && (fn = new Function("return " + fn)()) ) {
1595+
if ( fn && (fn = new Function('return ' + fn)()) ) {
15951596
return _getRule(fn);
15961597
}
15971598
}
@@ -1634,8 +1635,8 @@
16341635

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

@@ -1676,7 +1677,7 @@
16761677
});
16771678

16781679
new Messages({
1679-
fallback: "This field is not valid.",
1680+
fallback: 'This field is not valid.',
16801681
loading: 'Validating...'
16811682
});
16821683

@@ -1830,7 +1831,7 @@
18301831
}
18311832

18321833
// If both fields are blank
1833-
if (!me.required && a === "" && b === "") {
1834+
if (!me.required && a === '' && b === '') {
18341835
return null;
18351836
}
18361837

@@ -1846,7 +1847,7 @@
18461847
}
18471848

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

@@ -2013,7 +2014,7 @@
20132014
*/
20142015
filter: function(element, params) {
20152016
var value = this.value,
2016-
temp = value.replace( params ? (new RegExp("[" + params[0] + "]", "gm")) : rUnsafe, '' );
2017+
temp = value.replace( params ? (new RegExp('[' + params[0] + ']', 'gm')) : rUnsafe, '' );
20172018
if (temp !== value) this.setValue(temp);
20182019
}
20192020
});

0 commit comments

Comments
 (0)