mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 06:55:46 +01:00
closes #2880
This commit is contained in:
@@ -471,6 +471,26 @@ app.cacheBuster = null;
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleNewTopic() {
|
||||||
|
$('#content').on('click', '#new_topic', function() {
|
||||||
|
require(['composer'], function(composer) {
|
||||||
|
var cid = ajaxify.variables.get('category_id');
|
||||||
|
if (cid) {
|
||||||
|
composer.newTopic(cid);
|
||||||
|
} else {
|
||||||
|
socket.emit('categories.getCategoriesByPrivilege', 'topics:create', function(err, categories) {
|
||||||
|
if (err) {
|
||||||
|
return app.alertError(err.message);
|
||||||
|
}
|
||||||
|
if (categories.length) {
|
||||||
|
composer.newTopic(categories[0].cid);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
app.load = function() {
|
app.load = function() {
|
||||||
$('document').ready(function () {
|
$('document').ready(function () {
|
||||||
var url = ajaxify.start(window.location.pathname.slice(1), true, window.location.search);
|
var url = ajaxify.start(window.location.pathname.slice(1), true, window.location.search);
|
||||||
@@ -482,6 +502,8 @@ app.cacheBuster = null;
|
|||||||
handleSearch();
|
handleSearch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleNewTopic();
|
||||||
|
|
||||||
$('#logout-link').on('click', app.logout);
|
$('#logout-link').on('click', app.logout);
|
||||||
|
|
||||||
Visibility.change(function(e, state){
|
Visibility.change(function(e, state){
|
||||||
|
|||||||
@@ -33,10 +33,6 @@ define('forum/category', [
|
|||||||
|
|
||||||
share.addShareHandlers(ajaxify.variables.get('category_name'));
|
share.addShareHandlers(ajaxify.variables.get('category_name'));
|
||||||
|
|
||||||
$('#new_post').on('click', function () {
|
|
||||||
composer.newTopic(cid);
|
|
||||||
});
|
|
||||||
|
|
||||||
socket.removeListener('event:new_topic', Category.onNewTopic);
|
socket.removeListener('event:new_topic', Category.onNewTopic);
|
||||||
socket.on('event:new_topic', Category.onNewTopic);
|
socket.on('event:new_topic', Category.onNewTopic);
|
||||||
|
|
||||||
|
|||||||
@@ -23,17 +23,6 @@ define('forum/recent', ['forum/infinitescroll', 'composer', 'components'], funct
|
|||||||
$(this).addClass('hide');
|
$(this).addClass('hide');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#new_topic').on('click', function() {
|
|
||||||
socket.emit('categories.getCategoriesByPrivilege', 'topics:create', function(err, categories) {
|
|
||||||
if (err) {
|
|
||||||
return app.alertError(err.message);
|
|
||||||
}
|
|
||||||
if (categories.length) {
|
|
||||||
composer.newTopic(categories[0].cid);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
infinitescroll.init(Recent.loadMoreTopics);
|
infinitescroll.init(Recent.loadMoreTopics);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user