-- corr
This commit is contained in:
@@ -236,11 +236,6 @@ Sys.Extended.UI.MaskedEditBehavior.prototype = {
|
||||
this._focusHandler = null;
|
||||
}
|
||||
|
||||
if(this._focusHandler) {
|
||||
$removeHandler(e, "focus", this._focusHandler);
|
||||
this._focusHandler = null;
|
||||
}
|
||||
|
||||
if(this._blurHandler) {
|
||||
$removeHandler(e, "blur", this._blurHandler);
|
||||
this._blurHandler = null;
|
||||
@@ -547,29 +542,8 @@ Sys.Extended.UI.MaskedEditBehavior.prototype = {
|
||||
this._insertContent(c, logiccur);
|
||||
curpos = this._getNextPosition(logiccur + 1);
|
||||
} else {
|
||||
var wrapper = Sys.Extended.UI.TextBoxWrapper.get_Wrapper(this.get_element()),
|
||||
ClearText = this._getClearMask(wrapper.get_Value());
|
||||
|
||||
if(ClearText != "") {
|
||||
var pospt = ClearText.indexOf(this.get_cultureDecimalPlaceholder());
|
||||
|
||||
if(pospt != -1) {
|
||||
var intnum = ClearText.substring(0, pospt);
|
||||
if(intnum == "0" || intnum == "-0") {
|
||||
this.setSelectionRange(this._LogicLastInt - 1, this._LogicLastInt);
|
||||
this._deleteTextSelection();
|
||||
curpos = this._LogicLastInt;
|
||||
this.setSelectionRange(curpos, curpos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(ClearText == "" && c == "0") {
|
||||
curpos = this._LogicLastInt;
|
||||
} else {
|
||||
this._insertContentRight(c);
|
||||
curpos = this._LogicLastInt;
|
||||
}
|
||||
this._insertContentRight(c);
|
||||
curpos = this._LogicLastInt;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -711,7 +685,7 @@ Sys.Extended.UI.MaskedEditBehavior.prototype = {
|
||||
// Execute Navigator on Mask
|
||||
_ExecuteNav: function(evt, scanCode) {
|
||||
if(evt.type == "keydown") {
|
||||
if(this._isInternetExplorer()) {
|
||||
if($common.isInternetExplorer()) {
|
||||
// ctrl v
|
||||
if((scanCode == 86 || scanCode == 118) && !evt.shiftKey && evt.ctrlKey && !evt.altKey) {
|
||||
this._SetCancelEvent(evt);
|
||||
@@ -730,7 +704,7 @@ Sys.Extended.UI.MaskedEditBehavior.prototype = {
|
||||
}
|
||||
}
|
||||
|
||||
if(!this._isInternetExplorer() || evt.type == "keypress") {
|
||||
if (!$common.isInternetExplorer() || evt.type == "keypress") {
|
||||
// Shift Ins
|
||||
if(evt.rawEvent.shiftKey && !evt.rawEvent.ctrlKey && !evt.rawEvent.altKey && evt.rawEvent.keyCode == 45) {
|
||||
// at opera assume Ins = "-" not execute Shift-Ins
|
||||
@@ -983,7 +957,7 @@ Sys.Extended.UI.MaskedEditBehavior.prototype = {
|
||||
arr_num[0] = arr_num[0].substring(0, arr_num[0].length - 1);
|
||||
ClearText = arr_num[0];
|
||||
|
||||
if(arr_num.length = 2)
|
||||
if(arr_num.length == 2)
|
||||
ClearText += this.get_cultureDecimalPlaceholder() + arr_num[1];
|
||||
} else {
|
||||
ClearText = ClearText.substring(0, ClearText.length - 1);
|
||||
@@ -1082,16 +1056,6 @@ Sys.Extended.UI.MaskedEditBehavior.prototype = {
|
||||
return arr;
|
||||
},
|
||||
|
||||
_isInternetExplorer: function ()
|
||||
{
|
||||
if (Sys.Browser.agent == Sys.Browser.InternetExplorer //pre IE 11
|
||||
||
|
||||
(Sys.Browser.agent == null && Sys.Browser.name == "Netscape" && Sys.Browser.version == 5)) // IE 11
|
||||
return true;
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
// Paste clip board
|
||||
_ShowModalClipBoardInput: function() {
|
||||
var clip = prompt(this._clipboardText, "");
|
||||
@@ -1105,7 +1069,7 @@ Sys.Extended.UI.MaskedEditBehavior.prototype = {
|
||||
iniSel = -1,
|
||||
fimSel = -1;
|
||||
|
||||
if(this._isInternetExplorer()) {
|
||||
if ($common.isInternetExplorer()) {
|
||||
value = window.clipboardData.getData("Text");
|
||||
} else {
|
||||
// save current values because lost focus
|
||||
@@ -1444,16 +1408,19 @@ Sys.Extended.UI.MaskedEditBehavior.prototype = {
|
||||
m_mask = m_mask.split(":");
|
||||
if(curpos <= 1) {
|
||||
type = "H";
|
||||
newcur = 3 + this._LogicFirstPos + QtdDt;
|
||||
} else if(curpos >= 2 && curpos <= 4 && m_mask.length == 2) {
|
||||
newcur = this._LogicFirstPos + QtdDt + 3;
|
||||
} else if(curpos == 2 && m_mask.length == 2) {
|
||||
type = "M";
|
||||
newcur = QtdDt + this._LogicFirstPos;
|
||||
newcur = this._LogicFirstPos + QtdDt + 3;
|
||||
} else if (curpos >= 3 && curpos <= 5 && m_mask.length == 2) {
|
||||
type = "M";
|
||||
newcur = this._LogicFirstPos + QtdDt;
|
||||
} else if(curpos >= 2 && curpos <= 4 && m_mask.length == 3) {
|
||||
type = "M";
|
||||
newcur = 6 + this._LogicFirstPos + QtdDt;
|
||||
newcur = this._LogicFirstPos + QtdDt + 6;
|
||||
} else if(m_mask.length == 3) {
|
||||
type = "S";
|
||||
newcur = QtdDt + this._LogicFirstPos;
|
||||
newcur = this._LogicFirstPos + QtdDt;
|
||||
}
|
||||
|
||||
if(type == "")
|
||||
@@ -1949,6 +1916,10 @@ Sys.Extended.UI.MaskedEditBehavior.prototype = {
|
||||
this.loadValue(value, this._LogicLastPos);
|
||||
this._inputDirection = Sys.Extended.UI.MaskedEditInputDirections.LeftToRight;
|
||||
} else {
|
||||
if(!this.get_clearMaskOnLostFocus() && this._LogicFirstPos > 0) {
|
||||
// https://github.com/DevExpress/AjaxControlToolkit/issues/493
|
||||
value = value.substr(this._LogicFirstPos);
|
||||
}
|
||||
this.loadValue(value, this._LogicFirstPos);
|
||||
}
|
||||
} else if(this._inputDirection == Sys.Extended.UI.MaskedEditInputDirections.RightToLeft && value != "") {
|
||||
@@ -1985,7 +1956,33 @@ Sys.Extended.UI.MaskedEditBehavior.prototype = {
|
||||
containsAMPMLetters: function(value, index)
|
||||
{
|
||||
var currentAMPMtext = value.substring(index);
|
||||
},
|
||||
|
||||
getMaskCharPositions: function()
|
||||
{
|
||||
var maskCharPositions = [];
|
||||
var mask = this.get_clearMaskOnLostFocus() ? this.getVisibleMask() : this._LogicMaskConv;
|
||||
|
||||
for (var i = 0; i < mask.length; i++) {
|
||||
var char = mask[i];
|
||||
if (this.isMaskChar(char))
|
||||
maskCharPositions.push(i);
|
||||
}
|
||||
|
||||
return maskCharPositions;
|
||||
},
|
||||
|
||||
getVisibleMask: function()
|
||||
{
|
||||
var clearedMask = this.replaceAll(this._LogicMaskConv, this._LogicPrompt, "");
|
||||
clearedMask = this.replaceAll(clearedMask, this._LogicEscape, "");
|
||||
return clearedMask;
|
||||
},
|
||||
|
||||
isMaskChar: function(char)
|
||||
{
|
||||
var maskChars = "9L$CAN?";
|
||||
return maskChars.indexOf(char) == -1;
|
||||
},
|
||||
|
||||
// Load initial value in mask
|
||||
@@ -1995,6 +1992,8 @@ Sys.Extended.UI.MaskedEditBehavior.prototype = {
|
||||
var wrapper = Sys.Extended.UI.TextBoxWrapper.get_Wrapper(this.get_element());
|
||||
wrapper.set_Value(this._EmptyMask);
|
||||
|
||||
var maskCharPositions = this.getMaskCharPositions();
|
||||
|
||||
if(this._inputDirection == Sys.Extended.UI.MaskedEditInputDirections.LeftToRight) {
|
||||
for(i = 0 ; i < parseInt(value.length, 10) ; i++) {
|
||||
var c = value.substring(i, i + 1);
|
||||
@@ -2049,7 +2048,18 @@ Sys.Extended.UI.MaskedEditBehavior.prototype = {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(i = parseInt(value.length, 10) ; i > 0 ; i--) {
|
||||
|
||||
var valueLength = value.length;
|
||||
var maskLength = this.get_clearMaskOnLostFocus() ? this.getVisibleMask().length : this._EmptyMask.length;
|
||||
maskCharPositions.splice(0, maskLength - valueLength);
|
||||
|
||||
for (i = parseInt(value.length, 10) ; i > 0 ; i--) {
|
||||
|
||||
if (!this.get_clearMaskOnLostFocus()
|
||||
&& this._maskType === Sys.Extended.UI.MaskedEditType.Number
|
||||
&& maskCharPositions.indexOf(i - 1) != -1)
|
||||
continue;
|
||||
|
||||
var c = value.substring(i - 1, i);
|
||||
|
||||
if(this._maskType == Sys.Extended.UI.MaskedEditType.Number && this._acceptNegative != Sys.Extended.UI.MaskedEditShowSymbol.None && "+-".indexOf(c) != -1) {
|
||||
@@ -2059,14 +2069,15 @@ Sys.Extended.UI.MaskedEditBehavior.prototype = {
|
||||
this.insertSignal(c);
|
||||
}
|
||||
|
||||
if(this._processKey(logicPosition, c))
|
||||
if (this._processKey(logicPosition, c)) {
|
||||
this._insertContent(c, logicPosition);
|
||||
logicPosition = this._getPreviousPosition(logicPosition - 1);
|
||||
}
|
||||
|
||||
oldLogicPosition = logicPosition;
|
||||
logicPosition = this._getPreviousPosition(logicPosition - 1);
|
||||
//oldLogicPosition = logicPosition;
|
||||
|
||||
if(this._maskType === Sys.Extended.UI.MaskedEditType.Number && logicPosition === oldLogicPosition)
|
||||
break;
|
||||
//if(this._maskType === Sys.Extended.UI.MaskedEditType.Number && logicPosition === oldLogicPosition)
|
||||
// break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2511,7 +2522,7 @@ Sys.Extended.UI.MaskedEditBehavior.prototype = {
|
||||
var m_arrDateLD,
|
||||
m_arrDate;
|
||||
|
||||
m_arrDate = this._filter(input.split(this.get_CultureDatePlaceholder()), function (element) {
|
||||
m_arrDate = this._filter(input.split(this.get_cultureDatePlaceholder()), function (element) {
|
||||
return element != "";
|
||||
});
|
||||
m_arrDate = this._map(m_arrDate, function (element) {
|
||||
@@ -2519,9 +2530,9 @@ Sys.Extended.UI.MaskedEditBehavior.prototype = {
|
||||
});
|
||||
|
||||
if(loadFirst) {
|
||||
m_arrDateLD = input.split(this.get_CultureDatePlaceholder());
|
||||
if(this.get_UserDateFormat() != Sys.Extended.UI.MaskedEditUserDateFormat.None) {
|
||||
if(this.get_UserDateFormat() == Sys.Extended.UI.MaskedEditUserDateFormat.DayMonthYear)
|
||||
m_arrDateLD = input.split(this.get_cultureDatePlaceholder());
|
||||
if(this.get_userDateFormat() != Sys.Extended.UI.MaskedEditUserDateFormat.None) {
|
||||
if(this.get_userDateFormat() == Sys.Extended.UI.MaskedEditUserDateFormat.DayMonthYear)
|
||||
this._cultureDateFormat = 'DMY';
|
||||
if(this.get_userDateFormat() == Sys.Extended.UI.MaskedEditUserDateFormat.DayYearMonth)
|
||||
this._cultureDateFormat = 'DYM';
|
||||
@@ -2798,7 +2809,7 @@ Sys.Extended.UI.MaskedEditBehavior.prototype = {
|
||||
}
|
||||
}
|
||||
|
||||
if(arr_num.length = 2) {
|
||||
if(arr_num.length == 2) {
|
||||
masktext += this.get_cultureDecimalPlaceholder() + arr_num[1];
|
||||
this._LogicTextMask += this.get_cultureDecimalPlaceholder() + arr_log[1];
|
||||
}
|
||||
@@ -3143,6 +3154,34 @@ Sys.Extended.UI.MaskedEditBehavior.prototype = {
|
||||
this._EmptyMask = masktext;
|
||||
},
|
||||
|
||||
replaceAll: function(string, find, replace) {
|
||||
return string.split(find).join(replace);
|
||||
},
|
||||
|
||||
getTextWithoutMask: function(text)
|
||||
{
|
||||
var clearedMask = this.replaceAll(this._LogicMask, this._LogicPrompt, "");
|
||||
clearedMask = this.replaceAll(clearedMask, this._LogicEscape, "");
|
||||
|
||||
var clearedText = "";
|
||||
|
||||
for (var charPos = 0; charPos < text.length; charPos++) {
|
||||
var currentChar = text[charPos];
|
||||
|
||||
if (currentChar == clearedMask[0]) {
|
||||
clearedMask = clearedMask.substring(1);
|
||||
} else
|
||||
clearedText += currentChar;
|
||||
}
|
||||
|
||||
return clearedText;
|
||||
},
|
||||
|
||||
isDataCharacter: function(char)
|
||||
{
|
||||
return char == this._LogicEscape || char == this._LogicPrompt;
|
||||
},
|
||||
|
||||
// return text without mask but with placeholders
|
||||
_getClearMask: function(masktext) {
|
||||
var i = 0,
|
||||
|
||||
Reference in New Issue
Block a user