$.fn.loadTemplates = function() {
$.JST.loadTemplates($(this));
return this;
};
$.JST = {
_templates: new Object(),
_decorators:new Object(),
loadTemplates: function(elems) {
// var elems[0].innerHTML="↵
");
} else {
stripString = fillStripData(stripString, jsData); //replace placeholders with data
}
}
var ret = $(stripString);// create a jquery object in memory
ret.attr("__template", template); // set __template attribute
//decorate the strip
var dec = $.JST._decorators[template];
if (typeof (dec) == "function")
dec(ret, jsData);
return ret;
},
existsTemplate: function(template) {
return $.JST._templates[template];
},
//decorate function is like function(domElement,jsonData){...}
loadDecorator:function(template, decorator) {
$.JST._decorators[template] = decorator;
},
getDecorator:function(template) {
return $.JST._decorators[template];
},
decorateTemplate:function(element) {
var dec = $.JST._decorators[element.attr("__template")];
if (typeof (dec) == "function")
dec(editor);
},
// asynchronous
ajaxLoadAsynchTemplates: function(templateUrl, callback) {
$.get(templateUrl, function(data) {
var div = $("
");
div.html(data);
$.JST.loadTemplates(div);
if (typeof(callback == "function"))
callback();
},"html");
},
ajaxLoadTemplates: function(templateUrl) {
$.ajax({
async:false,
url: templateUrl,
dataType: "html",
success: function(data) {
var div = $("
");
div.html(data);
$.JST.loadTemplates(div);
}
});
}
};