vendor/assets/js/foundation.abide.js.es6 in foundation-rails-6.3.1.0 vs vendor/assets/js/foundation.abide.js.es6 in foundation-rails-6.4.1.0
- old
+ new
@@ -1,29 +1,30 @@
'use strict';
-!function($) {
+import $ from 'jquery';
+import { Plugin } from './foundation.plugin';
/**
* Abide module.
* @module foundation.abide
*/
-class Abide {
+class Abide extends Plugin {
/**
* Creates a new instance of Abide.
* @class
+ * @name Abide
* @fires Abide#init
* @param {Object} element - jQuery object to add the trigger to.
* @param {Object} options - Overrides to the default plugin settings.
*/
- constructor(element, options = {}) {
+ _setup(element, options = {}) {
this.$element = element;
this.options = $.extend({}, Abide.defaults, this.$element.data(), options);
+ this.className = 'Abide'; // ie9 back compat
this._init();
-
- Foundation.registerPlugin(this, 'Abide');
}
/**
* Initializes the Abide plugin and calls functions to get Abide functioning on load.
* @private
@@ -240,11 +241,11 @@
$el.removeClass(this.options.inputErrorClass).removeAttr('data-invalid');
}
/**
- * Goes through a form to find inputs and proceeds to validate them in ways specific to their type.
+ * Goes through a form to find inputs and proceeds to validate them in ways specific to their type.
* Ignores inputs with data-abide-ignore, type="hidden" or disabled attributes set
* @fires Abide#invalid
* @fires Abide#valid
* @param {Object} element - jQuery object to validate, should be an HTML input
* @returns {Boolean} goodToGo - If the input is valid or not.
@@ -451,11 +452,11 @@
/**
* Destroys an instance of Abide.
* Removes error styles and classes from elements, without resetting their values.
*/
- destroy() {
+ _destroy() {
var _this = this;
this.$element
.off('.abide')
.find('[data-abide-error]')
.css('display', 'none');
@@ -463,12 +464,10 @@
this.$inputs
.off('.abide')
.each(function() {
_this.removeErrorClasses($(this));
});
-
- Foundation.unregisterPlugin(this);
}
}
/**
* Default settings for plugin
@@ -536,11 +535,11 @@
alpha_numeric : /^[a-zA-Z0-9]+$/,
integer : /^[-+]?\d+$/,
number : /^[-+]?\d*(?:[\.\,]\d+)?$/,
// amex, visa, diners
- card : /^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$/,
+ card : /^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|(?:222[1-9]|2[3-6][0-9]{2}|27[0-1][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$/,
cvv : /^([0-9]){3,4}$/,
// http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#valid-e-mail-address
email : /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+$/,
@@ -558,11 +557,18 @@
month_day_year : /^(0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])[- \/.]\d{4}$/,
// DD/MM/YYYY
day_month_year : /^(0[1-9]|[12][0-9]|3[01])[- \/.](0[1-9]|1[012])[- \/.]\d{4}$/,
// #FFF or #FFFFFF
- color : /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/
+ color : /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/,
+
+ // Domain || URL
+ website: {
+ test: (text) => {
+ return Abide.defaults.patterns['domain'].test(text) || Abide.defaults.patterns['url'].test(text);
+ }
+ }
},
/**
* Optional validation functions to be used. `equalTo` being the only default included function.
* Functions should return only a boolean if the input is valid or not. Functions are given the following arguments:
@@ -576,9 +582,6 @@
return $(`#${el.attr('data-equalto')}`).val() === el.val();
}
}
}
-// Window exports
-Foundation.plugin(Abide, 'Abide');
-
-}(jQuery);
+export {Abide};