2012-07-19 21:45:22 +00:00
|
|
|
// js/modules/util.js
|
|
|
|
// utility functions for template loading / ..
|
|
|
|
|
2012-07-19 14:25:01 +00:00
|
|
|
(function (Util) {
|
|
|
|
|
|
|
|
// cache
|
|
|
|
Util.templates = {};
|
|
|
|
|
|
|
|
Util.preloadTemplates = function (names, callback) {
|
|
|
|
var loadTemplate = function (index) {
|
|
|
|
var name = names[index];
|
|
|
|
$.get('js/templates/' + name + '.handlebars', function (data) {
|
|
|
|
Util.templates[name] = data;
|
|
|
|
index++;
|
|
|
|
if (index < names.length) {
|
|
|
|
loadTemplate(index);
|
|
|
|
} else {
|
|
|
|
callback();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
loadTemplate(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Util.getTemplate = function (name) {
|
|
|
|
return Util.templates[name];
|
|
|
|
}
|
|
|
|
|
2012-07-19 21:45:22 +00:00
|
|
|
})(app.module("util"));
|
|
|
|
|
|
|
|
|
|
|
|
|