mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
closes #1999
This commit is contained in:
@@ -75,15 +75,6 @@
|
||||
socket.emit('admin.restart');
|
||||
});
|
||||
|
||||
Mousetrap.bind('ctrl+shift+a d', function() {
|
||||
var tid = ajaxify.variables.get('topic_id'),
|
||||
cid = ajaxify.variables.get('category_id');
|
||||
|
||||
if (tid && cid) {
|
||||
socket.emit('topics.delete', { tids: [tid], cid: cid });
|
||||
}
|
||||
});
|
||||
|
||||
Mousetrap.bind('/', function(e) {
|
||||
$('#acp-search input').focus();
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@ define('admin/extend/rewards', function() {
|
||||
conditionals;
|
||||
|
||||
rewards.init = function() {
|
||||
available = JSON.parse(ajaxify.variables.get('rewards'));
|
||||
active = JSON.parse(ajaxify.variables.get('active'));
|
||||
conditions = JSON.parse(ajaxify.variables.get('conditions'));
|
||||
conditionals = JSON.parse(ajaxify.variables.get('conditionals'));
|
||||
available = ajaxify.data.rewards;
|
||||
active = ajaxify.data.active;
|
||||
conditions = ajaxify.data.conditions;
|
||||
conditionals = ajaxify.data.conditionals;
|
||||
|
||||
$('[data-selected]').each(function() {
|
||||
select($(this));
|
||||
|
||||
@@ -6,7 +6,7 @@ define('admin/general/navigation', ['translator'], function(translator) {
|
||||
available;
|
||||
|
||||
navigation.init = function() {
|
||||
available = JSON.parse(ajaxify.variables.get('available'));
|
||||
available = ajaxify.data.available;
|
||||
|
||||
$('#enabled').html(translator.unescape($('#enabled').html()));
|
||||
translator.translate(translator.unescape($('#available').html()), function(html) {
|
||||
|
||||
@@ -95,7 +95,7 @@ define('admin/manage/category', [
|
||||
if (!confirm) {
|
||||
return;
|
||||
}
|
||||
socket.emit('admin.categories.purge', ajaxify.variables.get('cid'), function(err) {
|
||||
socket.emit('admin.categories.purge', ajaxify.data.category.cid, function(err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -141,7 +141,7 @@ define('admin/manage/category', [
|
||||
$('button[data-action="setParent"]').on('click', Category.launchParentSelector);
|
||||
$('button[data-action="removeParent"]').on('click', function() {
|
||||
var payload= {};
|
||||
payload[ajaxify.variables.get('cid')] = {
|
||||
payload[ajaxify.data.category.cid] = {
|
||||
parentCid: 0
|
||||
};
|
||||
|
||||
@@ -192,7 +192,7 @@ define('admin/manage/category', [
|
||||
};
|
||||
|
||||
Category.refreshPrivilegeTable = function() {
|
||||
socket.emit('admin.categories.getPrivilegeSettings', ajaxify.variables.get('cid'), function(err, privileges) {
|
||||
socket.emit('admin.categories.getPrivilegeSettings', ajaxify.data.category.cid, function(err, privileges) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -230,7 +230,7 @@ define('admin/manage/category', [
|
||||
|
||||
Category.setPrivilege = function(member, privilege, state, checkboxEl) {
|
||||
socket.emit('admin.categories.setPrivilege', {
|
||||
cid: ajaxify.variables.get('cid'),
|
||||
cid: ajaxify.data.category.cid,
|
||||
privilege: privilege,
|
||||
set: state,
|
||||
member: member
|
||||
@@ -258,7 +258,7 @@ define('admin/manage/category', [
|
||||
var parentCid = $(this).attr('data-cid'),
|
||||
payload = {};
|
||||
|
||||
payload[ajaxify.variables.get('cid')] = {
|
||||
payload[ajaxify.data.category.cid] = {
|
||||
parentCid: parentCid
|
||||
};
|
||||
|
||||
@@ -287,7 +287,7 @@ define('admin/manage/category', [
|
||||
|
||||
autocomplete.user(inputEl, function(ev, ui) {
|
||||
socket.emit('admin.categories.setPrivilege', {
|
||||
cid: ajaxify.variables.get('cid'),
|
||||
cid: ajaxify.data.category.cid,
|
||||
privilege: ['find', 'read'],
|
||||
set: true,
|
||||
member: ui.item.user.uid
|
||||
@@ -315,7 +315,7 @@ define('admin/manage/category', [
|
||||
|
||||
autocomplete.group(inputEl, function(ev, ui) {
|
||||
socket.emit('admin.categories.setPrivilege', {
|
||||
cid: ajaxify.variables.get('cid'),
|
||||
cid: ajaxify.data.category.cid,
|
||||
privilege: ['groups:find', 'groups:read'],
|
||||
set: true,
|
||||
member: ui.item.group.name
|
||||
|
||||
@@ -18,7 +18,7 @@ define('admin/manage/group', [
|
||||
searchDelay;
|
||||
|
||||
|
||||
var groupName = ajaxify.variables.get('groupName');
|
||||
var groupName = ajaxify.data.group.name;
|
||||
|
||||
changeGroupUserTitle.keyup(function() {
|
||||
groupLabelPreview.text(changeGroupUserTitle.val());
|
||||
|
||||
@@ -4,7 +4,7 @@ define('admin/manage/users', ['admin/modules/selectable'], function(selectable)
|
||||
var Users = {};
|
||||
|
||||
Users.init = function() {
|
||||
var yourid = ajaxify.variables.get('yourid');
|
||||
var yourid = ajaxify.data.yourid;
|
||||
|
||||
selectable.enable('#users-container', '.user-selectable');
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ $(document).ready(function() {
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
|
||||
ajaxify.data = data;
|
||||
data.relative_path = RELATIVE_PATH;
|
||||
$(window).trigger('action:ajaxify.dataLoaded', {url: url, data: data});
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ app.cacheBuster = null;
|
||||
|
||||
switch(url_parts[0]) {
|
||||
case 'user':
|
||||
room = 'user/' + ajaxify.variables.get('theirid');
|
||||
room = 'user/' + ajaxify.data.theirid;
|
||||
break;
|
||||
case 'topic':
|
||||
room = 'topic_' + url_parts[1];
|
||||
@@ -466,7 +466,7 @@ app.cacheBuster = null;
|
||||
|
||||
function handleNewTopic() {
|
||||
$('#content').on('click', '#new_topic', function() {
|
||||
var cid = ajaxify.variables.get('category_id');
|
||||
var cid = ajaxify.data.cid;
|
||||
if (cid) {
|
||||
$(window).trigger('action:composer.topic.new', {
|
||||
cid: cid
|
||||
|
||||
@@ -10,8 +10,8 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],
|
||||
currentEmail;
|
||||
|
||||
AccountEdit.init = function() {
|
||||
gravatarPicture = ajaxify.variables.get('gravatarpicture');
|
||||
uploadedPicture = ajaxify.variables.get('uploadedpicture');
|
||||
gravatarPicture = ajaxify.data.gravatarpicture;
|
||||
uploadedPicture = ajaxify.data.uploadedpicture;
|
||||
|
||||
header.init();
|
||||
|
||||
@@ -87,7 +87,7 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],
|
||||
}
|
||||
|
||||
function updateHeader(picture, username, userslug) {
|
||||
if (parseInt(ajaxify.variables.get('theirid'), 10) !== parseInt(ajaxify.variables.get('yourid'), 10)) {
|
||||
if (parseInt(ajaxify.data.theirid, 10) !== parseInt(ajaxify.data.yourid, 10)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],
|
||||
$('#uploadPictureBtn').on('click', function() {
|
||||
|
||||
$('#change-picture-modal').modal('hide');
|
||||
uploader.open(config.relative_path + '/api/user/' + ajaxify.variables.get('userslug') + '/uploadpicture', {}, config.maximumProfileImageSize, function(imageUrlOnServer) {
|
||||
uploader.open(config.relative_path + '/api/user/' + ajaxify.data.userslug + '/uploadpicture', {}, config.maximumProfileImageSize, function(imageUrlOnServer) {
|
||||
onUploadComplete(imageUrlOnServer);
|
||||
});
|
||||
|
||||
@@ -207,7 +207,7 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],
|
||||
if (!url) {
|
||||
return;
|
||||
}
|
||||
socket.emit('user.uploadProfileImageFromUrl', {url: url, uid: ajaxify.variables.get('theirid')}, function(err, imageUrlOnServer) {
|
||||
socket.emit('user.uploadProfileImageFromUrl', {url: url, uid: ajaxify.data.theirid}, function(err, imageUrlOnServer) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -286,7 +286,7 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],
|
||||
socket.emit('user.changePassword', {
|
||||
'currentPassword': currentPassword.val(),
|
||||
'newPassword': password.val(),
|
||||
'uid': ajaxify.variables.get('theirid')
|
||||
'uid': ajaxify.data.theirid
|
||||
}, function(err) {
|
||||
btn.removeClass('disabled').find('i').addClass('hide');
|
||||
currentPassword.val('');
|
||||
@@ -319,7 +319,7 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],
|
||||
function changeUserPicture(type, callback) {
|
||||
socket.emit('user.changePicture', {
|
||||
type: type,
|
||||
uid: ajaxify.variables.get('theirid')
|
||||
uid: ajaxify.data.theirid
|
||||
}, callback);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ define('forum/account/header', function() {
|
||||
};
|
||||
|
||||
function hidePrivateLinks() {
|
||||
if (!app.user.uid || app.user.uid !== parseInt(ajaxify.variables.get('theirid'), 10)) {
|
||||
if (!app.user.uid || app.user.uid !== parseInt(ajaxify.data.theirid, 10)) {
|
||||
$('.account-sub-links .plugin-link.private').addClass('hide');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ define('forum/account/posts', ['forum/account/header', 'forum/infinitescroll'],
|
||||
}
|
||||
|
||||
infinitescroll.loadMore(method, {
|
||||
uid: ajaxify.variables.get('theirid'),
|
||||
uid: ajaxify.data.theirid,
|
||||
after: $('[component="posts"]').attr('data-nextstart')
|
||||
}, function(data, done) {
|
||||
if (data.posts && data.posts.length) {
|
||||
|
||||
@@ -11,9 +11,9 @@ define('forum/account/profile', ['forum/account/header', 'forum/infinitescroll',
|
||||
Account.init = function() {
|
||||
header.init();
|
||||
|
||||
yourid = ajaxify.variables.get('yourid');
|
||||
theirid = ajaxify.variables.get('theirid');
|
||||
isFollowing = ajaxify.variables.get('isFollowing');
|
||||
yourid = ajaxify.data.yourid;
|
||||
theirid = ajaxify.data.theirid;
|
||||
isFollowing = ajaxify.data.isFollowing;
|
||||
|
||||
app.enterRoom('user/' + theirid);
|
||||
|
||||
@@ -70,7 +70,7 @@ define('forum/account/profile', ['forum/account/header', 'forum/infinitescroll',
|
||||
}
|
||||
|
||||
function onUserStatusChange(data) {
|
||||
if (parseInt(ajaxify.variables.get('theirid'), 10) !== parseInt(data.uid, 10)) {
|
||||
if (parseInt(ajaxify.data.theirid, 10) !== parseInt(data.uid, 10)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ define('forum/account/profile', ['forum/account/header', 'forum/infinitescroll',
|
||||
if (!confirm) {
|
||||
return;
|
||||
}
|
||||
socket.emit('admin.user.banUsers', [ajaxify.variables.get('theirid')], function(err) {
|
||||
socket.emit('admin.user.banUsers', [ajaxify.data.theirid], function(err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -134,7 +134,7 @@ define('forum/account/profile', ['forum/account/header', 'forum/infinitescroll',
|
||||
}
|
||||
|
||||
function unbanAccount() {
|
||||
socket.emit('admin.user.unbanUsers', [ajaxify.variables.get('theirid')], function(err) {
|
||||
socket.emit('admin.user.unbanUsers', [ajaxify.data.theirid], function(err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -150,7 +150,7 @@ define('forum/account/profile', ['forum/account/header', 'forum/infinitescroll',
|
||||
return;
|
||||
}
|
||||
|
||||
socket.emit('admin.user.deleteUsers', [ajaxify.variables.get('theirid')], function(err) {
|
||||
socket.emit('admin.user.deleteUsers', [ajaxify.data.theirid], function(err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ define('forum/account/settings', ['forum/account/header'], function(header) {
|
||||
}
|
||||
});
|
||||
|
||||
socket.emit('user.saveSettings', {uid: ajaxify.variables.get('theirid'), settings: settings}, function(err, newSettings) {
|
||||
socket.emit('user.saveSettings', {uid: ajaxify.data.theirid, settings: settings}, function(err, newSettings) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -46,7 +46,7 @@ define('forum/account/settings', ['forum/account/header'], function(header) {
|
||||
}
|
||||
}
|
||||
app.exposeConfigToTemplates();
|
||||
if (requireReload && parseInt(app.user.uid, 10) === parseInt(ajaxify.variables.get('theirid'), 10)) {
|
||||
if (requireReload && parseInt(app.user.uid, 10) === parseInt(ajaxify.data.theirid, 10)) {
|
||||
app.alert({
|
||||
id: 'setting-change',
|
||||
message: '[[user:settings-require-reload]]',
|
||||
|
||||
@@ -9,7 +9,7 @@ define('forum/account/topics', ['forum/account/header', 'forum/infinitescroll'],
|
||||
AccountTopics.init = function() {
|
||||
header.init();
|
||||
|
||||
AccountTopics.handleInfiniteScroll('account/topics', 'uid:' + ajaxify.variables.get('theirid') + ':topics');
|
||||
AccountTopics.handleInfiniteScroll('account/topics', 'uid:' + ajaxify.data.theirid + ':topics');
|
||||
};
|
||||
|
||||
AccountTopics.handleInfiniteScroll = function(_template, _set) {
|
||||
|
||||
@@ -7,7 +7,7 @@ define('forum/account/watched', ['forum/account/header', 'forum/account/topics']
|
||||
AccountWatched.init = function() {
|
||||
header.init();
|
||||
|
||||
topics.handleInfiniteScroll('account/watched', 'uid:' + ajaxify.variables.get('theirid') + ':followed_tids');
|
||||
topics.handleInfiniteScroll('account/watched', 'uid:' + ajaxify.data.theirid + ':followed_tids');
|
||||
};
|
||||
|
||||
return AccountWatched;
|
||||
|
||||
@@ -27,23 +27,23 @@ define('forum/category', [
|
||||
}
|
||||
|
||||
Category.init = function() {
|
||||
var cid = ajaxify.variables.get('category_id');
|
||||
var cid = ajaxify.data.cid;
|
||||
|
||||
app.enterRoom('category_' + cid);
|
||||
|
||||
share.addShareHandlers(ajaxify.variables.get('category_name'));
|
||||
share.addShareHandlers(ajaxify.data.name);
|
||||
|
||||
socket.removeListener('event:new_topic', Category.onNewTopic);
|
||||
socket.on('event:new_topic', Category.onNewTopic);
|
||||
|
||||
categoryTools.init(cid);
|
||||
|
||||
sort.handleSort('categoryTopicSort', 'user.setCategorySort', 'category/' + ajaxify.variables.get('category_slug'));
|
||||
sort.handleSort('categoryTopicSort', 'user.setCategorySort', 'category/' + ajaxify.data.slug);
|
||||
|
||||
enableInfiniteLoadingOrPagination();
|
||||
|
||||
if (!config.usePagination) {
|
||||
navigator.init('[component="category/topic"]', ajaxify.variables.get('topic_count'), Category.toTop, Category.toBottom, Category.navigatorCallback);
|
||||
navigator.init('[component="category/topic"]', ajaxify.data.topic_count, Category.toTop, Category.toBottom, Category.navigatorCallback);
|
||||
}
|
||||
|
||||
$('[component="category"]').on('click', '[component="topic/header"]', function() {
|
||||
@@ -83,7 +83,7 @@ define('forum/category', [
|
||||
};
|
||||
|
||||
Category.toBottom = function() {
|
||||
socket.emit('categories.getTopicCount', ajaxify.variables.get('category_id'), function(err, count) {
|
||||
socket.emit('categories.getTopicCount', ajaxify.data.cid, function(err, count) {
|
||||
navigator.scrollBottom(count - 1);
|
||||
});
|
||||
};
|
||||
@@ -157,7 +157,7 @@ define('forum/category', [
|
||||
}
|
||||
|
||||
var scrollTo = components.get('category/topic', 'index', bookmarkIndex);
|
||||
var cid = ajaxify.variables.get('category_id');
|
||||
var cid = ajaxify.data.cid;
|
||||
if (scrollTo.length && cid) {
|
||||
$('html, body').animate({
|
||||
scrollTop: (scrollTo.offset().top - $('#header-menu').height() - offset) + 'px'
|
||||
@@ -173,12 +173,12 @@ define('forum/category', [
|
||||
infinitescroll.init(Category.loadMoreTopics);
|
||||
} else {
|
||||
navigator.hide();
|
||||
pagination.init(ajaxify.variables.get('currentPage'), ajaxify.variables.get('pageCount'));
|
||||
pagination.init(ajaxify.data.currentPage, ajaxify.data.pageCount);
|
||||
}
|
||||
}
|
||||
|
||||
Category.onNewTopic = function(topic) {
|
||||
var cid = ajaxify.variables.get('category_id');
|
||||
var cid = ajaxify.data.cid;
|
||||
if (!topic || parseInt(topic.cid, 10) !== parseInt(cid, 10)) {
|
||||
return;
|
||||
}
|
||||
@@ -235,7 +235,7 @@ define('forum/category', [
|
||||
};
|
||||
|
||||
function updateTopicCount() {
|
||||
socket.emit('categories.getTopicCount', ajaxify.variables.get('category_id'), function(err, topicCount) {
|
||||
socket.emit('categories.getTopicCount', ajaxify.data.cid, function(err, topicCount) {
|
||||
if(err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -337,7 +337,7 @@ define('forum/category', [
|
||||
|
||||
$(window).trigger('action:categories.loading');
|
||||
infinitescroll.loadMore('categories.loadMore', {
|
||||
cid: ajaxify.variables.get('category_id'),
|
||||
cid: ajaxify.data.cid,
|
||||
after: after,
|
||||
author: utils.params().author
|
||||
}, function (data, done) {
|
||||
|
||||
@@ -12,7 +12,7 @@ define('forum/groups/details', ['iconSelect', 'components', 'forum/infinitescrol
|
||||
var detailsPage = components.get('groups/container'),
|
||||
settingsFormEl = detailsPage.find('form');
|
||||
|
||||
if (ajaxify.variables.get('is_owner') === 'true') {
|
||||
if (ajaxify.data.group.isOwner) {
|
||||
Details.prepareSettings();
|
||||
Details.initialiseCover();
|
||||
}
|
||||
@@ -34,7 +34,7 @@ define('forum/groups/details', ['iconSelect', 'components', 'forum/infinitescrol
|
||||
case 'toggleOwnership':
|
||||
socket.emit('groups.' + (isOwner ? 'rescind' : 'grant'), {
|
||||
toUid: uid,
|
||||
groupName: ajaxify.variables.get('group_name')
|
||||
groupName: ajaxify.data.group.name
|
||||
}, function(err) {
|
||||
if (!err) {
|
||||
ownerFlagEl.toggleClass('invisible');
|
||||
@@ -47,7 +47,7 @@ define('forum/groups/details', ['iconSelect', 'components', 'forum/infinitescrol
|
||||
case 'kick':
|
||||
socket.emit('groups.kick', {
|
||||
uid: uid,
|
||||
groupName: ajaxify.variables.get('group_name')
|
||||
groupName: ajaxify.data.group.name
|
||||
}, function(err) {
|
||||
if (!err) {
|
||||
userRow.slideUp().remove();
|
||||
@@ -75,7 +75,7 @@ define('forum/groups/details', ['iconSelect', 'components', 'forum/infinitescrol
|
||||
case 'rejectAll':
|
||||
socket.emit('groups.' + action, {
|
||||
toUid: uid,
|
||||
groupName: ajaxify.variables.get('group_name')
|
||||
groupName: ajaxify.data.group.name
|
||||
}, function(err) {
|
||||
if (!err) {
|
||||
ajaxify.refresh();
|
||||
@@ -156,7 +156,7 @@ define('forum/groups/details', ['iconSelect', 'components', 'forum/infinitescrol
|
||||
});
|
||||
|
||||
socket.emit('groups.update', {
|
||||
groupName: ajaxify.variables.get('group_name'),
|
||||
groupName: ajaxify.data.group.name,
|
||||
values: settings
|
||||
}, function(err) {
|
||||
if (err) {
|
||||
@@ -178,15 +178,15 @@ define('forum/groups/details', ['iconSelect', 'components', 'forum/infinitescrol
|
||||
};
|
||||
|
||||
Details.deleteGroup = function() {
|
||||
bootbox.confirm('Are you sure you want to delete the group: ' + utils.escapeHTML(ajaxify.variables.get('group_name')), function(confirm) {
|
||||
bootbox.confirm('Are you sure you want to delete the group: ' + utils.escapeHTML(ajaxify.data.group.name), function(confirm) {
|
||||
if (confirm) {
|
||||
bootbox.prompt('Please enter the name of this group in order to delete it:', function(response) {
|
||||
if (response === ajaxify.variables.get('group_name')) {
|
||||
if (response === ajaxify.data.group.name) {
|
||||
socket.emit('groups.delete', {
|
||||
groupName: ajaxify.variables.get('group_name')
|
||||
groupName: ajaxify.data.group.name
|
||||
}, function(err) {
|
||||
if (!err) {
|
||||
app.alertSuccess('[[groups:event.deleted, ' + utils.escapeHTML(ajaxify.variables.get('group_name')) + ']]');
|
||||
app.alertSuccess('[[groups:event.deleted, ' + utils.escapeHTML(ajaxify.data.group.name) + ']]');
|
||||
ajaxify.go('groups');
|
||||
} else {
|
||||
app.alertError(err.message);
|
||||
@@ -218,7 +218,7 @@ define('forum/groups/details', ['iconSelect', 'components', 'forum/infinitescrol
|
||||
|
||||
Details.cover.load = function() {
|
||||
socket.emit('groups.cover.get', {
|
||||
groupName: ajaxify.variables.get('group_name')
|
||||
groupName: ajaxify.data.group.name
|
||||
}, function(err, data) {
|
||||
if (!err) {
|
||||
var coverEl = components.get('groups/cover');
|
||||
@@ -267,7 +267,7 @@ define('forum/groups/details', ['iconSelect', 'components', 'forum/infinitescrol
|
||||
coverEl.addClass('saving');
|
||||
|
||||
socket.emit('groups.cover.update', {
|
||||
groupName: ajaxify.variables.get('group_name'),
|
||||
groupName: ajaxify.data.group.name,
|
||||
imageData: Details.cover.newCover || undefined,
|
||||
position: components.get('groups/cover').css('background-position')
|
||||
}, function(err) {
|
||||
@@ -294,7 +294,7 @@ define('forum/groups/details', ['iconSelect', 'components', 'forum/infinitescrol
|
||||
}
|
||||
|
||||
searchInterval = setTimeout(function() {
|
||||
socket.emit('groups.searchMembers', {groupName: ajaxify.variables.get('group_name'), query: query}, function(err, results) {
|
||||
socket.emit('groups.searchMembers', {groupName: ajaxify.data.group.name, query: query}, function(err, results) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -302,7 +302,7 @@ define('forum/groups/details', ['iconSelect', 'components', 'forum/infinitescrol
|
||||
infinitescroll.parseAndTranslate('groups/details', 'members', {
|
||||
group: {
|
||||
members: results.users,
|
||||
isOwner: ajaxify.variables.get('is_owner') === 'true'
|
||||
isOwner: ajaxify.data.group.isOwner
|
||||
}
|
||||
}, function(html) {
|
||||
$('[component="groups/members"] tbody').html(html);
|
||||
@@ -310,7 +310,7 @@ define('forum/groups/details', ['iconSelect', 'components', 'forum/infinitescrol
|
||||
});
|
||||
});
|
||||
}, 250);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function handleMemberInfiniteScroll() {
|
||||
@@ -330,7 +330,7 @@ define('forum/groups/details', ['iconSelect', 'components', 'forum/infinitescrol
|
||||
}
|
||||
members.attr('loading', 1);
|
||||
socket.emit('groups.loadMoreMembers', {
|
||||
groupName: ajaxify.variables.get('group_name'),
|
||||
groupName: ajaxify.data.group.name,
|
||||
after: members.attr('data-nextstart')
|
||||
}, function(err, data) {
|
||||
if (err) {
|
||||
@@ -356,7 +356,7 @@ define('forum/groups/details', ['iconSelect', 'components', 'forum/infinitescrol
|
||||
infinitescroll.parseAndTranslate('groups/details', 'members', {
|
||||
group: {
|
||||
members: users,
|
||||
isOwner: ajaxify.variables.get('is_owner') === 'true'
|
||||
isOwner: ajaxify.data.group.isOwner
|
||||
}
|
||||
}, function(html) {
|
||||
$('[component="groups/members"] tbody').append(html);
|
||||
|
||||
@@ -5,7 +5,7 @@ define('forum/reset_code', function() {
|
||||
var ResetCode = {};
|
||||
|
||||
ResetCode.init = function() {
|
||||
var reset_code = ajaxify.variables.get('reset_code');
|
||||
var reset_code = ajaxify.data.code;
|
||||
|
||||
var resetEl = $('#reset'),
|
||||
password = $('#password'),
|
||||
|
||||
@@ -24,7 +24,7 @@ define('forum/tag', ['forum/recent', 'forum/infinitescroll'], function(recent, i
|
||||
}
|
||||
|
||||
infinitescroll.loadMore('topics.loadMoreFromSet', {
|
||||
set: 'tag:' + ajaxify.variables.get('tag') + ':topics',
|
||||
set: 'tag:' + ajaxify.data.tag + ':topics',
|
||||
after: $('[component="category"]').attr('data-nextstart')
|
||||
}, function(data, done) {
|
||||
if (data.topics && data.topics.length) {
|
||||
|
||||
@@ -38,7 +38,7 @@ define('forum/topic', [
|
||||
});
|
||||
|
||||
Topic.init = function() {
|
||||
var tid = ajaxify.variables.get('topic_id');
|
||||
var tid = ajaxify.data.tid;
|
||||
|
||||
$(window).trigger('action:topic.loading');
|
||||
|
||||
@@ -50,7 +50,7 @@ define('forum/topic', [
|
||||
threadTools.init(tid);
|
||||
events.init();
|
||||
|
||||
sort.handleSort('topicPostSort', 'user.setTopicSort', 'topic/' + ajaxify.variables.get('topic_slug'));
|
||||
sort.handleSort('topicPostSort', 'user.setTopicSort', 'topic/' + ajaxify.data.slug);
|
||||
|
||||
enableInfiniteLoadingOrPagination();
|
||||
|
||||
@@ -58,7 +58,7 @@ define('forum/topic', [
|
||||
|
||||
handleBookmark(tid);
|
||||
|
||||
navigator.init('[component="post"]', ajaxify.variables.get('postcount'), Topic.toTop, Topic.toBottom, Topic.navigatorCallback, Topic.calculateIndex);
|
||||
navigator.init('[component="post"]', ajaxify.data.postcount, Topic.toTop, Topic.toBottom, Topic.navigatorCallback, Topic.calculateIndex);
|
||||
|
||||
$(window).on('scroll', updateTopicTitle);
|
||||
|
||||
@@ -107,7 +107,7 @@ define('forum/topic', [
|
||||
};
|
||||
|
||||
Topic.toBottom = function() {
|
||||
socket.emit('topics.postcount', ajaxify.variables.get('topic_id'), function(err, postCount) {
|
||||
socket.emit('topics.postcount', ajaxify.data.tid, function(err, postCount) {
|
||||
if (config.topicPostSort !== 'oldest_to_newest') {
|
||||
postCount = 2;
|
||||
}
|
||||
@@ -121,7 +121,7 @@ define('forum/topic', [
|
||||
|
||||
if (postIndex && window.location.search.indexOf('page=') === -1) {
|
||||
navigator.scrollToPost(postIndex - 1, true);
|
||||
} else if (bookmark && (!config.usePagination || (config.usePagination && pagination.currentPage === 1)) && ajaxify.variables.get('postcount') > 1) {
|
||||
} else if (bookmark && (!config.usePagination || (config.usePagination && pagination.currentPage === 1)) && ajaxify.data.postcount > 1) {
|
||||
app.alert({
|
||||
alert_id: 'bookmark',
|
||||
message: '[[topic:bookmark_instructions]]',
|
||||
@@ -162,14 +162,14 @@ define('forum/topic', [
|
||||
} else {
|
||||
navigator.hide();
|
||||
|
||||
pagination.init(parseInt(ajaxify.variables.get('currentPage'), 10), parseInt(ajaxify.variables.get('pageCount'), 10));
|
||||
pagination.init(parseInt(ajaxify.data.currentPage, 10), parseInt(ajaxify.data.pageCount, 10));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function updateTopicTitle() {
|
||||
if($(window).scrollTop() > 50) {
|
||||
components.get('navbar/title').find('span').text(ajaxify.variables.get('topic_name')).show();
|
||||
components.get('navbar/title').find('span').text(ajaxify.data.title).show();
|
||||
} else {
|
||||
components.get('navbar/title').find('span').text('').hide();
|
||||
}
|
||||
@@ -197,10 +197,10 @@ define('forum/topic', [
|
||||
}
|
||||
}
|
||||
|
||||
var currentBookmark = localStorage.getItem('topic:' + ajaxify.variables.get('topic_id') + ':bookmark');
|
||||
var currentBookmark = localStorage.getItem('topic:' + ajaxify.data.tid + ':bookmark');
|
||||
|
||||
if (!currentBookmark || parseInt(postIndex, 10) >= parseInt(currentBookmark, 10)) {
|
||||
localStorage.setItem('topic:' + ajaxify.variables.get('topic_id') + ':bookmark', postIndex);
|
||||
localStorage.setItem('topic:' + ajaxify.data.tid + ':bookmark', postIndex);
|
||||
app.removeAlert('bookmark');
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ define('forum/topic/browsing', ['translator'], function(translator) {
|
||||
var Browsing = {};
|
||||
|
||||
Browsing.onUpdateUsersInRoom = function(data) {
|
||||
if (data && data.room.indexOf('topic_' + ajaxify.variables.get('topic_id')) !== -1) {
|
||||
if (data && data.room.indexOf('topic_' + ajaxify.data.tid) !== -1) {
|
||||
$('[component="topic/browsing/list"]').parent().toggleClass('hidden', !data.users.length);
|
||||
for(var i=0; i<data.users.length; ++i) {
|
||||
addUserIcon(data.users[i]);
|
||||
|
||||
@@ -82,7 +82,7 @@ define('forum/topic/events', [
|
||||
}
|
||||
|
||||
function onTopicPurged(data) {
|
||||
ajaxify.go('category/' + ajaxify.variables.get('category_id'));
|
||||
ajaxify.go('category/' + ajaxify.data.cid);
|
||||
}
|
||||
|
||||
function onTopicMoved(data) {
|
||||
@@ -202,7 +202,7 @@ define('forum/topic/events', [
|
||||
}
|
||||
|
||||
function onNewNotification(data) {
|
||||
var tid = ajaxify.variables.get('topic_id');
|
||||
var tid = ajaxify.data.tid;
|
||||
if (data && data.tid && parseInt(data.tid, 10) === parseInt(tid, 10)) {
|
||||
socket.emit('topics.markTopicNotificationsRead', tid);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
topicName;
|
||||
|
||||
PostTools.init = function(tid) {
|
||||
topicName = ajaxify.variables.get('topic_name');
|
||||
topicName = ajaxify.data.title;
|
||||
|
||||
addPostHandlers(tid);
|
||||
|
||||
@@ -29,7 +29,7 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
};
|
||||
|
||||
PostTools.updatePostCount = function() {
|
||||
socket.emit('topics.postcount', ajaxify.variables.get('topic_id'), function(err, postCount) {
|
||||
socket.emit('topics.postcount', ajaxify.data.tid, function(err, postCount) {
|
||||
if (!err) {
|
||||
var postCountEl = components.get('topic/post-count');
|
||||
postCountEl.html(postCount).attr('title', postCount);
|
||||
@@ -110,7 +110,7 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
var btn = $(this);
|
||||
$(window).trigger('action:composer.post.edit', {
|
||||
pid: getData(btn, 'data-pid')
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
postContainer.on('click', '[component="post/delete"]', function(e) {
|
||||
@@ -152,7 +152,7 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
if (selectionText.length) {
|
||||
$(window).trigger('action:composer.addQuote', {
|
||||
tid: tid,
|
||||
slug: ajaxify.variables.get('topic_slug'),
|
||||
slug: ajaxify.data.slug,
|
||||
index: getData(button, 'data-index'),
|
||||
pid: getData(button, 'data-pid'),
|
||||
topicName: topicName,
|
||||
@@ -162,7 +162,7 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
} else {
|
||||
$(window).trigger('action:composer.post.new', {
|
||||
tid: tid,
|
||||
pid: ajaxify.variables.get('pid'),
|
||||
pid: getData(button, 'data-pid'),
|
||||
topicName: topicName,
|
||||
text: username + ' ' || ''
|
||||
});
|
||||
@@ -184,7 +184,7 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
|
||||
$(window).trigger('action:composer.addQuote', {
|
||||
tid: tid,
|
||||
slug: ajaxify.variables.get('topic_slug'),
|
||||
slug: ajaxify.data.slug,
|
||||
index: getData(button, 'data-index'),
|
||||
pid: pid,
|
||||
username: username,
|
||||
@@ -226,7 +226,7 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
}
|
||||
|
||||
function showVotes(pid) {
|
||||
socket.emit('posts.getVoters', {pid: pid, cid: ajaxify.variables.get('category_id')}, function(err, data) {
|
||||
socket.emit('posts.getVoters', {pid: pid, cid: ajaxify.data.cid}, function(err, data) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ define('forum/topic/posts', [
|
||||
var Posts = {};
|
||||
|
||||
Posts.onNewPost = function(data) {
|
||||
var tid = ajaxify.variables.get('topic_id');
|
||||
var tid = ajaxify.data.tid;
|
||||
if (data && data.posts && data.posts.length && parseInt(data.posts[0].tid, 10) !== parseInt(tid, 10)) {
|
||||
return;
|
||||
}
|
||||
@@ -133,9 +133,9 @@ define('forum/topic/posts', [
|
||||
|
||||
findInsertionPoint();
|
||||
|
||||
data.title = $('<div></div>').text(ajaxify.variables.get('topic_name')).html();
|
||||
data.slug = ajaxify.variables.get('topic_slug');
|
||||
data.viewcount = ajaxify.variables.get('viewcount');
|
||||
data.title = $('<div></div>').text(ajaxify.data.title).html();
|
||||
data.slug = ajaxify.data.slug;
|
||||
data.viewcount = ajaxify.data.viewcount;
|
||||
|
||||
infinitescroll.parseAndTranslate('topic', 'posts', data, function(html) {
|
||||
if (after) {
|
||||
@@ -219,7 +219,7 @@ define('forum/topic/posts', [
|
||||
};
|
||||
|
||||
function loadPostsAfter(after) {
|
||||
var tid = ajaxify.variables.get('topic_id');
|
||||
var tid = ajaxify.data.tid;
|
||||
if (!utils.isNumber(tid) || !utils.isNumber(after) || (after === 0 && components.get('post', 'index', 1).length)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -23,22 +23,22 @@ define('forum/topic/threadTools', ['forum/topic/fork', 'forum/topic/move', 'comp
|
||||
});
|
||||
|
||||
components.get('topic/lock').on('click', function() {
|
||||
socket.emit('topics.lock', {tids: [tid], cid: ajaxify.variables.get('category_id')});
|
||||
socket.emit('topics.lock', {tids: [tid], cid: ajaxify.data.cid});
|
||||
return false;
|
||||
});
|
||||
|
||||
components.get('topic/unlock').on('click', function() {
|
||||
socket.emit('topics.unlock', {tids: [tid], cid: ajaxify.variables.get('category_id')});
|
||||
socket.emit('topics.unlock', {tids: [tid], cid: ajaxify.data.cid});
|
||||
return false;
|
||||
});
|
||||
|
||||
components.get('topic/pin').on('click', function() {
|
||||
socket.emit('topics.pin', {tids: [tid], cid: ajaxify.variables.get('category_id')});
|
||||
socket.emit('topics.pin', {tids: [tid], cid: ajaxify.data.cid});
|
||||
return false;
|
||||
});
|
||||
|
||||
components.get('topic/unpin').on('click', function() {
|
||||
socket.emit('topics.unpin', {tids: [tid], cid: ajaxify.variables.get('category_id')});
|
||||
socket.emit('topics.unpin', {tids: [tid], cid: ajaxify.data.cid});
|
||||
return false;
|
||||
});
|
||||
|
||||
@@ -55,7 +55,7 @@ define('forum/topic/threadTools', ['forum/topic/fork', 'forum/topic/move', 'comp
|
||||
});
|
||||
|
||||
components.get('topic/move').on('click', function(e) {
|
||||
move.init([tid], ajaxify.variables.get('category_id'));
|
||||
move.init([tid], ajaxify.data.cid);
|
||||
return false;
|
||||
});
|
||||
|
||||
@@ -95,7 +95,7 @@ define('forum/topic/threadTools', ['forum/topic/fork', 'forum/topic/move', 'comp
|
||||
translator.translate('[[topic:thread_tools.' + command + '_confirm]]', function(msg) {
|
||||
bootbox.confirm(msg, function(confirm) {
|
||||
if (confirm) {
|
||||
socket.emit('topics.' + command, {tids: [tid], cid: ajaxify.variables.get('category_id')});
|
||||
socket.emit('topics.' + command, {tids: [tid], cid: ajaxify.data.cid});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -96,7 +96,7 @@ define('search', ['navigator', 'translator'], function(nav, translator) {
|
||||
};
|
||||
|
||||
Search.checkPagePresence = function(tid, callback) {
|
||||
if (parseInt(ajaxify.variables.get('topic_id'), 10) !== parseInt(tid, 10)) {
|
||||
if (parseInt(ajaxify.data.tid, 10) !== parseInt(tid, 10)) {
|
||||
ajaxify.go('topic/' + tid, callback);
|
||||
} else {
|
||||
callback();
|
||||
|
||||
@@ -7,10 +7,16 @@
|
||||
ajaxify.variables = {};
|
||||
|
||||
ajaxify.variables.set = function(key, value) {
|
||||
if (console && console.warn) {
|
||||
console.warn('[deprecated] variables.set is deprecated, please use ajaxify.data, key=' + key);
|
||||
}
|
||||
parsedVariables[key] = value;
|
||||
};
|
||||
|
||||
ajaxify.variables.get = function(key) {
|
||||
if (console && console.warn) {
|
||||
console.warn('[deprecated] variables.get is deprecated, please use ajaxify.data, key=' + key);
|
||||
}
|
||||
return parsedVariables[key];
|
||||
};
|
||||
|
||||
@@ -37,5 +43,9 @@
|
||||
|
||||
ajaxify.variables.set($(element).attr('template-variable'), value);
|
||||
});
|
||||
var dataEl = $('#content [ajaxify-data]');
|
||||
if (dataEl.length) {
|
||||
ajaxify.data = JSON.parse(decodeURIComponent(dataEl.attr('ajaxify-data')));
|
||||
}
|
||||
};
|
||||
}(ajaxify || {}));
|
||||
|
||||
@@ -191,7 +191,7 @@ middleware.buildHeader = function(req, res, next) {
|
||||
};
|
||||
|
||||
middleware.renderHeader = function(req, res, callback) {
|
||||
var registrationType = meta.config.registrationType || 'normal'
|
||||
var registrationType = meta.config.registrationType || 'normal';
|
||||
var templateValues = {
|
||||
bootswatchCSS: meta.config['theme:src'],
|
||||
title: meta.config.title || '',
|
||||
@@ -327,7 +327,7 @@ middleware.processRender = function(req, res, next) {
|
||||
return fn(err);
|
||||
}
|
||||
|
||||
// str = str + '<input type="hidden" ajaxify-data="' + encodeURIComponent(JSON.stringify(options)) + '" />';
|
||||
str = str + '<input type="hidden" ajaxify-data="' + encodeURIComponent(JSON.stringify(options)) + '" />';
|
||||
str = (res.locals.postHeader ? res.locals.postHeader : '') + str + (res.locals.preFooter ? res.locals.preFooter : '');
|
||||
|
||||
if (res.locals.footer) {
|
||||
|
||||
Reference in New Issue
Block a user