nette-forms
Advanced tools
Comparing version 3.0.0 to 3.0.1
{ | ||
"name": "nette-forms", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "Client side script for Nette Forms Component", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -38,17 +38,10 @@ /** | ||
/** | ||
* Attaches a handler to an event for the element. | ||
* Function to execute when the DOM is fully loaded. | ||
* @private | ||
*/ | ||
Nette.addEvent = function(element, on, callback) { | ||
if (on === 'DOMContentLoaded' && element.readyState !== 'loading') { | ||
Nette.onDocumentReady = function(callback) { | ||
if (document.readyState !== 'loading') { | ||
callback.call(this); | ||
} else if (element.addEventListener) { | ||
element.addEventListener(on, callback); | ||
} else if (on === 'DOMContentLoaded') { | ||
element.attachEvent('onreadystatechange', function() { | ||
if (element.readyState === 'complete') { | ||
callback.call(this); | ||
} | ||
}); | ||
} else { | ||
element.attachEvent('on' + on, getHandler(callback)); | ||
document.addEventListener('DOMContentLoaded', callback); | ||
} | ||
@@ -58,9 +51,2 @@ }; | ||
function getHandler(callback) { | ||
return function(e) { | ||
return callback.call(this, e); | ||
}; | ||
} | ||
/** | ||
@@ -189,3 +175,3 @@ * Returns the value of form element. | ||
if (!onlyCheck) { | ||
var arr = Nette.isArray(rule.arg) ? rule.arg : [rule.arg], | ||
var arr = Array.isArray(rule.arg) ? rule.arg : [rule.arg], | ||
message = rule.msg.replace(/%(value|\d+)/g, function(foo, m) { | ||
@@ -297,3 +283,3 @@ return Nette.getValue(m === 'value' ? curElem : elem.form.elements.namedItem(arr[m].control)); | ||
if (!Nette.inArray(messages, message)) { | ||
if (messages.indexOf(message) < 0) { | ||
messages.push(message); | ||
@@ -331,3 +317,3 @@ | ||
var arr = Nette.isArray(arg) ? arg.slice(0) : [arg]; | ||
var arr = Array.isArray(arg) ? arg.slice(0) : [arg]; | ||
if (!preventFiltering) { | ||
@@ -344,3 +330,3 @@ preventFiltering = true; | ||
return Nette.validators[op] | ||
? Nette.validators[op](elem, Nette.isArray(arg) ? arr : arr[0], value.value, value) | ||
? Nette.validators[op](elem, Array.isArray(arg) ? arr : arr[0], value.value, value) | ||
: null; | ||
@@ -356,3 +342,3 @@ }; | ||
return val !== '' && val !== false && val !== null | ||
&& (!Nette.isArray(val) || !!val.length) | ||
&& (!Array.isArray(val) || !!val.length) | ||
&& (!window.FileList || !(val instanceof window.FileList) || val.length); | ||
@@ -382,4 +368,4 @@ }, | ||
val = Nette.isArray(val) ? val : [val]; | ||
arg = Nette.isArray(arg) ? arg : [arg]; | ||
val = Array.isArray(val) ? val : [val]; | ||
arg = Array.isArray(arg) ? arg : [arg]; | ||
loop: | ||
@@ -431,3 +417,3 @@ for (var i1 = 0, len1 = val.length; i1 < len1; i1++) { | ||
} | ||
arg = Nette.isArray(arg) ? arg : [arg, arg]; | ||
arg = Array.isArray(arg) ? arg : [arg, arg]; | ||
return (arg[0] === null || val.length >= arg[0]) && (arg[1] === null || val.length <= arg[1]); | ||
@@ -544,3 +530,3 @@ }, | ||
} | ||
return Nette.isArray(arg) ? | ||
return Array.isArray(arg) ? | ||
((arg[0] === null || parseFloat(val) >= arg[0]) && (arg[1] === null || parseFloat(val) <= arg[1])) : null; | ||
@@ -642,9 +628,8 @@ }, | ||
if (firsttime) { | ||
var oldIE = !document.addEventListener, // IE < 9 | ||
name = curElem.tagName ? curElem.name : curElem[0].name, | ||
var name = curElem.tagName ? curElem.name : curElem[0].name, | ||
els = curElem.tagName ? curElem.form.elements : curElem; | ||
for (var i = 0; i < els.length; i++) { | ||
if (els[i].name === name && !Nette.inArray(handled, els[i])) { | ||
Nette.addEvent(els[i], oldIE && els[i].type in {checkbox: 1, radio: 1} ? 'click' : 'change', handler); | ||
if (els[i].name === name && handled.indexOf(els[i]) < 0) { | ||
els[i].addEventListener('change', handler); | ||
handled.push(els[i]); | ||
@@ -668,7 +653,10 @@ } | ||
*/ | ||
Nette.toggle = function(id, visible, srcElement) { // eslint-disable-line no-unused-vars | ||
var elem = document.getElementById(id); | ||
if (elem) { | ||
elem.style.display = visible ? '' : 'none'; | ||
Nette.toggle = function(selector, visible, srcElement) { // eslint-disable-line no-unused-vars | ||
if (/^\w+$/.test(selector)) { // id | ||
selector = '#' + selector; | ||
} | ||
var elems = document.querySelectorAll(selector); | ||
for (var i = 0; i < elems.length; i++) { | ||
elems[i].hidden = !visible; | ||
} | ||
}; | ||
@@ -689,11 +677,6 @@ | ||
Nette.addEvent(form, 'submit', function(e) { | ||
form.addEventListener('submit', function(e) { | ||
if (!Nette.validateForm(form)) { | ||
if (e && e.stopPropagation) { | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
} else if (window.event) { | ||
event.cancelBubble = true; | ||
event.returnValue = false; | ||
} | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
} | ||
@@ -708,3 +691,3 @@ }); | ||
Nette.initOnLoad = function() { | ||
Nette.addEvent(document, 'DOMContentLoaded', function() { | ||
Nette.onDocumentReady(function() { | ||
for (var i = 0; i < document.forms.length; i++) { | ||
@@ -720,4 +703,4 @@ var form = document.forms[i]; | ||
Nette.addEvent(document.body, 'click', function(e) { | ||
var target = e.target || e.srcElement; | ||
document.body.addEventListener('click', function(e) { | ||
var target = e.target; | ||
while (target) { | ||
@@ -736,27 +719,2 @@ if (target.form && target.type in {submit: 1, image: 1}) { | ||
/** | ||
* Determines whether the argument is an array. | ||
*/ | ||
Nette.isArray = function(arg) { | ||
return Object.prototype.toString.call(arg) === '[object Array]'; | ||
}; | ||
/** | ||
* Search for a specified value within an array. | ||
*/ | ||
Nette.inArray = function(arr, val) { | ||
if ([].indexOf) { | ||
return arr.indexOf(val) > -1; | ||
} else { | ||
for (var i = 0; i < arr.length; i++) { | ||
if (arr[i] === val) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
}; | ||
/** | ||
* Converts string to web safe characters [a-z0-9-] text. | ||
@@ -763,0 +721,0 @@ */ |
/*! netteForms.js | (c) 2004 David Grudl (https://davidgrudl.com) */ | ||
(function(e,q){if(e.JSON)if("function"===typeof define&&define.amd)define(function(){return q(e)});else if("object"===typeof module&&"object"===typeof module.exports)module.exports=q(e);else{var d=!e.Nette||!e.Nette.noInit;e.Nette=q(e);d&&e.Nette.initOnLoad()}})("undefined"!==typeof window?window:this,function(e){function q(a){return function(b){return a.call(this,b)}}var d={formErrors:[],version:"3.0",addEvent:function(a,b,c){"DOMContentLoaded"===b&&"loading"!==a.readyState?c.call(this):a.addEventListener? | ||
a.addEventListener(b,c):"DOMContentLoaded"===b?a.attachEvent("onreadystatechange",function(){"complete"===a.readyState&&c.call(this)}):a.attachEvent("on"+b,q(c))},getValue:function(a){var b;if(a){if(a.tagName){if("radio"===a.type){var c=a.form.elements;for(b=0;b<c.length;b++)if(c[b].name===a.name&&c[b].checked)return c[b].value;return null}if("file"===a.type)return a.files||a.value;if("select"===a.tagName.toLowerCase()){b=a.selectedIndex;c=a.options;var f=[];if("select-one"===a.type)return 0>b?null: | ||
c[b].value;for(b=0;b<c.length;b++)c[b].selected&&f.push(c[b].value);return f}if(a.name&&a.name.match(/\[\]$/)){c=a.form.elements[a.name].tagName?[a]:a.form.elements[a.name];f=[];for(b=0;b<c.length;b++)("checkbox"!==c[b].type||c[b].checked)&&f.push(c[b].value);return f}return"checkbox"===a.type?a.checked:"textarea"===a.tagName.toLowerCase()?a.value.replace("\r",""):a.value.replace("\r","").replace(/^\s+|\s+$/g,"")}return a[0]?d.getValue(a[0]):null}return null},getEffectiveValue:function(a,b){var c= | ||
d.getValue(a);a.getAttribute&&c===a.getAttribute("data-nette-empty-value")&&(c="");b&&(c={value:c},d.validateControl(a,null,!0,c),c=c.value);return c},validateControl:function(a,b,c,f,n){a=a.tagName?a:a[0];b=b||JSON.parse(a.getAttribute("data-nette-rules")||"[]");f=void 0===f?{value:d.getEffectiveValue(a)}:f;n=n||!d.validateRule(a,":filled",null,f);for(var g=0,p=b.length;g<p;g++){var h=b[g],k=h.op.match(/(~)?([^?]+)/),e=h.control?a.form.elements.namedItem(h.control):a;h.neg=k[1];h.op=k[2];h.condition= | ||
!!h.rules;if(e&&(!n||h.condition||":filled"===h.op)&&(e=e.tagName?e:e[0],k=d.validateRule(e,h.op,h.arg,a===e?f:void 0),null!==k))if(h.neg&&(k=!k),h.condition&&k){if(!d.validateControl(a,h.rules,c,f,":blank"===h.op?!1:n))return!1}else if(!h.condition&&!k&&!d.isDisabled(e)){if(!c){var q=d.isArray(h.arg)?h.arg:[h.arg];b=h.msg.replace(/%(value|\d+)/g,function(c,b){return d.getValue("value"===b?e:a.form.elements.namedItem(q[b].control))});d.addError(e,b)}return!1}}return"number"!==a.type||a.validity.valid? | ||
!0:(c||d.addError(a,"Please enter a valid value."),!1)},validateForm:function(a,b){var c=a.form||a,f=!1;d.formErrors=[];if(c["nette-submittedBy"]&&null!==c["nette-submittedBy"].getAttribute("formnovalidate"))if(f=JSON.parse(c["nette-submittedBy"].getAttribute("data-nette-validation-scope")||"[]"),f.length)f=new RegExp("^("+f.join("-|")+"-)");else return d.showFormErrors(c,[]),!0;var n={},g;for(g=0;g<c.elements.length;g++){var e=c.elements[g];if(!e.tagName||e.tagName.toLowerCase()in{input:1,select:1, | ||
textarea:1,button:1}){if("radio"===e.type){if(n[e.name])continue;n[e.name]=!0}if(!(f&&!e.name.replace(/]\[|\[|]|$/g,"-").match(f)||d.isDisabled(e)||d.validateControl(e,null,b)||d.formErrors.length))return!1}}f=!d.formErrors.length;d.showFormErrors(c,d.formErrors);return f},isDisabled:function(a){if("radio"===a.type){for(var b=0,c=a.form.elements;b<c.length;b++)if(c[b].name===a.name&&!c[b].disabled)return!1;return!0}return a.disabled},addError:function(a,b){d.formErrors.push({element:a,message:b})}, | ||
showFormErrors:function(a,b){for(var c=[],f,e=0;e<b.length;e++){var g=b[e].element,p=b[e].message;d.inArray(c,p)||(c.push(p),!f&&g.focus&&(f=g))}c.length&&(alert(c.join("\n")),f&&f.focus())}},t=!1;d.validateRule=function(a,b,c,f){f=void 0===f?{value:d.getEffectiveValue(a,!0)}:f;":"===b.charAt(0)&&(b=b.substr(1));b=b.replace("::","_");b=b.replace(/\\/g,"");var e=d.isArray(c)?c.slice(0):[c];if(!t){t=!0;for(var g=0,p=e.length;g<p;g++)if(e[g]&&e[g].control){var h=a.form.elements.namedItem(e[g].control); | ||
e[g]=h===a?f.value:d.getEffectiveValue(h,!0)}t=!1}return d.validators[b]?d.validators[b](a,d.isArray(c)?e:e[0],f.value,f):null};d.validators={filled:function(a,b,c){return"number"===a.type&&a.validity.badInput?!0:""!==c&&!1!==c&&null!==c&&(!d.isArray(c)||!!c.length)&&(!e.FileList||!(c instanceof e.FileList)||c.length)},blank:function(a,b,c){return!d.validators.filled(a,b,c)},valid:function(a){return d.validateControl(a,null,!0)},equal:function(a,b,c){function f(a){return"number"===typeof a||"string"=== | ||
typeof a?""+a:!0===a?"1":""}if(void 0===b)return null;c=d.isArray(c)?c:[c];b=d.isArray(b)?b:[b];a=0;var e=c.length;a:for(;a<e;a++){for(var g=0,p=b.length;g<p;g++)if(f(c[a])===f(b[g]))continue a;return!1}return!0},notEqual:function(a,b,c){return void 0===b?null:!d.validators.equal(a,b,c)},minLength:function(a,b,c){if("number"===a.type){if(a.validity.tooShort)return!1;if(a.validity.badInput)return null}return c.length>=b},maxLength:function(a,b,c){if("number"===a.type){if(a.validity.tooLong)return!1; | ||
if(a.validity.badInput)return null}return c.length<=b},length:function(a,b,c){if("number"===a.type){if(a.validity.tooShort||a.validity.tooLong)return!1;if(a.validity.badInput)return null}b=d.isArray(b)?b:[b,b];return(null===b[0]||c.length>=b[0])&&(null===b[1]||c.length<=b[1])},email:function(a,b,c){return/^("([ !#-[\]-~]|\\[ -~])+"|[-a-z0-9!#$%&'*+/=?^_`{|}~]+(\.[-a-z0-9!#$%&'*+/=?^_`{|}~]+)*)@([0-9a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,61}[0-9a-z\u00C0-\u02FF\u0370-\u1EFF])?\.)+[a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,17}[a-z\u00C0-\u02FF\u0370-\u1EFF])?$/i.test(c)}, | ||
url:function(a,b,c,d){/^[a-z\d+.-]+:/.test(c)||(c="http://"+c);return/^https?:\/\/((([-_0-9a-z\u00C0-\u02FF\u0370-\u1EFF]+\.)*[0-9a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,61}[0-9a-z\u00C0-\u02FF\u0370-\u1EFF])?\.)?[a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,17}[a-z\u00C0-\u02FF\u0370-\u1EFF])?|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|\[[0-9a-f:]{3,39}\])(:\d{1,5})?(\/\S*)?$/i.test(c)?(d.value=c,!0):!1},regexp:function(a,b,c){a="string"===typeof b?b.match(/^\/(.*)\/([imu]*)$/): | ||
!1;try{return a&&(new RegExp(a[1],a[2].replace("u",""))).test(c)}catch(f){}},pattern:function(a,b,c,d,n){if("string"!==typeof b)return null;try{try{var f=new RegExp("^(?:"+b+")$",n?"ui":"u")}catch(p){f=new RegExp("^(?:"+b+")$",n?"i":"")}if(e.FileList&&c instanceof FileList){for(a=0;a<c.length;a++)if(!f.test(c[a].name))return!1;return!0}return f.test(c)}catch(p){}},patternCaseInsensitive:function(a,b,c){return d.validators.pattern(a,b,c,null,!0)},numeric:function(a,b,c){return"number"===a.type&&a.validity.badInput? | ||
!1:/^[0-9]+$/.test(c)},integer:function(a,b,c){return"number"===a.type&&a.validity.badInput?!1:/^-?[0-9]+$/.test(c)},"float":function(a,b,c,d){if("number"===a.type&&a.validity.badInput)return!1;c=c.replace(/ +/g,"").replace(/,/g,".");return/^-?[0-9]*\.?[0-9]+$/.test(c)?(d.value=c,!0):!1},min:function(a,b,c){if("number"===a.type){if(a.validity.rangeUnderflow)return!1;if(a.validity.badInput)return null}return null===b||parseFloat(c)>=b},max:function(a,b,c){if("number"===a.type){if(a.validity.rangeOverflow)return!1; | ||
if(a.validity.badInput)return null}return null===b||parseFloat(c)<=b},range:function(a,b,c){if("number"===a.type){if(a.validity.rangeUnderflow||a.validity.rangeOverflow)return!1;if(a.validity.badInput)return null}return d.isArray(b)?(null===b[0]||parseFloat(c)>=b[0])&&(null===b[1]||parseFloat(c)<=b[1]):null},submitted:function(a){return a.form["nette-submittedBy"]===a},fileSize:function(a,b,c){if(e.FileList)for(a=0;a<c.length;a++)if(c[a].size>b)return!1;return!0},image:function(a,b,c){if(e.FileList&& | ||
c instanceof e.FileList)for(a=0;a<c.length;a++)if((b=c[a].type)&&"image/gif"!==b&&"image/png"!==b&&"image/jpeg"!==b)return!1;return!0},"static":function(a,b){return b}};d.toggleForm=function(a,b){var c;d.toggles={};for(c=0;c<a.elements.length;c++)a.elements[c].tagName.toLowerCase()in{input:1,select:1,textarea:1,button:1}&&d.toggleControl(a.elements[c],null,null,!b);for(c in d.toggles)d.toggle(c,d.toggles[c],b)};d.toggleControl=function(a,b,c,f,e){b=b||JSON.parse(a.getAttribute("data-nette-rules")|| | ||
"[]");e=void 0===e?{value:d.getEffectiveValue(a)}:e;for(var g=!1,p=[],h=function(){d.toggleForm(a.form,a)},k,n=0,q=b.length;n<q;n++){var m=b[n],u=m.op.match(/(~)?([^?]+)/),l=m.control?a.form.elements.namedItem(m.control):a;if(l){k=c;if(!1!==c){m.neg=u[1];m.op=u[2];k=d.validateRule(l,m.op,m.arg,a===l?e:void 0);if(null===k)continue;else m.neg&&(k=!k);m.rules||(c=k)}if(m.rules&&d.toggleControl(a,m.rules,k,f,e)||m.toggle){g=!0;if(f){u=!document.addEventListener;var t=l.tagName?l.name:l[0].name;l=l.tagName? | ||
l.form.elements:l;for(var r=0;r<l.length;r++)l[r].name!==t||d.inArray(p,l[r])||(d.addEvent(l[r],u&&l[r].type in{checkbox:1,radio:1}?"click":"change",h),p.push(l[r]))}for(var v in m.toggle||[])Object.prototype.hasOwnProperty.call(m.toggle,v)&&(d.toggles[v]=d.toggles[v]||(m.toggle[v]?k:!k))}}}return g};d.toggle=function(a,b,c){if(a=document.getElementById(a))a.style.display=b?"":"none"};d.initForm=function(a){d.toggleForm(a);a.noValidate||(a.noValidate=!0,d.addEvent(a,"submit",function(b){d.validateForm(a)|| | ||
(b&&b.stopPropagation?(b.stopPropagation(),b.preventDefault()):e.event&&(event.cancelBubble=!0,event.returnValue=!1))}))};d.initOnLoad=function(){d.addEvent(document,"DOMContentLoaded",function(){for(var a=0;a<document.forms.length;a++)for(var b=document.forms[a],c=0;c<b.elements.length;c++)if(b.elements[c].getAttribute("data-nette-rules")){d.initForm(b);break}d.addEvent(document.body,"click",function(a){for(a=a.target||a.srcElement;a;){if(a.form&&a.type in{submit:1,image:1}){a.form["nette-submittedBy"]= | ||
a;break}a=a.parentNode}})})};d.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)};d.inArray=function(a,b){if([].indexOf)return-1<a.indexOf(b);for(var c=0;c<a.length;c++)if(a[c]===b)return!0;return!1};d.webalize=function(a){a=a.toLowerCase();var b="",c;for(c=0;c<a.length;c++){var e=d.webalizeTable[a.charAt(c)];b+=e?e:a.charAt(c)}return b.replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")};d.webalizeTable={"\u00e1":"a","\u00e4":"a","\u010d":"c","\u010f":"d","\u00e9":"e","\u011b":"e", | ||
"\u00ed":"i","\u013e":"l","\u0148":"n","\u00f3":"o","\u00f4":"o","\u0159":"r","\u0161":"s","\u0165":"t","\u00fa":"u","\u016f":"u","\u00fd":"y","\u017e":"z"};return d}); | ||
(function(e,d){if(e.JSON)if("function"===typeof define&&define.amd)define(function(){return d(e)});else if("object"===typeof module&&"object"===typeof module.exports)module.exports=d(e);else{var q=!e.Nette||!e.Nette.noInit;e.Nette=d(e);q&&e.Nette.initOnLoad()}})("undefined"!==typeof window?window:this,function(e){var d={formErrors:[],version:"3.0",onDocumentReady:function(a){"loading"!==document.readyState?a.call(this):document.addEventListener("DOMContentLoaded",a)},getValue:function(a){var c;if(a){if(a.tagName){if("radio"=== | ||
a.type){var b=a.form.elements;for(c=0;c<b.length;c++)if(b[c].name===a.name&&b[c].checked)return b[c].value;return null}if("file"===a.type)return a.files||a.value;if("select"===a.tagName.toLowerCase()){c=a.selectedIndex;b=a.options;var f=[];if("select-one"===a.type)return 0>c?null:b[c].value;for(c=0;c<b.length;c++)b[c].selected&&f.push(b[c].value);return f}if(a.name&&a.name.match(/\[\]$/)){b=a.form.elements[a.name].tagName?[a]:a.form.elements[a.name];f=[];for(c=0;c<b.length;c++)("checkbox"!==b[c].type|| | ||
b[c].checked)&&f.push(b[c].value);return f}return"checkbox"===a.type?a.checked:"textarea"===a.tagName.toLowerCase()?a.value.replace("\r",""):a.value.replace("\r","").replace(/^\s+|\s+$/g,"")}return a[0]?d.getValue(a[0]):null}return null},getEffectiveValue:function(a,c){var b=d.getValue(a);a.getAttribute&&b===a.getAttribute("data-nette-empty-value")&&(b="");c&&(b={value:b},d.validateControl(a,null,!0,b),b=b.value);return b},validateControl:function(a,c,b,f,l){a=a.tagName?a:a[0];c=c||JSON.parse(a.getAttribute("data-nette-rules")|| | ||
"[]");f=void 0===f?{value:d.getEffectiveValue(a)}:f;l=l||!d.validateRule(a,":filled",null,f);for(var h=0,p=c.length;h<p;h++){var g=c[h],k=g.op.match(/(~)?([^?]+)/),e=g.control?a.form.elements.namedItem(g.control):a;g.neg=k[1];g.op=k[2];g.condition=!!g.rules;if(e&&(!l||g.condition||":filled"===g.op)&&(e=e.tagName?e:e[0],k=d.validateRule(e,g.op,g.arg,a===e?f:void 0),null!==k))if(g.neg&&(k=!k),g.condition&&k){if(!d.validateControl(a,g.rules,b,f,":blank"===g.op?!1:l))return!1}else if(!g.condition&&!k&& | ||
!d.isDisabled(e)){if(!b){var q=Array.isArray(g.arg)?g.arg:[g.arg];c=g.msg.replace(/%(value|\d+)/g,function(b,c){return d.getValue("value"===c?e:a.form.elements.namedItem(q[c].control))});d.addError(e,c)}return!1}}return"number"!==a.type||a.validity.valid?!0:(b||d.addError(a,"Please enter a valid value."),!1)},validateForm:function(a,c){var b=a.form||a,f=!1;d.formErrors=[];if(b["nette-submittedBy"]&&null!==b["nette-submittedBy"].getAttribute("formnovalidate"))if(f=JSON.parse(b["nette-submittedBy"].getAttribute("data-nette-validation-scope")|| | ||
"[]"),f.length)f=new RegExp("^("+f.join("-|")+"-)");else return d.showFormErrors(b,[]),!0;var l={},h;for(h=0;h<b.elements.length;h++){var e=b.elements[h];if(!e.tagName||e.tagName.toLowerCase()in{input:1,select:1,textarea:1,button:1}){if("radio"===e.type){if(l[e.name])continue;l[e.name]=!0}if(!(f&&!e.name.replace(/]\[|\[|]|$/g,"-").match(f)||d.isDisabled(e)||d.validateControl(e,null,c)||d.formErrors.length))return!1}}f=!d.formErrors.length;d.showFormErrors(b,d.formErrors);return f},isDisabled:function(a){if("radio"=== | ||
a.type){for(var c=0,b=a.form.elements;c<b.length;c++)if(b[c].name===a.name&&!b[c].disabled)return!1;return!0}return a.disabled},addError:function(a,c){d.formErrors.push({element:a,message:c})},showFormErrors:function(a,c){for(var b=[],d,e=0;e<c.length;e++){var h=c[e].element,p=c[e].message;0>b.indexOf(p)&&(b.push(p),!d&&h.focus&&(d=h))}b.length&&(alert(b.join("\n")),d&&d.focus())}},q=!1;d.validateRule=function(a,c,b,f){f=void 0===f?{value:d.getEffectiveValue(a,!0)}:f;":"===c.charAt(0)&&(c=c.substr(1)); | ||
c=c.replace("::","_");c=c.replace(/\\/g,"");var e=Array.isArray(b)?b.slice(0):[b];if(!q){q=!0;for(var h=0,p=e.length;h<p;h++)if(e[h]&&e[h].control){var g=a.form.elements.namedItem(e[h].control);e[h]=g===a?f.value:d.getEffectiveValue(g,!0)}q=!1}return d.validators[c]?d.validators[c](a,Array.isArray(b)?e:e[0],f.value,f):null};d.validators={filled:function(a,c,b){return"number"===a.type&&a.validity.badInput?!0:""!==b&&!1!==b&&null!==b&&(!Array.isArray(b)||!!b.length)&&(!e.FileList||!(b instanceof e.FileList)|| | ||
b.length)},blank:function(a,c,b){return!d.validators.filled(a,c,b)},valid:function(a){return d.validateControl(a,null,!0)},equal:function(a,c,b){function d(a){return"number"===typeof a||"string"===typeof a?""+a:!0===a?"1":""}if(void 0===c)return null;b=Array.isArray(b)?b:[b];c=Array.isArray(c)?c:[c];a=0;var e=b.length;a:for(;a<e;a++){for(var h=0,p=c.length;h<p;h++)if(d(b[a])===d(c[h]))continue a;return!1}return!0},notEqual:function(a,c,b){return void 0===c?null:!d.validators.equal(a,c,b)},minLength:function(a, | ||
c,b){if("number"===a.type){if(a.validity.tooShort)return!1;if(a.validity.badInput)return null}return b.length>=c},maxLength:function(a,c,b){if("number"===a.type){if(a.validity.tooLong)return!1;if(a.validity.badInput)return null}return b.length<=c},length:function(a,c,b){if("number"===a.type){if(a.validity.tooShort||a.validity.tooLong)return!1;if(a.validity.badInput)return null}c=Array.isArray(c)?c:[c,c];return(null===c[0]||b.length>=c[0])&&(null===c[1]||b.length<=c[1])},email:function(a,c,b){return/^("([ !#-[\]-~]|\\[ -~])+"|[-a-z0-9!#$%&'*+/=?^_`{|}~]+(\.[-a-z0-9!#$%&'*+/=?^_`{|}~]+)*)@([0-9a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,61}[0-9a-z\u00C0-\u02FF\u0370-\u1EFF])?\.)+[a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,17}[a-z\u00C0-\u02FF\u0370-\u1EFF])?$/i.test(b)}, | ||
url:function(a,c,b,d){/^[a-z\d+.-]+:/.test(b)||(b="http://"+b);return/^https?:\/\/((([-_0-9a-z\u00C0-\u02FF\u0370-\u1EFF]+\.)*[0-9a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,61}[0-9a-z\u00C0-\u02FF\u0370-\u1EFF])?\.)?[a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,17}[a-z\u00C0-\u02FF\u0370-\u1EFF])?|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|\[[0-9a-f:]{3,39}\])(:\d{1,5})?(\/\S*)?$/i.test(b)?(d.value=b,!0):!1},regexp:function(a,c,b){a="string"===typeof c?c.match(/^\/(.*)\/([imu]*)$/): | ||
!1;try{return a&&(new RegExp(a[1],a[2].replace("u",""))).test(b)}catch(f){}},pattern:function(a,c,b,d,l){if("string"!==typeof c)return null;try{try{var f=new RegExp("^(?:"+c+")$",l?"ui":"u")}catch(p){f=new RegExp("^(?:"+c+")$",l?"i":"")}if(e.FileList&&b instanceof FileList){for(a=0;a<b.length;a++)if(!f.test(b[a].name))return!1;return!0}return f.test(b)}catch(p){}},patternCaseInsensitive:function(a,c,b){return d.validators.pattern(a,c,b,null,!0)},numeric:function(a,c,b){return"number"===a.type&&a.validity.badInput? | ||
!1:/^[0-9]+$/.test(b)},integer:function(a,c,b){return"number"===a.type&&a.validity.badInput?!1:/^-?[0-9]+$/.test(b)},"float":function(a,c,b,d){if("number"===a.type&&a.validity.badInput)return!1;b=b.replace(/ +/g,"").replace(/,/g,".");return/^-?[0-9]*\.?[0-9]+$/.test(b)?(d.value=b,!0):!1},min:function(a,c,b){if("number"===a.type){if(a.validity.rangeUnderflow)return!1;if(a.validity.badInput)return null}return null===c||parseFloat(b)>=c},max:function(a,c,b){if("number"===a.type){if(a.validity.rangeOverflow)return!1; | ||
if(a.validity.badInput)return null}return null===c||parseFloat(b)<=c},range:function(a,c,b){if("number"===a.type){if(a.validity.rangeUnderflow||a.validity.rangeOverflow)return!1;if(a.validity.badInput)return null}return Array.isArray(c)?(null===c[0]||parseFloat(b)>=c[0])&&(null===c[1]||parseFloat(b)<=c[1]):null},submitted:function(a){return a.form["nette-submittedBy"]===a},fileSize:function(a,c,b){if(e.FileList)for(a=0;a<b.length;a++)if(b[a].size>c)return!1;return!0},image:function(a,c,b){if(e.FileList&& | ||
b instanceof e.FileList)for(a=0;a<b.length;a++)if((c=b[a].type)&&"image/gif"!==c&&"image/png"!==c&&"image/jpeg"!==c)return!1;return!0},"static":function(a,c){return c}};d.toggleForm=function(a,c){var b;d.toggles={};for(b=0;b<a.elements.length;b++)a.elements[b].tagName.toLowerCase()in{input:1,select:1,textarea:1,button:1}&&d.toggleControl(a.elements[b],null,null,!c);for(b in d.toggles)d.toggle(b,d.toggles[b],c)};d.toggleControl=function(a,c,b,e,l){c=c||JSON.parse(a.getAttribute("data-nette-rules")|| | ||
"[]");l=void 0===l?{value:d.getEffectiveValue(a)}:l;for(var f=!1,p=[],g=function(){d.toggleForm(a.form,a)},k,q=0,v=c.length;q<v;q++){var m=c[q],t=m.op.match(/(~)?([^?]+)/),n=m.control?a.form.elements.namedItem(m.control):a;if(n){k=b;if(!1!==b){m.neg=t[1];m.op=t[2];k=d.validateRule(n,m.op,m.arg,a===n?l:void 0);if(null===k)continue;else m.neg&&(k=!k);m.rules||(b=k)}if(m.rules&&d.toggleControl(a,m.rules,k,e,l)||m.toggle){f=!0;if(e){t=n.tagName?n.name:n[0].name;n=n.tagName?n.form.elements:n;for(var r= | ||
0;r<n.length;r++)n[r].name===t&&0>p.indexOf(n[r])&&(n[r].addEventListener("change",g),p.push(n[r]))}for(var u in m.toggle||[])Object.prototype.hasOwnProperty.call(m.toggle,u)&&(d.toggles[u]=d.toggles[u]||(m.toggle[u]?k:!k))}}}return f};d.toggle=function(a,c,b){/^\w+$/.test(a)&&(a="#"+a);a=document.querySelectorAll(a);for(b=0;b<a.length;b++)a[b].hidden=!c};d.initForm=function(a){d.toggleForm(a);a.noValidate||(a.noValidate=!0,a.addEventListener("submit",function(c){d.validateForm(a)||(c.stopPropagation(), | ||
c.preventDefault())}))};d.initOnLoad=function(){d.onDocumentReady(function(){for(var a=0;a<document.forms.length;a++)for(var c=document.forms[a],b=0;b<c.elements.length;b++)if(c.elements[b].getAttribute("data-nette-rules")){d.initForm(c);break}document.body.addEventListener("click",function(a){for(a=a.target;a;){if(a.form&&a.type in{submit:1,image:1}){a.form["nette-submittedBy"]=a;break}a=a.parentNode}})})};d.webalize=function(a){a=a.toLowerCase();var c="",b;for(b=0;b<a.length;b++){var e=d.webalizeTable[a.charAt(b)]; | ||
c+=e?e:a.charAt(b)}return c.replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")};d.webalizeTable={"\u00e1":"a","\u00e4":"a","\u010d":"c","\u010f":"d","\u00e9":"e","\u011b":"e","\u00ed":"i","\u013e":"l","\u0148":"n","\u00f3":"o","\u00f4":"o","\u0159":"r","\u0161":"s","\u0165":"t","\u00fa":"u","\u016f":"u","\u00fd":"y","\u017e":"z"};return d}); |
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
35707
654