diff --git a/public/src/forum/admin/themes.js b/public/src/forum/admin/themes.js
index d5873a7164..14408bbce6 100644
--- a/public/src/forum/admin/themes.js
+++ b/public/src/forum/admin/themes.js
@@ -1,43 +1,53 @@
define(['forum/admin/settings'], function(Settings) {
var Themes = {};
+ function highlightSelectedTheme(themeId) {
+ $('#themes li[data-theme]').removeClass('btn-warning');
+ $('#themes li[data-theme="' + themeId + '"]').addClass('btn-warning');
+ }
+
Themes.init = function() {
var scriptEl = $('');
scriptEl.attr('src', 'http://api.bootswatch.com/3/?callback=bootswatchListener');
$('body').append(scriptEl);
var bootstrapThemeContainer = $('#bootstrap_themes'),
- installedThemeContainer = $('#installed_themes'),
-
- themeEvent = function(e) {
- var target = $(e.target),
- action = target.attr('data-action');
-
- if (action) {
- switch (action) {
- case 'use':
- var parentEl = target.parents('li'),
- themeType = parentEl.attr('data-type'),
- cssSrc = parentEl.attr('data-css'),
- themeId = parentEl.attr('data-theme');
-
- socket.emit('admin.themes.set', {
- type: themeType,
- id: themeId,
- src: cssSrc
- }, function(err) {
- app.alert({
- alert_id: 'admin:theme',
- type: 'success',
- title: 'Theme Changed',
- message: 'Restarting your NodeBB ',
- timeout: 3500
- });
+ installedThemeContainer = $('#installed_themes');
+
+ function themeEvent(e) {
+ var target = $(e.target),
+ action = target.attr('data-action');
+
+ if (action) {
+ switch (action) {
+ case 'use':
+ var parentEl = target.parents('li'),
+ themeType = parentEl.attr('data-type'),
+ cssSrc = parentEl.attr('data-css'),
+ themeId = parentEl.attr('data-theme');
+
+ socket.emit('admin.themes.set', {
+ type: themeType,
+ id: themeId,
+ src: cssSrc
+ }, function(err) {
+ if (err) {
+ return app.alertError(err.message);
+ }
+ highlightSelectedTheme(themeId);
+
+ app.alert({
+ alert_id: 'admin:theme',
+ type: 'success',
+ title: 'Theme Changed',
+ message: 'Restarting your NodeBB ',
+ timeout: 3500
});
- break;
- }
+ });
+ break;
}
- };
+ }
+ }
bootstrapThemeContainer.on('click', themeEvent);
installedThemeContainer.on('click', themeEvent);
@@ -49,6 +59,10 @@ define(['forum/admin/settings'], function(Settings) {
type: 'local',
id: 'nodebb-theme-cerulean'
}, function(err) {
+ if (err) {
+ return app.alertError(err.message);
+ }
+ highlightSelectedTheme('nodebb-theme-cerulean');
app.alert({
alert_id: 'admin:theme',
type: 'success',
@@ -59,7 +73,7 @@ define(['forum/admin/settings'], function(Settings) {
});
}
});
- }, false);
+ });
// Installed Themes
socket.emit('admin.themes.getInstalled', function(err, themes) {
@@ -69,30 +83,32 @@ define(['forum/admin/settings'], function(Settings) {
var instListEl = $('#installed_themes').empty(), liEl;
- if (themes.length > 0) {
- for (var x = 0, numThemes = themes.length; x < numThemes; x++) {
- liEl = $('
').attr({
- 'data-type': 'local',
- 'data-theme': themes[x].id
- }).html('
' +
- '' +
- '
' +
- ' ' +
- '
' +
- '
' + themes[x].name + '
' +
- '
' +
- themes[x].description +
- (themes[x].url ? ' (Homepage)' : '') +
- '
' +
- '
' +
- '');
-
- instListEl.append(liEl);
- }
- } else {
- // No themes found
+ if (!themes.length) {
instListEl.append($('
').addClass('no-themes').html('No installed themes found'));
+ return;
}
+
+ for (var x = 0, numThemes = themes.length; x < numThemes; x++) {
+ liEl = $('').attr({
+ 'data-type': 'local',
+ 'data-theme': themes[x].id
+ }).html('
' +
+ '' +
+ '
' +
+ ' ' +
+ '
' +
+ '
' + themes[x].name + '
' +
+ '
' +
+ themes[x].description +
+ (themes[x].url ? ' (Homepage)' : '') +
+ '
' +
+ '
' +
+ '');
+
+ instListEl.append(liEl);
+ }
+
+ highlightSelectedTheme(config['theme:id']);
});
// Proper tabbing for "Custom CSS" field
diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js
index 6ccb865b07..2280bb728f 100644
--- a/public/src/forum/topic.js
+++ b/public/src/forum/topic.js
@@ -309,7 +309,7 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
var bookmark = localStorage.getItem('topic:' + tid + ':bookmark');
if (window.location.hash) {
Topic.scrollToPost(window.location.hash.substr(1), true);
- } else if (bookmark && (!config.usePagination || (config.usePagination && pagination.currentPage === 1))) {
+ } else if (bookmark && (!config.usePagination || (config.usePagination && pagination.currentPage === 1)) && Topic.postCount > 1) {
app.alert({
alert_id: 'bookmark',
message: '[[topic:bookmark_instructions]]',
@@ -1042,8 +1042,9 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
$('.progress-bar').width((index / Topic.postCount * 100) + '%');
var currentBookmark = localStorage.getItem('topic:' + templates.get('topic_id') + ':bookmark');
- if (!currentBookmark || parseInt(el.attr('data-pid'), 10) > parseInt(currentBookmark, 10)) {
+ if (!currentBookmark || parseInt(el.attr('data-pid'), 10) >= parseInt(currentBookmark, 10)) {
localStorage.setItem('topic:' + templates.get('topic_id') + ':bookmark', el.attr('data-pid'));
+ app.removeAlert('bookmark');
}
if (!scrollingToPost) {
diff --git a/src/controllers/api.js b/src/controllers/api.js
index 64a7a89885..031acf08f0 100644
--- a/src/controllers/api.js
+++ b/src/controllers/api.js
@@ -30,6 +30,7 @@ apiController.getConfig = function(req, res, next) {
config.topicsPerPage = meta.config.topicsPerPage || 20;
config.postsPerPage = meta.config.postsPerPage || 20;
config.maximumFileSize = meta.config.maximumFileSize;
+ config['theme:id'] = meta.config['theme:id'];
config.defaultLang = meta.config.defaultLang || 'en_GB';
config.environment = process.env.NODE_ENV;
diff --git a/src/database/redis.js b/src/database/redis.js
index d672994b6c..e37afff1ba 100644
--- a/src/database/redis.js
+++ b/src/database/redis.js
@@ -207,9 +207,7 @@
multi.hgetall(keys[x]);
}
- multi.exec(function (err, replies) {
- callback(err, replies);
- });
+ multi.exec(callback);
};
module.getObjectField = function(key, field, callback) {
diff --git a/src/meta.js b/src/meta.js
index 360333db98..ca635e464f 100644
--- a/src/meta.js
+++ b/src/meta.js
@@ -128,12 +128,12 @@ var fs = require('fs'),
},
set: function(data, callback) {
var themeData = {
- 'theme:type': data.type,
- 'theme:id': data.id,
- 'theme:staticDir': '',
- 'theme:templates': '',
- 'theme:src': ''
- };
+ 'theme:type': data.type,
+ 'theme:id': data.id,
+ 'theme:staticDir': '',
+ 'theme:templates': '',
+ 'theme:src': ''
+ };
switch(data.type) {
case 'local':
@@ -155,9 +155,7 @@ var fs = require('fs'),
db.setObject('config', themeData, next);
}
- ], function(err) {
- callback(err);
- });
+ ], callback);
break;
case 'bootswatch':