fix quoting on ajax topic load

apply #back classes properly on ajax topic load
This commit is contained in:
Azareal 2020-03-11 17:08:27 +10:00
parent d43bffdec5
commit d3336245d5
6 changed files with 56 additions and 41 deletions

View File

@ -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 = "<blockquote>" + source.innerHTML + "</blockquote>"
else item = "\r\n<blockquote>" + source.innerHTML + "</blockquote>";
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");
@ -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 = "<blockquote>" + src.innerHTML + "</blockquote>"
else item = "\r\n<blockquote>" + src.innerHTML + "</blockquote>";
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");
}

View File

@ -1,2 +1,7 @@
<div id="back" class="zone_{{.Header.Zone}}{{if hasWidgets "rightSidebar" .Header }} shrink_main{{end}}">
<div id="main">
<div class="alertbox initial_alertbox">{{range .Header.NoticeList}}{{template "notice.html" . }}{{end}}</div>
{{template "topic_alt_inner.html" . }}
</div>
<aside class="midRight sidebar">{{dock "rightSidebar" .Header}}</aside>
</div>

View File

@ -1,2 +1,7 @@
<div id="back" class="zone_{{.Header.Zone}}{{if hasWidgets "rightSidebar" .Header }} shrink_main{{end}}">
<div id="main">
<div class="alertbox initial_alertbox">{{range .Header.NoticeList}}{{template "notice.html" . }}{{end}}</div>
{{template "topic_inner.html" . }}
</div>
<aside class="midRight sidebar">{{dock "rightSidebar" .Header}}</aside>
</div>