dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit 0600112c5d16800c08569fc0863dbed3b3f40455
parent 2f3bc47d3b6d0f0e52f9bb5bba4f53ec3454e325
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Thu,  8 Jun 2023 21:53:32 -0700

add cancel button on modal

Diffstat:
Mpkg/web/handlers/streamModals/codeModal.go | 22++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/pkg/web/handlers/streamModals/codeModal.go b/pkg/web/handlers/streamModals/codeModal.go @@ -73,7 +73,21 @@ func getCss() string { position: fixed; top: 0; left: calc(50% - ((100% - 185px - 100px)/2) - 92px); background-color: gray; z-index: 999; border-radius: 5px; } - .code-modal .wrapper { position: absolute; top: 10px; left: 10px; right: 10px; bottom: 30px; } + .code-modal .header { position: absolute; top: 0; right: 0; } + .code-modal .header .cancel { + border: 1px solid gray; + background-color: #ff7070; + color: #850000; + font-size: 18px; + height: 23px; + border: 1px solid #850000; + border-radius: 0 0 0 5px; + cursor: pointer; + } + .code-modal .header .cancel:hover { + background-color: #ff6767; + } + .code-modal .wrapper { position: absolute; top: 25px; left: 10px; right: 10px; bottom: 30px; } .code-modal .wrapper textarea { width: 100%; height: 100%; color: #fff; background-color: rgba(79,79,79,1); border: 1px solid rgba(90,90,90,1); } .code-modal .controls { position: absolute; left: 10px; right: 10px; bottom: 5px; }`, "\n"), " ") } @@ -89,6 +103,9 @@ func getCodeModalHTML(codeModalIdx int, roomName, csrf string, msgTyp database.C <input type="hidden" name="pm" value="{{ .ToUserUsername }}" /> {{ end }} <input type="hidden" name="sender" value="codeModal" /> + <div class="header"> + <button class="cancel" type="submit" name="btn_cancel" value="1">×</button> + </div> <div class=wrapper> <textarea name="message" placeholder="Paste your code here..."></textarea> </div> @@ -121,6 +138,7 @@ func (_ CodeModal) InterceptMsg(cmd *command.Command) { lang := cmd.C.Request().PostFormValue("lang") isMod := utils.DoParseBool(cmd.C.Request().PostFormValue("isMod")) pm := cmd.C.Request().PostFormValue("pm") + btnCancel := cmd.C.Request().PostFormValue("btn_cancel") if !cmd.AuthUser.CanUseMultiline || sender != "codeModal" { return @@ -155,7 +173,7 @@ func (_ CodeModal) InterceptMsg(cmd *command.Command) { cmd.RedirectQP.Set(command.RedirectPmQP, string(toUser.Username)) } - if cmd.OrigMessage == "" { + if cmd.OrigMessage == "" || btnCancel == "1" { cmd.Err = command.ErrRedirect return }