diff --git a/package.json b/package.json index e4f665bfc6..cee921bd0f 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "nodebb", "license": "GPLv3 or later", "description": "NodeBB Forum", - "version": "0.2.0", + "version": "0.2.1", "homepage": "http://www.nodebb.org", "repository": { "type": "git", diff --git a/public/language/en/topic.json b/public/language/en/topic.json index 9df5829bea..401da12677 100644 --- a/public/language/en/topic.json +++ b/public/language/en/topic.json @@ -12,6 +12,7 @@ "reply": "Reply", "edit": "Edit", "delete": "Delete", + "fork": "Fork", "banned": "banned", "link": "Link", diff --git a/public/src/forum/admin/users.js b/public/src/forum/admin/users.js index 9269200ddf..1d82b1ae11 100644 --- a/public/src/forum/admin/users.js +++ b/public/src/forum/admin/users.js @@ -19,7 +19,7 @@ define(function() { return parent.attr('data-uid'); } - function updateUserButtons() { + function updateUserBanButtons() { jQuery('.ban-btn').each(function(index, element) { var banBtn = $(element); var uid = getUID(banBtn); @@ -27,15 +27,37 @@ define(function() { banBtn.addClass('disabled'); else if (isUserBanned(banBtn)) banBtn.addClass('btn-warning'); + else if (!isUserAdmin(banBtn)) + banBtn.removeClass('disabled'); else banBtn.removeClass('btn-warning'); + updateUserAdminButtons(); + }); + } + + function updateUserAdminButtons() { + jQuery('.admin-btn').each(function(index, element) { + var adminBtn = $(element); + var uid = getUID(adminBtn); + if (isUserAdmin(adminBtn)) { + adminBtn.attr('value', 'UnMake Admin').html('Remove Admin'); + if (uid === yourid) { + adminBtn.addClass('disabled'); + } + } + else if (isUserBanned(adminBtn)) + adminBtn.addClass('disabled'); + else if (!isUserBanned(adminBtn)) + adminBtn.removeClass('disabled'); + else + adminBtn.removeClass('btn-warning'); }); } function initUsers() { - - updateUserButtons(); + updateUserBanButtons(); + updateUserAdminButtons(); $('#users-container').on('click', '.ban-btn', function() { var banBtn = $(this); @@ -49,17 +71,56 @@ define(function() { socket.emit('api:admin.user.unbanUser', uid); banBtn.removeClass('btn-warning'); parent.attr('data-banned', 0); + updateUserAdminButtons(); } else { bootbox.confirm('Do you really want to ban "' + parent.attr('data-username') + '"?', function(confirm) { if (confirm) { socket.emit('api:admin.user.banUser', uid); banBtn.addClass('btn-warning'); parent.attr('data-banned', 1); + updateUserAdminButtons(); } }); } } + return false; + }); + + $('#users-container').on('click', '.admin-btn', function() { + var adminBtn = $(this); + var isAdmin = isUserAdmin(adminBtn); + var parent = adminBtn.parents('.users-box'); + var isBanned = isUserBanned(adminBtn); + var uid = getUID(adminBtn); + + if(uid === yourid){ + app.alert({ + title: 'Error', + message: 'You can\'t remove yourself as Administrator!', + type: 'danger', + timeout: 5000 + }); + } + else if (!isAdmin) { + socket.emit('api:admin.user.makeAdmin', uid); + adminBtn.attr('value', 'UnMake Admin').html('Remove Admin'); + parent.attr('data-admin', 1); + updateUserBanButtons(); + + } else if(uid !== yourid) { + bootbox.confirm('Do you really want to remove this user as admin "' + parent.attr('data-username') + '"?', function(confirm) { + if (confirm) { + socket.emit('api:admin.user.removeAdmin', uid); + adminBtn.attr('value', 'Make Admin').html('Make Admin'); + parent.attr('data-admin', 0); + updateUserBanButtons(); + + } + }); + } + + return false; }); } diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index 531184fcf0..788a0c1718 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -334,13 +334,13 @@ define(['composer'], function(composer) { return false; }); - $('#post-container').delegate('.edit', 'click', function(e) { + $('#post-container').on('click', '.edit', function(e) { var pid = $(this).parents('li').attr('data-pid'); composer.editPost(pid); }); - $('#post-container').delegate('.delete', 'click', function(e) { + $('#post-container').on('click', '.delete', function(e) { var pid = $(this).parents('li').attr('data-pid'), postEl = $(document.querySelector('#post-container li[data-pid="' + pid + '"]')), deleteAction = !postEl.hasClass('deleted') ? true : false, @@ -369,6 +369,21 @@ define(['composer'], function(composer) { } }); + $('#post-container').on('click', '.fork-post', function(e) { + var post = $(this).parents('li'), + pid = post.attr('data-pid'); + + socket.emit('api:topic.createTopicFromPost', {pid:pid}, function(err) { + if(err) { + return app.alertError(err.message); + } + post.fadeOut(500, function() { + post.remove(); + }); + }); + }); + + $('#post-container').on('click', '.chat', function(e) { var username = $(this).parents('li.row').attr('data-username'); var touid = $(this).parents('li.row').attr('data-uid'); diff --git a/public/src/modules/composer.js b/public/src/modules/composer.js index f148dc2d49..826911bc97 100644 --- a/public/src/modules/composer.js +++ b/public/src/modules/composer.js @@ -478,7 +478,6 @@ define(['taskbar'], function(taskbar) { $(reader).on('loadend', function(e) { var regex = /^data:.*;base64,(.*)$/; - console.log(file); var matches = this.result.match(regex); var fileData = { diff --git a/public/src/templates.js b/public/src/templates.js index 0c90900d9c..c451d982bf 100644 --- a/public/src/templates.js +++ b/public/src/templates.js @@ -349,7 +349,9 @@ if (blockInfo) { checkConditional('@first', blockInfo.iterator === 0); + checkConditional('!@first', blockInfo.iterator !== 0); checkConditional('@last', blockInfo.iterator === blockInfo.total); + checkConditional('!@last', blockInfo.iterator !== blockInfo.total); } template = replace(namespace + d, data[d], template); diff --git a/public/templates/admin/categories.tpl b/public/templates/admin/categories.tpl index 9651b387a9..483a481759 100644 --- a/public/templates/admin/categories.tpl +++ b/public/templates/admin/categories.tpl @@ -76,6 +76,21 @@ +
+
+
+ + +
+
+
+
+ + +
+
+
+ diff --git a/public/templates/admin/users.tpl b/public/templates/admin/users.tpl index b2507828d3..3eea35a9d1 100644 --- a/public/templates/admin/users.tpl +++ b/public/templates/admin/users.tpl @@ -33,6 +33,9 @@ {users.postcount} +
+ Make Admin +
Ban
diff --git a/public/templates/home.tpl b/public/templates/home.tpl index 13d7bd6caf..98ce2c7dcd 100644 --- a/public/templates/home.tpl +++ b/public/templates/home.tpl @@ -4,7 +4,7 @@
-
+