jq-idealform-test/js/main.js

66 lines
1.5 KiB
JavaScript
Raw Normal View History

2013-10-04 02:45:36 +02:00
/*!
* jQuery Ideal Forms
* @author: Cedric Ruiz
* @version: 3.0
* @license GPL or MIT
*/
(function($, win, doc, undefined) {
var plugin = {};
plugin.name = 'idealforms';
plugin.defaults = {
2013-10-10 02:30:21 +02:00
i18n: 'en',
2013-10-04 02:45:36 +02:00
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);
},
2013-10-10 02:30:21 +02:00
i18n: {},
2013-10-04 02:45:36 +02:00
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'),
2013-10-04 02:50:18 +02:00
require('./extensions/datepicker/datepicker.ext'),
require('./extensions/adaptive/adaptive.ext')
2013-10-04 02:45:36 +02:00
]
};
plugin.methods = $.extend({}, require('./private'), require('./public'));
require('./plugin')(plugin);
}(jQuery, window, document));