update BS brand colors in ACP

v1.18.x
psychobunny 11 years ago
parent 4234057821
commit a5a2e6f04e

@ -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;
});

@ -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', {
areas: widgetData.areas,
widgets: widgetData.widgets
widgets: widgetData.widgets,
branding: branding
});
});
});

@ -330,6 +330,7 @@ var fs = require('fs'),
Meta.css = {};
Meta.css.cache = undefined;
Meta.css.branding = {};
Meta.css.defaultBranding = {};
Meta.css.minify = function() {
winston.info('[meta/css] Minifying LESS/CSS');
@ -370,6 +371,8 @@ var fs = require('fs'),
cleancss: true
});
Meta.css.cache = css;
var re = /.brand-([\S]*?)[ ]*?{[\s\S]*?color:([\S\s]*?)}/gi,
match;
@ -377,24 +380,27 @@ var fs = require('fs'),
Meta.css.branding[match[1]] = match[2];
}
if (typeof Meta.config.branding !== 'undefined') {
Meta.css.updateBranding(Meta.config.branding);
}
Meta.css.defaultBranding = Meta.css.branding;
Meta.css.updateBranding();
Meta.css.cache = css;
winston.info('[meta/css] Done.');
});
});
};
Meta.css.updateBranding = function(branding) {
for (var b in branding) {
if (branding.hasOwnProperty(b)) {
Meta.css.replace(new RegExp(Meta.css.branding[b], 'g'), branding[b]);
Meta.css.updateBranding = function() {
var Settings = require('./settings');
var branding = new Settings('branding', '0', {}, function() {
branding = branding.cfg._;
for (var b in branding) {
if (branding.hasOwnProperty(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 */

@ -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) {
plugins.toggleActive(plugin_id, callback);
};

Loading…
Cancel
Save