From ff86f527d51072f8ec6525fe15491940c891cfc8 Mon Sep 17 00:00:00 2001 From: roberto emanuel Date: Fri, 22 Jul 2016 18:26:21 +0200 Subject: [PATCH 01/40] double click selection setting added doubleClickSelection setting lets users double click the input to select all its content --- src/jquery.maskMoney.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/jquery.maskMoney.js b/src/jquery.maskMoney.js index 889ac5f..5866bd1 100644 --- a/src/jquery.maskMoney.js +++ b/src/jquery.maskMoney.js @@ -58,7 +58,8 @@ decimal: ".", precision: 2, allowZero: false, - allowNegative: false + allowNegative: false, + doubleClickSelection: true }, parameters); return this.each(function () { @@ -377,12 +378,26 @@ } } + function doubleClickEvent() { + var input = $input.get(0), + start, + length; + if (input.setSelectionRange) { + length = $input.val().length; + start = settings.doubleClickSelection ? 0 : length; + input.setSelectionRange(start, length); + } else { + $input.val($input.val()); + } + } + $input.unbind(".maskMoney"); $input.bind("keypress.maskMoney", keypressEvent); $input.bind("keydown.maskMoney", keydownEvent); $input.bind("blur.maskMoney", blurEvent); $input.bind("focus.maskMoney", focusEvent); $input.bind("click.maskMoney", clickEvent); + $input.bind("dblclick.maskMoney", doubleClickEvent); $input.bind("cut.maskMoney", cutPasteEvent); $input.bind("paste.maskMoney", cutPasteEvent); $input.bind("mask.maskMoney", mask); From 1d21e4e31b5c8078f3139227559d35975c28db7e Mon Sep 17 00:00:00 2001 From: roberto emanuel Date: Mon, 19 Dec 2016 12:26:46 +0100 Subject: [PATCH 02/40] tests for doubleClickSelection added --- test/index.html | 1 + test/selection_test.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 test/selection_test.js diff --git a/test/index.html b/test/index.html index 99cfa2f..7b719f1 100644 --- a/test/index.html +++ b/test/index.html @@ -16,6 +16,7 @@ +
diff --git a/test/selection_test.js b/test/selection_test.js new file mode 100644 index 0000000..9b0b301 --- /dev/null +++ b/test/selection_test.js @@ -0,0 +1,19 @@ +"use strict"; + +module("double click selection"); +test("when double clicking", function() { + var input = $("#input1").maskMoney(); + input.val("123.45"); + input.maskMoney("mask"); + input.trigger("dblclick"); + equal(input.val(), "123.45", "the content does not change"); +}); + +test("when double clicking and hitting delete", function() { + var input = $("#input1").maskMoney(); + input.val("12345"); + input.maskMoney("mask"); + input.trigger("dblclick"); + keydown(input, "backspace"); + equal(input.val(), "0.00", "all the content is cleared"); +}); \ No newline at end of file From 93abb356d925445696a7758c27d2cf4f949c6905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAnior=20Garcia?= Date: Mon, 27 Feb 2017 18:05:04 -0300 Subject: [PATCH 03/40] Fixed bug of unresolved module for webpack users The lack of the "main" key with the value of the main file caused an error of unresolved module in webpack. --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 870a361..692b7ac 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "dependencies": { "jquery": "latest" }, + "main": "dist/jquery.maskMoney.js", "npmName": "jquery-maskmoney", "npmFileMap": [ { From 627f0ce11d83c68f0d70eef2609730ef4a95bea7 Mon Sep 17 00:00:00 2001 From: Andrew Duncan Date: Sun, 26 Mar 2017 18:24:00 -0400 Subject: [PATCH 04/40] Add formatOnBlur, reverse, and selectAllOnFocus features --- Gruntfile.js | 2 +- README.md | 4 + demo/index.html | 21 +++++ dist/jquery.maskMoney.js | 177 ++++++++++++++++++++++++---------- dist/jquery.maskMoney.min.js | 4 +- maskMoney.jquery.json | 4 +- src/jquery.maskMoney.js | 178 ++++++++++++++++++++++++++--------- 7 files changed, 291 insertions(+), 99 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index ae5b686..baa0138 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -10,7 +10,7 @@ module.exports = function(grunt) { " * <%= pkg.homepage %>\n" + " *\n" + " * Made by <%= pkg.author.name %>\n" + - " * Under <%= pkg.licenses[0].type %> License (<%= pkg.licenses[0].url %>)\n" + + " * Under <%= pkg.license %> License\n" + " */\n" }, jshint: { diff --git a/README.md b/README.md index f569e63..41164db 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,9 @@ The options that you can set are: * `precision`: how many decimal places are allowed. default: 2 * `allowZero`: use this setting to prevent users from inputing zero. default: false * `allowNegative`: use this setting to prevent users from inputing negative values. default: false + * `formatOnBlur`: delay formatting of text field until focus leaves the field. default: false + * `reverse`: by default, `maskMoney` applies keystrokes from right to left. use this setting to apply keystrokes from left to right. + * `selectAllOnFocus`: select all text in the input when the element fires the focus event. default :false __IMPORTANT__: if you try to bind maskMoney to a read only field, nothing will happen, since we ignore completely read only fields. So, if you have a read only field, try to bind maskMoney to it, it will not work. Even if you change the field removing the readonly property, you will need to re-bind maskMoney to make it work. @@ -89,6 +92,7 @@ npm install && grunt test * [Daniel Loureiro](https://github.com/loureirorg) * [Thiago Silva](http://twitter.com/tafs7/) * [Guilherme Nagatomo](https://github.com/guilhermehn) + * [Andrew Duncan](https://github.com/abduncan) *** ### License: diff --git a/demo/index.html b/demo/index.html index e586b25..04b9cca 100644 --- a/demo/index.html +++ b/demo/index.html @@ -13,6 +13,8 @@ @@ -58,6 +60,25 @@

jQuery-maskMoney examples

var num = $('#demo8').maskMoney('unmasked')[0]; alert('type: '+ typeof(num) + ', value: ' + num) + + +
$("#demo9").maskMoney({ formatOnBlur: true, prefix: '$' });
+ + + +

Note: The reverse option is meant to be used with the formatOnBlur option.

+
+			$("#demo10").maskMoney({ formatOnBlur: true, reverse: true, prefix: '$' });
+		
+ + +
$("#demo11").maskMoney({ selectAllOnFocus: true });
$("#demo11").maskMoney({ selectAllOnFocus: true });
+ + + + +
+			$("#demo12").maskMoney({ formatOnBlur: true, reverse: true, prefix: '$', selectAllOnFocus: true });
+			var num = $('#demo12').maskMoney('applyMask', $('#demo12').val());
+			alert('Mask applied '+ num);
+		
+
$("#demo13").maskMoney({ formatOnBlur: true, reverse: true, prefix: '$', selectAllOnFocus: true, precision: 0 });
$("#demo13").maskMoney({ formatOnBlur: true, reverse: true, prefix: '$', selectAllOnFocus: true, precision: 0 });
+ + + +
$("#demo14").maskMoney({ formatOnBlur: true, reverse: true, prefix: '$', selectAllOnFocus: true, precision: 4, allowEmpty: true });
+ +
From d9eef7d3e138b7d55d3bece66979aba3506793f4 Mon Sep 17 00:00:00 2001 From: jzywien Date: Tue, 28 Mar 2017 10:52:26 -0400 Subject: [PATCH 10/40] Updated Readme to include allowEmpty --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 41164db..e838d34 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ The options that you can set are: * `formatOnBlur`: delay formatting of text field until focus leaves the field. default: false * `reverse`: by default, `maskMoney` applies keystrokes from right to left. use this setting to apply keystrokes from left to right. * `selectAllOnFocus`: select all text in the input when the element fires the focus event. default :false + * `allowEmpty`: allow empty input values, so that when you delete the number it doesn't reset to 0.00. default: false __IMPORTANT__: if you try to bind maskMoney to a read only field, nothing will happen, since we ignore completely read only fields. So, if you have a read only field, try to bind maskMoney to it, it will not work. Even if you change the field removing the readonly property, you will need to re-bind maskMoney to make it work. From e050ec0baae60b58047f7e19db607f3934584366 Mon Sep 17 00:00:00 2001 From: jzywien Date: Tue, 28 Mar 2017 14:06:29 -0400 Subject: [PATCH 11/40] Don't format on blur when allowEmpty is true --- dist/jquery.maskMoney.js | 4 +++- dist/jquery.maskMoney.min.js | 2 +- src/jquery.maskMoney.js | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/dist/jquery.maskMoney.js b/dist/jquery.maskMoney.js index 5757fed..ca1991c 100644 --- a/dist/jquery.maskMoney.js +++ b/dist/jquery.maskMoney.js @@ -381,7 +381,9 @@ applyMask(e); } - if ($input.val() === "" || $input.val() === setSymbol(getDefaultMask(), settings)) { + if ($input.val() === "" && settings.allowEmpty) { + $input.val(""); + } else if ($input.val() === "" || $input.val() === setSymbol(getDefaultMask(), settings)) { if (!settings.allowZero) { $input.val(""); } else if (!settings.affixesStay) { diff --git a/dist/jquery.maskMoney.min.js b/dist/jquery.maskMoney.min.js index 52c720f..496fb77 100644 --- a/dist/jquery.maskMoney.min.js +++ b/dist/jquery.maskMoney.min.js @@ -6,4 +6,4 @@ * Made by Diego Plentz * Under MIT License */ -!function($){"use strict";function a(a,b){var c="";return a.indexOf("-")>-1&&(a=a.replace("-",""),c="-"),a.indexOf(b.prefix)>-1&&(a=a.replace(b.prefix,"")),a.indexOf(b.suffix)>-1&&(a=a.replace(b.suffix,"")),c+b.prefix+a+b.suffix}function b(a,b){return b.allowEmpty&&""===a?"":b.reverse?d(a,b):c(a,b)}function c(b,c){var d,f,g,h=b.indexOf("-")>-1&&c.allowNegative?"-":"",i=b.replace(/[^0-9]/g,""),j=i.slice(0,i.length-c.precision);return d=e(j,h,c),c.precision>0&&(f=i.slice(i.length-c.precision),g=new Array(c.precision+1-f.length).join(0),d+=c.decimal+g+f),a(d,c)}function d(b,c){var d,f=b.indexOf("-")>-1&&c.allowNegative?"-":"",g=b.replace(c.prefix,"").replace(c.suffix,""),h=g.split(c.decimal)[0],i="";if(""===h&&(h="0"),d=e(h,f,c),c.precision>0){var j=g.split(c.decimal);j.length>1&&(i=j[1]),d+=c.decimal+i;var k=Number.parseFloat(h+"."+i).toFixed(c.precision),l=k.toString().split(c.decimal)[1];d=d.split(c.decimal)[0]+"."+l}return a(d,c)}function e(a,b,c){return a=a.replace(/^0*/g,""),a=a.replace(/\B(?=(\d{3})+(?!\d))/g,c.thousands),""===a&&(a="0"),b+a}$.browser||($.browser={},$.browser.mozilla=/mozilla/.test(navigator.userAgent.toLowerCase())&&!/webkit/.test(navigator.userAgent.toLowerCase()),$.browser.webkit=/webkit/.test(navigator.userAgent.toLowerCase()),$.browser.opera=/opera/.test(navigator.userAgent.toLowerCase()),$.browser.msie=/msie/.test(navigator.userAgent.toLowerCase()));var f={destroy:function(){return $(this).unbind(".maskMoney"),$.browser.msie&&(this.onpaste=null),this},applyMask:function(a){return b(a,$(this).data("settings"))},mask:function(a){return this.each(function(){var b=$(this);return"number"==typeof a&&b.val(a),b.trigger("mask")})},unmasked:function(){return this.map(function(){var a,b=$(this).val()||"0",c=b.indexOf("-")!==-1;return $(b.split(/\D/).reverse()).each(function(b,c){if(c)return a=c,!1}),b=b.replace(/\D/g,""),b=b.replace(new RegExp(a+"$"),"."+a),c&&(b="-"+b),parseFloat(b)})},init:function(c){return c=$.extend({prefix:"",suffix:"",affixesStay:!0,thousands:",",decimal:".",precision:2,allowZero:!1,allowNegative:!1,allowEmpty:!1},c),this.each(function(){function d(){var a,b,c,d,e,f=w.get(0),g=0,h=0;return"number"==typeof f.selectionStart&&"number"==typeof f.selectionEnd?(g=f.selectionStart,h=f.selectionEnd):(b=document.selection.createRange())&&b.parentElement()===f&&(d=f.value.length,a=f.value.replace(/\r\n/g,"\n"),c=f.createTextRange(),c.moveToBookmark(b.getBookmark()),e=f.createTextRange(),e.collapse(!1),c.compareEndPoints("StartToEnd",e)>-1?g=h=d:(g=-c.moveStart("character",-d),g+=a.slice(0,g).split("\n").length-1,c.compareEndPoints("EndToEnd",e)>-1?h=d:(h=-c.moveEnd("character",-d),h+=a.slice(0,h).split("\n").length-1))),{start:g,end:h}}function e(){var a=!(w.val().length>=w.attr("maxlength")&&w.attr("maxlength")>=0),b=d(),c=b.start,e=b.end,f=!(b.start===b.end||!w.val().substring(c,e).match(/\d/)),g="0"===w.val().substring(0,1);return a||f||g}function f(a){u.formatOnBlur||w.each(function(b,c){if(c.setSelectionRange)c.focus(),c.setSelectionRange(a,a);else if(c.createTextRange){var d=c.createTextRange();d.collapse(!0),d.moveEnd("character",a),d.moveStart("character",a),d.select()}})}function g(a){var c,d=w.val().length;w.val(b(w.val(),u)),c=w.val().length,u.reverse||(a-=d-c),f(a)}function h(){var a=w.val();u.allowEmpty&&""===a||(u.precision>0&&a.indexOf(u.decimal)<0&&(a+=u.decimal+new Array(u.precision+1).join(0)),w.val(b(a,u)))}function i(){var a=w.val();return u.allowNegative?""!==a&&"-"===a.charAt(0)?a.replace("-",""):"-"+a:a}function j(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function k(a){a=a||window.event;var b=a.which||a.charCode||a.keyCode,c=u.decimal.charCodeAt(0);return void 0!==b&&(!(b<48||b>57)||b===c&&u.reverse?!!e()&&((b!==c||!l())&&(!!u.formatOnBlur||(j(a),m(a),!1))):n(b,a))}function l(){return w.val().indexOf(u.decimal)>-1}function m(a){a=a||window.event;var b,c,e,f,h=a.which||a.charCode||a.keyCode,i="";h>=48&&h<=57&&(i=String.fromCharCode(h)),b=d(),c=b.start,e=b.end,f=w.val(),w.val(f.substring(0,c)+i+f.substring(e,f.length)),g(c+1)}function n(a,b){return 45===a?(w.val(i()),!1):43===a?(w.val(w.val().replace("-","")),!1):13===a||9===a||(!(!$.browser.mozilla||37!==a&&39!==a||0!==b.charCode)||(j(b),!0))}function o(a){a=a||window.event;var b,c,e,f,h,i=a.which||a.charCode||a.keyCode;return void 0!==i&&(b=d(),c=b.start,e=b.end,8!==i&&46!==i&&63272!==i||(j(a),f=w.val(),c===e&&(8===i?""===u.suffix?c-=1:(h=f.split("").reverse().join("").search(/\d/),c=f.length-h-1,e=c+1):e+=1),w.val(f.substring(0,c)+f.substring(e,f.length)),g(c),!1))}function p(){v=w.val(),h();var a,b=w.get(0);u.selectAllOnFocus?b.select():b.createTextRange&&(a=b.createTextRange(),a.collapse(!1),a.select())}function q(){setTimeout(function(){h()},0)}function r(){return(parseFloat("0")/Math.pow(10,u.precision)).toFixed(u.precision).replace(new RegExp("\\.","g"),u.decimal)}function s(b){if($.browser.msie&&k(b),u.formatOnBlur&&w.val()!==v&&m(b),""===w.val()||w.val()===a(r(),u))u.allowZero?u.affixesStay?w.val(a(r(),u)):w.val(r()):w.val("");else if(!u.affixesStay){var c=w.val().replace(u.prefix,"").replace(u.suffix,"");w.val(c)}w.val()!==v&&w.change()}function t(){var a,b=w.get(0);u.selectAllOnFocus||(b.setSelectionRange?(a=w.val().length,b.setSelectionRange(a,a)):w.val(w.val()))}var u,v,w=$(this);u=$.extend({},c),u=$.extend(u,w.data()),w.data("settings",u),w.unbind(".maskMoney"),w.bind("keypress.maskMoney",k),w.bind("keydown.maskMoney",o),w.bind("blur.maskMoney",s),w.bind("focus.maskMoney",p),w.bind("click.maskMoney",t),w.bind("cut.maskMoney",q),w.bind("paste.maskMoney",q),w.bind("mask.maskMoney",h)})}};$.fn.maskMoney=function(a){return f[a]?f[a].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof a&&a?void $.error("Method "+a+" does not exist on jQuery.maskMoney"):f.init.apply(this,arguments)}}(window.jQuery||window.Zepto); \ No newline at end of file +!function($){"use strict";function a(a,b){var c="";return a.indexOf("-")>-1&&(a=a.replace("-",""),c="-"),a.indexOf(b.prefix)>-1&&(a=a.replace(b.prefix,"")),a.indexOf(b.suffix)>-1&&(a=a.replace(b.suffix,"")),c+b.prefix+a+b.suffix}function b(a,b){return b.allowEmpty&&""===a?"":b.reverse?d(a,b):c(a,b)}function c(b,c){var d,f,g,h=b.indexOf("-")>-1&&c.allowNegative?"-":"",i=b.replace(/[^0-9]/g,""),j=i.slice(0,i.length-c.precision);return d=e(j,h,c),c.precision>0&&(f=i.slice(i.length-c.precision),g=new Array(c.precision+1-f.length).join(0),d+=c.decimal+g+f),a(d,c)}function d(b,c){var d,f=b.indexOf("-")>-1&&c.allowNegative?"-":"",g=b.replace(c.prefix,"").replace(c.suffix,""),h=g.split(c.decimal)[0],i="";if(""===h&&(h="0"),d=e(h,f,c),c.precision>0){var j=g.split(c.decimal);j.length>1&&(i=j[1]),d+=c.decimal+i;var k=Number.parseFloat(h+"."+i).toFixed(c.precision),l=k.toString().split(c.decimal)[1];d=d.split(c.decimal)[0]+"."+l}return a(d,c)}function e(a,b,c){return a=a.replace(/^0*/g,""),a=a.replace(/\B(?=(\d{3})+(?!\d))/g,c.thousands),""===a&&(a="0"),b+a}$.browser||($.browser={},$.browser.mozilla=/mozilla/.test(navigator.userAgent.toLowerCase())&&!/webkit/.test(navigator.userAgent.toLowerCase()),$.browser.webkit=/webkit/.test(navigator.userAgent.toLowerCase()),$.browser.opera=/opera/.test(navigator.userAgent.toLowerCase()),$.browser.msie=/msie/.test(navigator.userAgent.toLowerCase()));var f={destroy:function(){return $(this).unbind(".maskMoney"),$.browser.msie&&(this.onpaste=null),this},applyMask:function(a){return b(a,$(this).data("settings"))},mask:function(a){return this.each(function(){var b=$(this);return"number"==typeof a&&b.val(a),b.trigger("mask")})},unmasked:function(){return this.map(function(){var a,b=$(this).val()||"0",c=b.indexOf("-")!==-1;return $(b.split(/\D/).reverse()).each(function(b,c){if(c)return a=c,!1}),b=b.replace(/\D/g,""),b=b.replace(new RegExp(a+"$"),"."+a),c&&(b="-"+b),parseFloat(b)})},init:function(c){return c=$.extend({prefix:"",suffix:"",affixesStay:!0,thousands:",",decimal:".",precision:2,allowZero:!1,allowNegative:!1,allowEmpty:!1},c),this.each(function(){function d(){var a,b,c,d,e,f=w.get(0),g=0,h=0;return"number"==typeof f.selectionStart&&"number"==typeof f.selectionEnd?(g=f.selectionStart,h=f.selectionEnd):(b=document.selection.createRange())&&b.parentElement()===f&&(d=f.value.length,a=f.value.replace(/\r\n/g,"\n"),c=f.createTextRange(),c.moveToBookmark(b.getBookmark()),e=f.createTextRange(),e.collapse(!1),c.compareEndPoints("StartToEnd",e)>-1?g=h=d:(g=-c.moveStart("character",-d),g+=a.slice(0,g).split("\n").length-1,c.compareEndPoints("EndToEnd",e)>-1?h=d:(h=-c.moveEnd("character",-d),h+=a.slice(0,h).split("\n").length-1))),{start:g,end:h}}function e(){var a=!(w.val().length>=w.attr("maxlength")&&w.attr("maxlength")>=0),b=d(),c=b.start,e=b.end,f=!(b.start===b.end||!w.val().substring(c,e).match(/\d/)),g="0"===w.val().substring(0,1);return a||f||g}function f(a){u.formatOnBlur||w.each(function(b,c){if(c.setSelectionRange)c.focus(),c.setSelectionRange(a,a);else if(c.createTextRange){var d=c.createTextRange();d.collapse(!0),d.moveEnd("character",a),d.moveStart("character",a),d.select()}})}function g(a){var c,d=w.val().length;w.val(b(w.val(),u)),c=w.val().length,u.reverse||(a-=d-c),f(a)}function h(){var a=w.val();u.allowEmpty&&""===a||(u.precision>0&&a.indexOf(u.decimal)<0&&(a+=u.decimal+new Array(u.precision+1).join(0)),w.val(b(a,u)))}function i(){var a=w.val();return u.allowNegative?""!==a&&"-"===a.charAt(0)?a.replace("-",""):"-"+a:a}function j(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function k(a){a=a||window.event;var b=a.which||a.charCode||a.keyCode,c=u.decimal.charCodeAt(0);return void 0!==b&&(!(b<48||b>57)||b===c&&u.reverse?!!e()&&((b!==c||!l())&&(!!u.formatOnBlur||(j(a),m(a),!1))):n(b,a))}function l(){return w.val().indexOf(u.decimal)>-1}function m(a){a=a||window.event;var b,c,e,f,h=a.which||a.charCode||a.keyCode,i="";h>=48&&h<=57&&(i=String.fromCharCode(h)),b=d(),c=b.start,e=b.end,f=w.val(),w.val(f.substring(0,c)+i+f.substring(e,f.length)),g(c+1)}function n(a,b){return 45===a?(w.val(i()),!1):43===a?(w.val(w.val().replace("-","")),!1):13===a||9===a||(!(!$.browser.mozilla||37!==a&&39!==a||0!==b.charCode)||(j(b),!0))}function o(a){a=a||window.event;var b,c,e,f,h,i=a.which||a.charCode||a.keyCode;return void 0!==i&&(b=d(),c=b.start,e=b.end,8!==i&&46!==i&&63272!==i||(j(a),f=w.val(),c===e&&(8===i?""===u.suffix?c-=1:(h=f.split("").reverse().join("").search(/\d/),c=f.length-h-1,e=c+1):e+=1),w.val(f.substring(0,c)+f.substring(e,f.length)),g(c),!1))}function p(){v=w.val(),h();var a,b=w.get(0);u.selectAllOnFocus?b.select():b.createTextRange&&(a=b.createTextRange(),a.collapse(!1),a.select())}function q(){setTimeout(function(){h()},0)}function r(){return(parseFloat("0")/Math.pow(10,u.precision)).toFixed(u.precision).replace(new RegExp("\\.","g"),u.decimal)}function s(b){if($.browser.msie&&k(b),u.formatOnBlur&&w.val()!==v&&m(b),""===w.val()&&u.allowEmpty)w.val("");else if(""===w.val()||w.val()===a(r(),u))u.allowZero?u.affixesStay?w.val(a(r(),u)):w.val(r()):w.val("");else if(!u.affixesStay){var c=w.val().replace(u.prefix,"").replace(u.suffix,"");w.val(c)}w.val()!==v&&w.change()}function t(){var a,b=w.get(0);u.selectAllOnFocus||(b.setSelectionRange?(a=w.val().length,b.setSelectionRange(a,a)):w.val(w.val()))}var u,v,w=$(this);u=$.extend({},c),u=$.extend(u,w.data()),w.data("settings",u),w.unbind(".maskMoney"),w.bind("keypress.maskMoney",k),w.bind("keydown.maskMoney",o),w.bind("blur.maskMoney",s),w.bind("focus.maskMoney",p),w.bind("click.maskMoney",t),w.bind("cut.maskMoney",q),w.bind("paste.maskMoney",q),w.bind("mask.maskMoney",h)})}};$.fn.maskMoney=function(a){return f[a]?f[a].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof a&&a?void $.error("Method "+a+" does not exist on jQuery.maskMoney"):f.init.apply(this,arguments)}}(window.jQuery||window.Zepto); \ No newline at end of file diff --git a/src/jquery.maskMoney.js b/src/jquery.maskMoney.js index 1d19c61..40961c9 100644 --- a/src/jquery.maskMoney.js +++ b/src/jquery.maskMoney.js @@ -373,7 +373,9 @@ applyMask(e); } - if ($input.val() === "" || $input.val() === setSymbol(getDefaultMask(), settings)) { + if ($input.val() === "" && settings.allowEmpty) { + $input.val(""); + } else if ($input.val() === "" || $input.val() === setSymbol(getDefaultMask(), settings)) { if (!settings.allowZero) { $input.val(""); } else if (!settings.affixesStay) { From b33a5d122a97c30d6a8bcbc6678224051f85c4f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lio=20Saraiva?= Date: Wed, 29 Mar 2017 11:32:21 -0300 Subject: [PATCH 12/40] Change href aureliosaraiva --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f569e63..8ddd635 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ npm install && grunt test *** ### Contributors: - * [Aurélio Saraiva](mailto:aureliosaraiva@gmail.com) + * [Aurélio Saraiva](http://github.com/aureliosaraiva) * [Raul Pereira da Silva](http://raulpereira.com) * [Diego Plentz](http://plentz.org) * [Otávio Ribeiro Medeiros](http://github.com/otaviomedeiros) From 836abc27946d79b4c5f9bcfffc842f37417ba75e Mon Sep 17 00:00:00 2001 From: Aurelio Saraiva Date: Wed, 29 Mar 2017 12:05:28 -0300 Subject: [PATCH 13/40] add jquery in bower' --- .gitignore | 1 + README.md | 4 +++- test/index.html | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index c2658d7..68b9e27 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules/ +bower_components/ diff --git a/README.md b/README.md index f569e63..79bcdbb 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,9 @@ You can also configure maskMoney options using the data-* API instead of passing To run our test suite, just clone the repo and open `test/index.html`. If you want to run it using nodejs, clone the repo and run: ``` -npm install && grunt test +npm install +bower install +grunt test ``` *** diff --git a/test/index.html b/test/index.html index 99cfa2f..d59b6f5 100644 --- a/test/index.html +++ b/test/index.html @@ -4,7 +4,7 @@ jQuery maskMoney Test Suite - + From e5a837568ef075cf25e7a0223d437708af31ab8d Mon Sep 17 00:00:00 2001 From: Aurelio Saraiva Date: Wed, 29 Mar 2017 12:14:20 -0300 Subject: [PATCH 14/40] add config bower travis --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4cee540..b5f0e13 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,6 @@ language: node_js node_js: - - 0.10 \ No newline at end of file + - 0.10 +before_script: + - npm install -g bower + - bower install From a934cd2b48bf3253471a036b0c219dcd4018e2c8 Mon Sep 17 00:00:00 2001 From: Aurelio Saraiva Date: Wed, 29 Mar 2017 13:20:59 -0300 Subject: [PATCH 15/40] config travis --- .travis.yml | 4 ++-- package.json | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b5f0e13..79fa2f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: node_js node_js: - - 0.10 -before_script: + - 4 +install: - npm install -g bower - bower install diff --git a/package.json b/package.json index 870a361..23805a4 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,9 @@ "dependencies": { "jquery": "latest" }, + "engines": { + "node": ">=4" + }, "npmName": "jquery-maskmoney", "npmFileMap": [ { From 885a7266942a278bfada49ae55c3384673bfa2c5 Mon Sep 17 00:00:00 2001 From: Aurelio Saraiva Date: Wed, 29 Mar 2017 13:24:51 -0300 Subject: [PATCH 16/40] add grunt on travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 79fa2f1..b8b6ed2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,5 +2,6 @@ language: node_js node_js: - 4 install: + - npm install grunt-cli -g - npm install -g bower - bower install From 1aa5d360cbf8b7b10e208e8f68b3b3fa6e108ee6 Mon Sep 17 00:00:00 2001 From: Aurelio Saraiva Date: Wed, 29 Mar 2017 13:28:49 -0300 Subject: [PATCH 17/40] add npm install on travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index b8b6ed2..27cb15f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,4 +4,5 @@ node_js: install: - npm install grunt-cli -g - npm install -g bower + - npm install - bower install From 7302e51494c5e25d9e94ae883f5cb55d4fa6343a Mon Sep 17 00:00:00 2001 From: Aurelio Saraiva Date: Wed, 29 Mar 2017 13:32:48 -0300 Subject: [PATCH 18/40] add jquery on bower --- bower.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bower.json b/bower.json index c8e1b8d..b975845 100644 --- a/bower.json +++ b/bower.json @@ -18,5 +18,8 @@ "node_modules", "bower_components", "test" - ] + ], + "dependencies": { + "jquery": "^3.2.1" + } } From f12805d0687c18dad196f6290d6528738c2abee1 Mon Sep 17 00:00:00 2001 From: Aurelio Saraiva Date: Wed, 29 Mar 2017 13:47:01 -0300 Subject: [PATCH 19/40] version 3.0.3 --- bower.json | 2 +- dist/jquery.maskMoney.js | 2 +- dist/jquery.maskMoney.min.js | 2 +- maskMoney.jquery.json | 2 +- package.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bower.json b/bower.json index b975845..09ca5c9 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jquery-maskmoney", - "version": "3.0.2", + "version": "3.0.3", "homepage": "https://github.com/plentz/jquery-maskmoney", "authors": [ "Diego Plentz " diff --git a/dist/jquery.maskMoney.js b/dist/jquery.maskMoney.js index ca1991c..e19a725 100644 --- a/dist/jquery.maskMoney.js +++ b/dist/jquery.maskMoney.js @@ -1,5 +1,5 @@ /* - * jquery-maskmoney - v3.0.2 + * jquery-maskmoney - v3.0.3 * jQuery plugin to mask data entry in the input text in the form of money (currency) * https://github.com/plentz/jquery-maskmoney * diff --git a/dist/jquery.maskMoney.min.js b/dist/jquery.maskMoney.min.js index 496fb77..96a3752 100644 --- a/dist/jquery.maskMoney.min.js +++ b/dist/jquery.maskMoney.min.js @@ -1,5 +1,5 @@ /* - * jquery-maskmoney - v3.0.2 + * jquery-maskmoney - v3.0.3 * jQuery plugin to mask data entry in the input text in the form of money (currency) * https://github.com/plentz/jquery-maskmoney * diff --git a/maskMoney.jquery.json b/maskMoney.jquery.json index 1ef3f94..95c73a0 100644 --- a/maskMoney.jquery.json +++ b/maskMoney.jquery.json @@ -1,6 +1,6 @@ { "name": "maskMoney", - "version": "3.0.2", + "version": "3.0.3", "title": "jQuery maskMoney", "author": { "name": "Diego Plentz", diff --git a/package.json b/package.json index a82fcfe..84d0266 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "jquery-maskmoney", "filename": "jquery.maskMoney.min.js", "description": "jQuery plugin to mask data entry in the input text in the form of money (currency)", - "version": "3.0.2", + "version": "3.0.3", "homepage": "https://github.com/plentz/jquery-maskmoney", "repository": { "type": "git", From fadb426dc4c925522a946aa8d2f2153232211d60 Mon Sep 17 00:00:00 2001 From: Aurelio Saraiva Date: Wed, 29 Mar 2017 14:22:30 -0300 Subject: [PATCH 20/40] version 3.1.0 --- bower.json | 2 +- dist/jquery.maskMoney.js | 17 ++++++++++++++++- dist/jquery.maskMoney.min.js | 4 ++-- maskMoney.jquery.json | 2 +- package.json | 2 +- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/bower.json b/bower.json index 09ca5c9..16c97f5 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jquery-maskmoney", - "version": "3.0.3", + "version": "3.1.0", "homepage": "https://github.com/plentz/jquery-maskmoney", "authors": [ "Diego Plentz " diff --git a/dist/jquery.maskMoney.js b/dist/jquery.maskMoney.js index e19a725..91f005d 100644 --- a/dist/jquery.maskMoney.js +++ b/dist/jquery.maskMoney.js @@ -1,5 +1,5 @@ /* - * jquery-maskmoney - v3.0.3 + * jquery-maskmoney - v3.1.0 * jQuery plugin to mask data entry in the input text in the form of money (currency) * https://github.com/plentz/jquery-maskmoney * @@ -74,6 +74,7 @@ precision: 2, allowZero: false, allowNegative: false, + doubleClickSelection: true, allowEmpty: false }, parameters); @@ -418,12 +419,26 @@ } } + function doubleClickEvent() { + var input = $input.get(0), + start, + length; + if (input.setSelectionRange) { + length = $input.val().length; + start = settings.doubleClickSelection ? 0 : length; + input.setSelectionRange(start, length); + } else { + $input.val($input.val()); + } + } + $input.unbind(".maskMoney"); $input.bind("keypress.maskMoney", keypressEvent); $input.bind("keydown.maskMoney", keydownEvent); $input.bind("blur.maskMoney", blurEvent); $input.bind("focus.maskMoney", focusEvent); $input.bind("click.maskMoney", clickEvent); + $input.bind("dblclick.maskMoney", doubleClickEvent); $input.bind("cut.maskMoney", cutPasteEvent); $input.bind("paste.maskMoney", cutPasteEvent); $input.bind("mask.maskMoney", mask); diff --git a/dist/jquery.maskMoney.min.js b/dist/jquery.maskMoney.min.js index 96a3752..27e80c4 100644 --- a/dist/jquery.maskMoney.min.js +++ b/dist/jquery.maskMoney.min.js @@ -1,9 +1,9 @@ /* - * jquery-maskmoney - v3.0.3 + * jquery-maskmoney - v3.1.0 * jQuery plugin to mask data entry in the input text in the form of money (currency) * https://github.com/plentz/jquery-maskmoney * * Made by Diego Plentz * Under MIT License */ -!function($){"use strict";function a(a,b){var c="";return a.indexOf("-")>-1&&(a=a.replace("-",""),c="-"),a.indexOf(b.prefix)>-1&&(a=a.replace(b.prefix,"")),a.indexOf(b.suffix)>-1&&(a=a.replace(b.suffix,"")),c+b.prefix+a+b.suffix}function b(a,b){return b.allowEmpty&&""===a?"":b.reverse?d(a,b):c(a,b)}function c(b,c){var d,f,g,h=b.indexOf("-")>-1&&c.allowNegative?"-":"",i=b.replace(/[^0-9]/g,""),j=i.slice(0,i.length-c.precision);return d=e(j,h,c),c.precision>0&&(f=i.slice(i.length-c.precision),g=new Array(c.precision+1-f.length).join(0),d+=c.decimal+g+f),a(d,c)}function d(b,c){var d,f=b.indexOf("-")>-1&&c.allowNegative?"-":"",g=b.replace(c.prefix,"").replace(c.suffix,""),h=g.split(c.decimal)[0],i="";if(""===h&&(h="0"),d=e(h,f,c),c.precision>0){var j=g.split(c.decimal);j.length>1&&(i=j[1]),d+=c.decimal+i;var k=Number.parseFloat(h+"."+i).toFixed(c.precision),l=k.toString().split(c.decimal)[1];d=d.split(c.decimal)[0]+"."+l}return a(d,c)}function e(a,b,c){return a=a.replace(/^0*/g,""),a=a.replace(/\B(?=(\d{3})+(?!\d))/g,c.thousands),""===a&&(a="0"),b+a}$.browser||($.browser={},$.browser.mozilla=/mozilla/.test(navigator.userAgent.toLowerCase())&&!/webkit/.test(navigator.userAgent.toLowerCase()),$.browser.webkit=/webkit/.test(navigator.userAgent.toLowerCase()),$.browser.opera=/opera/.test(navigator.userAgent.toLowerCase()),$.browser.msie=/msie/.test(navigator.userAgent.toLowerCase()));var f={destroy:function(){return $(this).unbind(".maskMoney"),$.browser.msie&&(this.onpaste=null),this},applyMask:function(a){return b(a,$(this).data("settings"))},mask:function(a){return this.each(function(){var b=$(this);return"number"==typeof a&&b.val(a),b.trigger("mask")})},unmasked:function(){return this.map(function(){var a,b=$(this).val()||"0",c=b.indexOf("-")!==-1;return $(b.split(/\D/).reverse()).each(function(b,c){if(c)return a=c,!1}),b=b.replace(/\D/g,""),b=b.replace(new RegExp(a+"$"),"."+a),c&&(b="-"+b),parseFloat(b)})},init:function(c){return c=$.extend({prefix:"",suffix:"",affixesStay:!0,thousands:",",decimal:".",precision:2,allowZero:!1,allowNegative:!1,allowEmpty:!1},c),this.each(function(){function d(){var a,b,c,d,e,f=w.get(0),g=0,h=0;return"number"==typeof f.selectionStart&&"number"==typeof f.selectionEnd?(g=f.selectionStart,h=f.selectionEnd):(b=document.selection.createRange())&&b.parentElement()===f&&(d=f.value.length,a=f.value.replace(/\r\n/g,"\n"),c=f.createTextRange(),c.moveToBookmark(b.getBookmark()),e=f.createTextRange(),e.collapse(!1),c.compareEndPoints("StartToEnd",e)>-1?g=h=d:(g=-c.moveStart("character",-d),g+=a.slice(0,g).split("\n").length-1,c.compareEndPoints("EndToEnd",e)>-1?h=d:(h=-c.moveEnd("character",-d),h+=a.slice(0,h).split("\n").length-1))),{start:g,end:h}}function e(){var a=!(w.val().length>=w.attr("maxlength")&&w.attr("maxlength")>=0),b=d(),c=b.start,e=b.end,f=!(b.start===b.end||!w.val().substring(c,e).match(/\d/)),g="0"===w.val().substring(0,1);return a||f||g}function f(a){u.formatOnBlur||w.each(function(b,c){if(c.setSelectionRange)c.focus(),c.setSelectionRange(a,a);else if(c.createTextRange){var d=c.createTextRange();d.collapse(!0),d.moveEnd("character",a),d.moveStart("character",a),d.select()}})}function g(a){var c,d=w.val().length;w.val(b(w.val(),u)),c=w.val().length,u.reverse||(a-=d-c),f(a)}function h(){var a=w.val();u.allowEmpty&&""===a||(u.precision>0&&a.indexOf(u.decimal)<0&&(a+=u.decimal+new Array(u.precision+1).join(0)),w.val(b(a,u)))}function i(){var a=w.val();return u.allowNegative?""!==a&&"-"===a.charAt(0)?a.replace("-",""):"-"+a:a}function j(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function k(a){a=a||window.event;var b=a.which||a.charCode||a.keyCode,c=u.decimal.charCodeAt(0);return void 0!==b&&(!(b<48||b>57)||b===c&&u.reverse?!!e()&&((b!==c||!l())&&(!!u.formatOnBlur||(j(a),m(a),!1))):n(b,a))}function l(){return w.val().indexOf(u.decimal)>-1}function m(a){a=a||window.event;var b,c,e,f,h=a.which||a.charCode||a.keyCode,i="";h>=48&&h<=57&&(i=String.fromCharCode(h)),b=d(),c=b.start,e=b.end,f=w.val(),w.val(f.substring(0,c)+i+f.substring(e,f.length)),g(c+1)}function n(a,b){return 45===a?(w.val(i()),!1):43===a?(w.val(w.val().replace("-","")),!1):13===a||9===a||(!(!$.browser.mozilla||37!==a&&39!==a||0!==b.charCode)||(j(b),!0))}function o(a){a=a||window.event;var b,c,e,f,h,i=a.which||a.charCode||a.keyCode;return void 0!==i&&(b=d(),c=b.start,e=b.end,8!==i&&46!==i&&63272!==i||(j(a),f=w.val(),c===e&&(8===i?""===u.suffix?c-=1:(h=f.split("").reverse().join("").search(/\d/),c=f.length-h-1,e=c+1):e+=1),w.val(f.substring(0,c)+f.substring(e,f.length)),g(c),!1))}function p(){v=w.val(),h();var a,b=w.get(0);u.selectAllOnFocus?b.select():b.createTextRange&&(a=b.createTextRange(),a.collapse(!1),a.select())}function q(){setTimeout(function(){h()},0)}function r(){return(parseFloat("0")/Math.pow(10,u.precision)).toFixed(u.precision).replace(new RegExp("\\.","g"),u.decimal)}function s(b){if($.browser.msie&&k(b),u.formatOnBlur&&w.val()!==v&&m(b),""===w.val()&&u.allowEmpty)w.val("");else if(""===w.val()||w.val()===a(r(),u))u.allowZero?u.affixesStay?w.val(a(r(),u)):w.val(r()):w.val("");else if(!u.affixesStay){var c=w.val().replace(u.prefix,"").replace(u.suffix,"");w.val(c)}w.val()!==v&&w.change()}function t(){var a,b=w.get(0);u.selectAllOnFocus||(b.setSelectionRange?(a=w.val().length,b.setSelectionRange(a,a)):w.val(w.val()))}var u,v,w=$(this);u=$.extend({},c),u=$.extend(u,w.data()),w.data("settings",u),w.unbind(".maskMoney"),w.bind("keypress.maskMoney",k),w.bind("keydown.maskMoney",o),w.bind("blur.maskMoney",s),w.bind("focus.maskMoney",p),w.bind("click.maskMoney",t),w.bind("cut.maskMoney",q),w.bind("paste.maskMoney",q),w.bind("mask.maskMoney",h)})}};$.fn.maskMoney=function(a){return f[a]?f[a].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof a&&a?void $.error("Method "+a+" does not exist on jQuery.maskMoney"):f.init.apply(this,arguments)}}(window.jQuery||window.Zepto); \ No newline at end of file +!function($){"use strict";function a(a,b){var c="";return a.indexOf("-")>-1&&(a=a.replace("-",""),c="-"),a.indexOf(b.prefix)>-1&&(a=a.replace(b.prefix,"")),a.indexOf(b.suffix)>-1&&(a=a.replace(b.suffix,"")),c+b.prefix+a+b.suffix}function b(a,b){return b.allowEmpty&&""===a?"":b.reverse?d(a,b):c(a,b)}function c(b,c){var d,f,g,h=b.indexOf("-")>-1&&c.allowNegative?"-":"",i=b.replace(/[^0-9]/g,""),j=i.slice(0,i.length-c.precision);return d=e(j,h,c),c.precision>0&&(f=i.slice(i.length-c.precision),g=new Array(c.precision+1-f.length).join(0),d+=c.decimal+g+f),a(d,c)}function d(b,c){var d,f=b.indexOf("-")>-1&&c.allowNegative?"-":"",g=b.replace(c.prefix,"").replace(c.suffix,""),h=g.split(c.decimal)[0],i="";if(""===h&&(h="0"),d=e(h,f,c),c.precision>0){var j=g.split(c.decimal);j.length>1&&(i=j[1]),d+=c.decimal+i;var k=Number.parseFloat(h+"."+i).toFixed(c.precision),l=k.toString().split(c.decimal)[1];d=d.split(c.decimal)[0]+"."+l}return a(d,c)}function e(a,b,c){return a=a.replace(/^0*/g,""),a=a.replace(/\B(?=(\d{3})+(?!\d))/g,c.thousands),""===a&&(a="0"),b+a}$.browser||($.browser={},$.browser.mozilla=/mozilla/.test(navigator.userAgent.toLowerCase())&&!/webkit/.test(navigator.userAgent.toLowerCase()),$.browser.webkit=/webkit/.test(navigator.userAgent.toLowerCase()),$.browser.opera=/opera/.test(navigator.userAgent.toLowerCase()),$.browser.msie=/msie/.test(navigator.userAgent.toLowerCase()));var f={destroy:function(){return $(this).unbind(".maskMoney"),$.browser.msie&&(this.onpaste=null),this},applyMask:function(a){return b(a,$(this).data("settings"))},mask:function(a){return this.each(function(){var b=$(this);return"number"==typeof a&&b.val(a),b.trigger("mask")})},unmasked:function(){return this.map(function(){var a,b=$(this).val()||"0",c=b.indexOf("-")!==-1;return $(b.split(/\D/).reverse()).each(function(b,c){if(c)return a=c,!1}),b=b.replace(/\D/g,""),b=b.replace(new RegExp(a+"$"),"."+a),c&&(b="-"+b),parseFloat(b)})},init:function(c){return c=$.extend({prefix:"",suffix:"",affixesStay:!0,thousands:",",decimal:".",precision:2,allowZero:!1,allowNegative:!1,doubleClickSelection:!0,allowEmpty:!1},c),this.each(function(){function d(){var a,b,c,d,e,f=x.get(0),g=0,h=0;return"number"==typeof f.selectionStart&&"number"==typeof f.selectionEnd?(g=f.selectionStart,h=f.selectionEnd):(b=document.selection.createRange())&&b.parentElement()===f&&(d=f.value.length,a=f.value.replace(/\r\n/g,"\n"),c=f.createTextRange(),c.moveToBookmark(b.getBookmark()),e=f.createTextRange(),e.collapse(!1),c.compareEndPoints("StartToEnd",e)>-1?g=h=d:(g=-c.moveStart("character",-d),g+=a.slice(0,g).split("\n").length-1,c.compareEndPoints("EndToEnd",e)>-1?h=d:(h=-c.moveEnd("character",-d),h+=a.slice(0,h).split("\n").length-1))),{start:g,end:h}}function e(){var a=!(x.val().length>=x.attr("maxlength")&&x.attr("maxlength")>=0),b=d(),c=b.start,e=b.end,f=!(b.start===b.end||!x.val().substring(c,e).match(/\d/)),g="0"===x.val().substring(0,1);return a||f||g}function f(a){v.formatOnBlur||x.each(function(b,c){if(c.setSelectionRange)c.focus(),c.setSelectionRange(a,a);else if(c.createTextRange){var d=c.createTextRange();d.collapse(!0),d.moveEnd("character",a),d.moveStart("character",a),d.select()}})}function g(a){var c,d=x.val().length;x.val(b(x.val(),v)),c=x.val().length,v.reverse||(a-=d-c),f(a)}function h(){var a=x.val();v.allowEmpty&&""===a||(v.precision>0&&a.indexOf(v.decimal)<0&&(a+=v.decimal+new Array(v.precision+1).join(0)),x.val(b(a,v)))}function i(){var a=x.val();return v.allowNegative?""!==a&&"-"===a.charAt(0)?a.replace("-",""):"-"+a:a}function j(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function k(a){a=a||window.event;var b=a.which||a.charCode||a.keyCode,c=v.decimal.charCodeAt(0);return void 0!==b&&(!(b<48||b>57)||b===c&&v.reverse?!!e()&&((b!==c||!l())&&(!!v.formatOnBlur||(j(a),m(a),!1))):n(b,a))}function l(){return x.val().indexOf(v.decimal)>-1}function m(a){a=a||window.event;var b,c,e,f,h=a.which||a.charCode||a.keyCode,i="";h>=48&&h<=57&&(i=String.fromCharCode(h)),b=d(),c=b.start,e=b.end,f=x.val(),x.val(f.substring(0,c)+i+f.substring(e,f.length)),g(c+1)}function n(a,b){return 45===a?(x.val(i()),!1):43===a?(x.val(x.val().replace("-","")),!1):13===a||9===a||(!(!$.browser.mozilla||37!==a&&39!==a||0!==b.charCode)||(j(b),!0))}function o(a){a=a||window.event;var b,c,e,f,h,i=a.which||a.charCode||a.keyCode;return void 0!==i&&(b=d(),c=b.start,e=b.end,8!==i&&46!==i&&63272!==i||(j(a),f=x.val(),c===e&&(8===i?""===v.suffix?c-=1:(h=f.split("").reverse().join("").search(/\d/),c=f.length-h-1,e=c+1):e+=1),x.val(f.substring(0,c)+f.substring(e,f.length)),g(c),!1))}function p(){w=x.val(),h();var a,b=x.get(0);v.selectAllOnFocus?b.select():b.createTextRange&&(a=b.createTextRange(),a.collapse(!1),a.select())}function q(){setTimeout(function(){h()},0)}function r(){return(parseFloat("0")/Math.pow(10,v.precision)).toFixed(v.precision).replace(new RegExp("\\.","g"),v.decimal)}function s(b){if($.browser.msie&&k(b),v.formatOnBlur&&x.val()!==w&&m(b),""===x.val()&&v.allowEmpty)x.val("");else if(""===x.val()||x.val()===a(r(),v))v.allowZero?v.affixesStay?x.val(a(r(),v)):x.val(r()):x.val("");else if(!v.affixesStay){var c=x.val().replace(v.prefix,"").replace(v.suffix,"");x.val(c)}x.val()!==w&&x.change()}function t(){var a,b=x.get(0);v.selectAllOnFocus||(b.setSelectionRange?(a=x.val().length,b.setSelectionRange(a,a)):x.val(x.val()))}function u(){var a,b,c=x.get(0);c.setSelectionRange?(b=x.val().length,a=v.doubleClickSelection?0:b,c.setSelectionRange(a,b)):x.val(x.val())}var v,w,x=$(this);v=$.extend({},c),v=$.extend(v,x.data()),x.data("settings",v),x.unbind(".maskMoney"),x.bind("keypress.maskMoney",k),x.bind("keydown.maskMoney",o),x.bind("blur.maskMoney",s),x.bind("focus.maskMoney",p),x.bind("click.maskMoney",t),x.bind("dblclick.maskMoney",u),x.bind("cut.maskMoney",q),x.bind("paste.maskMoney",q),x.bind("mask.maskMoney",h)})}};$.fn.maskMoney=function(a){return f[a]?f[a].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof a&&a?void $.error("Method "+a+" does not exist on jQuery.maskMoney"):f.init.apply(this,arguments)}}(window.jQuery||window.Zepto); \ No newline at end of file diff --git a/maskMoney.jquery.json b/maskMoney.jquery.json index 95c73a0..13745b0 100644 --- a/maskMoney.jquery.json +++ b/maskMoney.jquery.json @@ -1,6 +1,6 @@ { "name": "maskMoney", - "version": "3.0.3", + "version": "3.1.0", "title": "jQuery maskMoney", "author": { "name": "Diego Plentz", diff --git a/package.json b/package.json index e340497..53ec62c 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "jquery-maskmoney", "filename": "jquery.maskMoney.min.js", "description": "jQuery plugin to mask data entry in the input text in the form of money (currency)", - "version": "3.0.3", + "version": "3.1.0", "homepage": "https://github.com/plentz/jquery-maskmoney", "repository": { "type": "git", From 550024ba7f658c381f93458ee563aeb4f681d3c8 Mon Sep 17 00:00:00 2001 From: Andrew Duncan Date: Wed, 29 Mar 2017 17:07:06 -0400 Subject: [PATCH 21/40] Allow decimal if all text is selected or the text is empty --- dist/jquery.maskMoney.js | 18 +++++++++++++++++- dist/jquery.maskMoney.min.js | 2 +- src/jquery.maskMoney.js | 18 +++++++++++++++++- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/dist/jquery.maskMoney.js b/dist/jquery.maskMoney.js index ca1991c..35c7a7b 100644 --- a/dist/jquery.maskMoney.js +++ b/dist/jquery.maskMoney.js @@ -238,7 +238,7 @@ } else if (!canInputMoreNumbers()) { return false; } else { - if (key === decimalKeyCode && alreadyContainsDecimal()) { + if (key === decimalKeyCode && shouldPreventDecimalKey()) { return false; } if (settings.formatOnBlur) { @@ -250,6 +250,22 @@ } } + function shouldPreventDecimalKey() { + // If all text is selected, we can accept the decimal + // key because it will replace everything. + if (isAllTextSelected()) { + return false; + } + + return alreadyContainsDecimal(); + } + + function isAllTextSelected() { + var length = $input.val().length; + var selection = getInputSelection(); + return selection.start === 0 && selection.end === length; + } + function alreadyContainsDecimal() { return $input.val().indexOf(settings.decimal) > -1; } diff --git a/dist/jquery.maskMoney.min.js b/dist/jquery.maskMoney.min.js index 496fb77..0f92919 100644 --- a/dist/jquery.maskMoney.min.js +++ b/dist/jquery.maskMoney.min.js @@ -6,4 +6,4 @@ * Made by Diego Plentz * Under MIT License */ -!function($){"use strict";function a(a,b){var c="";return a.indexOf("-")>-1&&(a=a.replace("-",""),c="-"),a.indexOf(b.prefix)>-1&&(a=a.replace(b.prefix,"")),a.indexOf(b.suffix)>-1&&(a=a.replace(b.suffix,"")),c+b.prefix+a+b.suffix}function b(a,b){return b.allowEmpty&&""===a?"":b.reverse?d(a,b):c(a,b)}function c(b,c){var d,f,g,h=b.indexOf("-")>-1&&c.allowNegative?"-":"",i=b.replace(/[^0-9]/g,""),j=i.slice(0,i.length-c.precision);return d=e(j,h,c),c.precision>0&&(f=i.slice(i.length-c.precision),g=new Array(c.precision+1-f.length).join(0),d+=c.decimal+g+f),a(d,c)}function d(b,c){var d,f=b.indexOf("-")>-1&&c.allowNegative?"-":"",g=b.replace(c.prefix,"").replace(c.suffix,""),h=g.split(c.decimal)[0],i="";if(""===h&&(h="0"),d=e(h,f,c),c.precision>0){var j=g.split(c.decimal);j.length>1&&(i=j[1]),d+=c.decimal+i;var k=Number.parseFloat(h+"."+i).toFixed(c.precision),l=k.toString().split(c.decimal)[1];d=d.split(c.decimal)[0]+"."+l}return a(d,c)}function e(a,b,c){return a=a.replace(/^0*/g,""),a=a.replace(/\B(?=(\d{3})+(?!\d))/g,c.thousands),""===a&&(a="0"),b+a}$.browser||($.browser={},$.browser.mozilla=/mozilla/.test(navigator.userAgent.toLowerCase())&&!/webkit/.test(navigator.userAgent.toLowerCase()),$.browser.webkit=/webkit/.test(navigator.userAgent.toLowerCase()),$.browser.opera=/opera/.test(navigator.userAgent.toLowerCase()),$.browser.msie=/msie/.test(navigator.userAgent.toLowerCase()));var f={destroy:function(){return $(this).unbind(".maskMoney"),$.browser.msie&&(this.onpaste=null),this},applyMask:function(a){return b(a,$(this).data("settings"))},mask:function(a){return this.each(function(){var b=$(this);return"number"==typeof a&&b.val(a),b.trigger("mask")})},unmasked:function(){return this.map(function(){var a,b=$(this).val()||"0",c=b.indexOf("-")!==-1;return $(b.split(/\D/).reverse()).each(function(b,c){if(c)return a=c,!1}),b=b.replace(/\D/g,""),b=b.replace(new RegExp(a+"$"),"."+a),c&&(b="-"+b),parseFloat(b)})},init:function(c){return c=$.extend({prefix:"",suffix:"",affixesStay:!0,thousands:",",decimal:".",precision:2,allowZero:!1,allowNegative:!1,allowEmpty:!1},c),this.each(function(){function d(){var a,b,c,d,e,f=w.get(0),g=0,h=0;return"number"==typeof f.selectionStart&&"number"==typeof f.selectionEnd?(g=f.selectionStart,h=f.selectionEnd):(b=document.selection.createRange())&&b.parentElement()===f&&(d=f.value.length,a=f.value.replace(/\r\n/g,"\n"),c=f.createTextRange(),c.moveToBookmark(b.getBookmark()),e=f.createTextRange(),e.collapse(!1),c.compareEndPoints("StartToEnd",e)>-1?g=h=d:(g=-c.moveStart("character",-d),g+=a.slice(0,g).split("\n").length-1,c.compareEndPoints("EndToEnd",e)>-1?h=d:(h=-c.moveEnd("character",-d),h+=a.slice(0,h).split("\n").length-1))),{start:g,end:h}}function e(){var a=!(w.val().length>=w.attr("maxlength")&&w.attr("maxlength")>=0),b=d(),c=b.start,e=b.end,f=!(b.start===b.end||!w.val().substring(c,e).match(/\d/)),g="0"===w.val().substring(0,1);return a||f||g}function f(a){u.formatOnBlur||w.each(function(b,c){if(c.setSelectionRange)c.focus(),c.setSelectionRange(a,a);else if(c.createTextRange){var d=c.createTextRange();d.collapse(!0),d.moveEnd("character",a),d.moveStart("character",a),d.select()}})}function g(a){var c,d=w.val().length;w.val(b(w.val(),u)),c=w.val().length,u.reverse||(a-=d-c),f(a)}function h(){var a=w.val();u.allowEmpty&&""===a||(u.precision>0&&a.indexOf(u.decimal)<0&&(a+=u.decimal+new Array(u.precision+1).join(0)),w.val(b(a,u)))}function i(){var a=w.val();return u.allowNegative?""!==a&&"-"===a.charAt(0)?a.replace("-",""):"-"+a:a}function j(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function k(a){a=a||window.event;var b=a.which||a.charCode||a.keyCode,c=u.decimal.charCodeAt(0);return void 0!==b&&(!(b<48||b>57)||b===c&&u.reverse?!!e()&&((b!==c||!l())&&(!!u.formatOnBlur||(j(a),m(a),!1))):n(b,a))}function l(){return w.val().indexOf(u.decimal)>-1}function m(a){a=a||window.event;var b,c,e,f,h=a.which||a.charCode||a.keyCode,i="";h>=48&&h<=57&&(i=String.fromCharCode(h)),b=d(),c=b.start,e=b.end,f=w.val(),w.val(f.substring(0,c)+i+f.substring(e,f.length)),g(c+1)}function n(a,b){return 45===a?(w.val(i()),!1):43===a?(w.val(w.val().replace("-","")),!1):13===a||9===a||(!(!$.browser.mozilla||37!==a&&39!==a||0!==b.charCode)||(j(b),!0))}function o(a){a=a||window.event;var b,c,e,f,h,i=a.which||a.charCode||a.keyCode;return void 0!==i&&(b=d(),c=b.start,e=b.end,8!==i&&46!==i&&63272!==i||(j(a),f=w.val(),c===e&&(8===i?""===u.suffix?c-=1:(h=f.split("").reverse().join("").search(/\d/),c=f.length-h-1,e=c+1):e+=1),w.val(f.substring(0,c)+f.substring(e,f.length)),g(c),!1))}function p(){v=w.val(),h();var a,b=w.get(0);u.selectAllOnFocus?b.select():b.createTextRange&&(a=b.createTextRange(),a.collapse(!1),a.select())}function q(){setTimeout(function(){h()},0)}function r(){return(parseFloat("0")/Math.pow(10,u.precision)).toFixed(u.precision).replace(new RegExp("\\.","g"),u.decimal)}function s(b){if($.browser.msie&&k(b),u.formatOnBlur&&w.val()!==v&&m(b),""===w.val()&&u.allowEmpty)w.val("");else if(""===w.val()||w.val()===a(r(),u))u.allowZero?u.affixesStay?w.val(a(r(),u)):w.val(r()):w.val("");else if(!u.affixesStay){var c=w.val().replace(u.prefix,"").replace(u.suffix,"");w.val(c)}w.val()!==v&&w.change()}function t(){var a,b=w.get(0);u.selectAllOnFocus||(b.setSelectionRange?(a=w.val().length,b.setSelectionRange(a,a)):w.val(w.val()))}var u,v,w=$(this);u=$.extend({},c),u=$.extend(u,w.data()),w.data("settings",u),w.unbind(".maskMoney"),w.bind("keypress.maskMoney",k),w.bind("keydown.maskMoney",o),w.bind("blur.maskMoney",s),w.bind("focus.maskMoney",p),w.bind("click.maskMoney",t),w.bind("cut.maskMoney",q),w.bind("paste.maskMoney",q),w.bind("mask.maskMoney",h)})}};$.fn.maskMoney=function(a){return f[a]?f[a].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof a&&a?void $.error("Method "+a+" does not exist on jQuery.maskMoney"):f.init.apply(this,arguments)}}(window.jQuery||window.Zepto); \ No newline at end of file +!function($){"use strict";function a(a,b){var c="";return a.indexOf("-")>-1&&(a=a.replace("-",""),c="-"),a.indexOf(b.prefix)>-1&&(a=a.replace(b.prefix,"")),a.indexOf(b.suffix)>-1&&(a=a.replace(b.suffix,"")),c+b.prefix+a+b.suffix}function b(a,b){return b.allowEmpty&&""===a?"":b.reverse?d(a,b):c(a,b)}function c(b,c){var d,f,g,h=b.indexOf("-")>-1&&c.allowNegative?"-":"",i=b.replace(/[^0-9]/g,""),j=i.slice(0,i.length-c.precision);return d=e(j,h,c),c.precision>0&&(f=i.slice(i.length-c.precision),g=new Array(c.precision+1-f.length).join(0),d+=c.decimal+g+f),a(d,c)}function d(b,c){var d,f=b.indexOf("-")>-1&&c.allowNegative?"-":"",g=b.replace(c.prefix,"").replace(c.suffix,""),h=g.split(c.decimal)[0],i="";if(""===h&&(h="0"),d=e(h,f,c),c.precision>0){var j=g.split(c.decimal);j.length>1&&(i=j[1]),d+=c.decimal+i;var k=Number.parseFloat(h+"."+i).toFixed(c.precision),l=k.toString().split(c.decimal)[1];d=d.split(c.decimal)[0]+"."+l}return a(d,c)}function e(a,b,c){return a=a.replace(/^0*/g,""),a=a.replace(/\B(?=(\d{3})+(?!\d))/g,c.thousands),""===a&&(a="0"),b+a}$.browser||($.browser={},$.browser.mozilla=/mozilla/.test(navigator.userAgent.toLowerCase())&&!/webkit/.test(navigator.userAgent.toLowerCase()),$.browser.webkit=/webkit/.test(navigator.userAgent.toLowerCase()),$.browser.opera=/opera/.test(navigator.userAgent.toLowerCase()),$.browser.msie=/msie/.test(navigator.userAgent.toLowerCase()));var f={destroy:function(){return $(this).unbind(".maskMoney"),$.browser.msie&&(this.onpaste=null),this},applyMask:function(a){return b(a,$(this).data("settings"))},mask:function(a){return this.each(function(){var b=$(this);return"number"==typeof a&&b.val(a),b.trigger("mask")})},unmasked:function(){return this.map(function(){var a,b=$(this).val()||"0",c=b.indexOf("-")!==-1;return $(b.split(/\D/).reverse()).each(function(b,c){if(c)return a=c,!1}),b=b.replace(/\D/g,""),b=b.replace(new RegExp(a+"$"),"."+a),c&&(b="-"+b),parseFloat(b)})},init:function(c){return c=$.extend({prefix:"",suffix:"",affixesStay:!0,thousands:",",decimal:".",precision:2,allowZero:!1,allowNegative:!1,allowEmpty:!1},c),this.each(function(){function d(){var a,b,c,d,e,f=y.get(0),g=0,h=0;return"number"==typeof f.selectionStart&&"number"==typeof f.selectionEnd?(g=f.selectionStart,h=f.selectionEnd):(b=document.selection.createRange())&&b.parentElement()===f&&(d=f.value.length,a=f.value.replace(/\r\n/g,"\n"),c=f.createTextRange(),c.moveToBookmark(b.getBookmark()),e=f.createTextRange(),e.collapse(!1),c.compareEndPoints("StartToEnd",e)>-1?g=h=d:(g=-c.moveStart("character",-d),g+=a.slice(0,g).split("\n").length-1,c.compareEndPoints("EndToEnd",e)>-1?h=d:(h=-c.moveEnd("character",-d),h+=a.slice(0,h).split("\n").length-1))),{start:g,end:h}}function e(){var a=!(y.val().length>=y.attr("maxlength")&&y.attr("maxlength")>=0),b=d(),c=b.start,e=b.end,f=!(b.start===b.end||!y.val().substring(c,e).match(/\d/)),g="0"===y.val().substring(0,1);return a||f||g}function f(a){w.formatOnBlur||y.each(function(b,c){if(c.setSelectionRange)c.focus(),c.setSelectionRange(a,a);else if(c.createTextRange){var d=c.createTextRange();d.collapse(!0),d.moveEnd("character",a),d.moveStart("character",a),d.select()}})}function g(a){var c,d=y.val().length;y.val(b(y.val(),w)),c=y.val().length,w.reverse||(a-=d-c),f(a)}function h(){var a=y.val();w.allowEmpty&&""===a||(w.precision>0&&a.indexOf(w.decimal)<0&&(a+=w.decimal+new Array(w.precision+1).join(0)),y.val(b(a,w)))}function i(){var a=y.val();return w.allowNegative?""!==a&&"-"===a.charAt(0)?a.replace("-",""):"-"+a:a}function j(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function k(a){a=a||window.event;var b=a.which||a.charCode||a.keyCode,c=w.decimal.charCodeAt(0);return void 0!==b&&(!(b<48||b>57)||b===c&&w.reverse?!!e()&&((b!==c||!l())&&(!!w.formatOnBlur||(j(a),o(a),!1))):p(b,a))}function l(){return!m()&&n()}function m(){var a=y.val().length,b=d();return 0===b.start&&b.end===a}function n(){return y.val().indexOf(w.decimal)>-1}function o(a){a=a||window.event;var b,c,e,f,h=a.which||a.charCode||a.keyCode,i="";h>=48&&h<=57&&(i=String.fromCharCode(h)),b=d(),c=b.start,e=b.end,f=y.val(),y.val(f.substring(0,c)+i+f.substring(e,f.length)),g(c+1)}function p(a,b){return 45===a?(y.val(i()),!1):43===a?(y.val(y.val().replace("-","")),!1):13===a||9===a||(!(!$.browser.mozilla||37!==a&&39!==a||0!==b.charCode)||(j(b),!0))}function q(a){a=a||window.event;var b,c,e,f,h,i=a.which||a.charCode||a.keyCode;return void 0!==i&&(b=d(),c=b.start,e=b.end,8!==i&&46!==i&&63272!==i||(j(a),f=y.val(),c===e&&(8===i?""===w.suffix?c-=1:(h=f.split("").reverse().join("").search(/\d/),c=f.length-h-1,e=c+1):e+=1),y.val(f.substring(0,c)+f.substring(e,f.length)),g(c),!1))}function r(){x=y.val(),h();var a,b=y.get(0);w.selectAllOnFocus?b.select():b.createTextRange&&(a=b.createTextRange(),a.collapse(!1),a.select())}function s(){setTimeout(function(){h()},0)}function t(){return(parseFloat("0")/Math.pow(10,w.precision)).toFixed(w.precision).replace(new RegExp("\\.","g"),w.decimal)}function u(b){if($.browser.msie&&k(b),w.formatOnBlur&&y.val()!==x&&o(b),""===y.val()&&w.allowEmpty)y.val("");else if(""===y.val()||y.val()===a(t(),w))w.allowZero?w.affixesStay?y.val(a(t(),w)):y.val(t()):y.val("");else if(!w.affixesStay){var c=y.val().replace(w.prefix,"").replace(w.suffix,"");y.val(c)}y.val()!==x&&y.change()}function v(){var a,b=y.get(0);w.selectAllOnFocus||(b.setSelectionRange?(a=y.val().length,b.setSelectionRange(a,a)):y.val(y.val()))}var w,x,y=$(this);w=$.extend({},c),w=$.extend(w,y.data()),y.data("settings",w),y.unbind(".maskMoney"),y.bind("keypress.maskMoney",k),y.bind("keydown.maskMoney",q),y.bind("blur.maskMoney",u),y.bind("focus.maskMoney",r),y.bind("click.maskMoney",v),y.bind("cut.maskMoney",s),y.bind("paste.maskMoney",s),y.bind("mask.maskMoney",h)})}};$.fn.maskMoney=function(a){return f[a]?f[a].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof a&&a?void $.error("Method "+a+" does not exist on jQuery.maskMoney"):f.init.apply(this,arguments)}}(window.jQuery||window.Zepto); \ No newline at end of file diff --git a/src/jquery.maskMoney.js b/src/jquery.maskMoney.js index 40961c9..9eb1674 100644 --- a/src/jquery.maskMoney.js +++ b/src/jquery.maskMoney.js @@ -230,7 +230,7 @@ } else if (!canInputMoreNumbers()) { return false; } else { - if (key === decimalKeyCode && alreadyContainsDecimal()) { + if (key === decimalKeyCode && shouldPreventDecimalKey()) { return false; } if (settings.formatOnBlur) { @@ -242,6 +242,22 @@ } } + function shouldPreventDecimalKey() { + // If all text is selected, we can accept the decimal + // key because it will replace everything. + if (isAllTextSelected()) { + return false; + } + + return alreadyContainsDecimal(); + } + + function isAllTextSelected() { + var length = $input.val().length; + var selection = getInputSelection(); + return selection.start === 0 && selection.end === length; + } + function alreadyContainsDecimal() { return $input.val().indexOf(settings.decimal) > -1; } From 6895c667f471a66c93c2593f17c8ec65472f7a4b Mon Sep 17 00:00:00 2001 From: Andrew Duncan Date: Wed, 29 Mar 2017 17:08:04 -0400 Subject: [PATCH 22/40] Add comment --- dist/jquery.maskMoney.js | 2 ++ src/jquery.maskMoney.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/dist/jquery.maskMoney.js b/dist/jquery.maskMoney.js index 35c7a7b..cc15e61 100644 --- a/dist/jquery.maskMoney.js +++ b/dist/jquery.maskMoney.js @@ -263,6 +263,8 @@ function isAllTextSelected() { var length = $input.val().length; var selection = getInputSelection(); + // This should if all text is selected or if the + // input is empty. return selection.start === 0 && selection.end === length; } diff --git a/src/jquery.maskMoney.js b/src/jquery.maskMoney.js index 9eb1674..0d68fbf 100644 --- a/src/jquery.maskMoney.js +++ b/src/jquery.maskMoney.js @@ -255,6 +255,8 @@ function isAllTextSelected() { var length = $input.val().length; var selection = getInputSelection(); + // This should if all text is selected or if the + // input is empty. return selection.start === 0 && selection.end === length; } From 42db246f2262d467e447aa5e16459dde3e614fbf Mon Sep 17 00:00:00 2001 From: Aurelio Saraiva Date: Wed, 29 Mar 2017 22:32:40 -0300 Subject: [PATCH 23/40] version 3.1.1 --- bower.json | 2 +- dist/jquery.maskMoney.js | 2 +- dist/jquery.maskMoney.min.js | 4 ++-- maskMoney.jquery.json | 2 +- package.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bower.json b/bower.json index 16c97f5..b36c177 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jquery-maskmoney", - "version": "3.1.0", + "version": "3.1.1", "homepage": "https://github.com/plentz/jquery-maskmoney", "authors": [ "Diego Plentz " diff --git a/dist/jquery.maskMoney.js b/dist/jquery.maskMoney.js index 9e7046f..a41fa5b 100644 --- a/dist/jquery.maskMoney.js +++ b/dist/jquery.maskMoney.js @@ -1,5 +1,5 @@ /* - * jquery-maskmoney - v3.1.0 + * jquery-maskmoney - v3.1.1 * jQuery plugin to mask data entry in the input text in the form of money (currency) * https://github.com/plentz/jquery-maskmoney * diff --git a/dist/jquery.maskMoney.min.js b/dist/jquery.maskMoney.min.js index 27e80c4..b5776ee 100644 --- a/dist/jquery.maskMoney.min.js +++ b/dist/jquery.maskMoney.min.js @@ -1,9 +1,9 @@ /* - * jquery-maskmoney - v3.1.0 + * jquery-maskmoney - v3.1.1 * jQuery plugin to mask data entry in the input text in the form of money (currency) * https://github.com/plentz/jquery-maskmoney * * Made by Diego Plentz * Under MIT License */ -!function($){"use strict";function a(a,b){var c="";return a.indexOf("-")>-1&&(a=a.replace("-",""),c="-"),a.indexOf(b.prefix)>-1&&(a=a.replace(b.prefix,"")),a.indexOf(b.suffix)>-1&&(a=a.replace(b.suffix,"")),c+b.prefix+a+b.suffix}function b(a,b){return b.allowEmpty&&""===a?"":b.reverse?d(a,b):c(a,b)}function c(b,c){var d,f,g,h=b.indexOf("-")>-1&&c.allowNegative?"-":"",i=b.replace(/[^0-9]/g,""),j=i.slice(0,i.length-c.precision);return d=e(j,h,c),c.precision>0&&(f=i.slice(i.length-c.precision),g=new Array(c.precision+1-f.length).join(0),d+=c.decimal+g+f),a(d,c)}function d(b,c){var d,f=b.indexOf("-")>-1&&c.allowNegative?"-":"",g=b.replace(c.prefix,"").replace(c.suffix,""),h=g.split(c.decimal)[0],i="";if(""===h&&(h="0"),d=e(h,f,c),c.precision>0){var j=g.split(c.decimal);j.length>1&&(i=j[1]),d+=c.decimal+i;var k=Number.parseFloat(h+"."+i).toFixed(c.precision),l=k.toString().split(c.decimal)[1];d=d.split(c.decimal)[0]+"."+l}return a(d,c)}function e(a,b,c){return a=a.replace(/^0*/g,""),a=a.replace(/\B(?=(\d{3})+(?!\d))/g,c.thousands),""===a&&(a="0"),b+a}$.browser||($.browser={},$.browser.mozilla=/mozilla/.test(navigator.userAgent.toLowerCase())&&!/webkit/.test(navigator.userAgent.toLowerCase()),$.browser.webkit=/webkit/.test(navigator.userAgent.toLowerCase()),$.browser.opera=/opera/.test(navigator.userAgent.toLowerCase()),$.browser.msie=/msie/.test(navigator.userAgent.toLowerCase()));var f={destroy:function(){return $(this).unbind(".maskMoney"),$.browser.msie&&(this.onpaste=null),this},applyMask:function(a){return b(a,$(this).data("settings"))},mask:function(a){return this.each(function(){var b=$(this);return"number"==typeof a&&b.val(a),b.trigger("mask")})},unmasked:function(){return this.map(function(){var a,b=$(this).val()||"0",c=b.indexOf("-")!==-1;return $(b.split(/\D/).reverse()).each(function(b,c){if(c)return a=c,!1}),b=b.replace(/\D/g,""),b=b.replace(new RegExp(a+"$"),"."+a),c&&(b="-"+b),parseFloat(b)})},init:function(c){return c=$.extend({prefix:"",suffix:"",affixesStay:!0,thousands:",",decimal:".",precision:2,allowZero:!1,allowNegative:!1,doubleClickSelection:!0,allowEmpty:!1},c),this.each(function(){function d(){var a,b,c,d,e,f=x.get(0),g=0,h=0;return"number"==typeof f.selectionStart&&"number"==typeof f.selectionEnd?(g=f.selectionStart,h=f.selectionEnd):(b=document.selection.createRange())&&b.parentElement()===f&&(d=f.value.length,a=f.value.replace(/\r\n/g,"\n"),c=f.createTextRange(),c.moveToBookmark(b.getBookmark()),e=f.createTextRange(),e.collapse(!1),c.compareEndPoints("StartToEnd",e)>-1?g=h=d:(g=-c.moveStart("character",-d),g+=a.slice(0,g).split("\n").length-1,c.compareEndPoints("EndToEnd",e)>-1?h=d:(h=-c.moveEnd("character",-d),h+=a.slice(0,h).split("\n").length-1))),{start:g,end:h}}function e(){var a=!(x.val().length>=x.attr("maxlength")&&x.attr("maxlength")>=0),b=d(),c=b.start,e=b.end,f=!(b.start===b.end||!x.val().substring(c,e).match(/\d/)),g="0"===x.val().substring(0,1);return a||f||g}function f(a){v.formatOnBlur||x.each(function(b,c){if(c.setSelectionRange)c.focus(),c.setSelectionRange(a,a);else if(c.createTextRange){var d=c.createTextRange();d.collapse(!0),d.moveEnd("character",a),d.moveStart("character",a),d.select()}})}function g(a){var c,d=x.val().length;x.val(b(x.val(),v)),c=x.val().length,v.reverse||(a-=d-c),f(a)}function h(){var a=x.val();v.allowEmpty&&""===a||(v.precision>0&&a.indexOf(v.decimal)<0&&(a+=v.decimal+new Array(v.precision+1).join(0)),x.val(b(a,v)))}function i(){var a=x.val();return v.allowNegative?""!==a&&"-"===a.charAt(0)?a.replace("-",""):"-"+a:a}function j(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function k(a){a=a||window.event;var b=a.which||a.charCode||a.keyCode,c=v.decimal.charCodeAt(0);return void 0!==b&&(!(b<48||b>57)||b===c&&v.reverse?!!e()&&((b!==c||!l())&&(!!v.formatOnBlur||(j(a),m(a),!1))):n(b,a))}function l(){return x.val().indexOf(v.decimal)>-1}function m(a){a=a||window.event;var b,c,e,f,h=a.which||a.charCode||a.keyCode,i="";h>=48&&h<=57&&(i=String.fromCharCode(h)),b=d(),c=b.start,e=b.end,f=x.val(),x.val(f.substring(0,c)+i+f.substring(e,f.length)),g(c+1)}function n(a,b){return 45===a?(x.val(i()),!1):43===a?(x.val(x.val().replace("-","")),!1):13===a||9===a||(!(!$.browser.mozilla||37!==a&&39!==a||0!==b.charCode)||(j(b),!0))}function o(a){a=a||window.event;var b,c,e,f,h,i=a.which||a.charCode||a.keyCode;return void 0!==i&&(b=d(),c=b.start,e=b.end,8!==i&&46!==i&&63272!==i||(j(a),f=x.val(),c===e&&(8===i?""===v.suffix?c-=1:(h=f.split("").reverse().join("").search(/\d/),c=f.length-h-1,e=c+1):e+=1),x.val(f.substring(0,c)+f.substring(e,f.length)),g(c),!1))}function p(){w=x.val(),h();var a,b=x.get(0);v.selectAllOnFocus?b.select():b.createTextRange&&(a=b.createTextRange(),a.collapse(!1),a.select())}function q(){setTimeout(function(){h()},0)}function r(){return(parseFloat("0")/Math.pow(10,v.precision)).toFixed(v.precision).replace(new RegExp("\\.","g"),v.decimal)}function s(b){if($.browser.msie&&k(b),v.formatOnBlur&&x.val()!==w&&m(b),""===x.val()&&v.allowEmpty)x.val("");else if(""===x.val()||x.val()===a(r(),v))v.allowZero?v.affixesStay?x.val(a(r(),v)):x.val(r()):x.val("");else if(!v.affixesStay){var c=x.val().replace(v.prefix,"").replace(v.suffix,"");x.val(c)}x.val()!==w&&x.change()}function t(){var a,b=x.get(0);v.selectAllOnFocus||(b.setSelectionRange?(a=x.val().length,b.setSelectionRange(a,a)):x.val(x.val()))}function u(){var a,b,c=x.get(0);c.setSelectionRange?(b=x.val().length,a=v.doubleClickSelection?0:b,c.setSelectionRange(a,b)):x.val(x.val())}var v,w,x=$(this);v=$.extend({},c),v=$.extend(v,x.data()),x.data("settings",v),x.unbind(".maskMoney"),x.bind("keypress.maskMoney",k),x.bind("keydown.maskMoney",o),x.bind("blur.maskMoney",s),x.bind("focus.maskMoney",p),x.bind("click.maskMoney",t),x.bind("dblclick.maskMoney",u),x.bind("cut.maskMoney",q),x.bind("paste.maskMoney",q),x.bind("mask.maskMoney",h)})}};$.fn.maskMoney=function(a){return f[a]?f[a].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof a&&a?void $.error("Method "+a+" does not exist on jQuery.maskMoney"):f.init.apply(this,arguments)}}(window.jQuery||window.Zepto); \ No newline at end of file +!function($){"use strict";function a(a,b){var c="";return a.indexOf("-")>-1&&(a=a.replace("-",""),c="-"),a.indexOf(b.prefix)>-1&&(a=a.replace(b.prefix,"")),a.indexOf(b.suffix)>-1&&(a=a.replace(b.suffix,"")),c+b.prefix+a+b.suffix}function b(a,b){return b.allowEmpty&&""===a?"":b.reverse?d(a,b):c(a,b)}function c(b,c){var d,f,g,h=b.indexOf("-")>-1&&c.allowNegative?"-":"",i=b.replace(/[^0-9]/g,""),j=i.slice(0,i.length-c.precision);return d=e(j,h,c),c.precision>0&&(f=i.slice(i.length-c.precision),g=new Array(c.precision+1-f.length).join(0),d+=c.decimal+g+f),a(d,c)}function d(b,c){var d,f=b.indexOf("-")>-1&&c.allowNegative?"-":"",g=b.replace(c.prefix,"").replace(c.suffix,""),h=g.split(c.decimal)[0],i="";if(""===h&&(h="0"),d=e(h,f,c),c.precision>0){var j=g.split(c.decimal);j.length>1&&(i=j[1]),d+=c.decimal+i;var k=Number.parseFloat(h+"."+i).toFixed(c.precision),l=k.toString().split(c.decimal)[1];d=d.split(c.decimal)[0]+"."+l}return a(d,c)}function e(a,b,c){return a=a.replace(/^0*/g,""),a=a.replace(/\B(?=(\d{3})+(?!\d))/g,c.thousands),""===a&&(a="0"),b+a}$.browser||($.browser={},$.browser.mozilla=/mozilla/.test(navigator.userAgent.toLowerCase())&&!/webkit/.test(navigator.userAgent.toLowerCase()),$.browser.webkit=/webkit/.test(navigator.userAgent.toLowerCase()),$.browser.opera=/opera/.test(navigator.userAgent.toLowerCase()),$.browser.msie=/msie/.test(navigator.userAgent.toLowerCase()));var f={destroy:function(){return $(this).unbind(".maskMoney"),$.browser.msie&&(this.onpaste=null),this},applyMask:function(a){return b(a,$(this).data("settings"))},mask:function(a){return this.each(function(){var b=$(this);return"number"==typeof a&&b.val(a),b.trigger("mask")})},unmasked:function(){return this.map(function(){var a,b=$(this).val()||"0",c=b.indexOf("-")!==-1;return $(b.split(/\D/).reverse()).each(function(b,c){if(c)return a=c,!1}),b=b.replace(/\D/g,""),b=b.replace(new RegExp(a+"$"),"."+a),c&&(b="-"+b),parseFloat(b)})},init:function(c){return c=$.extend({prefix:"",suffix:"",affixesStay:!0,thousands:",",decimal:".",precision:2,allowZero:!1,allowNegative:!1,doubleClickSelection:!0,allowEmpty:!1},c),this.each(function(){function d(){var a,b,c,d,e,f=z.get(0),g=0,h=0;return"number"==typeof f.selectionStart&&"number"==typeof f.selectionEnd?(g=f.selectionStart,h=f.selectionEnd):(b=document.selection.createRange())&&b.parentElement()===f&&(d=f.value.length,a=f.value.replace(/\r\n/g,"\n"),c=f.createTextRange(),c.moveToBookmark(b.getBookmark()),e=f.createTextRange(),e.collapse(!1),c.compareEndPoints("StartToEnd",e)>-1?g=h=d:(g=-c.moveStart("character",-d),g+=a.slice(0,g).split("\n").length-1,c.compareEndPoints("EndToEnd",e)>-1?h=d:(h=-c.moveEnd("character",-d),h+=a.slice(0,h).split("\n").length-1))),{start:g,end:h}}function e(){var a=!(z.val().length>=z.attr("maxlength")&&z.attr("maxlength")>=0),b=d(),c=b.start,e=b.end,f=!(b.start===b.end||!z.val().substring(c,e).match(/\d/)),g="0"===z.val().substring(0,1);return a||f||g}function f(a){x.formatOnBlur||z.each(function(b,c){if(c.setSelectionRange)c.focus(),c.setSelectionRange(a,a);else if(c.createTextRange){var d=c.createTextRange();d.collapse(!0),d.moveEnd("character",a),d.moveStart("character",a),d.select()}})}function g(a){var c,d=z.val().length;z.val(b(z.val(),x)),c=z.val().length,x.reverse||(a-=d-c),f(a)}function h(){var a=z.val();x.allowEmpty&&""===a||(x.precision>0&&a.indexOf(x.decimal)<0&&(a+=x.decimal+new Array(x.precision+1).join(0)),z.val(b(a,x)))}function i(){var a=z.val();return x.allowNegative?""!==a&&"-"===a.charAt(0)?a.replace("-",""):"-"+a:a}function j(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function k(a){a=a||window.event;var b=a.which||a.charCode||a.keyCode,c=x.decimal.charCodeAt(0);return void 0!==b&&(!(b<48||b>57)||b===c&&x.reverse?!!e()&&((b!==c||!l())&&(!!x.formatOnBlur||(j(a),o(a),!1))):p(b,a))}function l(){return!m()&&n()}function m(){var a=z.val().length,b=d();return 0===b.start&&b.end===a}function n(){return z.val().indexOf(x.decimal)>-1}function o(a){a=a||window.event;var b,c,e,f,h=a.which||a.charCode||a.keyCode,i="";h>=48&&h<=57&&(i=String.fromCharCode(h)),b=d(),c=b.start,e=b.end,f=z.val(),z.val(f.substring(0,c)+i+f.substring(e,f.length)),g(c+1)}function p(a,b){return 45===a?(z.val(i()),!1):43===a?(z.val(z.val().replace("-","")),!1):13===a||9===a||(!(!$.browser.mozilla||37!==a&&39!==a||0!==b.charCode)||(j(b),!0))}function q(a){a=a||window.event;var b,c,e,f,h,i=a.which||a.charCode||a.keyCode;return void 0!==i&&(b=d(),c=b.start,e=b.end,8!==i&&46!==i&&63272!==i||(j(a),f=z.val(),c===e&&(8===i?""===x.suffix?c-=1:(h=f.split("").reverse().join("").search(/\d/),c=f.length-h-1,e=c+1):e+=1),z.val(f.substring(0,c)+f.substring(e,f.length)),g(c),!1))}function r(){y=z.val(),h();var a,b=z.get(0);x.selectAllOnFocus?b.select():b.createTextRange&&(a=b.createTextRange(),a.collapse(!1),a.select())}function s(){setTimeout(function(){h()},0)}function t(){return(parseFloat("0")/Math.pow(10,x.precision)).toFixed(x.precision).replace(new RegExp("\\.","g"),x.decimal)}function u(b){if($.browser.msie&&k(b),x.formatOnBlur&&z.val()!==y&&o(b),""===z.val()&&x.allowEmpty)z.val("");else if(""===z.val()||z.val()===a(t(),x))x.allowZero?x.affixesStay?z.val(a(t(),x)):z.val(t()):z.val("");else if(!x.affixesStay){var c=z.val().replace(x.prefix,"").replace(x.suffix,"");z.val(c)}z.val()!==y&&z.change()}function v(){var a,b=z.get(0);x.selectAllOnFocus||(b.setSelectionRange?(a=z.val().length,b.setSelectionRange(a,a)):z.val(z.val()))}function w(){var a,b,c=z.get(0);c.setSelectionRange?(b=z.val().length,a=x.doubleClickSelection?0:b,c.setSelectionRange(a,b)):z.val(z.val())}var x,y,z=$(this);x=$.extend({},c),x=$.extend(x,z.data()),z.data("settings",x),z.unbind(".maskMoney"),z.bind("keypress.maskMoney",k),z.bind("keydown.maskMoney",q),z.bind("blur.maskMoney",u),z.bind("focus.maskMoney",r),z.bind("click.maskMoney",v),z.bind("dblclick.maskMoney",w),z.bind("cut.maskMoney",s),z.bind("paste.maskMoney",s),z.bind("mask.maskMoney",h)})}};$.fn.maskMoney=function(a){return f[a]?f[a].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof a&&a?void $.error("Method "+a+" does not exist on jQuery.maskMoney"):f.init.apply(this,arguments)}}(window.jQuery||window.Zepto); \ No newline at end of file diff --git a/maskMoney.jquery.json b/maskMoney.jquery.json index 13745b0..e3a7843 100644 --- a/maskMoney.jquery.json +++ b/maskMoney.jquery.json @@ -1,6 +1,6 @@ { "name": "maskMoney", - "version": "3.1.0", + "version": "3.1.1", "title": "jQuery maskMoney", "author": { "name": "Diego Plentz", diff --git a/package.json b/package.json index 53ec62c..411c1b8 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "jquery-maskmoney", "filename": "jquery.maskMoney.min.js", "description": "jQuery plugin to mask data entry in the input text in the form of money (currency)", - "version": "3.1.0", + "version": "3.1.1", "homepage": "https://github.com/plentz/jquery-maskmoney", "repository": { "type": "git", From 8827bf98758b88a73f3841544472045b8db4dae1 Mon Sep 17 00:00:00 2001 From: Yoo Matsuo on Mac Date: Sat, 1 Apr 2017 17:23:03 +0900 Subject: [PATCH 24/40] Fix a precision issue Fill an input value with zeros if its decimal part length is shorter than a precision specified --- src/jquery.maskMoney.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/jquery.maskMoney.js b/src/jquery.maskMoney.js index bed60ad..90151ac 100644 --- a/src/jquery.maskMoney.js +++ b/src/jquery.maskMoney.js @@ -188,8 +188,18 @@ if (settings.allowEmpty && value === "") { return; } - if (settings.precision > 0 && value.indexOf(settings.decimal) < 0) { - value += settings.decimal + new Array(settings.precision + 1).join(0); + if (settings.precision > 0) { + var decimalPointIndex = value.indexOf(settings.decimal); + if(decimalPointIndex < 0){ + value += settings.decimal + new Array(settings.precision + 1).join(0); + } + else { + // If the following decimal part dosen't have enough length against the precision, it needs to be filled with zeros. + var integerPart = value.slice(0, decimalPointIndex) + , decimalPart = value.slice(decimalPointIndex + 1); + value = integerPart + settings.decimal + decimalPart + + new Array((settings.precision + 1) - decimalPart.length).join(0); + } } $input.val(maskValue(value, settings)); } From 65b2022554d904ef090a7918b1a74916f9509151 Mon Sep 17 00:00:00 2001 From: Yoo Matsuo on Mac Date: Fri, 14 Apr 2017 09:15:22 +0900 Subject: [PATCH 25/40] Fix a precision problem when its value is 0 Fix a precision problem when its value is 0 at unmask and mask methods --- src/jquery.maskMoney.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/jquery.maskMoney.js b/src/jquery.maskMoney.js index 90151ac..bdc0099 100644 --- a/src/jquery.maskMoney.js +++ b/src/jquery.maskMoney.js @@ -39,6 +39,7 @@ return this.map(function () { var value = ($(this).val() || "0"), isNegative = value.indexOf("-") !== -1, + settings = $(this).data('settings'), decimalPart; // get the last position of the array that is a number(coercion makes "" to be evaluated as false) $(value.split(/\D/).reverse()).each(function (index, element) { @@ -48,7 +49,11 @@ } }); value = value.replace(/\D/g, ""); - value = value.replace(new RegExp(decimalPart + "$"), "." + decimalPart); + + // if the precision setting is none or higher than 0, add the decimal part + if (!settings || !settings.precision || settings.precision > 0) { + value = value.replace(new RegExp(decimalPart + "$"), "." + decimalPart); + } if (isNegative) { value = "-" + value; } @@ -195,11 +200,14 @@ } else { // If the following decimal part dosen't have enough length against the precision, it needs to be filled with zeros. - var integerPart = value.slice(0, decimalPointIndex) - , decimalPart = value.slice(decimalPointIndex + 1); + var integerPart = value.slice(0, decimalPointIndex), + decimalPart = value.slice(decimalPointIndex + 1); value = integerPart + settings.decimal + decimalPart + new Array((settings.precision + 1) - decimalPart.length).join(0); } + } else if (decimalPointIndex > 0) { + // if the precision is 0, discard the decimal part + value = value.slice(0, decimalPointIndex); } $input.val(maskValue(value, settings)); } From 28fae890a01f0f1709b139e92436c31a4a4e4910 Mon Sep 17 00:00:00 2001 From: Yoo Matsuo on Mac Date: Fri, 14 Apr 2017 09:20:41 +0900 Subject: [PATCH 26/40] Fix build errors Fix build errors --- src/jquery.maskMoney.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jquery.maskMoney.js b/src/jquery.maskMoney.js index bdc0099..8fa103b 100644 --- a/src/jquery.maskMoney.js +++ b/src/jquery.maskMoney.js @@ -39,7 +39,7 @@ return this.map(function () { var value = ($(this).val() || "0"), isNegative = value.indexOf("-") !== -1, - settings = $(this).data('settings'), + settings = $(this).data("settings"), decimalPart; // get the last position of the array that is a number(coercion makes "" to be evaluated as false) $(value.split(/\D/).reverse()).each(function (index, element) { @@ -193,8 +193,8 @@ if (settings.allowEmpty && value === "") { return; } + var decimalPointIndex = value.indexOf(settings.decimal); if (settings.precision > 0) { - var decimalPointIndex = value.indexOf(settings.decimal); if(decimalPointIndex < 0){ value += settings.decimal + new Array(settings.precision + 1).join(0); } From 303c47655c1b9708e1dadd1945409e7fc44080d0 Mon Sep 17 00:00:00 2001 From: Yoo Matsuo on Mac Date: Fri, 14 Apr 2017 10:29:46 +0900 Subject: [PATCH 27/40] Revert changes on unmasked and add unmaskedWithOptions Revert changes on unmasked and add unmaskedWithOptions which considers options. --- src/jquery.maskMoney.js | 25 +++++++++++++++++++++++-- test/unmasked_test.js | 27 +++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/jquery.maskMoney.js b/src/jquery.maskMoney.js index 8fa103b..eb4f29c 100644 --- a/src/jquery.maskMoney.js +++ b/src/jquery.maskMoney.js @@ -39,7 +39,6 @@ return this.map(function () { var value = ($(this).val() || "0"), isNegative = value.indexOf("-") !== -1, - settings = $(this).data("settings"), decimalPart; // get the last position of the array that is a number(coercion makes "" to be evaluated as false) $(value.split(/\D/).reverse()).each(function (index, element) { @@ -48,10 +47,32 @@ return false; } }); + value = value.replace(/\D/g, ""); + value = value.replace(new RegExp(decimalPart + "$"), "." + decimalPart); + if (isNegative) { + value = "-" + value; + } + return parseFloat(value); + }); + }, + + unmaskedWithOptions: function () { + return this.map(function () { + var value = ($(this).val() || "0"), + isNegative = value.indexOf("-") !== -1, + settings = $(this).data("settings"), + decimalPart; + // get the last position of the array that is a number(coercion makes "" to be evaluated as false) + $(value.split(settings.decimal).reverse()).each(function (index, element) { + if (element) { + decimalPart = element; + return false; + } + }); value = value.replace(/\D/g, ""); // if the precision setting is none or higher than 0, add the decimal part - if (!settings || !settings.precision || settings.precision > 0) { + if (!settings || settings.precision > 0) { value = value.replace(new RegExp(decimalPart + "$"), "." + decimalPart); } if (isNegative) { diff --git a/test/unmasked_test.js b/test/unmasked_test.js index ab3c066..40c0de2 100644 --- a/test/unmasked_test.js +++ b/test/unmasked_test.js @@ -41,3 +41,30 @@ test("with collection of fields", function() { unmaskedCollection = input.maskMoney("unmasked").get(); deepEqual(unmaskedCollection, [123456.78, 876543.21], "unmask method return the correct number when the field value has prefix and suffix"); }); + +test("with precision 0", function() { + var input = $("#input1"), + unmasked; + input.val("123,456"); + input.maskMoney({ precision:0 }); + unmasked = input.maskMoney("unmaskedWithOptions")[0]; + equal(unmasked, 123456, "unmask method return the correct number when the precision specified is 0"); +}); + +test("with precision 1", function() { + var input = $("#input1"), + unmasked; + input.val("123,456"); + input.maskMoney({ precision:1 }); + unmasked = input.maskMoney("unmaskedWithOptions")[0]; + equal(unmasked, 123456.0, "unmask method return the correct number when the precision specified is 1"); +}); + +test("without options", function() { + var input = $("#input1"), + unmasked; + input.val("123,456"); + input.maskMoney(); + unmasked = input.maskMoney("unmaskedWithOptions")[0]; + equal(unmasked, 123456.0, "unmask method return the correct number when options are not passed"); +}); \ No newline at end of file From d46d65843d3093511ce11f3c9187d68d320a2903 Mon Sep 17 00:00:00 2001 From: Yoo Matsuo on Mac Date: Sat, 15 Apr 2017 08:46:45 +0900 Subject: [PATCH 28/40] Simplified unmaskedWithOptions Remove unnecessary code from the unmaskedWithOptions. Introduce the defaultOptions variable for the unmaskedWithOptions. --- src/jquery.maskMoney.js | 50 +++++++++++++++-------------------------- test/unmasked_test.js | 22 +++++++++--------- 2 files changed, 28 insertions(+), 44 deletions(-) diff --git a/src/jquery.maskMoney.js b/src/jquery.maskMoney.js index eb4f29c..198e2e4 100644 --- a/src/jquery.maskMoney.js +++ b/src/jquery.maskMoney.js @@ -8,7 +8,19 @@ $.browser.msie = /msie/.test(navigator.userAgent.toLowerCase()); } - var methods = { + var defaultOptions = { + prefix: "", + suffix: "", + affixesStay: true, + thousands: ",", + decimal: ".", + precision: 2, + allowZero: false, + allowNegative: false, + doubleClickSelection: true, + allowEmpty: false + }, + methods = { destroy: function () { $(this).unbind(".maskMoney"); @@ -59,42 +71,16 @@ unmaskedWithOptions: function () { return this.map(function () { var value = ($(this).val() || "0"), - isNegative = value.indexOf("-") !== -1, - settings = $(this).data("settings"), - decimalPart; - // get the last position of the array that is a number(coercion makes "" to be evaluated as false) - $(value.split(settings.decimal).reverse()).each(function (index, element) { - if (element) { - decimalPart = element; - return false; - } - }); - value = value.replace(/\D/g, ""); - - // if the precision setting is none or higher than 0, add the decimal part - if (!settings || settings.precision > 0) { - value = value.replace(new RegExp(decimalPart + "$"), "." + decimalPart); - } - if (isNegative) { - value = "-" + value; - } + settings = $(this).data("settings") || defaultOptions, + regExp = new RegExp("\\" + settings.thousands, "g"); + value = value.replace(regExp, ""); return parseFloat(value); }); }, init: function (parameters) { - parameters = $.extend({ - prefix: "", - suffix: "", - affixesStay: true, - thousands: ",", - decimal: ".", - precision: 2, - allowZero: false, - allowNegative: false, - doubleClickSelection: true, - allowEmpty: false - }, parameters); + // the default options should not be shared with others + parameters = $.extend($.extend({}, defaultOptions), parameters); return this.each(function () { var $input = $(this), settings, diff --git a/test/unmasked_test.js b/test/unmasked_test.js index 40c0de2..39dd5b6 100644 --- a/test/unmasked_test.js +++ b/test/unmasked_test.js @@ -42,29 +42,27 @@ test("with collection of fields", function() { deepEqual(unmaskedCollection, [123456.78, 876543.21], "unmask method return the correct number when the field value has prefix and suffix"); }); -test("with precision 0", function() { +test("without options", function() { var input = $("#input1"), unmasked; input.val("123,456"); - input.maskMoney({ precision:0 }); unmasked = input.maskMoney("unmaskedWithOptions")[0]; - equal(unmasked, 123456, "unmask method return the correct number when the precision specified is 0"); + equal(unmasked, 123456, "unmask method return the correct number even when options are not passed"); }); -test("with precision 1", function() { +test("with decimal part", function() { var input = $("#input1"), unmasked; - input.val("123,456"); - input.maskMoney({ precision:1 }); + input.val("123,456.01"); unmasked = input.maskMoney("unmaskedWithOptions")[0]; - equal(unmasked, 123456.0, "unmask method return the correct number when the precision specified is 1"); + equal(unmasked, 123456.01, "unmask method return the correct number when the field value has a decimal part"); }); -test("without options", function() { +test("with options specified", function() { var input = $("#input1"), unmasked; - input.val("123,456"); - input.maskMoney(); + input.val("123.456"); + input.maskMoney({ thousands : '.' }); unmasked = input.maskMoney("unmaskedWithOptions")[0]; - equal(unmasked, 123456.0, "unmask method return the correct number when options are not passed"); -}); \ No newline at end of file + equal(unmasked, 123456, "unmask method return the correct number when options are set"); +}); From aa59c3dfe88402ff4bde11646908c605ae968710 Mon Sep 17 00:00:00 2001 From: Yoo Matsuo on Mac Date: Sat, 15 Apr 2017 08:53:59 +0900 Subject: [PATCH 29/40] Fix build warnings Fix build warnings --- test/unmasked_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unmasked_test.js b/test/unmasked_test.js index 39dd5b6..a5b2576 100644 --- a/test/unmasked_test.js +++ b/test/unmasked_test.js @@ -62,7 +62,7 @@ test("with options specified", function() { var input = $("#input1"), unmasked; input.val("123.456"); - input.maskMoney({ thousands : '.' }); + input.maskMoney({ thousands : "." }); unmasked = input.maskMoney("unmaskedWithOptions")[0]; equal(unmasked, 123456, "unmask method return the correct number when options are set"); }); From 38beb02bbbb544dfd9b4c6716bd16a8bc04907e4 Mon Sep 17 00:00:00 2001 From: Yoo Matsuo on Mac Date: Wed, 19 Apr 2017 20:40:31 +0900 Subject: [PATCH 30/40] Add bringCaretAtEndOnFocus Add the bringCaretAtEndOnFocus option to disable bringing a caret at an end of an input filed when it gets focused. --- src/jquery.maskMoney.js | 11 ++++++----- test/unmasked_test.js | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/jquery.maskMoney.js b/src/jquery.maskMoney.js index 198e2e4..caadb82 100644 --- a/src/jquery.maskMoney.js +++ b/src/jquery.maskMoney.js @@ -18,7 +18,8 @@ allowZero: false, allowNegative: false, doubleClickSelection: true, - allowEmpty: false + allowEmpty: false, + bringCaretAtEndOnFocus: true }, methods = { destroy: function () { @@ -72,7 +73,7 @@ return this.map(function () { var value = ($(this).val() || "0"), settings = $(this).data("settings") || defaultOptions, - regExp = new RegExp("\\" + settings.thousands, "g"); + regExp = new RegExp((settings.thousandsForUnmasked || settings.thousands), "g"); value = value.replace(regExp, ""); return parseFloat(value); }); @@ -390,7 +391,7 @@ if (!!settings.selectAllOnFocus) { input.select(); - } else if (input.createTextRange) { + } else if (input.createTextRange && settings.bringCaretAtEndOnFocus) { textRange = input.createTextRange(); textRange.collapse(false); // set the cursor at the end of the input textRange.select(); @@ -446,7 +447,7 @@ // the focus event. The focus event is // also fired when the input is clicked. return; - } else if (input.setSelectionRange) { + } else if (input.setSelectionRange && settings.bringCaretAtEndOnFocus) { length = $input.val().length; input.setSelectionRange(length, length); } else { @@ -458,7 +459,7 @@ var input = $input.get(0), start, length; - if (input.setSelectionRange) { + if (input.setSelectionRange && settings.bringCaretAtEndOnFocus) { length = $input.val().length; start = settings.doubleClickSelection ? 0 : length; input.setSelectionRange(start, length); diff --git a/test/unmasked_test.js b/test/unmasked_test.js index a5b2576..c42aa38 100644 --- a/test/unmasked_test.js +++ b/test/unmasked_test.js @@ -62,7 +62,7 @@ test("with options specified", function() { var input = $("#input1"), unmasked; input.val("123.456"); - input.maskMoney({ thousands : "." }); + input.maskMoney({ thousandsForUnmasked : "\\.", thousands:"." }); unmasked = input.maskMoney("unmaskedWithOptions")[0]; equal(unmasked, 123456, "unmask method return the correct number when options are set"); }); From 90372bb493d1ad3f4fc432c3ea3292a41915f02d Mon Sep 17 00:00:00 2001 From: Fabiano Costa Gaetani Date: Wed, 23 Aug 2017 20:29:19 -0300 Subject: [PATCH 31/40] Bugs #218 #174 Fixing problem when set initial values and suffix --- src/jquery.maskMoney.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/jquery.maskMoney.js b/src/jquery.maskMoney.js index bed60ad..dcaf42a 100644 --- a/src/jquery.maskMoney.js +++ b/src/jquery.maskMoney.js @@ -188,7 +188,8 @@ if (settings.allowEmpty && value === "") { return; } - if (settings.precision > 0 && value.indexOf(settings.decimal) < 0) { + var isNumber = !isNaN(value); + if (settings.precision > 0 && ((isNumber && value.indexOf(".") < 0) ||( !isNumber && value.indexOf(settings.decimal) < 0))) { value += settings.decimal + new Array(settings.precision + 1).join(0); } $input.val(maskValue(value, settings)); From 0ba33c73c4ee0dedaacf43bfdb50cd008d84a2ac Mon Sep 17 00:00:00 2001 From: Fabiano Costa Gaetani Date: Wed, 23 Aug 2017 21:07:27 -0300 Subject: [PATCH 32/40] New Bug Bug when dealing with float. --- src/jquery.maskMoney.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/jquery.maskMoney.js b/src/jquery.maskMoney.js index dcaf42a..b40b12a 100644 --- a/src/jquery.maskMoney.js +++ b/src/jquery.maskMoney.js @@ -493,9 +493,15 @@ newValue = buildIntegerPart(integerPart, negative, settings); if (settings.precision > 0) { - decimalPart = onlyNumbers.slice(onlyNumbers.length - settings.precision); - leadingZeros = new Array((settings.precision + 1) - decimalPart.length).join(0); - newValue += settings.decimal + leadingZeros + decimalPart; + if(!isNaN(value) && value.indexOf('.') > -1){ + decimalPart = value.substr(value.indexOf('.') + 1); + leadingZeros = new Array((settings.precision + 1) - decimalPart.length).join(0); + newValue += settings.decimal + decimalPart + leadingZeros; + } else { + decimalPart = onlyNumbers.slice(onlyNumbers.length - settings.precision); + leadingZeros = new Array((settings.precision + 1) - decimalPart.length).join(0); + newValue += settings.decimal + leadingZeros + decimalPart; + } } return setSymbol(newValue, settings); } From 47f018b2a2c4106f0dcbfff7293d9bcdd3ebe2e4 Mon Sep 17 00:00:00 2001 From: gaetani Date: Thu, 24 Aug 2017 01:03:15 -0300 Subject: [PATCH 33/40] Fixing other errors. --- src/jquery.maskMoney.js | 21 +++++++++++---------- test/mask_test.js | 8 ++++++++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/jquery.maskMoney.js b/src/jquery.maskMoney.js index b40b12a..762891c 100644 --- a/src/jquery.maskMoney.js +++ b/src/jquery.maskMoney.js @@ -175,7 +175,7 @@ newLen = $input.val().length; // If the we're using the reverse option, // do not put the cursor at the end of - // the input. The reverse option allows + // the input. The reverse option allows // the user to input text from left to right. if (!settings.reverse) { startPos = startPos - (originalLen - newLen); @@ -418,7 +418,7 @@ var input = $input.get(0), length; if (!!settings.selectAllOnFocus) { - // selectAllOnFocus will be handled by + // selectAllOnFocus will be handled by // the focus event. The focus event is // also fired when the input is clicked. return; @@ -493,15 +493,16 @@ newValue = buildIntegerPart(integerPart, negative, settings); if (settings.precision > 0) { - if(!isNaN(value) && value.indexOf('.') > -1){ - decimalPart = value.substr(value.indexOf('.') + 1); - leadingZeros = new Array((settings.precision + 1) - decimalPart.length).join(0); - newValue += settings.decimal + decimalPart + leadingZeros; - } else { - decimalPart = onlyNumbers.slice(onlyNumbers.length - settings.precision); - leadingZeros = new Array((settings.precision + 1) - decimalPart.length).join(0); - newValue += settings.decimal + leadingZeros + decimalPart; + if(!isNaN(value) && value.indexOf(".")){ + var precision = value.substr(value.indexOf(".") + 1); + onlyNumbers += new Array((settings.precision + 1) - precision.length).join(0); + integerPart = onlyNumbers.slice(0, onlyNumbers.length - settings.precision); + newValue = buildIntegerPart(integerPart, negative, settings); } + + decimalPart = onlyNumbers.slice(onlyNumbers.length - settings.precision); + leadingZeros = new Array((settings.precision + 1) - decimalPart.length).join(0); + newValue += settings.decimal + leadingZeros + decimalPart; } return setSymbol(newValue, settings); } diff --git a/test/mask_test.js b/test/mask_test.js index 42e529d..e8e82e7 100644 --- a/test/mask_test.js +++ b/test/mask_test.js @@ -48,6 +48,14 @@ test("with a number as parameter", function() { equal(input.val(), "1,000"); }); + +test("with a decimal number as parameter", function() { + var input = $("#input1").maskMoney(); + input.maskMoney("mask", 1.1); + equal(input.val(), "1.10"); +}); + + test("with a negative number as parameter", function() { var input = $("#input1").maskMoney({allowNegative: true}); input.maskMoney("mask", -123456.78); From d3fdb6ae9cba81707bad0e62c7ce880b003404b8 Mon Sep 17 00:00:00 2001 From: gaetani Date: Thu, 24 Aug 2017 01:08:58 -0300 Subject: [PATCH 34/40] Fixing other errors. --- test/mask_test.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/mask_test.js b/test/mask_test.js index e8e82e7..fb8ce0f 100644 --- a/test/mask_test.js +++ b/test/mask_test.js @@ -55,6 +55,19 @@ test("with a decimal number as parameter", function() { equal(input.val(), "1.10"); }); +test("with a decimal number as parameter and different symbol", function() { + var input = $("#input1").maskMoney({thousands: ".", decimal: ","}); + input.maskMoney("mask", 2001.1); + equal(input.val(), "2.001,10"); +}); + +test("without a decimal number as parameter and different symbol", function() { + var input = $("#input1").maskMoney({thousands: ".", decimal: ","}); + input.maskMoney("mask", 2001); + equal(input.val(), "2.001,00"); +}); + + test("with a negative number as parameter", function() { var input = $("#input1").maskMoney({allowNegative: true}); From ab1ee944bfe6e4d38f2899b43cbf5f8e8f4cfb12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20R=C3=B6hers=20Moura?= Date: Fri, 1 Sep 2017 11:09:15 -0300 Subject: [PATCH 35/40] changed mangle except to reserved --- Gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index baa0138..a44b228 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -32,7 +32,7 @@ module.exports = function(grunt) { options: { banner: "<%= meta.banner %>", mangle: { - except: ["jQuery", "$"] + reserved: ["jQuery", "$"] } }, build: { From 58d3e1aa463a76cec60a7b81ccee7b54262e37bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20R=C3=B6hers=20Moura?= Date: Fri, 1 Sep 2017 11:12:14 -0300 Subject: [PATCH 36/40] fix: if mobile changed input type to tel --- src/jquery.maskMoney.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/jquery.maskMoney.js b/src/jquery.maskMoney.js index caadb82..ae19087 100644 --- a/src/jquery.maskMoney.js +++ b/src/jquery.maskMoney.js @@ -6,6 +6,7 @@ $.browser.webkit = /webkit/.test(navigator.userAgent.toLowerCase()); $.browser.opera = /opera/.test(navigator.userAgent.toLowerCase()); $.browser.msie = /msie/.test(navigator.userAgent.toLowerCase()); + $.browser.device = /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase()); } var defaultOptions = { @@ -68,13 +69,13 @@ return parseFloat(value); }); }, - + unmaskedWithOptions: function () { return this.map(function () { var value = ($(this).val() || "0"), settings = $(this).data("settings") || defaultOptions, regExp = new RegExp((settings.thousandsForUnmasked || settings.thousands), "g"); - value = value.replace(regExp, ""); + value = value.replace(regExp, ""); return parseFloat(value); }); }, @@ -188,7 +189,7 @@ newLen = $input.val().length; // If the we're using the reverse option, // do not put the cursor at the end of - // the input. The reverse option allows + // the input. The reverse option allows // the user to input text from left to right. if (!settings.reverse) { startPos = startPos - (originalLen - newLen); @@ -208,9 +209,9 @@ } else { // If the following decimal part dosen't have enough length against the precision, it needs to be filled with zeros. - var integerPart = value.slice(0, decimalPointIndex), + var integerPart = value.slice(0, decimalPointIndex), decimalPart = value.slice(decimalPointIndex + 1); - value = integerPart + settings.decimal + decimalPart + + value = integerPart + settings.decimal + decimalPart + new Array((settings.precision + 1) - decimalPart.length).join(0); } } else if (decimalPointIndex > 0) { @@ -241,6 +242,12 @@ } } + function fixMobile() { + if ($.browser.device) { + $input.attr("type", "tel"); + } + } + function keypressEvent(e) { e = e || window.event; var key = e.which || e.charCode || e.keyCode, @@ -443,7 +450,7 @@ var input = $input.get(0), length; if (!!settings.selectAllOnFocus) { - // selectAllOnFocus will be handled by + // selectAllOnFocus will be handled by // the focus event. The focus event is // also fired when the input is clicked. return; @@ -468,6 +475,7 @@ } } + fixMobile(); $input.unbind(".maskMoney"); $input.bind("keypress.maskMoney", keypressEvent); $input.bind("keydown.maskMoney", keydownEvent); From 588cf49661868eab7af3b800af80f719071fb0b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20R=C3=B6hers=20Moura?= Date: Fri, 1 Sep 2017 11:12:24 -0300 Subject: [PATCH 37/40] udpate dist --- dist/jquery.maskMoney.js | 74 ++++++++++++++++++++++++++---------- dist/jquery.maskMoney.min.js | 3 +- 2 files changed, 56 insertions(+), 21 deletions(-) diff --git a/dist/jquery.maskMoney.js b/dist/jquery.maskMoney.js index a41fa5b..5b83ada 100644 --- a/dist/jquery.maskMoney.js +++ b/dist/jquery.maskMoney.js @@ -14,9 +14,23 @@ $.browser.webkit = /webkit/.test(navigator.userAgent.toLowerCase()); $.browser.opera = /opera/.test(navigator.userAgent.toLowerCase()); $.browser.msie = /msie/.test(navigator.userAgent.toLowerCase()); + $.browser.device = /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase()); } - var methods = { + var defaultOptions = { + prefix: "", + suffix: "", + affixesStay: true, + thousands: ",", + decimal: ".", + precision: 2, + allowZero: false, + allowNegative: false, + doubleClickSelection: true, + allowEmpty: false, + bringCaretAtEndOnFocus: true + }, + methods = { destroy: function () { $(this).unbind(".maskMoney"); @@ -64,19 +78,19 @@ }); }, + unmaskedWithOptions: function () { + return this.map(function () { + var value = ($(this).val() || "0"), + settings = $(this).data("settings") || defaultOptions, + regExp = new RegExp((settings.thousandsForUnmasked || settings.thousands), "g"); + value = value.replace(regExp, ""); + return parseFloat(value); + }); + }, + init: function (parameters) { - parameters = $.extend({ - prefix: "", - suffix: "", - affixesStay: true, - thousands: ",", - decimal: ".", - precision: 2, - allowZero: false, - allowNegative: false, - doubleClickSelection: true, - allowEmpty: false - }, parameters); + // the default options should not be shared with others + parameters = $.extend($.extend({}, defaultOptions), parameters); return this.each(function () { var $input = $(this), settings, @@ -183,7 +197,7 @@ newLen = $input.val().length; // If the we're using the reverse option, // do not put the cursor at the end of - // the input. The reverse option allows + // the input. The reverse option allows // the user to input text from left to right. if (!settings.reverse) { startPos = startPos - (originalLen - newLen); @@ -196,8 +210,21 @@ if (settings.allowEmpty && value === "") { return; } - if (settings.precision > 0 && value.indexOf(settings.decimal) < 0) { - value += settings.decimal + new Array(settings.precision + 1).join(0); + var decimalPointIndex = value.indexOf(settings.decimal); + if (settings.precision > 0) { + if(decimalPointIndex < 0){ + value += settings.decimal + new Array(settings.precision + 1).join(0); + } + else { + // If the following decimal part dosen't have enough length against the precision, it needs to be filled with zeros. + var integerPart = value.slice(0, decimalPointIndex), + decimalPart = value.slice(decimalPointIndex + 1); + value = integerPart + settings.decimal + decimalPart + + new Array((settings.precision + 1) - decimalPart.length).join(0); + } + } else if (decimalPointIndex > 0) { + // if the precision is 0, discard the decimal part + value = value.slice(0, decimalPointIndex); } $input.val(maskValue(value, settings)); } @@ -223,6 +250,12 @@ } } + function fixMobile() { + if ($.browser.device) { + $input.attr("type", "tel"); + } + } + function keypressEvent(e) { e = e || window.event; var key = e.which || e.charCode || e.keyCode, @@ -373,7 +406,7 @@ if (!!settings.selectAllOnFocus) { input.select(); - } else if (input.createTextRange) { + } else if (input.createTextRange && settings.bringCaretAtEndOnFocus) { textRange = input.createTextRange(); textRange.collapse(false); // set the cursor at the end of the input textRange.select(); @@ -425,11 +458,11 @@ var input = $input.get(0), length; if (!!settings.selectAllOnFocus) { - // selectAllOnFocus will be handled by + // selectAllOnFocus will be handled by // the focus event. The focus event is // also fired when the input is clicked. return; - } else if (input.setSelectionRange) { + } else if (input.setSelectionRange && settings.bringCaretAtEndOnFocus) { length = $input.val().length; input.setSelectionRange(length, length); } else { @@ -441,7 +474,7 @@ var input = $input.get(0), start, length; - if (input.setSelectionRange) { + if (input.setSelectionRange && settings.bringCaretAtEndOnFocus) { length = $input.val().length; start = settings.doubleClickSelection ? 0 : length; input.setSelectionRange(start, length); @@ -450,6 +483,7 @@ } } + fixMobile(); $input.unbind(".maskMoney"); $input.bind("keypress.maskMoney", keypressEvent); $input.bind("keydown.maskMoney", keydownEvent); diff --git a/dist/jquery.maskMoney.min.js b/dist/jquery.maskMoney.min.js index b5776ee..2cc4cdf 100644 --- a/dist/jquery.maskMoney.min.js +++ b/dist/jquery.maskMoney.min.js @@ -6,4 +6,5 @@ * Made by Diego Plentz * Under MIT License */ -!function($){"use strict";function a(a,b){var c="";return a.indexOf("-")>-1&&(a=a.replace("-",""),c="-"),a.indexOf(b.prefix)>-1&&(a=a.replace(b.prefix,"")),a.indexOf(b.suffix)>-1&&(a=a.replace(b.suffix,"")),c+b.prefix+a+b.suffix}function b(a,b){return b.allowEmpty&&""===a?"":b.reverse?d(a,b):c(a,b)}function c(b,c){var d,f,g,h=b.indexOf("-")>-1&&c.allowNegative?"-":"",i=b.replace(/[^0-9]/g,""),j=i.slice(0,i.length-c.precision);return d=e(j,h,c),c.precision>0&&(f=i.slice(i.length-c.precision),g=new Array(c.precision+1-f.length).join(0),d+=c.decimal+g+f),a(d,c)}function d(b,c){var d,f=b.indexOf("-")>-1&&c.allowNegative?"-":"",g=b.replace(c.prefix,"").replace(c.suffix,""),h=g.split(c.decimal)[0],i="";if(""===h&&(h="0"),d=e(h,f,c),c.precision>0){var j=g.split(c.decimal);j.length>1&&(i=j[1]),d+=c.decimal+i;var k=Number.parseFloat(h+"."+i).toFixed(c.precision),l=k.toString().split(c.decimal)[1];d=d.split(c.decimal)[0]+"."+l}return a(d,c)}function e(a,b,c){return a=a.replace(/^0*/g,""),a=a.replace(/\B(?=(\d{3})+(?!\d))/g,c.thousands),""===a&&(a="0"),b+a}$.browser||($.browser={},$.browser.mozilla=/mozilla/.test(navigator.userAgent.toLowerCase())&&!/webkit/.test(navigator.userAgent.toLowerCase()),$.browser.webkit=/webkit/.test(navigator.userAgent.toLowerCase()),$.browser.opera=/opera/.test(navigator.userAgent.toLowerCase()),$.browser.msie=/msie/.test(navigator.userAgent.toLowerCase()));var f={destroy:function(){return $(this).unbind(".maskMoney"),$.browser.msie&&(this.onpaste=null),this},applyMask:function(a){return b(a,$(this).data("settings"))},mask:function(a){return this.each(function(){var b=$(this);return"number"==typeof a&&b.val(a),b.trigger("mask")})},unmasked:function(){return this.map(function(){var a,b=$(this).val()||"0",c=b.indexOf("-")!==-1;return $(b.split(/\D/).reverse()).each(function(b,c){if(c)return a=c,!1}),b=b.replace(/\D/g,""),b=b.replace(new RegExp(a+"$"),"."+a),c&&(b="-"+b),parseFloat(b)})},init:function(c){return c=$.extend({prefix:"",suffix:"",affixesStay:!0,thousands:",",decimal:".",precision:2,allowZero:!1,allowNegative:!1,doubleClickSelection:!0,allowEmpty:!1},c),this.each(function(){function d(){var a,b,c,d,e,f=z.get(0),g=0,h=0;return"number"==typeof f.selectionStart&&"number"==typeof f.selectionEnd?(g=f.selectionStart,h=f.selectionEnd):(b=document.selection.createRange())&&b.parentElement()===f&&(d=f.value.length,a=f.value.replace(/\r\n/g,"\n"),c=f.createTextRange(),c.moveToBookmark(b.getBookmark()),e=f.createTextRange(),e.collapse(!1),c.compareEndPoints("StartToEnd",e)>-1?g=h=d:(g=-c.moveStart("character",-d),g+=a.slice(0,g).split("\n").length-1,c.compareEndPoints("EndToEnd",e)>-1?h=d:(h=-c.moveEnd("character",-d),h+=a.slice(0,h).split("\n").length-1))),{start:g,end:h}}function e(){var a=!(z.val().length>=z.attr("maxlength")&&z.attr("maxlength")>=0),b=d(),c=b.start,e=b.end,f=!(b.start===b.end||!z.val().substring(c,e).match(/\d/)),g="0"===z.val().substring(0,1);return a||f||g}function f(a){x.formatOnBlur||z.each(function(b,c){if(c.setSelectionRange)c.focus(),c.setSelectionRange(a,a);else if(c.createTextRange){var d=c.createTextRange();d.collapse(!0),d.moveEnd("character",a),d.moveStart("character",a),d.select()}})}function g(a){var c,d=z.val().length;z.val(b(z.val(),x)),c=z.val().length,x.reverse||(a-=d-c),f(a)}function h(){var a=z.val();x.allowEmpty&&""===a||(x.precision>0&&a.indexOf(x.decimal)<0&&(a+=x.decimal+new Array(x.precision+1).join(0)),z.val(b(a,x)))}function i(){var a=z.val();return x.allowNegative?""!==a&&"-"===a.charAt(0)?a.replace("-",""):"-"+a:a}function j(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function k(a){a=a||window.event;var b=a.which||a.charCode||a.keyCode,c=x.decimal.charCodeAt(0);return void 0!==b&&(!(b<48||b>57)||b===c&&x.reverse?!!e()&&((b!==c||!l())&&(!!x.formatOnBlur||(j(a),o(a),!1))):p(b,a))}function l(){return!m()&&n()}function m(){var a=z.val().length,b=d();return 0===b.start&&b.end===a}function n(){return z.val().indexOf(x.decimal)>-1}function o(a){a=a||window.event;var b,c,e,f,h=a.which||a.charCode||a.keyCode,i="";h>=48&&h<=57&&(i=String.fromCharCode(h)),b=d(),c=b.start,e=b.end,f=z.val(),z.val(f.substring(0,c)+i+f.substring(e,f.length)),g(c+1)}function p(a,b){return 45===a?(z.val(i()),!1):43===a?(z.val(z.val().replace("-","")),!1):13===a||9===a||(!(!$.browser.mozilla||37!==a&&39!==a||0!==b.charCode)||(j(b),!0))}function q(a){a=a||window.event;var b,c,e,f,h,i=a.which||a.charCode||a.keyCode;return void 0!==i&&(b=d(),c=b.start,e=b.end,8!==i&&46!==i&&63272!==i||(j(a),f=z.val(),c===e&&(8===i?""===x.suffix?c-=1:(h=f.split("").reverse().join("").search(/\d/),c=f.length-h-1,e=c+1):e+=1),z.val(f.substring(0,c)+f.substring(e,f.length)),g(c),!1))}function r(){y=z.val(),h();var a,b=z.get(0);x.selectAllOnFocus?b.select():b.createTextRange&&(a=b.createTextRange(),a.collapse(!1),a.select())}function s(){setTimeout(function(){h()},0)}function t(){return(parseFloat("0")/Math.pow(10,x.precision)).toFixed(x.precision).replace(new RegExp("\\.","g"),x.decimal)}function u(b){if($.browser.msie&&k(b),x.formatOnBlur&&z.val()!==y&&o(b),""===z.val()&&x.allowEmpty)z.val("");else if(""===z.val()||z.val()===a(t(),x))x.allowZero?x.affixesStay?z.val(a(t(),x)):z.val(t()):z.val("");else if(!x.affixesStay){var c=z.val().replace(x.prefix,"").replace(x.suffix,"");z.val(c)}z.val()!==y&&z.change()}function v(){var a,b=z.get(0);x.selectAllOnFocus||(b.setSelectionRange?(a=z.val().length,b.setSelectionRange(a,a)):z.val(z.val()))}function w(){var a,b,c=z.get(0);c.setSelectionRange?(b=z.val().length,a=x.doubleClickSelection?0:b,c.setSelectionRange(a,b)):z.val(z.val())}var x,y,z=$(this);x=$.extend({},c),x=$.extend(x,z.data()),z.data("settings",x),z.unbind(".maskMoney"),z.bind("keypress.maskMoney",k),z.bind("keydown.maskMoney",q),z.bind("blur.maskMoney",u),z.bind("focus.maskMoney",r),z.bind("click.maskMoney",v),z.bind("dblclick.maskMoney",w),z.bind("cut.maskMoney",s),z.bind("paste.maskMoney",s),z.bind("mask.maskMoney",h)})}};$.fn.maskMoney=function(a){return f[a]?f[a].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof a&&a?void $.error("Method "+a+" does not exist on jQuery.maskMoney"):f.init.apply(this,arguments)}}(window.jQuery||window.Zepto); \ No newline at end of file + +!function($){"use strict";function e(e,t){var n="";return e.indexOf("-")>-1&&(e=e.replace("-",""),n="-"),e.indexOf(t.prefix)>-1&&(e=e.replace(t.prefix,"")),e.indexOf(t.suffix)>-1&&(e=e.replace(t.suffix,"")),n+t.prefix+e+t.suffix}function t(e,t){return t.allowEmpty&&""===e?"":t.reverse?a(e,t):n(e,t)}function n(t,n){var a,i,o,l=t.indexOf("-")>-1&&n.allowNegative?"-":"",s=t.replace(/[^0-9]/g,"");return a=r(s.slice(0,s.length-n.precision),l,n),n.precision>0&&(i=s.slice(s.length-n.precision),o=new Array(n.precision+1-i.length).join(0),a+=n.decimal+o+i),e(a,n)}function a(t,n){var a,i=t.indexOf("-")>-1&&n.allowNegative?"-":"",o=t.replace(n.prefix,"").replace(n.suffix,""),l=o.split(n.decimal)[0],s="";if(""===l&&(l="0"),a=r(l,i,n),n.precision>0){var c=o.split(n.decimal);c.length>1&&(s=c[1]),a+=n.decimal+s;var u=Number.parseFloat(l+"."+s).toFixed(n.precision).toString().split(n.decimal)[1];a=a.split(n.decimal)[0]+"."+u}return e(a,n)}function r(e,t,n){return e=e.replace(/^0*/g,""),""===(e=e.replace(/\B(?=(\d{3})+(?!\d))/g,n.thousands))&&(e="0"),t+e}$.browser||($.browser={},$.browser.mozilla=/mozilla/.test(navigator.userAgent.toLowerCase())&&!/webkit/.test(navigator.userAgent.toLowerCase()),$.browser.webkit=/webkit/.test(navigator.userAgent.toLowerCase()),$.browser.opera=/opera/.test(navigator.userAgent.toLowerCase()),$.browser.msie=/msie/.test(navigator.userAgent.toLowerCase()),$.browser.device=/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase()));var i={prefix:"",suffix:"",affixesStay:!0,thousands:",",decimal:".",precision:2,allowZero:!1,allowNegative:!1,doubleClickSelection:!0,allowEmpty:!1,bringCaretAtEndOnFocus:!0},o={destroy:function(){return $(this).unbind(".maskMoney"),$.browser.msie&&(this.onpaste=null),this},applyMask:function(e){return t(e,$(this).data("settings"))},mask:function(e){return this.each(function(){var t=$(this);return"number"==typeof e&&t.val(e),t.trigger("mask")})},unmasked:function(){return this.map(function(){var e,t=$(this).val()||"0",n=-1!==t.indexOf("-");return $(t.split(/\D/).reverse()).each(function(t,n){if(n)return e=n,!1}),t=t.replace(/\D/g,""),t=t.replace(new RegExp(e+"$"),"."+e),n&&(t="-"+t),parseFloat(t)})},unmaskedWithOptions:function(){return this.map(function(){var e=$(this).val()||"0",t=$(this).data("settings")||i,n=new RegExp(t.thousandsForUnmasked||t.thousands,"g");return e=e.replace(n,""),parseFloat(e)})},init:function(n){return n=$.extend($.extend({},i),n),this.each(function(){function a(){var e,t,n,a,r,i=x.get(0),o=0,l=0;return"number"==typeof i.selectionStart&&"number"==typeof i.selectionEnd?(o=i.selectionStart,l=i.selectionEnd):(t=document.selection.createRange())&&t.parentElement()===i&&(a=i.value.length,e=i.value.replace(/\r\n/g,"\n"),(n=i.createTextRange()).moveToBookmark(t.getBookmark()),(r=i.createTextRange()).collapse(!1),n.compareEndPoints("StartToEnd",r)>-1?o=l=a:(o=-n.moveStart("character",-a),o+=e.slice(0,o).split("\n").length-1,n.compareEndPoints("EndToEnd",r)>-1?l=a:(l=-n.moveEnd("character",-a),l+=e.slice(0,l).split("\n").length-1))),{start:o,end:l}}function r(){var e=!(x.val().length>=x.attr("maxlength")&&x.attr("maxlength")>=0),t=a(),n=t.start,r=t.end,i=!(t.start===t.end||!x.val().substring(n,r).match(/\d/)),o="0"===x.val().substring(0,1);return e||i||o}function i(e){w.formatOnBlur||x.each(function(t,n){if(n.setSelectionRange)n.focus(),n.setSelectionRange(e,e);else if(n.createTextRange){var a=n.createTextRange();a.collapse(!0),a.moveEnd("character",e),a.moveStart("character",e),a.select()}})}function o(e){var n,a=x.val().length;x.val(t(x.val(),w)),n=x.val().length,w.reverse||(e-=a-n),i(e)}function l(){var e=x.val();if(!w.allowEmpty||""!==e){var n=e.indexOf(w.decimal);if(w.precision>0)if(n<0)e+=w.decimal+new Array(w.precision+1).join(0);else{var a=e.slice(0,n),r=e.slice(n+1);e=a+w.decimal+r+new Array(w.precision+1-r.length).join(0)}else n>0&&(e=e.slice(0,n));x.val(t(e,w))}}function s(){var e=x.val();return w.allowNegative?""!==e&&"-"===e.charAt(0)?e.replace("-",""):"-"+e:e}function c(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function u(e){var t=(e=e||window.event).which||e.charCode||e.keyCode,n=w.decimal.charCodeAt(0);return void 0!==t&&(!(t<48||t>57)||t===n&&w.reverse?!!r()&&((t!==n||!d())&&(!!w.formatOnBlur||(c(e),p(e),!1))):g(t,e))}function d(){return!v()&&f()}function v(){var e=x.val().length,t=a();return 0===t.start&&t.end===e}function f(){return x.val().indexOf(w.decimal)>-1}function p(e){var t,n,r,i,l=(e=e||window.event).which||e.charCode||e.keyCode,s="";l>=48&&l<=57&&(s=String.fromCharCode(l)),n=(t=a()).start,r=t.end,i=x.val(),x.val(i.substring(0,n)+s+i.substring(r,i.length)),o(n+1)}function g(e,t){return 45===e?(x.val(s()),!1):43===e?(x.val(x.val().replace("-","")),!1):13===e||9===e||(!(!$.browser.mozilla||37!==e&&39!==e||0!==t.charCode)||(c(t),!0))}function m(){setTimeout(function(){l()},0)}function h(){return(parseFloat("0")/Math.pow(10,w.precision)).toFixed(w.precision).replace(new RegExp("\\.","g"),w.decimal)}var w,b,x=$(this);w=$.extend({},n),w=$.extend(w,x.data()),x.data("settings",w),$.browser.device&&x.attr("type","tel"),x.unbind(".maskMoney"),x.bind("keypress.maskMoney",u),x.bind("keydown.maskMoney",function(e){var t,n,r,i,l,s=(e=e||window.event).which||e.charCode||e.keyCode;return void 0!==s&&(t=a(),n=t.start,r=t.end,8!==s&&46!==s&&63272!==s||(c(e),i=x.val(),n===r&&(8===s?""===w.suffix?n-=1:(l=i.split("").reverse().join("").search(/\d/),r=1+(n=i.length-l-1)):r+=1),x.val(i.substring(0,n)+i.substring(r,i.length)),o(n),!1))}),x.bind("blur.maskMoney",function(t){if($.browser.msie&&u(t),w.formatOnBlur&&x.val()!==b&&p(t),""===x.val()&&w.allowEmpty)x.val("");else if(""===x.val()||x.val()===e(h(),w))w.allowZero?w.affixesStay?x.val(e(h(),w)):x.val(h()):x.val("");else if(!w.affixesStay){var n=x.val().replace(w.prefix,"").replace(w.suffix,"");x.val(n)}x.val()!==b&&x.change()}),x.bind("focus.maskMoney",function(){b=x.val(),l();var e,t=x.get(0);w.selectAllOnFocus?t.select():t.createTextRange&&w.bringCaretAtEndOnFocus&&((e=t.createTextRange()).collapse(!1),e.select())}),x.bind("click.maskMoney",function(){var e,t=x.get(0);w.selectAllOnFocus||(t.setSelectionRange&&w.bringCaretAtEndOnFocus?(e=x.val().length,t.setSelectionRange(e,e)):x.val(x.val()))}),x.bind("dblclick.maskMoney",function(){var e,t,n=x.get(0);n.setSelectionRange&&w.bringCaretAtEndOnFocus?(t=x.val().length,e=w.doubleClickSelection?0:t,n.setSelectionRange(e,t)):x.val(x.val())}),x.bind("cut.maskMoney",m),x.bind("paste.maskMoney",m),x.bind("mask.maskMoney",l)})}};$.fn.maskMoney=function(e){return o[e]?o[e].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof e&&e?void $.error("Method "+e+" does not exist on jQuery.maskMoney"):o.init.apply(this,arguments)}}(window.jQuery||window.Zepto); \ No newline at end of file From 3c06fdf8c32cd585aff35f1fa54dd30c6e4a3584 Mon Sep 17 00:00:00 2001 From: gaetani Date: Mon, 4 Sep 2017 22:20:59 -0300 Subject: [PATCH 38/40] Merge remote-tracking branch 'upstream/master' # Conflicts: # src/jquery.maskMoney.js --- src/jquery.maskMoney.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/jquery.maskMoney.js b/src/jquery.maskMoney.js index 2c6501c..a1a7fd9 100644 --- a/src/jquery.maskMoney.js +++ b/src/jquery.maskMoney.js @@ -202,15 +202,13 @@ return; } var isNumber = !isNaN(value); - if (settings.precision > 0 && ((isNumber && value.indexOf(".") < 0) ||( !isNumber && value.indexOf(settings.decimal) < 0))) { - value += settings.decimal + new Array(settings.precision + 1).join(0); - var decimalPointIndex = value.indexOf(settings.decimal); + var decimalPointIndex = isNumber? value.indexOf("."): value.indexOf(settings.decimal); if (settings.precision > 0) { if(decimalPointIndex < 0){ value += settings.decimal + new Array(settings.precision + 1).join(0); } else { - // If the following decimal part dosen't have enough length against the precision, it needs to be filled with zeros. + // If the following decimal part dosen"t have enough length against the precision, it needs to be filled with zeros. var integerPart = value.slice(0, decimalPointIndex), decimalPart = value.slice(decimalPointIndex + 1); value = integerPart + settings.decimal + decimalPart + From 6a898e8f1251072a7da1450bfdb78c5f9e3e4690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rog=C3=A9rio=20Morais?= Date: Wed, 4 Aug 2021 19:20:56 -0300 Subject: [PATCH 39/40] bug highlight text Bug fix that happens when the user selects and highlight the input text and starts editing, usage causes a zero to be inserted after the first wrongly typed character. --- .vs/ProjectSettings.json | 3 +++ .vs/VSWorkspaceState.json | 8 ++++++++ .vs/jquery-maskmoney/v16/.suo | Bin 0 -> 19456 bytes .vs/slnx.sqlite | Bin 0 -> 90112 bytes src/jquery.maskMoney.js | 2 +- 5 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .vs/ProjectSettings.json create mode 100644 .vs/VSWorkspaceState.json create mode 100644 .vs/jquery-maskmoney/v16/.suo create mode 100644 .vs/slnx.sqlite diff --git a/.vs/ProjectSettings.json b/.vs/ProjectSettings.json new file mode 100644 index 0000000..f8b4888 --- /dev/null +++ b/.vs/ProjectSettings.json @@ -0,0 +1,3 @@ +{ + "CurrentProjectSetting": null +} \ No newline at end of file diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json new file mode 100644 index 0000000..1567487 --- /dev/null +++ b/.vs/VSWorkspaceState.json @@ -0,0 +1,8 @@ +{ + "ExpandedNodes": [ + "", + "\\src" + ], + "SelectedNode": "\\src\\jquery.maskMoney.js", + "PreviewInSolutionExplorer": false +} \ No newline at end of file diff --git a/.vs/jquery-maskmoney/v16/.suo b/.vs/jquery-maskmoney/v16/.suo new file mode 100644 index 0000000000000000000000000000000000000000..2cd71810d78a109f31fb05649973fdd97cc66388 GIT binary patch literal 19456 zcmeHPO>i7X6(0E~{)x$-gCQZnTG)vbq}g5lSh6e$%aUywdn3s!$qJTZk7j43k!E++ zGqbkWKM*HeLKQ_7se)sQi*ul$$_F@bq9}?3Wr(Rt!HFW=C|@X!RFRnPo0(qCu4dPx zl^sX2p6bnX_jLE`*ZunS>({-y^Wn1}|LoR_|CFkrU)m^rdT*QbL?FE>5SE^iq)mu# z0DgM!-aUTecLdjA74^U=$;6){#iS!r9&bx3aVR6hE@^Xl%qa`?;N!o1@Z0O}{;g>n zG9B9O<|5KgL)RBBhux1RV?|o3lbRY?j;#Q626Z#h_4GHQW0Dmk`DUBSt*UU z0@U2LB>jA~UVEesO(Qm6RSQRJz$te6yDGJVe-zt+zEUh_(k9@Ap7IXz!!io0>1)$3HVju*MMIK z?g5h47yLKFPY1$`ufxObfzNXOzjf}t^89y&31j^z=KnjOyFUNX2>>BoLJu?}jdPvp zoAKs+=lo}!^Pg`q{~3Nz^PhBx-|%U$?sa(hJy7B(F1IWgvx2ac^67s>?J0_tj} zQBQLYaUGz12>s7*LjQ}h!FN#q$54(kMVaHcb3ND#4Ca5;kAD;I7GNt-2F8I2AlGNE zk?p_^U?*@tunX7?JOJzg9t8FR`+)txZvhVh2Y`oxgTNu+5#UkaG2k%pIPlxR6Tp+e z6!3N62yhfQ20R5!1IK|Az)9d~;1uu;;CFy$fYZRUz&C+G9%lk^4dE<2dNrpnDS5mkp~cEzO}t7DB3PnK5rYp#4L+rR@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8!42g-W{K z{c(>f$hp7$;X4d?4~^&N?)baEWMNo8gh4&rnjY^-;O{E@ab5eh?qsW`bttXLWG2z7 zXl)t}w3UQ<Ad$^x)%NT3M3Tp40);2&f80UO%jFv98DpMzjlOJK9@h(a6!n6Cp0Vh1 zOzw~Db4;{nJF{I`@YI=5+Lg_0PG1e`<2c(1CoQLo=26@a7{d7sYuMe(ylMX&h+p~_ z&Ye4qa~B+K9Mv@=(?mA6KPgRpxE+DUVb79ZFxe7)K$Msyq=V0Tz<U_;E6`qI4;$1K zVV82fE4SXgyX*?+MZa|IX|!uTEpeCfv%Fv&Wj;_09t1Rce*>qAj%GD}|6{e^9~p$^ z=GA`N^_yzYrQQwLrN1-_A0__&Wj8);0aA^H=c-H%p8rp|9$v$}^}zqWK))?7zel|T z#rtQZE1;56cq~Z2`u^Ez(C2RtdGa3R02}vDDh|!VDORSch>G+7YWm^#-zv)oW4Qm- z#5+*S;a@@iVZV|ac)tx~pAgsK@#+EI!duPv|5m&H^{3$@d+}6^I_P2i!02&U|M@#Q z?jJY6_NQJS?3u=Wpn1(PZT~K6EAPnW+&i-6+p@BMeRke9^HFcfCd8#&UcszOrp7(k HP(uF)qHki; literal 0 HcmV?d00001 diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..c5621389bc2508fcde95b921736205754383fa4d GIT binary patch literal 90112 zcmeI53v3(7d4P9CiqwPTP?BZZmTj%=yV|V1GT)Cg3`C}An`c>)^{`{uth(GC%Csd? zN3MLQ<bp)L#BFoI0cp}AL4e$)X^<e776sC@Xo@C>B1O<PMUV#&Bx#zW*8&OJ^w0)r zlU@q+pM8+KOY)@HIiJ(~3wy+!`Df;zZ~mE`$37M=O;=PZlxy`hNfqK;kmGsoO@hF2 zTtEEZ4gbw!1b(>96Zp$pes}xX&x!y0L@yI2uQHio@~ZC>zTn`6f#>?4?fbUZ<+<c~ zZ_iJ9=6fFRmIV6$Vi52UkEZC>BLQ#dipXzW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xjhU{PJynu;>4I@+y4)?}1PD zF+(JP1dsp{Kmter2_OL^fCP{L5<mh-;PofKzW?Xb=l?(D$WLGY3^4~JfCP{L5<mh- z00|%gB!C2v01`j~NZ`Q}aJjgCcK^RC@B&934}2f~;DH2?01`j~NB{{S0VIF~kN^@u z0!ZKuA#l#cUU9c{8Z!6wB$K6dT24g8Y&sbg6Y;n#W|d@FOwvp=S&k-S$yBV{>+Y6& zjD$|#XF}aF*oyN5Ox06c$(?3VXuunxq>WW|L6z$2#yUKAc9Y8LTiIh=huO;p4nGEe zYYG**Whxw7m*iX03WXQ_)vDpc+QUhQRd_UsMOF0F5Bmq+)-3_H|L-EN!2SQ^NAL#^ pB!C2v01`j~NB{{S0VIF~kN^@u0!ZK&pFppR=Y1~C?a}W4|34)j7l{A> literal 0 HcmV?d00001 diff --git a/src/jquery.maskMoney.js b/src/jquery.maskMoney.js index 7421b71..ae86d9a 100644 --- a/src/jquery.maskMoney.js +++ b/src/jquery.maskMoney.js @@ -529,7 +529,7 @@ if (settings.precision > 0) { if(!isNaN(value) && value.indexOf(".")){ var precision = value.substr(value.indexOf(".") + 1); - onlyNumbers += new Array((settings.precision + 1) - precision.length).join(0); + onlyNumbers = new Array((settings.precision + 1) - precision.length).join(0) + onlyNumbers; integerPart = onlyNumbers.slice(0, onlyNumbers.length - settings.precision); newValue = buildIntegerPart(integerPart, negative, settings); } From 65aa312260b261dd112bb249c6a9509a123a95df Mon Sep 17 00:00:00 2001 From: Jerry Cheung <jollyjerry@gmail.com> Date: Sat, 2 Nov 2024 13:13:30 -0700 Subject: [PATCH 40/40] README: fix broken link to examples --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 052772a..3a615ea 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ You can also use [CloudFlare's cdnjs](http://cdnjs.com/). Just choose the versio *** ### Show Time! -To view a complete demonstration of it's features and usage, access our [examples page](http://plentz.github.com/jquery-maskmoney)! +To view a complete demonstration of it's features and usage, access our [examples page](https://plentz.github.io/jquery-maskmoney/)! *** ### Usage: