+ $("#changepass").unbind("submit");
+ },
+
+ close: function() {
+ this.closeChangePass();
+ this.closeAddUser();
+ },
+
+ toggleChangePass: function() {
+ if (this._changepassDisplayed) {
+ this.closeChangePass();
+ } else {
+ this.showChangePass();
+ }
+ },
+
+ showChangePass: function() {
+ if (!Admin.cancelCurrentFeature()) {
+ return;
+ }
+ this.closeAddUser();
+
+ $(document).unbind("keydown").keydown(function(e) {
+ if (e.keyCode == 27) {
+ userMgr.closeChangePass()
+ e.preventDefault();
+ }
+ });
+
+ this.resetForms();
+ this.enableForms();
+ $("#user_area, #changepass").show();
+ this.commError("");
+
+ // XXX: setTimeout needed because otherwise, map becomes hidden in IE. Why ??
+ window.setTimeout(function() {
+ $("#pass_current").focus();
+ }, 0);
+
+ this._changepassDisplayed = true;
+ },
+
+ closeChangePass: function() {
+ if (!this._changepassDisplayed) {
+ return;
+ }
+ $("#user_area, #changepass").hide();
+ $(document).unbind("keydown");
+ this._changepassDisplayed = false;
+ },
+
+ changepass: function() {
+ var newpass = $("#pass_new").val();
+ var newpass_confirm = $("#pass_new_confirm").val();
+ if (newpass != newpass_confirm) {
+ this.commError(SypStrings.userPasswordmatchError);
+ $("#pass_new").focus().select();
+ return;
+ }
+
+ if (!newpass) {
+ this.commError(SypStrings.emptyPasswordError);
+ $("#pass_new").focus().select();
+ return;
+ }
+
+ var curpass = $("#pass_current").val();
+ if (newpass == curpass) {
+ this.commError(SypStrings.changeSamePass);
+ $("#pass_new").focus().select();
+ return;
+ }
+
+ this.commError("");
+
+ this.disableForms();
+ alert (SypStrings.DisabledForDemo);
+ return;
+
+ AjaxMgr.add({
+ form: $("#changepass"),
+ oncomplete: OpenLayers.Function.bind(this.ajaxReply, this),
+ throbberid: "user_throbber",
+ onsend: function() {
+ // we need a timeout; otherwise those fields will not be submitted
+ window.setTimeout(function() {
+ // removes focus from #password before disabling it. Otherwise, opera
+ // prevents re-focusing it after re-enabling it.
+ $("#pass_current, #pass_new, #pass_new_confirm").blur();
+ userMgr.disableForms();
+ }, 0);
+ }
+ });