mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-09 07:25:46 +01:00
closes #197
This commit is contained in:
@@ -2,7 +2,7 @@ var ajaxify = {};
|
||||
|
||||
|
||||
(function($) {
|
||||
|
||||
|
||||
var location = document.location || window.location,
|
||||
rootUrl = location.protocol + '//' + (location.hostname || location.host) + (location.port ? ':' + location.port : ''),
|
||||
content = null;
|
||||
@@ -39,14 +39,14 @@ var ajaxify = {};
|
||||
}
|
||||
|
||||
var tpl_url = templates.get_custom_map(url.split('?')[0]);
|
||||
|
||||
|
||||
if (tpl_url == false && !templates[url]) {
|
||||
if(url === '' || url === '/') {
|
||||
tpl_url = 'home';
|
||||
} else {
|
||||
tpl_url = url.split('/')[0].split('?')[0];
|
||||
}
|
||||
|
||||
|
||||
} else if (templates[url]) {
|
||||
tpl_url = url;
|
||||
}
|
||||
@@ -67,9 +67,9 @@ var ajaxify = {};
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
|
||||
|
||||
app.process_page();
|
||||
|
||||
|
||||
jQuery('#content, #footer').stop(true, true).fadeIn(200, function() {
|
||||
if(window.location.hash)
|
||||
hash = window.location.hash;
|
||||
@@ -94,12 +94,15 @@ var ajaxify = {};
|
||||
|
||||
// Enhancing all anchors to ajaxify...
|
||||
$(document.body).on('click', 'a', function(e) {
|
||||
if (this.href == window.location.href + "#") return;
|
||||
if(this.href.slice(-1) === "#") return;
|
||||
|
||||
|
||||
function hrefEmpty(href) {
|
||||
return href == 'javascript:;' || href == window.location.href + "#" || href.slice(-1) === "#";
|
||||
}
|
||||
|
||||
if(hrefEmpty(this.href)) return;
|
||||
|
||||
var url = this.href.replace(rootUrl +'/', '');
|
||||
|
||||
|
||||
if (this.target !== '') return;
|
||||
|
||||
if (!e.ctrlKey && e.which === 1) {
|
||||
@@ -126,7 +129,7 @@ var ajaxify = {};
|
||||
|
||||
script.type = "text/javascript";
|
||||
try {
|
||||
script.appendChild(document.createTextNode(data));
|
||||
script.appendChild(document.createTextNode(data));
|
||||
} catch(e) {
|
||||
script.text = data;
|
||||
}
|
||||
@@ -162,5 +165,5 @@ var ajaxify = {};
|
||||
evalScript(scripts[i]);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}(jQuery));
|
||||
@@ -218,7 +218,6 @@ var socket,
|
||||
|
||||
app.current_room = null;
|
||||
app.enter_room = function(room) {
|
||||
|
||||
if(socket) {
|
||||
if (app.current_room === room)
|
||||
return;
|
||||
@@ -334,7 +333,7 @@ var socket,
|
||||
if(data.posts.length) {
|
||||
app.createNewPosts(data);
|
||||
}
|
||||
|
||||
|
||||
if(callback)
|
||||
callback(data.posts);
|
||||
});
|
||||
@@ -356,20 +355,20 @@ var socket,
|
||||
}
|
||||
|
||||
if(!scrollTo.length && tid) {
|
||||
|
||||
|
||||
var intervalID = setInterval(function() {
|
||||
app.loadMorePosts(tid, function(posts) {
|
||||
scrollTo = $('#post_anchor_' + pid);
|
||||
|
||||
|
||||
if(tid && scrollTo.length) {
|
||||
animateScroll();
|
||||
animateScroll();
|
||||
}
|
||||
|
||||
|
||||
if(!posts.length || scrollTo.length)
|
||||
clearInterval(intervalID);
|
||||
});
|
||||
}, 100);
|
||||
|
||||
|
||||
} else if(tid) {
|
||||
animateScroll();
|
||||
}
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
pinned: templates.get('pinned')
|
||||
},
|
||||
topic_name = templates.get('topic_name');
|
||||
|
||||
|
||||
|
||||
jQuery('document').ready(function() {
|
||||
|
||||
app.addCommasToNumbers();
|
||||
|
||||
|
||||
var room = 'topic_' + tid,
|
||||
adminTools = document.getElementById('thread-tools');
|
||||
|
||||
@@ -26,17 +26,12 @@
|
||||
if (thread_state.pinned === '1') set_pinned_state(true);
|
||||
|
||||
if (expose_tools === '1') {
|
||||
var deleteThreadEl = document.getElementById('delete_thread'),
|
||||
lockThreadEl = document.getElementById('lock_thread'),
|
||||
pinThreadEl = document.getElementById('pin_thread'),
|
||||
moveThreadEl = document.getElementById('move_thread'),
|
||||
moveThreadModal = $('#move_thread_modal');
|
||||
var moveThreadModal = $('#move_thread_modal');
|
||||
|
||||
adminTools.style.visibility = 'inherit';
|
||||
|
||||
// Add events to the thread tools
|
||||
deleteThreadEl.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
$('#delete_thread').on('click', function(e) {
|
||||
if (thread_state.deleted !== '1') {
|
||||
bootbox.confirm('Are you sure you want to delete this thread?', function(confirm) {
|
||||
if (confirm) socket.emit('api:topic.delete', { tid: tid });
|
||||
@@ -46,30 +41,31 @@
|
||||
if (confirm) socket.emit('api:topic.restore', { tid: tid });
|
||||
});
|
||||
}
|
||||
}, false);
|
||||
return false;
|
||||
});
|
||||
|
||||
lockThreadEl.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
$('#lock_thread').on('click', function(e) {
|
||||
if (thread_state.locked !== '1') {
|
||||
socket.emit('api:topic.lock', { tid: tid });
|
||||
} else {
|
||||
socket.emit('api:topic.unlock', { tid: tid });
|
||||
}
|
||||
}, false);
|
||||
return false;
|
||||
});
|
||||
|
||||
pinThreadEl.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
$('#pin_thread').on('click', function(e) {
|
||||
if (thread_state.pinned !== '1') {
|
||||
socket.emit('api:topic.pin', { tid: tid });
|
||||
} else {
|
||||
socket.emit('api:topic.unpin', { tid: tid });
|
||||
}
|
||||
}, false);
|
||||
return false;
|
||||
});
|
||||
|
||||
moveThreadEl.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
$('#move_thread').on('click', function(e) {
|
||||
moveThreadModal.modal('show');
|
||||
}, false);
|
||||
return false;
|
||||
});
|
||||
|
||||
moveThreadModal.on('shown', function() {
|
||||
var loadingEl = document.getElementById('categories-loading');
|
||||
@@ -195,7 +191,7 @@
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
socket.emit('api:topic.followCheck', tid);
|
||||
if(followEl[0]) {
|
||||
followEl[0].addEventListener('click', function() {
|
||||
@@ -284,7 +280,7 @@
|
||||
socket.emit('api:posts.delete', { pid: pid }) :
|
||||
socket.emit('api:posts.restore', { pid: pid });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.post-container').delegate('.chat', 'click', function(e) {
|
||||
|
||||
@@ -296,7 +292,7 @@
|
||||
chatModal.show();
|
||||
chat.bringModalToTop(chatModal);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
ajaxify.register_events([
|
||||
@@ -372,7 +368,7 @@
|
||||
var editedPostEl = document.getElementById('content_' + data.pid);
|
||||
|
||||
var editedPostTitle = $('#topic_title_'+data.pid);
|
||||
|
||||
|
||||
if(editedPostTitle.length > 0) {
|
||||
editedPostTitle.fadeOut(250, function() {
|
||||
editedPostTitle.html(data.title);
|
||||
@@ -402,7 +398,7 @@
|
||||
if (favEl) {
|
||||
favEl.className = 'icon-star-empty';
|
||||
$(favEl).parent().removeClass('btn-warning');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -595,7 +591,7 @@
|
||||
var postEl = $(document.querySelector('#post-container li[data-pid="' + pid + '"]')),
|
||||
editEl = postEl.find('.edit'),
|
||||
deleteEl = postEl.find('.delete');
|
||||
|
||||
|
||||
if (state) {
|
||||
editEl.removeClass('none');
|
||||
deleteEl.removeClass('none');
|
||||
|
||||
Reference in New Issue
Block a user