v1.18.x
Baris Usakli 12 years ago
parent c647793512
commit cb6f587f24

@ -2,7 +2,7 @@ var ajaxify = {};
(function($) { (function($) {
var location = document.location || window.location, var location = document.location || window.location,
rootUrl = location.protocol + '//' + (location.hostname || location.host) + (location.port ? ':' + location.port : ''), rootUrl = location.protocol + '//' + (location.hostname || location.host) + (location.port ? ':' + location.port : ''),
content = null; content = null;
@ -39,14 +39,14 @@ var ajaxify = {};
} }
var tpl_url = templates.get_custom_map(url.split('?')[0]); var tpl_url = templates.get_custom_map(url.split('?')[0]);
if (tpl_url == false && !templates[url]) { if (tpl_url == false && !templates[url]) {
if(url === '' || url === '/') { if(url === '' || url === '/') {
tpl_url = 'home'; tpl_url = 'home';
} else { } else {
tpl_url = url.split('/')[0].split('?')[0]; tpl_url = url.split('/')[0].split('?')[0];
} }
} else if (templates[url]) { } else if (templates[url]) {
tpl_url = url; tpl_url = url;
} }
@ -67,9 +67,9 @@ var ajaxify = {};
if (callback) { if (callback) {
callback(); callback();
} }
app.process_page(); app.process_page();
jQuery('#content, #footer').stop(true, true).fadeIn(200, function() { jQuery('#content, #footer').stop(true, true).fadeIn(200, function() {
if(window.location.hash) if(window.location.hash)
hash = window.location.hash; hash = window.location.hash;
@ -94,12 +94,15 @@ var ajaxify = {};
// Enhancing all anchors to ajaxify... // Enhancing all anchors to ajaxify...
$(document.body).on('click', 'a', function(e) { $(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 +'/', ''); var url = this.href.replace(rootUrl +'/', '');
if (this.target !== '') return; if (this.target !== '') return;
if (!e.ctrlKey && e.which === 1) { if (!e.ctrlKey && e.which === 1) {
@ -126,7 +129,7 @@ var ajaxify = {};
script.type = "text/javascript"; script.type = "text/javascript";
try { try {
script.appendChild(document.createTextNode(data)); script.appendChild(document.createTextNode(data));
} catch(e) { } catch(e) {
script.text = data; script.text = data;
} }
@ -162,5 +165,5 @@ var ajaxify = {};
evalScript(scripts[i]); evalScript(scripts[i]);
} }
}; };
}(jQuery)); }(jQuery));

@ -218,7 +218,6 @@ var socket,
app.current_room = null; app.current_room = null;
app.enter_room = function(room) { app.enter_room = function(room) {
if(socket) { if(socket) {
if (app.current_room === room) if (app.current_room === room)
return; return;
@ -334,7 +333,7 @@ var socket,
if(data.posts.length) { if(data.posts.length) {
app.createNewPosts(data); app.createNewPosts(data);
} }
if(callback) if(callback)
callback(data.posts); callback(data.posts);
}); });
@ -356,20 +355,20 @@ var socket,
} }
if(!scrollTo.length && tid) { if(!scrollTo.length && tid) {
var intervalID = setInterval(function() { var intervalID = setInterval(function() {
app.loadMorePosts(tid, function(posts) { app.loadMorePosts(tid, function(posts) {
scrollTo = $('#post_anchor_' + pid); scrollTo = $('#post_anchor_' + pid);
if(tid && scrollTo.length) { if(tid && scrollTo.length) {
animateScroll(); animateScroll();
} }
if(!posts.length || scrollTo.length) if(!posts.length || scrollTo.length)
clearInterval(intervalID); clearInterval(intervalID);
}); });
}, 100); }, 100);
} else if(tid) { } else if(tid) {
animateScroll(); animateScroll();
} }

