From 7f193041a817f168752125f551aff14339bc8b7e Mon Sep 17 00:00:00 2001 From: barisusakli Date: Fri, 21 Mar 2014 13:24:26 -0400 Subject: [PATCH] removed admin topics --- public/src/forum/admin/topics.js | 192 ------------------------------- src/controllers/admin.js | 10 -- src/routes/admin.js | 3 - 3 files changed, 205 deletions(-) delete mode 100644 public/src/forum/admin/topics.js diff --git a/public/src/forum/admin/topics.js b/public/src/forum/admin/topics.js deleted file mode 100644 index 5bb0d3eb0b..0000000000 --- a/public/src/forum/admin/topics.js +++ /dev/null @@ -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(' 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; -}); \ No newline at end of file diff --git a/src/controllers/admin.js b/src/controllers/admin.js index 826f9e71f3..0cc98bbd25 100644 --- a/src/controllers/admin.js +++ b/src/controllers/admin.js @@ -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) { diff --git a/src/routes/admin.js b/src/routes/admin.js index dcb8513f55..393fc2c3df 100644 --- a/src/routes/admin.js +++ b/src/routes/admin.js @@ -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) {