MCPcopy
hub / github.com/autoNumeric/autoNumeric / _onFocusIn

Method _onFocusIn

src/AutoNumeric.js:6432–6443  ·  view source on GitHub ↗

* Handler for the 'focusin' event. * This is called before the 'focus' event, and is necessary to change the selection on focus under Firefox for instance. * * @param {Event} e * @private

(e)

Source from the content-addressed store, hash-verified

6430 * @private
6431 */
6432 _onFocusIn(e) {
6433 if (this.settings.selectOnFocus) {
6434 // The whole input content is selected on focus (following the `selectOnFocus` and `selectNumberOnly` options)
6435 //XXX Firefox <47 does not respect this selection...Oh well.
6436 this.select();
6437 } else {
6438 // Or we decide where to put the caret using the `caretPositionOnFocus` option
6439 if (!AutoNumericHelper.isNull(this.settings.caretPositionOnFocus)) {
6440 AutoNumericHelper.setElementSelection(e.target, this._initialCaretPosition(AutoNumericHelper.getElementValue(this.domElement)));
6441 }
6442 }
6443 }
6444
6445 /**
6446 * Enter the special 'formula mode' where users can enter a math expression that will be evaluated on blur and `enter`

Callers 1

_createEventListenersMethod · 0.95

Calls 5

selectMethod · 0.95
_initialCaretPositionMethod · 0.95
isNullMethod · 0.80
setElementSelectionMethod · 0.80
getElementValueMethod · 0.80

Tested by

no test coverage detected