@ -9,12 +9,12 @@
pinned: templates.get('pinned') pinned: templates.get('pinned')
}, },
topic_name = templates.get('topic_name'); topic_name = templates.get('topic_name');
jQuery('document').ready(function() { jQuery('document').ready(function() {
app.addCommasToNumbers(); app.addCommasToNumbers();
var room = 'topic_' + tid, var room = 'topic_' + tid,
adminTools = document.getElementById('thread-tools'); adminTools = document.getElementById('thread-tools');
@ -26,17 +26,12 @@
if (thread_state.pinned === '1') set_pinned_state(true); if (thread_state.pinned === '1') set_pinned_state(true);
if (expose_tools === '1') { if (expose_tools === '1') {
var deleteThreadEl = document.getElementById('delete_thread'), var moveThreadModal = $('#move_thread_modal');
lockThreadEl = document.getElementById('lock_thread'),
pinThreadEl = document.getElementById('pin_thread'),
moveThreadEl = document.getElementById('move_thread'),
moveThreadModal = $('#move_thread_modal');
adminTools.style.visibility = 'inherit'; adminTools.style.visibility = 'inherit';
// Add events to the thread tools // Add events to the thread tools
deleteThreadEl.addEventListener('click', function(e) { $('#delete_thread').on('click', function(e) {
e.preventDefault();
if (thread_state.deleted !== '1') { if (thread_state.deleted !== '1') {
bootbox.confirm('Are you sure you want to delete this thread?', function(confirm) { bootbox.confirm('Are you sure you want to delete this thread?', function(confirm) {
if (confirm) socket.emit('api:topic.delete', { tid: tid }); if (confirm) socket.emit('api:topic.delete', { tid: tid });
@ -46,30 +41,31 @@
if (confirm) socket.emit('api:topic.restore', { tid: tid }); if (confirm) socket.emit('api:topic.restore', { tid: tid });
}); });
} }
}, false); return false;
});
lockThreadEl.addEventListener('click', function(e) { $('#lock_thread').on('click', function(e) {
e.preventDefault();
if (thread_state.locked !== '1') { if (thread_state.locked !== '1') {
socket.emit('api:topic.lock', { tid: tid }); socket.emit('api:topic.lock', { tid: tid });
} else { } else {
socket.emit('api:topic.unlock', { tid: tid }); socket.emit('api:topic.unlock', { tid: tid });
} }
}, false); return false;
});
pinThreadEl.addEventListener('click', function(e) { $('#pin_thread').on('click', function(e) {
e.preventDefault();
if (thread_state.pinned !== '1') { if (thread_state.pinned !== '1') {
socket.emit('api:topic.pin', { tid: tid }); socket.emit('api:topic.pin', { tid: tid });
} else { } else {
socket.emit('api:topic.unpin', { tid: tid }); socket.emit('api:topic.unpin', { tid: tid });
} }
}, false); return false;
});
moveThreadEl.addEventListener('click', function(e) { $('#move_thread').on('click', function(e) {
e.preventDefault();
moveThreadModal.modal('show'); moveThreadModal.modal('show');
}, false); return false;
});
moveThreadModal.on('shown', function() { moveThreadModal.on('shown', function() {
var loadingEl = document.getElementById('categories-loading'); var loadingEl = document.getElementById('categories-loading');
@ -195,7 +191,7 @@
}); });
} }
}); });
socket.emit('api:topic.followCheck', tid); socket.emit('api:topic.followCheck', tid);
if(followEl[0]) { if(followEl[0]) {
followEl[0].addEventListener('click', function() { followEl[0].addEventListener('click', function() {
@ -284,7 +280,7 @@
socket.emit('api:posts.delete', { pid: pid }) : socket.emit('api:posts.delete', { pid: pid }) :
socket.emit('api:posts.restore', { pid: pid }); socket.emit('api:posts.restore', { pid: pid });
} }
}); });
$('.post-container').delegate('.chat', 'click', function(e) { $('.post-container').delegate('.chat', 'click', function(e) {
@ -296,7 +292,7 @@
chatModal.show(); chatModal.show();
chat.bringModalToTop(chatModal); chat.bringModalToTop(chatModal);
}); });
}); });
ajaxify.register_events([ ajaxify.register_events([
@ -372,7 +368,7 @@
var editedPostEl = document.getElementById('content_' + data.pid); var editedPostEl = document.getElementById('content_' + data.pid);
var editedPostTitle = $('#topic_title_'+data.pid); var editedPostTitle = $('#topic_title_'+data.pid);
if(editedPostTitle.length > 0) { if(editedPostTitle.length > 0) {
editedPostTitle.fadeOut(250, function() { editedPostTitle.fadeOut(250, function() {
editedPostTitle.html(data.title); editedPostTitle.html(data.title);
@ -402,7 +398,7 @@
if (favEl) { if (favEl) {
favEl.className = 'icon-star-empty'; favEl.className = 'icon-star-empty';
$(favEl).parent().removeClass('btn-warning'); $(favEl).parent().removeClass('btn-warning');
} }
} }
}); });
@ -595,7 +591,7 @@
var postEl = $(document.querySelector('#post-container li[data-pid="' + pid + '"]')), var postEl = $(document.querySelector('#post-container li[data-pid="' + pid + '"]')),
editEl = postEl.find('.edit'), editEl = postEl.find('.edit'),
deleteEl = postEl.find('.delete'); deleteEl = postEl.find('.delete');
if (state) { if (state) {
editEl.removeClass('none'); editEl.removeClass('none');
deleteEl.removeClass('none'); deleteEl.removeClass('none');

Loading…
Cancel
Save