|
|
|
@ -4,16 +4,8 @@ define(['taskbar'], function(taskbar) {
|
|
|
|
|
posts: {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
composer.push = function(tid, cid, pid, text) {
|
|
|
|
|
|
|
|
|
|
socket.emit('api:composer.push', {
|
|
|
|
|
tid: tid, // Replying
|
|
|
|
|
cid: cid, // Posting
|
|
|
|
|
pid: pid, // Editing
|
|
|
|
|
body: text // Predefined text
|
|
|
|
|
}, function(threadData) {
|
|
|
|
|
|
|
|
|
|
if(threadData.error) {
|
|
|
|
|
function allowed() {
|
|
|
|
|
if(!(parseInt(app.uid, 10) > 0 || parseInt(config.allowGuestPosting, 10) === 1)) {
|
|
|
|
|
app.alert({
|
|
|
|
|
type: 'danger',
|
|
|
|
|
timeout: 5000,
|
|
|
|
@ -24,27 +16,60 @@ define(['taskbar'], function(taskbar) {
|
|
|
|
|
ajaxify.go('login');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
composer.newTopic = function(cid) {
|
|
|
|
|
if(allowed()) {
|
|
|
|
|
push({
|
|
|
|
|
cid: cid,
|
|
|
|
|
title: '',
|
|
|
|
|
body: '',
|
|
|
|
|
modified: false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
composer.newReply = function(tid, title, text) {
|
|
|
|
|
if(allowed()) {
|
|
|
|
|
push({
|
|
|
|
|
tid: tid,
|
|
|
|
|
title: title,
|
|
|
|
|
body: text,
|
|
|
|
|
modified: false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
composer.editPost = function(pid) {
|
|
|
|
|
if(allowed()) {
|
|
|
|
|
socket.emit('api:composer.push', {
|
|
|
|
|
pid: pid
|
|
|
|
|
}, function(threadData) {
|
|
|
|
|
console.log(threadData);
|
|
|
|
|
push({
|
|
|
|
|
pid: pid,
|
|
|
|
|
title: threadData.title,
|
|
|
|
|
body: threadData.body,
|
|
|
|
|
modified: false
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function push(post) {
|
|
|
|
|
var uuid = utils.generateUUID();
|
|
|
|
|
|
|
|
|
|
taskbar.push('composer', uuid, {
|
|
|
|
|
title: (!threadData.cid ? (threadData.title || '') : 'New Topic'),
|
|
|
|
|
icon: threadData.picture
|
|
|
|
|
title: post.title ? post.title : 'New Topic',
|
|
|
|
|
icon: post.picture
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
composer.posts[uuid] = {
|
|
|
|
|
tid: threadData.tid,
|
|
|
|
|
cid: threadData.cid,
|
|
|
|
|
pid: threadData.pid,
|
|
|
|
|
title: threadData.title || '',
|
|
|
|
|
body: threadData.body || '',
|
|
|
|
|
modified: false
|
|
|
|
|
};
|
|
|
|
|
composer.posts[uuid] = post;
|
|
|
|
|
|
|
|
|
|
composer.load(uuid);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
composer.load = function(post_uuid) {
|
|
|
|
@ -470,7 +495,9 @@ define(['taskbar'], function(taskbar) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
push: composer.push,
|
|
|
|
|
newTopic: composer.newTopic,
|
|
|
|
|
newReply: composer.newReply,
|
|
|
|
|
editPost: composer.editPost,
|
|
|
|
|
load: composer.load,
|
|
|
|
|
minimize: composer.minimize
|
|
|
|
|
};
|
|
|
|
|