Make sure we don't call both the yes and no handlers in prompts
This commit is contained in:
@@ -19,11 +19,11 @@ define([
|
|||||||
Alertify._$$alertify.delay = AppConfig.notificationTimeout || 5000;
|
Alertify._$$alertify.delay = AppConfig.notificationTimeout || 5000;
|
||||||
|
|
||||||
var findCancelButton = UI.findCancelButton = function () {
|
var findCancelButton = UI.findCancelButton = function () {
|
||||||
return $('button.cancel');
|
return $('button.cancel').last();
|
||||||
};
|
};
|
||||||
|
|
||||||
var findOKButton = UI.findOKButton = function () {
|
var findOKButton = UI.findOKButton = function () {
|
||||||
return $('button.ok');
|
return $('button.ok').last();
|
||||||
};
|
};
|
||||||
|
|
||||||
var listenForKeys = UI.listenForKeys = function (yes, no) {
|
var listenForKeys = UI.listenForKeys = function (yes, no) {
|
||||||
@@ -74,14 +74,22 @@ define([
|
|||||||
findCancelButton().click();
|
findCancelButton().click();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Make sure we don't call both the "yes" and "no" handlers if we use "findOKButton().click()"
|
||||||
|
// in the callback
|
||||||
|
var isClicked = false;
|
||||||
|
|
||||||
Alertify
|
Alertify
|
||||||
.defaultValue(def || '')
|
.defaultValue(def || '')
|
||||||
.okBtn(opt.ok || Messages.okButton || 'OK')
|
.okBtn(opt.ok || Messages.okButton || 'OK')
|
||||||
.cancelBtn(opt.cancel || Messages.cancelButton || 'Cancel')
|
.cancelBtn(opt.cancel || Messages.cancelButton || 'Cancel')
|
||||||
.prompt(msg, function (val, ev) {
|
.prompt(msg, function (val, ev) {
|
||||||
|
if (isClicked) { return; }
|
||||||
|
isClicked = true;
|
||||||
cb(val, ev);
|
cb(val, ev);
|
||||||
stopListening(keyHandler);
|
stopListening(keyHandler);
|
||||||
}, function (ev) {
|
}, function (ev) {
|
||||||
|
if (isClicked) { return; }
|
||||||
|
isClicked = true;
|
||||||
cb(null, ev);
|
cb(null, ev);
|
||||||
stopListening(keyHandler);
|
stopListening(keyHandler);
|
||||||
});
|
});
|
||||||
@@ -98,13 +106,21 @@ define([
|
|||||||
findCancelButton().click();
|
findCancelButton().click();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Make sure we don't call both the "yes" and "no" handlers if we use "findOKButton().click()"
|
||||||
|
// in the callback
|
||||||
|
var isClicked = false;
|
||||||
|
|
||||||
Alertify
|
Alertify
|
||||||
.okBtn(opt.ok || Messages.okButton || 'OK')
|
.okBtn(opt.ok || Messages.okButton || 'OK')
|
||||||
.cancelBtn(opt.cancel || Messages.cancelButton || 'Cancel')
|
.cancelBtn(opt.cancel || Messages.cancelButton || 'Cancel')
|
||||||
.confirm(msg, function () {
|
.confirm(msg, function () {
|
||||||
|
if (isClicked) { return; }
|
||||||
|
isClicked = true;
|
||||||
cb(true);
|
cb(true);
|
||||||
stopListening(keyHandler);
|
stopListening(keyHandler);
|
||||||
}, function () {
|
}, function () {
|
||||||
|
if (isClicked) { return; }
|
||||||
|
isClicked = true;
|
||||||
cb(false);
|
cb(false);
|
||||||
stopListening(keyHandler);
|
stopListening(keyHandler);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -521,9 +521,9 @@ define([
|
|||||||
if (_onDisplayNameChanged.indexOf(h) !== -1) { return; }
|
if (_onDisplayNameChanged.indexOf(h) !== -1) { return; }
|
||||||
_onDisplayNameChanged.push(h);
|
_onDisplayNameChanged.push(h);
|
||||||
};
|
};
|
||||||
common.changeDisplayName = function (newName) {
|
common.changeDisplayName = function (newName, isLocal) {
|
||||||
_onDisplayNameChanged.forEach(function (h) {
|
_onDisplayNameChanged.forEach(function (h) {
|
||||||
h(newName);
|
h(newName, isLocal);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -730,7 +730,7 @@ define([
|
|||||||
Cryptpad.prompt(Messages.changeNamePrompt, lastName || '', function (newName) {
|
Cryptpad.prompt(Messages.changeNamePrompt, lastName || '', function (newName) {
|
||||||
if (newName === null && typeof(lastName) === "string") { return; }
|
if (newName === null && typeof(lastName) === "string") { return; }
|
||||||
if (newName === null) { newName = ''; }
|
if (newName === null) { newName = ''; }
|
||||||
Cryptpad.changeDisplayName(newName);
|
Cryptpad.changeDisplayName(newName, true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user