/* * jquery templates plugin 1.0.0pre * http://github.com/jquery/jquery-tmpl * requires jquery 1.4.2 * * copyright software freedom conservancy, inc. * dual licensed under the mit or gpl version 2 licenses. * http://jquery.org/license */ (function (a) { var r = a.fn.dommanip, d = "_tmplitem", q = /^[^<]*(<[\w\w]+>)[^>]*$|\{\{\! /, b = {}, f = {}, e, p = { key: 0, data: {} }, i = 0, c = 0, l = []; function g(g, d, h, e) { var c = { data: e || (e === 0 || e === false) ? e : d ? d.data : {}, _wrap: d ? d._wrap : null, tmpl: null, parent: d || null, nodes: [], calls: u, nest: w, wrap: x, html: v, update: t }; g && a.extend(c, g, { nodes: [], parent: d }); if (h) { c.tmpl = h; c._ctnt = c._ctnt || c.tmpl(a, c); c.key = ++i; (l.length ? f : b)[i] = c } return c } a.each({ appendto: "append", prependto: "prepend", insertbefore: "before", insertafter: "after", replaceall: "replacewith" }, function (f, d) { a.fn[f] = function (n) { var g = [], i = a(n), k, h, m, l, j = this.length === 1 && this[0].parentnode; e = b || {}; if (j && j.nodetype === 11 && j.childnodes.length === 1 && i.length === 1) { i[d](this[0]); g = this } else { for (h = 0, m = i.length; h < m; h++) { c = h; k = (h > 0 ? this.clone(true) : this).get(); a(i[h])[d](k); g = g.concat(k) } c = 0; g = this.pushstack(g, f, i.selector) } l = e; e = null; a.tmpl.complete(l); return g } }); a.fn.extend({ tmpl: function (d, c, b) { return a.tmpl(this[0], d, c, b) }, tmplitem: function () { return a.tmplitem(this[0]) }, template: function (b) { return a.template(b, this[0]) }, dommanip: function (d, m, k) { if (d[0] && a.isarray(d[0])) { var g = a.makearray(arguments), h = d[0], j = h.length, i = 0, f; while (i < j && !(f = a.data(h[i++], "tmplitem"))); if (f && c) g[2] = function (b) { a.tmpl.aftermanip(this, b, k) }; r.apply(this, g) } else r.apply(this, arguments); c = 0; !e && a.tmpl.complete(b); return this } }); a.extend({ tmpl: function (d, h, e, c) { var i, k = !c; if (k) { c = p; d = a.template[d] || a.template(null, d); f = {} } else if (!d) { d = c.tmpl; b[c.key] = c; c.nodes = []; c.wrapped && n(c, c.wrapped); return a(j(c, null, c.tmpl(a, c))) } if (!d) return []; if (typeof h === "function") h = h.call(c || {}); e && e.wrapped && n(e, e.wrapped); i = a.isarray(h) ? a.map(h, function (a) { return a ? g(e, c, d, a) : null }) : [g(e, c, d, h)]; return k ? a(j(c, null, i)) : i }, tmplitem: function (b) { var c; if (b instanceof a) b = b[0]; while (b && b.nodetype === 1 && !(c = a.data(b, "tmplitem")) && (b = b.parentnode)); return c || p }, template: function (c, b) { if (b) { if (typeof b === "string") b = o(b); else if (b instanceof a) b = b[0] || {}; if (b.nodetype) b = a.data(b, "tmpl") || a.data(b, "tmpl", o(b.innerhtml)); return typeof c === "string" ? (a.template[c] = b) : b } return c ? typeof c !== "string" ? a.template(null, c) : a.template[c] || a.template(null, q.test(c) ? c : a(c)) : null }, encode: function (a) { return ("" + a).split("<").join("<").split(">").join(">").split('"').join(""").split("'").join("'") } }); a.extend(a.tmpl, { tag: { tmpl: { _default: { $2: "null" }, open: "if($notnull_1){__=__.concat($item.nest($1,$2));}" }, wrap: { _default: { $2: "null" }, open: "$item.calls(__,$1,$2);__=[];", close: "call=$item.calls();__=call._.concat($item.wrap(call,__));" }, each: { _default: { $2: "$index, $value" }, open: "if($notnull_1){$.each($1a,function($2){with(this){", close: "}});}" }, "if": { open: "if(($notnull_1) && $1a){", close: "}" }, "else": { _default: { $1: "true" }, open: "}else if(($notnull_1) && $1a){" }, html: { open: "if($notnull_1){__.push($1a);}" }, "=": { _default: { $1: "$data" }, open: "if($notnull_1){__.push($.encode($1a));}" }, "!": { open: "" } }, complete: function () { b = {} }, aftermanip: function (f, b, d) { var e = b.nodetype === 11 ? a.makearray(b.childnodes) : b.nodetype === 1 ? [b] : []; d.call(f, b); m(e); c++ } }); function j(e, g, f) { var b, c = f ? a.map(f, function (a) { return typeof a === "string" ? e.key ? a.replace(/(<\w+)(?=[\s>])(?![^>]*_tmplitem)([^>]*)/g, "$1 " + d + '="' + e.key + '" $2') : a : j(a, e, a._ctnt) }) : e; if (g) return c; c = c.join(""); c.replace(/^\s*([^<\s][^<]*)?(<[\w\w]+>)([^>]*[^>\s])?\s*$/, function (f, c, e, d) { b = a(e).get(); m(b); if (c) b = k(c).concat(b); if (d) b = b.concat(k(d)) }); return b ? b : k(c) } function k(c) { var b = document.createelement("div"); b.innerhtml = c; return a.makearray(b.childnodes) } function o(b) { return new function("jquery", "$item", "var $=jquery,call,__=[],$data=$item.data;with($data){__.push('" + a.trim(b).replace(/([\\'])/g, "\\$1").replace(/[\r\t\n]/g, " ").replace(/\$\{([^\}]*)\}/g, "{{= $1}}").replace(/\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g, function (m, l, k, g, b, c, d) { var j = a.tmpl.tag[k], i, e, f; if (!j) throw "unknown template tag: " + k; i = j._default || []; if (c && !/\w$/.test(b)) { b += c; c = "" } if (b) { b = h(b); d = d ? "," + h(d) + ")" : c ? ")" : ""; e = c ? b.indexof(".") > -1 ? b + h(c) : "(" + b + ").call($item" + d : b; f = c ? e : "(typeof(" + b + ")==='function'?(" + b + ").call($item):(" + b + "))" } else f = e = i.$1 || "null"; g = h(g); return "');" + j[l ? "close" : "open"].split("$notnull_1").join(b ? "typeof(" + b + ")!=='undefined' && (" + b + ")!=null" : "true").split("$1a").join(f).split("$1").join(e).split("$2").join(g || i.$2 || "") + "__.push('" }) + "');}return __;") } function n(c, b) { c._wrap = j(c, true, a.isarray(b) ? b : [q.test(b) ? b : a(b).html()]).join("") } function h(a) { return a ? a.replace(/\\'/g, "'").replace(/\\\\/g, "\\") : null } function s(b) { var a = document.createelement("div"); a.appendchild(b.clonenode(true)); return a.innerhtml } function m(o) { var n = "_" + c, k, j, l = {}, e, p, h; for (e = 0, p = o.length; e < p; e++) { if ((k = o[e]).nodetype !== 1) continue; j = k.getelementsbytagname("*"); for (h = j.length - 1; h >= 0; h--) m(j[h]); m(k) } function m(j) { var p, h = j, k, e, m; if (m = j.getattribute(d)) { while (h.parentnode && (h = h.parentnode).nodetype === 1 && !(p = h.getattribute(d))); if (p !== m) { h = h.parentnode ? h.nodetype === 11 ? 0 : h.getattribute(d) || 0 : 0; if (!(e = b[m])) { e = f[m]; e = g(e, b[h] || f[h]); e.key = ++i; b[i] = e } c && o(m) } j.removeattribute(d) } else if (c && (e = a.data(j, "tmplitem"))) { o(e.key); b[e.key] = e; h = a.data(j.parentnode, "tmplitem"); h = h ? h.key : 0 } if (e) { k = e; while (k && k.key != h) { k.nodes.push(j); k = k.parent } delete e._ctnt; delete e._wrap; a.data(j, "tmplitem", e) } function o(a) { a = a + n; e = l[a] = l[a] || g(e, b[e.parent.key + n] || e.parent) } } } function u(a, d, c, b) { if (!a) return l.pop(); l.push({ _: a, tmpl: d, item: this, data: c, options: b }) } function w(d, c, b) { return a.tmpl(a.template(d), c, b, this) } function x(b, d) { var c = b.options || {}; c.wrapped = d; return a.tmpl(a.template(b.tmpl), b.data, c, b.item) } function v(d, c) { var b = this._wrap; return a.map(a(a.isarray(b) ? b.join("") : b).filter(d || "*"), function (a) { return c ? a.innertext || a.textcontent : a.outerhtml || s(a) }) } function t() { var b = this.nodes; a.tmpl(null, null, null, this).insertbefore(b[0]); a(b).remove() } })(jquery); //�첽����ģ���� ; (function ($) { $.extend({ tmpl_data: function (te, data, fun, templatecache) { data = jquery.extend({ data: "", url: "", templatedata: {}, remote: true, cache: true }, data); if (!data.remote) { fun(te.tmpl(data.templatedata), te, data.templatedata); if (!templatecache) { te.remove(); } return; } var da = te.data("objdata"); if (data.cache && da != null && da != undefined) { fun(te.tmpl(da), te, da); if (!templatecache) { te.remove(); } return; } $.ajax({ type: "get", data: data.data, url: data.url, datatype: "json", cache: false, context: { template: te, data: data }, success: function (tmpldata) { fun(this.template.tmpl(tmpldata), this.template, tmpldata); if (data.cache) { this.template.data("objdata", tmpldata); } if (!templatecache) { this.template.remove(); } }, error: function (e) { throw "get data error(" + this.data.url + "?" + this.data.data + "):" + e; } }); }, jqueryselecotrcharchange: function (str) { return str.replace(".", "\\.").replace("#", "\\#"); }, tmpl: function (template, data, fun) { template = jquery.extend({ data: "", url: "", templateselector: "", remote: true, cache: true }, template); if (!template.remote) { $.tmpl_data($(template.templateselector), data, fun, true); return; } var te = null; try { te = $("script:[url='" + $.jqueryselecotrcharchange(template.url + "?" + template.data) + "']") } catch (e) { } if (template.cache && te != null && te.length > 0) { $.tmpl_data(te, data, fun, template.cache); return; } $.ajax({ type: "get", data: template.data, url: template.url, datatype: "html", cache: false, context: { template: template, data: data }, error: function (e) { throw "get template error(" + this.template.url + "?" + this.template.data + "):" + e; }, success: function (tmpltemplate) { var te = $('