From 1ee24517e310674ff7e13351fbfa5a8734296d09 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 11 Oct 2013 20:55:31 -0400 Subject: [PATCH] enhanced the "discard post" confirmation message to only trigger if something in the post body actually changed --- public/src/modules/composer.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/public/src/modules/composer.js b/public/src/modules/composer.js index 5eee2aef2f..dae501565d 100644 --- a/public/src/modules/composer.js +++ b/public/src/modules/composer.js @@ -150,7 +150,8 @@ define(['taskbar'], function(taskbar) { cid: threadData.cid, pid: threadData.pid, title: threadData.title || '', - body: threadData.body || '' + body: threadData.body || '', + modified: false }; composer.load(uuid); } else { @@ -179,6 +180,9 @@ define(['taskbar'], function(taskbar) { var uuid = $(this).parents('.post-window')[0].getAttribute('data-uuid'); if (this.nodeName === 'INPUT') composer.posts[uuid].title = this.value; else if (this.nodeName === 'TEXTAREA') composer.posts[uuid].body = this.value; + + // Mark this post window as having been changed + composer.posts[uuid].modified = true; }); jPostContainer.on('click', '.action-bar button', function() { @@ -188,7 +192,7 @@ define(['taskbar'], function(taskbar) { case 'post': composer.post(uuid); break; case 'minimize': composer.minimize(uuid); break; case 'discard': - if (postContentEl.value.length > 0) { + if (composer.posts[uuid].modified) { bootbox.confirm('Are you sure you wish to discard this post?', function(discard) { if (discard) composer.discard(uuid); });