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(); app.handleSearch();
} }
handleNewTopic(); $('#content').on('click', '#new_topic', function(){
app.newTopic();
});
require(['components'], function(components) { require(['components'], function(components) {
components.get('user/logout').on('click', app.logout); components.get('user/logout').on('click', app.logout);
@ -455,30 +457,28 @@ app.cacheBuster = null;
}); });
}; };
function handleNewTopic() { app.newTopic = function (cid) {
$('#content').on('click', '#new_topic', function() { cid = cid || ajaxify.data.cid;
var cid = ajaxify.data.cid; if (cid) {
if (cid) { $(window).trigger('action:composer.topic.new', {
$(window).trigger('action:composer.topic.new', { cid: cid
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 { if (categories.length) {
socket.emit('categories.getCategoriesByPrivilege', 'topics:create', function(err, categories) { $(window).trigger('action:composer.topic.new', {
if (err) { cid: categories[0].cid
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 }
}); };
}
});
}
});
}
app.loadJQueryUI = function(callback) { app.loadJQueryUI = function(callback) {
if (typeof $().autocomplete === 'function') { if (typeof $().autocomplete === 'function') {

Loading…
Cancel
Save