hide avatar during editing

This commit is contained in:
Martin Zimmermann 2014-05-27 14:27:19 +02:00
parent 0211322915
commit 16663d44f8
2 changed files with 25 additions and 3 deletions

View File

@ -91,14 +91,26 @@ define(function() {
this.parentNode.removeChild(this); this.parentNode.removeChild(this);
}; };
var DOM = function(query, root) { window.Element.prototype.show = function() {
this.style.display = "block";
};
window.Element.prototype.hide = function() {
this.style.display = "none";
};
var DOM = function(query, root, single) {
/* /*
jQuery-like CSS selector which returns on :param query: either a jQuery-like CSS selector which returns on :param query: either a
single node, a node list or null. single node (unless single=false), a node list or null.
:param root: only queries within the given element. :param root: only queries within the given element.
*/ */
if (typeof single === "undefined") {
single = true;
}
if (! root) { if (! root) {
root = window.document; root = window.document;
} }
@ -109,7 +121,7 @@ define(function() {
return null; return null;
} }
if (elements.length === 1) { if (elements.length === 1 && single) {
return elements[0]; return elements[0];
} }

View File

@ -176,6 +176,7 @@ define(["app/dom", "app/utils", "app/config", "app/api", "app/jade", "app/i18n",
$("a.edit", footer).toggle("click", $("a.edit", footer).toggle("click",
function(toggler) { function(toggler) {
var edit = $("a.edit", footer); var edit = $("a.edit", footer);
var avatar = $(".avatar", el, false)[0];
edit.textContent = i18n.translate("comment-save"); edit.textContent = i18n.translate("comment-save");
edit.insertAfter($.new("a.cancel", i18n.translate("comment-cancel"))).on("click", function() { edit.insertAfter($.new("a.cancel", i18n.translate("comment-cancel"))).on("click", function() {
@ -196,9 +197,14 @@ define(["app/dom", "app/utils", "app/config", "app/api", "app/jade", "app/i18n",
text.textContent = ""; text.textContent = "";
text.append(textarea); text.append(textarea);
}); });
if (avatar !== null) {
avatar.hide();
}
}, },
function(toggler) { function(toggler) {
var textarea = $(".textarea", text); var textarea = $(".textarea", text);
var avatar = $(".avatar", el, false)[0];
if (! toggler.canceled && textarea !== null) { if (! toggler.canceled && textarea !== null) {
if (utils.text(textarea.innerHTML).length < 3) { if (utils.text(textarea.innerHTML).length < 3) {
@ -218,6 +224,10 @@ define(["app/dom", "app/utils", "app/config", "app/api", "app/jade", "app/i18n",
text.classList.remove("textarea-wrapper"); text.classList.remove("textarea-wrapper");
text.classList.add("text"); text.classList.add("text");
if (avatar !== null) {
avatar.show();
}
$("a.cancel", footer).remove(); $("a.cancel", footer).remove();
$("a.edit", footer).textContent = i18n.translate("comment-edit"); $("a.edit", footer).textContent = i18n.translate("comment-edit");
} }