mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 14:35:47 +01:00
update BS brand colors in ACP
This commit is contained in:
@@ -320,5 +320,19 @@ define(['forum/admin/settings'], function(Settings) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
require(['settings'], function (settings) {
|
||||||
|
var wrapper = $('#branding');
|
||||||
|
|
||||||
|
settings.sync('branding', wrapper);
|
||||||
|
|
||||||
|
$('#save-branding').click(function(event) {
|
||||||
|
settings.persist('branding', $('#branding'), function() {
|
||||||
|
socket.emit('admin.themes.updateBranding');
|
||||||
|
});
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
return Themes;
|
return Themes;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -136,9 +136,21 @@ adminController.themes.get = function(req, res, next) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var branding = [];
|
||||||
|
|
||||||
|
for (var key in meta.css.branding) {
|
||||||
|
if (meta.css.branding.hasOwnProperty(key)) {
|
||||||
|
branding.push({
|
||||||
|
key: key,
|
||||||
|
value: meta.css.branding[key]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
res.render('admin/themes', {
|
res.render('admin/themes', {
|
||||||
areas: widgetData.areas,
|
areas: widgetData.areas,
|
||||||
widgets: widgetData.widgets
|
widgets: widgetData.widgets,
|
||||||
|
branding: branding
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
18
src/meta.js
18
src/meta.js
@@ -330,6 +330,7 @@ var fs = require('fs'),
|
|||||||
Meta.css = {};
|
Meta.css = {};
|
||||||
Meta.css.cache = undefined;
|
Meta.css.cache = undefined;
|
||||||
Meta.css.branding = {};
|
Meta.css.branding = {};
|
||||||
|
Meta.css.defaultBranding = {};
|
||||||
|
|
||||||
Meta.css.minify = function() {
|
Meta.css.minify = function() {
|
||||||
winston.info('[meta/css] Minifying LESS/CSS');
|
winston.info('[meta/css] Minifying LESS/CSS');
|
||||||
@@ -370,6 +371,8 @@ var fs = require('fs'),
|
|||||||
cleancss: true
|
cleancss: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Meta.css.cache = css;
|
||||||
|
|
||||||
var re = /.brand-([\S]*?)[ ]*?{[\s\S]*?color:([\S\s]*?)}/gi,
|
var re = /.brand-([\S]*?)[ ]*?{[\s\S]*?color:([\S\s]*?)}/gi,
|
||||||
match;
|
match;
|
||||||
|
|
||||||
@@ -377,24 +380,27 @@ var fs = require('fs'),
|
|||||||
Meta.css.branding[match[1]] = match[2];
|
Meta.css.branding[match[1]] = match[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof Meta.config.branding !== 'undefined') {
|
Meta.css.defaultBranding = Meta.css.branding;
|
||||||
Meta.css.updateBranding(Meta.config.branding);
|
Meta.css.updateBranding();
|
||||||
}
|
|
||||||
|
|
||||||
Meta.css.cache = css;
|
|
||||||
winston.info('[meta/css] Done.');
|
winston.info('[meta/css] Done.');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Meta.css.updateBranding = function(branding) {
|
Meta.css.updateBranding = function() {
|
||||||
|
var Settings = require('./settings');
|
||||||
|
var branding = new Settings('branding', '0', {}, function() {
|
||||||
|
branding = branding.cfg._;
|
||||||
|
|
||||||
for (var b in branding) {
|
for (var b in branding) {
|
||||||
if (branding.hasOwnProperty(b)) {
|
if (branding.hasOwnProperty(b)) {
|
||||||
Meta.css.replace(new RegExp(Meta.css.branding[b], 'g'), branding[b]);
|
Meta.css.cache = Meta.css.cache.replace(new RegExp(Meta.css.branding[b], 'g'), branding[b]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Meta.css.branding = branding;
|
Meta.css.branding = branding;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Sounds */
|
/* Sounds */
|
||||||
|
|||||||
@@ -83,6 +83,10 @@ SocketAdmin.themes.set = function(socket, data, callback) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SocketAdmin.themes.updateBranding = function(socket, data, callback) {
|
||||||
|
meta.css.updateBranding();
|
||||||
|
};
|
||||||
|
|
||||||
SocketAdmin.plugins.toggleActive = function(socket, plugin_id, callback) {
|
SocketAdmin.plugins.toggleActive = function(socket, plugin_id, callback) {
|
||||||
plugins.toggleActive(plugin_id, callback);
|
plugins.toggleActive(plugin_id, callback);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user