Editing replies now uses a client template instead of inline HTML in global.js
Added the topic_c_edit_post template.
This commit is contained in:
parent
3db09c6a1f
commit
d61ec9a6fe
|
@ -165,6 +165,11 @@ type CustomPagePage struct {
|
||||||
Page *CustomPage
|
Page *CustomPage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TopicCEditPost struct {
|
||||||
|
Source string
|
||||||
|
Ref string
|
||||||
|
}
|
||||||
|
|
||||||
type TopicPage struct {
|
type TopicPage struct {
|
||||||
*Header
|
*Header
|
||||||
ItemList []ReplyUser
|
ItemList []ReplyUser
|
||||||
|
|
|
@ -477,6 +477,8 @@ func compileJSTemplates(wg *sync.WaitGroup, c *tmpl.CTemplateSet, themeName stri
|
||||||
pageList := Paginate(20, itemsPerPage, 5)
|
pageList := Paginate(20, itemsPerPage, 5)
|
||||||
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{Source: "", Ref: ""})
|
||||||
|
|
||||||
var dirPrefix = "./tmpl_client/"
|
var dirPrefix = "./tmpl_client/"
|
||||||
var writeTemplate = func(name string, content string) {
|
var writeTemplate = func(name string, content string) {
|
||||||
log.Print("Writing template '" + name + "'")
|
log.Print("Writing template '" + name + "'")
|
||||||
|
|
|
@ -662,8 +662,10 @@ function mainInit(){
|
||||||
let source = "";
|
let source = "";
|
||||||
if(srcNode!=null) source = srcNode.innerText;
|
if(srcNode!=null) source = srcNode.innerText;
|
||||||
else source = block.innerHTML;
|
else source = block.innerHTML;
|
||||||
// TODO: Add a client template for this
|
block.innerHTML = Template_topic_c_edit_post({
|
||||||
block.innerHTML = "<textarea style='width: 99%;' name='edit_item'>" + source + "</textarea><br><a href='" + this.closest('a').getAttribute("href") + "'><button class='submit_edit' type='submit'>Update</button></a>";
|
Source: source,
|
||||||
|
Ref: this.closest('a').getAttribute("href")
|
||||||
|
})
|
||||||
runHook("edit_item_pre_bind");
|
runHook("edit_item_pre_bind");
|
||||||
|
|
||||||
$(".submit_edit").click(function(event){
|
$(".submit_edit").click(function(event){
|
||||||
|
|
|
@ -176,7 +176,7 @@ function RelativeTime(date) {
|
||||||
function initPhrases() {
|
function initPhrases() {
|
||||||
console.log("in initPhrases")
|
console.log("in initPhrases")
|
||||||
console.log("tmlInits:",tmplInits)
|
console.log("tmlInits:",tmplInits)
|
||||||
fetchPhrases("status,topic_list,alerts,paginator,analytics")
|
fetchPhrases("status,topic_list,topic,alerts,paginator,analytics") // TODO: Break this up?
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetchPhrases(plist) {
|
function fetchPhrases(plist) {
|
||||||
|
@ -224,6 +224,11 @@ function fetchPhrases(plist) {
|
||||||
if(toLoad===0) initPhrases();
|
if(toLoad===0) initPhrases();
|
||||||
if(!Template_paginator) throw("template function not found");
|
if(!Template_paginator) throw("template function not found");
|
||||||
});
|
});
|
||||||
|
notifyOnScriptW("template_topic_c_edit_post", () => {
|
||||||
|
toLoad--;
|
||||||
|
if(toLoad===0) initPhrases();
|
||||||
|
if(!Template_topic_c_edit_post) throw("template function not found");
|
||||||
|
});
|
||||||
|
|
||||||
let loggedIn = document.head.querySelector("[property='x-loggedin']").content;
|
let loggedIn = document.head.querySelector("[property='x-loggedin']").content;
|
||||||
if(loggedIn=="true") {
|
if(loggedIn=="true") {
|
||||||
|
|
|
@ -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"></script>
|
<script type="text/javascript" src="/static/init.js?i=0"></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>
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
<textarea style='width: 99%;' name='edit_item'>{{.Source}}</textarea><br>
|
||||||
|
<a href='{{.Ref}}'><button class='submit_edit' type='submit'>{{lang "topic.update_button"}}</button></a>
|
Loading…
Reference in New Issue