Skip to content

Node.js based forum software built for the modern web

fixing quoting that broke with the introduction of the new post window

Julian Lam7e55e7b3d24b
diff --git a/public/src/app.js b/public/src/app.js
index 451f73e493..79b9636ce8 100644
--- a/public/src/app.js
+++ b/public/src/app.js
@@ -30,12 +30,6 @@ var socket,
console.log(data);
});
- socket.on('api:posts.getRawPost', function(data) {
- var contentEl = document.getElementById('post_content');
-
- contentEl.value = data.post;
- });
-
socket.on('connect', function(data){
if(reconnecting) {
setTimeout(function(){
diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js
index 6052629665..aacaae19ab 100644
--- a/public/src/forum/topic.js
+++ b/public/src/forum/topic.js
@@ -443,10 +443,15 @@
if (thread_state.locked !== '1') {
var pid = $(this).parents('li').attr('data-pid');
- require(['composer'], function(cmp) {
- cmp.push(tid);
- $('.post-window textarea').val('> ' + $('#content_' + pid).html() + '\n');
+ socket.once('api:posts.getRawPost', function(data) {
+ quoted = '> ' + data.post.replace(/\n/g, '\n> ') + '\n\n';
+ require(['composer'], function(cmp) {
+ cmp.push(tid, null, null, quoted);
+ });
});
+ socket.emit('api:posts.getRawPost', { pid: pid });
+ // $('.post-window textarea').val('> ' + $('#content_' + pid).html() + '\n');
+ // });
}
});
diff --git a/public/src/modules/composer.js b/public/src/modules/composer.js
index 217772fae8..50a2673fe5 100644
--- a/public/src/modules/composer.js
+++ b/public/src/modules/composer.js
@@ -28,12 +28,12 @@ define(function() {
'<span class="btn btn-link" tabindex="-1"><i class="icon-link"></i></span>' +
'</div>' +
'<div class="btn-group action-bar" style="float: right; margin-right: -12px">' +
- '<button data-action="post" class="btn" tabIndex="3"><i class="icon-ok"></i> Submit</button>' +
- '<button data-action="minimize" class="btn" tabIndex="4"><i class="icon-download-alt"></i> Minimize</button>' +
- '<button class="btn" data-action="discard" tabIndex="5"><i class="icon-remove"></i> Discard</button>' +
+ '<button data-action="post" class="btn" tabIndex="2"><i class="icon-ok"></i> Submit</button>' +
+ '<button data-action="minimize" class="btn" tabIndex="3"><i class="icon-download-alt"></i> Minimize</button>' +
+ '<button class="btn" data-action="discard" tabIndex="4"><i class="icon-remove"></i> Discard</button>' +
'</div>' +
'</div>' +
- '<textarea></textarea>' +
+ '<textarea tabIndex="1"></textarea>' +
'</div>';
composer.listEl = composer.btnContainer.querySelector('ul');
@@ -167,11 +167,12 @@ define(function() {
}
}
- composer.push = function(tid, cid, pid) {
+ composer.push = function(tid, cid, pid, text) {
socket.emit('api:composer.push', {
tid: tid, // Replying
cid: cid, // Posting
- pid: pid // Editing
+ pid: pid, // Editing
+ body: text // Predefined text
});
}
@@ -202,6 +203,8 @@ define(function() {
// Direct user focus to the correct element
if ((parseInt(post_data.tid) || parseInt(post_data.pid)) > 0) {
bodyEl.focus();
+ bodyEl.selectionStart = bodyEl.value.length;
+ bodyEl.selectionEnd = bodyEl.value.length;
} else if (parseInt(post_data.cid) > 0) {
titleEl.focus();
}
diff --git a/src/websockets.js b/src/websockets.js
index 916ab20255..e59784f518 100644
--- a/src/websockets.js
+++ b/src/websockets.js
@@ -316,6 +316,7 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
if (parseInt(data.tid) > 0) {
topics.get_topic(data.tid, uid, function(topicData) {
topicData.tid = data.tid;
+ if (data.body) topicData.body = data.body;
socket.emit('api:composer.push', topicData);
});
} else if (parseInt(data.cid) > 0) {