Skip to content

Commit 243a5e4

Browse files
committed
Merge branch 'dev'
2 parents 1b2f4f6 + 09c89a2 commit 243a5e4

11 files changed

+55
-42
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ charset = utf-8
55
indent_style = space
66
indent_size = 4
77
end_of_line = lf
8-
insert_final_newline = true
8+
insert_final_newline = false
99
trim_trailing_whitespace = true
1010

1111
[*.md]

demo/load-by-requirejs.html

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<body>
1010

11-
<form id="form1" class="form" data-validator-option="{timely:2}">
11+
<form id="form1" class="form">
1212
<div class="form-item">
1313
<input type="text" name="user[email]" data-rule="required;email" placeholder="Email">
1414
</div>
@@ -27,29 +27,32 @@
2727
baseUrl: '../',
2828
paths: {
2929
jquery: 'http://cdn.jsdelivr.net/jquery/1.12.3/jquery.min',
30-
validator: 'dist/jquery.validator.js?local=en'
30+
validator: 'dist/local/zh-CN'
31+
},
32+
shim: {
33+
validator: ['../dist/jquery.validator.js?css']
3134
}
3235
});
3336

34-
// Just include nice-validator
35-
require(['validator']);
3637

37-
38-
/*
39-
// Use plugin methods
38+
// Way 1: Use plugin methods
4039
require(['jquery', 'validator'], function($){
41-
$('#form1').validator();
40+
$('#form1').validator({
41+
timely: 2,
42+
stopOnError: true,
43+
theme: 'yellow_right'
44+
});
4245
});
43-
*/
4446

4547

46-
/*
47-
// Define a module dependency nice-validator
48-
define('some-module', ['jquery', 'validator'], function($){
49-
// some code
50-
});
51-
*/
48+
// Way 2: Just include nice-validator
49+
// require(['validator']);
50+
5251

52+
// Way 3: Define a module dependency nice-validator
53+
// define('some-module', ['jquery', 'validator'], function($){
54+
// // some code
55+
// });
5356
</script>
5457
</body>
55-
</html>
58+
</html>

