added functionality to post button. also introduced some underlying concepts regarding modules and pulling template vars

v1.18.x
psychobunny 12 years ago
parent a846caa387
commit 5bb9933f4a

@ -48,6 +48,7 @@ var ajaxify = {};
jQuery('#footer, #content').fadeOut(100); jQuery('#footer, #content').fadeOut(100);
templates.flush();
templates.load_template(function() { templates.load_template(function() {
exec_body_scripts(content); exec_body_scripts(content);

@ -191,6 +191,11 @@ var socket,
socket.emit('api:user.get_online_users', uids); socket.emit('api:user.get_online_users', uids);
} }
// here is where all modules' onNavigate should be called, I think.
require(['mobileMenu'], function(mobileMenu) {
mobileMenu.onNavigate();
});
populate_online_users(); populate_online_users();

@ -4,7 +4,8 @@ define(function() {
var categories = null, var categories = null,
overlay = null, overlay = null,
menuBtn = null; menuBtn = null,
postBtn = null;
function loadCategories(callback) { function loadCategories(callback) {
@ -63,9 +64,27 @@ define(function() {
} }
mobileMenu.onNavigate = function() {
var cid = templates.get('category_id');
if (cid) {
postBtn.style.display = 'inline-block';
postBtn.onclick = function() {
require(['composer'], function(cmp) {
cmp.push(0, cid); //todo check if in post
});
};
} else {
postBtn.style.display = 'none';
}
};
mobileMenu.init = function() { mobileMenu.init = function() {
overlay = overlay || document.getElementById('mobile-menu-overlay'); overlay = overlay || document.getElementById('mobile-menu-overlay');
menuBtn = menuBtn || document.getElementById('mobile-menu-btn'); menuBtn = menuBtn || document.getElementById('mobile-menu-btn');
postBtn = postBtn || document.getElementById('mobile-post-btn');
menuBtn.onclick = function() { menuBtn.onclick = function() {
animateIcons(); animateIcons();
@ -73,9 +92,11 @@ define(function() {
loadCategories(displayCategories); loadCategories(displayCategories);
mobileMenu.onNavigate();
} }
return { return {
init: mobileMenu.init init: mobileMenu.init,
onNavigate: mobileMenu.onNavigate
} }
}); });

@ -181,6 +181,10 @@
} }
templates.flush = function() {
parsed_variables = {};
}
templates.get = function(key) { templates.get = function(key) {
return parsed_variables[key]; return parsed_variables[key];
} }

Loading…
Cancel
Save