-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve trim email address in customer account login page
- Loading branch information
1 parent
bedf5c1
commit 96af9cf
Showing
3 changed files
with
61 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 0 additions & 65 deletions
65
app/code/Magento/Customer/view/frontend/web/js/trim-username.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
define([ | ||
'jquery' | ||
], function ($) { | ||
'use strict'; | ||
|
||
$.widget('mage.trimInput', { | ||
options: { | ||
cache: {} | ||
}, | ||
|
||
/** | ||
* Widget initialization | ||
* @private | ||
*/ | ||
_create: function () { | ||
this.options.cache.input = $(this.element); | ||
this._bind(); | ||
}, | ||
|
||
/** | ||
* Event binding, will monitor change, keyup and paste events. | ||
* @private | ||
*/ | ||
_bind: function () { | ||
if (this.options.cache.input.length) { | ||
this._on(this.options.cache.input, { | ||
'change': this._trimInput, | ||
'keyup': this._trimInput, | ||
'paste': this._trimInput | ||
}); | ||
} | ||
}, | ||
|
||
/** | ||
* Trim value | ||
* @private | ||
*/ | ||
_trimInput: function () { | ||
var input = this._getInputValue().trim(); | ||
|
||
this.options.cache.input.val(input); | ||
}, | ||
|
||
/** | ||
* Get input value | ||
* @returns {*} | ||
* @private | ||
*/ | ||
_getInputValue: function () { | ||
return this.options.cache.input.val(); | ||
} | ||
}); | ||
|
||
return $.mage.trimInput; | ||
}); |