inputmask.numeric.extensions.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. /*!
  2. * inputmask.numeric.extensions.js
  3. * https://github.com/RobinHerbots/jquery.inputmask
  4. * Copyright (c) 2010 - 2016 Robin Herbots
  5. * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
  6. * Version: 3.2.8-39
  7. */
  8. !function(factory) {
  9. "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);
  10. }(function($, Inputmask) {
  11. return Inputmask.extendAliases({
  12. numeric: {
  13. mask: function(opts) {
  14. function autoEscape(txt) {
  15. for (var escapedTxt = "", i = 0; i < txt.length; i++) escapedTxt += opts.definitions[txt.charAt(i)] || opts.optionalmarker.start === txt.charAt(i) || opts.optionalmarker.end === txt.charAt(i) || opts.quantifiermarker.start === txt.charAt(i) || opts.quantifiermarker.end === txt.charAt(i) || opts.groupmarker.start === txt.charAt(i) || opts.groupmarker.end === txt.charAt(i) || opts.alternatormarker === txt.charAt(i) ? "\\" + txt.charAt(i) : txt.charAt(i);
  16. return escapedTxt;
  17. }
  18. if (0 !== opts.repeat && isNaN(opts.integerDigits) && (opts.integerDigits = opts.repeat),
  19. opts.repeat = 0, opts.groupSeparator === opts.radixPoint && ("." === opts.radixPoint ? opts.groupSeparator = "," : "," === opts.radixPoint ? opts.groupSeparator = "." : opts.groupSeparator = ""),
  20. " " === opts.groupSeparator && (opts.skipOptionalPartCharacter = void 0), opts.autoGroup = opts.autoGroup && "" !== opts.groupSeparator,
  21. opts.autoGroup && ("string" == typeof opts.groupSize && isFinite(opts.groupSize) && (opts.groupSize = parseInt(opts.groupSize)),
  22. isFinite(opts.integerDigits))) {
  23. var seps = Math.floor(opts.integerDigits / opts.groupSize), mod = opts.integerDigits % opts.groupSize;
  24. opts.integerDigits = parseInt(opts.integerDigits) + (0 === mod ? seps - 1 : seps),
  25. opts.integerDigits < 1 && (opts.integerDigits = "*");
  26. }
  27. opts.placeholder.length > 1 && (opts.placeholder = opts.placeholder.charAt(0)),
  28. opts.radixFocus = opts.radixFocus && "" !== opts.placeholder && opts.integerOptional === !0,
  29. opts.definitions[";"] = opts.definitions["~"], opts.definitions[";"].definitionSymbol = "~",
  30. opts.numericInput === !0 && (opts.radixFocus = !1, opts.digitsOptional = !1, isNaN(opts.digits) && (opts.digits = 2),
  31. opts.decimalProtect = !1);
  32. var mask = autoEscape(opts.prefix);
  33. return mask += "[+]", mask += opts.integerOptional === !0 ? "~{1," + opts.integerDigits + "}" : "~{" + opts.integerDigits + "}",
  34. void 0 !== opts.digits && (isNaN(opts.digits) || parseInt(opts.digits) > 0) && (opts.decimalProtect && (opts.radixPointDefinitionSymbol = ":"),
  35. mask += opts.digitsOptional ? "[" + (opts.decimalProtect ? ":" : opts.radixPoint) + ";{1," + opts.digits + "}]" : (opts.decimalProtect ? ":" : opts.radixPoint) + ";{" + opts.digits + "}"),
  36. mask += "[-]", mask += autoEscape(opts.suffix), opts.greedy = !1, null !== opts.min && (opts.min = opts.min.toString().replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  37. "," === opts.radixPoint && (opts.min = opts.min.replace(opts.radixPoint, "."))),
  38. null !== opts.max && (opts.max = opts.max.toString().replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  39. "," === opts.radixPoint && (opts.max = opts.max.replace(opts.radixPoint, "."))),
  40. mask;
  41. },
  42. placeholder: "",
  43. greedy: !1,
  44. digits: "*",
  45. digitsOptional: !0,
  46. radixPoint: ".",
  47. radixFocus: !0,
  48. groupSize: 3,
  49. groupSeparator: "",
  50. autoGroup: !1,
  51. allowPlus: !0,
  52. allowMinus: !0,
  53. negationSymbol: {
  54. front: "-",
  55. back: ""
  56. },
  57. integerDigits: "+",
  58. integerOptional: !0,
  59. prefix: "",
  60. suffix: "",
  61. rightAlign: !0,
  62. decimalProtect: !0,
  63. min: null,
  64. max: null,
  65. step: 1,
  66. insertMode: !0,
  67. autoUnmask: !1,
  68. unmaskAsNumber: !1,
  69. postFormat: function(buffer, pos, opts) {
  70. opts.numericInput === !0 && (buffer = buffer.reverse(), isFinite(pos) && (pos = buffer.join("").length - pos - 1));
  71. var i, l, suffixStripped = !1;
  72. buffer.length >= opts.suffix.length && buffer.join("").indexOf(opts.suffix) === buffer.length - opts.suffix.length && (buffer.length = buffer.length - opts.suffix.length,
  73. suffixStripped = !0), pos = pos >= buffer.length ? buffer.length - 1 : pos < opts.prefix.length ? opts.prefix.length : pos;
  74. var needsRefresh = !1, charAtPos = buffer[pos], cbuf = buffer.slice();
  75. charAtPos === opts.groupSeparator && (cbuf.splice(pos--, 1), charAtPos = cbuf[pos]),
  76. charAtPos !== opts.radixPoint && charAtPos !== opts.negationSymbol.front && charAtPos !== opts.negationSymbol.back && (cbuf[pos] = "?");
  77. var bufVal = cbuf.join(""), bufValOrigin = bufVal;
  78. if (bufVal.length > 0 && opts.autoGroup || -1 !== bufVal.indexOf(opts.groupSeparator)) {
  79. var escapedGroupSeparator = Inputmask.escapeRegex(opts.groupSeparator);
  80. needsRefresh = 0 === bufVal.indexOf(opts.groupSeparator), bufVal = bufVal.replace(new RegExp(escapedGroupSeparator, "g"), "");
  81. var radixSplit = bufVal.split(opts.radixPoint);
  82. if (bufVal = "" === opts.radixPoint ? bufVal : radixSplit[0], bufVal !== opts.prefix + "?0" && bufVal.length >= opts.groupSize + opts.prefix.length) for (var reg = new RegExp("([-+]?[\\d?]+)([\\d?]{" + opts.groupSize + "})"); reg.test(bufVal) && "" !== opts.groupSeparator; ) bufVal = bufVal.replace(reg, "$1" + opts.groupSeparator + "$2"),
  83. bufVal = bufVal.replace(opts.groupSeparator + opts.groupSeparator, opts.groupSeparator);
  84. "" !== opts.radixPoint && radixSplit.length > 1 && (bufVal += opts.radixPoint + radixSplit[1]);
  85. }
  86. for (needsRefresh = bufValOrigin !== bufVal, buffer.length = bufVal.length, i = 0,
  87. l = bufVal.length; l > i; i++) buffer[i] = bufVal.charAt(i);
  88. var newPos = $.inArray("?", buffer);
  89. if (-1 === newPos && (newPos = $.inArray(charAtPos, buffer)), buffer[newPos] = charAtPos,
  90. !needsRefresh && suffixStripped) for (i = 0, l = opts.suffix.length; l > i; i++) buffer.push(opts.suffix.charAt(i));
  91. return newPos = opts.numericInput && isFinite(pos) ? buffer.join("").length - newPos - 1 : newPos,
  92. opts.numericInput && (buffer = buffer.reverse(), $.inArray(opts.radixPoint, buffer) < newPos && buffer.join("").length - opts.suffix.length !== newPos && (newPos -= 1)),
  93. {
  94. pos: newPos,
  95. refreshFromBuffer: needsRefresh,
  96. buffer: buffer
  97. };
  98. },
  99. onBeforeWrite: function(e, buffer, caretPos, opts) {
  100. var rslt;
  101. if (e && ("blur" === e.type || "checkval" === e.type || "keydown" === e.type)) {
  102. var maskedValue = opts.numericInput ? buffer.slice().reverse().join("") : buffer.join(""), processValue = maskedValue.replace(opts.prefix, "");
  103. processValue = processValue.replace(opts.suffix, ""), processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  104. "," === opts.radixPoint && (processValue = processValue.replace(opts.radixPoint, "."));
  105. var isNegative = processValue.match(new RegExp("[-" + Inputmask.escapeRegex(opts.negationSymbol.front) + "]", "g"));
  106. if (isNegative = null !== isNegative && 1 === isNegative.length, processValue = processValue.replace(new RegExp("[-" + Inputmask.escapeRegex(opts.negationSymbol.front) + "]", "g"), ""),
  107. processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), ""),
  108. processValue = processValue === opts.negationSymbol.front ? processValue + "0" : processValue,
  109. "" !== processValue && isFinite(processValue)) {
  110. var floatValue = parseFloat(processValue), signedFloatValue = isNegative ? -1 * floatValue : floatValue;
  111. if (null !== opts.min && isFinite(opts.min) && signedFloatValue < parseFloat(opts.min) ? (floatValue = Math.abs(opts.min),
  112. isNegative = opts.min < 0, maskedValue = void 0) : null !== opts.max && isFinite(opts.max) && signedFloatValue > parseFloat(opts.max) && (floatValue = Math.abs(opts.max),
  113. isNegative = opts.max < 0, maskedValue = void 0), processValue = floatValue.toString().replace(".", opts.radixPoint).split(""),
  114. isFinite(opts.digits)) {
  115. var radixPosition = $.inArray(opts.radixPoint, processValue), rpb = $.inArray(opts.radixPoint, maskedValue);
  116. -1 === radixPosition && (processValue.push(opts.radixPoint), radixPosition = processValue.length - 1);
  117. for (var i = 1; i <= opts.digits; i++) opts.digitsOptional || void 0 !== processValue[radixPosition + i] && processValue[radixPosition + i] !== opts.placeholder.charAt(0) ? -1 !== rpb && void 0 !== maskedValue[rpb + i] && (processValue[radixPosition + i] = processValue[radixPosition + i] || maskedValue[rpb + i]) : processValue[radixPosition + i] = "0";
  118. processValue[processValue.length - 1] === opts.radixPoint && delete processValue[processValue.length - 1];
  119. }
  120. if (floatValue.toString() !== processValue && floatValue.toString() + "." !== processValue || isNegative) return !isNegative || 0 === floatValue && "blur" === e.type || (processValue.unshift(opts.negationSymbol.front),
  121. processValue.push(opts.negationSymbol.back)), processValue = (opts.prefix + processValue.join("")).split(""),
  122. opts.numericInput && (processValue = processValue.reverse()), rslt = opts.postFormat(processValue, opts.numericInput ? caretPos : caretPos - 1, opts),
  123. rslt.buffer && (rslt.refreshFromBuffer = rslt.buffer.join("") !== buffer.join("")),
  124. rslt;
  125. }
  126. }
  127. return opts.autoGroup ? (rslt = opts.postFormat(buffer, opts.numericInput ? caretPos : caretPos - 1, opts),
  128. rslt.caret = caretPos <= opts.prefix.length ? rslt.pos : rslt.pos + 1, rslt) : void 0;
  129. },
  130. regex: {
  131. integerPart: function(opts) {
  132. return new RegExp("[" + Inputmask.escapeRegex(opts.negationSymbol.front) + "+]?\\d+");
  133. },
  134. integerNPart: function(opts) {
  135. return new RegExp("[\\d" + Inputmask.escapeRegex(opts.groupSeparator) + Inputmask.escapeRegex(opts.placeholder.charAt(0)) + "]+");
  136. }
  137. },
  138. signHandler: function(chrs, maskset, pos, strict, opts) {
  139. if (!strict && opts.allowMinus && "-" === chrs || opts.allowPlus && "+" === chrs) {
  140. var matchRslt = maskset.buffer.join("").match(opts.regex.integerPart(opts));
  141. if (matchRslt && matchRslt[0].length > 0) return maskset.buffer[matchRslt.index] === ("-" === chrs ? "+" : opts.negationSymbol.front) ? "-" === chrs ? "" !== opts.negationSymbol.back ? {
  142. pos: matchRslt.index,
  143. c: opts.negationSymbol.front,
  144. remove: matchRslt.index,
  145. caret: pos,
  146. insert: {
  147. pos: maskset.buffer.length - opts.suffix.length - 1,
  148. c: opts.negationSymbol.back
  149. }
  150. } : {
  151. pos: matchRslt.index,
  152. c: opts.negationSymbol.front,
  153. remove: matchRslt.index,
  154. caret: pos
  155. } : "" !== opts.negationSymbol.back ? {
  156. pos: matchRslt.index,
  157. c: "+",
  158. remove: [ matchRslt.index, maskset.buffer.length - opts.suffix.length - 1 ],
  159. caret: pos
  160. } : {
  161. pos: matchRslt.index,
  162. c: "+",
  163. remove: matchRslt.index,
  164. caret: pos
  165. } : maskset.buffer[matchRslt.index] === ("-" === chrs ? opts.negationSymbol.front : "+") ? "-" === chrs && "" !== opts.negationSymbol.back ? {
  166. remove: [ matchRslt.index, maskset.buffer.length - opts.suffix.length - 1 ],
  167. caret: pos - 1
  168. } : {
  169. remove: matchRslt.index,
  170. caret: pos - 1
  171. } : "-" === chrs ? "" !== opts.negationSymbol.back ? {
  172. pos: matchRslt.index,
  173. c: opts.negationSymbol.front,
  174. caret: pos + 1,
  175. insert: {
  176. pos: maskset.buffer.length - opts.suffix.length,
  177. c: opts.negationSymbol.back
  178. }
  179. } : {
  180. pos: matchRslt.index,
  181. c: opts.negationSymbol.front,
  182. caret: pos + 1
  183. } : {
  184. pos: matchRslt.index,
  185. c: chrs,
  186. caret: pos + 1
  187. };
  188. }
  189. return !1;
  190. },
  191. radixHandler: function(chrs, maskset, pos, strict, opts) {
  192. if (!strict && opts.numericInput !== !0 && chrs === opts.radixPoint && void 0 !== opts.digits && (isNaN(opts.digits) || parseInt(opts.digits) > 0)) {
  193. var radixPos = $.inArray(opts.radixPoint, maskset.buffer), integerValue = maskset.buffer.join("").match(opts.regex.integerPart(opts));
  194. if (-1 !== radixPos && maskset.validPositions[radixPos]) return maskset.validPositions[radixPos - 1] ? {
  195. caret: radixPos + 1
  196. } : {
  197. pos: integerValue.index,
  198. c: integerValue[0],
  199. caret: radixPos + 1
  200. };
  201. if (!integerValue || "0" === integerValue[0] && integerValue.index + 1 !== pos) return maskset.buffer[integerValue ? integerValue.index : pos] = "0",
  202. {
  203. pos: (integerValue ? integerValue.index : pos) + 1,
  204. c: opts.radixPoint
  205. };
  206. }
  207. return !1;
  208. },
  209. leadingZeroHandler: function(chrs, maskset, pos, strict, opts, isSelection) {
  210. if (!strict) if (opts.numericInput === !0) {
  211. var buffer = maskset.buffer.slice("").reverse(), char = buffer[opts.prefix.length];
  212. if ("0" === char && void 0 === maskset.validPositions[pos - 1]) return {
  213. pos: pos,
  214. remove: buffer.length - opts.prefix.length - 1
  215. };
  216. } else {
  217. var radixPosition = $.inArray(opts.radixPoint, maskset.buffer), matchRslt = maskset.buffer.slice(0, -1 !== radixPosition ? radixPosition : void 0).join("").match(opts.regex.integerNPart(opts));
  218. if (matchRslt && (-1 === radixPosition || radixPosition >= pos)) {
  219. var decimalPart = -1 === radixPosition ? 0 : parseInt(maskset.buffer.slice(radixPosition + 1).join(""));
  220. if (0 === matchRslt[0].indexOf("" !== opts.placeholder ? opts.placeholder.charAt(0) : "0") && (matchRslt.index + 1 === pos || isSelection !== !0 && 0 === decimalPart)) return maskset.buffer.splice(matchRslt.index, 1),
  221. {
  222. pos: matchRslt.index,
  223. remove: matchRslt.index
  224. };
  225. if ("0" === chrs && pos <= matchRslt.index && matchRslt[0] !== opts.groupSeparator) return !1;
  226. }
  227. }
  228. return !0;
  229. },
  230. definitions: {
  231. "~": {
  232. validator: function(chrs, maskset, pos, strict, opts, isSelection) {
  233. var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
  234. if (!isValid && (isValid = opts.radixHandler(chrs, maskset, pos, strict, opts),
  235. !isValid && (isValid = strict ? new RegExp("[0-9" + Inputmask.escapeRegex(opts.groupSeparator) + "]").test(chrs) : new RegExp("[0-9]").test(chrs),
  236. isValid === !0 && (isValid = opts.leadingZeroHandler(chrs, maskset, pos, strict, opts, isSelection),
  237. isValid === !0)))) {
  238. var radixPosition = $.inArray(opts.radixPoint, maskset.buffer);
  239. isValid = -1 !== radixPosition && (opts.digitsOptional === !1 || maskset.validPositions[pos]) && opts.numericInput !== !0 && pos > radixPosition && !strict ? {
  240. pos: pos,
  241. remove: pos
  242. } : {
  243. pos: pos
  244. };
  245. }
  246. return isValid;
  247. },
  248. cardinality: 1
  249. },
  250. "+": {
  251. validator: function(chrs, maskset, pos, strict, opts) {
  252. var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
  253. return !isValid && (strict && opts.allowMinus && chrs === opts.negationSymbol.front || opts.allowMinus && "-" === chrs || opts.allowPlus && "+" === chrs) && (isValid = strict || "-" !== chrs ? !0 : "" !== opts.negationSymbol.back ? {
  254. pos: pos,
  255. c: "-" === chrs ? opts.negationSymbol.front : "+",
  256. caret: pos + 1,
  257. insert: {
  258. pos: maskset.buffer.length,
  259. c: opts.negationSymbol.back
  260. }
  261. } : {
  262. pos: pos,
  263. c: "-" === chrs ? opts.negationSymbol.front : "+",
  264. caret: pos + 1
  265. }), isValid;
  266. },
  267. cardinality: 1,
  268. placeholder: ""
  269. },
  270. "-": {
  271. validator: function(chrs, maskset, pos, strict, opts) {
  272. var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
  273. return !isValid && strict && opts.allowMinus && chrs === opts.negationSymbol.back && (isValid = !0),
  274. isValid;
  275. },
  276. cardinality: 1,
  277. placeholder: ""
  278. },
  279. ":": {
  280. validator: function(chrs, maskset, pos, strict, opts) {
  281. var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
  282. if (!isValid) {
  283. var radix = "[" + Inputmask.escapeRegex(opts.radixPoint) + "]";
  284. isValid = new RegExp(radix).test(chrs), isValid && maskset.validPositions[pos] && maskset.validPositions[pos].match.placeholder === opts.radixPoint && (isValid = {
  285. caret: pos + 1
  286. });
  287. }
  288. return isValid ? {
  289. c: opts.radixPoint
  290. } : isValid;
  291. },
  292. cardinality: 1,
  293. placeholder: function(opts) {
  294. return opts.radixPoint;
  295. }
  296. }
  297. },
  298. onUnMask: function(maskedValue, unmaskedValue, opts) {
  299. var processValue = maskedValue.replace(opts.prefix, "");
  300. return processValue = processValue.replace(opts.suffix, ""), processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  301. opts.unmaskAsNumber ? ("" !== opts.radixPoint && -1 !== processValue.indexOf(opts.radixPoint) && (processValue = processValue.replace(Inputmask.escapeRegex.call(this, opts.radixPoint), ".")),
  302. Number(processValue)) : processValue;
  303. },
  304. isComplete: function(buffer, opts) {
  305. var maskedValue = buffer.join(""), bufClone = buffer.slice();
  306. if (opts.postFormat(bufClone, 0, opts), bufClone.join("") !== maskedValue) return !1;
  307. var processValue = maskedValue.replace(opts.prefix, "");
  308. return processValue = processValue.replace(opts.suffix, ""), processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  309. "," === opts.radixPoint && (processValue = processValue.replace(Inputmask.escapeRegex(opts.radixPoint), ".")),
  310. isFinite(processValue);
  311. },
  312. onBeforeMask: function(initialValue, opts) {
  313. if ("" !== opts.radixPoint && isFinite(initialValue)) initialValue = initialValue.toString().replace(".", opts.radixPoint); else {
  314. var kommaMatches = initialValue.match(/,/g), dotMatches = initialValue.match(/\./g);
  315. dotMatches && kommaMatches ? dotMatches.length > kommaMatches.length ? (initialValue = initialValue.replace(/\./g, ""),
  316. initialValue = initialValue.replace(",", opts.radixPoint)) : kommaMatches.length > dotMatches.length ? (initialValue = initialValue.replace(/,/g, ""),
  317. initialValue = initialValue.replace(".", opts.radixPoint)) : initialValue = initialValue.indexOf(".") < initialValue.indexOf(",") ? initialValue.replace(/\./g, "") : initialValue = initialValue.replace(/,/g, "") : initialValue = initialValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "");
  318. }
  319. if (0 === opts.digits && (-1 !== initialValue.indexOf(".") ? initialValue = initialValue.substring(0, initialValue.indexOf(".")) : -1 !== initialValue.indexOf(",") && (initialValue = initialValue.substring(0, initialValue.indexOf(",")))),
  320. "" !== opts.radixPoint && isFinite(opts.digits) && -1 !== initialValue.indexOf(opts.radixPoint)) {
  321. var valueParts = initialValue.split(opts.radixPoint), decPart = valueParts[1].match(new RegExp("\\d*"))[0];
  322. if (parseInt(opts.digits) < decPart.toString().length) {
  323. var digitsFactor = Math.pow(10, parseInt(opts.digits));
  324. initialValue = initialValue.replace(Inputmask.escapeRegex(opts.radixPoint), "."),
  325. initialValue = Math.round(parseFloat(initialValue) * digitsFactor) / digitsFactor,
  326. initialValue = initialValue.toString().replace(".", opts.radixPoint);
  327. }
  328. }
  329. return initialValue.toString();
  330. },
  331. canClearPosition: function(maskset, position, lvp, strict, opts) {
  332. var positionInput = maskset.validPositions[position].input, canClear = positionInput !== opts.radixPoint || null !== maskset.validPositions[position].match.fn && opts.decimalProtect === !1 || isFinite(positionInput) || position === lvp || positionInput === opts.groupSeparator || positionInput === opts.negationSymbol.front || positionInput === opts.negationSymbol.back;
  333. return canClear;
  334. },
  335. onKeyDown: function(e, buffer, caretPos, opts) {
  336. var $input = $(this);
  337. if (e.ctrlKey) switch (e.keyCode) {
  338. case Inputmask.keyCode.UP:
  339. $input.val(parseFloat(this.inputmask.unmaskedvalue()) + parseInt(opts.step)), $input.trigger("setvalue");
  340. break;
  341. case Inputmask.keyCode.DOWN:
  342. $input.val(parseFloat(this.inputmask.unmaskedvalue()) - parseInt(opts.step)), $input.trigger("setvalue");
  343. }
  344. }
  345. },
  346. currency: {
  347. prefix: "$ ",
  348. groupSeparator: ",",
  349. alias: "numeric",
  350. placeholder: "0",
  351. autoGroup: !0,
  352. digits: 2,
  353. digitsOptional: !1,
  354. clearMaskOnLostFocus: !1
  355. },
  356. decimal: {
  357. alias: "numeric"
  358. },
  359. integer: {
  360. alias: "numeric",
  361. digits: 0,
  362. radixPoint: ""
  363. },
  364. percentage: {
  365. alias: "numeric",
  366. digits: 2,
  367. radixPoint: ".",
  368. placeholder: "0",
  369. autoGroup: !1,
  370. min: 0,
  371. max: 100,
  372. suffix: " %",
  373. allowPlus: !1,
  374. allowMinus: !1
  375. }
  376. }), Inputmask;
  377. });