From 68c3fcb9098ef65b70a507f7b919b57f3001c514 Mon Sep 17 00:00:00 2001 From: flashwave Date: Sat, 10 Dec 2016 22:03:41 +0100 Subject: [PATCH] make dialogue close itself if callback is missing --- resources/assets/typescript/Sakura/Dialogue.ts | 8 +++++++- resources/views/yuuno/elements/comments.twig | 3 --- .../views/yuuno/forum/elements/replyForm.twig | 10 ---------- resources/views/yuuno/forum/topic.twig | 6 ------ resources/views/yuuno/master.twig | 12 ------------ resources/views/yuuno/settings/account/ranks.twig | 15 --------------- .../views/yuuno/settings/advanced/deactivate.twig | 4 ---- .../views/yuuno/settings/advanced/sessions.twig | 4 ---- resources/views/yuuno/settings/master.twig | 3 --- resources/views/yuuno/user/profile.twig | 3 --- 10 files changed, 7 insertions(+), 61 deletions(-) diff --git a/resources/assets/typescript/Sakura/Dialogue.ts b/resources/assets/typescript/Sakura/Dialogue.ts index a554c39..b6fa287 100644 --- a/resources/assets/typescript/Sakura/Dialogue.ts +++ b/resources/assets/typescript/Sakura/Dialogue.ts @@ -68,7 +68,13 @@ namespace Sakura DOM.Append(button, DOM.Text(btnText)); button.setAttribute('data-type', btnType.toString()); button.addEventListener("click", (ev: any) => { - (this.Callbacks.Get(+ev.target.attributes['data-type'].value)).Value.call(this); + var callback: KeyValuePair = this.Callbacks.Get(+ev.target.attributes['data-type'].value); + + if (callback) { + callback.Value.call(this); + } else { + this.Close(); + } }); DOM.Append(buttonCont, button); diff --git a/resources/views/yuuno/elements/comments.twig b/resources/views/yuuno/elements/comments.twig index e199bf1..af7abdc 100644 --- a/resources/views/yuuno/elements/comments.twig +++ b/resources/views/yuuno/elements/comments.twig @@ -46,9 +46,6 @@ var error = new Sakura.Dialogue; error.Title = "Error"; error.Text = text; - error.AddCallback(Sakura.DialogueButton.Ok, function () { - this.Close(); - }); error.Display(); } diff --git a/resources/views/yuuno/forum/elements/replyForm.twig b/resources/views/yuuno/forum/elements/replyForm.twig index 5a4690d..338b6de 100644 --- a/resources/views/yuuno/forum/elements/replyForm.twig +++ b/resources/views/yuuno/forum/elements/replyForm.twig @@ -150,11 +150,6 @@ error.Title = "Error"; error.Text = result.error; error.SetType(Sakura.DialogueType.Info); - - error.AddCallback(Sakura.DialogueButton.Ok, function () { - this.Close(); - }); - error.Display(); } else { stopEdit(); @@ -198,11 +193,6 @@ error.Title = "Error"; error.Text = result.error; error.SetType(Sakura.DialogueType.Info); - - error.AddCallback(Sakura.DialogueButton.Ok, function () { - this.Close(); - }); - error.Display(); } else if (result.go) { window.location.assign(result.go) diff --git a/resources/views/yuuno/forum/topic.twig b/resources/views/yuuno/forum/topic.twig index 626f910..b95ac57 100644 --- a/resources/views/yuuno/forum/topic.twig +++ b/resources/views/yuuno/forum/topic.twig @@ -66,17 +66,11 @@ var error = new Sakura.Dialogue; error.Title = "Error"; error.Text = "Deletion failed!"; - error.AddCallback(Sakura.DialogueButton.Ok, function () { - this.Close(); - }); error.Display(); }); deleter.Start(Sakura.HTTPMethod.DELETE); this.Close(); }); - confirm.AddCallback(Sakura.DialogueButton.No, function () { - this.Close(); - }); confirm.Display(); } diff --git a/resources/views/yuuno/master.twig b/resources/views/yuuno/master.twig index ef93ff5..294e095 100644 --- a/resources/views/yuuno/master.twig +++ b/resources/views/yuuno/master.twig @@ -99,9 +99,6 @@ var diag = new Sakura.Dialogue; diag.Title = "Login Error"; diag.Text = result.error; - diag.AddCallback(Sakura.DialogueButton.Ok, function () { - this.Close(); - }); diag.Display(); } else if (result.go) { window.location.assign(result.go); @@ -121,10 +118,6 @@ confirm.Title = "Logout"; confirm.Text = "Are you sure?"; - confirm.AddCallback(Sakura.DialogueButton.No, function () { - this.Close(); - }); - confirm.AddCallback(Sakura.DialogueButton.Yes, function () { var ajax = new Sakura.AJAX; ajax.SetUrl("{{ route('auth.logout') }}?session=" + Sakura.Config.SessionId); @@ -138,11 +131,6 @@ var error = new Sakura.Dialogue; error.Title = "Logout Error"; error.Text = "Logout failed."; - - error.AddCallback(Sakura.DialogueButton.Ok, function () { - this.Close(); - }); - error.Display(); }); diff --git a/resources/views/yuuno/settings/account/ranks.twig b/resources/views/yuuno/settings/account/ranks.twig index 5dea897..68195aa 100644 --- a/resources/views/yuuno/settings/account/ranks.twig +++ b/resources/views/yuuno/settings/account/ranks.twig @@ -10,14 +10,8 @@