From 89c8f4e775714157d23316ee81b28700ef27b456 Mon Sep 17 00:00:00 2001 From: Azareal Date: Sun, 16 Jun 2019 17:26:31 +1000 Subject: [PATCH] Use a client template for poll input. Tweak the poll input phrase. Increase the padding on .pollinput for Nox. --- common/pages.go | 3 +++ common/routes_common.go | 1 + common/template_init.go | 5 +++-- langs/english.json | 4 ++-- public/init.js | 3 ++- public/member.js | 5 +++-- templates/header.html | 2 +- templates/topic_c_poll_input.html | 5 +++++ templates/topics.html | 2 +- themes/nox/public/main.css | 6 ++++++ 10 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 templates/topic_c_poll_input.html diff --git a/common/pages.go b/common/pages.go index 42af2971..6304116b 100644 --- a/common/pages.go +++ b/common/pages.go @@ -177,6 +177,9 @@ type TopicCAttachItem struct { Path string FullPath string } +type TopicCPollInput struct { + Index int +} type TopicPage struct { *Header diff --git a/common/routes_common.go b/common/routes_common.go index 30abc487..2026061b 100644 --- a/common/routes_common.go +++ b/common/routes_common.go @@ -275,6 +275,7 @@ func PrepResources(user *User, header *Header, theme *Theme) { if user.Loggedin { addPreScript("topic_c_edit_post") addPreScript("topic_c_attach_item") + addPreScript("topic_c_poll_input") } } diff --git a/common/template_init.go b/common/template_init.go index cfeda353..251301ca 100644 --- a/common/template_init.go +++ b/common/template_init.go @@ -43,7 +43,8 @@ type CTmpl struct { func genIntTmpl(name string) 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 { 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("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_poll_input", "common.TopicCPollInput", TopicCPollInput{Index:0}) tmpls.AddStd("notice", "string", "nonono") diff --git a/langs/english.json b/langs/english.json index 4b402049..0bff7b7d 100644 --- a/langs/english.json +++ b/langs/english.json @@ -546,7 +546,7 @@ "quick_topic.avatar_alt":"Your Avatar", "quick_topic.whatsup":"What's up?", "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_short":"New Topic", "quick_topic.add_poll_button":"Add Poll", @@ -653,7 +653,7 @@ "topic.reply_aria":"The quick reply form", "topic.reply_content":"Insert reply here", "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_add_poll_button":"Add Poll", "topic.reply_add_file_button":"Add File", diff --git a/public/init.js b/public/init.js index 13c8e155..de3c048a 100644 --- a/public/init.js +++ b/public/init.js @@ -231,9 +231,10 @@ function fetchPhrases(plist) { if(!panel) { toLoad += 2; if(loggedIn) { - toLoad += 2; + toLoad += 3; 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_poll_input", () => q(!Template_topic_c_poll_input)); } notifyOnScriptW("template_topics_topic", () => q(!Template_topics_topic)); notifyOnScriptW("template_paginator", () => q(!Template_paginator)); diff --git a/public/member.js b/public/member.js index 96687ce0..a26501b6 100644 --- a/public/member.js +++ b/public/member.js @@ -284,8 +284,9 @@ console.log("dataPollInput: ", dataPollInput); if(dataPollInput == undefined) return; if(dataPollInput != (pollInputIndex-1)) return; - - $(".poll_content_row .formitem").append("
"); + $(".poll_content_row .formitem").append(Template_topic_c_poll_input({ + Index: pollInputIndex, + })); pollInputIndex++; console.log("new pollInputIndex: ", pollInputIndex); $(".pollinputinput").off("click"); diff --git a/templates/header.html b/templates/header.html index 092c8d35..84152c4d 100644 --- a/templates/header.html +++ b/templates/header.html @@ -7,7 +7,7 @@ {{range .Header.PreScriptsAsync}} {{end}} - + {{range .Header.ScriptsAsync}} {{end}} diff --git a/templates/topic_c_poll_input.html b/templates/topic_c_poll_input.html new file mode 100644 index 00000000..830d700b --- /dev/null +++ b/templates/topic_c_poll_input.html @@ -0,0 +1,5 @@ +
+ + + +
\ No newline at end of file diff --git a/templates/topics.html b/templates/topics.html index bd7affb1..c5ad5355 100644 --- a/templates/topics.html +++ b/templates/topics.html @@ -27,7 +27,7 @@ {{else}}
{{end}} -
+
{{end}} diff --git a/themes/nox/public/main.css b/themes/nox/public/main.css index c781c6c3..62e88d4b 100644 --- a/themes/nox/public/main.css +++ b/themes/nox/public/main.css @@ -978,6 +978,12 @@ input[type=checkbox]:checked + label .sel { .poll_results { margin-left: 12px; } +.pollinput { + margin-bottom: 5px; +} +.pollinput:last-child { + margin-bottom: 12px; +} .ip_item { display: none;