removed admin topics

v1.18.x
barisusakli 11 years ago
parent 8abaa812ec
commit 7f193041a8

@ -1,192 +0,0 @@
"use strict";
/* global define, socket, app, templates, RELATIVE_PATH */
define(function() {
var Topics = {};
Topics.init = function() {
var topicsListEl = $('.topics'),
loadMoreEl = $('#topics_loadmore');
this.resolveButtonStates();
topicsListEl.on('click', '[data-action]', function() {
var $this = $(this),
action = $this.attr('data-action'),
tid = $this.parents('[data-tid]').attr('data-tid');
switch (action) {
case 'pin':
if (!$this.hasClass('active')) {
socket.emit('topics.pin', tid, Topics.pin);
} else {
socket.emit('topics.unpin', tid, Topics.unpin);
}
break;
case 'lock':
if (!$this.hasClass('active')) {
socket.emit('topics.lock', tid, Topics.lock);
} else {
socket.emit('topics.unlock', tid, Topics.unlock);
}
break;
case 'delete':
if (!$this.hasClass('active')) {
socket.emit('topics.delete', tid, Topics.setDeleted);
} else {
socket.emit('topics.restore', tid, Topics.restore);
}
break;
}
});
loadMoreEl.on('click', function() {
if (!$(this).hasClass('disabled')) {
var topics = $('.topics li[data-tid]');
if(!topics.length) {
return;
}
var lastTid = parseInt(topics.eq(topics.length - 1).attr('data-tid'), 10);
$(this).html('<i class="fa fa-refresh fa-spin"></i> Retrieving topics');
socket.emit('admin.topics.getMore', {
limit: 10,
after: lastTid
}, function(err, topics) {
if(err) {
return app.alertError(err.message);
}
var btnEl = $('#topics_loadmore');
if (topics.length > 0) {
templates.preload_template('admin/topics', function() {
templates['admin/topics'].parse({topics:[]});
var html = templates.prepare(templates['admin/topics'].blocks.topics).parse({
topics: topics
}),
topicsListEl = $('.topics');
// Fix relative paths
html = html.replace(/\{relative_path\}/g, RELATIVE_PATH);
topicsListEl.html(topicsListEl.html() + html);
Topics.resolveButtonStates();
btnEl.html('Load More Topics');
$('span.timeago').timeago();
});
} else {
// Exhausted all topics
btnEl.addClass('disabled');
btnEl.html('No more topics');
}
});
}
}, false);
};
Topics.resolveButtonStates = function() {
// Resolve proper button state for all topics
var topicsListEl = $('.topics'),
topicEls = topicsListEl.find('li'),
numTopics = topicEls.length;
for (var x = 0; x < numTopics; x++) {
var topic = topicEls.eq(x);
if (topic.attr('data-pinned') === '1') {
topic.find('[data-action="pin"]').addClass('active');
topic.removeAttr('data-pinned');
}
if (topic.attr('data-locked') === '1') {
topic.find('[data-action="lock"]').addClass('active');
topic.removeAttr('data-locked');
}
if (topic.attr('data-deleted') === '1') {
topic.find('[data-action="delete"]').addClass('active');
topic.removeAttr('data-deleted');
}
}
};
Topics.setDeleted = function(err, response) {
if(err) {
return app.alert(err.message);
}
if (response && response.tid) {
var btnEl = $('li[data-tid="' + response.tid + '"] button[data-action="delete"]');
btnEl.addClass('active');
btnEl.siblings('[data-action="lock"]').addClass('active');
}
};
Topics.restore = function(err, response) {
if(err) {
return app.alert(err.message);
}
if (response && response.tid) {
var btnEl = $('li[data-tid="' + response.tid + '"] button[data-action="delete"]');
btnEl.removeClass('active');
btnEl.siblings('[data-action="lock"]').removeClass('active');
}
};
Topics.lock = function(err, response) {
if(err) {
return app.alert(err.message);
}
if (response && response.tid) {
var btnEl = $('li[data-tid="' + response.tid + '"] button[data-action="lock"]');
btnEl.addClass('active');
}
};
Topics.unlock = function(err, response) {
if(err) {
return app.alert(err.message);
}
if (response && response.tid) {
var btnEl = $('li[data-tid="' + response.tid + '"] button[data-action="lock"]');
btnEl.removeClass('active');
}
};
Topics.unpin = function(err, response) {
if(err) {
return app.alert(err.message);
}
if (response && response.tid) {
var btnEl = $('li[data-tid="' + response.tid + '"] button[data-action="pin"]');
btnEl.removeClass('active');
}
};
Topics.pin = function(err, response) {
if(err) {
return app.alert(err.message);
}
if (response && response.tid) {
var btnEl = $('li[data-tid="' + response.tid + '"] button[data-action="pin"]');
btnEl.addClass('active');
}
};
return Topics;
});

@ -69,16 +69,6 @@ adminController.database.get = function(req, res, next) {
});
};
// todo: deprecate this seemingly useless view
adminController.topics.get = function(req, res, next) {
topics.getAllTopics(0, 19, function (err, topics) {
res.render('admin/topics', {
topics: topics,
notopics: topics.length === 0
});
});
};
adminController.events.get = function(req, res, next) {
events.getLog(function(err, data) {
if(err || !data) {

@ -48,9 +48,6 @@ function forumRoutes(app, middleware, controllers) {
app.get('/admin/categories/disabled', middleware.admin.buildHeader, controllers.admin.categories.disabled);
app.get('/api/admin/categories/disabled', controllers.admin.categories.disabled);
app.get('/admin/topics', middleware.admin.buildHeader, controllers.admin.topics.get);
app.get('/api/admin/topics', controllers.admin.topics.get);
}
function apiRoutes(app, middleware, controllers) {

Loading…
Cancel
Save