fastman2 2.8.9 → 3.0.0-alpha.1
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 +96 -1
- package/alertman.js +79 -1
- package/annotationman.js +2912 -17
- package/baseman.js +115 -1
- package/blankpageman.js +171 -1
- package/bootstrap/index.d.ts +1 -0
- package/cascadepickerman.js +322 -1
- package/confirmman.js +87 -1
- package/coreman.js +2182 -3
- package/cryptoman.js +8931 -2
- package/datetimepickerman.js +181 -1
- package/domman.js +2759 -1
- package/eventemitterman.js +112 -1
- package/fileuploadman.js +2970 -1
- package/formvalidateman.js +335 -1
- package/jsbridgeman.js +992 -1
- package/lazyloadman.js +133 -1
- package/loadingman.js +81 -1
- package/modalman.js +264 -1
- package/mutationobserverman.js +356 -1
- package/package.json +1 -1
- package/passguardman.js +1722 -1
- package/persistman.js +60 -1
- package/pickerman.js +680 -1
- package/popupman.js +61 -1
- package/postman.js +1649 -1
- package/preloadman.js +8760 -2
- package/resultpageman.js +153 -1
- package/routerman.js +1201 -1
- package/scrollman-infiniteRefresh.js +117 -1
- package/scrollman-pullDownRefresh.js +302 -1
- package/scrollman.js +2567 -2
- package/storeman.js +585 -1
- package/swiperman.js +4702 -1
- package/swiperoldman.js +3005 -1
- package/tabman.js +145 -1
- package/tipman.js +110 -1
- package/toastman.js +78 -1
- package/toolman.js +22 -1
- package/whenman.js +774 -1
- package/wsman.js +7624 -1
package/formvalidateman.js
CHANGED
|
@@ -1 +1,335 @@
|
|
|
1
|
-
|
|
1
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
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
|
+
});
|