📄 maskededitbehavior.js
字号:
}
else
{
var wrapper = AjaxControlToolkit.TextBoxWrapper.get_Wrapper(this.get_element());
var 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.setSelectionRange(curpos,curpos);
}
}
this._SetCancelEvent(evt);
return false;
}
, _onKeyPressdown : function(evt)
{
// for other browsers not IE (NOT IMPLEMENT document.activeElement)
if (this._InLostfocus)
{
this._onFocus(evt);
}
var scancode = this._KeyCode(evt);
if (scancode == 9) //tab default action
{
return true;
}
if (scanCode == 13) //enter
{
return true;
}
if (!this._isNormalChar(evt,scancode))
{
this._ExecuteNav(evt,scancode);
}
else
{
// Opera not perform cancel event. Re-perform at Timer
if (Sys.Browser.agent == Sys.Browser.Opera)
{
// cancel shift Ins , assume Ins = "-"
if (evt.rawEvent.shiftKey && !evt.rawEvent.ctrlKey && !evt.rawEvent.altKey && evt.rawEvent.keyCode == 45)
{
var wrapper = AjaxControlToolkit.TextBoxWrapper.get_Wrapper(this.get_element());
this._SaveText = wrapper.get_Value();
this._SavePosi = this._getCurrentPosition();
this._timer.set_enabled(false);
this._timer.set_interval(1);
this._timer.set_enabled(true);
}
}
}
}
, _onMouseOut : function(evt)
{
this._RemoveDivToolTip();
}
, _onMouseMove : function(evt)
{
if ((this._InLostfocus || this._ErroOnEnter) && this._ExternalMessageError != "")
{
this._ShowDivToolTip(evt);
}
}
,_onMouseover : function(evt)
{
// check if validation execute at asyc.post back
if (!$get("DivMaskedEditTip_" + this.get_element().id))
{
this._CaptureServerValidators();
}
if ((this._InLostfocus || this._ErroOnEnter) && this._ExternalMessageError != "")
{
this._createDivToolTip(evt,this._ExternalMessageError);
}
}
//
// CREATE TOOLTIP
//
, _ShowDivToolTip : function(evt) {
var et = $get("DivMaskedEditTip_" + this.get_element().id);
if (!et)
{
this._createDivToolTip(evt,this._ExternalMessageError);
et = $get("DivMaskedEditTip_" + this.get_element().id);
}
var mousepos = this._GetMousePos(evt);
et.style.left = mousepos.x + 1/*offset To prevent flick in FF*/ + "px";
et.style.top = mousepos.y + 1/*offset To prevent flick in FF*/ + "px";
}
, _GetMousePos : function(evt) {
var scrOfX = 0, scrOfY = 0;
if( typeof( window.pageYOffset ) == 'number' ) {
//Netscape compliant
scrOfY = window.pageYOffset;
scrOfX = window.pageXOffset;
}
else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
//DOM compliant
scrOfY = document.body.scrollTop;
scrOfX = document.body.scrollLeft;
}
else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
//IE6 standards compliant mode
scrOfY = document.documentElement.scrollTop;
scrOfX = document.documentElement.scrollLeft;
}
var posX = 0, posY = 0;
if( typeof( evt.pageX ) == 'number' )
{
posX = evt.pageX;
posY = evt.pageY;
}
else if( typeof( evt.clientX ) == 'number' )
{
posX = evt.clientX;
posY = evt.clientY;
}
return {x:posX+scrOfX,y:posY+scrOfY}
}
, _RemoveDivToolTip : function() {
var e = $get("DivMaskedEditTip_" + this.get_element().id);
if (e)
{
document.body.removeChild(e);
}
}
, _createDivToolTip : function(evt,Msg) {
var e = $get("DivMaskedEditTip_" + this.get_element().id);
if (!e)
{
var DivTp;
var mousepos = this._GetMousePos(evt);
DivTp = document.createElement("div");
DivTp.id = "DivMaskedEditTip_" + this.get_element().id;
DivTp.style.position = "absolute";
DivTp.style.left = mousepos.x + 2/*offset*/ + "px";
DivTp.style.top = mousepos.y + 2/*offset*/ + "px";
DivTp.style.zIndex = 99999;
if (this._CssMessageErrorFloat == "")
{
DivTp.style.padding = "3px 3px 3px 3px";
DivTp.style.border = "Solid 1px #000000";
DivTp.style.backgroundColor = "#FFFFEA";
DivTp.style.fontWeight = "normal";
DivTp.style.fontSize = "12px";
DivTp.style.fontFamily = "Arial";
}
else
{
DivTp.className = this._CssMessageErrorFloat;
}
DivTp.innerHTML = Msg;
DivTp = document.body.insertBefore(DivTp, document.body.firstChild);
}
}
//
// Execute Navigator on Mask
//
, _ExecuteNav : function(evt,scanCode)
{
if (evt.type == "keydown")
{
if (Sys.Browser.agent == Sys.Browser.InternetExplorer)
{
// ctrl v
if ( (scanCode == 86 || scanCode == 118) && !evt.shiftKey && evt.ctrlKey && !evt.altKey) {
this._SetCancelEvent(evt);
this._PasteFromClipBoard();
return;
}
//Shift Ins
if (evt.shiftKey && !evt.ctrlKey && !evt.altKey && evt.keyCode == 45) {
this._SetCancelEvent(evt);
this._PasteFromClipBoard();
return;
}
}
}
if (Sys.Browser.agent != Sys.Browser.InternetExplorer || 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
this._SetCancelEvent(evt);
this._PasteFromClipBoard();
return;
}
// ctrl v
if (evt.type == "keypress" && (scanCode == 86 || scanCode == 118) && !evt.shiftKey && evt.ctrlKey && !evt.altKey) {
this._SetCancelEvent(evt);
this._PasteFromClipBoard();
return;
}
}
if (Sys.Browser.agent == Sys.Browser.InternetExplorer || evt.type == "keypress")
{
if (scanCode == 8) // BackSpace
{
this._SetCancelEvent(evt);
curpos = this._deleteTextSelection();
if (curpos != -1)
{
this.setSelectionRange(curpos,curpos);
}
else
{
curpos = this._getCurrentPosition();
this._backspace(curpos);
curpos = this._getPreviousPosition(curpos-1);
this.setSelectionRange(curpos,curpos);
}
var wrapper = AjaxControlToolkit.TextBoxWrapper.get_Wrapper(this.get_element());
if (this._MessageValidatorTip && wrapper.get_Value() == this._EmptyMask)
{
this.ShowTooltipMessage(true);
}
// Opera not perform cancel event. Re-perform at Timer
if (Sys.Browser.agent == Sys.Browser.Opera)
{
this._SaveText = wrapper.get_Value();
this._SavePosi = curpos;
this._timer.set_enabled(false);
this._timer.set_interval(1);
this._timer.set_enabled(true);
}
}
else if (scanCode == 46 || scanCode == 127) // delete
{
this._SetCancelEvent(evt);
var wrapper = AjaxControlToolkit.TextBoxWrapper.get_Wrapper(this.get_element());
curpos = this._deleteTextSelection();
if (curpos == -1)
{
curpos = this._getCurrentPosition();
if (!this._isValidMaskedEditPosition(curpos))
{
if (curpos != this._LogicLastInt && this._InputDirection != AjaxControlToolkit.MaskedEditInputDirections.RightToLeft)
{
curpos = this._getNextPosition(curpos);
}
}
this._deleteAtPosition(curpos,false);
}
else
{
if (this._InputDirection == AjaxControlToolkit.MaskedEditInputDirections.RightToLeft)
{
ClearText = this._getClearMask(wrapper.get_Value());
if (ClearText != "")
{
ClearText = ClearText.replace(new RegExp("(\\" + this.get_CultureThousandsPlaceholder() + ")", "g"), "") + '';
if (ClearText.substring(ClearText.length-1,ClearText.length) == this.get_CultureDecimalPlaceholder())
{
ClearText = ClearText.substring(0,ClearText.length-1);
this.loadValue(ClearText,this._LogicLastInt);
}
else
{
this.loadValue(ClearText,this._LogicLastPos);
}
}
}
}
this.setSelectionRange(curpos,curpos);
if (this._MessageValidatorTip && wrapper.get_Value() == this._EmptyMask)
{
this.ShowTooltipMessage(true);
}
if (Sys.Browser.agent == Sys.Browser.Opera)
{
this._SaveText = wrapper.get_Value();
this._SavePosi = curpos;
this._timer.set_enabled(false);
this._timer.set_interval(1);
this._timer.set_enabled(true);
}
}
else if(evt.ctrlKey)
{
if (scanCode == 39 || scanCode == 35 || scanCode == 34) //Right or END or pgdown
{
this._DirectSelText = "R";
if (Sys.Browser.agent == Sys.Browser.Opera)
{
return;
}
this._SetCancelEvent(evt);
curpos = this._getCurrentPosition();
this.setSelectionRange(curpos,this._LogicLastPos+1);
}
else if (scanCode == 37 || scanCode == 36 || scanCode == 33) //Left or Home or pgup
{
this._DirectSelText = "L";
if (Sys.Browser.agent == Sys.Browser.Opera)
{
return;
}
this._SetCancelEvent(evt);
curpos = this._getCurrentPosition();
this.setSelectionRange(this._LogicFirstPos,curpos);
}
}
else if (scanCode == 35 || scanCode == 34) //END or pgdown
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -