📄 loginbox.as
字号:
#initclip 10_global.LoginBox = function() { super(); this.dialog_name = 'loginbox'; //redirect links from InputGroup this.lblUserName = this.InputGroup.lblUserName; this.lblPassword = this.InputGroup.lblPassword; this.lblModerator = this.InputGroup.lblModerator; this.lblLanguage = this.InputGroup.lblLanguage; this.txtUserName = this.InputGroup.txtUserName; this.txtUserNameBackground = this.InputGroup.txtUserNameBackground; this.txtPassword = this.InputGroup.txtPassword; this.txtPasswordBackground = this.InputGroup.txtPasswordBackground; this.languageChooser = this.InputGroup.languageChooser; this.setCloseButtonEnabled(false); this._visible = false; this.txtLabel.autoSize = 'left'; this.txtPassword.password = true; this.languageList = null; this.selectedLanguage = null; this.languageTarget = null; this.labelTextId = null; this.language = null; this.txtUserName._height = this.txtPassword._height = 20; this.txtUserNameBackground._height = this.txtPasswordBackground._height = this.txtUserName._height; this.txtUserName.onChanged = function() { this._parent.languageChooser.myOnKillFocus(); this._parent._parent.textValidator(); }; this.txtPassword.onChanged = function() { this._parent.languageChooser.myOnKillFocus(); //this._parent._parent.textValidator(); }; this.txtUserName.background = false; this.txtPassword.background = false; this.txtUserName.onSetFocus = function() { this.borderColor = this._style.bodyText; }; this.txtUserName.onKillFocus = function() { this.borderColor = this._style.borderColor; }; this.txtPassword.onSetFocus = function() { this.borderColor = this._style.bodyText; }; this.txtPassword.onKillFocus = function() { this.borderColor = this._style.borderColor; };};_global.LoginBox.prototype = new _global.DialogBox();//PUBLIC METHODS._global.LoginBox.prototype.setEnabled = function(inDialogEnabled) { super.setEnabled(inDialogEnabled); this.textValidator(); this.languageChooser.enabled = (inDialogEnabled);};_global.LoginBox.prototype.show = function() { this.btnLogin.setClickHandler('processButton', this); this.languageChooser.setChangeHandler('processLanguageChooser', this); this.txtUserName.text = ''; this.txtPassword.text = ''; this.textValidator(); this.setLanguageList(this.languageList); this.setLabelText(this.labelTextId); this.setSelectedLanguage(this.selectedLanguage); if(_level0.ini.allowLanguage == false) { this.languageChooser.setEnabled(false); this.languageChooser._visible = false; this.lblLanguage._visible = false; var dim = this.getSize(); var fH = this.txtLabel._y + this.txtLabel._height + this.lblModerator._y + this.lblModerator._height - this.lblUserName._y + this.btnLogin._height; var dH = (dim.height - fH) / 3; this.InputGroup._y = (this.txtLabel._y + this.txtLabel._height + dH); this.btnLogin._y = dim.height - this.btnLogin._height - dH; } Key.addListener(this); this._visible = true; Selection.setFocus(this.txtUserName);};_global.LoginBox.prototype.setLabelText = function(inLabelText) { this.labelTextId = inLabelText; var toLbl = this.language.messages[this.labelTextId]; this.txtLabel.text = (toLbl != undefined)? toLbl : this.labelTextId; this.txtLabel._y = (this.InputGroup._y - this.txtLabel.textHeight - this.dbTop._height)/2 + this.dbTop._height; if( this.txtLabel._y < this.dbTop._height+this.dbTop._y) this.txtLabel._y = this.dbTop._height + this.dbTop._y; //this.txtLabel.text = inLabelText;};_global.LoginBox.prototype.setLanguageList = function(inLanguageList) { this.languageList = inLanguageList; this.languageChooser.removeAll(); for (var i = 0; i < this.languageList.length; i ++) { this.languageChooser.addItem(this.languageList[i].name, this.languageList[i]); //trace(this.languageList[i].name); }};_global.LoginBox.prototype.setSelectedLanguage = function(inSelectedLanguage) { this.selectedLanguage = inSelectedLanguage; for (var i = 0; i < this.languageList.length; i ++) { if (this.languageList[i].name == inSelectedLanguage.name) { this.languageChooser.setSelectedIndex(i); return; } }};_global.LoginBox.prototype.setLanguageTarget = function(inLanguageTarget) { this.languageTarget = inLanguageTarget;};_global.LoginBox.prototype.getUserName = function() { return this.txtUserName.text;};_global.LoginBox.prototype.getPassword = function() { return this.txtPassword.text;};_global.LoginBox.prototype.getSelectedLanguage = function() { return this.languageChooser.getSelectedItem().data;};_global.LoginBox.prototype.initialized = function() { return (super.initialized() && (this.btnLogin.setEnabled != null));};_global.LoginBox.prototype.applyTextProperty = function(propName, val){ setTextProperty(propName, val, this.txtLabel); setTextProperty(propName, val, this.lblUserName); setTextProperty(propName, val, this.lblPassword); setTextProperty(propName, val, this.lblLanguage);}_global.LoginBox.prototype.applyStyle = function(inStyle) { if (!inStyle.showBackgroundImagesOnLogin) { inStyle.dialogBackgroundImage = null; } super.applyStyle(inStyle); this.txtLabel.textColor = inStyle.bodyText; this.lblUserName.textColor = inStyle.bodyText; this.lblPassword.textColor = inStyle.bodyText; this.lblModerator.textColor = inStyle.bodyText; this.lblLanguage.textColor = inStyle.bodyText; this.txtUserName.textColor = inStyle.buttonText; this.txtUserName._style = inStyle; this.txtUserName.borderColor = inStyle.borderColor; this.txtUserName.border = true; this.txtPassword.textColor = inStyle.buttonText; this.txtPassword._style = inStyle; this.txtPassword.borderColor = inStyle.borderColor; this.txtPassword.border = true; var c = new Color(this.txtUserNameBackground); c.setRGB(inStyle.inputBoxBackground); this.txtUserNameBackground._alpha = inStyle.uiAlpha; c = new Color(this.txtPasswordBackground); c.setRGB(inStyle.inputBoxBackground); this.txtPasswordBackground._alpha = inStyle.uiAlpha;};_global.LoginBox.prototype.applyLanguage = function(inLanguage) { this.language = inLanguage; this.setLabelText(this.labelTextId); this.lblUserName.text = this.language.dialog.login.username; this.lblPassword.text = this.language.dialog.login.password; this.lblModerator.text = this.language.dialog.login.moderator; this.lblLanguage.text = this.language.dialog.login.language; this.btnLogin.setLabel( this.language.dialog.login.loginBtn ); this.btnLogin._x = (this.dialogWidth - this.btnLogin._width) / 2;};//PRIVATE METHODS._global.LoginBox.prototype.onKeyDown = function() { if(this.btnLogin.enabled) { if(this.handlerObj.isSpecialLanguage(this.languageChooser.getSelectedItem().data.id)) { if(Key.isDown(Key.CONTROL) && Key.isDown(Key.ENTER)) { this.processButton(); } } else if (Key.isDown(Key.ENTER)) { this.processButton(); } }};_global.LoginBox.prototype.processButton = function() { var usr = this.getUserName(); //fix for symbol #160 var str_buff = ''; for(var i = 0; i < length(usr); i++) { if(ord(usr.charAt(i)) == 160) continue; str_buff += usr.charAt(i); } usr = str_buff; if(usr.trim() != '') { this._visible = false; Key.removeListener(this); this.handlerObj[this.handlerFunctionName](this); } else { this.txtUserName.text = ''; Selection.setFocus(this.txtUserName); }};_global.LoginBox.prototype.processLanguageChooser = function() { var chosenLanguage = this.languageChooser.getSelectedItem().data; this.languageTarget.setSelectedLanguage(chosenLanguage); this.languageTarget.applyLanguage(chosenLanguage);};_global.LoginBox.prototype.textValidator = function() { this.btnLogin.setEnabled( (this.getEnabled() && (this.txtUserName.text.length > 0)) );};Object.registerClass('LoginBox', _global.LoginBox);#endinitclip
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -