fastman2 3.0.0-alpha.1 → 3.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actionsheetman.js +1 -96
- package/alertman.js +1 -79
- package/annotationman.js +17 -2912
- package/baseman.js +1 -115
- package/blankpageman.js +1 -171
- package/cascadepickerman.js +1 -322
- package/confirmman.js +1 -87
- package/coreman.js +3 -2182
- package/cryptoman.js +2 -8931
- package/datetimepickerman.js +1 -181
- package/domman.js +1 -2759
- package/eventemitterman.js +1 -112
- package/fileuploadman.js +1 -2970
- package/formvalidateman.js +1 -335
- package/jsbridgeman.js +1 -992
- package/lazyloadman.js +1 -133
- package/loadingman.js +1 -81
- package/modalman.js +1 -264
- package/mutationobserverman.js +1 -356
- package/package.json +1 -1
- package/passguardman.js +1 -1722
- package/persistman.js +1 -60
- package/pickerman.js +1 -680
- package/popupman.js +1 -61
- package/postman.js +1 -1649
- package/preloadman.js +2 -8760
- package/resultpageman.js +1 -153
- package/routerman.js +1 -1201
- package/scrollman-infiniteRefresh.js +1 -117
- package/scrollman-pullDownRefresh.js +1 -302
- package/scrollman.js +2 -2567
- package/storeman.js +1 -585
- package/swiperman.js +1 -4702
- package/swiperoldman.js +1 -3005
- package/tabman.js +1 -145
- package/tipman.js +1 -110
- package/toastman.js +1 -78
- package/toolman.js +1 -22
- package/whenman.js +1 -774
- package/wsman.js +1 -7624
package/formvalidateman.js
CHANGED
|
@@ -1,335 +1 @@
|
|
|
1
|
-
(function
|
|
2
|
-
if(typeof exports === 'object' && typeof module === 'object')
|
|
3
|
-
module.exports = factory();
|
|
4
|
-
else if(typeof define === 'function' && define.amd)
|
|
5
|
-
define([], factory);
|
|
6
|
-
else if(typeof exports === 'object')
|
|
7
|
-
exports["fastman"] = factory();
|
|
8
|
-
else
|
|
9
|
-
root["fastman"] = factory();
|
|
10
|
-
})(this, function() {
|
|
11
|
-
return webpackJsonpfastman([16],{
|
|
12
|
-
|
|
13
|
-
/***/ 229:
|
|
14
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
15
|
-
|
|
16
|
-
module.exports = __webpack_require__(94);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/***/ }),
|
|
20
|
-
|
|
21
|
-
/***/ 94:
|
|
22
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
23
|
-
|
|
24
|
-
"use strict";
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
Object.defineProperty(exports, "__esModule", {
|
|
28
|
-
value: true
|
|
29
|
-
});
|
|
30
|
-
exports.validateExtend = exports.validate = undefined;
|
|
31
|
-
|
|
32
|
-
var _toast = __webpack_require__(50);
|
|
33
|
-
|
|
34
|
-
var type = ['input:not([type]),input[type="color"],input[type="date"],input[type="datetime"],input[type="datetime-local"],input[type="email"],input[type="file"],input[type="hidden"],input[type="month"],input[type="number"],input[type="password"],input[type="range"],input[type="search"],input[type="tel"],input[type="text"],input[type="time"],input[type="url"],input[type="week"],textarea', 'select', 'input[type="checkbox"],input[type="radio"]'],
|
|
35
|
-
allTypes = type.join(","),
|
|
36
|
-
extend = {};
|
|
37
|
-
// var fieldValidTypeHand=function($field,status,options){
|
|
38
|
-
// if($field.prop("type")=="radio" || $field.prop("type")=="checkbox"){
|
|
39
|
-
// var $fields=options.$form.find('[name="'+$field.prop('name')+'"]');
|
|
40
|
-
//
|
|
41
|
-
// if($fields.filter(":checked").length > 0){
|
|
42
|
-
// $fields.removeClass('field-invalid')
|
|
43
|
-
// }else{
|
|
44
|
-
// $fields.addClass('field-invalid')
|
|
45
|
-
// }
|
|
46
|
-
// }else{
|
|
47
|
-
// if(status.required && status.pattern && status.conditional) {
|
|
48
|
-
// $field.removeClass('field-invalid');
|
|
49
|
-
// }else{
|
|
50
|
-
// $field.addClass('field-invalid');
|
|
51
|
-
// }
|
|
52
|
-
// }
|
|
53
|
-
// };
|
|
54
|
-
/**
|
|
55
|
-
* Created by linyiqing on 2017/3/30.
|
|
56
|
-
*/
|
|
57
|
-
//import { toast, closeToast } from 'fastman/toastman'
|
|
58
|
-
var fieldTooltip = function () {
|
|
59
|
-
var instance = null;
|
|
60
|
-
function show(text) {
|
|
61
|
-
if (!instance) {
|
|
62
|
-
// var $container=$('<div class="field-tooltipWrap"><div class="field-tooltipInner"><div class="field-tooltip fieldTipBounceIn">'+text+'</div></div></div>');
|
|
63
|
-
// $container.appendTo($("body"));
|
|
64
|
-
var toastInstance = (0, _toast.toast)(text, 99999999);
|
|
65
|
-
instance = true;
|
|
66
|
-
setTimeout(function () {
|
|
67
|
-
(0, _toast.closeToast)(toastInstance);
|
|
68
|
-
instance = false;
|
|
69
|
-
}, 1500);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
show: show
|
|
75
|
-
};
|
|
76
|
-
}();
|
|
77
|
-
var validateField = function validateField(event, options) {
|
|
78
|
-
var $field = $(this),
|
|
79
|
-
status = {
|
|
80
|
-
required: true,
|
|
81
|
-
conditional: true,
|
|
82
|
-
pattern: true
|
|
83
|
-
},
|
|
84
|
-
log,
|
|
85
|
-
//验证提示信息存储变量
|
|
86
|
-
|
|
87
|
-
//errorTipFormat=$.fn.mvalidate.errorTipFormat,//错误信息输出的格式化
|
|
88
|
-
|
|
89
|
-
fieldValue = $.trim($field.val()) || "",
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
//*****获取当前字段的data-validate
|
|
93
|
-
fieldValidate = $field.attr("data-validate"),
|
|
94
|
-
validation = fieldValidate != undefined ? extend[fieldValidate] : {},
|
|
95
|
-
|
|
96
|
-
//*****获取当前字段的data-required
|
|
97
|
-
fieldRequired = $field.attr("data-required"),
|
|
98
|
-
|
|
99
|
-
//*****获取当前字段的data-pattern
|
|
100
|
-
fieldPattern = $field.attr('data-pattern') || ($.type(validation.pattern) == 'regexp' ? validation.pattern : /(?:)/),
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
//*****获取当前字段的data-conditional
|
|
104
|
-
fieldConditional = $field.attr("data-conditional") || validation.conditional,
|
|
105
|
-
|
|
106
|
-
//*****获取当前字段的data-description
|
|
107
|
-
fieldDescription = $field.attr("data-descriptions") || validation.descriptions,
|
|
108
|
-
|
|
109
|
-
//*****获取当前字段的data-describedby
|
|
110
|
-
fieldDescribedby = $field.attr("data-describedby") || validation.describedby;
|
|
111
|
-
|
|
112
|
-
fieldDescription = $.isPlainObject(fieldDescription) ? fieldDescription : options.descriptions[fieldDescription] || {};
|
|
113
|
-
fieldRequired = fieldRequired != '' ? fieldRequired || !!validation.required : true;
|
|
114
|
-
if ($.type(fieldPattern) != 'regexp') {
|
|
115
|
-
fieldPattern = RegExp(fieldPattern);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
//如果是必填验证,那么就要判断是什么类型的表单
|
|
119
|
-
if (fieldRequired) {
|
|
120
|
-
//如果是那种可以通过val()来判断的
|
|
121
|
-
if ($field.is(type[0] + ',' + type[1])) {
|
|
122
|
-
if (!fieldValue.length > 0) {
|
|
123
|
-
status.required = false;
|
|
124
|
-
}
|
|
125
|
-
//如果是raido和checkbox,通过name和checked来判断
|
|
126
|
-
} else if ($field.is(type[2])) {
|
|
127
|
-
if ($field.is('[name]')) {
|
|
128
|
-
if (options.$form.find('[name="' + $field.prop('name') + '"]:checked').length == 0) {
|
|
129
|
-
status.required = false;
|
|
130
|
-
}
|
|
131
|
-
} else {
|
|
132
|
-
status.required = field.is(':checked');
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
/**如果是正则验证
|
|
137
|
-
* 只有那些类似type=text的文本框我们才能通过正则表达式去验证pattern,
|
|
138
|
-
* 而对于select,radio,checkbox pattern显然是无效的
|
|
139
|
-
*/
|
|
140
|
-
if ($field.is(type[0])) {
|
|
141
|
-
//如果不匹配
|
|
142
|
-
if (!fieldPattern.test(fieldValue)) {
|
|
143
|
-
if (fieldRequired) {
|
|
144
|
-
status.pattern = false;
|
|
145
|
-
} else {
|
|
146
|
-
if (fieldValue.length > 0) {
|
|
147
|
-
status.pattern = false;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
//如果是data-conditional="name"函数验证,函数返回true或者是false
|
|
154
|
-
if (fieldConditional != "undefined") {
|
|
155
|
-
if ($.isFunction(fieldConditional)) {
|
|
156
|
-
status.conditional = !!fieldConditional.call($field, fieldValue, options);
|
|
157
|
-
} else {
|
|
158
|
-
if (options.conditional.hasOwnProperty(fieldConditional) && !options.conditional[fieldConditional].call($field, fieldValue, options)) {
|
|
159
|
-
status.conditional = false;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
//验证通过的信息所在对象
|
|
165
|
-
log = fieldDescription.valid;
|
|
166
|
-
if (!status.required) {
|
|
167
|
-
log = fieldDescription.required;
|
|
168
|
-
} else if (!status.pattern) {
|
|
169
|
-
log = fieldDescription.pattern;
|
|
170
|
-
} else if (!status.conditional) {
|
|
171
|
-
log = fieldDescription.conditional;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// var $describedShowElem=$('[id="' + fieldDescribedby +'"]');
|
|
175
|
-
// //如果找打提示的容器,是第二种类型的验证
|
|
176
|
-
// if($describedShowElem.length > 0 && options.type==2){
|
|
177
|
-
// //如果是change 或者是keyup 同时是第一次输入的时候就不要验证
|
|
178
|
-
// if((event.type=="keyup" || event.type=="change") && (!$describedShowElem.children().length || !$.trim($describedShowElem.text()))){
|
|
179
|
-
//
|
|
180
|
-
// }else{
|
|
181
|
-
// $describedShowElem.html(log || '');
|
|
182
|
-
// fieldValidTypeHand($field,status,options)
|
|
183
|
-
// }
|
|
184
|
-
// }
|
|
185
|
-
|
|
186
|
-
if (typeof validation.each == 'function') {
|
|
187
|
-
validation.each.call($field, event, status, options);
|
|
188
|
-
}
|
|
189
|
-
options.eachField.call($field, event, status, options);
|
|
190
|
-
|
|
191
|
-
if (status.required && status.pattern && status.conditional) {
|
|
192
|
-
|
|
193
|
-
if (typeof validation.valid == 'function') {
|
|
194
|
-
//二外拓展的
|
|
195
|
-
validation.valid.call($field, event, status, options);
|
|
196
|
-
}
|
|
197
|
-
options.eachValidField.call($field, event, status, options);
|
|
198
|
-
} else {
|
|
199
|
-
//验证未通过
|
|
200
|
-
if (!options.firstInvalid && options.firstInvalidFocus) {
|
|
201
|
-
options.firstInvalid = true;
|
|
202
|
-
$field.focus();
|
|
203
|
-
}
|
|
204
|
-
if (options.type == 1) {
|
|
205
|
-
fieldTooltip.show(log);
|
|
206
|
-
}
|
|
207
|
-
if (typeof validation.invalid == 'function') {
|
|
208
|
-
validation.invalid.call($field, event, status, options);
|
|
209
|
-
}
|
|
210
|
-
options.eachInvalidField.call($field, event, status, options);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* 如果是data-describedby="elemId"验证信息要显示的地方,类型3的验证:
|
|
215
|
-
* 第一元素获取焦点,keyUp的时候要一直验证,如果正确那么错误信息就隐藏,如果不正确,那么错误
|
|
216
|
-
* 提示信息要根据状态而改变,对于与验证通过,那么可以通过eachInvalid来让用户自定义,而无需要
|
|
217
|
-
* 在插件中写它的操作方式
|
|
218
|
-
*/
|
|
219
|
-
return status;
|
|
220
|
-
};
|
|
221
|
-
// $.extend($,{
|
|
222
|
-
// mvalidateExtend:function(options){
|
|
223
|
-
// return $.extend(extend, options);
|
|
224
|
-
// }
|
|
225
|
-
// });
|
|
226
|
-
|
|
227
|
-
var validateExtend = function validateExtend(options) {
|
|
228
|
-
return $.extend(extend, options);
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
var validate = function validate(selector, options) {
|
|
232
|
-
var form = $(selector);
|
|
233
|
-
var defaults = {
|
|
234
|
-
type: 1,
|
|
235
|
-
validateInSubmit: true,
|
|
236
|
-
sendForm: false,
|
|
237
|
-
onKeyup: false,
|
|
238
|
-
onChange: true,
|
|
239
|
-
firstInvalidFocus: false, //第一个未通过验证的表单是否获得交代呢
|
|
240
|
-
conditional: {},
|
|
241
|
-
descriptions: {},
|
|
242
|
-
eachField: $.noop,
|
|
243
|
-
eachValidField: $.noop,
|
|
244
|
-
eachInvalidField: $.noop,
|
|
245
|
-
valid: $.noop,
|
|
246
|
-
invalid: $.noop,
|
|
247
|
-
namespace: "mvalidate"
|
|
248
|
-
},
|
|
249
|
-
opts = $.extend(true, defaults, options),
|
|
250
|
-
namespace = opts.namespace;
|
|
251
|
-
|
|
252
|
-
opts.type = Number(opts.type);
|
|
253
|
-
opts.firstInvalid = false;
|
|
254
|
-
return form.mvalidateDestroy().each(function (event) {
|
|
255
|
-
|
|
256
|
-
var $form = $(this),
|
|
257
|
-
$fields; //存放当前表单下的所有元素;
|
|
258
|
-
if (!$form.is("form")) return;
|
|
259
|
-
opts.$form = $form;
|
|
260
|
-
$form.zeptoData(name, { "options": opts });
|
|
261
|
-
$fields = $form.find(allTypes);
|
|
262
|
-
|
|
263
|
-
//
|
|
264
|
-
if (opts.onKeyup) {
|
|
265
|
-
$fields.filter(type[0]).each(function () {
|
|
266
|
-
|
|
267
|
-
$(this).on("keyup." + namespace, function (event) {
|
|
268
|
-
validateField.call(this, event, opts);
|
|
269
|
-
});
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
if (opts.onChange) {
|
|
274
|
-
$fields.each(function () {
|
|
275
|
-
var $this = $(this);
|
|
276
|
-
if ($this.is(type[1] + ',' + type[2])) {
|
|
277
|
-
$(this).on('change.' + namespace, function (event) {
|
|
278
|
-
validateField.call(this, event, opts);
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
//如果需要验证的时候,在提交表单的时候对所有的字段进行验证
|
|
285
|
-
if (opts.validateInSubmit) {
|
|
286
|
-
$form.on("submit." + namespace, function (event) {
|
|
287
|
-
var formValid = true;
|
|
288
|
-
opts.firstInvalid = false;
|
|
289
|
-
$fields.each(function () {
|
|
290
|
-
var status = validateField.call(this, event, opts);
|
|
291
|
-
if (!status.pattern || !status.conditional || !status.required) {
|
|
292
|
-
formValid = false;
|
|
293
|
-
}
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
if (formValid) {
|
|
297
|
-
if (!opts.sendForm) {
|
|
298
|
-
event.preventDefault();
|
|
299
|
-
}
|
|
300
|
-
if ($.isFunction(opts.valid)) {
|
|
301
|
-
opts.valid.call($form, event, opts);
|
|
302
|
-
}
|
|
303
|
-
//验证没有通过,禁用提交事件,以及绑定在这个elem上的其他事件
|
|
304
|
-
} else {
|
|
305
|
-
event.preventDefault();
|
|
306
|
-
event.stopImmediatePropagation();
|
|
307
|
-
if ($.isFunction(opts.invalid)) {
|
|
308
|
-
opts.invalid.call($form, event, opts);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
};
|
|
315
|
-
$.fn.mvalidateDestroy = function () {
|
|
316
|
-
var $form = $(this),
|
|
317
|
-
$fields,
|
|
318
|
-
dataValidate = $form.zeptoData(name);
|
|
319
|
-
if ($form.is('form') && $.isPlainObject(dataValidate) && typeof dataValidate.options.namespace == 'string') {
|
|
320
|
-
$fields = $form.removeData(name).find(allTypes);
|
|
321
|
-
$fields.off('.' + dataValidate.options.namespace);
|
|
322
|
-
}
|
|
323
|
-
return $form;
|
|
324
|
-
};
|
|
325
|
-
// $.fn.mvalidate.errorTipFormat=function(text){
|
|
326
|
-
// return '<div class="zvalid-resultformat">'+text+'</div>';
|
|
327
|
-
// }
|
|
328
|
-
|
|
329
|
-
exports.validate = validate;
|
|
330
|
-
exports.validateExtend = validateExtend;
|
|
331
|
-
|
|
332
|
-
/***/ })
|
|
333
|
-
|
|
334
|
-
},[229]);
|
|
335
|
-
});
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.fastman=e():t.fastman=e()}(this,function(){return webpackJsonpfastman([16],{229:function(t,e,i){t.exports=i(94)},94:function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.validateExtend=e.validate=void 0;var n=i(50),a=['input:not([type]),input[type="color"],input[type="date"],input[type="datetime"],input[type="datetime-local"],input[type="email"],input[type="file"],input[type="hidden"],input[type="month"],input[type="number"],input[type="password"],input[type="range"],input[type="search"],input[type="tel"],input[type="text"],input[type="time"],input[type="url"],input[type="week"],textarea',"select",'input[type="checkbox"],input[type="radio"]'],o=a.join(","),r={},d=function(){function t(t){if(!e){var i=(0,n.toast)(t,99999999);e=!0,setTimeout(function(){(0,n.closeToast)(i),e=!1},1500)}}var e=null;return{show:t}}(),p=function(t,e){var i,n=$(this),o={required:!0,conditional:!0,pattern:!0},p=$.trim(n.val())||"",l=n.attr("data-validate"),c=void 0!=l?r[l]:{},u=n.attr("data-required"),s=n.attr("data-pattern")||("regexp"==$.type(c.pattern)?c.pattern:/(?:)/),f=n.attr("data-conditional")||c.conditional,v=n.attr("data-descriptions")||c.descriptions;n.attr("data-describedby")||c.describedby;return v=$.isPlainObject(v)?v:e.descriptions[v]||{},u=""==u||(u||!!c.required),"regexp"!=$.type(s)&&(s=RegExp(s)),u&&(n.is(a[0]+","+a[1])?!p.length>0&&(o.required=!1):n.is(a[2])&&(n.is("[name]")?0==e.$form.find('[name="'+n.prop("name")+'"]:checked').length&&(o.required=!1):o.required=field.is(":checked"))),n.is(a[0])&&(s.test(p)||(u?o.pattern=!1:p.length>0&&(o.pattern=!1))),"undefined"!=f&&($.isFunction(f)?o.conditional=!!f.call(n,p,e):e.conditional.hasOwnProperty(f)&&!e.conditional[f].call(n,p,e)&&(o.conditional=!1)),i=v.valid,o.required?o.pattern?o.conditional||(i=v.conditional):i=v.pattern:i=v.required,"function"==typeof c.each&&c.each.call(n,t,o,e),e.eachField.call(n,t,o,e),o.required&&o.pattern&&o.conditional?("function"==typeof c.valid&&c.valid.call(n,t,o,e),e.eachValidField.call(n,t,o,e)):(!e.firstInvalid&&e.firstInvalidFocus&&(e.firstInvalid=!0,n.focus()),1==e.type&&d.show(i),"function"==typeof c.invalid&&c.invalid.call(n,t,o,e),e.eachInvalidField.call(n,t,o,e)),o},l=function(t){return $.extend(r,t)},c=function(t,e){var i=$(t),n={type:1,validateInSubmit:!0,sendForm:!1,onKeyup:!1,onChange:!0,firstInvalidFocus:!1,conditional:{},descriptions:{},eachField:$.noop,eachValidField:$.noop,eachInvalidField:$.noop,valid:$.noop,invalid:$.noop,namespace:"mvalidate"},r=$.extend(!0,n,e),d=r.namespace;return r.type=Number(r.type),r.firstInvalid=!1,i.mvalidateDestroy().each(function(t){var e,i=$(this);i.is("form")&&(r.$form=i,i.zeptoData(name,{options:r}),e=i.find(o),r.onKeyup&&e.filter(a[0]).each(function(){$(this).on("keyup."+d,function(t){p.call(this,t,r)})}),r.onChange&&e.each(function(){$(this).is(a[1]+","+a[2])&&$(this).on("change."+d,function(t){p.call(this,t,r)})}),r.validateInSubmit&&i.on("submit."+d,function(t){var n=!0;r.firstInvalid=!1,e.each(function(){var e=p.call(this,t,r);e.pattern&&e.conditional&&e.required||(n=!1)}),n?(r.sendForm||t.preventDefault(),$.isFunction(r.valid)&&r.valid.call(i,t,r)):(t.preventDefault(),t.stopImmediatePropagation(),$.isFunction(r.invalid)&&r.invalid.call(i,t,r))}))})};$.fn.mvalidateDestroy=function(){var t,e=$(this),i=e.zeptoData(name);return e.is("form")&&$.isPlainObject(i)&&"string"==typeof i.options.namespace&&(t=e.removeData(name).find(o),t.off("."+i.options.namespace)),e},e.validate=c,e.validateExtend=l}},[229])});
|