make dialogue close itself if callback is missing

This commit is contained in:
flash 2016-12-10 22:03:41 +01:00
parent 687d49a958
commit 68c3fcb909
10 changed files with 7 additions and 61 deletions

View file

@ -68,7 +68,13 @@ namespace Sakura
DOM.Append(button, DOM.Text(btnText)); DOM.Append(button, DOM.Text(btnText));
button.setAttribute('data-type', btnType.toString()); button.setAttribute('data-type', btnType.toString());
button.addEventListener("click", (ev: any) => { button.addEventListener("click", (ev: any) => {
(this.Callbacks.Get(+ev.target.attributes['data-type'].value)).Value.call(this); var callback: KeyValuePair<DialogueButton, Function> = this.Callbacks.Get(+ev.target.attributes['data-type'].value);
if (callback) {
callback.Value.call(this);
} else {
this.Close();
}
}); });
DOM.Append(buttonCont, button); DOM.Append(buttonCont, button);

View file

@ -46,9 +46,6 @@
var error = new Sakura.Dialogue; var error = new Sakura.Dialogue;
error.Title = "Error"; error.Title = "Error";
error.Text = text; error.Text = text;
error.AddCallback(Sakura.DialogueButton.Ok, function () {
this.Close();
});
error.Display(); error.Display();
} }

View file

@ -150,11 +150,6 @@
error.Title = "Error"; error.Title = "Error";
error.Text = result.error; error.Text = result.error;
error.SetType(Sakura.DialogueType.Info); error.SetType(Sakura.DialogueType.Info);
error.AddCallback(Sakura.DialogueButton.Ok, function () {
this.Close();
});
error.Display(); error.Display();
} else { } else {
stopEdit(); stopEdit();
@ -198,11 +193,6 @@
error.Title = "Error"; error.Title = "Error";
error.Text = result.error; error.Text = result.error;
error.SetType(Sakura.DialogueType.Info); error.SetType(Sakura.DialogueType.Info);
error.AddCallback(Sakura.DialogueButton.Ok, function () {
this.Close();
});
error.Display(); error.Display();
} else if (result.go) { } else if (result.go) {
window.location.assign(result.go) window.location.assign(result.go)

View file

@ -66,17 +66,11 @@
var error = new Sakura.Dialogue; var error = new Sakura.Dialogue;
error.Title = "Error"; error.Title = "Error";
error.Text = "Deletion failed!"; error.Text = "Deletion failed!";
error.AddCallback(Sakura.DialogueButton.Ok, function () {
this.Close();
});
error.Display(); error.Display();
}); });
deleter.Start(Sakura.HTTPMethod.DELETE); deleter.Start(Sakura.HTTPMethod.DELETE);
this.Close(); this.Close();
}); });
confirm.AddCallback(Sakura.DialogueButton.No, function () {
this.Close();
});
confirm.Display(); confirm.Display();
} }

View file

