Skip to content

Commit

Permalink
[Issue-84] Code patch and regenerate assets
Browse files Browse the repository at this point in the history
  • Loading branch information
nosir committed Aug 26, 2016
1 parent 996c65e commit 02651c1
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 39 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"form",
"input"
],
"version": "0.6.12",
"version": "0.6.14",
"author": {
"name": "Max Huang",
"email": "[email protected]",
Expand Down
17 changes: 9 additions & 8 deletions dist/cleave-angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,21 +246,22 @@ Cleave.prototype = {
},

getRawValue: function () {
var owner = this,
var owner = this,
pps = owner.properties,
Util = Cleave.Util,
inputValue = owner.element.value,
rawValueTrimPrefix = owner.properties.rawValueTrimPrefix;
rawValue = owner.element.value;

if (rawValueTrimPrefix) {
inputValue = Util.getPrefixStrippedValue(inputValue, pps.prefix, pps.prefixLength);
if (pps.rawValueTrimPrefix) {
rawValue = Util.getPrefixStrippedValue(rawValue, pps.prefix, pps.prefixLength);
}

if (pps.numeral) {
return pps.numeralFormatter.getRawValue(inputValue);
rawValue = pps.numeralFormatter.getRawValue(rawValue);
} else {
rawValue = Util.stripDelimiters(rawValue, pps.delimiter, pps.delimiters);
}

return Cleave.Util.stripDelimiters(inputValue, pps.delimiter, pps.delimiters);
return rawValue;
},

getFormattedValue: function () {
Expand Down Expand Up @@ -440,6 +441,7 @@ var DefaultProperties = {

target.prefix = (target.creditCard || target.phone || target.date) ? '' : (opts.prefix || '');
target.prefixLength = target.prefix.length;
target.rawValueTrimPrefix = !!opts.rawValueTrimPrefix;

target.initValue = opts.initValue || '';

Expand All @@ -458,7 +460,6 @@ var DefaultProperties = {

target.backspace = false;
target.result = '';
target.rawValueTrimPrefix = opts.rawValueTrimPrefix || false;

return target;
}
Expand Down
4 changes: 2 additions & 2 deletions dist/cleave-angular.min.js

Large diffs are not rendered by default.

16 changes: 12 additions & 4 deletions dist/cleave-react.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,24 @@ return /******/ (function(modules) { // webpackBootstrap

onChange: function onChange(event) {
var owner = this,
pps = owner.properties;
pps = owner.properties,
rawValue;

owner.onInput(event.target.value);

rawValue = pps.result;

if (pps.rawValueTrimPrefix) {
rawValue = Util.getPrefixStrippedValue(rawValue, pps.prefix, pps.prefixLength);
}

if (pps.numeral) {
event.target.rawValue = pps.numeralFormatter.getRawValue(pps.result);
rawValue = pps.numeralFormatter.getRawValue(rawValue);
} else {
event.target.rawValue = Util.stripDelimiters(pps.result, pps.delimiter, pps.delimiters);
rawValue = Util.stripDelimiters(rawValue, pps.delimiter, pps.delimiters);
}

event.target.rawValue = rawValue;
event.target.value = pps.result;

owner.registeredEvents.onChange(event);
Expand Down Expand Up @@ -893,6 +901,7 @@ return /******/ (function(modules) { // webpackBootstrap

target.prefix = target.creditCard || target.phone || target.date ? '' : opts.prefix || '';
target.prefixLength = target.prefix.length;
target.rawValueTrimPrefix = !!opts.rawValueTrimPrefix;

target.initValue = opts.initValue || '';

Expand All @@ -906,7 +915,6 @@ return /******/ (function(modules) { // webpackBootstrap

target.backspace = false;
target.result = '';
target.rawValueTrimPrefix = opts.rawValueTrimPrefix || false;

return target;
}
Expand Down
4 changes: 2 additions & 2 deletions dist/cleave-react.min.js

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions dist/cleave.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,21 +246,22 @@ Cleave.prototype = {
},

getRawValue: function () {
var owner = this,
var owner = this,
pps = owner.properties,
Util = Cleave.Util,
inputValue = owner.element.value,
rawValueTrimPrefix = owner.properties.rawValueTrimPrefix;
rawValue = owner.element.value;

if (rawValueTrimPrefix) {
inputValue = Util.getPrefixStrippedValue(inputValue, pps.prefix, pps.prefixLength);
if (pps.rawValueTrimPrefix) {
rawValue = Util.getPrefixStrippedValue(rawValue, pps.prefix, pps.prefixLength);
}

if (pps.numeral) {
return pps.numeralFormatter.getRawValue(inputValue);
rawValue = pps.numeralFormatter.getRawValue(rawValue);
} else {
rawValue = Util.stripDelimiters(rawValue, pps.delimiter, pps.delimiters);
}

return Cleave.Util.stripDelimiters(inputValue, pps.delimiter, pps.delimiters);
return rawValue;
},

getFormattedValue: function () {
Expand Down Expand Up @@ -440,6 +441,7 @@ var DefaultProperties = {

target.prefix = (target.creditCard || target.phone || target.date) ? '' : (opts.prefix || '');
target.prefixLength = target.prefix.length;
target.rawValueTrimPrefix = !!opts.rawValueTrimPrefix;

target.initValue = opts.initValue || '';

Expand All @@ -458,7 +460,6 @@ var DefaultProperties = {

target.backspace = false;
target.result = '';
target.rawValueTrimPrefix = opts.rawValueTrimPrefix || false;

return target;
}
Expand Down
4 changes: 2 additions & 2 deletions dist/cleave.min.js

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions doc/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- [delimiter](#delimiter)
- [delimiters](#delimiters)
- [prefix](#prefix)
- [rawValueTrimPrefix](#rawvaluetrimprefix)
- [numericOnly](#numericonly)
- [uppercase](#uppercase)
- [lowercase](#lowercase)
Expand Down Expand Up @@ -288,6 +289,25 @@ new Cleave('.my-input', {
// 253874 XXX XXX
```

### `rawValueTrimPrefix`

A `Boolean` value indicates if to trim prefix in calling `getRawValue()` or getting `rawValue` in AngularJS or ReactJS component.

**Default value**: `false`

```js
new Cleave('.my-input', {
numeral: true,
prefix: '$',
rawValueTrimPrefix: true
});
```

```js
// formatted value: $123,456.78
// raw value: 123456.78
```

### `numericOnly`

A `Boolean` value indicates if it only allows numeric letters (0-9).
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"form",
"input"
],
"version": "0.6.12",
"version": "0.6.14",
"author": {
"name": "Max Huang",
"url": "http://github.com/nosir",
Expand Down
15 changes: 8 additions & 7 deletions src/Cleave.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,21 +244,22 @@ Cleave.prototype = {
},

getRawValue: function () {
var owner = this,
var owner = this,
pps = owner.properties,
Util = Cleave.Util,
inputValue = owner.element.value,
rawValueTrimPrefix = owner.properties.rawValueTrimPrefix;
rawValue = owner.element.value;

if (rawValueTrimPrefix) {
inputValue = Util.getPrefixStrippedValue(inputValue, pps.prefix, pps.prefixLength);
if (pps.rawValueTrimPrefix) {
rawValue = Util.getPrefixStrippedValue(rawValue, pps.prefix, pps.prefixLength);
}

if (pps.numeral) {
return pps.numeralFormatter.getRawValue(inputValue);
rawValue = pps.numeralFormatter.getRawValue(rawValue);
} else {
rawValue = Util.stripDelimiters(rawValue, pps.delimiter, pps.delimiters);
}

return Cleave.Util.stripDelimiters(inputValue, pps.delimiter, pps.delimiters);
return rawValue;
},

getFormattedValue: function () {
Expand Down
14 changes: 11 additions & 3 deletions src/Cleave.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,24 @@ var Cleave = React.createClass({
},

onChange: function (event) {
var owner = this, pps = owner.properties;
var owner = this, pps = owner.properties,
rawValue;

owner.onInput(event.target.value);

rawValue = pps.result;

if (pps.rawValueTrimPrefix) {
rawValue = Util.getPrefixStrippedValue(rawValue, pps.prefix, pps.prefixLength);
}

if (pps.numeral) {
event.target.rawValue = pps.numeralFormatter.getRawValue(pps.result);
rawValue = pps.numeralFormatter.getRawValue(rawValue);
} else {
event.target.rawValue = Util.stripDelimiters(pps.result, pps.delimiter, pps.delimiters);
rawValue = Util.stripDelimiters(rawValue, pps.delimiter, pps.delimiters);
}

event.target.rawValue = rawValue;
event.target.value = pps.result;

owner.registeredEvents.onChange(event);
Expand Down
2 changes: 1 addition & 1 deletion src/common/DefaultProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ var DefaultProperties = {

target.prefix = (target.creditCard || target.phone || target.date) ? '' : (opts.prefix || '');
target.prefixLength = target.prefix.length;
target.rawValueTrimPrefix = !!opts.rawValueTrimPrefix;

target.initValue = opts.initValue || '';

Expand All @@ -60,7 +61,6 @@ var DefaultProperties = {

target.backspace = false;
target.result = '';
target.rawValueTrimPrefix = opts.rawValueTrimPrefix || false;

return target;
}
Expand Down

0 comments on commit 02651c1

Please sign in to comment.