|
|
|
@ -32,6 +32,23 @@ $(document).ready(function() {
|
|
|
|
|
socket.emit('api:admin.topics.getMore', {
|
|
|
|
|
limit: 10,
|
|
|
|
|
after: lastTid
|
|
|
|
|
}, function(topics) {
|
|
|
|
|
var btnEl = document.getElementById('topics_loadmore');
|
|
|
|
|
|
|
|
|
|
topics = JSON.parse(topics);
|
|
|
|
|
if (topics.length > 0) {
|
|
|
|
|
var html = templates.prepare(templates['admin/topics'].blocks['topics']).parse({
|
|
|
|
|
topics: topics
|
|
|
|
|
}),
|
|
|
|
|
topicsListEl = document.querySelector('.topics');
|
|
|
|
|
|
|
|
|
|
topicsListEl.innerHTML += html;
|
|
|
|
|
btnEl.innerHTML = 'Load More Topics';
|
|
|
|
|
} else {
|
|
|
|
|
// Exhausted all topics
|
|
|
|
|
btnEl.className += ' disabled';
|
|
|
|
|
btnEl.innerHTML = 'No more topics';
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, false);
|
|
|
|
@ -40,9 +57,9 @@ $(document).ready(function() {
|
|
|
|
|
var topicEls = topicsListEl.querySelectorAll('li'),
|
|
|
|
|
numTopics = topicEls.length;
|
|
|
|
|
for(var x=0;x<numTopics;x++) {
|
|
|
|
|
if (topicEls[x].getAttribute('data-pinned')) topicEls[x].querySelector('[data-action="pin"]').className += ' active';
|
|
|
|
|
if (topicEls[x].getAttribute('data-locked')) topicEls[x].querySelector('[data-action="lock"]').className += ' active';
|
|
|
|
|
if (topicEls[x].getAttribute('data-deleted')) topicEls[x].querySelector('[data-action="delete"]').className += ' active';
|
|
|
|
|
if (topicEls[x].getAttribute('data-pinned') === '1') topicEls[x].querySelector('[data-action="pin"]').className += ' active';
|
|
|
|
|
if (topicEls[x].getAttribute('data-locked') === '1') topicEls[x].querySelector('[data-action="lock"]').className += ' active';
|
|
|
|
|
if (topicEls[x].getAttribute('data-deleted') === '1') topicEls[x].querySelector('[data-action="delete"]').className += ' active';
|
|
|
|
|
topicEls[x].removeAttribute('data-pinned');
|
|
|
|
|
topicEls[x].removeAttribute('data-locked');
|
|
|
|
|
topicEls[x].removeAttribute('data-deleted');
|
|
|
|
@ -96,23 +113,3 @@ socket.on('api:topic.restore', function(response) {
|
|
|
|
|
$(btnEl).removeClass('active');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
socket.on('api:admin.topics.getMore', function(topics) {
|
|
|
|
|
var btnEl = document.getElementById('topics_loadmore');
|
|
|
|
|
|
|
|
|
|
topics = JSON.parse(topics);
|
|
|
|
|
console.log(topics);
|
|
|
|
|
if (topics.length > 0) {
|
|
|
|
|
var html = templates.prepare(templates['admin/topics'].blocks['topics']).parse({
|
|
|
|
|
topics: topics
|
|
|
|
|
}),
|
|
|
|
|
topicsListEl = document.querySelector('.topics');
|
|
|
|
|
|
|
|
|
|
topicsListEl.innerHTML += html;
|
|
|
|
|
btnEl.innerHTML = 'Load More Topics';
|
|
|
|
|
} else {
|
|
|
|
|
// Exhausted all topics
|
|
|
|
|
btnEl.className += ' disabled';
|
|
|
|
|
btnEl.innerHTML = 'No more topics';
|
|
|
|
|
}
|
|
|
|
|
});
|