//评卷状态模块 var change_name = function(option, success) { var object = new ChangeName(option); success(); return object; } function ChangeName(option) { this.markControl = option.markControl; this.url = option.url; this.context = option.markControl.context; this.userName = option.markControl.container.header.find('#mark-user-name'); this.popover = getDom(this.popover_dom, this.markControl); this.popover.userNameInput = this.popover.find('input.username-input'); this.popover.passwordInput = this.popover.find('input.password-input'); this.popover.password2Input = this.popover.find('input.password2-input'); this.popover.userNameMessage = this.popover.find('i.username'); this.popover.password2Message = this.popover.find('i.password2'); this.popover.submitButton = this.popover.find('a.btn'); this.popover.cancelButton = this.popover.find('p.image-close'); this.popover.appendTo(this.markControl.container); var self = this; this.markControl.container.header.find('a.useinfo').click(function() { self.toggle(true); }); this.popover.cancelButton.click(function() { self.toggle(false); }); this.popover.submitButton.click(function() { var logout = false; var nameText = self.popover.userNameInput.val(); nameText = nameText.replace(/(^\s*)|(\s*$)/g, ""); var pwText = self.popover.passwordInput.val(); pwText = pwText.replace(/(^\s*)|(\s*$)/g, ""); var pw2Text = self.popover.password2Input.val(); pw2Text = pw2Text.replace(/(^\s*)|(\s*$)/g, ""); if (nameText.length == 0) { self.popover.userNameMessage.html(getMessage("mark.change.name.null")); return false; } else if (nameText.length > 8) { self.popover.userNameMessage.html(getMessage("mark.change.name.length")); return false; } if(pwText.length > 0 || pw2Text.length > 0) { logout = true; if (!pw2Text) { self.popover.password2Message.html(getMessage("mark.change.press.password.again")); return false; } if (pwText != pw2Text) { self.popover.password2Message.html(getMessage("mark.change.password.same")); return false; } if(pw2Text.length < 4){ self.popover.password2Message.html(getMessage("mark.change.password.length")); return false; } } $.post(self.url, { name: nameText, password:pwText }, function(result) { if (result.success == true) { self.userName.html(result.name); self.toggle(false); if(logout){//修改密码后请重新登陆 window.location.href = '/mark/logout'; } } else { self.popover.userNameMessage.html(getMessage("mark.change.error")); } }).error(function() { self.popover.userNameMessage.html(getMessage("mark.change.network.error")); }); }); } ChangeName.prototype.toggle = function(enable) { if (enable == true) { this.enable = true; this.popover.userNameInput.val(this.userName.html()); this.popover.passwordInput.val(''); this.popover.userNameMessage.html(''); this.popover.password2Message.html(''); this.popover.show(); this.context.listenKeyboard = false; } else { this.enable = false; this.popover.hide(); this.context.listenKeyboard = true; } } ChangeName.prototype.popover_dom = '';