|
@@ -3,7 +3,7 @@ Input Mask plugin for jquery
|
|
|
http://github.com/RobinHerbots/jquery.inputmask
|
|
http://github.com/RobinHerbots/jquery.inputmask
|
|
|
Copyright (c) 2010 Robin Herbots
|
|
Copyright (c) 2010 Robin Herbots
|
|
|
Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
|
|
Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
|
|
|
-Version: 0.5.3d
|
|
|
|
|
|
|
+Version: 0.5.4
|
|
|
|
|
|
|
|
This plugin is based on the masked input plugin written by Josh Bush (digitalbush.com)
|
|
This plugin is based on the masked input plugin written by Josh Bush (digitalbush.com)
|
|
|
*/
|
|
*/
|
|
@@ -388,27 +388,29 @@ This plugin is based on the masked input plugin written by Josh Bush (digitalbus
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function clearOptionalTail(input, buffer) {
|
|
function clearOptionalTail(input, buffer) {
|
|
|
- var tmpBuffer = buffer.slice();
|
|
|
|
|
- if ($(input).data('inputmask')['isRTL']) {
|
|
|
|
|
- for (var pos = 0; pos <= tmpBuffer.length - 1; pos++) {
|
|
|
|
|
- var testPos = determineTestPosition(pos);
|
|
|
|
|
- if (tests[testPos].optionality) {
|
|
|
|
|
- if (getPlaceHolder(pos) == buffer[pos] || !isMask(pos))
|
|
|
|
|
- tmpBuffer.splice(0, 1);
|
|
|
|
|
- else break;
|
|
|
|
|
- } else break;
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- for (var pos = tmpBuffer.length - 1; pos >= 0; pos--) {
|
|
|
|
|
- var testPos = determineTestPosition(pos);
|
|
|
|
|
- if (tests[testPos].optionality) {
|
|
|
|
|
- if (getPlaceHolder(pos) == buffer[pos] || !isMask(pos))
|
|
|
|
|
- tmpBuffer.pop();
|
|
|
|
|
- else break;
|
|
|
|
|
- } else break;
|
|
|
|
|
|
|
+ setTimeout(function() {
|
|
|
|
|
+ var tmpBuffer = buffer.slice();
|
|
|
|
|
+ if ($(input).data('inputmask')['isRTL']) {
|
|
|
|
|
+ for (var pos = 0; pos <= tmpBuffer.length - 1; pos++) {
|
|
|
|
|
+ var testPos = determineTestPosition(pos);
|
|
|
|
|
+ if (tests[testPos].optionality) {
|
|
|
|
|
+ if (getPlaceHolder(pos) == buffer[pos] || !isMask(pos))
|
|
|
|
|
+ tmpBuffer.splice(0, 1);
|
|
|
|
|
+ else break;
|
|
|
|
|
+ } else break;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ for (var pos = tmpBuffer.length - 1; pos >= 0; pos--) {
|
|
|
|
|
+ var testPos = determineTestPosition(pos);
|
|
|
|
|
+ if (tests[testPos].optionality) {
|
|
|
|
|
+ if (getPlaceHolder(pos) == buffer[pos] || !isMask(pos))
|
|
|
|
|
+ tmpBuffer.pop();
|
|
|
|
|
+ else break;
|
|
|
|
|
+ } else break;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- writeBuffer(input, tmpBuffer);
|
|
|
|
|
|
|
+ writeBuffer(input, tmpBuffer);
|
|
|
|
|
+ }, 0);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//functionality fn
|
|
//functionality fn
|
|
@@ -512,7 +514,9 @@ This plugin is based on the masked input plugin written by Josh Bush (digitalbus
|
|
|
var $input = $(this), input = this, nptValue = input._valueGet();
|
|
var $input = $(this), input = this, nptValue = input._valueGet();
|
|
|
$input.removeClass('focus.inputmask');
|
|
$input.removeClass('focus.inputmask');
|
|
|
if (nptValue != undoBuffer) {
|
|
if (nptValue != undoBuffer) {
|
|
|
- $input.change();
|
|
|
|
|
|
|
+ setTimeout(function() { //move the change event to later, ...
|
|
|
|
|
+ $input.change();
|
|
|
|
|
+ }, 0);
|
|
|
}
|
|
}
|
|
|
if (opts.clearMaskOnLostFocus) {
|
|
if (opts.clearMaskOnLostFocus) {
|
|
|
if (nptValue == _buffer.join(''))
|
|
if (nptValue == _buffer.join(''))
|
|
@@ -576,6 +580,7 @@ This plugin is based on the masked input plugin written by Josh Bush (digitalbus
|
|
|
buffer = _buffer.slice();
|
|
buffer = _buffer.slice();
|
|
|
writeBuffer(input, buffer);
|
|
writeBuffer(input, buffer);
|
|
|
if (!isRTL) caret(input, 0);
|
|
if (!isRTL) caret(input, 0);
|
|
|
|
|
+ undoBuffer = input._valueGet();
|
|
|
}
|
|
}
|
|
|
}).bind(pasteEventName, function() {
|
|
}).bind(pasteEventName, function() {
|
|
|
var input = this;
|
|
var input = this;
|
|
@@ -616,7 +621,7 @@ This plugin is based on the masked input plugin written by Josh Bush (digitalbus
|
|
|
Object.defineProperty(npt, "value", {
|
|
Object.defineProperty(npt, "value", {
|
|
|
get: function() {
|
|
get: function() {
|
|
|
var $self = $(this), inputData = $(this).data('inputmask');
|
|
var $self = $(this), inputData = $(this).data('inputmask');
|
|
|
- return inputData && inputData['autoUnmask'] ? $self.inputmask('unmaskedvalue') : this._valueGet();
|
|
|
|
|
|
|
+ return inputData && inputData['autoUnmask'] ? $self.inputmask('unmaskedvalue') : this._valueGet() != inputData['_buffer'].join('') ? this._valueGet() : '';
|
|
|
},
|
|
},
|
|
|
set: function(value) {
|
|
set: function(value) {
|
|
|
this._valueSet(value); $(this).triggerHandler('setvalue.inputmask');
|
|
this._valueSet(value); $(this).triggerHandler('setvalue.inputmask');
|
|
@@ -630,7 +635,7 @@ This plugin is based on the masked input plugin written by Josh Bush (digitalbus
|
|
|
|
|
|
|
|
npt.__defineGetter__("value", function() {
|
|
npt.__defineGetter__("value", function() {
|
|
|
var $self = $(this), inputData = $(this).data('inputmask');
|
|
var $self = $(this), inputData = $(this).data('inputmask');
|
|
|
- return inputData && inputData['autoUnmask'] ? $self.inputmask('unmaskedvalue') : this._valueGet();
|
|
|
|
|
|
|
+ return inputData && inputData['autoUnmask'] ? $self.inputmask('unmaskedvalue') : this._valueGet() != inputData['_buffer'].join('') ? this._valueGet() : '';
|
|
|
});
|
|
});
|
|
|
npt.__defineSetter__("value", function(value) {
|
|
npt.__defineSetter__("value", function(value) {
|
|
|
this._valueSet(value); $(this).triggerHandler('setvalue.inputmask');
|
|
this._valueSet(value); $(this).triggerHandler('setvalue.inputmask');
|
|
@@ -645,15 +650,16 @@ This plugin is based on the masked input plugin written by Josh Bush (digitalbus
|
|
|
$.fn.val = function() {
|
|
$.fn.val = function() {
|
|
|
var $self = $(this);
|
|
var $self = $(this);
|
|
|
if ($self.data('inputmask')) {
|
|
if ($self.data('inputmask')) {
|
|
|
- if ($self.data('inputmask')['autoUnmask'] && arguments.length == 0) {
|
|
|
|
|
- return $self.inputmask('unmaskedvalue');
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- var result = $.inputmask.val.apply(this, arguments);
|
|
|
|
|
- if (arguments.length > 0) {
|
|
|
|
|
- this.triggerHandler('setvalue.inputmask');
|
|
|
|
|
|
|
+ if (arguments.length == 0) {
|
|
|
|
|
+ if ($self.data('inputmask')['autoUnmask'])
|
|
|
|
|
+ return $self.inputmask('unmaskedvalue');
|
|
|
|
|
+ else {
|
|
|
|
|
+ var result = $.inputmask.val.apply(this);
|
|
|
|
|
+ return result != $self.data('inputmask')['_buffer'].join('') ? result : '';
|
|
|
}
|
|
}
|
|
|
- return result;
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ var result = $.inputmask.val.apply(this, arguments);
|
|
|
|
|
+ this.triggerHandler('setvalue.inputmask');
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|