MCPcopy
hub / github.com/autoNumeric/autoNumeric / _getSignPosition

Method _getSignPosition

src/AutoNumeric.js:8909–8930  ·  view source on GitHub ↗

* Helper function for `_expandSelectionOnSign()`. * * @returns {[number, number]} Array containing [signPosition, currencySymbolPosition] of a formatted value * @private

()

Source from the content-addressed store, hash-verified

8907 * @private
8908 */
8909 _getSignPosition() {
8910 let result;
8911 if (this.settings.currencySymbol) {
8912 const currencySymbolLen = this.settings.currencySymbol.length;
8913 const value = AutoNumericHelper.getElementValue(this.domElement);
8914 if (this.settings.currencySymbolPlacement === AutoNumeric.options.currencySymbolPlacement.prefix) {
8915 const hasNeg = this.settings.negativeSignCharacter && value && value.charAt(0) === this.settings.negativeSignCharacter;
8916 if (hasNeg) {
8917 result = [1, currencySymbolLen + 1];
8918 } else {
8919 result = [0, currencySymbolLen];
8920 }
8921 } else {
8922 const valueLen = value.length;
8923 result = [valueLen - currencySymbolLen, valueLen];
8924 }
8925 } else {
8926 result = [1000, -1];
8927 }
8928
8929 return result;
8930 }
8931
8932 /**
8933 * Expands selection to cover whole sign

Callers 1

Calls 1

getElementValueMethod · 0.80

Tested by

no test coverage detected