@ -99,9 +99,6 @@
var diag = new Sakura.Dialogue; var diag = new Sakura.Dialogue;
diag.Title = "Login Error"; diag.Title = "Login Error";
diag.Text = result.error; diag.Text = result.error;
diag.AddCallback(Sakura.DialogueButton.Ok, function () {
this.Close();
});
diag.Display(); diag.Display();
} else if (result.go) { } else if (result.go) {
window.location.assign(result.go); window.location.assign(result.go);
@ -121,10 +118,6 @@
confirm.Title = "Logout"; confirm.Title = "Logout";
confirm.Text = "Are you sure?"; confirm.Text = "Are you sure?";
confirm.AddCallback(Sakura.DialogueButton.No, function () {
this.Close();
});
confirm.AddCallback(Sakura.DialogueButton.Yes, function () { confirm.AddCallback(Sakura.DialogueButton.Yes, function () {
var ajax = new Sakura.AJAX; var ajax = new Sakura.AJAX;
ajax.SetUrl("{{ route('auth.logout') }}?session=" + Sakura.Config.SessionId); ajax.SetUrl("{{ route('auth.logout') }}?session=" + Sakura.Config.SessionId);
@ -138,11 +131,6 @@
var error = new Sakura.Dialogue; var error = new Sakura.Dialogue;
error.Title = "Logout Error"; error.Title = "Logout Error";
error.Text = "Logout failed."; error.Text = "Logout failed.";
error.AddCallback(Sakura.DialogueButton.Ok, function () {
this.Close();
});
error.Display(); error.Display();
}); });

View file

@ -10,14 +10,8 @@
<script> <script>
function yuunoRankProtected() { function yuunoRankProtected() {
var confirm = new Sakura.Dialogue; var confirm = new Sakura.Dialogue;
confirm.Title = "Ranks"; confirm.Title = "Ranks";
confirm.Text = "You aren't allowed to remove this rank from your account!"; confirm.Text = "You aren't allowed to remove this rank from your account!";
confirm.AddCallback(Sakura.DialogueButton.Ok, function () {
this.Close();
});
confirm.Display(); confirm.Display();
} }
@ -33,10 +27,6 @@
confirm.Title = "Ranks"; confirm.Title = "Ranks";
confirm.Text = "You are about to remove the rank '" + name + "' from your account. Are you sure about this?"; confirm.Text = "You are about to remove the rank '" + name + "' from your account. Are you sure about this?";
confirm.AddCallback(Sakura.DialogueButton.No, function () {
this.Close();
});
confirm.AddCallback(Sakura.DialogueButton.Yes, function () { confirm.AddCallback(Sakura.DialogueButton.Yes, function () {
this.Close(); this.Close();
yuunoRankDo(id, csrf, 'remove'); yuunoRankDo(id, csrf, 'remove');
@ -64,11 +54,6 @@
error.Title = "Ranks"; error.Title = "Ranks";
error.Text = result.error; error.Text = result.error;
error.SetType(Sakura.DialogueType.Info); error.SetType(Sakura.DialogueType.Info);
error.AddCallback(Sakura.DialogueButton.Ok, function () {
this.Close();
});
error.Display(); error.Display();
} else if (mode === 'remove') { } else if (mode === 'remove') {
Sakura.DOM.Remove(Sakura.DOM.ID('rank-' + id)); Sakura.DOM.Remove(Sakura.DOM.ID('rank-' + id));

View file

@ -17,10 +17,6 @@
confirm.Title = "Account Deactivation"; confirm.Title = "Account Deactivation";
confirm.Text = "Are you really sure? You can reactivate your account within 30 days of deactivated, after that it'll be permanently deleted!"; confirm.Text = "Are you really sure? You can reactivate your account within 30 days of deactivated, after that it'll be permanently deleted!";
confirm.AddCallback(Sakura.DialogueButton.No, function () {
this.Close();
});
confirm.AddCallback(Sakura.DialogueButton.Yes, function () { confirm.AddCallback(Sakura.DialogueButton.Yes, function () {
var ajax = new Sakura.AJAX; var ajax = new Sakura.AJAX;

View file

@ -17,10 +17,6 @@
confirm.Title = "Session Manager"; confirm.Title = "Session Manager";
confirm.Text = !id ? "You are about to end every active login to your account. Are you sure?" : "Are you sure you want to end this session?"; confirm.Text = !id ? "You are about to end every active login to your account. Are you sure?" : "Are you sure you want to end this session?";
confirm.AddCallback(Sakura.DialogueButton.No, function () {
this.Close();
});
confirm.AddCallback(Sakura.DialogueButton.Yes, function () { confirm.AddCallback(Sakura.DialogueButton.Yes, function () {
var ajax = new Sakura.AJAX, var ajax = new Sakura.AJAX,
formData = new FormData; formData = new FormData;

View file

@ -33,9 +33,6 @@
dialogue.Title = "Confirmation"; dialogue.Title = "Confirmation";
dialogue.Text = "Are you sure?"; dialogue.Text = "Are you sure?";
dialogue.SetType(Sakura.DialogueType.Confirm); dialogue.SetType(Sakura.DialogueType.Confirm);
dialogue.AddCallback(Sakura.DialogueButton.No, function () {
this.Close();
});
dialogue.AddCallback(Sakura.DialogueButton.Yes, function () { dialogue.AddCallback(Sakura.DialogueButton.Yes, function () {
updateSettings(form, action); updateSettings(form, action);
this.Close(); this.Close();

View file

@ -155,9 +155,6 @@
var diag = new Sakura.Dialogue; var diag = new Sakura.Dialogue;
diag.Title = "Error"; diag.Title = "Error";
diag.Text = result.error; diag.Text = result.error;
diag.AddCallback(Sakura.DialogueButton.Ok, function () {
this.Close();
});
diag.Display(); diag.Display();
} }