From 9efce41ac754b3f5addae2d17a23ced1a9ea2d58 Mon Sep 17 00:00:00 2001 From: Steven French Date: Thu, 2 Feb 2017 11:10:45 +1300 Subject: [PATCH 1/7] bind focused attribute --- money-input.html | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/money-input.html b/money-input.html index 3c879d4..f0d7cc6 100644 --- a/money-input.html +++ b/money-input.html @@ -56,7 +56,8 @@ allowed-pattern="[0-9\.\,\-]" disabled$="[[disabled]]" readonly$="[[readonly]]" - placeholder$="[[placeholder]]"> + placeholder$="[[placeholder]]" + focused="{{focused}}">
[[currency]]
@@ -177,6 +178,12 @@ placeholder: { type: String, value: '' + }, + + /** Boolean value indicating whether the paper-input is focused **/ + focused: { + type: Boolean, + reflectToAttribute: true } }, From 8570a43806f09b6a6b5a657a10d59b1fc858342b Mon Sep 17 00:00:00 2001 From: Steven French Date: Thu, 2 Feb 2017 11:14:10 +1300 Subject: [PATCH 2/7] override focus method to defer to paper-input --- money-input.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/money-input.html b/money-input.html index f0d7cc6..3eb0e19 100644 --- a/money-input.html +++ b/money-input.html @@ -334,6 +334,10 @@ /** Return validation based on required, max and min configs */ validate: function(){ return this.$.input.validate() && this._validate(this.$.input.value); + }, + + focus: function () { + return this.$.input.focus(); } }); From e4eb913f13745b6a71178a9a82f679eb63bbdb01 Mon Sep 17 00:00:00 2001 From: Steven French Date: Sat, 11 Feb 2017 19:23:18 +1300 Subject: [PATCH 3/7] use === to check value change This allows for values of "0" to be set initially --- money-input.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/money-input.html b/money-input.html index 3c879d4..b4ca164 100644 --- a/money-input.html +++ b/money-input.html @@ -217,7 +217,7 @@ }, _valueChange: function() { - if (this._formattedValue != this.value) { + if (this._formattedValue !== this.value) { if(!isNaN(parseFloat(this.value)) && isFinite(this.value)) { var signal = this._getSignal('' + this.value); if((''+this.value).length >= this.precision) { From b959ef87c78eeef192b06e1770fe4efea6616a84 Mon Sep 17 00:00:00 2001 From: Steven French Date: Fri, 24 Feb 2017 15:53:54 +1300 Subject: [PATCH 4/7] add type="tel" to enforce numeric keyboard on ios/android --- money-input.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/money-input.html b/money-input.html index 743328b..38e8ff5 100644 --- a/money-input.html +++ b/money-input.html @@ -57,7 +57,10 @@ disabled$="[[disabled]]" readonly$="[[readonly]]" placeholder$="[[placeholder]]" - focused="{{focused}}"> + focused="{{focused}}" + type="tel" + step="any" + >
[[currency]]
From 537d32f102c0edd26137dcc9307408cb8bac8459 Mon Sep 17 00:00:00 2001 From: Steven French Date: Wed, 24 May 2017 16:50:24 +1200 Subject: [PATCH 5/7] add content selct="[suffix]" --- money-input.html | 1 + 1 file changed, 1 insertion(+) diff --git a/money-input.html b/money-input.html index 38e8ff5..a277200 100644 --- a/money-input.html +++ b/money-input.html @@ -62,6 +62,7 @@ step="any" >
[[currency]]
+ From 54ee5ffcef05b5e9c048a3e6d2d74317dfd9b830 Mon Sep 17 00:00:00 2001 From: Steven French Date: Wed, 31 May 2017 10:03:43 +1200 Subject: [PATCH 6/7] parse min/max value as currency string in errorMessage --- money-input.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/money-input.html b/money-input.html index a277200..e640f1b 100644 --- a/money-input.html +++ b/money-input.html @@ -322,11 +322,11 @@ if(n > this.maxValue){ this.$.input.invalid = true; - this.$.input.errorMessage = this.maxValueErrorMessage + ' ' + this.maxValue; + this.$.input.errorMessage = this.maxValueErrorMessage + ' $' + this._parse(this._removeUI(this.maxValue.toString())); return false; } else if(n < this.minValue){ this.$.input.invalid = true; - this.$.input.errorMessage = this.minValueErrorMessage + ' ' + this.minValue; + this.$.input.errorMessage = this.minValueErrorMessage + ' $' + this._parse(this._removeUI(this.minValue.toString())); return false; } else { this.$.input.invalid = false; From 399f722257198fe4a4e6f1249c311a8cfd7a4851 Mon Sep 17 00:00:00 2001 From: Steven French Date: Wed, 31 May 2017 18:13:41 +1200 Subject: [PATCH 7/7] when min/max value changes and input was invalid: revalidate --- money-input.html | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/money-input.html b/money-input.html index e640f1b..880d76b 100644 --- a/money-input.html +++ b/money-input.html @@ -139,13 +139,15 @@ /** Max value accepted by field */ maxValue: { type: Number, - value: 1000000 + value: 1000000, + observer: 'maxValueChanged' }, /** Min value accepted by field */ minValue: { type: Number, - value: 0 + value: 0, + observer: 'minValueChanged' }, /** Decimal precision -> Use "0" for integer amount */ @@ -335,6 +337,18 @@ } }, + maxValueChanged: function () { + if (this.$.input.invalid || !this._validate(this.$.input.value)) { + this.validate(); + } + }, + + minValueChanged: function () { + if (this.$.input.invalid || !this._validate(this.$.input.value)) { + this.validate(); + } + }, + /** Return validation based on required, max and min configs */ validate: function(){ return this.$.input.validate() && this._validate(this.$.input.value);