half broken editing

v1.18.x
Julian Lam 12 years ago
parent 2b4782b376
commit 061c7a9e66

@ -162,11 +162,13 @@
var pid = ($(this).attr('id') || $(this.parentNode).attr('id')).split('_')[1];
var main = $(this).parents('.main-post');
if(main.length > 0)
app.open_post_window('edit', tid, topic_name, pid);
else
app.open_post_window('edit', tid, "", pid);
// if(main.length > 0)
// app.open_post_window('edit', tid, topic_name, pid);
// else
// app.open_post_window('edit', tid, "", pid);
require(['composer'], function(cmp) {
cmp.push(null, null, pid);
});
});
$('.post-container').delegate('.delete', 'click', function(e) {
@ -448,13 +450,6 @@
}
});
jQuery(div + ' .edit, ' + div + ' .delete').each(function() {
var ids = this.id.replace('ids_', '').split('_'),
pid = ids[0],
uid = ids[1];
});
jQuery(div + ' .favourite').click(function() {
var ids = this.id.replace('favs_', '').split('_'),
pid = ids[0],

@ -49,8 +49,9 @@ define(function() {
composer.posts[uuid] = {
tid: threadData.tid,
cid: threadData.cid,
pid: threadData.pid,
title: threadData.tid ? threadData.title : '',
body: ''
body: threadData.body || ''
};
composer.active++;
composer.update();
@ -149,10 +150,11 @@ define(function() {
}
}
composer.push = function(tid, cid) {
composer.push = function(tid, cid, pid) {
socket.emit('api:composer.push', {
tid: tid,
cid: cid
tid: tid, // Replying
cid: cid, // Posting
pid: pid // Editing
});
}
@ -167,6 +169,9 @@ define(function() {
if (post_data.tid > 0) {
titleEl.value = 'Replying to: ' + post_data.title;
titleEl.readonly = true;
} else if (post_data.pid > 0) {
titleEl.value = 'Editing: ' + post_data.title;
titleEl.readonly = true;
} else {
titleEl.value = post_data.title;
}

@ -291,9 +291,9 @@ marked.setOptions({
});
}
Posts.getRawContent = function(pid, socket) {
Posts.getRawContent = function(pid, callback) {
RDB.get('pid:' + pid + ':content', function(err, raw) {
socket.emit('api:posts.getRawPost', { post: raw });
callback(raw);
});
}

@ -233,7 +233,9 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
});
socket.on('api:posts.getRawPost', function(data) {
posts.getRawContent(data.pid, socket);
posts.getRawContent(data.pid, function(raw) {
socket.emit('api:posts.getRawPost', { post: raw });
});
});
socket.on('api:posts.edit', function(data) {
@ -306,12 +308,12 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
});
socket.on('api:composer.push', function(data) {
if (data.tid > 0) {
if (parseInt(data.tid) > 0) {
topics.get_topic(data.tid, uid, function(topicData) {
topicData.tid = data.tid;
socket.emit('api:composer.push', topicData);
});
} else {
} else if (parseInt(data.cid) > 0) {
user.getUserField(uid, 'username', function(username) {
socket.emit('api:composer.push', {
tid: 0,
@ -320,6 +322,14 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
title: 'New Topic'
});
});
} else if (parseInt(data.pid) > 0) {
posts.getRawContent(data.pid, function(raw) {
socket.emit('api:composer.push', {
title: 'asdf',
pid: data.pid,
body: raw
});
});
}
});
});

Loading…
Cancel
Save