Merge remote-tracking branch 'origin' into thread_options

Conflicts:
	public/src/templates.js
This commit is contained in:
Julian Lam
2013-05-07 12:56:21 -04:00
14 changed files with 163 additions and 55 deletions

View File

@@ -30,6 +30,7 @@ var ajaxify = {};
var url = url.replace(/\/$/, "");
var tpl_url = (url === '' || url === '/') ? 'home' : url.split('/')[0];
tpl_url = templates.get_custom_map(tpl_url);
if (templates[tpl_url]) {
window.history.pushState({}, url, "/" + url);

View File

@@ -1,7 +1,12 @@
var templates = {};
(function() {
var ready_callback;
var ready_callback,
config;
templates.get_custom_map = function(tpl) {
return (config['custom_mapping'] && config['custom_mapping'][tpl]) ? config['custom_mapping'][tpl] : tpl;
}
templates.ready = function(callback) {
//quick implementation because introducing a lib to handle several async callbacks
@@ -21,6 +26,10 @@ var templates = {};
var timestamp = new Date().getTime();
var loaded = templatesToLoad.length;
$.getJSON('/templates/config.json', function(data) {
config = data;
});
for (var t in templatesToLoad) {
(function(file) {
$.get('/templates/' + file + '.tpl?v=' + timestamp, function(html) {
@@ -146,7 +155,10 @@ function load_template(callback) {
url = (url === '' || url === '/') ? 'home' : url;
jQuery.get(API_URL + url, function(data) {
document.getElementById('content').innerHTML = templates[url.split('/')[0]].parse(JSON.parse(data));
var tpl = url.split('/')[0];
tpl = templates.get_custom_map(tpl);
document.getElementById('content').innerHTML = templates[tpl].parse(JSON.parse(data));
if (callback) callback();
});
}