MCPcopy Create free account
hub / github.com/ampproject/amphtml / ev

Function ev

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

Source from the content-addressed store, hash-verified

1612 var EventRuler = {
1613 on: function(input, eventName, eventHandler) {
1614 var ev = function(e) {
1615 var that = this;
1616 if (that.inputmask === undefined && this.nodeName !== "FORM") {
1617 var imOpts = $.data(that, "_inputmask_opts");
1618 if (imOpts) new Inputmask(imOpts).mask(that); else EventRuler.off(that);
1619 } else if (e.type !== "setvalue" && this.nodeName !== "FORM" && (that.disabled || that.readOnly && !(e.type === "keydown" && (e.ctrlKey && e.keyCode === 67) || opts.tabThrough === false && e.keyCode === Inputmask.keyCode.TAB))) {
1620 e.preventDefault();
1621 } else {
1622 switch (e.type) {
1623 case "input":
1624 if (skipInputEvent === true) {
1625 skipInputEvent = false;
1626 return e.preventDefault();
1627 }
1628 if (mobile) {
1629 var args = arguments;
1630 setTimeout(function() {
1631 eventHandler.apply(that, args);
1632 caret(that, that.inputmask.caretPos, undefined, true);
1633 }, 0);
1634 return false;
1635 }
1636 break;
1637
1638 case "keydown":
1639 skipKeyPressEvent = false;
1640 skipInputEvent = false;
1641 break;
1642
1643 case "keypress":
1644 if (skipKeyPressEvent === true) {
1645 return e.preventDefault();
1646 }
1647 skipKeyPressEvent = true;
1648 break;
1649
1650 case "click":
1651 if (iemobile || iphone) {
1652 var args = arguments;
1653 setTimeout(function() {
1654 eventHandler.apply(that, args);
1655 }, 0);
1656 return false;
1657 }
1658 break;
1659 }
1660 var returnVal = eventHandler.apply(that, arguments);
1661 if (returnVal === false) {
1662 e.preventDefault();
1663 e.stopPropagation();
1664 }
1665 return returnVal;
1666 }
1667 };
1668 input.inputmask.events[eventName] = input.inputmask.events[eventName] || [];
1669 input.inputmask.events[eventName].push(ev);
1670 if ($.inArray(eventName, [ "submit", "reset" ]) !== -1) {

Callers

nothing calls this directly

Calls 4

caretFunction · 0.85
offMethod · 0.80
applyMethod · 0.80
maskMethod · 0.45

Tested by

no test coverage detected