Resetting didn't like the new docs.
This commit is contained in:
		| @@ -99,48 +99,40 @@ function notify(target, type, msg, duration) { | |||||||
|  * @param {Number} duration The number of miliseconds to show the error. Default is 4000. -1 is infinite. |  * @param {Number} duration The number of miliseconds to show the error. Default is 4000. -1 is infinite. | ||||||
|  * @returns {HTMLElement} The created notification HTMLElement. |  * @returns {HTMLElement} The created notification HTMLElement. | ||||||
|  */ |  */ | ||||||
| function error(msg, duration = 4000) { |  HTMLElement.prototype.error = function(msg, duration = 4000) { | ||||||
|     return notify(this, "error", msg, duration); |     return notify(this, "error", msg, duration); | ||||||
| } | } | ||||||
|  |  | ||||||
| HTMLElement.prototype.error = error; |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Shows a warning message on a given HTMLElement. |  * Shows a warning message on a given HTMLElement. | ||||||
|  * @param {string|Function} msg The warning message to show. |  * @param {string|Function} msg The warning message to show. | ||||||
|  * @param {Number} duration The number of miliseconds to show the warning. Default is 4000. -1 is infinite. |  * @param {Number} duration The number of miliseconds to show the warning. Default is 4000. -1 is infinite. | ||||||
|  * @returns {HTMLElement} The created notification HTMLElement. |  * @returns {HTMLElement} The created notification HTMLElement. | ||||||
|  */ |  */ | ||||||
| function warning(msg, duration = 4000) { |  HTMLElement.prototype.warning = function(msg, duration = 4000) { | ||||||
|     return notify(this, "warning", msg, duration); |     return notify(this, "warning", msg, duration); | ||||||
| } | } | ||||||
|  |  | ||||||
| HTMLElement.prototype.warning = warning; |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Shows a success message on a given HTMLElement. |  * Shows a success message on a given HTMLElement. | ||||||
|  * @param {string|Function} msg The success message to show. |  * @param {string|Function} msg The success message to show. | ||||||
|  * @param {Number} duration The number of miliseconds to show the notification. Default is 4000. -1 is infinite. |  * @param {Number} duration The number of miliseconds to show the notification. Default is 4000. -1 is infinite. | ||||||
|  * @returns {HTMLElement} The created notification HTMLElement. |  * @returns {HTMLElement} The created notification HTMLElement. | ||||||
|  */ |  */ | ||||||
| function success(msg, duration = 4000) { |  HTMLElement.prototype.success = function(msg, duration = 4000) { | ||||||
|     return notify(this, "success", msg, duration); |     return notify(this, "success", msg, duration); | ||||||
| } | } | ||||||
|  |  | ||||||
| HTMLElement.prototype.success = success; |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Shows a info message on a given HTMLElement. |  * Shows a info message on a given HTMLElement. | ||||||
|  * @param {string|Function} msg The info message to show. |  * @param {string|Function} msg The info message to show. | ||||||
|  * @param {Number} duration The number of miliseconds to show the notification. Default is 4000. -1 is infinite. |  * @param {Number} duration The number of miliseconds to show the notification. Default is 4000. -1 is infinite. | ||||||
|  * @returns {HTMLElement} The created notification HTMLElement. |  * @returns {HTMLElement} The created notification HTMLElement. | ||||||
|  */ |  */ | ||||||
| function info(msg, duration = 4000) { |  HTMLElement.prototype.info = function(msg, duration = 4000) { | ||||||
|     notify(this, "info", msg, duration); |     notify(this, "info", msg, duration); | ||||||
| } | } | ||||||
|  |  | ||||||
| HTMLElement.prototype.info = info; |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Validates an input when changed. |  * Validates an input when changed. | ||||||
|  * @param {Function|IgniteProperty} callback The callback function to invoke in order to validate changes to an input. |  * @param {Function|IgniteProperty} callback The callback function to invoke in order to validate changes to an input. | ||||||
| @@ -152,7 +144,7 @@ HTMLElement.prototype.info = info; | |||||||
|  * }) |  * }) | ||||||
|  * @returns {IgniteTemplate} This ignite template. |  * @returns {IgniteTemplate} This ignite template. | ||||||
|  */ |  */ | ||||||
| function validate(callback) { |  IgniteTemplate.prototype.validate = function(callback) { | ||||||
|     //Setup the validators array if it doesn't exist. |     //Setup the validators array if it doesn't exist. | ||||||
|     if (!this._validators) { |     if (!this._validators) { | ||||||
|         this._validators = []; |         this._validators = []; | ||||||
| @@ -207,14 +199,12 @@ function validate(callback) { | |||||||
|     return this; |     return this; | ||||||
| } | } | ||||||
|  |  | ||||||
| IgniteTemplate.prototype.validate = validate; |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Validates an input to make sure it contains a valid email address. |  * Validates an input to make sure it contains a valid email address. | ||||||
|  * @param {string|Function|IgniteProperty} msg The message to display when the email is incorrect. If null a default one will show.  |  * @param {string|Function|IgniteProperty} msg The message to display when the email is incorrect. If null a default one will show.  | ||||||
|  * @returns {IgniteTemplate} This ignite template. |  * @returns {IgniteTemplate} This ignite template. | ||||||
|  */ |  */ | ||||||
| function validateEmail(msg) { |  IgniteTemplate.prototype.validateEmail = function(msg) { | ||||||
|     return this.validate((value, error) => { |     return this.validate((value, error) => { | ||||||
|         if (!value || value.trim().length < 5) { |         if (!value || value.trim().length < 5) { | ||||||
|             return error(msg ? msg : `Email address too short.`); |             return error(msg ? msg : `Email address too short.`); | ||||||
| @@ -230,14 +220,12 @@ function validateEmail(msg) { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
|  |  | ||||||
| IgniteTemplate.prototype.validateEmail = validateEmail; |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Validates an input to make sure it contains a valid password. |  * Validates an input to make sure it contains a valid password. | ||||||
|  * @param {string|Function|IgniteProperty} msg The message to display when the email is incorrect. If null a default one will show. |  * @param {string|Function|IgniteProperty} msg The message to display when the email is incorrect. If null a default one will show. | ||||||
|  * @returns {IgniteTemplate} This ignite template. |  * @returns {IgniteTemplate} This ignite template. | ||||||
|  */ |  */ | ||||||
| function validatePassword(msg) { |  IgniteTemplate.prototype.validatePassword = function(msg) { | ||||||
|     return this.validate((value, error) => { |     return this.validate((value, error) => { | ||||||
|         if (!value || value.trim().length < 5) { |         if (!value || value.trim().length < 5) { | ||||||
|             return error(msg ? msg : `Password is too short.`); |             return error(msg ? msg : `Password is too short.`); | ||||||
| @@ -249,15 +237,13 @@ function validatePassword(msg) { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
|  |  | ||||||
| IgniteTemplate.prototype.validatePassword = validatePassword; |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Validates an input to make sure it contains a min number of characters. |  * Validates an input to make sure it contains a min number of characters. | ||||||
|  * @param {Number} min The min number of characters the input can have. |  * @param {Number} min The min number of characters the input can have. | ||||||
|  * @param {string|Function|IgniteProperty} msg The message to display when the input length is too short. If null a default one will show.  |  * @param {string|Function|IgniteProperty} msg The message to display when the input length is too short. If null a default one will show.  | ||||||
|  * @returns {IgniteTemplate} This ignite template. |  * @returns {IgniteTemplate} This ignite template. | ||||||
|  */ |  */ | ||||||
| function validateMin(min, msg) { |  IgniteTemplate.prototype.validateMin = function(min, msg) { | ||||||
|     return this.validate((value, error) => { |     return this.validate((value, error) => { | ||||||
|         if (!value || value.toString().trim().length < min) { |         if (!value || value.toString().trim().length < min) { | ||||||
|             return error(msg ? msg : `Input must contain at least ${min} character(s).`); |             return error(msg ? msg : `Input must contain at least ${min} character(s).`); | ||||||
| @@ -265,15 +251,13 @@ function validateMin(min, msg) { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
|  |  | ||||||
| IgniteTemplate.prototype.validateMin = validateMin; |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Validates an input to make sure it contains a max number of characters. |  * Validates an input to make sure it contains a max number of characters. | ||||||
|  * @param {Number} max The max number of characters the input can have. |  * @param {Number} max The max number of characters the input can have. | ||||||
|  * @param {string|Function|IgniteProperty} msg The message to display when the input length is too long. If null a default one will show.  |  * @param {string|Function|IgniteProperty} msg The message to display when the input length is too long. If null a default one will show.  | ||||||
|  * @returns {IgniteTemplate} This ignite template. |  * @returns {IgniteTemplate} This ignite template. | ||||||
|  */ |  */ | ||||||
| function validateMax(max, msg) { |  IgniteTemplate.prototype.validateMax = function(max, msg) { | ||||||
|     return this.validate((value, error) => { |     return this.validate((value, error) => { | ||||||
|         if (!value || value.toString().trim().length > max) { |         if (!value || value.toString().trim().length > max) { | ||||||
|             return error(msg ? msg : `Input must contain less than ${max} character(s).`); |             return error(msg ? msg : `Input must contain less than ${max} character(s).`); | ||||||
| @@ -281,15 +265,13 @@ function validateMax(max, msg) { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
|  |  | ||||||
| IgniteTemplate.prototype.validateMax = validateMax; |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Validates an input to make sure it it's value is not the given value. |  * Validates an input to make sure it it's value is not the given value. | ||||||
|  * @param {Any} expected The value the input cannot have in order to be considered valid. |  * @param {Any} expected The value the input cannot have in order to be considered valid. | ||||||
|  * @param {string|Function|IgniteProperty} msg The message to display when the input length is too long. If null a deafult one will show. |  * @param {string|Function|IgniteProperty} msg The message to display when the input length is too long. If null a default one will show. | ||||||
|  * @returns {IgniteTemplate} This ignite template.  |  * @returns {IgniteTemplate} This ignite template.  | ||||||
|  */ |  */ | ||||||
| function validateNot(expected, msg) { |  IgniteTemplate.prototype.validateNot = function(expected, msg) { | ||||||
|     return this.validate((value, error) => { |     return this.validate((value, error) => { | ||||||
|         if (!value || value == expected) { |         if (!value || value == expected) { | ||||||
|             return error(msg ? msg : `Input cannot be ${expected}.`); |             return error(msg ? msg : `Input cannot be ${expected}.`); | ||||||
| @@ -297,15 +279,13 @@ function validateNot(expected, msg) { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
|  |  | ||||||
| IgniteTemplate.prototype.validateNot = validateNot; |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Validates an input to make sure it includes a string. |  * Validates an input to make sure it includes a string. | ||||||
|  * @param {string} str The string that the input must include.  |  * @param {string} str The string that the input must include.  | ||||||
|  * @param {string|Function|IgniteProperty} msg The message to display when the input doesn't contain the string. If null a default one will show.  |  * @param {string|Function|IgniteProperty} msg The message to display when the input doesn't contain the string. If null a default one will show.  | ||||||
|  * @returns {IgniteTemplate} This ignite template. |  * @returns {IgniteTemplate} This ignite template. | ||||||
|  */ |  */ | ||||||
| function validateIncludes(str, msg) { |  IgniteTemplate.prototype.validateIncludes = function(str, msg) { | ||||||
|     return this.validate((value, error) => { |     return this.validate((value, error) => { | ||||||
|         if (!value || !value.toString().includes(str)) { |         if (!value || !value.toString().includes(str)) { | ||||||
|             return error(msg ? msg : `Input must contain ${str}.`); |             return error(msg ? msg : `Input must contain ${str}.`); | ||||||
| @@ -313,15 +293,13 @@ function validateIncludes(str, msg) { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
|  |  | ||||||
| IgniteTemplate.prototype.validateIncludes = validateIncludes; |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Validates an input to make sure it matches a given value. |  * Validates an input to make sure it matches a given value. | ||||||
|  * @param {string|Function|IgniteProperty} compare The value to compare against the input. |  * @param {string|Function|IgniteProperty} compare The value to compare against the input. | ||||||
|  * @param {string|Function|IgniteProperty} msg The message to display when the input doesn't match. If null a default one will show. |  * @param {string|Function|IgniteProperty} msg The message to display when the input doesn't match. If null a default one will show. | ||||||
|  * @returns {IgniteTemplate} This ignite template.  |  * @returns {IgniteTemplate} This ignite template.  | ||||||
|  */ |  */ | ||||||
| function validateMatches(compare, msg) { |  IgniteTemplate.prototype.validateMatches = function(compare, msg) { | ||||||
|     return this.validate((value, error) => { |     return this.validate((value, error) => { | ||||||
|         if (compare instanceof Function) { |         if (compare instanceof Function) { | ||||||
|             if (compare() != value) { |             if (compare() != value) { | ||||||
| @@ -337,13 +315,11 @@ function validateMatches(compare, msg) { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
|  |  | ||||||
| IgniteTemplate.prototype.validateMatches = validateMatches; |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Validates all the children of an element and returns if they are valid or not. |  * Validates all the children of an element and returns if they are valid or not. | ||||||
|  * @returns {Boolean} Whether or not all the children of this element are valid. |  * @returns {Boolean} Whether or not all the children of this element are valid. | ||||||
|  */ |  */ | ||||||
| function validateAll() { |  HTMLElement.prototype.validateAll = function() { | ||||||
|     var elements = this.getElementsByTagName("*"); |     var elements = this.getElementsByTagName("*"); | ||||||
|     for (var i = 0; i < elements.length; i++) { |     for (var i = 0; i < elements.length; i++) { | ||||||
|         if (elements[i].validate != undefined && !elements[i].validate()) { |         if (elements[i].validate != undefined && !elements[i].validate()) { | ||||||
| @@ -352,5 +328,3 @@ function validateAll() { | |||||||
|     } |     } | ||||||
|     return true; |     return true; | ||||||
| } | } | ||||||
|  |  | ||||||
| HTMLElement.prototype.validateAll = validateAll; |  | ||||||
		Reference in New Issue
	
	Block a user