From dbf7887cc62a525fc5f8691c21bd550968546465 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Mon, 24 Jun 2013 13:03:18 -0400 Subject: [PATCH 1/2] fixes issue #14 --- public/src/modules/mobileMenu.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) 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 { From 838387430473af6315f7efbf39bbe9cf0fac52f2 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Mon, 24 Jun 2013 13:30:33 -0400 Subject: [PATCH 2/2] closes issue #15 - fixed some issues in templates.js --- public/src/templates.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/public/src/templates.js b/public/src/templates.js index 10116f6663..f8d97edcc0 100644 --- a/public/src/templates.js +++ b/public/src/templates.js @@ -250,19 +250,22 @@ 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; + 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 + '.';