diff --git a/public/css/noscript.less b/public/css/noscript.less index 76f15d2325..9df1243c50 100644 --- a/public/css/noscript.less +++ b/public/css/noscript.less @@ -29,8 +29,22 @@ noscript { } .teaser { + margin-left: 16px; + margin-top: 8px; + img { float: left; + width: 32px; + } + + p { + color: #666; + font-size: 13px; + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; + margin-left: 64px; + padding-top: 10px; } } } diff --git a/public/src/forum/admin/topics.js b/public/src/forum/admin/topics.js index 4294f140a4..ba4ae12ea3 100644 --- a/public/src/forum/admin/topics.js +++ b/public/src/forum/admin/topics.js @@ -1,5 +1,6 @@ $(document).ready(function() { - var topicsListEl = document.querySelector('.topics'); + var topicsListEl = document.querySelector('.topics'), + loadMoreEl = document.getElementById('topics_loadmore'); $(topicsListEl).on('click', '[data-action]', function() { var $this = $(this), @@ -22,6 +23,19 @@ $(document).ready(function() { } }); + loadMoreEl.addEventListener('click', function() { + if (this.className.indexOf('disabled') === -1) { + var topics = document.querySelectorAll('.topics li[data-tid]'), + lastTid = parseInt(topics[topics.length - 1].getAttribute('data-tid')); + + this.innerHTML = ' Retrieving topics'; + socket.emit('api:admin.topics.getMore', { + limit: 10, + after: lastTid + }); + } + }, false); + // Resolve proper button state for all topics var topicEls = topicsListEl.querySelectorAll('li'), numTopics = topicEls.length; @@ -81,4 +95,24 @@ 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'; + } }); \ No newline at end of file diff --git a/public/src/forum/category.js b/public/src/forum/category.js index 4388198e5b..99c4d300e0 100644 --- a/public/src/forum/category.js +++ b/public/src/forum/category.js @@ -27,20 +27,21 @@ jQuery('#category-no-topics').remove(); topic.innerHTML = html; + topic = topic.querySelector('a'); + if (numTopics > 0) { for(x=0;x').appendTo("#topics-container").hide().append(html).fadeIn('slow'); - // set_up_posts(uniqueid); + ajaxify.enable(); }); diff --git a/public/src/modules/mobileMenu.js b/public/src/modules/mobileMenu.js index c21bc5bed9..2ee74f12ad 100644 --- a/public/src/modules/mobileMenu.js +++ b/public/src/modules/mobileMenu.js @@ -5,18 +5,23 @@ define(function() { var categories = null, overlay = null, menuBtn = null, - postBtn = null; + postBtn = null, + initialized = false; function loadCategories(callback) { if (categories) { - displayCategories(); + callback(true); return; } jQuery.getJSON('/api/home', function(data) { categories = data.categories; - displayCategories(); + initialized = true; + + if (callback) { + callback(true); + } }); } @@ -65,6 +70,8 @@ define(function() { mobileMenu.onNavigate = function() { + if (initialized == false) return false; + var cid = templates.get('category_id'), tid = templates.get('topic_id'); @@ -100,9 +107,11 @@ define(function() { animateIcons(); } - - loadCategories(displayCategories); - mobileMenu.onNavigate(); + loadCategories(function() { + displayCategories(); + mobileMenu.onNavigate(); + }); + } return { diff --git a/public/src/templates.js b/public/src/templates.js index 10116f6663..418018dded 100644 --- a/public/src/templates.js +++ b/public/src/templates.js @@ -250,19 +250,23 @@ if (data[d] === null) { template = replace(namespace + d, '', template); } else if (data[d].constructor == Array) { - namespace += d; + namespace += d + '.'; - regex = makeRegex(d), - block = getBlock(regex, namespace, template) - if (block == null) continue; + var regex = makeRegex(d), + block = getBlock(regex, namespace.substring(0, namespace.length-1), template); + + if (block == null) { + namespace = namespace.replace(d + '.', ''); + continue; + } var numblocks = data[d].length - 1, i = 0, result = ""; do { - result += parse(data[d][i], namespace + '.', block); + result += parse(data[d][i], namespace, block); } while (i++ < numblocks); - namespace = namespace.replace(d, ''); + namespace = namespace.replace(d + '.', ''); template = setBlock(regex, result, template); } else if (data[d] instanceof Object) { namespace += d + '.'; @@ -273,7 +277,7 @@ block = parse(data[d], namespace, block); template = setBlock(regex, block, template); - } else { + } else { template = replace(namespace + d, data[d], template); } } diff --git a/public/templates/admin/topics.tpl b/public/templates/admin/topics.tpl index d3fef7b6b5..68d58e2c19 100644 --- a/public/templates/admin/topics.tpl +++ b/public/templates/admin/topics.tpl @@ -19,4 +19,8 @@ +
+ +
+ \ No newline at end of file diff --git a/public/templates/noscript/category.tpl b/public/templates/noscript/category.tpl index 00728916b0..3aeb8ddc87 100644 --- a/public/templates/noscript/category.tpl +++ b/public/templates/noscript/category.tpl @@ -6,7 +6,7 @@