inputmask.numeric.extensions.js 26 KB

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