|
Apache/2.4.41 (Ubuntu) Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) server ip : 62.171.164.128 | your ip : 127.0.0.1 safemode OFF > / home / a / home / dev2.destoffenstraat.com / lib / web / mage / |
Filename | /home/a/home/dev2.destoffenstraat.com/lib/web/mage/trim-input.js |
Size | 1.81 kb |
Permission | rw-r--r-- |
Owner | root : root |
Create time | 21-Aug-2025 12:26 |
Last modified | 28-Jan-2025 06:45 |
Last accessed | 22-Aug-2025 11:56 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
/**
* 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 () {
// Safari caret position workaround: storing carter position
var caretStart, caretEnd, input;
caretStart = this.options.cache.input.get(0).selectionStart;
caretEnd = this.options.cache.input.get(0).selectionEnd;
input = this._getInputValue().trim();
this.options.cache.input.val(input);
// Safari caret position workaround: setting caret position to previously stored values
if (caretStart !== null && caretEnd !== null) {
this.options.cache.input.get(0).setSelectionRange(caretStart, caretEnd);
}
},
/**
* Get input value
* @returns {*}
* @private
*/
_getInputValue: function () {
return this.options.cache.input.val();
}
});
return $.mage.trimInput;
});
* 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 () {
// Safari caret position workaround: storing carter position
var caretStart, caretEnd, input;
caretStart = this.options.cache.input.get(0).selectionStart;
caretEnd = this.options.cache.input.get(0).selectionEnd;
input = this._getInputValue().trim();
this.options.cache.input.val(input);
// Safari caret position workaround: setting caret position to previously stored values
if (caretStart !== null && caretEnd !== null) {
this.options.cache.input.get(0).setSelectionRange(caretStart, caretEnd);
}
},
/**
* Get input value
* @returns {*}
* @private
*/
_getInputValue: function () {
return this.options.cache.input.val();
}
});
return $.mage.trimInput;
});