From ebd8454b5556af2b9b6ebfa70a0af0248e3246c2 Mon Sep 17 00:00:00 2001 From: Kerrick Long Date: Fri, 15 Jul 2011 19:21:10 -0500 Subject: [PATCH] Comment is cached in case the popup closes --- js/common.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/js/common.js b/js/common.js index 799c6c5..8581ef1 100644 --- a/js/common.js +++ b/js/common.js @@ -788,3 +788,22 @@ Popup.prototype.showCommentForm = function (postId) { document.getElementById(postId).getElementsByClassName('comment')[0].style.display = 'block'; return true; }; + +/** + * Cache a comment for a given post. + * @alias Popup.cacheComment(event) + * @param {Object} event The event object of the keyup. + * @return {Boolean} Returns true. + * @method + */ +Popup.prototype.cacheComment = function (e) { + var value, postId, url, oldCache; + + value = e.srcElement.value; + postId = e.srcElement.parentNode.parentNode.parentNode.id + url = e.srcElement.parentNode.parentNode.parentNode.parentNode.getAttribute('data-url'); + oldCache = cache.get(url); + oldCache.posts[postId].savedCommentText = value; + cache.set(url, oldCache); + return true; +};