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.
This commit is contained in:
Azareal 2019-09-01 11:37:04 +10:00
parent 4e166df3e2
commit 57712e0cb5
8 changed files with 69 additions and 31 deletions

12
public/convo.js Normal file
View File

@ -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");
});
});
})();

View File

@ -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(){

View File

@ -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 {

View File

@ -1,9 +1,28 @@
<div class="colstack_item colstack_head rowhead">
<div class="rowitem">
<h1>{{lang "convos_head"}}</h1>
{{if not .CurrentUser.IsBanned}}<h2><a href="/user/convos/create/">Create Convo</a></h2>{{end}}
{{if not .CurrentUser.IsBanned}}<h2><a class="create_convo_link" href="/user/convos/create/">Create Convo</a></h2>{{end}}
</div>
</div>
{{if not .CurrentUser.IsBanned}}
<div class="colstack_item the_form convo_create_form auto_hide">
<form action="/user/convos/create/submit/?s={{.CurrentUser.Session}}" method="post">
<div class="formrow real_first_child">
<div class="formitem formlabel"><a>Recipient/s</a></div>
<div class="formitem"><input name="recp" type="text" /></div>
</div>
<div class="formrow">
<div class="formitem"><textarea name="body"></textarea></div>
</div>
<div class="formrow">
<div class="formitem">
<button name="panel-button" class="formbutton form_middle_button">{{lang "create_convo_button"}}</button>
<button class="formbutton close_form">{{lang "quick_topic.cancel_button"}}</button>
</div>
</div>
</form>
</div>
{{end}}
<div class="colstack_item convos_list">
{{range .Convos}}
<div class="rowitem">

View File

@ -10,25 +10,25 @@
<h1 itemprop="name">{{.Title}}</h1>
</div>
{{if .CurrentUser.Loggedin}}
<div class="optbox">
{{if .CurrentUser.Perms.CreateTopic}}
<div class="opt dummy_opt"></div>
<div class="pre_opt auto_hide"></div>
<div class="opt create_topic_opt" title="{{lang "topic_list.create_topic_tooltip"}}" aria-label="{{lang "topic_list.create_topic_aria"}}"><a class="create_topic_link" href="/topics/create/{{.Forum.ID}}"></a></div>
{{/** TODO: Add a permissions check for this **/}}
<div class="opt mod_opt" title="{{lang "topic_list.moderate_tooltip"}}">
<a class="moderate_link" href="#" aria-label="{{lang "topic_list.moderate_aria"}}"></a>
</div>
{{else}}<div class="opt locked_opt" title="{{lang "forum_locked_tooltip"}}" aria-label="{{lang "forum_locked_aria"}}"><a></a></div>{{end}}
<div class="optbox">
{{if .CurrentUser.Perms.CreateTopic}}
<div class="opt dummy_opt"></div>
<div class="pre_opt auto_hide"></div>
<div class="opt create_topic_opt" title="{{lang "topic_list.create_topic_tooltip"}}" aria-label="{{lang "topic_list.create_topic_aria"}}"><a class="create_topic_link" href="/topics/create/{{.Forum.ID}}"></a></div>
{{/** TODO: Add a permissions check for this **/}}
<div class="opt mod_opt" title="{{lang "topic_list.moderate_tooltip"}}">
<a class="moderate_link" href="#" aria-label="{{lang "topic_list.moderate_aria"}}"></a>
</div>
<div style="clear:both;"></div>
{{end}}
{{else}}<div class="opt locked_opt" title="{{lang "forum_locked_tooltip"}}" aria-label="{{lang "forum_locked_aria"}}"><a></a></div>{{end}}
</div>
<div style="clear:both;"></div>
{{end}}
</div>
{{if .CurrentUser.Loggedin}}
{{template "topics_mod_floater.html"}}
{{if .CurrentUser.Perms.CreateTopic}}
<div id="forum_topic_create_form" class="rowblock topic_create_form quick_create_form" style="display:none;" aria-label="{{lang "quick_topic.aria"}}">
<div id="forum_topic_create_form" class="rowblock topic_create_form quick_create_form auto_hide" aria-label="{{lang "quick_topic.aria"}}">
<form id="quick_post_form" enctype="multipart/form-data" action="/topic/create/submit/?s={{.CurrentUser.Session}}" method="post"></form>
<img class="little_row_avatar" src="{{.CurrentUser.MicroAvatar}}" height=64 alt="{{lang "quick_topic.avatar_alt"}}" title="{{lang "quick_topic.avatar_tooltip"}}" />
<input form="quick_post_form" id="topic_board_input" name="topic-board" value="{{.Forum.ID}}" type="hidden">

View File

@ -8,25 +8,25 @@
<h1 itemprop="name">{{.Title}}</h1>
</div>
{{if .CurrentUser.Loggedin}}
<div class="optbox">
{{if .CurrentUser.Perms.CreateTopic}}
<div class="opt dummy_opt"></div>
<div class="pre_opt auto_hide"></div>
<div class="opt create_topic_opt" title="{{lang "topic_list.create_topic_tooltip"}}" aria-label="{{lang "topic_list.create_topic_aria"}}"><a class="create_topic_link" href="/topics/create/{{.Forum.ID}}"></a></div>
{{/** TODO: Add a permissions check for this **/}}
<div class="opt mod_opt" title="{{lang "topic_list.moderate_tooltip"}}">
<a class="moderate_link" href="#" aria-label="{{lang "topic_list.moderate_aria"}}"></a>
</div>
{{else}}<div class="opt locked_opt" title="{{lang "forum_locked_tooltip"}}" aria-label="{{lang "forum_locked_aria"}}"><a></a></div>{{end}}
<div class="optbox">
{{if .CurrentUser.Perms.CreateTopic}}
<div class="opt dummy_opt"></div>
<div class="pre_opt auto_hide"></div>
<div class="opt create_topic_opt" title="{{lang "topic_list.create_topic_tooltip"}}" aria-label="{{lang "topic_list.create_topic_aria"}}"><a class="create_topic_link" href="/topics/create/{{.Forum.ID}}"></a></div>
{{/** TODO: Add a permissions check for this **/}}
<div class="opt mod_opt" title="{{lang "topic_list.moderate_tooltip"}}">
<a class="moderate_link" href="#" aria-label="{{lang "topic_list.moderate_aria"}}"></a>
</div>
<div style="clear:both;"></div>
{{else}}<div class="opt locked_opt" title="{{lang "forum_locked_tooltip"}}" aria-label="{{lang "forum_locked_aria"}}"><a></a></div>{{end}}
</div>
<div style="clear:both;"></div>
{{end}}
</div>
{{if .CurrentUser.Loggedin}}
{{template "topics_mod_floater.html"}}
{{if .CurrentUser.Perms.CreateTopic}}
<div id="forum_topic_create_form" class="rowblock topic_create_form quick_create_form" style="display:none;" aria-label="{{lang "quick_topic.aria"}}">
<div id="forum_topic_create_form" class="rowblock topic_create_form quick_create_form auto_hide" aria-label="{{lang "quick_topic.aria"}}">
<form id="quick_post_form" enctype="multipart/form-data" action="/topic/create/submit/?s={{.CurrentUser.Session}}" method="post"></form>
<img class="little_row_avatar" src="{{.CurrentUser.MicroAvatar}}" height=64 alt="{{lang "quick_topic.avatar_alt"}}" title="{{lang "quick_topic.avatar_tooltip"}}" />
<input form="quick_post_form" id="topic_board_input" name="topic-board" value="{{.Forum.ID}}" type="hidden">

View File

@ -53,14 +53,14 @@
</div>
</form>
</div>
<div class="rowblock topic_create_form quick_create_form" style="display:none;" aria-label="{{lang "quick_topic.aria"}}">
<div class="rowblock topic_create_form quick_create_form auto_hide" aria-label="{{lang "quick_topic.aria"}}">
<form name="topic_create_form_form" id="quick_post_form" enctype="multipart/form-data" action="/topic/create/submit/?s={{.CurrentUser.Session}}" method="post"></form>
<img class="little_row_avatar" src="{{.CurrentUser.MicroAvatar}}" height=64 alt="{{lang "quick_topic.avatar_alt"}}" title="{{lang "quick_topic.avatar_tooltip"}}" />
<div class="main_form">
<div class="topic_meta">
<div class="formrow topic_board_row real_first_child">
<div class="formitem"><select form="quick_post_form" id="topic_board_input" name="topic-board">
{{range .ForumList}}<option {{if eq .ID $.DefaultForum}}selected{{end}} value="{{.ID}}">{{.Name}}</option>{{end}}
{{range .ForumList}}<option{{if eq .ID $.DefaultForum}} selected{{end}} value="{{.ID}}">{{.Name}}</option>{{end}}
</select></div>
</div>
<div class="formrow topic_name_row">

View File

@ -2,6 +2,12 @@
.convos_list .rowitem {
display: flex;
}
.convo_create_form {
margin-bottom: 8px;
}
.close_form {
margin-left: 8px;
}
.convos_item_user:not(:last-child):after {
content: ",";
}