Node.js based forum software built for the modern web
fixed quoting and highlighted-text auto-quote for composer when composer is minimized, closes #2870
Julian Lam5587233e7880
diff --git a/public/src/client/topic/postTools.js b/public/src/client/topic/postTools.jsindex 6adf07d13e..4a227252a8 100644--- a/public/src/client/topic/postTools.js+++ b/public/src/client/topic/postTools.js@@ -137,7 +137,8 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translatorfunction onReplyClicked(button, tid, topicName) {require(['composer'], function(composer) {var selectionText = '',- selection = window.getSelection ? window.getSelection() : document.selection.createRange();+ selection = window.getSelection ? window.getSelection() : document.selection.createRange(),+ topicUUID = composer.findByTid(tid);if ($(selection.baseNode).parents('[component="post/content"]').length > 0) {var snippet = selection.toString();@@ -151,7 +152,7 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translatorusername = '';}if (selectionText.length) {- composer.addQuote(tid, ajaxify.variables.get('topic_slug'), getData(button, 'data-index'), getData(button, 'data-pid'), topicName, username, selectionText);+ composer.addQuote(tid, ajaxify.variables.get('topic_slug'), getData(button, 'data-index'), getData(button, 'data-pid'), topicName, username, selectionText, topicUUID);} else {composer.newReply(tid, getData(button, 'data-pid'), topicName, username ? username + ' ' : '');}@@ -162,7 +163,8 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translatorfunction onQuoteClicked(button, tid, topicName) {require(['composer'], function(composer) {var username = getUserName(button),- pid = getData(button, 'data-pid');+ pid = getData(button, 'data-pid'),+ topicUUID = composer.findByTid(tid);socket.emit('posts.getRawPost', pid, function(err, post) {if(err) {@@ -173,8 +175,8 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translatorquoted = '> ' + post.replace(/\n/g, '\n> ') + '\n\n';}- if($('.composer').length) {- composer.addQuote(tid, ajaxify.variables.get('topic_slug'), getData(button, 'data-index'), pid, topicName, username, quoted);+ if(topicUUID) {+ composer.addQuote(tid, ajaxify.variables.get('topic_slug'), getData(button, 'data-index'), pid, topicName, username, quoted, topicUUID);} else {composer.newReply(tid, pid, topicName, '[[modules:composer.user_said, ' + username + ']]\n' + quoted);}diff --git a/public/src/modules/composer.js b/public/src/modules/composer.jsindex 6b871207f5..e6c34ace3e 100644--- a/public/src/modules/composer.js+++ b/public/src/modules/composer.js@@ -141,6 +141,17 @@ define('composer', [});}+ composer.findByTid = function(tid) {+ // Iterates through the initialised composers and returns the uuid of the matching composer+ for(var uuid in composer.posts) {+ if (composer.posts.hasOwnProperty(uuid) && composer.posts[uuid].hasOwnProperty('tid') && parseInt(composer.posts[uuid].tid, 10) === parseInt(tid, 10)) {+ return uuid;+ }+ }++ return null;+ };+composer.addButton = function(iconClass, onClick) {formatting.addButton(iconClass, onClick);};@@ -161,13 +172,17 @@ define('composer', [});};- composer.addQuote = function(tid, topicSlug, postIndex, pid, title, username, text) {- var uuid = composer.active;+ composer.addQuote = function(tid, topicSlug, postIndex, pid, title, username, text, uuid) {+ uuid = uuid || composer.active;if (uuid === undefined) {composer.newReply(tid, pid, title, '[[modules:composer.user_said, ' + username + ']]\n' + text);return;+ } else if (uuid !== composer.active) {+ // If the composer is not currently active, activate it+ composer.load(uuid);}+var postContainer = $('#cmp-uuid-' + uuid);var bodyEl = postContainer.find('textarea');var prevText = bodyEl.val();