nette-forms
Advanced tools
Comparing version 3.2.0 to 3.3.0
{ | ||
"name": "nette-forms", | ||
"version": "3.2.0", | ||
"version": "3.3.0", | ||
"description": "Client side script for Nette Forms Component", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -5,3 +5,3 @@ Nette Forms: greatly facilitates web forms | ||
[![Downloads this Month](https://img.shields.io/packagist/dm/nette/forms.svg)](https://packagist.org/packages/nette/forms) | ||
[![Build Status](https://travis-ci.org/nette/forms.svg?branch=master)](https://travis-ci.org/nette/forms) | ||
[![Tests](https://github.com/nette/forms/workflows/Tests/badge.svg?branch=master)](https://github.com/nette/forms/actions) | ||
[![Coverage Status](https://coveralls.io/repos/github/nette/forms/badge.svg?branch=master)](https://coveralls.io/github/nette/forms?branch=master) | ||
@@ -28,5 +28,13 @@ [![Latest Stable Version](https://poser.pugx.org/nette/forms/v/stable)](https://github.com/nette/forms/releases) | ||
If you like Nette, **[please make a donation now](https://nette.org/donate)**. Thank you! | ||
[Support Me](https://github.com/sponsors/dg) | ||
-------------------------------------------- | ||
Do you like Nette Forms? Are you looking forward to the new features? | ||
[![Buy me a coffee](https://files.nette.org/icons/donation-3.svg)](https://github.com/sponsors/dg) | ||
Thank you! | ||
Installation | ||
@@ -41,3 +49,3 @@ ------------ | ||
It requires PHP version 7.2 and supports PHP up to 8.0. | ||
It requires PHP version 7.2 and supports PHP up to 8.1. | ||
@@ -44,0 +52,0 @@ |
@@ -37,3 +37,3 @@ /** | ||
Nette.formErrors = []; | ||
Nette.version = '3.0'; | ||
Nette.version = '3.3.0'; | ||
Nette.invalidNumberMessage = 'Please enter a valid value.'; | ||
@@ -298,8 +298,42 @@ | ||
if (messages.length) { | ||
alert(messages.join('\n')); | ||
Nette.showModal(messages.join('\n'), function () { | ||
if (focusElem) { | ||
focusElem.focus(); | ||
} | ||
}); | ||
} | ||
}; | ||
if (focusElem) { | ||
focusElem.focus(); | ||
} | ||
/** | ||
* Display modal window. | ||
*/ | ||
Nette.showModal = function(message, onclose) { | ||
var dialog = document.createElement('dialog'), | ||
ua = navigator.userAgentData; | ||
if (ua && dialog.showModal | ||
&& ua.brands.some(function(item) { return item.brand === 'Opera' || (item.brand === 'Chromium' && ua.mobile); }) | ||
) { | ||
var style = document.createElement('style'); | ||
style.innerText = '.netteFormsModal { text-align: center } .netteFormsModal button { padding: .1em 2em }'; | ||
var button = document.createElement('button'); | ||
button.innerText = 'OK'; | ||
button.onclick = function () { | ||
dialog.remove(); | ||
onclose(); | ||
}; | ||
dialog.setAttribute('class', 'netteFormsModal'); | ||
dialog.innerText = message + '\n\n'; | ||
dialog.appendChild(style); | ||
dialog.appendChild(button); | ||
document.body.appendChild(dialog); | ||
dialog.showModal(); | ||
return; | ||
} | ||
alert(message); | ||
onclose(); | ||
}; | ||
@@ -357,3 +391,3 @@ | ||
function toString(val) { | ||
var toString = function(val) { | ||
if (typeof val === 'number' || typeof val === 'string') { | ||
@@ -364,3 +398,3 @@ return '' + val; | ||
} | ||
} | ||
}; | ||
@@ -367,0 +401,0 @@ val = Array.isArray(val) ? val : [val]; |
/*! netteForms.js | (c) 2004 David Grudl (https://davidgrudl.com) */ | ||
(function(n,e){if(n.JSON)if("function"===typeof define&&define.amd)define(function(){return e(n)});else if("object"===typeof module&&"object"===typeof module.exports)module.exports=e(n);else{var v=!n.Nette||!n.Nette.noInit;n.Nette=e(n);v&&n.Nette.initOnLoad()}})("undefined"!==typeof window?window:this,function(n){var e={},v={},t={},y=new n.WeakMap;e.formErrors=[];e.version="3.0";e.invalidNumberMessage="Please enter a valid value.";e.onDocumentReady=function(a){"loading"!==document.readyState?a.call(this): | ||
(function(n,e){if(n.JSON)if("function"===typeof define&&define.amd)define(function(){return e(n)});else if("object"===typeof module&&"object"===typeof module.exports)module.exports=e(n);else{var v=!n.Nette||!n.Nette.noInit;n.Nette=e(n);v&&n.Nette.initOnLoad()}})("undefined"!==typeof window?window:this,function(n){var e={},v={},t={},y=new n.WeakMap;e.formErrors=[];e.version="3.3.0";e.invalidNumberMessage="Please enter a valid value.";e.onDocumentReady=function(a){"loading"!==document.readyState?a.call(this): | ||
document.addEventListener("DOMContentLoaded",a)};e.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 d=[];if("select-one"===a.type)return 0>c?null:b[c].value;for(c=0;c<b.length;c++)b[c].selected&&d.push(b[c].value);return d}if(a.name&&"[]"===a.name.substr(-2)){b= | ||
@@ -9,6 +9,7 @@ a.form.elements[a.name].tagName?[a]:a.form.elements[a.name];d=[];for(c=0;c<b.length;c++)("checkbox"!==b[c].type||b[c].checked)&&d.push(b[c].value);return d}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]?e.getValue(a[0]):null}return null};e.getEffectiveValue=function(a,c){var b=e.getValue(a);a.getAttribute&&b===a.getAttribute("data-nette-empty-value")&&(b="");c&&void 0===v[a.name]&&(v[a.name]= | ||
f[k.name]=!0}if(!(d&&!k.name.replace(/]\[|\[|]|$/g,"-").match(d)||e.isDisabled(k)||e.validateControl(k,null,c)||e.formErrors.length))return!1}}d=!e.formErrors.length;e.showFormErrors(b,e.formErrors);return d};e.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};e.addError=function(a,c){e.formErrors.push({element:a,message:c})};e.showFormErrors=function(a,c){for(var b=[],d,f=0;f<c.length;f++){var g= | ||
c[f].element,k=c[f].message;0>b.indexOf(k)&&(b.push(k),!d&&g.focus&&(d=g))}b.length&&(alert(b.join("\n")),d&&d.focus())};e.validateRule=function(a,c,b,d){d=void 0===d?{value:e.getEffectiveValue(a,!0)}:d;":"===c.charAt(0)&&(c=c.substr(1));c=c.replace("::","_");c=c.replace(/\\/g,"");for(var f=Array.isArray(b)?b.slice(0):[b],g=0,k=f.length;g<k;g++)if(f[g]&&f[g].control){var r=a.form.elements.namedItem(f[g].control);f[g]=r===a?d.value:e.getEffectiveValue(r,!0)}return e.validators[c]?e.validators[c](a, | ||
Array.isArray(b)?f:f[0],d.value,d):null};e.validators={filled:function(a,c,b){return"number"===a.type&&a.validity.badInput?!0:""!==b&&!1!==b&&null!==b&&(!Array.isArray(b)||!!b.length)&&(!n.FileList||!(b instanceof n.FileList)||b.length)},blank:function(a,c,b){return!e.validators.filled(a,c,b)},valid:function(a){return e.validateControl(a,null,!0)},equal:function(a,c,b){function d(r){return"number"===typeof r||"string"===typeof r?""+r:!0===r?"1":""}if(void 0===c)return null;b=Array.isArray(b)?b:[b]; | ||
c=Array.isArray(c)?c:[c];a=0;var f=b.length;a:for(;a<f;a++){for(var g=0,k=c.length;g<k;g++)if(d(b[a])===d(c[g]))continue a;return!1}return 0<b.length},notEqual:function(a,c,b){return void 0===c?null:!e.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)}, | ||
c[f].element,k=c[f].message;0>b.indexOf(k)&&(b.push(k),!d&&g.focus&&(d=g))}b.length&&e.showModal(b.join("\n"),function(){d&&d.focus()})};e.showModal=function(a,c){var b=document.createElement("dialog"),d=navigator.userAgentData;if(d&&b.showModal&&d.brands.some(function(k){return"Opera"===k.brand||"Chromium"===k.brand&&d.mobile})){var f=document.createElement("style");f.innerText=".netteFormsModal { text-align: center } .netteFormsModal button { padding: .1em 2em }";var g=document.createElement("button"); | ||
g.innerText="OK";g.onclick=function(){b.remove();c()};b.setAttribute("class","netteFormsModal");b.innerText=a+"\n\n";b.appendChild(f);b.appendChild(g);document.body.appendChild(b);b.showModal()}else alert(a),c()};e.validateRule=function(a,c,b,d){d=void 0===d?{value:e.getEffectiveValue(a,!0)}:d;":"===c.charAt(0)&&(c=c.substr(1));c=c.replace("::","_");c=c.replace(/\\/g,"");for(var f=Array.isArray(b)?b.slice(0):[b],g=0,k=f.length;g<k;g++)if(f[g]&&f[g].control){var r=a.form.elements.namedItem(f[g].control); | ||
f[g]=r===a?d.value:e.getEffectiveValue(r,!0)}return e.validators[c]?e.validators[c](a,Array.isArray(b)?f:f[0],d.value,d):null};e.validators={filled:function(a,c,b){return"number"===a.type&&a.validity.badInput?!0:""!==b&&!1!==b&&null!==b&&(!Array.isArray(b)||!!b.length)&&(!n.FileList||!(b instanceof n.FileList)||b.length)},blank:function(a,c,b){return!e.validators.filled(a,c,b)},valid:function(a){return e.validateControl(a,null,!0)},equal:function(a,c,b){if(void 0===c)return null;a=function(r){return"number"=== | ||
typeof r||"string"===typeof r?""+r:!0===r?"1":""};b=Array.isArray(b)?b:[b];c=Array.isArray(c)?c:[c];var d=0,f=b.length;a:for(;d<f;d++){for(var g=0,k=c.length;g<k;g++)if(a(b[d])===a(c[g]))continue a;return!1}return 0<b.length},notEqual:function(a,c,b){return void 0===c?null:!e.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="https://"+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]*)$/): | ||
@@ -15,0 +16,0 @@ !1;try{return a&&(new RegExp(a[1],a[2].replace("u",""))).test(b)}catch(d){}},pattern:function(a,c,b,d,f){if("string"!==typeof c)return null;try{try{var g=new RegExp("^(?:"+c+")$",f?"ui":"u")}catch(k){g=new RegExp("^(?:"+c+")$",f?"i":"")}if(n.FileList&&b instanceof FileList){for(a=0;a<b.length;a++)if(!g.test(b[a].name))return!1;return!0}return g.test(b)}catch(k){}},patternCaseInsensitive:function(a,c,b){return e.validators.pattern(a,c,b,null,!0)},numeric:function(a,c,b){return"number"===a.type&&a.validity.badInput? |
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
41098
745
94