Use a client template for poll input.

Tweak the poll input phrase.
Increase the padding on .pollinput for Nox.
This commit is contained in:
Azareal 2019-06-16 17:26:31 +10:00
parent a5441f18de
commit 89c8f4e775
10 changed files with 27 additions and 9 deletions

View File

@ -177,6 +177,9 @@ type TopicCAttachItem struct {
Path string Path string
FullPath string FullPath string
} }
type TopicCPollInput struct {
Index int
}
type TopicPage struct { type TopicPage struct {
*Header *Header

View File

@ -275,6 +275,7 @@ func PrepResources(user *User, header *Header, theme *Theme) {
if user.Loggedin { if user.Loggedin {
addPreScript("topic_c_edit_post") addPreScript("topic_c_edit_post")
addPreScript("topic_c_attach_item") addPreScript("topic_c_attach_item")
addPreScript("topic_c_poll_input")
} }
} }

View File

@ -43,7 +43,8 @@ type CTmpl struct {
func genIntTmpl(name string) func(pi interface{}, w io.Writer) error { func genIntTmpl(name string) func(pi interface{}, w io.Writer) error {
return func(pi interface{}, w io.Writer) error { return func(pi interface{}, w io.Writer) error {
mapping, ok := Themes[DefaultThemeBox.Load().(string)].TemplatesMap[name] theme := Themes[DefaultThemeBox.Load().(string)]
mapping, ok := theme.TemplatesMap[name]
if !ok { if !ok {
mapping = name mapping = name
} }
@ -531,8 +532,8 @@ func compileJSTemplates(wg *sync.WaitGroup, c *tmpl.CTemplateSet, themeName stri
tmpls.AddStd("paginator", "common.Paginator", Paginator{pageList, page, lastPage}) tmpls.AddStd("paginator", "common.Paginator", Paginator{pageList, page, lastPage})
tmpls.AddStd("topic_c_edit_post", "common.TopicCEditPost", TopicCEditPost{ID: 0, Source: "", Ref: ""}) tmpls.AddStd("topic_c_edit_post", "common.TopicCEditPost", TopicCEditPost{ID: 0, Source: "", Ref: ""})
tmpls.AddStd("topic_c_attach_item", "common.TopicCAttachItem", TopicCAttachItem{ID: 1, ImgSrc: "", Path: "", FullPath: ""}) tmpls.AddStd("topic_c_attach_item", "common.TopicCAttachItem", TopicCAttachItem{ID: 1, ImgSrc: "", Path: "", FullPath: ""})
tmpls.AddStd("topic_c_poll_input", "common.TopicCPollInput", TopicCPollInput{Index:0})
tmpls.AddStd("notice", "string", "nonono") tmpls.AddStd("notice", "string", "nonono")

View File

@ -546,7 +546,7 @@
"quick_topic.avatar_alt":"Your Avatar", "quick_topic.avatar_alt":"Your Avatar",
"quick_topic.whatsup":"What's up?", "quick_topic.whatsup":"What's up?",
"quick_topic.content_placeholder":"Insert post here", "quick_topic.content_placeholder":"Insert post here",
"quick_topic.add_poll_option":"Add new poll option", "quick_topic.add_poll_option":"Poll option",
"quick_topic.create_topic_button":"Create Topic", "quick_topic.create_topic_button":"Create Topic",
"quick_topic.create_topic_button_short":"New Topic", "quick_topic.create_topic_button_short":"New Topic",
"quick_topic.add_poll_button":"Add Poll", "quick_topic.add_poll_button":"Add Poll",
@ -653,7 +653,7 @@
"topic.reply_aria":"The quick reply form", "topic.reply_aria":"The quick reply form",
"topic.reply_content":"Insert reply here", "topic.reply_content":"Insert reply here",
"topic.reply_content_alt":"What do you think?", "topic.reply_content_alt":"What do you think?",
"topic.reply_add_poll_option":"Add new poll option", "topic.reply_add_poll_option":"Poll option",
"topic.reply_button":"Create Reply", "topic.reply_button":"Create Reply",
"topic.reply_add_poll_button":"Add Poll", "topic.reply_add_poll_button":"Add Poll",
"topic.reply_add_file_button":"Add File", "topic.reply_add_file_button":"Add File",

View File

@ -231,9 +231,10 @@ function fetchPhrases(plist) {
if(!panel) { if(!panel) {
toLoad += 2; toLoad += 2;
if(loggedIn) { if(loggedIn) {
toLoad += 2; toLoad += 3;
notifyOnScriptW("template_topic_c_edit_post", () => q(!Template_topic_c_edit_post)); notifyOnScriptW("template_topic_c_edit_post", () => q(!Template_topic_c_edit_post));
notifyOnScriptW("template_topic_c_attach_item", () => q(!Template_topic_c_attach_item)); notifyOnScriptW("template_topic_c_attach_item", () => q(!Template_topic_c_attach_item));
notifyOnScriptW("template_topic_c_poll_input", () => q(!Template_topic_c_poll_input));
} }
notifyOnScriptW("template_topics_topic", () => q(!Template_topics_topic)); notifyOnScriptW("template_topics_topic", () => q(!Template_topics_topic));
notifyOnScriptW("template_paginator", () => q(!Template_paginator)); notifyOnScriptW("template_paginator", () => q(!Template_paginator));

View File

@ -284,8 +284,9 @@
console.log("dataPollInput: ", dataPollInput); console.log("dataPollInput: ", dataPollInput);
if(dataPollInput == undefined) return; if(dataPollInput == undefined) return;
if(dataPollInput != (pollInputIndex-1)) return; if(dataPollInput != (pollInputIndex-1)) return;
$(".poll_content_row .formitem").append(Template_topic_c_poll_input({
$(".poll_content_row .formitem").append("<div class='pollinput' data-pollinput='"+pollInputIndex+"'><input type='checkbox' disabled /><label class='pollinputlabel'></label><input form='quick_post_form' name='pollinputitem["+pollInputIndex+"]' class='pollinputinput' type='text' placeholder='Add new poll option' /></div>"); Index: pollInputIndex,
}));
pollInputIndex++; pollInputIndex++;
console.log("new pollInputIndex: ", pollInputIndex); console.log("new pollInputIndex: ", pollInputIndex);
$(".pollinputinput").off("click"); $(".pollinputinput").off("click");

View File

@ -7,7 +7,7 @@
{{range .Header.PreScriptsAsync}} {{range .Header.PreScriptsAsync}}
<script async type="text/javascript" src="/static/{{.}}"></script>{{end}} <script async type="text/javascript" src="/static/{{.}}"></script>{{end}}
<meta property="x-loggedin" content="{{.CurrentUser.Loggedin}}" /> <meta property="x-loggedin" content="{{.CurrentUser.Loggedin}}" />
<script type="text/javascript" src="/static/init.js?i=6"></script> <script type="text/javascript" src="/static/init.js?i=7"></script>
{{range .Header.ScriptsAsync}} {{range .Header.ScriptsAsync}}
<script async type="text/javascript" src="/static/{{.}}"></script>{{end}} <script async type="text/javascript" src="/static/{{.}}"></script>{{end}}
<script type="text/javascript" src="/static/jquery-3.1.1.min.js"></script> <script type="text/javascript" src="/static/jquery-3.1.1.min.js"></script>

View File

@ -0,0 +1,5 @@
<div class='pollinput' data-pollinput='{{.Index}}'>
<input type='checkbox' disabled />
<label class='pollinputlabel'></label>
<input form='quick_post_form' name='pollinputitem[{{.Index}}]' class='pollinputinput' type='text' placeholder='{{lang "topic.reply_add_poll_option"}}' />
</div>

View File

@ -978,6 +978,12 @@ input[type=checkbox]:checked + label .sel {
.poll_results { .poll_results {
margin-left: 12px; margin-left: 12px;
} }
.pollinput {
margin-bottom: 5px;
}
.pollinput:last-child {
margin-bottom: 12px;
}
.ip_item { .ip_item {
display: none; display: none;