From 57712e0cb50193b92102394e287d80723cd38306 Mon Sep 17 00:00:00 2001 From: Azareal Date: Sun, 1 Sep 2019 11:37:04 +1000 Subject: [PATCH] Quick Convo Form. Be more tolerant of spaces when inputting participant names. Use a class instead of inline css for the Quick Topic Form Toggle. --- public/convo.js | 12 ++++++++++++ public/global.js | 4 ++-- routes/convos.go | 3 ++- templates/convos.html | 21 ++++++++++++++++++++- templates/forum.html | 26 +++++++++++++------------- templates/forum_gallery.html | 24 ++++++++++++------------ templates/topics.html | 4 ++-- themes/nox/public/convo.css | 6 ++++++ 8 files changed, 69 insertions(+), 31 deletions(-) create mode 100644 public/convo.js diff --git a/public/convo.js b/public/convo.js new file mode 100644 index 00000000..135f5dda --- /dev/null +++ b/public/convo.js @@ -0,0 +1,12 @@ +(() => { + addInitHook("end_init", () => { + $(".create_convo_link").click((event) => { + event.preventDefault(); + $(".convo_create_form").removeClass("auto_hide"); + }); + $(".convo_create_form .close_form").click((event) => { + event.preventDefault(); + $(".convo_create_form").addClass("auto_hide"); + }); + }); +})(); \ No newline at end of file diff --git a/public/global.js b/public/global.js index 711d6bb5..ece44a97 100644 --- a/public/global.js +++ b/public/global.js @@ -843,11 +843,11 @@ function mainInit(){ $(".create_topic_link").click((event) => { event.preventDefault(); - $(".topic_create_form").show(); + $(".topic_create_form").removeClass("auto_hide"); }); $(".topic_create_form .close_form").click((event) => { event.preventDefault(); - $(".topic_create_form").hide(); + $(".topic_create_form").addClass("auto_hide"); }); $("#themeSelectorSelect").change(function(){ diff --git a/routes/convos.go b/routes/convos.go index 360ae476..2f108b69 100644 --- a/routes/convos.go +++ b/routes/convos.go @@ -14,6 +14,7 @@ import ( func Convos(w http.ResponseWriter, r *http.Request, user c.User, header *c.Header) c.RouteError { accountEditHead("convos", w, r, &user, header) + header.AddScript("convo.js") header.AddSheet(header.Theme.Name + "/convo.css") header.AddNotice("convo_dev") ccount := c.Convos.GetUserCount(user.ID) @@ -124,7 +125,7 @@ func ConvosCreateSubmit(w http.ResponseWriter, r *http.Request, user c.User) c.R break } - u, err := c.Users.GetByName(recp) + u, err := c.Users.GetByName(strings.TrimSpace(recp)) if err == sql.ErrNoRows { return c.LocalError("One of the recipients doesn't exist", w, r, user) } else if err != nil { diff --git a/templates/convos.html b/templates/convos.html index f8fcd39f..072abdda 100644 --- a/templates/convos.html +++ b/templates/convos.html @@ -1,9 +1,28 @@

{{lang "convos_head"}}

- {{if not .CurrentUser.IsBanned}}

Create Convo

{{end}} + {{if not .CurrentUser.IsBanned}}

Create Convo

{{end}}
+{{if not .CurrentUser.IsBanned}} +
+
+
+ +
+
+
+
+
+
+
+ + +
+
+
+
+{{end}}
{{range .Convos}}
diff --git a/templates/forum.html b/templates/forum.html index 1bfe9f6e..3bd9c0fd 100644 --- a/templates/forum.html +++ b/templates/forum.html @@ -10,25 +10,25 @@

{{.Title}}

{{if .CurrentUser.Loggedin}} -
- {{if .CurrentUser.Perms.CreateTopic}} -
-
-
- {{/** TODO: Add a permissions check for this **/}} -
- -
- {{else}}
{{end}} +
+ {{if .CurrentUser.Perms.CreateTopic}} +
+
+
+ {{/** TODO: Add a permissions check for this **/}} +
+
-
- {{end}} + {{else}}
{{end}} +
+
+ {{end}}
{{if .CurrentUser.Loggedin}} {{template "topics_mod_floater.html"}} {{if .CurrentUser.Perms.CreateTopic}} -