mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-11-03 20:45:58 +01:00 
			
		
		
		
	revamped client side scripts so that they are loaded using Require.js instead.
This commit is contained in:
		@@ -76,6 +76,9 @@ var ajaxify = {};
 | 
			
		||||
			templates.flush();
 | 
			
		||||
			templates.load_template(function () {
 | 
			
		||||
				exec_body_scripts(content);
 | 
			
		||||
				require(['forum/' + tpl_url], function(script) {
 | 
			
		||||
					if (script) script.init();
 | 
			
		||||
				});
 | 
			
		||||
 | 
			
		||||
				if (callback) {
 | 
			
		||||
					callback();
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,9 @@
 | 
			
		||||
(function() {
 | 
			
		||||
define(['forum/accountheader'], function(header) {
 | 
			
		||||
	var Account = {};
 | 
			
		||||
 | 
			
		||||
	Account.init = function() {
 | 
			
		||||
		header.init();
 | 
			
		||||
 | 
			
		||||
		var yourid = templates.get('yourid'),
 | 
			
		||||
			theirid = templates.get('theirid'),
 | 
			
		||||
			isFollowing = templates.get('isFollowing');
 | 
			
		||||
@@ -59,21 +64,9 @@
 | 
			
		||||
				ajaxify.go($(this).attr('topic-url'));
 | 
			
		||||
			});
 | 
			
		||||
 | 
			
		||||
		var onlineStatus = $('.account-online-status');
 | 
			
		||||
			socket.on('api:user.isOnline', Account.handleUserOnline);
 | 
			
		||||
 | 
			
		||||
		function handleUserOnline(data) {
 | 
			
		||||
			if (data.online) {
 | 
			
		||||
				onlineStatus.find('span span').text('online');
 | 
			
		||||
				onlineStatus.find('i').attr('class', 'icon-circle');
 | 
			
		||||
			} else {
 | 
			
		||||
				onlineStatus.find('span span').text('offline');
 | 
			
		||||
				onlineStatus.find('i').attr('class', 'icon-circle-blank');
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		socket.on('api:user.isOnline', handleUserOnline);
 | 
			
		||||
 | 
			
		||||
		socket.emit('api:user.isOnline', theirid, handleUserOnline);
 | 
			
		||||
			socket.emit('api:user.isOnline', theirid, Account.handleUserOnline);
 | 
			
		||||
 | 
			
		||||
			socket.on('event:new_post', function(data) {
 | 
			
		||||
				var html = templates.prepare(templates['account'].blocks['posts']).parse(data);
 | 
			
		||||
@@ -81,5 +74,19 @@
 | 
			
		||||
			});
 | 
			
		||||
 | 
			
		||||
		});
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
}());
 | 
			
		||||
	Account.handleUserOnline = function(data) {
 | 
			
		||||
		var onlineStatus = $('.account-online-status');
 | 
			
		||||
 | 
			
		||||
		if (data.online) {
 | 
			
		||||
			onlineStatus.find('span span').text('online');
 | 
			
		||||
			onlineStatus.find('i').attr('class', 'icon-circle');
 | 
			
		||||
		} else {
 | 
			
		||||
			onlineStatus.find('span span').text('offline');
 | 
			
		||||
			onlineStatus.find('i').attr('class', 'icon-circle-blank');
 | 
			
		||||
		}
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	return Account;
 | 
			
		||||
});
 | 
			
		||||
@@ -1,19 +1,21 @@
 | 
			
		||||
var gravatarPicture = templates.get('gravatarpicture');
 | 
			
		||||
var uploadedPicture = templates.get('uploadedpicture');
 | 
			
		||||
 | 
			
		||||
$(document).ready(function() {
 | 
			
		||||
define(['forum/accountheader'], function(header) {
 | 
			
		||||
	var AccountEdit = {};
 | 
			
		||||
 | 
			
		||||
	AccountEdit.init = function() {
 | 
			
		||||
		header.init();
 | 
			
		||||
 | 
			
		||||
		var gravatarPicture = templates.get('gravatarpicture');
 | 
			
		||||
		var uploadedPicture = templates.get('uploadedpicture');
 | 
			
		||||
 | 
			
		||||
		$('#uploadForm').submit(function() {
 | 
			
		||||
		status('uploading the file ...');
 | 
			
		||||
			AccountEdit.status('uploading the file ...');
 | 
			
		||||
 | 
			
		||||
			$('#upload-progress-bar').css('width', '0%');
 | 
			
		||||
			$('#upload-progress-box').show();
 | 
			
		||||
			$('#upload-progress-box').removeClass('hide');
 | 
			
		||||
 | 
			
		||||
			if (!$('#userPhotoInput').val()) {
 | 
			
		||||
			error('select an image to upload!');
 | 
			
		||||
				AccountEdit.error('select an image to upload!');
 | 
			
		||||
				return false;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
@@ -23,7 +25,7 @@ $(document).ready(function() {
 | 
			
		||||
			$(this).ajaxSubmit({
 | 
			
		||||
 | 
			
		||||
				error: function(xhr) {
 | 
			
		||||
				error('Error: ' + xhr.status);
 | 
			
		||||
					AccountEdit.error('Error: ' + xhr.status);
 | 
			
		||||
				},
 | 
			
		||||
 | 
			
		||||
				uploadProgress: function(event, position, total, percent) {
 | 
			
		||||
@@ -34,7 +36,7 @@ $(document).ready(function() {
 | 
			
		||||
 | 
			
		||||
				success: function(response) {
 | 
			
		||||
					if (response.error) {
 | 
			
		||||
					error(response.error);
 | 
			
		||||
						AccountEdit.error(response.error);
 | 
			
		||||
						return;
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
@@ -46,54 +48,20 @@ $(document).ready(function() {
 | 
			
		||||
					uploadedPicture = imageUrlOnServer;
 | 
			
		||||
 | 
			
		||||
					setTimeout(function() {
 | 
			
		||||
					hideAlerts();
 | 
			
		||||
						AccountEdit.hideAlerts();
 | 
			
		||||
						$('#upload-picture-modal').modal('hide');
 | 
			
		||||
					}, 750);
 | 
			
		||||
 | 
			
		||||
					socket.emit('api:updateHeader', {
 | 
			
		||||
						fields: ['username', 'picture', 'userslug']
 | 
			
		||||
					});
 | 
			
		||||
				success('File uploaded successfully!');
 | 
			
		||||
					AccountEdit.success('File uploaded successfully!');
 | 
			
		||||
				}
 | 
			
		||||
			});
 | 
			
		||||
 | 
			
		||||
			return false;
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
	function hideAlerts() {
 | 
			
		||||
		$('#alert-status').addClass('hide');
 | 
			
		||||
		$('#alert-success').addClass('hide');
 | 
			
		||||
		$('#alert-error').addClass('hide');
 | 
			
		||||
		$('#upload-progress-box').addClass('hide');
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function status(message) {
 | 
			
		||||
		hideAlerts();
 | 
			
		||||
		$('#alert-status').text(message).removeClass('hide');
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function success(message) {
 | 
			
		||||
		hideAlerts();
 | 
			
		||||
		$('#alert-success').text(message).removeClass('hide');
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function error(message) {
 | 
			
		||||
		hideAlerts();
 | 
			
		||||
		$('#alert-error').text(message).removeClass('hide');
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function changeUserPicture(type) {
 | 
			
		||||
		var userData = {
 | 
			
		||||
			type: type
 | 
			
		||||
		};
 | 
			
		||||
 | 
			
		||||
		socket.emit('api:user.changePicture', userData, function(success) {
 | 
			
		||||
			if (!success) {
 | 
			
		||||
				app.alertError('There was an error changing picture!');
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
		var selectedImageType = '';
 | 
			
		||||
 | 
			
		||||
		$('#submitBtn').on('click', function() {
 | 
			
		||||
@@ -126,37 +94,9 @@ $(document).ready(function() {
 | 
			
		||||
			return false;
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
	function updateImages() {
 | 
			
		||||
		var currentPicture = $('#user-current-picture').attr('src');
 | 
			
		||||
 | 
			
		||||
		if (gravatarPicture) {
 | 
			
		||||
			$('#user-gravatar-picture').attr('src', gravatarPicture);
 | 
			
		||||
			$('#gravatar-box').show();
 | 
			
		||||
		} else
 | 
			
		||||
			$('#gravatar-box').hide();
 | 
			
		||||
 | 
			
		||||
		if (uploadedPicture) {
 | 
			
		||||
			$('#user-uploaded-picture').attr('src', uploadedPicture);
 | 
			
		||||
			$('#uploaded-box').show();
 | 
			
		||||
		} else
 | 
			
		||||
			$('#uploaded-box').hide();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		if (currentPicture == gravatarPicture)
 | 
			
		||||
			$('#gravatar-box .icon-ok').show();
 | 
			
		||||
		else
 | 
			
		||||
			$('#gravatar-box .icon-ok').hide();
 | 
			
		||||
 | 
			
		||||
		if (currentPicture == uploadedPicture)
 | 
			
		||||
			$('#uploaded-box .icon-ok').show();
 | 
			
		||||
		else
 | 
			
		||||
			$('#uploaded-box .icon-ok').hide();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		$('#changePictureBtn').on('click', function() {
 | 
			
		||||
			selectedImageType = '';
 | 
			
		||||
		updateImages();
 | 
			
		||||
			AccountEdit.updateImages();
 | 
			
		||||
 | 
			
		||||
			$('#change-picture-modal').modal('show');
 | 
			
		||||
			$('#change-picture-modal').removeClass('hide');
 | 
			
		||||
@@ -180,7 +120,7 @@ $(document).ready(function() {
 | 
			
		||||
			$('#change-picture-modal').modal('hide');
 | 
			
		||||
 | 
			
		||||
			if (selectedImageType) {
 | 
			
		||||
			changeUserPicture(selectedImageType);
 | 
			
		||||
				AccountEdit.changeUserPicture(selectedImageType);
 | 
			
		||||
 | 
			
		||||
				if (selectedImageType == 'gravatar')
 | 
			
		||||
					$('#user-current-picture').attr('src', gravatarPicture);
 | 
			
		||||
@@ -200,7 +140,7 @@ $(document).ready(function() {
 | 
			
		||||
			$('#upload-picture-modal').modal('show');
 | 
			
		||||
			$('#upload-picture-modal').removeClass('hide');
 | 
			
		||||
 | 
			
		||||
		hideAlerts();
 | 
			
		||||
			AccountEdit.hideAlerts();
 | 
			
		||||
 | 
			
		||||
			return false;
 | 
			
		||||
		});
 | 
			
		||||
@@ -288,4 +228,70 @@ $(document).ready(function() {
 | 
			
		||||
			});
 | 
			
		||||
 | 
			
		||||
		}());
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	AccountEdit.hideAlerts = function() {
 | 
			
		||||
		$('#alert-status').addClass('hide');
 | 
			
		||||
		$('#alert-success').addClass('hide');
 | 
			
		||||
		$('#alert-error').addClass('hide');
 | 
			
		||||
		$('#upload-progress-box').addClass('hide');
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	AccountEdit.status = function(message) {
 | 
			
		||||
		AccountEdit.hideAlerts();
 | 
			
		||||
		$('#alert-status').text(message).removeClass('hide');
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	AccountEdit.success = function(message) {
 | 
			
		||||
		AccountEdit.hideAlerts();
 | 
			
		||||
		$('#alert-success').text(message).removeClass('hide');
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	AccountEdit.error = function(message) {
 | 
			
		||||
		AccountEdit.hideAlerts();
 | 
			
		||||
		$('#alert-error').text(message).removeClass('hide');
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	AccountEdit.changeUserPicture = function(type) {
 | 
			
		||||
		var userData = {
 | 
			
		||||
			type: type
 | 
			
		||||
		};
 | 
			
		||||
 | 
			
		||||
		socket.emit('api:user.changePicture', userData, function(success) {
 | 
			
		||||
			if (!success) {
 | 
			
		||||
				app.alertError('There was an error changing picture!');
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	AccountEdit.updateImages = function() {
 | 
			
		||||
		var currentPicture = $('#user-current-picture').attr('src');
 | 
			
		||||
		var gravatarPicture = templates.get('gravatarpicture');
 | 
			
		||||
		var uploadedPicture = templates.get('uploadedpicture');
 | 
			
		||||
 | 
			
		||||
		if (gravatarPicture) {
 | 
			
		||||
			$('#user-gravatar-picture').attr('src', gravatarPicture);
 | 
			
		||||
			$('#gravatar-box').show();
 | 
			
		||||
		} else
 | 
			
		||||
			$('#gravatar-box').hide();
 | 
			
		||||
 | 
			
		||||
		if (uploadedPicture) {
 | 
			
		||||
			$('#user-uploaded-picture').attr('src', uploadedPicture);
 | 
			
		||||
			$('#uploaded-box').show();
 | 
			
		||||
		} else
 | 
			
		||||
			$('#uploaded-box').hide();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		if (currentPicture == gravatarPicture)
 | 
			
		||||
			$('#gravatar-box .icon-ok').show();
 | 
			
		||||
		else
 | 
			
		||||
			$('#gravatar-box .icon-ok').hide();
 | 
			
		||||
 | 
			
		||||
		if (currentPicture == uploadedPicture)
 | 
			
		||||
			$('#uploaded-box .icon-ok').show();
 | 
			
		||||
		else
 | 
			
		||||
			$('#uploaded-box .icon-ok').hide();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return AccountEdit;
 | 
			
		||||
});
 | 
			
		||||
@@ -1,24 +1,11 @@
 | 
			
		||||
(function() {
 | 
			
		||||
define(function() {
 | 
			
		||||
	var	AccountHeader = {};
 | 
			
		||||
 | 
			
		||||
	AccountHeader.init = function() {
 | 
			
		||||
		var yourid = templates.get('yourid'),
 | 
			
		||||
			theirid = templates.get('theirid');
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	function createMenu() {
 | 
			
		||||
		var userslug = $('.account-username-box').attr('data-userslug');
 | 
			
		||||
		var links = $('<div class="account-sub-links inline-block pull-right">\
 | 
			
		||||
			<span id="settingsLink" class="pull-right"><a href="/user/' + userslug + '/settings">settings</a></span>\
 | 
			
		||||
			<span id="favouritesLink" class="pull-right"><a href="/user/' + userslug + '/favourites">favourites</a></span>\
 | 
			
		||||
			<span class="pull-right"><a href="/user/' + userslug + '/followers">followers</a></span>\
 | 
			
		||||
			<span class="pull-right"><a href="/user/' + userslug + '/following">following</a></span>\
 | 
			
		||||
			<span id="editLink" class="pull-right"><a href="/user/' + userslug + '/edit">edit</a></span>\
 | 
			
		||||
		</div>');
 | 
			
		||||
 | 
			
		||||
		$('.account-username-box').append(links);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	$(document).ready(function() {
 | 
			
		||||
 | 
			
		||||
		createMenu();
 | 
			
		||||
		AccountHeader.createMenu();
 | 
			
		||||
 | 
			
		||||
		var editLink = $('#editLink');
 | 
			
		||||
		var settingsLink = $('#settingsLink');
 | 
			
		||||
@@ -37,6 +24,20 @@
 | 
			
		||||
				return false;
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
	});
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}());
 | 
			
		||||
	AccountHeader.createMenu = function() {
 | 
			
		||||
		var userslug = $('.account-username-box').attr('data-userslug');
 | 
			
		||||
		var links = $('<div class="account-sub-links inline-block pull-right">\
 | 
			
		||||
			<span id="settingsLink" class="pull-right"><a href="/user/' + userslug + '/settings">settings</a></span>\
 | 
			
		||||
			<span id="favouritesLink" class="pull-right"><a href="/user/' + userslug + '/favourites">favourites</a></span>\
 | 
			
		||||
			<span class="pull-right"><a href="/user/' + userslug + '/followers">followers</a></span>\
 | 
			
		||||
			<span class="pull-right"><a href="/user/' + userslug + '/following">following</a></span>\
 | 
			
		||||
			<span id="editLink" class="pull-right"><a href="/user/' + userslug + '/edit">edit</a></span>\
 | 
			
		||||
		</div>');
 | 
			
		||||
 | 
			
		||||
		$('.account-username-box').append(links);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return AccountHeader;
 | 
			
		||||
});
 | 
			
		||||
@@ -1,4 +1,8 @@
 | 
			
		||||
$(document).ready(function() {
 | 
			
		||||
define(['forum/accountheader'], function(header) {
 | 
			
		||||
	var	AccountSettings = {};
 | 
			
		||||
 | 
			
		||||
	AccountSettings.init = function() {
 | 
			
		||||
		header.init();
 | 
			
		||||
 | 
			
		||||
		$('#submitBtn').on('click', function() {
 | 
			
		||||
 | 
			
		||||
@@ -15,5 +19,7 @@ $(document).ready(function() {
 | 
			
		||||
			});
 | 
			
		||||
			return false;
 | 
			
		||||
		});
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	return AccountSettings;
 | 
			
		||||
});
 | 
			
		||||
@@ -1,18 +1,22 @@
 | 
			
		||||
var modified_categories = {};
 | 
			
		||||
define(function() {
 | 
			
		||||
	var	Categories = {};
 | 
			
		||||
 | 
			
		||||
function modified(el) {
 | 
			
		||||
	Categories.init = function() {
 | 
			
		||||
		var modified_categories = {};
 | 
			
		||||
 | 
			
		||||
		function modified(el) {
 | 
			
		||||
			var cid = $(el).parents('li').attr('data-cid');
 | 
			
		||||
 | 
			
		||||
			modified_categories[cid] = modified_categories[cid] || {};
 | 
			
		||||
			modified_categories[cid][$(el).attr('data-name')] = $(el).val();
 | 
			
		||||
}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
function save() {
 | 
			
		||||
		function save() {
 | 
			
		||||
			socket.emit('api:admin.categories.update', modified_categories);
 | 
			
		||||
			modified_categories = {};
 | 
			
		||||
}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
function select_icon(el) {
 | 
			
		||||
		function select_icon(el) {
 | 
			
		||||
			var selected = el.attr('class').replace(' icon-2x', '');
 | 
			
		||||
			jQuery('#icons .selected').removeClass('selected');
 | 
			
		||||
			if (selected)
 | 
			
		||||
@@ -35,21 +39,20 @@ function select_icon(el) {
 | 
			
		||||
					jQuery(this).addClass('selected');
 | 
			
		||||
				});
 | 
			
		||||
			}, 500);
 | 
			
		||||
}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
function update_blockclass(el) {
 | 
			
		||||
		function update_blockclass(el) {
 | 
			
		||||
			el.parentNode.parentNode.className = 'entry-row ' + el.value;
 | 
			
		||||
}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
jQuery('#entry-container').sortable();
 | 
			
		||||
jQuery('.blockclass').each(function() {
 | 
			
		||||
		jQuery('#entry-container').sortable();
 | 
			
		||||
		jQuery('.blockclass').each(function() {
 | 
			
		||||
			jQuery(this).val(this.getAttribute('data-value'));
 | 
			
		||||
});
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//DRY Failure. this needs to go into an ajaxify onready style fn. Currently is copy pasted into every single function so after ACP is off the ground fix asap
 | 
			
		||||
(function() {
 | 
			
		||||
		//DRY Failure. this needs to go into an ajaxify onready style fn. Currently is copy pasted into every single function so after ACP is off the ground fix asap
 | 
			
		||||
		function showCreateCategoryModal() {
 | 
			
		||||
			$('#new-category-modal').modal();
 | 
			
		||||
		}
 | 
			
		||||
@@ -135,5 +138,7 @@ jQuery('.blockclass').each(function() {
 | 
			
		||||
			});
 | 
			
		||||
 | 
			
		||||
		});
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
}());
 | 
			
		||||
	return Categories;
 | 
			
		||||
});
 | 
			
		||||
@@ -1,79 +1,4 @@
 | 
			
		||||
var nodebb_admin = (function(nodebb_admin) {
 | 
			
		||||
 | 
			
		||||
	nodebb_admin.config = undefined;
 | 
			
		||||
 | 
			
		||||
	nodebb_admin.prepare = function() {
 | 
			
		||||
		// Come back in 500ms if the config isn't ready yet
 | 
			
		||||
		if (nodebb_admin.config === undefined) {
 | 
			
		||||
			setTimeout(function() {
 | 
			
		||||
				nodebb_admin.prepare();
 | 
			
		||||
			}, 500);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Populate the fields on the page from the config
 | 
			
		||||
		var fields = document.querySelectorAll('#content [data-field]'),
 | 
			
		||||
			numFields = fields.length,
 | 
			
		||||
			saveBtn = document.getElementById('save'),
 | 
			
		||||
			x, key, inputType;
 | 
			
		||||
		for (x = 0; x < numFields; x++) {
 | 
			
		||||
			key = fields[x].getAttribute('data-field');
 | 
			
		||||
			inputType = fields[x].getAttribute('type');
 | 
			
		||||
			if (fields[x].nodeName === 'INPUT') {
 | 
			
		||||
				if (nodebb_admin.config[key]) {
 | 
			
		||||
					switch (inputType) {
 | 
			
		||||
						case 'text':
 | 
			
		||||
						case 'textarea':
 | 
			
		||||
						case 'number':
 | 
			
		||||
							fields[x].value = nodebb_admin.config[key];
 | 
			
		||||
							break;
 | 
			
		||||
 | 
			
		||||
						case 'checkbox':
 | 
			
		||||
							fields[x].checked = nodebb_admin.config[key] === '1' ? true : false;
 | 
			
		||||
							break;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			} else if (fields[x].nodeName === 'TEXTAREA') {
 | 
			
		||||
				if (nodebb_admin.config[key]) fields[x].value = nodebb_admin.config[key];
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		saveBtn.addEventListener('click', function(e) {
 | 
			
		||||
			var key, value;
 | 
			
		||||
			e.preventDefault();
 | 
			
		||||
 | 
			
		||||
			for (x = 0; x < numFields; x++) {
 | 
			
		||||
				key = fields[x].getAttribute('data-field');
 | 
			
		||||
				if (fields[x].nodeName === 'INPUT') {
 | 
			
		||||
					inputType = fields[x].getAttribute('type');
 | 
			
		||||
					switch (inputType) {
 | 
			
		||||
						case 'text':
 | 
			
		||||
						case 'number':
 | 
			
		||||
							value = fields[x].value;
 | 
			
		||||
							break;
 | 
			
		||||
 | 
			
		||||
						case 'checkbox':
 | 
			
		||||
							value = fields[x].checked ? '1' : '0';
 | 
			
		||||
							break;
 | 
			
		||||
					}
 | 
			
		||||
				} else if (fields[x].nodeName === 'TEXTAREA') {
 | 
			
		||||
					value = fields[x].value;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				socket.emit('api:config.set', {
 | 
			
		||||
					key: key,
 | 
			
		||||
					value: value
 | 
			
		||||
				});
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	nodebb_admin.remove = function(key) {
 | 
			
		||||
		socket.emit('api:config.remove', key);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	jQuery('document').ready(function() {
 | 
			
		||||
jQuery('document').ready(function() {
 | 
			
		||||
	// On menu click, change "active" state
 | 
			
		||||
	var menuEl = document.querySelector('.sidebar-nav'),
 | 
			
		||||
		liEls = menuEl.querySelectorAll('li')
 | 
			
		||||
@@ -88,15 +13,17 @@ var nodebb_admin = (function(nodebb_admin) {
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}, false);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
socket.once('api:config.get', function(config) {
 | 
			
		||||
	require(['forum/admin/settings'], function(Settings) {
 | 
			
		||||
		Settings.config = config;
 | 
			
		||||
	});
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
	socket.once('api:config.get', function(config) {
 | 
			
		||||
		nodebb_admin.config = config;
 | 
			
		||||
	});
 | 
			
		||||
socket.emit('api:config.get');
 | 
			
		||||
 | 
			
		||||
	socket.emit('api:config.get');
 | 
			
		||||
 | 
			
		||||
	socket.on('api:config.set', function(data) {
 | 
			
		||||
socket.on('api:config.set', function(data) {
 | 
			
		||||
	if (data.status === 'ok') {
 | 
			
		||||
		app.alert({
 | 
			
		||||
			alert_id: 'config_status',
 | 
			
		||||
@@ -114,8 +41,4 @@ var nodebb_admin = (function(nodebb_admin) {
 | 
			
		||||
			type: 'danger'
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	return nodebb_admin;
 | 
			
		||||
 | 
			
		||||
}(nodebb_admin || {}));
 | 
			
		||||
});
 | 
			
		||||
@@ -1,4 +1,7 @@
 | 
			
		||||
$(document).ready(function() {
 | 
			
		||||
define(function() {
 | 
			
		||||
	var	Groups = {};
 | 
			
		||||
 | 
			
		||||
	Groups.init = function() {
 | 
			
		||||
		var createEl = document.getElementById('create'),
 | 
			
		||||
			createModal = $('#create-modal'),
 | 
			
		||||
			createSubmitBtn = document.getElementById('create-modal-go'),
 | 
			
		||||
@@ -191,4 +194,7 @@ $(document).ready(function() {
 | 
			
		||||
				}
 | 
			
		||||
			});
 | 
			
		||||
		});
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	return Groups;
 | 
			
		||||
});
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
define(function() {
 | 
			
		||||
	var	Admin = {};
 | 
			
		||||
 | 
			
		||||
(function() {
 | 
			
		||||
 | 
			
		||||
		Admin.init = function() {
 | 
			
		||||
		ajaxify.register_events(['api:get_all_rooms']);
 | 
			
		||||
		socket.on('api:get_all_rooms', function(data) {
 | 
			
		||||
 | 
			
		||||
@@ -21,5 +22,7 @@
 | 
			
		||||
 | 
			
		||||
		app.enter_room('admin');
 | 
			
		||||
		socket.emit('api:get_all_rooms');
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
}());
 | 
			
		||||
	return Admin;
 | 
			
		||||
});
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,5 @@
 | 
			
		||||
var nodebb_admin = nodebb_admin || {};
 | 
			
		||||
 | 
			
		||||
(function() {
 | 
			
		||||
	var plugins = {
 | 
			
		||||
define(function() {
 | 
			
		||||
	var Plugins = {
 | 
			
		||||
		init: function() {
 | 
			
		||||
			var pluginsList = $('.plugins'),
 | 
			
		||||
				numPlugins = pluginsList[0].querySelectorAll('li').length,
 | 
			
		||||
@@ -31,8 +29,5 @@ var nodebb_admin = nodebb_admin || {};
 | 
			
		||||
		}
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	jQuery(document).ready(function() {
 | 
			
		||||
		nodebb_admin.plugins = plugins;
 | 
			
		||||
		nodebb_admin.plugins.init();
 | 
			
		||||
	});
 | 
			
		||||
})();
 | 
			
		||||
	return Plugins;
 | 
			
		||||
});
 | 
			
		||||
							
								
								
									
										81
									
								
								public/src/forum/admin/settings.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								public/src/forum/admin/settings.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,81 @@
 | 
			
		||||
define(function() {
 | 
			
		||||
	var Settings = {};
 | 
			
		||||
 | 
			
		||||
	Settings.config = {};
 | 
			
		||||
 | 
			
		||||
	Settings.init = function() {
 | 
			
		||||
		Settings.prepare();
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	Settings.prepare = function() {
 | 
			
		||||
		// Come back in 500ms if the config isn't ready yet
 | 
			
		||||
		if (Settings.config === undefined) {
 | 
			
		||||
			setTimeout(function() {
 | 
			
		||||
				Settings.prepare();
 | 
			
		||||
			}, 500);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Populate the fields on the page from the config
 | 
			
		||||
		var fields = document.querySelectorAll('#content [data-field]'),
 | 
			
		||||
			numFields = fields.length,
 | 
			
		||||
			saveBtn = document.getElementById('save'),
 | 
			
		||||
			x, key, inputType;
 | 
			
		||||
		for (x = 0; x < numFields; x++) {
 | 
			
		||||
			key = fields[x].getAttribute('data-field');
 | 
			
		||||
			inputType = fields[x].getAttribute('type');
 | 
			
		||||
			if (fields[x].nodeName === 'INPUT') {
 | 
			
		||||
				if (Settings.config[key]) {
 | 
			
		||||
					switch (inputType) {
 | 
			
		||||
						case 'text':
 | 
			
		||||
						case 'textarea':
 | 
			
		||||
						case 'number':
 | 
			
		||||
							fields[x].value = Settings.config[key];
 | 
			
		||||
							break;
 | 
			
		||||
 | 
			
		||||
						case 'checkbox':
 | 
			
		||||
							fields[x].checked = Settings.config[key] === '1' ? true : false;
 | 
			
		||||
							break;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			} else if (fields[x].nodeName === 'TEXTAREA') {
 | 
			
		||||
				if (Settings.config[key]) fields[x].value = Settings.config[key];
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		saveBtn.addEventListener('click', function(e) {
 | 
			
		||||
			var key, value;
 | 
			
		||||
			e.preventDefault();
 | 
			
		||||
 | 
			
		||||
			for (x = 0; x < numFields; x++) {
 | 
			
		||||
				key = fields[x].getAttribute('data-field');
 | 
			
		||||
				if (fields[x].nodeName === 'INPUT') {
 | 
			
		||||
					inputType = fields[x].getAttribute('type');
 | 
			
		||||
					switch (inputType) {
 | 
			
		||||
						case 'text':
 | 
			
		||||
						case 'number':
 | 
			
		||||
							value = fields[x].value;
 | 
			
		||||
							break;
 | 
			
		||||
 | 
			
		||||
						case 'checkbox':
 | 
			
		||||
							value = fields[x].checked ? '1' : '0';
 | 
			
		||||
							break;
 | 
			
		||||
					}
 | 
			
		||||
				} else if (fields[x].nodeName === 'TEXTAREA') {
 | 
			
		||||
					value = fields[x].value;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				socket.emit('api:config.set', {
 | 
			
		||||
					key: key,
 | 
			
		||||
					value: value
 | 
			
		||||
				});
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	Settings.remove = function(key) {
 | 
			
		||||
		socket.emit('api:config.remove', key);
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	return Settings;
 | 
			
		||||
});
 | 
			
		||||
@@ -1,43 +1,9 @@
 | 
			
		||||
var nodebb_admin = (function(nodebb_admin) {
 | 
			
		||||
define(function() {
 | 
			
		||||
	var Themes = {};
 | 
			
		||||
 | 
			
		||||
	var themes = {};
 | 
			
		||||
 | 
			
		||||
	themes.render = function(bootswatch) {
 | 
			
		||||
		var themeFrag = document.createDocumentFragment(),
 | 
			
		||||
			themeEl = document.createElement('li'),
 | 
			
		||||
			themeContainer = document.querySelector('#bootstrap_themes'),
 | 
			
		||||
			numThemes = bootswatch.themes.length;
 | 
			
		||||
 | 
			
		||||
		for (var x = 0; x < numThemes; x++) {
 | 
			
		||||
			var theme = bootswatch.themes[x];
 | 
			
		||||
			themeEl.setAttribute('data-css', theme.cssMin);
 | 
			
		||||
			themeEl.setAttribute('data-theme', theme.name);
 | 
			
		||||
			themeEl.innerHTML = '<img src="' + theme.thumbnail + '" />' +
 | 
			
		||||
				'<div>' +
 | 
			
		||||
				'<div class="pull-right">' +
 | 
			
		||||
				'<button class="btn btn-primary" data-action="use">Use</button> ' +
 | 
			
		||||
				'<button class="btn btn-default" data-action="preview">Preview</button>' +
 | 
			
		||||
				'</div>' +
 | 
			
		||||
				'<h4>' + theme.name + '</h4>' +
 | 
			
		||||
				'<p>' + theme.description + '</p>' +
 | 
			
		||||
				'</div>' +
 | 
			
		||||
				'<div class="clear">';
 | 
			
		||||
			themeFrag.appendChild(themeEl.cloneNode(true));
 | 
			
		||||
		}
 | 
			
		||||
		themeContainer.innerHTML = '';
 | 
			
		||||
		themeContainer.appendChild(themeFrag);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	nodebb_admin.themes = themes;
 | 
			
		||||
 | 
			
		||||
	return nodebb_admin;
 | 
			
		||||
 | 
			
		||||
}(nodebb_admin || {}));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
(function() {
 | 
			
		||||
	Themes.init = function() {
 | 
			
		||||
		var scriptEl = document.createElement('script');
 | 
			
		||||
	scriptEl.src = 'http://api.bootswatch.com/3/?callback=nodebb_admin.themes.render';
 | 
			
		||||
		scriptEl.src = 'http://api.bootswatch.com/3/?callback=bootswatchListener';
 | 
			
		||||
		document.body.appendChild(scriptEl);
 | 
			
		||||
 | 
			
		||||
		var bootstrapThemeContainer = document.querySelector('#bootstrap_themes'),
 | 
			
		||||
@@ -74,8 +40,10 @@ var nodebb_admin = (function(nodebb_admin) {
 | 
			
		||||
		revertEl.addEventListener('click', function() {
 | 
			
		||||
			bootbox.confirm('Are you sure you wish to remove the custom theme and restore the NodeBB default theme?', function(confirm) {
 | 
			
		||||
				if (confirm) {
 | 
			
		||||
				nodebb_admin.remove('theme:id');
 | 
			
		||||
				nodebb_admin.remove('theme:src');
 | 
			
		||||
					require(['forum/admin/settings'], function(Settings) {
 | 
			
		||||
						Settings.remove('theme:id');
 | 
			
		||||
						Settings.remove('theme:src');
 | 
			
		||||
					});
 | 
			
		||||
				}
 | 
			
		||||
			});
 | 
			
		||||
		}, false);
 | 
			
		||||
@@ -115,4 +83,33 @@ var nodebb_admin = (function(nodebb_admin) {
 | 
			
		||||
			instListEl.innerHTML = '';
 | 
			
		||||
			instListEl.appendChild(themeFrag);
 | 
			
		||||
		});
 | 
			
		||||
})();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	Themes.render = function(bootswatch) {
 | 
			
		||||
		var themeFrag = document.createDocumentFragment(),
 | 
			
		||||
			themeEl = document.createElement('li'),
 | 
			
		||||
			themeContainer = document.querySelector('#bootstrap_themes'),
 | 
			
		||||
			numThemes = bootswatch.themes.length;
 | 
			
		||||
 | 
			
		||||
		for (var x = 0; x < numThemes; x++) {
 | 
			
		||||
			var theme = bootswatch.themes[x];
 | 
			
		||||
			themeEl.setAttribute('data-css', theme.cssMin);
 | 
			
		||||
			themeEl.setAttribute('data-theme', theme.name);
 | 
			
		||||
			themeEl.innerHTML = '<img src="' + theme.thumbnail + '" />' +
 | 
			
		||||
				'<div>' +
 | 
			
		||||
				'<div class="pull-right">' +
 | 
			
		||||
				'<button class="btn btn-primary" data-action="use">Use</button> ' +
 | 
			
		||||
				'<button class="btn btn-default" data-action="preview">Preview</button>' +
 | 
			
		||||
				'</div>' +
 | 
			
		||||
				'<h4>' + theme.name + '</h4>' +
 | 
			
		||||
				'<p>' + theme.description + '</p>' +
 | 
			
		||||
				'</div>' +
 | 
			
		||||
				'<div class="clear">';
 | 
			
		||||
			themeFrag.appendChild(themeEl.cloneNode(true));
 | 
			
		||||
		}
 | 
			
		||||
		themeContainer.innerHTML = '';
 | 
			
		||||
		themeContainer.appendChild(themeFrag);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return Themes;
 | 
			
		||||
});
 | 
			
		||||
@@ -1,4 +1,7 @@
 | 
			
		||||
$(document).ready(function() {
 | 
			
		||||
define(function() {
 | 
			
		||||
	var	Topics = {};
 | 
			
		||||
 | 
			
		||||
	Topics.init = function() {
 | 
			
		||||
		var topicsListEl = document.querySelector('.topics'),
 | 
			
		||||
			loadMoreEl = document.getElementById('topics_loadmore');
 | 
			
		||||
 | 
			
		||||
@@ -76,52 +79,55 @@ $(document).ready(function() {
 | 
			
		||||
			topicEls[x].removeAttribute('data-locked');
 | 
			
		||||
			topicEls[x].removeAttribute('data-deleted');
 | 
			
		||||
		}
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
socket.on('api:topic.pin', function(response) {
 | 
			
		||||
		socket.on('api:topic.pin', function(response) {
 | 
			
		||||
			if (response.status === 'ok') {
 | 
			
		||||
				var btnEl = document.querySelector('li[data-tid="' + response.tid + '"] button[data-action="pin"]');
 | 
			
		||||
 | 
			
		||||
				$(btnEl).addClass('active');
 | 
			
		||||
			}
 | 
			
		||||
});
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
socket.on('api:topic.unpin', function(response) {
 | 
			
		||||
		socket.on('api:topic.unpin', function(response) {
 | 
			
		||||
			if (response.status === 'ok') {
 | 
			
		||||
				var btnEl = document.querySelector('li[data-tid="' + response.tid + '"] button[data-action="pin"]');
 | 
			
		||||
 | 
			
		||||
				$(btnEl).removeClass('active');
 | 
			
		||||
			}
 | 
			
		||||
});
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
socket.on('api:topic.lock', function(response) {
 | 
			
		||||
		socket.on('api:topic.lock', function(response) {
 | 
			
		||||
			if (response.status === 'ok') {
 | 
			
		||||
				var btnEl = document.querySelector('li[data-tid="' + response.tid + '"] button[data-action="lock"]');
 | 
			
		||||
 | 
			
		||||
				$(btnEl).addClass('active');
 | 
			
		||||
			}
 | 
			
		||||
});
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
socket.on('api:topic.unlock', function(response) {
 | 
			
		||||
		socket.on('api:topic.unlock', function(response) {
 | 
			
		||||
			if (response.status === 'ok') {
 | 
			
		||||
				var btnEl = document.querySelector('li[data-tid="' + response.tid + '"] button[data-action="lock"]');
 | 
			
		||||
 | 
			
		||||
				$(btnEl).removeClass('active');
 | 
			
		||||
			}
 | 
			
		||||
});
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
socket.on('api:topic.delete', function(response) {
 | 
			
		||||
		socket.on('api:topic.delete', function(response) {
 | 
			
		||||
			if (response.status === 'ok') {
 | 
			
		||||
				var btnEl = document.querySelector('li[data-tid="' + response.tid + '"] button[data-action="delete"]');
 | 
			
		||||
 | 
			
		||||
				$(btnEl).addClass('active');
 | 
			
		||||
			}
 | 
			
		||||
});
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
socket.on('api:topic.restore', function(response) {
 | 
			
		||||
		socket.on('api:topic.restore', function(response) {
 | 
			
		||||
			if (response.status === 'ok') {
 | 
			
		||||
				var btnEl = document.querySelector('li[data-tid="' + response.tid + '"] button[data-action="delete"]');
 | 
			
		||||
 | 
			
		||||
				$(btnEl).removeClass('active');
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	return Topics;
 | 
			
		||||
});
 | 
			
		||||
@@ -1,5 +1,7 @@
 | 
			
		||||
(function() {
 | 
			
		||||
define(function() {
 | 
			
		||||
	var Users = {};
 | 
			
		||||
 | 
			
		||||
	Users.init = function() {
 | 
			
		||||
		var yourid = templates.get('yourid');
 | 
			
		||||
 | 
			
		||||
		function isUserAdmin(element) {
 | 
			
		||||
@@ -166,5 +168,7 @@
 | 
			
		||||
			});
 | 
			
		||||
 | 
			
		||||
		});
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
}());
 | 
			
		||||
	return Users;
 | 
			
		||||
});
 | 
			
		||||
@@ -1,4 +1,7 @@
 | 
			
		||||
(function () {
 | 
			
		||||
define(function () {
 | 
			
		||||
	var	Category = {};
 | 
			
		||||
 | 
			
		||||
	Category.init = function() {
 | 
			
		||||
		var cid = templates.get('category_id'),
 | 
			
		||||
			room = 'category_' + cid,
 | 
			
		||||
			twitterEl = document.getElementById('twitter-intent'),
 | 
			
		||||
@@ -35,36 +38,7 @@
 | 
			
		||||
			'event:new_topic'
 | 
			
		||||
		]);
 | 
			
		||||
 | 
			
		||||
	function onNewTopic(data) {
 | 
			
		||||
		var html = templates.prepare(templates['category'].blocks['topics']).parse({
 | 
			
		||||
			topics: [data]
 | 
			
		||||
		}),
 | 
			
		||||
			topic = $(html),
 | 
			
		||||
			container = $('#topics-container'),
 | 
			
		||||
			topics = $('#topics-container').children(),
 | 
			
		||||
			numTopics = topics.length;
 | 
			
		||||
 | 
			
		||||
		jQuery('#topics-container, .category-sidebar').removeClass('hidden');
 | 
			
		||||
		jQuery('#category-no-topics').remove();
 | 
			
		||||
 | 
			
		||||
		if (numTopics > 0) {
 | 
			
		||||
			for (var x = 0; x < numTopics; x++) {
 | 
			
		||||
				if ($(topics[x]).find('.icon-pushpin').length)
 | 
			
		||||
					continue;
 | 
			
		||||
				topic.insertBefore(topics[x]);
 | 
			
		||||
				topic.hide().fadeIn('slow');
 | 
			
		||||
				break;
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			container.append(topic);
 | 
			
		||||
			topic.hide().fadeIn('slow');
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		socket.emit('api:categories.getRecentReplies', cid);
 | 
			
		||||
		$('#topics-container span.timeago').timeago();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	socket.on('event:new_topic', onNewTopic);
 | 
			
		||||
		socket.on('event:new_topic', Category.onNewTopic);
 | 
			
		||||
 | 
			
		||||
		socket.emit('api:categories.getRecentReplies', cid);
 | 
			
		||||
		socket.on('api:categories.getRecentReplies', function (posts) {
 | 
			
		||||
@@ -97,7 +71,45 @@
 | 
			
		||||
			$('#category_recent_replies span.timeago').timeago();
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
	function onTopicsLoaded(topics) {
 | 
			
		||||
		$(window).off('scroll').on('scroll', function (ev) {
 | 
			
		||||
			var bottom = ($(document).height() - $(window).height()) * 0.9;
 | 
			
		||||
 | 
			
		||||
			if ($(window).scrollTop() > bottom && !loadingMoreTopics) {
 | 
			
		||||
				Category.loadMoreTopics(cid);
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	Category.onNewTopic = function(data) {
 | 
			
		||||
		var html = templates.prepare(templates['category'].blocks['topics']).parse({
 | 
			
		||||
			topics: [data]
 | 
			
		||||
		}),
 | 
			
		||||
			topic = $(html),
 | 
			
		||||
			container = $('#topics-container'),
 | 
			
		||||
			topics = $('#topics-container').children(),
 | 
			
		||||
			numTopics = topics.length;
 | 
			
		||||
 | 
			
		||||
		jQuery('#topics-container, .category-sidebar').removeClass('hidden');
 | 
			
		||||
		jQuery('#category-no-topics').remove();
 | 
			
		||||
 | 
			
		||||
		if (numTopics > 0) {
 | 
			
		||||
			for (var x = 0; x < numTopics; x++) {
 | 
			
		||||
				if ($(topics[x]).find('.icon-pushpin').length)
 | 
			
		||||
					continue;
 | 
			
		||||
				topic.insertBefore(topics[x]);
 | 
			
		||||
				topic.hide().fadeIn('slow');
 | 
			
		||||
				break;
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			container.append(topic);
 | 
			
		||||
			topic.hide().fadeIn('slow');
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		socket.emit('api:categories.getRecentReplies', cid);
 | 
			
		||||
		$('#topics-container span.timeago').timeago();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	Category.onTopicsLoaded = function(topics) {
 | 
			
		||||
 | 
			
		||||
		var html = templates.prepare(templates['category'].blocks['topics']).parse({
 | 
			
		||||
			topics: topics
 | 
			
		||||
@@ -113,26 +125,18 @@
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	function loadMoreTopics(cid) {
 | 
			
		||||
	Category.loadMoreTopics = function(cid) {
 | 
			
		||||
		loadingMoreTopics = true;
 | 
			
		||||
		socket.emit('api:category.loadMore', {
 | 
			
		||||
			cid: cid,
 | 
			
		||||
			after: $('#topics-container').children().length
 | 
			
		||||
		}, function (data) {
 | 
			
		||||
			if (data.topics.length) {
 | 
			
		||||
				onTopicsLoaded(data.topics);
 | 
			
		||||
				Category.onTopicsLoaded(data.topics);
 | 
			
		||||
			}
 | 
			
		||||
			loadingMoreTopics = false;
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	$(window).off('scroll').on('scroll', function (ev) {
 | 
			
		||||
		var bottom = ($(document).height() - $(window).height()) * 0.9;
 | 
			
		||||
 | 
			
		||||
		if ($(window).scrollTop() > bottom && !loadingMoreTopics) {
 | 
			
		||||
			loadMoreTopics(cid);
 | 
			
		||||
		}
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
})();
 | 
			
		||||
	return Category;
 | 
			
		||||
});
 | 
			
		||||
@@ -1,7 +1,13 @@
 | 
			
		||||
(function() {
 | 
			
		||||
	$(document).ready(function() {
 | 
			
		||||
define(['forum/accountheader'], function(header) {
 | 
			
		||||
	var AccountHeader = {};
 | 
			
		||||
 | 
			
		||||
	AccountHeader.init = function() {
 | 
			
		||||
		header.init();
 | 
			
		||||
 | 
			
		||||
		$('.user-favourite-posts .topic-row').on('click', function() {
 | 
			
		||||
			ajaxify.go($(this).attr('topic-url'));
 | 
			
		||||
		});
 | 
			
		||||
	});
 | 
			
		||||
}());
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	return AccountHeader;
 | 
			
		||||
});
 | 
			
		||||
@@ -1,18 +1,20 @@
 | 
			
		||||
(function() {
 | 
			
		||||
define(['forum/accountheader'], function(header) {
 | 
			
		||||
	var	Followers = {};
 | 
			
		||||
 | 
			
		||||
	Followers.init = function() {
 | 
			
		||||
		header.init();
 | 
			
		||||
 | 
			
		||||
		var yourid = templates.get('yourid'),
 | 
			
		||||
			theirid = templates.get('theirid'),
 | 
			
		||||
			followersCount = templates.get('followersCount');
 | 
			
		||||
 | 
			
		||||
	$(document).ready(function() {
 | 
			
		||||
 | 
			
		||||
			if (parseInt(followersCount, 10) === 0) {
 | 
			
		||||
				$('#no-followers-notice').removeClass('hide');
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		app.addCommasToNumbers();
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}());
 | 
			
		||||
	return Followers;
 | 
			
		||||
});
 | 
			
		||||
@@ -1,11 +1,13 @@
 | 
			
		||||
(function() {
 | 
			
		||||
define(['forum/accountheader'], function(header) {
 | 
			
		||||
	var	Following = {};
 | 
			
		||||
 | 
			
		||||
	Following.init = function() {
 | 
			
		||||
		header.init();
 | 
			
		||||
 | 
			
		||||
		var yourid = templates.get('yourid'),
 | 
			
		||||
			theirid = templates.get('theirid'),
 | 
			
		||||
			followingCount = templates.get('followingCount');
 | 
			
		||||
 | 
			
		||||
	$(document).ready(function() {
 | 
			
		||||
 | 
			
		||||
		if (parseInt(followingCount, 10) === 0) {
 | 
			
		||||
			$('#no-following-notice').removeClass('hide');
 | 
			
		||||
		}
 | 
			
		||||
@@ -34,7 +36,7 @@
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		app.addCommasToNumbers();
 | 
			
		||||
	});
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}());
 | 
			
		||||
	return Following;
 | 
			
		||||
});
 | 
			
		||||
@@ -1,4 +1,7 @@
 | 
			
		||||
(function() {
 | 
			
		||||
define(function() {
 | 
			
		||||
	var	Login = {};
 | 
			
		||||
 | 
			
		||||
	Login.init = function() {
 | 
			
		||||
		// Alternate Logins
 | 
			
		||||
		var altLoginEl = document.querySelector('.alt-logins');
 | 
			
		||||
		altLoginEl.addEventListener('click', function(e) {
 | 
			
		||||
@@ -57,4 +60,7 @@
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		document.querySelector('#content input').focus();
 | 
			
		||||
}());
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	return Login;
 | 
			
		||||
});
 | 
			
		||||
@@ -1,6 +1,11 @@
 | 
			
		||||
(function() {
 | 
			
		||||
	var loadingMoreTopics = false;
 | 
			
		||||
define(function() {
 | 
			
		||||
	var	Recent = {};
 | 
			
		||||
 | 
			
		||||
	Recent.newTopicCount = 0;
 | 
			
		||||
	Recent.newPostCount = 0;
 | 
			
		||||
	Recent.loadingMoreTopics = false;
 | 
			
		||||
 | 
			
		||||
	Recent.init = function() {
 | 
			
		||||
		app.enter_room('recent_posts');
 | 
			
		||||
 | 
			
		||||
		ajaxify.register_events([
 | 
			
		||||
@@ -8,33 +13,44 @@
 | 
			
		||||
			'event:new_post'
 | 
			
		||||
		]);
 | 
			
		||||
 | 
			
		||||
	var newTopicCount = 0,
 | 
			
		||||
		newPostCount = 0;
 | 
			
		||||
 | 
			
		||||
		$('#new-topics-alert').on('click', function() {
 | 
			
		||||
			$(this).hide();
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		socket.on('event:new_topic', function(data) {
 | 
			
		||||
 | 
			
		||||
		++newTopicCount;
 | 
			
		||||
		updateAlertText();
 | 
			
		||||
			++Recent.newTopicCount;
 | 
			
		||||
			Recent.updateAlertText();
 | 
			
		||||
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
	function updateAlertText() {
 | 
			
		||||
		socket.on('event:new_post', function(data) {
 | 
			
		||||
			++Recent.newPostCount;
 | 
			
		||||
			Recent.updateAlertText();
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		$(window).off('scroll').on('scroll', function() {
 | 
			
		||||
			var bottom = ($(document).height() - $(window).height()) * 0.9;
 | 
			
		||||
 | 
			
		||||
			if ($(window).scrollTop() > bottom && !Recent.loadingMoreTopics) {
 | 
			
		||||
				Recent.loadMoreTopics();
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	Recent.updateAlertText = function() {
 | 
			
		||||
		var text = '';
 | 
			
		||||
 | 
			
		||||
		if (newTopicCount > 1)
 | 
			
		||||
			text = 'There are ' + newTopicCount + ' new topics';
 | 
			
		||||
		else if (newTopicCount === 1)
 | 
			
		||||
		if (Recent.newTopicCount > 1)
 | 
			
		||||
			text = 'There are ' + Recent.newTopicCount + ' new topics';
 | 
			
		||||
		else if (Recent.newTopicCount === 1)
 | 
			
		||||
			text = 'There is 1 new topic';
 | 
			
		||||
		else
 | 
			
		||||
			text = 'There are no new topics';
 | 
			
		||||
 | 
			
		||||
		if (newPostCount > 1)
 | 
			
		||||
			text += ' and ' + newPostCount + ' new posts.';
 | 
			
		||||
		else if (newPostCount === 1)
 | 
			
		||||
		if (Recent.newPostCount > 1)
 | 
			
		||||
			text += ' and ' + Recent.newPostCount + ' new posts.';
 | 
			
		||||
		else if (Recent.newPostCount === 1)
 | 
			
		||||
			text += ' and 1 new post.';
 | 
			
		||||
		else
 | 
			
		||||
			text += ' and no new posts.';
 | 
			
		||||
@@ -44,12 +60,7 @@
 | 
			
		||||
		$('#new-topics-alert').html(text).fadeIn('slow');
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	socket.on('event:new_post', function(data) {
 | 
			
		||||
		++newPostCount;
 | 
			
		||||
		updateAlertText();
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	function onTopicsLoaded(topics) {
 | 
			
		||||
	Recent.onTopicsLoaded = function(topics) {
 | 
			
		||||
 | 
			
		||||
		var html = templates.prepare(templates['recent'].blocks['topics']).parse({
 | 
			
		||||
			topics: topics
 | 
			
		||||
@@ -61,25 +72,17 @@
 | 
			
		||||
		container.append(html);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function loadMoreTopics() {
 | 
			
		||||
		loadingMoreTopics = true;
 | 
			
		||||
	Recent.loadMoreTopics = function() {
 | 
			
		||||
		Recent.loadingMoreTopics = true;
 | 
			
		||||
		socket.emit('api:topics.loadMoreRecentTopics', {
 | 
			
		||||
			after: $('#topics-container').children().length
 | 
			
		||||
		}, function(data) {
 | 
			
		||||
			if (data.topics && data.topics.length) {
 | 
			
		||||
				onTopicsLoaded(data.topics);
 | 
			
		||||
				Recent.onTopicsLoaded(data.topics);
 | 
			
		||||
			}
 | 
			
		||||
			loadingMoreTopics = false;
 | 
			
		||||
			Recent.loadingMoreTopics = false;
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	$(window).off('scroll').on('scroll', function() {
 | 
			
		||||
		var bottom = ($(document).height() - $(window).height()) * 0.9;
 | 
			
		||||
 | 
			
		||||
		if ($(window).scrollTop() > bottom && !loadingMoreTopics) {
 | 
			
		||||
			loadMoreTopics();
 | 
			
		||||
		}
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
})();
 | 
			
		||||
	return Recent;
 | 
			
		||||
});
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,7 @@
 | 
			
		||||
(function() {
 | 
			
		||||
define(function() {
 | 
			
		||||
	var Register = {};
 | 
			
		||||
 | 
			
		||||
	Register.init = function() {
 | 
			
		||||
		var username = $('#username'),
 | 
			
		||||
			password = $('#password'),
 | 
			
		||||
			password_confirm = $('#password-confirm'),
 | 
			
		||||
@@ -150,5 +153,7 @@
 | 
			
		||||
		register.on('click', function(e) {
 | 
			
		||||
			if (validateForm()) e.preventDefault();
 | 
			
		||||
		});
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
}());
 | 
			
		||||
	return Register;
 | 
			
		||||
});
 | 
			
		||||
@@ -1,4 +1,7 @@
 | 
			
		||||
(function() {
 | 
			
		||||
define(function() {
 | 
			
		||||
	var	ResetPassword = {};
 | 
			
		||||
 | 
			
		||||
	ResetPassword.init = function() {
 | 
			
		||||
		var inputEl = document.getElementById('email'),
 | 
			
		||||
			errorEl = document.getElementById('error'),
 | 
			
		||||
			errorTextEl = errorEl.querySelector('p');
 | 
			
		||||
@@ -38,4 +41,7 @@
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
}());
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	return ResetPassword;
 | 
			
		||||
});
 | 
			
		||||
@@ -1,4 +1,7 @@
 | 
			
		||||
(function() {
 | 
			
		||||
define(function() {
 | 
			
		||||
	var	ResetCode = {};
 | 
			
		||||
 | 
			
		||||
	ResetCode.init = function() {
 | 
			
		||||
		var reset_code = templates.get('reset_code');
 | 
			
		||||
 | 
			
		||||
		var resetEl = document.getElementById('reset'),
 | 
			
		||||
@@ -49,4 +52,7 @@
 | 
			
		||||
				$('#success').show();
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
}());
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	return ResetCode;
 | 
			
		||||
});
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
(function() {
 | 
			
		||||
define(function() {
 | 
			
		||||
	var	Search = {};
 | 
			
		||||
 | 
			
		||||
	$(document).ready(function() {
 | 
			
		||||
	Search.init = function() {
 | 
			
		||||
		var searchQuery = $('#topics-container').attr('data-search-query');
 | 
			
		||||
 | 
			
		||||
		$('.search-result-text').each(function() {
 | 
			
		||||
@@ -21,4 +22,5 @@
 | 
			
		||||
		});
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
})();
 | 
			
		||||
	return Search;
 | 
			
		||||
});
 | 
			
		||||
@@ -1,4 +1,7 @@
 | 
			
		||||
(function() {
 | 
			
		||||
define(function() {
 | 
			
		||||
	var	Topic = {};
 | 
			
		||||
 | 
			
		||||
	Topic.init = function() {
 | 
			
		||||
		var expose_tools = templates.get('expose_tools'),
 | 
			
		||||
			tid = templates.get('topic_id'),
 | 
			
		||||
			postListEl = document.getElementById('post-container'),
 | 
			
		||||
@@ -713,4 +716,7 @@
 | 
			
		||||
 | 
			
		||||
		window.onscroll = updateHeader;
 | 
			
		||||
		window.onload = updateHeader;
 | 
			
		||||
})();
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	return Topic;
 | 
			
		||||
});
 | 
			
		||||
@@ -1,4 +1,7 @@
 | 
			
		||||
(function() {
 | 
			
		||||
define(function() {
 | 
			
		||||
	var	Unread = {};
 | 
			
		||||
 | 
			
		||||
	Unread.init = function() {
 | 
			
		||||
		var loadingMoreTopics = false;
 | 
			
		||||
 | 
			
		||||
		app.enter_room('recent_posts');
 | 
			
		||||
@@ -110,5 +113,7 @@
 | 
			
		||||
		$('#load-more-btn').on('click', function() {
 | 
			
		||||
			loadMoreTopics();
 | 
			
		||||
		});
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
})();
 | 
			
		||||
	return Unread;
 | 
			
		||||
});
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
(function() {
 | 
			
		||||
define(function() {
 | 
			
		||||
	var	Users = {};
 | 
			
		||||
 | 
			
		||||
	$(document).ready(function() {
 | 
			
		||||
	Users.init = function() {
 | 
			
		||||
		var timeoutId = 0;
 | 
			
		||||
		var loadingMoreUsers = false;
 | 
			
		||||
 | 
			
		||||
@@ -131,6 +132,7 @@
 | 
			
		||||
				loadMoreUsers();
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
	});
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
}());
 | 
			
		||||
	return Users;
 | 
			
		||||
});
 | 
			
		||||
@@ -98,6 +98,3 @@
 | 
			
		||||
<input type="hidden" template-variable="yourid" value="{yourid}" />
 | 
			
		||||
<input type="hidden" template-variable="theirid" value="{theirid}" />
 | 
			
		||||
<input type="hidden" template-type="boolean" template-variable="isFollowing" value="{isFollowing}" />
 | 
			
		||||
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/account.js"></script>
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/accountheader.js"></script>
 | 
			
		||||
@@ -174,9 +174,3 @@
 | 
			
		||||
 | 
			
		||||
	</div>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<input type="hidden" template-variable="gravatarpicture" value="{gravatarpicture}" />
 | 
			
		||||
<input type="hidden" template-variable="uploadedpicture" value="{uploadedpicture}" />
 | 
			
		||||
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/accountheader.js"></script>
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/accountedit.js"></script>
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,3 @@
 | 
			
		||||
		<a id="submitBtn" href="#" class="btn btn-primary">Save changes</a>
 | 
			
		||||
	</div>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/accountheader.js"></script>
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/accountsettings.js"></script>
 | 
			
		||||
@@ -101,5 +101,3 @@
 | 
			
		||||
  <div class="col-md-3"><i class="icon-adn"></i></div><div class="col-md-3"><i class="icon-android"></i></div><div class="col-md-3"><i class="icon-apple"></i></div><div class="col-md-3"><i class="icon-bitbucket"></i></div><div class="col-md-3"><i class="icon-bitbucket-sign"></i></div><div class="col-md-3"><i class="icon-bitcoin"></i></div><div class="col-md-3"><i class="icon-btc"></i></div><div class="col-md-3"><i class="icon-css3"></i></div><div class="col-md-3"><i class="icon-dribbble"></i></div><div class="col-md-3"><i class="icon-dropbox"></i></div><div class="col-md-3"><i class="icon-facebook"></i></div><div class="col-md-3"><i class="icon-facebook-sign"></i></div><div class="col-md-3"><i class="icon-flickr"></i></div><div class="col-md-3"><i class="icon-foursquare"></i></div><div class="col-md-3"><i class="icon-github"></i></div><div class="col-md-3"><i class="icon-github-alt"></i></div><div class="col-md-3"><i class="icon-github-sign"></i></div><div class="col-md-3"><i class="icon-gittip"></i></div><div class="col-md-3"><i class="icon-google-plus"></i></div><div class="col-md-3"><i class="icon-google-plus-sign"></i></div><div class="col-md-3"><i class="icon-html5"></i></div><div class="col-md-3"><i class="icon-instagram"></i></div><div class="col-md-3"><i class="icon-linkedin"></i></div><div class="col-md-3"><i class="icon-linkedin-sign"></i></div><div class="col-md-3"><i class="icon-linux"></i></div><div class="col-md-3"><i class="icon-maxcdn"></i></div><div class="col-md-3"><i class="icon-pinterest"></i></div><div class="col-md-3"><i class="icon-pinterest-sign"></i></div><div class="col-md-3"><i class="icon-renren"></i></div><div class="col-md-3"><i class="icon-skype"></i></div><div class="col-md-3"><i class="icon-stackexchange"></i></div><div class="col-md-3"><i class="icon-trello"></i></div><div class="col-md-3"><i class="icon-tumblr"></i></div><div class="col-md-3"><i class="icon-tumblr-sign"></i></div><div class="col-md-3"><i class="icon-twitter"></i></div><div class="col-md-3"><i class="icon-twitter-sign"></i></div><div class="col-md-3"><i class="icon-vk"></i></div><div class="col-md-3"><i class="icon-weibo"></i></div><div class="col-md-3"><i class="icon-windows"></i></div><div class="col-md-3"><i class="icon-xing"></i></div><div class="col-md-3"><i class="icon-xing-sign"></i></div><div class="col-md-3"><i class="icon-youtube"></i></div><div class="col-md-3"><i class="icon-youtube-play"></i></div><div class="col-md-3"><i class="icon-youtube-sign"></i></div>
 | 
			
		||||
  <div class="col-md-3"><i class="icon-ambulance"></i></div><div class="col-md-3"><i class="icon-h-sign"></i></div><div class="col-md-3"><i class="icon-hospital"></i></div><div class="col-md-3"><i class="icon-medkit"></i></div><div class="col-md-3"><i class="icon-plus-sign-alt"></i></div><div class="col-md-3"><i class="icon-stethoscope"></i></div><div class="col-md-3"><i class="icon-user-md"></i></div>
 | 
			
		||||
</div></div></div>
 | 
			
		||||
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/admin/categories.js"></script>
 | 
			
		||||
@@ -17,10 +17,7 @@
 | 
			
		||||
<button class="btn btn-lg btn-primary" id="save">Save</button>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
	var	loadDelay = setInterval(function() {
 | 
			
		||||
		if (nodebb_admin) {
 | 
			
		||||
			nodebb_admin.prepare();
 | 
			
		||||
			clearInterval(loadDelay);
 | 
			
		||||
		}
 | 
			
		||||
	}, 500);
 | 
			
		||||
	require(['forum/admin/settings'], function(Settings) {
 | 
			
		||||
		Settings.prepare();
 | 
			
		||||
	});
 | 
			
		||||
</script>
 | 
			
		||||
@@ -9,7 +9,7 @@
 | 
			
		||||
	</div>
 | 
			
		||||
 | 
			
		||||
<script type="text/javascript">
 | 
			
		||||
	$.getScript(RELATIVE_PATH + '/src/forum/admin/footer.js');
 | 
			
		||||
	require(['forum/admin/footer']);
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
</body>
 | 
			
		||||
 
 | 
			
		||||
@@ -17,10 +17,7 @@
 | 
			
		||||
<button class="btn btn-lg btn-primary" id="save">Save</button>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
	var	loadDelay = setInterval(function() {
 | 
			
		||||
		if (nodebb_admin) {
 | 
			
		||||
			nodebb_admin.prepare();
 | 
			
		||||
			clearInterval(loadDelay);
 | 
			
		||||
		}
 | 
			
		||||
	}, 500);
 | 
			
		||||
	require(['forum/admin/settings'], function(Settings) {
 | 
			
		||||
		Settings.prepare();
 | 
			
		||||
	});
 | 
			
		||||
</script>
 | 
			
		||||
@@ -96,5 +96,3 @@
 | 
			
		||||
		</div>
 | 
			
		||||
	</div>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/admin/groups.js"></script>
 | 
			
		||||
@@ -25,7 +25,10 @@
 | 
			
		||||
	<script>
 | 
			
		||||
		require.config({
 | 
			
		||||
			baseUrl: "{relative_path}/src/modules",
 | 
			
		||||
			waitSeconds: 3
 | 
			
		||||
			waitSeconds: 3,
 | 
			
		||||
			paths: {
 | 
			
		||||
				"forum": '../forum'
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
	</script>
 | 
			
		||||
	<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
 | 
			
		||||
 
 | 
			
		||||
@@ -18,5 +18,3 @@
 | 
			
		||||
 | 
			
		||||
	</p>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/admin/index.js"></script>
 | 
			
		||||
@@ -24,10 +24,7 @@
 | 
			
		||||
<button class="btn btn-lg btn-primary" id="save" checked>Save</button>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
	var	loadDelay = setInterval(function() {
 | 
			
		||||
		if (nodebb_admin) {
 | 
			
		||||
			nodebb_admin.prepare();
 | 
			
		||||
			clearInterval(loadDelay);
 | 
			
		||||
		}
 | 
			
		||||
	}, 500);
 | 
			
		||||
	require(['forum/admin/settings'], function(Settings) {
 | 
			
		||||
		Settings.prepare();
 | 
			
		||||
	});
 | 
			
		||||
</script>
 | 
			
		||||
@@ -21,5 +21,3 @@
 | 
			
		||||
		Full documentation regarding plugin authoring can be found in the <a target="_blank" href="https://github.com/designcreateplay/NodeBB/wiki/Writing-Plugins-for-NodeBB">NodeBB Wiki</a>.
 | 
			
		||||
	</p>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/admin/plugins.js"></script>
 | 
			
		||||
@@ -83,10 +83,7 @@
 | 
			
		||||
<button class="btn btn-lg btn-primary" id="save">Save</button>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
	var	loadDelay = setInterval(function() {
 | 
			
		||||
		if (nodebb_admin) {
 | 
			
		||||
			nodebb_admin.prepare();
 | 
			
		||||
			clearInterval(loadDelay);
 | 
			
		||||
		}
 | 
			
		||||
	}, 500);
 | 
			
		||||
	require(['forum/admin/settings'], function(Settings) {
 | 
			
		||||
		Settings.prepare();
 | 
			
		||||
	});
 | 
			
		||||
</script>
 | 
			
		||||
@@ -23,4 +23,10 @@
 | 
			
		||||
	<button class="btn btn-warning" id="revert_theme">Revert</button> This will remove any custom theme applied to your NodeBB, and restore the base theme.
 | 
			
		||||
</p>
 | 
			
		||||
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/admin/themes.js"></script>
 | 
			
		||||
<script>
 | 
			
		||||
	var bootswatchListener = function(data) {
 | 
			
		||||
		require(['forum/admin/themes'], function(t) {
 | 
			
		||||
			t.render(data);
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
</script>
 | 
			
		||||
@@ -22,5 +22,3 @@
 | 
			
		||||
<div class="text-center">
 | 
			
		||||
	<button id="topics_loadmore" class="btn btn-primary btn-lg">Load More Topics</button>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/admin/topics.js"></script>
 | 
			
		||||
@@ -17,10 +17,7 @@
 | 
			
		||||
<button class="btn btn-lg btn-primary" id="save">Save</button>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
	var	loadDelay = setInterval(function() {
 | 
			
		||||
		if (nodebb_admin) {
 | 
			
		||||
			nodebb_admin.prepare();
 | 
			
		||||
			clearInterval(loadDelay);
 | 
			
		||||
		}
 | 
			
		||||
	}, 500);
 | 
			
		||||
	require(['forum/admin/settings'], function(Settings) {
 | 
			
		||||
		Settings.prepare();
 | 
			
		||||
	});
 | 
			
		||||
</script>
 | 
			
		||||
 
 | 
			
		||||
@@ -42,6 +42,3 @@
 | 
			
		||||
	<button id="load-more-users-btn" class="btn btn-primary">Load More</button>
 | 
			
		||||
</div>
 | 
			
		||||
<input type="hidden" template-variable="yourid" value="{yourid}" />
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/admin/users.js"></script>
 | 
			
		||||
 
 | 
			
		||||
@@ -97,5 +97,3 @@
 | 
			
		||||
<input type="hidden" template-variable="twitter-intent-url" value="{twitter-intent-url}" />
 | 
			
		||||
<input type="hidden" template-variable="facebook-share-url" value="{facebook-share-url}" />
 | 
			
		||||
<input type="hidden" template-variable="google-share-url" value="{google-share-url}" />
 | 
			
		||||
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/category.js"></script>
 | 
			
		||||
@@ -22,6 +22,3 @@
 | 
			
		||||
		</div>
 | 
			
		||||
	</div>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/accountheader.js"></script>
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/favourites.js"></script>
 | 
			
		||||
 
 | 
			
		||||
@@ -34,6 +34,3 @@
 | 
			
		||||
<input type="hidden" template-variable="yourid" value="{yourid}" />
 | 
			
		||||
<input type="hidden" template-variable="theirid" value="{theirid}" />
 | 
			
		||||
<input type="hidden" template-variable="followersCount" value="{followersCount}" />
 | 
			
		||||
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/followers.js"></script>
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/accountheader.js"></script>
 | 
			
		||||
@@ -35,6 +35,3 @@
 | 
			
		||||
<input type="hidden" template-variable="yourid" value="{yourid}" />
 | 
			
		||||
<input type="hidden" template-variable="theirid" value="{theirid}" />
 | 
			
		||||
<input type="hidden" template-variable="followingCount" value="{followingCount}" />
 | 
			
		||||
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/following.js"></script>
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/accountheader.js"></script>
 | 
			
		||||
 
 | 
			
		||||
@@ -53,7 +53,7 @@
 | 
			
		||||
	</footer>
 | 
			
		||||
 | 
			
		||||
	<script>
 | 
			
		||||
		$.getScript(RELATIVE_PATH + '/src/forum/footer.js');
 | 
			
		||||
		require(['forum/footer']);
 | 
			
		||||
	</script>
 | 
			
		||||
 | 
			
		||||
</body>
 | 
			
		||||
 
 | 
			
		||||
@@ -15,8 +15,14 @@
 | 
			
		||||
	<script>
 | 
			
		||||
		require.config({
 | 
			
		||||
			baseUrl: "{relative_path}/src/modules",
 | 
			
		||||
			waitSeconds: 3
 | 
			
		||||
			waitSeconds: 3,
 | 
			
		||||
			paths: {
 | 
			
		||||
				"forum": '../forum'
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
		requirejs.onError = function(err) {
 | 
			
		||||
			console.log(err);
 | 
			
		||||
		}
 | 
			
		||||
	</script>
 | 
			
		||||
 | 
			
		||||
	<link rel="stylesheet" type="text/css" href="{relative_path}/css/nodebb.css" />
 | 
			
		||||
 
 | 
			
		||||
@@ -60,5 +60,3 @@
 | 
			
		||||
		</div>
 | 
			
		||||
	</div>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/login.js"></script>
 | 
			
		||||
@@ -49,5 +49,3 @@
 | 
			
		||||
		</ul>
 | 
			
		||||
	</div>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/recent.js"></script>
 | 
			
		||||
 
 | 
			
		||||
@@ -80,5 +80,3 @@
 | 
			
		||||
		</div>
 | 
			
		||||
	</div>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/register.js"></script>
 | 
			
		||||
@@ -26,5 +26,3 @@
 | 
			
		||||
		<button class="btn btn-primary btn-block btn-lg" id="reset" type="submit">Reset Password</button>
 | 
			
		||||
	</form>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/reset.js"></script>
 | 
			
		||||
@@ -34,6 +34,3 @@
 | 
			
		||||
	</form>
 | 
			
		||||
</div>
 | 
			
		||||
<input type="hidden" template-variable="reset_code" value="{reset_code}" />
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/reset_code.js"></script>
 | 
			
		||||
@@ -53,5 +53,3 @@
 | 
			
		||||
		</ul>
 | 
			
		||||
	</div>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/search.js"></script>
 | 
			
		||||
 
 | 
			
		||||
@@ -199,7 +199,3 @@
 | 
			
		||||
<input type="hidden" template-variable="pinned" value="{pinned}" />
 | 
			
		||||
<input type="hidden" template-variable="topic_name" value="{topic_name}" />
 | 
			
		||||
<input type="hidden" template-variable="postcount" value="{postcount}" />
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/topic.js"></script>
 | 
			
		||||
@@ -54,5 +54,3 @@
 | 
			
		||||
		</div>
 | 
			
		||||
	</div>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/unread.js"></script>
 | 
			
		||||
@@ -45,5 +45,3 @@
 | 
			
		||||
		<button id="load-more-users-btn" class="btn btn-primary">[[users:load_more]]</button>
 | 
			
		||||
	</div>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<script type="text/javascript" src="{relative_path}/src/forum/users.js"></script>
 | 
			
		||||
@@ -135,22 +135,22 @@ var express = require('express'),
 | 
			
		||||
				app.use(function (req, res, next) {
 | 
			
		||||
					res.status(404);
 | 
			
		||||
 | 
			
		||||
					if (path.dirname(req.url) === '/src/forum') {
 | 
			
		||||
						// Handle missing client-side scripts
 | 
			
		||||
						res.type('text/javascript').send(200, '');
 | 
			
		||||
					} else if (req.accepts('html')) {
 | 
			
		||||
						// respond with html page
 | 
			
		||||
					if (req.accepts('html')) {
 | 
			
		||||
						winston.warn('Route requested but not found: ' + req.url);
 | 
			
		||||
						res.redirect(nconf.get('relative_path') + '/404');
 | 
			
		||||
						return;
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
					} else if (req.accepts('json')) {
 | 
			
		||||
						// respond with json
 | 
			
		||||
					if (req.accepts('json')) {
 | 
			
		||||
						res.send({
 | 
			
		||||
						res.json({
 | 
			
		||||
							error: 'Not found'
 | 
			
		||||
						});
 | 
			
		||||
						return;
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
					} else {
 | 
			
		||||
						// default to plain-text. send()
 | 
			
		||||
						res.type('txt').send('Not found');
 | 
			
		||||
					}
 | 
			
		||||
				});
 | 
			
		||||
 | 
			
		||||
				app.use(function (err, req, res, next) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user