* Handler for 'drop' event * * @param {DragEvent} e
(e)
| 7738 | * @param {DragEvent} e |
| 7739 | */ |
| 7740 | _onDrop(e) { |
| 7741 | if (this.formulaMode) { // Dropping while in formula mode shouldn't be possible. This is done 'just in case' |
| 7742 | return; |
| 7743 | } |
| 7744 | |
| 7745 | // Note: by default browsers already prevent the drop on readOnly and disabled elements |
| 7746 | this.isDropEvent = true; |
| 7747 | e.preventDefault(); |
| 7748 | |
| 7749 | const droppedText = e.dataTransfer.getData('text/plain'); |
| 7750 | const cleanedValue = this.unformatOther(droppedText); |
| 7751 | const previousValue = this.rawValue; |
| 7752 | this.set(cleanedValue); |
| 7753 | this.isDropEvent = false; |
| 7754 | |
| 7755 | // Test if a change event must be sent (if the dropped value is different from before) |
| 7756 | const newValue = this.constructor._toNumericValue(cleanedValue, this.settings); |
| 7757 | if (!isNaN(Number(newValue))) { |
| 7758 | if (AutoNumericHelper.trimPaddedZerosFromDecimalPlaces(previousValue) !== AutoNumericHelper.trimPaddedZerosFromDecimalPlaces(newValue)) { |
| 7759 | this._triggerEvent(AutoNumeric.events.native.change, this.domElement); |
| 7760 | } |
| 7761 | } |
| 7762 | } |
| 7763 | |
| 7764 | /** |
| 7765 | * Handler for 'submit' events happening on the parent <form> element. |
no test coverage detected