Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<div class="field email required">
<label class="label" for="email"><span><?= $block->escapeHtml(__('Email')) ?></span></label>
<div class="control">
<input name="login[username]" value="<?= $block->escapeHtmlAttr($block->getUsername()) ?>" <?php if ($block->isAutocompleteDisabled()): ?> autocomplete="off"<?php endif; ?> id="email" type="email" class="input-text" title="<?= $block->escapeHtmlAttr(__('Email')) ?>" data-validate="{required:true, 'validate-email':true}">
<input name="login[username]" value="<?= $block->escapeHtmlAttr($block->getUsername()) ?>" <?php if ($block->isAutocompleteDisabled()): ?> autocomplete="off"<?php endif; ?> id="email" type="email" class="input-text" title="<?= $block->escapeHtmlAttr(__('Email')) ?>" data-mage-init='{"mage/trim-input":{}}' data-validate="{required:true, 'validate-email':true}">
</div>
</div>
<div class="field password required">
Expand All @@ -43,12 +43,3 @@
</div>
</div>

<script type="text/x-magento-init">
{
".field.email": {
"Magento_Customer/js/trim-username": {
"formSelector": "form.form-login"
}
}
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
class="input-text"
data-password-min-length="<?= $block->escapeHtmlAttr($block->getMinimumPasswordLength()) ?>"
data-password-min-character-sets="<?= $block->escapeHtmlAttr($block->getRequiredCharacterClassesNumber()) ?>"
data-mage-init='{"mage/trim-input":{}}'
data-validate="{required:true, 'validate-customer-password':true}"
autocomplete="off">
<div id="password-strength-meter-container" data-role="password-strength-meter" aria-live="polite">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ define([

/** Show login popup window */
showModal: function () {
$(this.modalWindow).modal('openModal');
$(this.modalWindow).modal('openModal').trigger('contentUpdated');
}
};
});
65 changes: 0 additions & 65 deletions app/code/Magento/Customer/view/frontend/web/js/trim-username.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
id="customer-email"
type="email"
class="input-text"
data-mage-init='{"mage/trim-input":{}}'
data-bind="attr: {autocomplete: autocomplete}"
data-validate="{required:true, 'validate-email':true}">
</div>
Expand Down
60 changes: 60 additions & 0 deletions lib/web/mage/trim-input.js
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;
});