MCPcopy
hub / github.com/autoNumeric/autoNumeric / selectDecimal

Method selectDecimal

src/AutoNumeric.js:2793–2818  ·  view source on GitHub ↗

* Select only the decimal part in the formatted element content, whatever the value of `selectNumberOnly` * Multiple cases are possible : * +1.234,57suffixText * * € +1.234,57suffixText * +€ 1.234,57suffixText * € 1.234,57+suffixText * * 1.234,57+ €suffixText

()

Source from the content-addressed store, hash-verified

2791 * @returns {AutoNumeric}
2792 */
2793 selectDecimal() {
2794 let start = AutoNumericHelper.getElementValue(this.domElement).indexOf(this.settings.decimalCharacter);
2795 let end;
2796
2797 if (start === -1) {
2798 // The decimal character has not been found, we deselect all
2799 start = 0;
2800 end = 0;
2801 } else {
2802 // A decimal character has been found
2803 start = start + 1; // We add 1 to exclude the decimal character from the selection
2804
2805 let decimalCount;
2806 if (this.isFocused) {
2807 decimalCount = this.settings.decimalPlacesShownOnFocus;
2808 } else {
2809 decimalCount = this.settings.decimalPlacesShownOnBlur;
2810 }
2811
2812 end = start + Number(decimalCount);
2813 }
2814
2815 AutoNumericHelper.setElementSelection(this.domElement, start, end);
2816
2817 return this;
2818 }
2819
2820 /**
2821 * Return the DOM element reference of the autoNumeric-managed element

Callers 2

Calls 2

getElementValueMethod · 0.80
setElementSelectionMethod · 0.80

Tested by

no test coverage detected