dist/jquery.validator.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
/*! nice-validator 1.0.4
1+
/*! nice-validator 1.0.5
22
* (c) 2012-2016 Jony Zhang <[email protected]>, MIT Licensed
33
* https://github.com/niceue/nice-validator
44
*/
55
;(function(factory) {
66
typeof module === "object" && module.exports ? module.exports = factory( require( "jquery" ) ) :
7-
typeof define === 'function' && define.amd ? require(['jquery'], factory) :
7+
typeof define === 'function' && define.amd ? define(['jquery'], factory) :
88
factory(jQuery);
99
}(function($, undefined) {
1010
"use strict";
@@ -786,13 +786,18 @@
786786
var me = this,
787787
el = e.target;
788788

789-
if ( $(el).is(INPUT_SELECTOR) ) {
790-
me.showMsg(el, {type: type, msg: msg});
789+
if ( me.$el.is(el) ) {
790+
if (isObject(type)) {
791+
me.showMsg(type)
792+
}
793+
else if ( type === 'tip' ) {
794+
me.$el.find(INPUT_SELECTOR +"["+ DATA_TIP +"]", el).each(function(){
795+
me.showMsg(this, {type: type, msg: msg});
796+
});
797+
}
791798
}
792-
else if ( type === 'tip' ) {
793-
me.$el.find(INPUT_SELECTOR +"["+ DATA_TIP +"]", el).each(function(){
794-
me.showMsg(this, {type: type, msg: msg});
795-
});
799+
else {
800+
me.showMsg(el, {type: type, msg: msg});
796801
}
797802
},
798803

@@ -2104,7 +2109,7 @@
21042109
el.href = Validator.css = dir + 'jquery.validator.css';
21052110
node.parentNode.insertBefore(el, node);
21062111
}
2107-
if (!Validator.local && params.local !== '') {
2112+
if (!Validator.local && ~str.indexOf('local') && params.local !== '') {
21082113
Validator.local = (params.local || doc.documentElement.lang || 'en').replace('_','-');
21092114
Validator.pending = 1;
21102115
el = doc.createElement('script');

dist/jquery.validator.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/local/en.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*********************************/
55
(function(factory) {
66
typeof module === "object" && module.exports ? module.exports = factory( require( "jquery" ) ) :
7-
typeof define === 'function' && define.amd ? require(['jquery'], factory) :
7+
typeof define === 'function' && define.amd ? define(['jquery'], factory) :
88
factory(jQuery);
99
}(function($) {
1010

dist/local/ja.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*********************************/
55
(function(factory) {
66
typeof module === "object" && module.exports ? module.exports = factory( require( "jquery" ) ) :
7-
typeof define === 'function' && define.amd ? require(['jquery'], factory) :
7+
typeof define === 'function' && define.amd ? define(['jquery'], factory) :
88
factory(jQuery);
99
}(function($) {
1010

dist/local/zh-CN.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*********************************/
55
(function(factory) {
66
typeof module === "object" && module.exports ? module.exports = factory( require( "jquery" ) ) :
7-
typeof define === 'function' && define.amd ? require(['jquery'], factory) :
7+
typeof define === 'function' && define.amd ? define(['jquery'], factory) :
88
factory(jQuery);
99
}(function($) {
1010

dist/local/zh-TW.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*********************************/
55
(function(factory) {
66
typeof module === "object" && module.exports ? module.exports = factory( require( "jquery" ) ) :
7-
typeof define === 'function' && define.amd ? require(['jquery'], factory) :
7+
typeof define === 'function' && define.amd ? define(['jquery'], factory) :
88
factory(jQuery);
99
}(function($) {
1010

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nice-validator",
3-
"version": "1.0.4",
3+
"version": "1.0.5",
44
"author": "Jony Zhang <[email protected]>",
55
"license": "MIT",
66
"description": "Simple, smart and pleasant verification solution.",

src/jquery.validator.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
;(function(factory) {
22
typeof module === "object" && module.exports ? module.exports = factory( require( "jquery" ) ) :
3-
typeof define === 'function' && define.amd ? require(['jquery'], factory) :
3+
typeof define === 'function' && define.amd ? define(['jquery'], factory) :
44
factory(jQuery);
55
}(function($, undefined) {
66
"use strict";
@@ -782,13 +782,18 @@
782782
var me = this,
783783
el = e.target;
784784

785-
if ( $(el).is(INPUT_SELECTOR) ) {
786-
me.showMsg(el, {type: type, msg: msg});
785+
if ( me.$el.is(el) ) {
786+
if (isObject(type)) {
787+
me.showMsg(type)
788+
}
789+
else if ( type === 'tip' ) {
790+
me.$el.find(INPUT_SELECTOR +"["+ DATA_TIP +"]", el).each(function(){
791+
me.showMsg(this, {type: type, msg: msg});
792+
});
793+
}
787794
}
788-
else if ( type === 'tip' ) {
789-
me.$el.find(INPUT_SELECTOR +"["+ DATA_TIP +"]", el).each(function(){
790-
me.showMsg(this, {type: type, msg: msg});
791-
});
795+
else {
796+
me.showMsg(el, {type: type, msg: msg});
792797
}
793798
},
794799

@@ -2100,7 +2105,7 @@
21002105
el.href = Validator.css = dir + 'jquery.validator.css';
21012106
node.parentNode.insertBefore(el, node);
21022107
}
2103-
if (!Validator.local && params.local !== '') {
2108+
if (!Validator.local && ~str.indexOf('local') && params.local !== '') {
21042109
Validator.local = (params.local || doc.documentElement.lang || 'en').replace('_','-');
21052110
Validator.pending = 1;
21062111
el = doc.createElement('script');

src/local/_config.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*********************************/
55
(function(factory) {
66
typeof module === "object" && module.exports ? module.exports = factory( require( "jquery" ) ) :
7-
typeof define === 'function' && define.amd ? require(['jquery'], factory) :
7+
typeof define === 'function' && define.amd ? define(['jquery'], factory) :
88
factory(jQuery);
99
}(function($) {
1010

0 commit comments

Comments
 (0)