From d3336245d5a9eade0a61153b3267c3a73747939e Mon Sep 17 00:00:00 2001 From: Azareal Date: Wed, 11 Mar 2020 17:08:27 +1000 Subject: [PATCH] fix quoting on ajax topic load apply #back classes properly on ajax topic load --- public/global.js | 59 +++++++++++++++++++---------------- templates/header.html | 18 +++++------ templates/menu_item.html | 2 +- templates/topic_alt_mini.html | 7 ++++- templates/topic_inner.html | 4 +-- templates/topic_mini.html | 7 ++++- 6 files changed, 56 insertions(+), 41 deletions(-) diff --git a/public/global.js b/public/global.js index 993e33f4..ce3379bc 100644 --- a/public/global.js +++ b/public/global.js @@ -620,7 +620,7 @@ function mainInit(){ }); }); - bindTopic(); + bindPage(); $(".edit_field").click(function(ev) { ev.preventDefault(); @@ -711,23 +711,6 @@ function mainInit(){ }); }); - $(".quote_item").click(function(){ - event.preventDefault(); - event.stopPropagation(); - let source = this.closest(".post_item").getElementsByClassName("edit_source")[0]; - let content = document.getElementById("input_content") - console.log("content.value", content.value); - - let item; - if(content.value == "") item = "
" + source.innerHTML + "
" - else item = "\r\n
" + source.innerHTML + "
"; - content.value = content.value + item; - console.log("content.value", content.value); - - // For custom / third party text editors - quoteItemCallback(source.innerHTML,item); - }); - $(this).click(() => { $(".selectedAlert").removeClass("selectedAlert"); $("#back").removeClass("alertActive"); @@ -772,9 +755,9 @@ function mainInit(){ error: ajaxError, success: function (data,status,xhr) { console.log("Theme successfully switched"); - console.log("data", data); - console.log("status", status); - console.log("xhr", xhr); + console.log("data",data); + console.log("status",status); + console.log("xhr",xhr); window.location.reload(); } }); @@ -868,14 +851,10 @@ function mainInit(){ if(!resp.ok) throw(href+" failed to load"); return resp.text(); }).then(data => { - let el = document.createElement("div"); - el.innerHTML = data; - console.log("el",el); - document.querySelector("main").outerHTML = el.children[0].innerHTML; - //$(".sidebar").html(el.children[1]); - document.querySelector(".sidebar").outerHTML = el.children[1].outerHTML; + document.querySelector("#back").outerHTML = data; unbindTopic(); bindTopic(); + $(".elapsed").remove(); let obj = {Title: document.title, Url: base}; history.pushState(obj, obj.Title, obj.Url); }).catch(ex => { @@ -892,6 +871,14 @@ function mainInit(){ runInitHook("end_init"); } +function bindPage() { + bindTopic(); +} + +function unbindPage() { + unbindTopic(); +} + function bindTopic() { $(".open_edit").click(ev => { ev.preventDefault(); @@ -997,6 +984,23 @@ function bindTopic() { }); }); }); + + $(".quote_item").click(function(ev){ + ev.preventDefault(); + ev.stopPropagation(); + let src = this.closest(".post_item").getElementsByClassName("edit_source")[0]; + let content = document.getElementById("input_content") + console.log("content.value", content.value); + + let item; + if(content.value == "") item = "
" + src.innerHTML + "
" + else item = "\r\n
" + src.innerHTML + "
"; + content.value = content.value + item; + console.log("content.value", content.value); + + // For custom / third party text editors + quoteItemCallback(src.innerHTML,item); + }); } function unbindTopic() { @@ -1005,4 +1009,5 @@ function unbindTopic() { $(".delete_item").unbind("click"); $(".edit_item").unbind("click"); $(".submit_edit").unbind("click"); + $(".quote_item").unbind("click"); } \ No newline at end of file diff --git a/templates/header.html b/templates/header.html index a921413d..3f5e8e1b 100644 --- a/templates/header.html +++ b/templates/header.html @@ -14,15 +14,15 @@ {{range .Header.Scripts}} {{end}} - {{if .Header.MetaDesc}}{{end}} + {{if .Header.MetaDesc}}{{end}} {{/** TODO: Have page / forum / topic level tags and descriptions below as-well **/}} - - - - - {{if .OGDesc}} - {{end}} - {{if .GoogSiteVerify}}{{end}} + + + + + {{if .OGDesc}} + {{end}} + {{if .GoogSiteVerify}}{{end}} @@ -47,7 +47,7 @@
- {{.CurrentUser.Name}} + {{.CurrentUser.Name}} {{lang "alerts.no_alerts_short"}}
diff --git a/templates/menu_item.html b/templates/menu_item.html index 92bd1235..265a3c52 100644 --- a/templates/menu_item.html +++ b/templates/menu_item.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/templates/topic_alt_mini.html b/templates/topic_alt_mini.html index 3b004f8f..8f4b1be7 100644 --- a/templates/topic_alt_mini.html +++ b/templates/topic_alt_mini.html @@ -1,2 +1,7 @@ +
+
+
{{range .Header.NoticeList}}{{template "notice.html" . }}{{end}}
{{template "topic_alt_inner.html" . }} - \ No newline at end of file +
+ +
\ No newline at end of file diff --git a/templates/topic_inner.html b/templates/topic_inner.html index 41d03ae3..4ab5855d 100644 --- a/templates/topic_inner.html +++ b/templates/topic_inner.html @@ -1,11 +1,11 @@
{{if gt .Page 1}} -{{end}} +{{end}} {{if ne .LastPage .Page}} {{end}} diff --git a/templates/topic_mini.html b/templates/topic_mini.html index 04a2bb33..4d6c2039 100644 --- a/templates/topic_mini.html +++ b/templates/topic_mini.html @@ -1,2 +1,7 @@ +
+
+
{{range .Header.NoticeList}}{{template "notice.html" . }}{{end}}
{{template "topic_inner.html" . }} - \ No newline at end of file +
+ +
\ No newline at end of file