ability to toggle display of subcategories on categories page (#284)

* ability to toggle display of subcategories on categories page

* settingsv2
main
pichalite 9 years ago committed by Julian Lam
parent e4b468e9e9
commit 7be7d322ce

@ -0,0 +1,24 @@
'use strict';
/* globals $, app */
define('admin/plugins/persona', ['settings'], function(Settings) {
var ACP = {};
ACP.init = function() {
Settings.load('persona', $('.persona-settings'));
$('#save').on('click', function() {
Settings.save('persona', $('.persona-settings'), function() {
app.alert({
type: 'success',
alert_id: 'persona-saved',
title: 'Settings Saved',
message: 'Persona settings saved'
});
});
});
};
return ACP;
});

@ -1,9 +1,30 @@
'use strict';
var S = require.main.require('string');
var meta = module.parent.require('./meta');
var library = {};
library.init = function(params, callback) {
var app = params.router;
var middleware = params.middleware;
app.get('/admin/plugins/persona', middleware.admin.buildHeader, renderAdmin);
app.get('/api/admin/plugins/persona', renderAdmin);
callback();
};
library.addAdminNavigation = function(header, callback) {
header.plugins.push({
route: '/plugins/persona',
icon: 'fa-paint-brush',
name: 'Persona Theme'
});
callback(null, header);
};
library.getTeasers = function(data, callback) {
data.teasers.forEach(function(teaser) {
if (teaser && teaser.content) {
@ -65,4 +86,17 @@ library.defineWidgetAreas = function(areas, callback) {
callback(null, areas);
};
module.exports = library;
library.getThemeConfig = function(config, callback) {
meta.settings.get('persona', function(err, settings) {
config.hideSubCategories = settings.hideSubCategories === 'on';
});
callback(false, config);
};
function renderAdmin(req, res, next) {
res.render('admin/plugins/persona', {});
}
module.exports = library;

@ -3,7 +3,10 @@
"library": "library.js",
"hooks": [
{ "hook": "filter:teasers.get", "method": "getTeasers" },
{ "hook": "filter:widgets.getAreas", "method": "defineWidgetAreas" }
{ "hook": "filter:widgets.getAreas", "method": "defineWidgetAreas" },
{ "hook": "filter:config.get", "method": "getThemeConfig" },
{ "hook": "static:app.load", "method": "init" },
{ "hook": "filter:admin.header.build", "method": "addAdminNavigation" }
],
"scripts": [
"lib/persona.js",
@ -11,5 +14,8 @@
"lib/modules/autohidingnavbar.min.js",
"lib/modules/slideout.min.js",
"lib/client/chats.js"
],
"acpScripts": [
"lib/admin.js"
]
}

@ -0,0 +1,17 @@
<div class="row">
<div class="col-sm-2 col-xs-12 settings-header">Theme Settings</div>
<div class="col-sm-10 col-xs-12">
<form role="form" class="persona-settings">
<div class="checkbox">
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
<input class="mdl-switch__input" type="checkbox" id="hideSubCategories" name="hideSubCategories">
<span class="mdl-switch__label"><strong>Hide subcategories on categories view</strong></span>
</label>
</div>
</form>
</div>
</div>
<button id="save" class="floating-button mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect mdl-button--colored">
<i class="material-icons">save</i>
</button>

@ -13,7 +13,9 @@
{../descriptionParsed}
</div>
<!-- ENDIF ../descriptionParsed -->
<!-- IF !config.hideSubCategories -->
{function.generateChildrenCategories}
<!-- ENDIF !config.hideSubCategories -->
</h2>
<span class="visible-xs pull-right">
<a class="permalink" href="{../teaser.url}">

Loading…
Cancel
Save