62 lines
1.4 KiB
JavaScript
62 lines
1.4 KiB
JavaScript
|
/*!
|
||
|
* jQuery Ideal Forms
|
||
|
* @author: Cedric Ruiz
|
||
|
* @version: 3.0
|
||
|
* @license GPL or MIT
|
||
|
*/
|
||
|
(function($, win, doc, undefined) {
|
||
|
|
||
|
var plugin = {};
|
||
|
|
||
|
plugin.name = 'idealforms';
|
||
|
|
||
|
plugin.defaults = {
|
||
|
field: '.field',
|
||
|
error: '.error',
|
||
|
iconHtml: '<i/>',
|
||
|
iconClass: 'icon',
|
||
|
invalidClass: 'invalid',
|
||
|
validClass: 'valid',
|
||
|
silentLoad: true,
|
||
|
onValidate: $.noop,
|
||
|
onSubmit: $.noop
|
||
|
};
|
||
|
|
||
|
plugin.global = {
|
||
|
|
||
|
_format: function(str) {
|
||
|
var args = [].slice.call(arguments, 1);
|
||
|
return str.replace(/\{(\d)\}/g, function(_, match) {
|
||
|
return args[+match] || '';
|
||
|
}).replace(/\{\*([^*}]*)\}/g, function(_, sep) {
|
||
|
return args.join(sep || ', ');
|
||
|
});
|
||
|
},
|
||
|
|
||
|
_getKey: function(key, obj) {
|
||
|
return key.split('.').reduce(function(a,b) {
|
||
|
return a && a[b];
|
||
|
}, obj);
|
||
|
},
|
||
|
|
||
|
ruleSeparator: ' ',
|
||
|
argSeparator: ':',
|
||
|
|
||
|
rules: require('./rules'),
|
||
|
errors: require('./errors'),
|
||
|
|
||
|
extensions: [
|
||
|
require('./extensions/dynamic-fields/dynamic-fields.ext'),
|
||
|
require('./extensions/ajax/ajax.ext'),
|
||
|
require('./extensions/steps/steps.ext'),
|
||
|
require('./extensions/custom-inputs/custom-inputs.ext'),
|
||
|
require('./extensions/datepicker/datepicker.ext')
|
||
|
]
|
||
|
};
|
||
|
|
||
|
plugin.methods = $.extend({}, require('./private'), require('./public'));
|
||
|
|
||
|
require('./plugin')(plugin);
|
||
|
|
||
|
}(jQuery, window, document));
|