From a2e3179ea49c9342a958fc82fae33a234e76a8ba Mon Sep 17 00:00:00 2001 From: psychobunny Date: Wed, 25 Feb 2015 15:16:51 -0500 Subject: [PATCH] nav - enable / disable --- public/src/admin/general/navigation.js | 9 +++++++++ public/src/modules/helpers.js | 7 ++++++- src/navigation/index.js | 3 --- src/socket.io/admin.js | 1 + src/views/admin/general/navigation.tpl | 13 ++++++++----- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/public/src/admin/general/navigation.js b/public/src/admin/general/navigation.js index a9452a9579..6e2e36e66d 100644 --- a/public/src/admin/general/navigation.js +++ b/public/src/admin/general/navigation.js @@ -14,6 +14,15 @@ define('admin/general/navigation', function() { $(this).parents('li').remove(); }); + $('.toggle').on('click', function() { + var btn = $(this), + disabled = btn.html() === 'Enable'; + + btn.toggleClass('btn-warning').toggleClass('btn-success').html(!disabled ? 'Enable' : 'Disable'); + btn.parents('li').find('[name="enabled"]').val(disabled); + return false; + }); + $('#save').on('click', saveNavigation); }; diff --git a/public/src/modules/helpers.js b/public/src/modules/helpers.js index 71473d0d9a..14815c9811 100644 --- a/public/src/modules/helpers.js +++ b/public/src/modules/helpers.js @@ -14,7 +14,12 @@ }; helpers.displayMenuItem = function(data, index) { - var properties = data.navigation[index].properties; + var item = data.navigation[index], + properites = item.properties; + + if (!item.enabled) { + return false; + } if (properties) { if (properties.loggedIn && !data.loggedIn || diff --git a/src/navigation/index.js b/src/navigation/index.js index e11f845576..6a7ea1f638 100644 --- a/src/navigation/index.js +++ b/src/navigation/index.js @@ -10,9 +10,6 @@ navigation.get = function(callback) { db.getSortedSetRange('navigation:enabled', 0, -1, function(err, data) { callback(err, data.map(function(item) { return JSON.parse(item); - }) - .filter(function(item) { - return item.enabled; })); }); }; diff --git a/src/socket.io/admin.js b/src/socket.io/admin.js index 30782f4d6e..dcbda783aa 100644 --- a/src/socket.io/admin.js +++ b/src/socket.io/admin.js @@ -26,6 +26,7 @@ var async = require('async'), groups: require('./admin/groups'), tags: require('./admin/tags'), rewards: require('./admin/rewards'), + navigation: require('./admin/navigation'), themes: {}, plugins: {}, widgets: {}, diff --git a/src/views/admin/general/navigation.tpl b/src/views/admin/general/navigation.tpl index e513c1b7a1..0f2890f855 100644 --- a/src/views/admin/general/navigation.tpl +++ b/src/views/admin/general/navigation.tpl @@ -13,11 +13,11 @@ -