Added app.newTopic

Make a new topic from anywhere. #4223
v1.18.x
Timothy Fike 9 years ago
parent e3371eb7ab
commit c80bd0c413

@ -34,7 +34,9 @@ app.cacheBuster = null;
app.handleSearch();
}
handleNewTopic();
$('#content').on('click', '#new_topic', function(){
app.newTopic();
});
require(['components'], function(components) {
components.get('user/logout').on('click', app.logout);
@ -455,30 +457,28 @@ app.cacheBuster = null;
});
};
function handleNewTopic() {
$('#content').on('click', '#new_topic', function() {
var cid = ajaxify.data.cid;
if (cid) {
$(window).trigger('action:composer.topic.new', {
cid: cid
app.newTopic = function (cid) {
cid = cid || ajaxify.data.cid;
if (cid) {
$(window).trigger('action:composer.topic.new', {
cid: cid
});
} else {
socket.emit('categories.getCategoriesByPrivilege', 'topics:create', function(err, categories) {
if (err) {
return app.alertError(err.message);
}
categories = categories.filter(function(category) {
return !category.link && !parseInt(category.parentCid, 10);
});
} else {
socket.emit('categories.getCategoriesByPrivilege', 'topics:create', function(err, categories) {
if (err) {
return app.alertError(err.message);
}
categories = categories.filter(function(category) {
return !category.link && !parseInt(category.parentCid, 10);
if (categories.length) {
$(window).trigger('action:composer.topic.new', {
cid: categories[0].cid
});
if (categories.length) {
$(window).trigger('action:composer.topic.new', {
cid: categories[0].cid
});
}
});
}
});
}
}
});
}
};
app.loadJQueryUI = function(callback) {
if (typeof $().autocomplete === 'function') {

Loading…
Cancel
Save