1266 lines
No EOL
82 KiB
JavaScript
1266 lines
No EOL
82 KiB
JavaScript
;(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
|
/**
|
|
* Errors
|
|
*/
|
|
module.exports = {
|
|
|
|
required: 'This field is required',
|
|
digits: 'Must be only digits',
|
|
name: 'Must be at least 3 characters long and must only contain letters',
|
|
email: 'Must be a valid email',
|
|
username: 'Must be at between 4 and 32 characters long and start with a letter. You may use letters, numbers, underscores, and one dot',
|
|
pass: 'Must be at least 6 characters long, and contain at least one number, one uppercase and one lowercase letter',
|
|
strongpass: 'Must be at least 8 characters long and contain at least one uppercase and one lowercase letter and one number or special character',
|
|
phone: 'Must be a valid phone number',
|
|
zip: 'Must be a valid zip code',
|
|
url: 'Must be a valid URL',
|
|
number: 'Must be a number',
|
|
range: 'Must be a number between {0} and {1}',
|
|
min: 'Must be at least {0} characters long',
|
|
max: 'Must be under {0} characters',
|
|
minoption: 'Select at least {0} options',
|
|
maxoption: 'Select no more than {0} options',
|
|
minmax: 'Must be between {0} and {1} characters long',
|
|
select: 'Select an option',
|
|
extension: 'File(s) must have a valid extension ({*})',
|
|
equalto: 'Must have the same value as the "{0}" field',
|
|
date: 'Must be a valid date {0}'
|
|
|
|
};
|
|
|
|
},{}],2:[function(require,module,exports){
|
|
/**
|
|
* Adaptive
|
|
*/
|
|
module.exports = {
|
|
|
|
name: 'adaptive',
|
|
|
|
options: {
|
|
adaptiveWidth: $('<p class="idealforms-field-width"/>').appendTo('body').css('width').replace('px','')
|
|
},
|
|
|
|
methods: {
|
|
|
|
// @extend
|
|
_init: function () {
|
|
|
|
var self = this;
|
|
|
|
function adapt() {
|
|
|
|
var formWidth = self.$form.outerWidth()
|
|
, isAdaptive = self.opts.adaptiveWidth > formWidth;
|
|
|
|
self.$form.toggleClass('adaptive', isAdaptive);
|
|
|
|
if (self._hasExtension('steps')) {
|
|
self.$stepsContainer.toggleClass('adaptive', isAdaptive);
|
|
}
|
|
|
|
if (self._hasExtension('datepicker')) {
|
|
$('#ui-datepicker-div').hide();
|
|
}
|
|
}
|
|
|
|
$(window).resize(adapt);
|
|
adapt();
|
|
|
|
this.$form.find('select').each(function() {
|
|
self._getField(this).find(self.opts.error).addClass('hidden');
|
|
});
|
|
|
|
$('p.idealforms-field-width').remove();
|
|
}
|
|
|
|
}
|
|
};
|
|
|
|
},{}],3:[function(require,module,exports){
|
|
module.exports = {
|
|
|
|
name: 'ajax',
|
|
|
|
methods: {
|
|
|
|
// @extend
|
|
_init: function() {
|
|
|
|
$.extend($.idealforms, { _requests: {} });
|
|
|
|
$.extend($.idealforms.errors, {
|
|
ajax: 'Loading...'
|
|
});
|
|
|
|
$.extend($.idealforms.rules, {
|
|
|
|
ajax: function(input) {
|
|
|
|
var self = this
|
|
, $field = this._getField(input)
|
|
, url = $(input).data('idealforms-ajax')
|
|
, userError = $.idealforms._getKey('errors.'+ input.name +'.ajaxError', self.opts)
|
|
, requests = $.idealforms._requests
|
|
, data = {};
|
|
|
|
data[input.name] = input.value;
|
|
|
|
$field.addClass('ajax');
|
|
|
|
if (requests[input.name]) requests[input.name].abort();
|
|
|
|
requests[input.name] = $.post(url, data, function(resp) {
|
|
|
|
if (resp === true) {
|
|
$field.data('idealforms-valid', true);
|
|
self._handleError(input);
|
|
self._handleStyle(input);
|
|
} else {
|
|
self._handleError(input, userError);
|
|
}
|
|
|
|
$field.removeClass('ajax');
|
|
|
|
}, 'json');
|
|
|
|
return false;
|
|
}
|
|
});
|
|
},
|
|
|
|
// @extend
|
|
_validate: function(input, rule) {
|
|
if (rule != 'ajax' && $.idealforms._requests[input.name]) {
|
|
$.idealforms._requests[input.name].abort();
|
|
this._getField(input).removeClass('ajax');
|
|
}
|
|
}
|
|
|
|
}
|
|
};
|
|
|
|
},{}],4:[function(require,module,exports){
|
|
require('./idealfile');
|
|
require('./idealradiocheck');
|
|
|
|
module.exports = {
|
|
|
|
name: 'customInputs',
|
|
|
|
methods: {
|
|
|
|
// @extend
|
|
_init: function() {
|
|
this._buildCustomInputs();
|
|
},
|
|
|
|
addFields: function() {
|
|
this._buildCustomInputs();
|
|
},
|
|
|
|
_buildCustomInputs: function() {
|
|
this.$form.find(':file').idealfile();
|
|
this.$form.find(':checkbox, :radio').idealradiocheck();
|
|
}
|
|
|
|
}
|
|
};
|
|
|
|
},{"./idealfile":5,"./idealradiocheck":6}],5:[function(require,module,exports){
|
|
/**
|
|
* Ideal File
|
|
*/
|
|
(function($, win, doc, undefined) {
|
|
|
|
// Browser supports HTML5 multiple file?
|
|
var multipleSupport = typeof $('<input/>')[0].multiple !== 'undefined'
|
|
, isIE = /msie/i.test(navigator.userAgent)
|
|
, plugin = {};
|
|
|
|
plugin.name = 'idealfile';
|
|
|
|
plugin.methods = {
|
|
|
|
_init: function() {
|
|
|
|
var $file = $(this.el).addClass('ideal-file') // the original file input
|
|
, $wrap = $('<div class="ideal-file-wrap">')
|
|
, $input = $('<input type="text" class="ideal-file-filename" />')
|
|
// Button that will be used in non-IE browsers
|
|
, $button = $('<button type="button" class="ideal-file-upload">Open</button>')
|
|
// Hack for IE
|
|
, $label = $('<label class="ideal-file-upload" for="' + $file[0].id + '">Open</label>');
|
|
|
|
// Hide by shifting to the left so we
|
|
// can still trigger events
|
|
$file.css({
|
|
position: 'absolute',
|
|
left: '-9999px'
|
|
});
|
|
|
|
$wrap.append($input, (isIE ? $label : $button)).insertAfter($file);
|
|
|
|
// Prevent focus
|
|
$file.attr('tabIndex', -1);
|
|
$button.attr('tabIndex', -1);
|
|
|
|
$button.click(function () {
|
|
$file.focus().click(); // Open dialog
|
|
});
|
|
|
|
$file.change(function () {
|
|
|
|
var files = []
|
|
, fileArr, filename;
|
|
|
|
// If multiple is supported then extract
|
|
// all filenames from the file array
|
|
if (multipleSupport) {
|
|
fileArr = $file[0].files;
|
|
for (var i = 0, len = fileArr.length; i < len; i++) {
|
|
files.push(fileArr[i].name);
|
|
}
|
|
filename = files.join(', ');
|
|
|
|
// If not supported then just take the value
|
|
// and remove the path to just show the filename
|
|
} else {
|
|
filename = $file.val().split('\\').pop();
|
|
}
|
|
|
|
$input .val(filename).attr('title', filename);
|
|
|
|
});
|
|
|
|
$input.on({
|
|
blur: function () {
|
|
$file.trigger('blur');
|
|
},
|
|
keydown: function (e) {
|
|
if (e.which === 13) { // Enter
|
|
if (!isIE) $file.trigger('click');
|
|
$(this).closest('form').one('keydown', function(e) {
|
|
if (e.which === 13) e.preventDefault();
|
|
});
|
|
} else if (e.which === 8 || e.which === 46) { // Backspace & Del
|
|
// In IE the value is read-only
|
|
// with this trick we remove the old input and add
|
|
// a clean clone with all the original events attached
|
|
if (isIE) $file.replaceWith($file = $file.clone(true));
|
|
$file.val('').trigger('change');
|
|
$input.val('');
|
|
} else if (e.which === 9) { // TAB
|
|
return;
|
|
} else { // All other keys
|
|
return false;
|
|
}
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
require('../../plugin')(plugin);
|
|
|
|
}(jQuery, window, document));
|
|
|
|
},{"../../plugin":12}],6:[function(require,module,exports){
|
|
/*
|
|
* idealRadioCheck: jQuery plguin for checkbox and radio replacement
|
|
* Usage: $('input[type=checkbox], input[type=radio]').idealRadioCheck()
|
|
*/
|
|
(function($, win, doc, undefined) {
|
|
|
|
var plugin = {};
|
|
|
|
plugin.name = 'idealradiocheck';
|
|
|
|
plugin.methods = {
|
|
|
|
_init: function() {
|
|
|
|
var $input = $(this.el);
|
|
var $span = $('<span/>');
|
|
|
|
$span.addClass('ideal-'+ ($input.is(':checkbox') ? 'check' : 'radio'));
|
|
$input.is(':checked') && $span.addClass('checked'); // init
|
|
$span.insertAfter($input);
|
|
|
|
$input.parent('label')
|
|
.addClass('ideal-radiocheck-label')
|
|
.attr('onclick', ''); // Fix clicking label in iOS
|
|
|
|
$input.css({ position: 'absolute', left: '-9999px' }); // hide by shifting left
|
|
|
|
// Events
|
|
$input.on({
|
|
change: function() {
|
|
var $input = $(this);
|
|
if ( $input.is('input[type="radio"]') ) {
|
|
$input.parent().siblings('label').find('.ideal-radio').removeClass('checked');
|
|
}
|
|
$span.toggleClass('checked', $input.is(':checked'));
|
|
},
|
|
focus: function() { $span.addClass('focus') },
|
|
blur: function() { $span.removeClass('focus') },
|
|
click: function() { $(this).trigger('focus') }
|
|
});
|
|
}
|
|
|
|
};
|
|
|
|
require('../../plugin')(plugin);
|
|
|
|
}(jQuery, window, document));
|
|
|
|
|
|
},{"../../plugin":12}],7:[function(require,module,exports){
|
|
module.exports = {
|
|
|
|
name: 'datepicker',
|
|
|
|
methods: {
|
|
|
|
// @extend
|
|
_init: function() {
|
|
this._buildDatepicker();
|
|
},
|
|
|
|
_buildDatepicker: function() {
|
|
|
|
var $datepicker = this.$form.find('input.datepicker');
|
|
|
|
this._getField($datepicker).find(this.opts.error).addClass('hidden');
|
|
|
|
// Always show datepicker below the input
|
|
if (jQuery.ui) {
|
|
$.datepicker._checkOffset = function(a,b,c){ return b };
|
|
}
|
|
|
|
if (jQuery.ui && $datepicker.length) {
|
|
|
|
$datepicker.each(function() {
|
|
|
|
$(this).datepicker({
|
|
beforeShow: function(input) {
|
|
$(input).addClass('open');
|
|
},
|
|
onChangeMonthYear: function() {
|
|
// Hack to fix IE9 not resizing
|
|
var $this = $(this)
|
|
, width = $this.outerWidth(); // cache first!
|
|
setTimeout(function() {
|
|
$this.datepicker('widget').css('width', width);
|
|
}, 1);
|
|
},
|
|
onClose: function() {
|
|
$(this).removeClass('open');
|
|
}
|
|
});
|
|
});
|
|
|
|
// Adjust width
|
|
$datepicker.on('focus keyup', function() {
|
|
var t = $(this), w = t.outerWidth();
|
|
t.datepicker('widget').css('width', w);
|
|
});
|
|
}
|
|
}
|
|
|
|
}
|
|
};
|
|
|
|
},{}],8:[function(require,module,exports){
|
|
function template(html, data) {
|
|
|
|
var loop = /\{@([^}]+)\}(.+?)\{\/\1\}/g
|
|
, loopVariable = /\{#([^}]+)\}/g
|
|
, variable = /\{([^}]+)\}/g;
|
|
|
|
return html
|
|
.replace(loop, function(_, key, list) {
|
|
return $.map(data[key], function(item) {
|
|
return list.replace(loopVariable, function(_, k) {
|
|
return item[k];
|
|
});
|
|
}).join('');
|
|
})
|
|
.replace(variable, function(_, key) {
|
|
return data[key] || '';
|
|
});
|
|
}
|
|
|
|
module.exports = {
|
|
|
|
name: 'dynamicFields',
|
|
|
|
options: {
|
|
|
|
templates: {
|
|
|
|
base:'\
|
|
<div class="field" {class}>\
|
|
<label class="main">{label}</label>\
|
|
{field}\
|
|
<span class="error"></span>\
|
|
</div>\
|
|
',
|
|
|
|
text: '<input name="{name}" type="{subtype}" value="{value}" {attrs}>',
|
|
|
|
file: '<input id="{name} "name="{name}" type="file" {attrs}>',
|
|
|
|
textarea: '<textarea name="{name}" {attrs}>{text}</textarea>',
|
|
|
|
group: '\
|
|
<p class="group">\
|
|
{@list}\
|
|
<label><input name="{name}" type="{subtype}" value="{#value}" {#attrs}>{#text}</label>\
|
|
{/list}\
|
|
</p>\
|
|
',
|
|
|
|
select: '\
|
|
<select name={name}>\
|
|
{@list}\
|
|
<option value="{#value}">{#text}</option>\
|
|
{/list}\
|
|
</select>\
|
|
'
|
|
}
|
|
},
|
|
|
|
methods: {
|
|
|
|
addFields: function(fields) {
|
|
|
|
var self = this;
|
|
|
|
$.each(fields, function(name, field) {
|
|
|
|
var typeArray = field.type.split(':')
|
|
, rules = {};
|
|
|
|
field.name = name;
|
|
field.type = typeArray[0];
|
|
if (typeArray[1]) field.subtype = typeArray[1];
|
|
|
|
var html = template(self.opts.templates.base, {
|
|
label: field.label,
|
|
field: template(self.opts.templates[field.type], field)
|
|
});
|
|
|
|
if (field.after || field.before) {
|
|
self.$form.find('[name='+ (field.after || field.before) +']').each(function() {
|
|
self._getField(this)[field.after ? 'after' : 'before'](html);
|
|
});
|
|
} else {
|
|
self.$form.find(self.opts.field).last().after(html);
|
|
}
|
|
|
|
if (field.rules) {
|
|
rules[name] = field.rules;
|
|
self.addRules(rules);
|
|
}
|
|
});
|
|
|
|
this._inject('addFields');
|
|
},
|
|
|
|
removeFields: function(names) {
|
|
|
|
var self = this;
|
|
|
|
$.each(names.split(' '), function(i, name) {
|
|
var $field = self._getField($('[name="'+ name +'"]'));
|
|
self.$fields = self.$fields.filter(function() {
|
|
return ! $(this).is($field);
|
|
});
|
|
$field.remove();
|
|
});
|
|
|
|
this._inject('removeFields');
|
|
},
|
|
|
|
toggleFields: function(names) {
|
|
|
|
var self = this;
|
|
|
|
$.each(names.split(' '), function(i, name) {
|
|
var $field = self._getField($('[name="'+ name +'"]'));
|
|
$field.data('idealforms-valid', $field.is(':visible')).toggle();
|
|
});
|
|
|
|
this._inject('toggleFields');
|
|
}
|
|
|
|
}
|
|
};
|
|
|
|
},{}],9:[function(require,module,exports){
|
|
/*!
|
|
* Ideal Steps
|
|
*/
|
|
(function($, win, doc, undefined) {
|
|
|
|
var plugin = {};
|
|
|
|
plugin.name = 'idealsteps';
|
|
|
|
plugin.defaults = {
|
|
nav: '.idealsteps-nav',
|
|
navItems: 'li',
|
|
buildNavItems: true,
|
|
wrap: '.idealsteps-wrap',
|
|
step: '.idealsteps-step',
|
|
activeClass: 'idealsteps-step-active',
|
|
before: null,
|
|
after: null,
|
|
fadeSpeed: 0
|
|
};
|
|
|
|
plugin.methods = {
|
|
|
|
_init: function() {
|
|
|
|
var self = this,
|
|
active = this.opts.activeClass;
|
|
|
|
this.$el = $(this.el);
|
|
|
|
this.$nav = this.$el.find(this.opts.nav);
|
|
this.$navItems = this.$nav.find(this.opts.navItems);
|
|
|
|
this.$wrap = this.$el.find(this.opts.wrap);
|
|
this.$steps = this.$wrap.find(this.opts.step);
|
|
|
|
if (this.opts.buildNavItems) this._buildNavItems();
|
|
|
|
this.$steps.hide().first().show();
|
|
this.$navItems.removeClass(active).first().addClass(active);
|
|
|
|
this.$navItems.click(function() {
|
|
self.go(self.$navItems.index(this));
|
|
});
|
|
},
|
|
|
|
_buildNavItems: function() {
|
|
|
|
var self = this,
|
|
isCustom = typeof this.opts.buildNavItems == 'function',
|
|
item = function(val){ return '<li><a href="#" tabindex="-1">'+ val +'</a></li>'; },
|
|
items;
|
|
|
|
items = isCustom ?
|
|
this.$steps.map(function(i){ return item(self.opts.buildNavItems.call(self, i)) }).get() :
|
|
this.$steps.map(function(i){ return item(++i); }).get();
|
|
|
|
this.$navItems = $(items.join(''));
|
|
|
|
this.$nav.append($('<ul/>').append(this.$navItems));
|
|
},
|
|
|
|
_getCurIdx: function() {
|
|
return this.$steps.index(this.$steps.filter(':visible'));
|
|
},
|
|
|
|
go: function(idx) {
|
|
|
|
var active = this.opts.activeClass,
|
|
fadeSpeed = this.opts.fadeSpeed;
|
|
|
|
if (typeof idx == 'function') idx = idx.call(this, this._getCurIdx());
|
|
|
|
if (idx >= this.$steps.length) idx = 0;
|
|
if (idx < 0) idx = this.$steps.length-1;
|
|
|
|
if (this.opts.before) this.opts.before.call(this, idx);
|
|
|
|
this.$navItems.removeClass(active).eq(idx).addClass(active);
|
|
this.$steps.fadeOut(fadeSpeed).eq(idx).fadeIn(fadeSpeed);
|
|
|
|
if (this.opts.after) this.opts.after.call(this, idx);
|
|
},
|
|
|
|
prev: function() {
|
|
this.go(this._getCurIdx() - 1);
|
|
},
|
|
|
|
next: function() {
|
|
this.go(this._getCurIdx() + 1);
|
|
},
|
|
|
|
first: function() {
|
|
this.go(0);
|
|
},
|
|
|
|
last: function() {
|
|
this.go(this.$steps.length-1);
|
|
}
|
|
};
|
|
|
|
require('../../plugin')(plugin);
|
|
|
|
}(jQuery, window, document));
|
|
|
|
},{"../../plugin":12}],10:[function(require,module,exports){
|
|
require('./idealsteps');
|
|
|
|
module.exports = {
|
|
|
|
name: 'steps',
|
|
|
|
options: {
|
|
stepsContainer: '.idealsteps-container',
|
|
stepsOptions: {}
|
|
},
|
|
|
|
methods: {
|
|
|
|
// @extend
|
|
_init: function() {
|
|
this._buildSteps();
|
|
},
|
|
|
|
// @extend
|
|
_validate: function() {
|
|
|
|
var self = this;
|
|
|
|
this._updateSteps();
|
|
|
|
if (this._hasExtension('ajax')) {
|
|
$.each($.idealforms._requests, function(key, request) {
|
|
request.done(function(){ self._updateSteps() });
|
|
});
|
|
}
|
|
},
|
|
|
|
// @extend
|
|
focusFirstInvalid: function(firstInvalid) {
|
|
|
|
var self = this;
|
|
|
|
this.$stepsContainer.idealsteps('go', function() {
|
|
return this.$steps.filter(function() {
|
|
return $(this).find(firstInvalid).length;
|
|
}).index();
|
|
});
|
|
},
|
|
|
|
_buildSteps: function() {
|
|
|
|
var self = this, options
|
|
, hasRules = ! $.isEmptyObject(this.opts.rules)
|
|
, counter = hasRules
|
|
? '<span class="counter"/>'
|
|
: '<span class="counter zero">0</span>';
|
|
|
|
options = $.extend({}, {
|
|
buildNavItems: function(i){ return 'Step '+ (i+1) + counter }
|
|
}, this.opts.stepsOptions);
|
|
|
|
this.$stepsContainer = this.$form.closest(this.opts.stepsContainer).idealsteps(options);
|
|
},
|
|
|
|
_updateSteps: function() {
|
|
|
|
var self = this;
|
|
|
|
this.$stepsContainer.idealsteps('_inject', function() {
|
|
|
|
var idealsteps = this;
|
|
|
|
this.$navItems.each(function(i) {
|
|
var invalid = idealsteps.$steps.eq(i).find(self.getInvalid()).length;
|
|
$(this).find('span').text(invalid).toggleClass('zero', ! invalid);
|
|
});
|
|
});
|
|
},
|
|
|
|
// @extend
|
|
addRules: function() {
|
|
this.firstStep();
|
|
},
|
|
|
|
// @extend
|
|
toggleFields: function() {
|
|
this._updateSteps();
|
|
},
|
|
|
|
// @extend
|
|
removeFields: function() {
|
|
this._updateSteps();
|
|
},
|
|
|
|
goToStep: function(idx) {
|
|
this.$stepsContainer.idealsteps('go', idx);
|
|
},
|
|
|
|
prevStep: function() {
|
|
this.$stepsContainer.idealsteps('prev');
|
|
},
|
|
|
|
nextStep: function() {
|
|
this.$stepsContainer.idealsteps('next');
|
|
},
|
|
|
|
firstStep: function() {
|
|
this.$stepsContainer.idealsteps('first');
|
|
},
|
|
|
|
lastStep: function() {
|
|
this.$stepsContainer.idealsteps('last');
|
|
}
|
|
}
|
|
|
|
};
|
|
|
|
},{"./idealsteps":9}],11:[function(require,module,exports){
|
|
/*!
|
|
* 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'),
|
|
require('./extensions/adaptive/adaptive.ext')
|
|
]
|
|
};
|
|
|
|
plugin.methods = $.extend({}, require('./private'), require('./public'));
|
|
|
|
require('./plugin')(plugin);
|
|
|
|
}(jQuery, window, document));
|
|
|
|
},{"./errors":1,"./extensions/adaptive/adaptive.ext":2,"./extensions/ajax/ajax.ext":3,"./extensions/custom-inputs/custom-inputs.ext":4,"./extensions/datepicker/datepicker.ext":7,"./extensions/dynamic-fields/dynamic-fields.ext":8,"./extensions/steps/steps.ext":10,"./plugin":12,"./private":13,"./public":14,"./rules":15}],12:[function(require,module,exports){
|
|
/**
|
|
* Plugin boilerplate
|
|
*/
|
|
module.exports = (function() {
|
|
|
|
var AP = Array.prototype;
|
|
|
|
return function(plugin) {
|
|
|
|
plugin = $.extend(true, {
|
|
name: 'plugin',
|
|
defaults: {
|
|
disabledExtensions: 'none'
|
|
},
|
|
methods: {},
|
|
global: {},
|
|
}, plugin);
|
|
|
|
$[plugin.name] = $.extend({
|
|
|
|
addExtension: function(extension) {
|
|
plugin.global.extensions.push(extension);
|
|
}
|
|
}, plugin.global);
|
|
|
|
function Plugin(element, options) {
|
|
|
|
this.opts = $.extend({}, plugin.defaults, options);
|
|
this.el = element;
|
|
|
|
this._name = plugin.name;
|
|
|
|
this._init();
|
|
}
|
|
|
|
Plugin._extended = {};
|
|
|
|
Plugin.prototype._hasExtension = function(extension) {
|
|
|
|
var self = this;
|
|
|
|
return plugin.global.extensions.filter(function(ext) {
|
|
return ext.name == extension && self.opts.disabledExtensions.indexOf(ext.name) < 0;
|
|
}).length;
|
|
};
|
|
|
|
Plugin.prototype._extend = function(extensions) {
|
|
|
|
var self = this;
|
|
|
|
$.each(extensions, function(i, extension) {
|
|
|
|
$.extend(self.opts, $.extend(true, extension.options, self.opts));
|
|
|
|
$.each(extension.methods, function(method, fn) {
|
|
|
|
if (self.opts.disabledExtensions.indexOf(extension.name) > -1) {
|
|
return;
|
|
}
|
|
|
|
if (Plugin.prototype[method]) {
|
|
Plugin._extended[method] = Plugin._extended[method] || [];
|
|
Plugin._extended[method].push({ name: extension.name, fn: fn });
|
|
} else {
|
|
Plugin.prototype[method] = fn;
|
|
}
|
|
});
|
|
|
|
});
|
|
};
|
|
|
|
Plugin.prototype._inject = function(method) {
|
|
|
|
var args = [].slice.call(arguments, 1);
|
|
|
|
if (typeof method == 'function') return method.call(this);
|
|
|
|
var self = this;
|
|
|
|
if (Plugin._extended[method]) {
|
|
$.each(Plugin._extended[method], function(i, plugin) {
|
|
plugin.fn.apply(self, args);
|
|
});
|
|
}
|
|
};
|
|
|
|
Plugin.prototype._init = $.noop;
|
|
|
|
Plugin.prototype[plugin.name] = function(method) {
|
|
if (!method) return this;
|
|
try { return this[method].apply(this, AP.slice.call(arguments, 1)); }
|
|
catch(e) {}
|
|
};
|
|
|
|
$.extend(Plugin.prototype, plugin.methods);
|
|
|
|
$.fn[plugin.name] = function() {
|
|
|
|
var args = AP.slice.call(arguments)
|
|
, methodArray = typeof args[0] == 'string' && args[0].split(':')
|
|
, method = methodArray[methodArray.length > 1 ? 1 : 0]
|
|
, prefix = methodArray.length > 1 && methodArray[0]
|
|
, opts = typeof args[0] == 'object' && args[0]
|
|
, params = args.slice(1)
|
|
, ret;
|
|
|
|
if (prefix) {
|
|
method = prefix + method.substr(0,1).toUpperCase() + method.substr(1,method.length-1);
|
|
}
|
|
|
|
this.each(function() {
|
|
|
|
var instance = $.data(this, plugin.name);
|
|
|
|
// Method
|
|
if (instance) {
|
|
return ret = instance[plugin.name].apply(instance, [method].concat(params));
|
|
}
|
|
|
|
// Init
|
|
return $.data(this, plugin.name, new Plugin(this, opts));
|
|
});
|
|
|
|
return prefix ? ret : this;
|
|
};
|
|
};
|
|
|
|
}());
|
|
|
|
},{}],13:[function(require,module,exports){
|
|
/**
|
|
* Private methods
|
|
*/
|
|
module.exports = {
|
|
|
|
_init: function() {
|
|
|
|
var self = this;
|
|
|
|
this._extend($.idealforms.extensions);
|
|
|
|
this.$form = $(this.el);
|
|
this.$fields = $();
|
|
this.$inputs = $();
|
|
|
|
this.$form.submit(function(e) {
|
|
e.preventDefault();
|
|
self.focusFirstInvalid();
|
|
self.opts.onSubmit.call(this, self.getInvalid().length, e);
|
|
});
|
|
|
|
this._inject('_init');
|
|
|
|
this.addRules(this.opts.rules || {});
|
|
|
|
if (! this.opts.silentLoad) this.focusFirstInvalid();
|
|
},
|
|
|
|
_buildField: function(input) {
|
|
|
|
var self = this
|
|
, $field = this._getField(input)
|
|
, $icon;
|
|
|
|
$icon = $(this.opts.iconHtml, {
|
|
class: this.opts.iconClass,
|
|
click: function(){ $(input).focus() }
|
|
});
|
|
|
|
if (! this.$fields.filter($field).length) {
|
|
this.$fields = this.$fields.add($field);
|
|
if (this.opts.iconHtml) $field.append($icon);
|
|
$field.addClass('idealforms-field idealforms-field-'+ input.type);
|
|
}
|
|
|
|
this._addEvents(input);
|
|
|
|
this._inject('_buildField', input);
|
|
},
|
|
|
|
_addEvents: function(input) {
|
|
|
|
var self = this
|
|
, $field = this._getField(input);
|
|
|
|
$(input)
|
|
.on('change keyup', function(e) {
|
|
|
|
var oldValue = $field.data('idealforms-value');
|
|
|
|
if (e.which == 9 || e.which == 16) return;
|
|
if (! $(this).is(':checkbox, :radio') && oldValue == this.value) return;
|
|
|
|
$field.data('idealforms-value', this.value);
|
|
|
|
self._validate(this, true, true);
|
|
})
|
|
.focus(function() {
|
|
|
|
if (self.isValid(this.name)) return false;
|
|
|
|
if (self._isRequired(this) || this.value) {
|
|
$field.find(self.opts.error).show();
|
|
}
|
|
})
|
|
.blur(function() {
|
|
$field.find(self.opts.error).hide();
|
|
});
|
|
},
|
|
|
|
_isRequired: function(input) {
|
|
// We assume non-text inputs with rules are required
|
|
if ($(input).is(':checkbox, :radio, select')) return true;
|
|
return this.opts.rules[input.name].indexOf('required') > -1;
|
|
},
|
|
|
|
_getRelated: function(input) {
|
|
return this._getField(input).find('[name="'+ input.name +'"]');
|
|
},
|
|
|
|
_getField: function(input) {
|
|
return $(input).closest(this.opts.field);
|
|
},
|
|
|
|
_getFirstInvalid: function() {
|
|
return this.getInvalid().first().find('input:first, textarea, select');
|
|
},
|
|
|
|
_handleError: function(input, error, valid) {
|
|
valid = valid || this.isValid(input.name);
|
|
var $error = this._getField(input).find(this.opts.error);
|
|
this.$form.find(this.opts.error).hide();
|
|
if (error) $error.text(error);
|
|
$error.toggle(!valid);
|
|
},
|
|
|
|
_handleStyle: function(input, valid) {
|
|
valid = valid || this.isValid(input.name);
|
|
this._getField(input)
|
|
.removeClass(this.opts.validClass +' '+ this.opts.invalidClass)
|
|
.addClass(valid ? this.opts.validClass : this.opts.invalidClass)
|
|
.find('.'+ this.opts.iconClass).show();
|
|
},
|
|
|
|
_fresh: function(input) {
|
|
this._getField(input)
|
|
.removeClass(this.opts.validClass +' '+ this.opts.invalidClass)
|
|
.find(this.opts.error).hide()
|
|
.end()
|
|
.find('.'+ this.opts.iconClass).toggle(this._isRequired(input));
|
|
},
|
|
|
|
_validate: function(input, handleError, handleStyle) {
|
|
|
|
var self = this
|
|
, $field = this._getField(input)
|
|
, userRules = this.opts.rules[input.name].split($.idealforms.ruleSeparator)
|
|
, valid = true
|
|
, rule;
|
|
|
|
// Non-required input with empty value must pass validation
|
|
if (! input.value && ! this._isRequired(input)) {
|
|
$field.removeData('idealforms-valid');
|
|
this._fresh(input);
|
|
|
|
// Required inputs
|
|
} else {
|
|
|
|
$.each(userRules, function(i, userRule) {
|
|
|
|
userRule = userRule.split($.idealforms.argSeparator);
|
|
|
|
rule = userRule[0];
|
|
|
|
var theRule = $.idealforms.rules[rule]
|
|
, args = userRule.slice(1)
|
|
, error;
|
|
|
|
error = $.idealforms._format.apply(null, [
|
|
$.idealforms._getKey('errors.'+ input.name +'.'+ rule, self.opts) ||
|
|
$.idealforms.errors[rule]
|
|
].concat(args));
|
|
|
|
valid = typeof theRule == 'function'
|
|
? theRule.apply(self, [input, input.value].concat(args))
|
|
: theRule.test(input.value);
|
|
|
|
$field.data('idealforms-valid', valid);
|
|
|
|
if (handleError) self._handleError(input, error, valid);
|
|
if (handleStyle) self._handleStyle(input, valid);
|
|
|
|
self.opts.onValidate.call(self, input, rule, valid);
|
|
|
|
return valid;
|
|
});
|
|
}
|
|
|
|
this._inject('_validate', input, rule, valid);
|
|
|
|
return valid;
|
|
}
|
|
|
|
};
|
|
|
|
},{}],14:[function(require,module,exports){
|
|
/**
|
|
* Public methods
|
|
*/
|
|
module.exports = {
|
|
|
|
addRules: function(rules) {
|
|
|
|
var self = this;
|
|
|
|
var $inputs = this.$form.find($.map(rules, function(_, name) {
|
|
return '[name="'+ name +'"]';
|
|
}).join(','));
|
|
|
|
$.extend(this.opts.rules, rules);
|
|
|
|
$inputs.each(function(){ self._buildField(this) });
|
|
|
|
this.$inputs = this.$inputs
|
|
.add($inputs)
|
|
.each(function(){ self._validate(this, true) });
|
|
|
|
this.$fields.find(this.opts.error).hide();
|
|
|
|
this._inject('addRules');
|
|
},
|
|
|
|
getInvalid: function() {
|
|
return this.$fields.filter(function() {
|
|
return $(this).data('idealforms-valid') === false;
|
|
});
|
|
},
|
|
|
|
focusFirstInvalid: function() {
|
|
|
|
var firstInvalid = this._getFirstInvalid()[0];
|
|
|
|
if (firstInvalid) {
|
|
this._handleError(firstInvalid);
|
|
this._handleStyle(firstInvalid);
|
|
this._inject('focusFirstInvalid', firstInvalid);
|
|
firstInvalid.focus();
|
|
}
|
|
},
|
|
|
|
isValid: function(name) {
|
|
if (name) return ! this.getInvalid().find('[name="'+ name +'"]').length;
|
|
return ! this.getInvalid().length;
|
|
},
|
|
|
|
reset: function(name) {
|
|
|
|
var self = this
|
|
, $inputs = this.$inputs;
|
|
|
|
if (name) $inputs = $inputs.filter('[name="'+ name +'"]');
|
|
|
|
$inputs.filter('input:not(:checkbox, :radio)').val('');
|
|
$inputs.filter(':checkbox, :radio').prop('checked', false);
|
|
$inputs.filter('select').find('option').prop('selected', function() {
|
|
return this.defaultSelected;
|
|
});
|
|
|
|
$inputs.change().each(function(){ self._resetErrorAndStyle(this) });
|
|
|
|
this._inject('reset', name);
|
|
}
|
|
|
|
};
|
|
|
|
},{}],15:[function(require,module,exports){
|
|
/**
|
|
* Rules
|
|
*/
|
|
module.exports = {
|
|
|
|
required: /.+/,
|
|
digits: /^\d+$/,
|
|
email: /^[^@]+@[^@]+\..{2,6}$/,
|
|
username: /^[a-z](?=[\w.]{3,31}$)\w*\.?\w*$/i,
|
|
pass: /(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}/,
|
|
strongpass: /(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/,
|
|
phone: /^[2-9]\d{2}-\d{3}-\d{4}$/,
|
|
zip: /^\d{5}$|^\d{5}-\d{4}$/,
|
|
url: /^(?:(ftp|http|https):\/\/)?(?:[\w\-]+\.)+[a-z]{2,6}([\:\/?#].*)?$/i,
|
|
|
|
number: function(input, value) {
|
|
return !isNaN(value);
|
|
},
|
|
|
|
range: function(input, value, mix, max) {
|
|
return Number(value) >= min && Number(value) <= max;
|
|
},
|
|
|
|
min: function(input, value, min) {
|
|
return value.length >= min;
|
|
},
|
|
|
|
max: function(input, value, max) {
|
|
return value.length <= max;
|
|
},
|
|
|
|
minoption: function(input, value, min) {
|
|
return this._getRelated(input).filter(':checked').length >= min;
|
|
},
|
|
|
|
maxoption: function(input, value, max) {
|
|
return this._getRelated(input).filter(':checked').length <= max;
|
|
},
|
|
|
|
minmax: function(input, value, min, max) {
|
|
return value.length >= min && value.length <= max;
|
|
},
|
|
|
|
select: function(input, value, def) {
|
|
return value != def;
|
|
},
|
|
|
|
extension: function(input) {
|
|
|
|
var extensions = [].slice.call(arguments, 1)
|
|
, valid = false;
|
|
|
|
$.each(input.files || [{name: input.value}], function(i, file) {
|
|
valid = $.inArray(file.name.match(/\.(.+)$/)[1], extensions) > -1;
|
|
});
|
|
|
|
return valid;
|
|
},
|
|
|
|
equalto: function(input, value, target) {
|
|
|
|
var self = this
|
|
, $target = $('[name="'+ target +'"]');
|
|
|
|
if (this.getInvalid().find($target).length) return false;
|
|
|
|
$target.off('keyup.equalto').on('keyup.equalto', function() {
|
|
self._validate(input, false, true);
|
|
});
|
|
|
|
return input.value == $target.val();
|
|
},
|
|
|
|
date: function(input, value, format) {
|
|
|
|
format = format || 'mm/dd/yyyy';
|
|
|
|
var delimiter = /[^mdy]/.exec(format)[0]
|
|
, theFormat = format.split(delimiter)
|
|
, theDate = value.split(delimiter);
|
|
|
|
function isDate(date, format) {
|
|
|
|
var m, d, y;
|
|
|
|
for (var i = 0, len = format.length; i < len; i++) {
|
|
if (/m/.test(format[i])) m = date[i];
|
|
if (/d/.test(format[i])) d = date[i];
|
|
if (/y/.test(format[i])) y = date[i];
|
|
}
|
|
|
|
if (!m || !d || !y) return false;
|
|
|
|
return m > 0 && m < 13 &&
|
|
y && y.length == 4 &&
|
|
d > 0 && d <= (new Date(y, m, 0)).getDate();
|
|
}
|
|
|
|
return isDate(theDate, theFormat);
|
|
}
|
|
|
|
};
|
|
|
|
},{}]},{},[11])
|
|
//@ sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2VuZXJhdGVkLmpzIiwic291cmNlcyI6WyIvdmFyL3d3dy9qcS1pZGVhbGZvcm1zL2pzL2Vycm9ycy5qcyIsIi92YXIvd3d3L2pxLWlkZWFsZm9ybXMvanMvZXh0ZW5zaW9ucy9hZGFwdGl2ZS9hZGFwdGl2ZS5leHQuanMiLCIvdmFyL3d3dy9qcS1pZGVhbGZvcm1zL2pzL2V4dGVuc2lvbnMvYWpheC9hamF4LmV4dC5qcyIsIi92YXIvd3d3L2pxLWlkZWFsZm9ybXMvanMvZXh0ZW5zaW9ucy9jdXN0b20taW5wdXRzL2N1c3RvbS1pbnB1dHMuZXh0LmpzIiwiL3Zhci93d3cvanEtaWRlYWxmb3Jtcy9qcy9leHRlbnNpb25zL2N1c3RvbS1pbnB1dHMvaWRlYWxmaWxlLmpzIiwiL3Zhci93d3cvanEtaWRlYWxmb3Jtcy9qcy9leHRlbnNpb25zL2N1c3RvbS1p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bG93IHRoZSBpbnB1dFxuICAgICAgaWYgKGpRdWVyeS51aSkge1xuICAgICAgICAkLmRhdGVwaWNrZXIuX2NoZWNrT2Zmc2V0ID0gZnVuY3Rpb24oYSxiLGMpeyByZXR1cm4gYiB9O1xuICAgICAgfVxuXG4gICAgICBpZiAoalF1ZXJ5LnVpICYmICRkYXRlcGlja2VyLmxlbmd0aCkge1xuXG4gICAgICAgICRkYXRlcGlja2VyLmVhY2goZnVuY3Rpb24oKSB7XG5cbiAgICAgICAgICAkKHRoaXMpLmRhdGVwaWNrZXIoe1xuICAgICAgICAgICAgYmVmb3JlU2hvdzogZnVuY3Rpb24oaW5wdXQpIHtcbiAgICAgICAgICAgICAgJChpbnB1dCkuYWRkQ2xhc3MoJ29wZW4nKTtcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBvbkNoYW5nZU1vbnRoWWVhcjogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgIC8vIEhhY2sgdG8gZml4IElFOSBub3QgcmVzaXppbmdcbiAgICAgICAgICAgICAgdmFyICR0aGlzID0gJCh0aGlzKVxuICAgICAgICAgICAgICAgICwgd2lkdGggPSAkdGhpcy5vdXRlcldpZHRoKCk7IC8vIGNhY2hlIGZpcnN0IVxuICAgICAgICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICR0aGlzLmRhdGVwaWNrZXIoJ3dpZGdldCcpLmNzcygnd2lkdGgnLCB3aWR0aCk7XG4gICAgICAgICAgICAgIH0sIDEpO1xuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIG9uQ2xvc2U6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAkKHRoaXMpLnJlbW92ZUNsYXNzKCdvcGVuJyk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSk7XG4gICAgICAgIH0pO1xuXG4gICAgICAgIC8vIEFkanVzdCB3aWR0aFxuICAgICAgICAkZGF0ZXBpY2tlci5vbignZm9jdX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