scoll into view

This commit is contained in:
Martin Zimmermann 2013-09-08 17:24:54 +02:00
parent f0c1574c15
commit aecab5cf01
2 changed files with 9 additions and 3 deletions

View File

@ -16,6 +16,7 @@ define(["lib/HTML", "./logging"], function(HTML, logging) {
textarea.placeholder = "Kommentar hier eintippen (andere Felder sind optional)" textarea.placeholder = "Kommentar hier eintippen (andere Felder sind optional)"
textarea.onfocus = function() { textarea.onfocus = function() {
textarea.rows = 10 textarea.rows = 10
form.scrollIntoView(false);
}; };
textarea.onblur = function() { setTimeout(function() { textarea.onblur = function() { setTimeout(function() {
if (textarea.value == "" && document.activeElement != textarea) { if (textarea.value == "" && document.activeElement != textarea) {

View File

@ -12,7 +12,7 @@ define(["lib/q", "lib/HTML", "helper/utils", "./api", "./forms", "./logging"], f
email: "info@example.org", website: "..." email: "info@example.org", website: "..."
}; };
var insert = function(comment) { var insert = function(comment, scrollIntoView) {
/* /*
* insert a comment (JSON/object) into the #isso-thread or below a parent (#isso-N), renders some HTML and * insert a comment (JSON/object) into the #isso-thread or below a parent (#isso-N), renders some HTML and
* registers events to reply to, edit and remove a comment. * registers events to reply to, edit and remove a comment.
@ -63,6 +63,10 @@ define(["lib/q", "lib/HTML", "helper/utils", "./api", "./forms", "./logging"], f
node.footer.add("a.liek{Liek}").href = "#"; node.footer.add("a.liek{Liek}").href = "#";
node.footer.add("a.reply{Antworten}").href = "#"; node.footer.add("a.reply{Antworten}").href = "#";
if (scrollIntoView) {
node.scrollIntoView(false);
}
if (utils.read(window.location.pathname + "-" + comment.id)) { if (utils.read(window.location.pathname + "-" + comment.id)) {
node.footer.add("a.delete{Löschen}").href = "#"; node.footer.add("a.delete{Löschen}").href = "#";
node.footer.add("a.edit{Bearbeiten}").href = "#"; node.footer.add("a.edit{Bearbeiten}").href = "#";
@ -131,10 +135,11 @@ define(["lib/q", "lib/HTML", "helper/utils", "./api", "./forms", "./logging"], f
} }
var msgbox = forms.msgbox({}) var msgbox = forms.msgbox({})
HTML.query("#isso-" + comment.id).footer.appendChild(msgbox) HTML.query("#isso-" + comment.id).footer.appendChild(msgbox);
HTML.query("#isso-" + comment.id).classList.add("isso-active-msgbox"); HTML.query("#isso-" + comment.id).classList.add("isso-active-msgbox");
HTML.query("#isso-" + comment.id + " a.reply").textContent = "Schließen"; HTML.query("#isso-" + comment.id + " a.reply").textContent = "Schließen";
msgbox.scrollIntoView(false);
msgbox.query("input[type=submit]").addEventListener("click", function(event) { msgbox.query("input[type=submit]").addEventListener("click", function(event) {
forms.validate(msgbox) && api.create({ forms.validate(msgbox) && api.create({
author: msgbox.query("[name=author]").value, author: msgbox.query("[name=author]").value,
@ -147,7 +152,7 @@ define(["lib/q", "lib/HTML", "helper/utils", "./api", "./forms", "./logging"], f
msgbox.parentNode.parentNode.classList.remove("isso-active-msgbox"); msgbox.parentNode.parentNode.classList.remove("isso-active-msgbox");
msgbox.parentNode.parentNode.query("a.reply").textContent = "Antworten" msgbox.parentNode.parentNode.query("a.reply").textContent = "Antworten"
msgbox.remove() msgbox.remove()
insert(rv); insert(rv, true);
}) })
event.preventDefault() event.preventDefault()
}); });