mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 23:15:48 +01:00
added functionality to post button. also introduced some underlying concepts regarding modules and pulling template vars
This commit is contained in:
@@ -47,7 +47,8 @@ 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
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -169,7 +169,7 @@
|
|||||||
if (!templates[tpl_url] || !template_data) return;
|
if (!templates[tpl_url] || !template_data) return;
|
||||||
|
|
||||||
document.getElementById('content').innerHTML = templates[tpl_url].parse(JSON.parse(template_data));
|
document.getElementById('content').innerHTML = templates[tpl_url].parse(JSON.parse(template_data));
|
||||||
|
|
||||||
jQuery('#content [template-variable]').each(function(index, element) {
|
jQuery('#content [template-variable]').each(function(index, element) {
|
||||||
templates.set(element.getAttribute('template-variable'), element.value);
|
templates.set(element.getAttribute('template-variable'), element.value);
|
||||||
});
|
});
|
||||||
@@ -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];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user