todo/public/vendor/inputmask/dist/min/inputmask/inputmask.date.extensions.min.js

9 lines
10 KiB
JavaScript
Raw Normal View History

2020-06-23 04:40:37 +00:00
/*!
* inputmask.date.extensions.min.js
* https://github.com/RobinHerbots/Inputmask
* Copyright (c) 2010 - 2017 Robin Herbots
* Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
* Version: 3.3.11
*/
!function(e){"function"==typeof define&&define.amd?define(["./dependencyLibs/inputmask.dependencyLib","./inputmask"],e):"object"==typeof exports?module.exports=e(require("./dependencyLibs/inputmask.dependencyLib"),require("./inputmask")):e(window.dependencyLib||jQuery,window.Inputmask)}(function(e,a){function r(e){return isNaN(e)||29===new Date(e,2,0).getDate()}return a.extendAliases({"dd/mm/yyyy":{mask:"1/2/y",placeholder:"dd/mm/yyyy",regex:{val1pre:new RegExp("[0-3]"),val1:new RegExp("0[1-9]|[12][0-9]|3[01]"),val2pre:function(e){var r=a.escapeRegex.call(this,e);return new RegExp("((0[1-9]|[12][0-9]|3[01])"+r+"[01])")},val2:function(e){var r=a.escapeRegex.call(this,e);return new RegExp("((0[1-9]|[12][0-9])"+r+"(0[1-9]|1[012]))|(30"+r+"(0[13-9]|1[012]))|(31"+r+"(0[13578]|1[02]))")}},leapday:"29/02/",separator:"/",yearrange:{minyear:1900,maxyear:2099},isInYearRange:function(e,a,r){if(isNaN(e))return!1;var t=parseInt(e.concat(a.toString().slice(e.length))),n=parseInt(e.concat(r.toString().slice(e.length)));return!isNaN(t)&&(a<=t&&t<=r)||!isNaN(n)&&(a<=n&&n<=r)},determinebaseyear:function(e,a,r){var t=(new Date).getFullYear();if(e>t)return e;if(a<t){for(var n=a.toString().slice(0,2),y=a.toString().slice(2,4);a<n+r;)n--;var i=n+y;return e>i?e:i}if(e<=t&&t<=a){for(var s=t.toString().slice(0,2);a<s+r;)s--;var o=s+r;return o<e?e:o}return t},onKeyDown:function(r,t,n,y){var i=e(this);if(r.ctrlKey&&r.keyCode===a.keyCode.RIGHT){var s=new Date;i.val(s.getDate().toString()+(s.getMonth()+1).toString()+s.getFullYear().toString()),i.trigger("setvalue")}},getFrontValue:function(e,a,r){for(var t=0,n=0,y=0;y<e.length&&"2"!==e.charAt(y);y++){var i=r.definitions[e.charAt(y)];i?(t+=n,n=i.cardinality):n++}return a.join("").substr(t,n)},postValidation:function(e,a,t){var n,y,i=e.join("");return 0===t.mask.indexOf("y")?(y=i.substr(0,4),n=i.substring(4,10)):(y=i.substring(6,10),n=i.substr(0,6)),a&&(n!==t.leapday||r(y))},definitions:{1:{validator:function(e,a,r,t,n){var y=n.regex.val1.test(e);return t||y||e.charAt(1)!==n.separator&&-1==="-./".indexOf(e.charAt(1))||!(y=n.regex.val1.test("0"+e.charAt(0)))?y:(a.buffer[r-1]="0",{refreshFromBuffer:{start:r-1,end:r},pos:r,c:e.charAt(0)})},cardinality:2,prevalidator:[{validator:function(e,a,r,t,n){var y=e;isNaN(a.buffer[r+1])||(y+=a.buffer[r+1]);var i=1===y.length?n.regex.val1pre.test(y):n.regex.val1.test(y);if(i&&a.validPositions[r]&&(n.regex.val2(n.separator).test(e+a.validPositions[r].input)||(a.validPositions[r].input="0"===e?"1":"0")),!t&&!i){if(i=n.regex.val1.test(e+"0"))return a.buffer[r]=e,a.buffer[++r]="0",{pos:r,c:"0"};if(i=n.regex.val1.test("0"+e))return a.buffer[r]="0",r++,{pos:r}}return i},cardinality:1}]},2:{validator:function(e,a,r,t,n){var y=n.getFrontValue(a.mask,a.buffer,n);-1!==y.indexOf(n.placeholder[0])&&(y="01"+n.separator);var i=n.regex.val2(n.separator).test(y+e);return t||i||e.charAt(1)!==n.separator&&-1==="-./".indexOf(e.charAt(1))||!(i=n.regex.val2(n.separator).test(y+"0"+e.charAt(0)))?i:(a.buffer[r-1]="0",{refreshFromBuffer:{start:r-1,end:r},pos:r,c:e.charAt(0)})},cardinality:2,prevalidator:[{validator:function(e,a,r,t,n){isNaN(a.buffer[r+1])||(e+=a.buffer[r+1]);var y=n.getFrontValue(a.mask,a.buffer,n);-1!==y.indexOf(n.placeholder[0])&&(y="01"+n.separator);var i=1===e.length?n.regex.val2pre(n.separator).test(y+e):n.regex.val2(n.separator).test(y+e);return i&&a.validPositions[r]&&(n.regex.val2(n.separator).test(e+a.validPositions[r].input)||(a.validPositions[r].input="0"===e?"1":"0")),t||i||!(i=n.regex.val2(n.separator).test(y+"0"+e))?i:(a.buffer[r]="0",r++,{pos:r})},cardinality:1}]},y:{validator:function(e,a,r,t,n){return n.isInYearRange(e,n.yearrange.minyear,n.yearrange.maxyear)},cardinality:4,prevalidator:[{validator:function(e,a,r,t,n){var y=n.isInYearRange(e,n.yearrange.minyear,n.yearrange.maxyear);if(!t&&!y){var i=n.determinebaseyear(n.yearrange.minyear,n.yearrange.maxyear,e+"0").toString().slice(0,1);if(y=n.isInYearRange(i+e,n.yearrange.minyear,n.yearrange.maxyear))return a.buffer[r++]=i.charAt(0),{pos:r};if(i=n.determinebaseyear(n.yearrange.minyear,n.yearrange.maxyear,