From e692072985a92dab16f80885cfc844f974df51c1 Mon Sep 17 00:00:00 2001 From: elclanrs Date: Mon, 7 Oct 2013 18:53:16 -0400 Subject: [PATCH] readme... --- js/out/jquery.idealforms.js | 1294 ----------------------------------- 1 file changed, 1294 deletions(-) diff --git a/js/out/jquery.idealforms.js b/js/out/jquery.idealforms.js index bf880a7..e69de29 100644 --- a/js/out/jquery.idealforms.js +++ b/js/out/jquery.idealforms.js @@ -1,1294 +0,0 @@ -;(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').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); - } - - $('#ui-datepicker-div').hide(); - } - - $(window).resize(adapt); - adapt(); - - this.$form.find('select, .datepicker').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 $('')[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 = $('
') - , $input = $('') - // Button that will be used in non-IE browsers - , $button = $('') - // Hack for IE - , $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.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'); - - // 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:'\ -
\ - \ - {field}\ - \ -
\ - ', - - text: '', - - file: '', - - textarea: '', - - group: '\ -

\ - {@list}\ - \ - {/list}\ -

\ - ', - - select: '\ - \ - ' - } - }, - - methods: { - - addFields: function(fields) { - - var self = this; - - $.each(fields, function(name, field) { - - var typeArray = field.type.split(':') - , rules = {} - , $last = self.$form.find(self.opts.field).last(); - - field.name = name; - field.type = typeArray[0]; - if (typeArray[1]) field.subtype = typeArray[1]; - - field.html = template(self.opts.templates.base, { - label: field.label, - field: template(self.opts.templates[field.type], field) - }); - - self._inject('addFields', field); - - if (field.after || field.before) { - self.$form.find('[name="'+ (field.after || field.before) +'"]').first().each(function() { - self._getField(this)[field.after ? 'after' : 'before'](field.html); - }); - } else { - // Form has at least one field - if ($last.length) $last.after(field.html); - // Form has no fields - else self.$form.append(field.html); - } - - if (field.rules) { - rules[name] = field.rules; - self.addRules(rules); - } - }); - - }, - - 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(e) { - e.preventDefault(); - self.go(self.$navItems.index(this)); - }); - }, - - _buildNavItems: function() { - - var self = this, - isCustom = typeof this.opts.buildNavItems == 'function', - item = function(val){ return '
  • '+ val +'
  • '; }, - 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($('
      ').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: { - steps: { - container: '.idealsteps-container', - nav: '.idealsteps-nav', - navItems: 'li', - buildNavItems: function(i) { - return 'Step '+ (i+1); - }, - wrap: '.idealsteps-wrap', - step: '.idealsteps-step', - activeClass: 'idealsteps-step-active', - before: null, - after: null, - fadeSpeed: 0 - } - }, - - 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) - , buildNavItems = this.opts.steps.buildNavItems - , counter = hasRules - ? '' - : '0'; - - if (this.opts.steps.buildNavItems) { - this.opts.steps.buildNavItems = function(i) { - return buildNavItems(i) + counter; - }; - } - - this.$stepsContainer = this.$form - .closest(this.opts.steps.container) - .idealsteps(this.opts.steps); - }, - - _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 - addFields: function(field) { - field.after = this.$stepsContainer - .find(this.opts.steps.step) - .eq(field.appendToStep) - .find('input, textarea, select') - .last()[0].name; - }, - - // @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: '', - 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2VuZXJhdGVkLmpzIiwic291cmNlcyI6WyIvdmFyL3d3dy9qcS1pZGVhbGZvcm1zL2pzL2Vycm9ycy5qcyIsIi92YXIvd3d3L2pxLWlkZWFsZm9ybXMvanMvZXh0ZW5zaW9ucy9hZGFwdGl2ZS9hZGFwdGl2ZS5leHQuanMiLCIvdmFyL3d3dy9qcS1pZGVhbGZvcm1zL2pzL2V4dGVuc2lvbnMvYWphe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