MCPcopy
hub / github.com/ampproject/amphtml / factory

Function factory

third_party/inputmask/bundle.js:2–2  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

1(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
2"use strict";var _inputmask=require("./inputmask.dependencyLib"),_inputmask2=require("./inputmask"),_inputmaskDate=require("./inputmask.date.extensions");function factory(e){var n=e.ownerDocument,t=n.defaultView,i=(0,_inputmask.factory)(t,n),a=(0,_inputmask2.factory)(i,t,n,void 0);return(0,_inputmaskDate.factory)(a),a}(window.AMP=window.AMP||[]).push(function(e){(e.dependencies=e.dependencies||{}).inputmaskFactory=factory});
3
4},{"./inputmask":4,"./inputmask.date.extensions":2,"./inputmask.dependencyLib":3}],2:[function(require,module,exports){
5"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function factory(e){var t=e.dependencyLib,r={d:["[1-9]|[12][0-9]|3[01]",Date.prototype.setDate,"day",Date.prototype.getDate],dd:["0[1-9]|[12][0-9]|3[01]",Date.prototype.setDate,"day",function(){return i(Date.prototype.getDate.call(this),2)}],ddd:[""],dddd:[""],m:["[1-9]|1[012]",Date.prototype.setMonth,"month",function(){return Date.prototype.getMonth.call(this)+1}],mm:["0[1-9]|1[012]",Date.prototype.setMonth,"month",function(){return i(Date.prototype.getMonth.call(this)+1,2)}],mmm:[""],mmmm:[""],yy:["[0-9]{2}",Date.prototype.setFullYear,"year",function(){return i(Date.prototype.getFullYear.call(this),2)}],yyyy:["[0-9]{4}",Date.prototype.setFullYear,"year",function(){return i(Date.prototype.getFullYear.call(this),4)}],h:["[1-9]|1[0-2]",Date.prototype.setHours,"hours",Date.prototype.getHours],hh:["0[1-9]|1[0-2]",Date.prototype.setHours,"hours",function(){return i(Date.prototype.getHours.call(this),2)}],hhh:["[0-9]+",Date.prototype.setHours,"hours",Date.prototype.getHours],H:["1?[0-9]|2[0-3]",Date.prototype.setHours,"hours",Date.prototype.getHours],HH:["[01][0-9]|2[0-3]",Date.prototype.setHours,"hours",function(){return i(Date.prototype.getHours.call(this),2)}],HHH:["[0-9]+",Date.prototype.setHours,"hours",Date.prototype.getHours],M:["[1-5]?[0-9]",Date.prototype.setMinutes,"minutes",Date.prototype.getMinutes],MM:["[0-5][0-9]",Date.prototype.setMinutes,"minutes",function(){return i(Date.prototype.getMinutes.call(this),2)}],s:["[1-5]?[0-9]",Date.prototype.setSeconds,"seconds",Date.prototype.getSeconds],ss:["[0-5][0-9]",Date.prototype.setSeconds,"seconds",function(){return i(Date.prototype.getSeconds.call(this),2)}],l:["[0-9]{3}",Date.prototype.setMilliseconds,"milliseconds",function(){return i(Date.prototype.getMilliseconds.call(this),3)}],L:["[0-9]{2}",Date.prototype.setMilliseconds,"milliseconds",function(){return i(Date.prototype.getMilliseconds.call(this),2)}],t:["[ap]"],tt:["[ap]m"],T:["[AP]"],TT:["[AP]M"],Z:[""],o:[""],S:[""]},o={isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:ss",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"};function a(e){if(!e.tokenizer){var t=[];for(var o in r)-1===t.indexOf(o[0])&&t.push(o[0]);e.tokenizer="("+t.join("+|")+")+?|.",e.tokenizer=new RegExp(e.tokenizer,"g")}return e.tokenizer}function n(t,o,n,i){for(var s,u="";s=a(n).exec(t);){if(void 0===o)if(r[s[0]])u+="("+r[s[0]][0]+")";else switch(s[0]){case"[":u+="(";break;case"]":u+=")?";break;default:u+=e.escapeRegex(s[0])}else if(r[s[0]])if(!0!==i&&r[s[0]][3])u+=r[s[0]][3].call(o.date);else r[s[0]][2]?u+=o["raw"+r[s[0]][2]]:u+=s[0];else u+=s[0]}return u}function i(e,t){for(e=String(e),t=t||2;e.length<t;)e="0"+e;return e}function s(e,t,o){var n,i,s,u={date:new Date(1,0,1)},l=e;function p(e){var t=e.replace(/[^0-9]/g,"0");if(t!=e){var r=e.replace(/[^0-9]/g,""),a=(o.min&&o.min[n]||e).toString(),i=(o.max&&o.max[n]||e).toString();t=r+(r<a.slice(0,r.length)?a.slice(r.length):r>i.slice(0,r.length)?i.slice(r.length):t.toString().slice(r.length))}return t}function y(e,t,r){e[n]=p(t),e["raw"+n]=t,void 0!==s&&s.call(e.date,"month"==n?parseInt(e[n])-1:e[n])}if("string"==typeof l){for(;i=a(o).exec(t);){var c=l.slice(0,i[0].length);r.hasOwnProperty(i[0])&&(r[i[0]][0],n=r[i[0]][2],s=r[i[0]][1],y(u,c)),l=l.slice(c.length)}return u}if(l&&"object"===_typeof(l)&&l.hasOwnProperty("date"))return l}function u(e){var t=e.inputmask;e.inputmask.remove(),e.addEventListener("input",function r(){0==e.value.length&&(e.removeEventListener("input",r),t.mask(e))})}return e.extendAliases({datetime:{mask:function(e){return r.S=e.i18n.ordinalSuffix.join("|"),e.inputFormat=o[e.inputFormat]||e.inputFormat,e.displayFormat=o[e.displayFormat]||e.displayFormat||e.inputFormat,e.outputFormat=o[e.outputFormat]||e.outputFormat||e.inputFormat,e.placeholder=""!==e.placeholder?e.placeholder:e.inputFormat.replace(/[\[\]]/,""),e.regex=n(e.inputFormat,void 0,e),null},placeholder:"",inputFormat:"isoDateTime",displayFormat:void 0,outputFormat:void 0,min:null,max:null,i18n:{dayNames:["Mon","Tue","Wed","Thu","Fri","Sat","Sun","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],monthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","January","February","March","April","May","June","July","August","September","October","November","December"],ordinalSuffix:["st","nd","rd","th"]},postValidation:function(e,t,r,o,a){o.min=s(o.min,o.inputFormat,o),o.max=s(o.max,o.inputFormat,o);var i=r,u=s(e.join(""),o.inputFormat,o);if(i&&u.date.getTime()==u.date.getTime()){var l=(i=function(e,t){return(!isFinite(e.rawday)||"29"==e.day&&!isFinite(e.rawyear)||e.year.length<4||new Date(e.date.getFullYear(),isFinite(e.rawmonth)?e.month:e.date.getMonth()+1,0).getDate()>=e.day)&&t}(u,i))&&function(e,t){var r=!0;if(!e.rawyear||!e.rawmonth||!e.rawday)return!1;if(t.min){if(e.rawyear){var o=e.rawyear.replace(/[^0-9]/g,"");r=t.min.year.substr(0,o.length)<=o}e.year===e.rawyear&&t.min.date.getTime()==t.min.date.getTime()&&(r=t.min.date.getTime()<=e.date.getTime())}return r&&t.max&&t.max.date.getTime()==t.max.date.getTime()&&(r=t.max.date.getTime()>=e.date.getTime()),r}(u,o);if(t&&l&&r.pos!==t)return{buffer:n(o.inputFormat,u,o),refreshFromBuffer:{start:t,end:r.pos}}}var p=e.length,y=a.tests[p];if(!y)return i;var c=y.map(function(e){return e.match}).filter(function(e){return/^[-\/]$/.test(e.def)});if(1===c.length){var d=c[0].def;return{buffer:e.concat([d]),refreshFromBuffer:{start:t,end:e.length+1}}}return i},onKeyDown:function(r,o,n,s,l,p){var y=this;if(r.ctrlKey&&r.keyCode===e.keyCode.RIGHT){for(var c,d=new Date,m="";c=a(s).exec(s.inputFormat);)"d"===c[0].charAt(0)?m+=i(d.getDate(),c[0].length):"m"===c[0].charAt(0)?m+=i(d.getMonth()+1,c[0].length):"yyyy"===c[0]?m+=d.getFullYear().toString():"y"===c[0].charAt(0)&&(m+=i(d.getYear(),c[0].length));y.inputmask._valueSet(m),t(y).trigger("setvalue")}var f=p.begin,h=p.end;if(r.keyCode===e.keyCode.BACKSPACE||r.keyCode===e.keyCode.DELETE||(r.metaKey||r.ctrlKey)&&r.keyCode==="X".charCodeAt(0)){var g=y.value.length,D=y.selectionStart!=g&&y.selectionEnd!=g;if(g>0&&D){u(y);var v=h-f;if(r.keyCode===e.keyCode.BACKSPACE){var F=0==v?f-1:f;y.value=l.slice(0,F)+l.slice(h),y.setSelectionRange(F,F)}else if(r.keyCode===e.keyCode.DELETE){var M=0==v?h+1:h;y.value=l.slice(0,f)+l.slice(M),y.setSelectionRange(f,f)}}}else if(p.begin!=p.end){if((r.metaKey||r.ctrlKey)&&r.keyCode==="V".charCodeAt(0))return void u(y);if(r.metaKey||r.ctrlKey)return;var S=String.fromCharCode(r.keyCode),T=r.shiftKey?S.toLocaleUpperCase():S.toLocaleLowerCase();/\s/.test(T)||(u(y),setTimeout(function(){y.value=l.slice(0,f)+T+l.slice(h),y.setSelectionRange(f+1,f+1)},0))}},onUnMask:function(e,t,r){return n(r.outputFormat,s(e,r.inputFormat,r),r,!0)},casing:function(e,t,r,o){return 0==t.nativeDef.indexOf("[ap]")?e.toLowerCase():0==t.nativeDef.indexOf("[AP]")?e.toUpperCase():e},insertMode:!1,shiftPositions:!1}}),e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.factory=factory;

Callers

nothing calls this directly

Calls 15

_typeofFunction · 0.85
concatMethod · 0.80
fireEventMethod · 0.80
applyMethod · 0.80
getAttributeMethod · 0.80
iFunction · 0.70
nFunction · 0.70
sFunction · 0.70
aFunction · 0.70
uFunction · 0.70
oFunction · 0.70
pFunction · 0.70

Tested by

no test coverage detected