Comparing version 0.1.2 to 0.1.3
{ | ||
"name": "vivalid", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"homepage": "https://github.com/pazams/vivalid", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -1,2 +0,2 @@ | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.vivalid = f()}})(function(){var define,module,exports;return (require=(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);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.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){ | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.vivalid = f()}})(function(){var define,module,exports;return (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);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.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){ | ||
module.exports = { | ||
@@ -590,4 +590,4 @@ VERSION: '0.1.0', | ||
errorDiv.parentNode.removeChild(errorDiv); | ||
el.style.borderStyle = null; | ||
el.style.borderColor = null; | ||
el.style.borderStyle = ""; | ||
el.style.borderColor = ""; | ||
} | ||
@@ -900,3 +900,2 @@ } | ||
var validatorRepo = require('./validator-repo'); | ||
var stateEnum = require('./state-enum'); | ||
var htmlInterface = require('./html-interface'); | ||
@@ -917,3 +916,3 @@ var constants = require('./constants'); | ||
},{"./constants":1,"./html-interface":3,"./input":5,"./input-group":4,"./state-enum":6,"./validator-repo":8}]},{},["vivalid"]))("vivalid") | ||
},{"./constants":1,"./html-interface":3,"./input":5,"./input-group":4,"./validator-repo":8}]},{},["vivalid"])("vivalid") | ||
}); |
@@ -1,1 +0,1 @@ | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.vivalid=t()}}(function(){return(require=function t(e,i,n){function a(r,o){if(!i[r]){if(!e[r]){var u="function"==typeof require&&require;if(!o&&u)return u(r,!0);if(s)return s(r,!0);var d=new Error("Cannot find module '"+r+"'");throw d.code="MODULE_NOT_FOUND",d}var l=i[r]={exports:{}};e[r][0].call(l.exports,function(t){var i=e[r][1][t];return a(i?i:t)},l,l.exports,t,e,i,n)}return i[r].exports}for(var s="function"==typeof require&&require,r=0;r<n.length;r++)a(n[r]);return a}({1:[function(t,e,i){e.exports={VERSION:"0.1.0",DEBUG:!1,validInputTagNames:["input","textarea","select"],keyStrokedInputTypes:["text","email","password","search"],ERROR:{mandatorySuccessFailure:"passing callbacks for onValidationSuccess and onValidationFailure is mandatory"}}},{}],2:[function(t,e,i){function n(t){return Array.prototype.slice.call(t)}function a(t){"loading"!=document.readyState?t():document.addEventListener("DOMContentLoaded",t)}function s(t,e){e||(e=document);for(var i=[],n=0;n<t.length;n++)for(var a=e.getElementsByTagName(t[n]),s=0;s<a.length;s++)i.push(a[s]);return i}function r(t,e){for(;t&&t!==document;t=t.parentNode)if(h(t,e))return t;return!1}function o(t,e){return n(t.getElementsByTagName("*")).filter(function(t){return h(t,e)?!0:void 0})}function u(){var t=document.createElement("div");return t.setAttribute("data-a-b","c"),!(!t.dataset||"c"!==t.dataset.aB)}function d(t,e){return t.nodeType!==Node.ELEMENT_NODE?!1:t.getAttribute("data-"+c(e))}function l(t,e){return t.nodeType!==Node.ELEMENT_NODE?!1:t.dataset[e]}function h(t,e){return t.nodeType===Node.ELEMENT_NODE&&t.hasAttribute("data-"+c(e))}function c(t){return t.replace(/([A-Z])/g,function(t){return"-"+t.toLowerCase()})}var p=u();e.exports={getDataSet:p?l:d,hasDataSet:h,getElementsByTagNames:s,getClosestParentByAttribute:r,getChildrenByAttribute:o,ready:a,toArray:n}},{}],3:[function(t,e,i){function n(t,e){if("function"!=typeof e)throw"error while trying to add a custom callback: argument must be a function";if(p[t])throw"error while trying to add a custom callback: "+t+" already exists";p[t]=e}function a(t){function e(){inputElems=l.getElementsByTagNames(c,t).filter(function(t){return l.hasDataSet(t,"vivalidTuples")}),r(t,inputElems)}l.ready(e)}function s(){function t(){function t(t,a){if(!t)throw"an input validation is missing a group, input id: "+a.id;t._groupId||(t._groupId=e++),i[t._groupId]||(i[t._groupId]=[],n[t._groupId]=t),i[t._groupId].push(a)}var e=1,i={},n={};l.getElementsByTagNames(c).filter(function(t){return l.hasDataSet(t,"vivalidTuples")}).forEach(function(e){t(l.getClosestParentByAttribute(e,"vivalidGroup"),e)});for(var a in i)r(n[a],i[a])}l.ready(t)}function r(t,e){var i,n,a=e.map(o),s=[null,null],r=[null,null];if(l.hasDataSet(t,"vivalidOnValidation")&&(s=JSON.parse(l.getDataSet(t,"vivalidOnValidation")),!Array.isArray(s)||2!==s.length))throw"data-vivalid-on-validation value should be an array of size 2";if(l.hasDataSet(t,"vivalidPendingUi")&&(r=JSON.parse(l.getDataSet(t,"vivalidPendingUi")),!Array.isArray(r)||2!==r.length))throw"data-vivalid-pending-ui value should be an array of size 2";l.hasDataSet(t,"vivalidStatesChanged")&&(i=l.getDataSet(t,"vivalidStatesChanged")),l.hasDataSet(t,"vivalidPendingChanged")&&(n=l.getDataSet(t,"vivalidPendingChanged")),new d(a,l.getChildrenByAttribute(t,"vivalidSubmit"),p[s[0]],p[s[1]],p[r[0]],p[r[1]],i,n)}function o(t){var e,i=JSON.parse(l.getDataSet(t,"vivalidTuples"));return l.hasDataSet(t,"vivalidResult")&&(e=l.getDataSet(t,"vivalidResult")),new u(t,i,p[e])}var u=t("./input"),d=t("./input-group"),l=t("./dom-helpers"),h=t("./constants"),c=h.validInputTagNames,p={};e.exports={addCallback:n,initAll:s,initGroup:a}},{"./constants":1,"./dom-helpers":2,"./input":5,"./input-group":4}],4:[function(t,e,i){function n(t,e,i,n,s,o,u,d){if(!i||!n)throw r.mandatorySuccessFailure;this.inputs=[],this.inputElems=[],this.submitElems=[],this.onValidationSuccess=i,this.onValidationFailure=n,this.pendingUiStart=s,this.pendingUiStop=o,this.groupStatesChanged=u,this.groupPendingChangedListeners=[],this.groupPendingChangedListeners.push(function(t){t||this.isPendingUiStartRun&&(this.pendingUiStop.call(this.pendingUiLastSubmitElem,this.inputElems,this.submitElems),this.getOnSubmit.call(this).call(this.pendingUiLastSubmitElem),this.isPendingUiStartRun=!1,this.pendingUiLastSubmitElem={})}.bind(this)),d&&this.groupPendingChangedListeners.push(d),this.stateCounters={},this.stateCounters[a.invalid]=0,this.stateCounters[a.pending]=0,this.stateCounters[a.valid]=0,this.isPendingChangeTrueRun=!1,this.isPendingUiStartRun=!1,this.pendingUiLastSubmitElem={},this.inputs=t.map(function(t){return t.setGroup(this),t},this),this.inputElems=t.map(function(t){return t.el}),this.stateCounters[a.valid]=t.length,this.submitElems=Array.prototype.slice.call(e),this.submitElems.forEach(function(t){t.addEventListener("click",this.getOnSubmit.call(this))},this)}var a=(t("./input"),t("./state-enum")),s=t("./constants").DEBUG,r=t("./constants").ERROR;n.prototype=function(){function t(){return this.triggerInputsValidation(),0===this.stateCounters[a.invalid]&&0===this.stateCounters[a.pending]}function e(){return this.triggerInputsValidation(),0===this.stateCounters[a.invalid]&&this.stateCounters[a.pending]>0}function i(){var t=this;return function(e){e&&e.preventDefault(),t.isPending()?(t.pendingUiStart.call(this,t.inputElems,t.submitElems),t.isPendingUiStartRun=!0,t.pendingUiLastSubmitElem=this):t.isValid()?t.onValidationSuccess.call(this):t.onValidationFailure.call(this,t.stateCounters[a.invalid],t.stateCounters[a.pending],t.stateCounters[a.valid]),s&&(console.debug("cuurent states:"),console.debug("invalid: "+t.stateCounters[a.invalid]),console.debug("pending: "+t.stateCounters[a.pending]),console.debug("valid: "+t.stateCounters[a.valid]))}}function n(){this.inputs.forEach(function(t){t.triggerValidation()})}function r(t,e){t.stateEnum!==e.stateEnum&&(this.stateCounters[t.stateEnum]--,this.stateCounters[e.stateEnum]++)}function o(){this.groupStatesChanged&&this.groupStatesChanged(),this.groupPendingChangedListeners.forEach(function(t){!this.isPendingChangeTrueRun&&0===this.stateCounters[a.invalid]&&this.stateCounters[a.pending]>0?(t(!0),this.isPendingChangeTrueRun=!0):this.isPendingChangeTrueRun&&0===this.stateCounters[a.pending]&&(t(!1),this.isPendingChangeTrueRun=!1)},this)}return{isValid:t,isPending:e,getOnSubmit:i,triggerInputsValidation:n,updateGroupListeners:o,updateGroupStates:r}}(),e.exports=n},{"./constants":1,"./input":5,"./state-enum":6}],5:[function(t,e,i){function n(t,e,i){function n(){var t=[];return e.forEach(function(e){var i=e[0],n=e[1];t.push({name:i,run:a.build(i,n)})}),t}function o(t,e,i,n){function a(t){return"vivalid-error"===t.nextSibling.className?t.nextSibling:void 0}function s(t,i){r=document.createElement("DIV"),r.className="vivalid-error",r.style.color="#ff0000";var n=document.createTextNode(e.message);r.appendChild(n),t.parentNode.insertBefore(r,t.nextSibling)}var r;if("input"===t.nodeName.toLowerCase()&&("radio"===t.type||"checkbox"===t.type)){var o=t.parentNode.querySelectorAll('input[name="'+t.name+'"]');t=o.item(o.length-1)}e.stateEnum===n.invalid?(r=a(t),r?r.textContent=e.message:s(t,e.message),t.style.borderStyle="solid",t.style.borderColor="#ff0000"):(r=a(t),r&&(r.parentNode.removeChild(r),t.style.borderStyle=null,t.style.borderColor=null))}if(-1===u.indexOf(t.nodeName.toLowerCase()))throw"only operates on the following html tags: "+u.toString();this.group={},this.el=t,this.validators=n(),this.onInputValidationResult=i||o,this.isNoneChecked=!1,this.validationState=new r("",s.valid),this.validationCycle=0,this.isChanged=!1,this.elName=t.nodeName.toLowerCase(),this.elType=t.type,this.isKeyed="textarea"===this.elName||d.indexOf(this.elType)>-1,this.activeEventType="",this._runValidatorsBounded=this.runValidators.bind(this),this.initListeners()}var a=t("./validator-repo"),s=t("./state-enum"),r=t("./validation-state"),o=t("./constants"),u=o.validInputTagNames,d=o.keyStrokedInputTypes;n.prototype=function(){function t(){if("input"===this.el.nodeName.toLowerCase()&&("radio"===this.el.type||"checkbox"===this.el.type)){var t=document.querySelector('input[name="'+this.el.name+'"]:checked');t?(this.el=t,this.isNoneChecked=!1):this.isNoneChecked=!0}}function e(){(0===this.validationCycle||this.isChanged)&&this._runValidatorsBounded()}function i(t){this.isKeyed&&t!==this.activeEventType&&(this.removeActiveEventType(),this.addEventType(t))}function n(t){this.group=t}function a(){this.addChangeListener(),this.isKeyed?this.addEventType("blur"):this.addEventType("change")}function o(t,e){this.validationCycle++,this.reBindCheckedElement();for(var i,n,a=e||0;a<this.validators.length;a++){var o=this.validators[a],u=this.isNoneChecked?"":this.el.value,d=o.run(u,this.getUpdateInputValidationResultAsync(o.name,a,this.validationCycle));if(d.stateEnum!==s.valid){i=d,n=o.name,this.changeEventType("input");break}}i=i||new r("",s.valid),this.updateInputValidationResult(i,n),this.isChanged=!1}function u(){if(this.isKeyed)this.el.addEventListener("input",function(){this.isChanged=!0},!1);else if("input"!==this.elName||"radio"!==this.elType&&"checkbox"!==this.elType)"select"===this.elName&&this.el.addEventListener("change",function(){this.isChanged=!0},!1);else for(var t=document.querySelectorAll('input[name="'+this.el.name+'"]'),e=0;e<t.length;e++)t[e].addEventListener("change",function(){this.isChanged=!0},!1)}function d(t){if(this.isKeyed)this.el.addEventListener(t,this._runValidatorsBounded,!1);else if("input"!==this.elName||"radio"!==this.elType&&"checkbox"!==this.elType)"select"===this.elName&&this.el.addEventListener(t,this._runValidatorsBounded,!1);else for(var e=document.querySelectorAll('input[name="'+this.el.name+'"]'),i=0;i<e.length;i++)e[i].addEventListener(t,this._runValidatorsBounded,!1);this.activeEventType=t}function l(){this.el.removeEventListener(this.activeEventType,this._runValidatorsBounded,!1)}function h(t,e,i){var n=this;return function(a){i&&i!==n.validationCycle||(a.stateEnum===s.valid&&e+1<n.validators.length?n._runValidatorsBounded(null,e+1):n.updateInputValidationResult(a,t))}}function c(t,e){this.group.updateGroupStates(this.validationState,t),this.group.updateGroupListeners(),this.validationState=t,this.onInputValidationResult(this.el,t,e,s)}return{reBindCheckedElement:t,triggerValidation:e,runValidators:o,changeEventType:i,initListeners:a,setGroup:n,addChangeListener:u,addEventType:d,removeActiveEventType:l,getUpdateInputValidationResultAsync:h,updateInputValidationResult:c}}(),e.exports=n},{"./constants":1,"./state-enum":6,"./validation-state":7,"./validator-repo":8}],6:[function(t,e,i){var n={invalid:1,pending:2,valid:3};e.exports=n},{}],7:[function(t,e,i){function n(t,e){this.message=t,this.stateEnum=e}e.exports=n},{}],8:[function(t,e,i){function n(t,e){if("function"!=typeof e)throw"error while trying to register a Validator: argument must be a function";o[t]=e}function a(t,e){if("function"!=typeof o[t])throw t+" does not exists. use addValidatorBuilder to add a new validation rule";return o[t](r,s,e)}var s=t("./state-enum"),r=t("./validation-state"),o={};e.exports={addBuilder:n,build:a}},{"./state-enum":6,"./validation-state":7}],vivalid:[function(t,e,i){"use strict";var n=t("./input"),a=t("./input-group"),s=t("./validator-repo"),r=(t("./state-enum"),t("./html-interface")),o=t("./constants");e.exports={VERSION:o.VERSION,Input:n,InputGroup:a,validatorRepo:s,htmlInterface:r,_ERROR:o.ERROR}},{"./constants":1,"./html-interface":3,"./input":5,"./input-group":4,"./state-enum":6,"./validator-repo":8}]},{},["vivalid"]))("vivalid")}); | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.vivalid=t()}}(function(){return function t(e,i,n){function a(r,o){if(!i[r]){if(!e[r]){var u="function"==typeof require&&require;if(!o&&u)return u(r,!0);if(s)return s(r,!0);var d=new Error("Cannot find module '"+r+"'");throw d.code="MODULE_NOT_FOUND",d}var l=i[r]={exports:{}};e[r][0].call(l.exports,function(t){var i=e[r][1][t];return a(i?i:t)},l,l.exports,t,e,i,n)}return i[r].exports}for(var s="function"==typeof require&&require,r=0;r<n.length;r++)a(n[r]);return a}({1:[function(t,e,i){e.exports={VERSION:"0.1.0",DEBUG:!1,validInputTagNames:["input","textarea","select"],keyStrokedInputTypes:["text","email","password","search"],ERROR:{mandatorySuccessFailure:"passing callbacks for onValidationSuccess and onValidationFailure is mandatory"}}},{}],2:[function(t,e,i){function n(t){return Array.prototype.slice.call(t)}function a(t){"loading"!=document.readyState?t():document.addEventListener("DOMContentLoaded",t)}function s(t,e){e||(e=document);for(var i=[],n=0;n<t.length;n++)for(var a=e.getElementsByTagName(t[n]),s=0;s<a.length;s++)i.push(a[s]);return i}function r(t,e){for(;t&&t!==document;t=t.parentNode)if(h(t,e))return t;return!1}function o(t,e){return n(t.getElementsByTagName("*")).filter(function(t){return h(t,e)?!0:void 0})}function u(){var t=document.createElement("div");return t.setAttribute("data-a-b","c"),!(!t.dataset||"c"!==t.dataset.aB)}function d(t,e){return t.nodeType!==Node.ELEMENT_NODE?!1:t.getAttribute("data-"+c(e))}function l(t,e){return t.nodeType!==Node.ELEMENT_NODE?!1:t.dataset[e]}function h(t,e){return t.nodeType===Node.ELEMENT_NODE&&t.hasAttribute("data-"+c(e))}function c(t){return t.replace(/([A-Z])/g,function(t){return"-"+t.toLowerCase()})}var p=u();e.exports={getDataSet:p?l:d,hasDataSet:h,getElementsByTagNames:s,getClosestParentByAttribute:r,getChildrenByAttribute:o,ready:a,toArray:n}},{}],3:[function(t,e,i){function n(t,e){if("function"!=typeof e)throw"error while trying to add a custom callback: argument must be a function";if(p[t])throw"error while trying to add a custom callback: "+t+" already exists";p[t]=e}function a(t){function e(){inputElems=l.getElementsByTagNames(c,t).filter(function(t){return l.hasDataSet(t,"vivalidTuples")}),r(t,inputElems)}l.ready(e)}function s(){function t(){function t(t,a){if(!t)throw"an input validation is missing a group, input id: "+a.id;t._groupId||(t._groupId=e++),i[t._groupId]||(i[t._groupId]=[],n[t._groupId]=t),i[t._groupId].push(a)}var e=1,i={},n={};l.getElementsByTagNames(c).filter(function(t){return l.hasDataSet(t,"vivalidTuples")}).forEach(function(e){t(l.getClosestParentByAttribute(e,"vivalidGroup"),e)});for(var a in i)r(n[a],i[a])}l.ready(t)}function r(t,e){var i,n,a=e.map(o),s=[null,null],r=[null,null];if(l.hasDataSet(t,"vivalidOnValidation")&&(s=JSON.parse(l.getDataSet(t,"vivalidOnValidation")),!Array.isArray(s)||2!==s.length))throw"data-vivalid-on-validation value should be an array of size 2";if(l.hasDataSet(t,"vivalidPendingUi")&&(r=JSON.parse(l.getDataSet(t,"vivalidPendingUi")),!Array.isArray(r)||2!==r.length))throw"data-vivalid-pending-ui value should be an array of size 2";l.hasDataSet(t,"vivalidStatesChanged")&&(i=l.getDataSet(t,"vivalidStatesChanged")),l.hasDataSet(t,"vivalidPendingChanged")&&(n=l.getDataSet(t,"vivalidPendingChanged")),new d(a,l.getChildrenByAttribute(t,"vivalidSubmit"),p[s[0]],p[s[1]],p[r[0]],p[r[1]],i,n)}function o(t){var e,i=JSON.parse(l.getDataSet(t,"vivalidTuples"));return l.hasDataSet(t,"vivalidResult")&&(e=l.getDataSet(t,"vivalidResult")),new u(t,i,p[e])}var u=t("./input"),d=t("./input-group"),l=t("./dom-helpers"),h=t("./constants"),c=h.validInputTagNames,p={};e.exports={addCallback:n,initAll:s,initGroup:a}},{"./constants":1,"./dom-helpers":2,"./input":5,"./input-group":4}],4:[function(t,e,i){function n(t,e,i,n,s,o,u,d){if(!i||!n)throw r.mandatorySuccessFailure;this.inputs=[],this.inputElems=[],this.submitElems=[],this.onValidationSuccess=i,this.onValidationFailure=n,this.pendingUiStart=s,this.pendingUiStop=o,this.groupStatesChanged=u,this.groupPendingChangedListeners=[],this.groupPendingChangedListeners.push(function(t){t||this.isPendingUiStartRun&&(this.pendingUiStop.call(this.pendingUiLastSubmitElem,this.inputElems,this.submitElems),this.getOnSubmit.call(this).call(this.pendingUiLastSubmitElem),this.isPendingUiStartRun=!1,this.pendingUiLastSubmitElem={})}.bind(this)),d&&this.groupPendingChangedListeners.push(d),this.stateCounters={},this.stateCounters[a.invalid]=0,this.stateCounters[a.pending]=0,this.stateCounters[a.valid]=0,this.isPendingChangeTrueRun=!1,this.isPendingUiStartRun=!1,this.pendingUiLastSubmitElem={},this.inputs=t.map(function(t){return t.setGroup(this),t},this),this.inputElems=t.map(function(t){return t.el}),this.stateCounters[a.valid]=t.length,this.submitElems=Array.prototype.slice.call(e),this.submitElems.forEach(function(t){t.addEventListener("click",this.getOnSubmit.call(this))},this)}var a=(t("./input"),t("./state-enum")),s=t("./constants").DEBUG,r=t("./constants").ERROR;n.prototype=function(){function t(){return this.triggerInputsValidation(),0===this.stateCounters[a.invalid]&&0===this.stateCounters[a.pending]}function e(){return this.triggerInputsValidation(),0===this.stateCounters[a.invalid]&&this.stateCounters[a.pending]>0}function i(){var t=this;return function(e){e&&e.preventDefault(),t.isPending()?(t.pendingUiStart.call(this,t.inputElems,t.submitElems),t.isPendingUiStartRun=!0,t.pendingUiLastSubmitElem=this):t.isValid()?t.onValidationSuccess.call(this):t.onValidationFailure.call(this,t.stateCounters[a.invalid],t.stateCounters[a.pending],t.stateCounters[a.valid]),s&&(console.debug("cuurent states:"),console.debug("invalid: "+t.stateCounters[a.invalid]),console.debug("pending: "+t.stateCounters[a.pending]),console.debug("valid: "+t.stateCounters[a.valid]))}}function n(){this.inputs.forEach(function(t){t.triggerValidation()})}function r(t,e){t.stateEnum!==e.stateEnum&&(this.stateCounters[t.stateEnum]--,this.stateCounters[e.stateEnum]++)}function o(){this.groupStatesChanged&&this.groupStatesChanged(),this.groupPendingChangedListeners.forEach(function(t){!this.isPendingChangeTrueRun&&0===this.stateCounters[a.invalid]&&this.stateCounters[a.pending]>0?(t(!0),this.isPendingChangeTrueRun=!0):this.isPendingChangeTrueRun&&0===this.stateCounters[a.pending]&&(t(!1),this.isPendingChangeTrueRun=!1)},this)}return{isValid:t,isPending:e,getOnSubmit:i,triggerInputsValidation:n,updateGroupListeners:o,updateGroupStates:r}}(),e.exports=n},{"./constants":1,"./input":5,"./state-enum":6}],5:[function(t,e,i){function n(t,e,i){function n(){var t=[];return e.forEach(function(e){var i=e[0],n=e[1];t.push({name:i,run:a.build(i,n)})}),t}function o(t,e,i,n){function a(t){return"vivalid-error"===t.nextSibling.className?t.nextSibling:void 0}function s(t,i){r=document.createElement("DIV"),r.className="vivalid-error",r.style.color="#ff0000";var n=document.createTextNode(e.message);r.appendChild(n),t.parentNode.insertBefore(r,t.nextSibling)}var r;if("input"===t.nodeName.toLowerCase()&&("radio"===t.type||"checkbox"===t.type)){var o=t.parentNode.querySelectorAll('input[name="'+t.name+'"]');t=o.item(o.length-1)}e.stateEnum===n.invalid?(r=a(t),r?r.textContent=e.message:s(t,e.message),t.style.borderStyle="solid",t.style.borderColor="#ff0000"):(r=a(t),r&&(r.parentNode.removeChild(r),t.style.borderStyle="",t.style.borderColor=""))}if(-1===u.indexOf(t.nodeName.toLowerCase()))throw"only operates on the following html tags: "+u.toString();this.group={},this.el=t,this.validators=n(),this.onInputValidationResult=i||o,this.isNoneChecked=!1,this.validationState=new r("",s.valid),this.validationCycle=0,this.isChanged=!1,this.elName=t.nodeName.toLowerCase(),this.elType=t.type,this.isKeyed="textarea"===this.elName||d.indexOf(this.elType)>-1,this.activeEventType="",this._runValidatorsBounded=this.runValidators.bind(this),this.initListeners()}var a=t("./validator-repo"),s=t("./state-enum"),r=t("./validation-state"),o=t("./constants"),u=o.validInputTagNames,d=o.keyStrokedInputTypes;n.prototype=function(){function t(){if("input"===this.el.nodeName.toLowerCase()&&("radio"===this.el.type||"checkbox"===this.el.type)){var t=document.querySelector('input[name="'+this.el.name+'"]:checked');t?(this.el=t,this.isNoneChecked=!1):this.isNoneChecked=!0}}function e(){(0===this.validationCycle||this.isChanged)&&this._runValidatorsBounded()}function i(t){this.isKeyed&&t!==this.activeEventType&&(this.removeActiveEventType(),this.addEventType(t))}function n(t){this.group=t}function a(){this.addChangeListener(),this.isKeyed?this.addEventType("blur"):this.addEventType("change")}function o(t,e){this.validationCycle++,this.reBindCheckedElement();for(var i,n,a=e||0;a<this.validators.length;a++){var o=this.validators[a],u=this.isNoneChecked?"":this.el.value,d=o.run(u,this.getUpdateInputValidationResultAsync(o.name,a,this.validationCycle));if(d.stateEnum!==s.valid){i=d,n=o.name,this.changeEventType("input");break}}i=i||new r("",s.valid),this.updateInputValidationResult(i,n),this.isChanged=!1}function u(){if(this.isKeyed)this.el.addEventListener("input",function(){this.isChanged=!0},!1);else if("input"!==this.elName||"radio"!==this.elType&&"checkbox"!==this.elType)"select"===this.elName&&this.el.addEventListener("change",function(){this.isChanged=!0},!1);else for(var t=document.querySelectorAll('input[name="'+this.el.name+'"]'),e=0;e<t.length;e++)t[e].addEventListener("change",function(){this.isChanged=!0},!1)}function d(t){if(this.isKeyed)this.el.addEventListener(t,this._runValidatorsBounded,!1);else if("input"!==this.elName||"radio"!==this.elType&&"checkbox"!==this.elType)"select"===this.elName&&this.el.addEventListener(t,this._runValidatorsBounded,!1);else for(var e=document.querySelectorAll('input[name="'+this.el.name+'"]'),i=0;i<e.length;i++)e[i].addEventListener(t,this._runValidatorsBounded,!1);this.activeEventType=t}function l(){this.el.removeEventListener(this.activeEventType,this._runValidatorsBounded,!1)}function h(t,e,i){var n=this;return function(a){i&&i!==n.validationCycle||(a.stateEnum===s.valid&&e+1<n.validators.length?n._runValidatorsBounded(null,e+1):n.updateInputValidationResult(a,t))}}function c(t,e){this.group.updateGroupStates(this.validationState,t),this.group.updateGroupListeners(),this.validationState=t,this.onInputValidationResult(this.el,t,e,s)}return{reBindCheckedElement:t,triggerValidation:e,runValidators:o,changeEventType:i,initListeners:a,setGroup:n,addChangeListener:u,addEventType:d,removeActiveEventType:l,getUpdateInputValidationResultAsync:h,updateInputValidationResult:c}}(),e.exports=n},{"./constants":1,"./state-enum":6,"./validation-state":7,"./validator-repo":8}],6:[function(t,e,i){var n={invalid:1,pending:2,valid:3};e.exports=n},{}],7:[function(t,e,i){function n(t,e){this.message=t,this.stateEnum=e}e.exports=n},{}],8:[function(t,e,i){function n(t,e){if("function"!=typeof e)throw"error while trying to register a Validator: argument must be a function";o[t]=e}function a(t,e){if("function"!=typeof o[t])throw t+" does not exists. use addValidatorBuilder to add a new validation rule";return o[t](r,s,e)}var s=t("./state-enum"),r=t("./validation-state"),o={};e.exports={addBuilder:n,build:a}},{"./state-enum":6,"./validation-state":7}],vivalid:[function(t,e,i){"use strict";var n=t("./input"),a=t("./input-group"),s=t("./validator-repo"),r=t("./html-interface"),o=t("./constants");e.exports={VERSION:o.VERSION,Input:n,InputGroup:a,validatorRepo:s,htmlInterface:r,_ERROR:o.ERROR}},{"./constants":1,"./html-interface":3,"./input":5,"./input-group":4,"./validator-repo":8}]},{},["vivalid"])("vivalid")}); |
@@ -99,4 +99,4 @@ var validatorRepo = require('./validator-repo'); | ||
errorDiv.parentNode.removeChild(errorDiv); | ||
el.style.borderStyle = null; | ||
el.style.borderColor = null; | ||
el.style.borderStyle = ""; | ||
el.style.borderColor = ""; | ||
} | ||
@@ -103,0 +103,0 @@ } |
@@ -6,3 +6,2 @@ 'use strict'; | ||
var validatorRepo = require('./validator-repo'); | ||
var stateEnum = require('./state-enum'); | ||
var htmlInterface = require('./html-interface'); | ||
@@ -9,0 +8,0 @@ var constants = require('./constants'); |
{ | ||
"name": "vivalid", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "client side validations with async (client-server) support", | ||
@@ -5,0 +5,0 @@ "main": "./lib/vivalid.js", |
@@ -178,3 +178,6 @@ # ViValid [![Build Status](https://travis-ci.org/pazams/vivalid.svg)](https://travis-ci.org/pazams/vivalid) | ||
## Contributers | ||
read [this](https://github.com/pazams/vivalid/issues/1) before attempting to `gulp build` | ||
## More demos | ||
Coming soon |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
183
92877
1668