Skip to content

Commit

Permalink
Merge pull request #322 from surveyjs/321-add-the-showmaskonhover-option
Browse files Browse the repository at this point in the history
Add the showMaskOnHover option
  • Loading branch information
tsv2013 authored Nov 15, 2022
2 parents 334fc2d + 1aa39c1 commit 5779648
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/inputmask.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function init(Survey) {
numericPlaceholder: "0",
autoUnmask: true,
clearIncomplete: true,
showMaskOnHover: true,
widgetIsLoaded: function () {
return typeof Inputmask != "undefined";
},
Expand All @@ -35,6 +36,11 @@ function init(Survey) {
category: "general",
default: true,
},
{
name: "showMaskOnHover:boolean",
category: "general",
default: true,
},
{ name: "inputFormat", category: "general" },
{
name: "inputMask",
Expand Down Expand Up @@ -96,6 +102,9 @@ function init(Survey) {
options.clearIncomplete = typeof surveyElement.clearIncomplete !== "undefined"
? surveyElement.clearIncomplete
: rootWidget.clearIncomplete;
options.showMaskOnHover = typeof surveyElement.showMaskOnHover !== "undefined"
? surveyElement.showMaskOnHover
: rootWidget.showMaskOnHover;
if (surveyElement.inputMask !== "none") {
options.inputFormat = surveyElement.inputFormat;
}
Expand All @@ -112,15 +121,14 @@ function init(Survey) {
options.digitsOptional = rootWidget.numericDigitsOptional;
options.prefix = surveyElement.prefix || "";
options.suffix = surveyElement.suffix || "";
options.placeholder = rootWidget.numericPlaceholder;
options.placeholder = rootWidget.numericPlaceholder;
}
// if (surveyElement.inputMask == "datetime") {
// mask = surveyElement.inputFormat;
// }
if (surveyElement.inputMask === "phone" && !!surveyElement.inputFormat) {
mask = surveyElement.inputFormat;
}

Inputmask(mask, options).mask(el);

el.onblur = function () {
Expand All @@ -138,7 +146,7 @@ function init(Survey) {
customWidgetData.isNeedRender = true;
};

var pushValueHandler = function () {
var pushValueHandler = function () {
if (!el.inputmask) return;
if (el.inputmask.isComplete()) {
surveyElement.value = options.autoUnmask
Expand All @@ -159,7 +167,7 @@ function init(Survey) {
surveyElement.valueChangedCallback = updateHandler;
updateHandler();
},
afterRender: function (question, el) {
afterRender: function (question, el) {
if (question.getType() != "multipletext") {
var input = el.querySelector("input") || el;
this.applyInputMask(question, input);
Expand Down

0 comments on commit 5779648

Please sign in to comment.