nav - enable / disable

v1.18.x
psychobunny 10 years ago
parent 1ae0a8a1bf
commit a2e3179ea4

@ -14,6 +14,15 @@ define('admin/general/navigation', function() {
$(this).parents('li').remove(); $(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); $('#save').on('click', saveNavigation);
}; };

@ -14,7 +14,12 @@
}; };
helpers.displayMenuItem = function(data, index) { 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) {
if (properties.loggedIn && !data.loggedIn || if (properties.loggedIn && !data.loggedIn ||

@ -10,9 +10,6 @@ navigation.get = function(callback) {
db.getSortedSetRange('navigation:enabled', 0, -1, function(err, data) { db.getSortedSetRange('navigation:enabled', 0, -1, function(err, data) {
callback(err, data.map(function(item) { callback(err, data.map(function(item) {
return JSON.parse(item); return JSON.parse(item);
})
.filter(function(item) {
return item.enabled;
})); }));
}); });
}; };

@ -26,6 +26,7 @@ var async = require('async'),
groups: require('./admin/groups'), groups: require('./admin/groups'),
tags: require('./admin/tags'), tags: require('./admin/tags'),
rewards: require('./admin/rewards'), rewards: require('./admin/rewards'),
navigation: require('./admin/navigation'),
themes: {}, themes: {},
plugins: {}, plugins: {},
widgets: {}, widgets: {},

@ -13,11 +13,11 @@
<label>Route: <small>ex. /unread</small> <label>Route: <small>ex. /unread</small>
<input class="form-control" type="text" name="route" value="{enabled.route}" /> <input class="form-control" type="text" name="route" value="{enabled.route}" />
</label> </label>
<label>Title: <small>text shown upon mouseover</small> <label>Title: <small>shown upon mouseover</small>
<input class="form-control" type="text" name="title" value="{enabled.title}" /> <input class="form-control" type="text" name="title" value="{enabled.title}" />
</label> </label>
<label>Text: <label>Text:
<input class="form-control" type="text" name="textClass" value="{enabled.text}" /> <input class="form-control" type="text" name="text" value="{enabled.text}" />
</label> </label>
<label>Icon Class: <small><a href="http://fortawesome.github.io/Font-Awesome/cheatsheet/" target="_blank">pick one</a></small> <label>Icon Class: <small><a href="http://fortawesome.github.io/Font-Awesome/cheatsheet/" target="_blank">pick one</a></small>
<input class="form-control" type="text" name="iconClass" value="{enabled.iconClass}" /> <input class="form-control" type="text" name="iconClass" value="{enabled.iconClass}" />
@ -27,9 +27,12 @@
</label> </label>
<hr /> <hr />
<button class="btn btn-danger delete">Delete</button> <button class="btn btn-danger delete">Delete</button>
<label>Enabled <!-- IF enabled.enabled -->
<input type="checkbox" name="enabled" <!-- IF enabled --> checked<!-- ENDIF enabled --> /> <button class="btn btn-warning toggle">Disable</button>
</label> <!-- ELSE -->
<button class="btn btn-success toggle">Enable</button>
<!-- ENDIF enabled.enabled -->
<input type="hidden" name="enabled" value="{enabled.enabled}" />
</form> </form>
</li> </li>
<!-- END enabled --> <!-- END enabled -->

Loading…
Cancel
Save