|
|
@ -1,15 +1,20 @@
|
|
|
|
define(['forum/admin/settings'], function(Settings) {
|
|
|
|
define(['forum/admin/settings'], function(Settings) {
|
|
|
|
var Themes = {};
|
|
|
|
var Themes = {};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function highlightSelectedTheme(themeId) {
|
|
|
|
|
|
|
|
$('#themes li[data-theme]').removeClass('btn-warning');
|
|
|
|
|
|
|
|
$('#themes li[data-theme="' + themeId + '"]').addClass('btn-warning');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Themes.init = function() {
|
|
|
|
Themes.init = function() {
|
|
|
|
var scriptEl = $('<script />');
|
|
|
|
var scriptEl = $('<script />');
|
|
|
|
scriptEl.attr('src', 'http://api.bootswatch.com/3/?callback=bootswatchListener');
|
|
|
|
scriptEl.attr('src', 'http://api.bootswatch.com/3/?callback=bootswatchListener');
|
|
|
|
$('body').append(scriptEl);
|
|
|
|
$('body').append(scriptEl);
|
|
|
|
|
|
|
|
|
|
|
|
var bootstrapThemeContainer = $('#bootstrap_themes'),
|
|
|
|
var bootstrapThemeContainer = $('#bootstrap_themes'),
|
|
|
|
installedThemeContainer = $('#installed_themes'),
|
|
|
|
installedThemeContainer = $('#installed_themes');
|
|
|
|
|
|
|
|
|
|
|
|
themeEvent = function(e) {
|
|
|
|
function themeEvent(e) {
|
|
|
|
var target = $(e.target),
|
|
|
|
var target = $(e.target),
|
|
|
|
action = target.attr('data-action');
|
|
|
|
action = target.attr('data-action');
|
|
|
|
|
|
|
|
|
|
|
@ -26,6 +31,11 @@ define(['forum/admin/settings'], function(Settings) {
|
|
|
|
id: themeId,
|
|
|
|
id: themeId,
|
|
|
|
src: cssSrc
|
|
|
|
src: cssSrc
|
|
|
|
}, function(err) {
|
|
|
|
}, function(err) {
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
return app.alertError(err.message);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
highlightSelectedTheme(themeId);
|
|
|
|
|
|
|
|
|
|
|
|
app.alert({
|
|
|
|
app.alert({
|
|
|
|
alert_id: 'admin:theme',
|
|
|
|
alert_id: 'admin:theme',
|
|
|
|
type: 'success',
|
|
|
|
type: 'success',
|
|
|
@ -37,7 +47,7 @@ define(['forum/admin/settings'], function(Settings) {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bootstrapThemeContainer.on('click', themeEvent);
|
|
|
|
bootstrapThemeContainer.on('click', themeEvent);
|
|
|
|
installedThemeContainer.on('click', themeEvent);
|
|
|
|
installedThemeContainer.on('click', themeEvent);
|
|
|
@ -49,6 +59,10 @@ define(['forum/admin/settings'], function(Settings) {
|
|
|
|
type: 'local',
|
|
|
|
type: 'local',
|
|
|
|
id: 'nodebb-theme-cerulean'
|
|
|
|
id: 'nodebb-theme-cerulean'
|
|
|
|
}, function(err) {
|
|
|
|
}, function(err) {
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
return app.alertError(err.message);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
highlightSelectedTheme('nodebb-theme-cerulean');
|
|
|
|
app.alert({
|
|
|
|
app.alert({
|
|
|
|
alert_id: 'admin:theme',
|
|
|
|
alert_id: 'admin:theme',
|
|
|
|
type: 'success',
|
|
|
|
type: 'success',
|
|
|
@ -59,7 +73,7 @@ define(['forum/admin/settings'], function(Settings) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}, false);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// Installed Themes
|
|
|
|
// Installed Themes
|
|
|
|
socket.emit('admin.themes.getInstalled', function(err, themes) {
|
|
|
|
socket.emit('admin.themes.getInstalled', function(err, themes) {
|
|
|
@ -69,7 +83,11 @@ define(['forum/admin/settings'], function(Settings) {
|
|
|
|
|
|
|
|
|
|
|
|
var instListEl = $('#installed_themes').empty(), liEl;
|
|
|
|
var instListEl = $('#installed_themes').empty(), liEl;
|
|
|
|
|
|
|
|
|
|
|
|
if (themes.length > 0) {
|
|
|
|
if (!themes.length) {
|
|
|
|
|
|
|
|
instListEl.append($('<li/ >').addClass('no-themes').html('No installed themes found'));
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (var x = 0, numThemes = themes.length; x < numThemes; x++) {
|
|
|
|
for (var x = 0, numThemes = themes.length; x < numThemes; x++) {
|
|
|
|
liEl = $('<li/ >').attr({
|
|
|
|
liEl = $('<li/ >').attr({
|
|
|
|
'data-type': 'local',
|
|
|
|
'data-type': 'local',
|
|
|
@ -89,10 +107,8 @@ define(['forum/admin/settings'], function(Settings) {
|
|
|
|
|
|
|
|
|
|
|
|
instListEl.append(liEl);
|
|
|
|
instListEl.append(liEl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// No themes found
|
|
|
|
highlightSelectedTheme(config['theme:id']);
|
|
|
|
instListEl.append($('<li/ >').addClass('no-themes').html('No installed themes found'));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// Proper tabbing for "Custom CSS" field
|
|
|
|
// Proper tabbing for "Custom CSS" field
|
|
|
|