From 02d7f1c1471395bd24ade2568cf0dfc654bfbc54 Mon Sep 17 00:00:00 2001 From: Paul Burgess Date: Fri, 23 Aug 2013 21:40:45 +0100 Subject: [PATCH 01/71] Added a prepend option Added prepend option. Append takes priority over prepend --- Examples/index.html | 2 +- jquery-loadTemplate/jquery.loadTemplate-1.0.0.min.js | 1 - ....loadTemplate-1.0.0.js => jquery.loadTemplate-1.1.0.js} | 7 +++++-- jquery-loadTemplate/jquery.loadTemplate-1.1.0.min.js | 1 + loadTemplate.jquery.json | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) delete mode 100644 jquery-loadTemplate/jquery.loadTemplate-1.0.0.min.js rename jquery-loadTemplate/{jquery.loadTemplate-1.0.0.js => jquery.loadTemplate-1.1.0.js} (98%) create mode 100644 jquery-loadTemplate/jquery.loadTemplate-1.1.0.min.js diff --git a/Examples/index.html b/Examples/index.html index 72df701..3a6317c 100644 --- a/Examples/index.html +++ b/Examples/index.html @@ -10,7 +10,7 @@ - +
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.0.0.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.0.0.min.js deleted file mode 100644 index 25c294a..0000000 --- a/jquery-loadTemplate/jquery.loadTemplate-1.0.0.min.js +++ /dev/null @@ -1 +0,0 @@ -(function (e) { "use strict"; function i(n, r, i) { var s = this, h, p, d; r = r || {}; p = e.extend({ overwriteCache: false, complete: null, success: null, error: function () { e(this).each(function () { e(this).html(p.errorMessage) }) }, errorMessage: "There was an error loading the template.", paged: false, pageNo: 1, elemPerPage: 10, append: false }, i); if (e.type(r) === "array") { return u.call(this, n, r, p) } if (!o(n)) { h = e(n) } d = p.isFile || typeof p.isFile === "undefined" && (typeof h === "undefined" || h.length === 0); if (d && !p.overwriteCache && t[n]) { f(n, s, r, p) } else if (d && !p.overwriteCache && t.hasOwnProperty(n)) { a(n, s, r, p) } else if (d) { l(n, s, r, p) } else { c(h, s, r, p) } return this } function s(t, n) { if (n) { r[t] = n } else { r = e.extend(r, t) } } function o(e) { return typeof e === "string" && e.indexOf("/") > -1 } function u(t, n, r) { var s = this, o = n.length, u = 0, a; r = r || {}; if (r.paged) { var f = (r.pageNo - 1) * r.elemPerPage; n = n.slice(f, f + r.elemPerPage) } a = e.extend({}, r, { complete: function () { s.append(this.html()); u++; if (u === o) { if (r && typeof r.complete === "function") { r.complete() } } } }); if (!r.append) { s.html("") } e(n).each(function () { var n = e("
"); i.call(n, t, this, a) }); return this } function a(e, t, r, i) { if (n[e]) { n[e].push({ data: r, selection: t, settings: i }) } else { n[e] = [{ data: r, selection: t, settings: i }] } } function f(e, n, r, i) { var s = t[e].clone(); h.call(n, s, r, i); if (typeof i.success === "function") { i.success() } } function l(n, r, i, s) { var o = e("
"); t[n] = null; o.load(n, function (e, t) { if (t === "error") { p(n, r, i, s) } else { d(o, n, r, i, s) } }) } function c(t, n, r, i) { var s = e("
"); if (t.is("script")) { t = e.parseHTML(e.trim(t.html())) } s.html(t); h.call(n, s, r, i); if (typeof i.success === "function") { i.success() } } function h(t, n, r) { v(t, n); e(this).each(function () { if (r.append) { e(this).append(t.html()) } else { e(this).html(t.html()) } }); if (typeof r.complete === "function") { r.complete.call(e(this)) } } function p(t, r, i, s) { var o; if (typeof s.error === "function") { s.error.call(r) } e(n[t]).each(function (e, t) { if (typeof t.settings.error === "function") { t.settings.error.call(t.selection) } }); if (typeof s.complete === "function") { s.complete.call(r) } while (n[t] && (o = n[t].shift())) { if (typeof o.settings.complete === "function") { o.settings.complete.call(o.selection) } } if (typeof n[t] !== "undefined" && n[t].length > 0) { n[t] = [] } } function d(e, r, i, s, o) { var u; t[r] = e.clone(); h.call(i, e, s, o); if (typeof o.success === "function") { o.success.call(i) } while (n[r] && (u = n[r].shift())) { h.call(u.selection, t[r].clone(), u.data, u.settings); if (typeof u.settings.success === "function") { u.settings.success.call(u.selection) } } } function v(t, n) { n = n || {}; m("data-content", t, n, function (e, t) { e.html(w(e, t, "content")) }); m("data-content-append", t, n, function (e, t) { e.append(w(e, t, "content")) }); m("data-content-prepend", t, n, function (e, t) { e.prepend(w(e, t, "content")) }); m("data-src", t, n, function (e, t) { e.attr("src", w(e, t, "src")) }, function (e) { e.remove() }); m("data-alt", t, n, function (e, t) { e.attr("alt", w(e, t, "alt")) }); m("data-value", t, n, function (e, t) { e.val(w(e, t, "value")) }); m("data-link", t, n, function (t, n) { var r = e(""); r.attr("href", w(t, n, "link")); r.html(t.html()); t.html(r) }); m("data-link-wrap", t, n, function (t, n) { var r = e(""); r.attr("href", w(t, n, "link-wrap")); t.wrap(r) }); m("data-options", t, n, function (t, n) { e(n).each(function () { var n = e("
");m.call(D,B,this,y)});return this}function c(y,w,v,x){if(t[y]){t[y].push({data:v,selection:w,settings:x})}else{t[y]=[{data:v,selection:w,settings:x}]}}function p(z,x,w,y){var v=u[z].clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success()}}function l(z,x,w,y){var v=a("
");u[z]=null;v.load(z,function(A,B){if(B==="error"){j(z,x,w,y)}else{k(v,z,x,w,y)}})}function n(v,y,x,z){var w=a("
");if(v.is("script")){v=a.parseHTML(a.trim(v.html()))}w.html(v);o.call(y,w,x,z);if(typeof z.success==="function"){z.success()}}function o(x,v,w){f(x,v);a(this).each(function(){if(w.append){a(this).append(x.html())}else{if(w.prepend){a(this).prepend(x.html())}else{a(this).html(x.html())}}});if(typeof w.complete==="function"){w.complete.call(a(this))}}function j(y,w,v,x){var z;if(typeof x.error==="function"){x.error.call(w)}a(t[y]).each(function(A,B){if(typeof B.settings.error==="function"){B.settings.error.call(B.selection)}});if(typeof x.complete==="function"){x.complete.call(w)}while(t[y]&&(z=t[y].shift())){if(typeof z.settings.complete==="function"){z.settings.complete.call(z.selection)}}if(typeof t[y]!=="undefined"&&t[y].length>0){t[y]=[]}}function k(v,z,x,w,y){var A;u[z]=v.clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success.call(x)}while(t[z]&&(A=t[z].shift())){o.call(A.selection,u[z].clone(),A.data,A.settings);if(typeof A.settings.success==="function"){A.settings.success.call(A.selection)}}}function f(w,v){v=v||{};s("data-content",w,v,function(x,y){x.html(e(x,y,"content"))});s("data-content-append",w,v,function(x,y){x.append(e(x,y,"content"))});s("data-content-prepend",w,v,function(x,y){x.prepend(e(x,y,"content"))});s("data-src",w,v,function(x,y){x.attr("src",e(x,y,"src"))},function(x){x.remove()});s("data-alt",w,v,function(x,y){x.attr("alt",e(x,y,"alt"))});s("data-value",w,v,function(x,y){x.val(e(x,y,"value"))});s("data-link",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link"));y.html(x.html());x.html(y)});s("data-link-wrap",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link-wrap"));x.wrap(y)});s("data-options",w,v,function(x,y){a(y).each(function(){var z=a("
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.1.0.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.1.0.min.js deleted file mode 100644 index f1cb183..0000000 --- a/jquery-loadTemplate/jquery.loadTemplate-1.1.0.min.js +++ /dev/null @@ -1 +0,0 @@ -(function(a){var u={},t={},h={};function m(B,x,z){var w=this,v,A,y;x=x||{};A=a.extend({overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(A.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false},z);if(a.type(x)==="array"){return r.call(this,B,x,A)}if(!g(B)){v=a(B)}y=A.isFile||(typeof A.isFile==="undefined"&&(typeof v==="undefined"||v.length===0));if(y&&!A.overwriteCache&&u[B]){p(B,w,x,A)}else{if(y&&!A.overwriteCache&&u.hasOwnProperty(B)){c(B,w,x,A)}else{if(y){l(B,w,x,A)}else{n(v,w,x,A)}}}return this}function b(w,v){if(v){h[w]=v}else{h=a.extend(h,w)}}function g(v){return typeof v==="string"&&v.indexOf("/")>-1}function r(B,w,z){var v=this,C=w.length,x=0,y;z=z||{};if(z.paged){var A=(z.pageNo-1)*z.elemPerPage;w=w.slice(A,A+z.elemPerPage)}y=a.extend({},z,{complete:function(){v.append(this.html());x++;if(x===C){if(z&&typeof z.complete==="function"){z.complete()}}}});if(!z.append&&!z.prepend){v.html("")}a(w).each(function(){var D=a("
");m.call(D,B,this,y)});return this}function c(y,w,v,x){if(t[y]){t[y].push({data:v,selection:w,settings:x})}else{t[y]=[{data:v,selection:w,settings:x}]}}function p(z,x,w,y){var v=u[z].clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success()}}function l(z,x,w,y){var v=a("
");u[z]=null;v.load(z,function(A,B){if(B==="error"){j(z,x,w,y)}else{k(v,z,x,w,y)}})}function n(v,y,x,z){var w=a("
");if(v.is("script")){v=a.parseHTML(a.trim(v.html()))}w.html(v);o.call(y,w,x,z);if(typeof z.success==="function"){z.success()}}function o(x,v,w){f(x,v);a(this).each(function(){if(w.append){a(this).append(x.html())}else{if(w.prepend){a(this).prepend(x.html())}else{a(this).html(x.html())}}});if(typeof w.complete==="function"){w.complete.call(a(this))}}function j(y,w,v,x){var z;if(typeof x.error==="function"){x.error.call(w)}a(t[y]).each(function(A,B){if(typeof B.settings.error==="function"){B.settings.error.call(B.selection)}});if(typeof x.complete==="function"){x.complete.call(w)}while(t[y]&&(z=t[y].shift())){if(typeof z.settings.complete==="function"){z.settings.complete.call(z.selection)}}if(typeof t[y]!=="undefined"&&t[y].length>0){t[y]=[]}}function k(v,z,x,w,y){var A;u[z]=v.clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success.call(x)}while(t[z]&&(A=t[z].shift())){o.call(A.selection,u[z].clone(),A.data,A.settings);if(typeof A.settings.success==="function"){A.settings.success.call(A.selection)}}}function f(w,v){v=v||{};s("data-content",w,v,function(x,y){x.html(e(x,y,"content"))});s("data-content-append",w,v,function(x,y){x.append(e(x,y,"content"))});s("data-content-prepend",w,v,function(x,y){x.prepend(e(x,y,"content"))});s("data-src",w,v,function(x,y){x.attr("src",e(x,y,"src"))},function(x){x.remove()});s("data-alt",w,v,function(x,y){x.attr("alt",e(x,y,"alt"))});s("data-value",w,v,function(x,y){x.val(e(x,y,"value"))});s("data-link",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link"));y.html(x.html());x.html(y)});s("data-link-wrap",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link-wrap"));x.wrap(y)});s("data-options",w,v,function(x,y){a(y).each(function(){var z=a("
");m.call(D,B,this,y)});return this}function c(y,w,v,x){if(t[y]){t[y].push({data:v,selection:w,settings:x})}else{t[y]=[{data:v,selection:w,settings:x}]}}function p(z,x,w,y){var v=u[z].clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success()}}function l(z,x,w,y){var v=a("
");u[z]=null;v.load(z,function(A,B){if(B==="error"){j(z,x,w,y)}else{k(v,z,x,w,y)}})}function n(v,y,x,z){var w=a("
");if(v.is("script")){v=a.parseHTML(a.trim(v.html()))}w.html(v);o.call(y,w,x,z);if(typeof z.success==="function"){z.success()}}function o(x,v,w){f(x,v);a(this).each(function(){var y=a(x.html());if(w.beforeInsert){w.beforeInsert(y)}if(w.append){a(this).append(y)}else{if(w.prepend){a(this).prepend(y)}else{a(this).html(y)}}if(w.afterInsert){w.afterInsert(y)}});if(typeof w.complete==="function"){w.complete.call(a(this))}}function j(y,w,v,x){var z;if(typeof x.error==="function"){x.error.call(w)}a(t[y]).each(function(A,B){if(typeof B.settings.error==="function"){B.settings.error.call(B.selection)}});if(typeof x.complete==="function"){x.complete.call(w)}while(t[y]&&(z=t[y].shift())){if(typeof z.settings.complete==="function"){z.settings.complete.call(z.selection)}}if(typeof t[y]!=="undefined"&&t[y].length>0){t[y]=[]}}function k(v,z,x,w,y){var A;u[z]=v.clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success.call(x)}while(t[z]&&(A=t[z].shift())){o.call(A.selection,u[z].clone(),A.data,A.settings);if(typeof A.settings.success==="function"){A.settings.success.call(A.selection)}}}function f(w,v){v=v||{};s("data-content",w,v,function(x,y){x.html(e(x,y,"content"))});s("data-content-append",w,v,function(x,y){x.append(e(x,y,"content"))});s("data-content-prepend",w,v,function(x,y){x.prepend(e(x,y,"content"))});s("data-src",w,v,function(x,y){x.attr("src",e(x,y,"src"))},function(x){x.remove()});s("data-alt",w,v,function(x,y){x.attr("alt",e(x,y,"alt"))});s("data-value",w,v,function(x,y){x.val(e(x,y,"value"))});s("data-link",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link"));y.html(x.html());x.html(y)});s("data-link-wrap",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link-wrap"));x.wrap(y)});s("data-options",w,v,function(x,y){a(y).each(function(){var z=a("
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.2.0.js b/jquery-loadTemplate/jquery.loadTemplate-1.2.1.js similarity index 96% rename from jquery-loadTemplate/jquery.loadTemplate-1.2.0.js rename to jquery-loadTemplate/jquery.loadTemplate-1.2.1.js index ba75295..676c5ac 100644 --- a/jquery-loadTemplate/jquery.loadTemplate-1.2.0.js +++ b/jquery-loadTemplate/jquery.loadTemplate-1.2.1.js @@ -311,32 +311,32 @@ if (typeof value !== "undefined" && this.attribute) { switch (this.attribute) { case "content": - $this.html(applyDataBindFormatters(value, this)); + $this.html(applyDataBindFormatters($this, value, this)); break; case "contentAppend": - $this.append(applyDataBindFormatters(value, this)); + $this.append(applyDataBindFormatters($this, value, this)); break; case "contentPrepend": - $this.prepend(applyDataBindFormatters(value, this)); + $this.prepend(applyDataBindFormatters($this, value, this)); break; case "options": var optionsData = this; $(value).each(function () { var $option = $("
");m.call(D,B,this,y)});return this}function c(y,w,v,x){if(t[y]){t[y].push({data:v,selection:w,settings:x})}else{t[y]=[{data:v,selection:w,settings:x}]}}function p(z,x,w,y){var v=u[z].clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success()}}function l(z,x,w,y){var v=a("
");u[z]=null;v.load(z,function(A,B){if(B==="error"){j(z,x,w,y)}else{k(v,z,x,w,y)}})}function n(v,y,x,z){var w=a("
");if(v.is("script")){v=a.parseHTML(a.trim(v.html()))}w.html(v);o.call(y,w,x,z);if(typeof z.success==="function"){z.success()}}function o(x,v,w){f(x,v);a(this).each(function(){var y=a(x.html());if(w.beforeInsert){w.beforeInsert(y)}if(w.append){a(this).append(y)}else{if(w.prepend){a(this).prepend(y)}else{a(this).html(y)}}if(w.afterInsert){w.afterInsert(y)}});if(typeof w.complete==="function"){w.complete.call(a(this))}}function j(y,w,v,x){var z;if(typeof x.error==="function"){x.error.call(w)}a(t[y]).each(function(A,B){if(typeof B.settings.error==="function"){B.settings.error.call(B.selection)}});if(typeof x.complete==="function"){x.complete.call(w)}while(t[y]&&(z=t[y].shift())){if(typeof z.settings.complete==="function"){z.settings.complete.call(z.selection)}}if(typeof t[y]!=="undefined"&&t[y].length>0){t[y]=[]}}function k(v,z,x,w,y){var A;u[z]=v.clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success.call(x)}while(t[z]&&(A=t[z].shift())){o.call(A.selection,u[z].clone(),A.data,A.settings);if(typeof A.settings.success==="function"){A.settings.success.call(A.selection)}}}function f(w,v){v=v||{};s("data-content",w,v,function(x,y){x.html(e(x,y,"content"))});s("data-content-append",w,v,function(x,y){x.append(e(x,y,"content"))});s("data-content-prepend",w,v,function(x,y){x.prepend(e(x,y,"content"))});s("data-src",w,v,function(x,y){x.attr("src",e(x,y,"src"))},function(x){x.remove()});s("data-alt",w,v,function(x,y){x.attr("alt",e(x,y,"alt"))});s("data-value",w,v,function(x,y){x.val(e(x,y,"value"))});s("data-link",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link"));y.html(x.html());x.html(y)});s("data-link-wrap",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link-wrap"));x.wrap(y)});s("data-options",w,v,function(x,y){a(y).each(function(){var z=a("
");m.call(D,B,this,y)});return this}function c(y,w,v,x){if(t[y]){t[y].push({data:v,selection:w,settings:x})}else{t[y]=[{data:v,selection:w,settings:x}]}}function p(z,x,w,y){var v=u[z].clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success()}}function l(z,x,w,y){var v=a("
");u[z]=null;v.load(z,function(A,B){if(B==="error"){j(z,x,w,y)}else{k(v,z,x,w,y)}})}function n(v,y,x,z){var w=a("
");if(v.is("script")){v=a.parseHTML(a.trim(v.html()))}w.html(v);o.call(y,w,x,z);if(typeof z.success==="function"){z.success()}}function o(x,v,w){f(x,v);a(this).each(function(){var y=a(x.html());if(w.beforeInsert){w.beforeInsert(y)}if(w.append){a(this).append(y)}else{if(w.prepend){a(this).prepend(y)}else{a(this).html(y)}}if(w.afterInsert){w.afterInsert(y)}});if(typeof w.complete==="function"){w.complete.call(a(this))}}function j(y,w,v,x){var z;if(typeof x.error==="function"){x.error.call(w)}a(t[y]).each(function(A,B){if(typeof B.settings.error==="function"){B.settings.error.call(B.selection)}});if(typeof x.complete==="function"){x.complete.call(w)}while(t[y]&&(z=t[y].shift())){if(typeof z.settings.complete==="function"){z.settings.complete.call(z.selection)}}if(typeof t[y]!=="undefined"&&t[y].length>0){t[y]=[]}}function k(v,z,x,w,y){var A;u[z]=v.clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success.call(x)}while(t[z]&&(A=t[z].shift())){o.call(A.selection,u[z].clone(),A.data,A.settings);if(typeof A.settings.success==="function"){A.settings.success.call(A.selection)}}}function f(w,v){v=v||{};s("data-content",w,v,function(x,y){x.html(e(x,y,"content"))});s("data-content-append",w,v,function(x,y){x.append(e(x,y,"content"))});s("data-content-prepend",w,v,function(x,y){x.prepend(e(x,y,"content"))});s("data-src",w,v,function(x,y){x.attr("src",e(x,y,"src"))},function(x){x.remove()});s("data-alt",w,v,function(x,y){x.attr("alt",e(x,y,"alt"))});s("data-value",w,v,function(x,y){x.val(e(x,y,"value"))});s("data-link",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link"));y.html(x.html());x.html(y)});s("data-link-wrap",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link-wrap"));x.wrap(y)});s("data-options",w,v,function(x,y){a(y).each(function(){var z=a("
"); loadTemplate.call($div, template, this, newOptions); From f26f54672e53c6d82b1993d4b9fc90872abc7ab0 Mon Sep 17 00:00:00 2001 From: mamod Date: Tue, 3 Sep 2013 19:12:41 +0300 Subject: [PATCH 07/71] examples minor fixes 1- updated jQuery version 2- Fixed mixed tabs with space indentation 3- Fix absolute links -> to work when running from non root location --- Examples/ExampleSearchResults/search.html | 8 ++- Examples/SimpleExample/Templates/simple.html | 9 +-- Examples/SimpleExample/example.html | 60 ++++++++++---------- Examples/index.html | 5 +- 4 files changed, 41 insertions(+), 41 deletions(-) diff --git a/Examples/ExampleSearchResults/search.html b/Examples/ExampleSearchResults/search.html index 36a5cb3..ccd94d1 100644 --- a/Examples/ExampleSearchResults/search.html +++ b/Examples/ExampleSearchResults/search.html @@ -24,10 +24,12 @@

Example of using jQuery.loadTemplate for improved search.

+
+ \ No newline at end of file + }); + diff --git a/Examples/index.html b/Examples/index.html index 371e425..f10ebdb 100644 --- a/Examples/index.html +++ b/Examples/index.html @@ -1,5 +1,4 @@ - @@ -9,7 +8,7 @@ - + @@ -68,7 +67,6 @@

Code

} function highlightSupported() { var ver = getInternetExplorerVersion(); - if (ver > -1) { if (ver < 9) { return false; @@ -78,7 +76,6 @@

Code

} $("a").click(function (e) { e.preventDefault(); - var $div = $("
"); $($div).load($(this).attr("href"), function () { $(".contentContainer > div").hide(); From 59427783270bcfbd01ece7d23f1e59716745d141 Mon Sep 17 00:00:00 2001 From: Paul Burgess Date: Wed, 18 Sep 2013 20:43:10 +0100 Subject: [PATCH 08/71] Updated error/success for arrays Error and Success callbacks now only fire at the end of the processing of an array. --- Examples/ExampleSearchResults/search.html | 2 +- Examples/index.html | 2 +- ...-1.2.1.js => jquery.loadTemplate-1.2.2.js} | 19 ++++++++++++++++++- ...in.js => jquery.loadTemplate-1.2.2.min.js} | 2 +- loadTemplate.jquery.json | 2 +- 5 files changed, 22 insertions(+), 5 deletions(-) rename jquery-loadTemplate/{jquery.loadTemplate-1.2.1.js => jquery.loadTemplate-1.2.2.js} (94%) rename jquery-loadTemplate/{jquery.loadTemplate-1.2.1.min.js => jquery.loadTemplate-1.2.2.min.js} (87%) diff --git a/Examples/ExampleSearchResults/search.html b/Examples/ExampleSearchResults/search.html index ccd94d1..f1c2f13 100644 --- a/Examples/ExampleSearchResults/search.html +++ b/Examples/ExampleSearchResults/search.html @@ -71,7 +71,7 @@

Example of using jQuery.loadTemplate for improved search.

}); function displayPage(pageNo) { - $("#ResultsDisplay tbody").loadTemplate("ExampleSearchResults/Templates/SearchResult.html", data, {paged: true, pageNo: pageNo, elemPerPage: resultsPerPage}); + $("#ResultsDisplay tbody").loadTemplate("ExampleSearchResults/Templates/SearchResult.html", data, {paged: true, pageNo: pageNo, elemPerPage: resultsPerPage, success: function() {console.log('success');}, complete: function(){console.log('complete')}, error: function(){console.log('error');}}); page = pageNo; if (page * resultsPerPage > data.length) { $("[data-action='next']").attr('disabled', 'disabled'); diff --git a/Examples/index.html b/Examples/index.html index f10ebdb..be897d3 100644 --- a/Examples/index.html +++ b/Examples/index.html @@ -9,7 +9,7 @@ - +
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.2.1.js b/jquery-loadTemplate/jquery.loadTemplate-1.2.2.js similarity index 94% rename from jquery-loadTemplate/jquery.loadTemplate-1.2.1.js rename to jquery-loadTemplate/jquery.loadTemplate-1.2.2.js index 86ba965..18e12a7 100644 --- a/jquery-loadTemplate/jquery.loadTemplate-1.2.1.js +++ b/jquery-loadTemplate/jquery.loadTemplate-1.2.2.js @@ -72,11 +72,14 @@ todo = data.length, doPrepend = settings.prepend && !settings.append, done = 0, + success = 0, + errored = false, newOptions; if (settings.paged) { var startNo = (settings.pageNo - 1) * settings.elemPerPage; data = data.slice(startNo, startNo + settings.elemPerPage); + todo = data.length; } newOptions = $.extend( @@ -84,17 +87,31 @@ settings, { complete: function () { - if (doPrepend){ + if (doPrepend) { $that.prepend(this.html()); } else { $that.append(this.html()); } done++; if (done === todo) { + if (errored && settings && typeof settings.error === "function") { + settings.error(); + } if (settings && typeof settings.complete === "function") { settings.complete(); } } + }, + success: function () { + success++; + if (success === todo) { + if (settings && typeof settings.success === "function") { + settings.success(); + } + } + }, + error: function () { + errored = true; } } ); diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.2.1.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.2.2.min.js similarity index 87% rename from jquery-loadTemplate/jquery.loadTemplate-1.2.1.min.js rename to jquery-loadTemplate/jquery.loadTemplate-1.2.2.min.js index 1caf7d4..8bb7888 100644 --- a/jquery-loadTemplate/jquery.loadTemplate-1.2.1.min.js +++ b/jquery-loadTemplate/jquery.loadTemplate-1.2.2.min.js @@ -1 +1 @@ -(function(a){var u={},t={},h={};function m(B,x,z){var w=this,v,A,y;x=x||{};A=a.extend({overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(A.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null},z);if(a.type(x)==="array"){return r.call(this,B,x,A)}if(!g(B)){v=a(B)}y=A.isFile||(typeof A.isFile==="undefined"&&(typeof v==="undefined"||v.length===0));if(y&&!A.overwriteCache&&u[B]){p(B,w,x,A)}else{if(y&&!A.overwriteCache&&u.hasOwnProperty(B)){c(B,w,x,A)}else{if(y){l(B,w,x,A)}else{n(v,w,x,A)}}}return this}function b(w,v){if(v){h[w]=v}else{h=a.extend(h,w)}}function g(v){return typeof v==="string"&&v.indexOf("/")>-1}function r(B,w,z){var v=this,C=w.length,x=0,y;z=z||{};if(z.paged){var A=(z.pageNo-1)*z.elemPerPage;w=w.slice(A,A+z.elemPerPage)}y=a.extend({},z,{complete:function(){v.append(this.html());x++;if(x===C){if(z&&typeof z.complete==="function"){z.complete()}}}});if(!z.append&&!z.prepend){v.html("")}a(w).each(function(){var D=a("
");m.call(D,B,this,y)});return this}function c(y,w,v,x){if(t[y]){t[y].push({data:v,selection:w,settings:x})}else{t[y]=[{data:v,selection:w,settings:x}]}}function p(z,x,w,y){var v=u[z].clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success()}}function l(z,x,w,y){var v=a("
");u[z]=null;v.load(z,function(A,B){if(B==="error"){j(z,x,w,y)}else{k(v,z,x,w,y)}})}function n(v,y,x,z){var w=a("
");if(v.is("script")){v=a.parseHTML(a.trim(v.html()))}w.html(v);o.call(y,w,x,z);if(typeof z.success==="function"){z.success()}}function o(x,v,w){f(x,v);a(this).each(function(){var y=a(x.html());if(w.beforeInsert){w.beforeInsert(y)}if(w.append){a(this).append(y)}else{if(w.prepend){a(this).prepend(y)}else{a(this).html(y)}}if(w.afterInsert){w.afterInsert(y)}});if(typeof w.complete==="function"){w.complete.call(a(this))}}function j(y,w,v,x){var z;if(typeof x.error==="function"){x.error.call(w)}a(t[y]).each(function(A,B){if(typeof B.settings.error==="function"){B.settings.error.call(B.selection)}});if(typeof x.complete==="function"){x.complete.call(w)}while(t[y]&&(z=t[y].shift())){if(typeof z.settings.complete==="function"){z.settings.complete.call(z.selection)}}if(typeof t[y]!=="undefined"&&t[y].length>0){t[y]=[]}}function k(v,z,x,w,y){var A;u[z]=v.clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success.call(x)}while(t[z]&&(A=t[z].shift())){o.call(A.selection,u[z].clone(),A.data,A.settings);if(typeof A.settings.success==="function"){A.settings.success.call(A.selection)}}}function f(w,v){v=v||{};s("data-content",w,v,function(x,y){x.html(e(x,y,"content"))});s("data-content-append",w,v,function(x,y){x.append(e(x,y,"content"))});s("data-content-prepend",w,v,function(x,y){x.prepend(e(x,y,"content"))});s("data-src",w,v,function(x,y){x.attr("src",e(x,y,"src"))},function(x){x.remove()});s("data-alt",w,v,function(x,y){x.attr("alt",e(x,y,"alt"))});s("data-value",w,v,function(x,y){x.val(e(x,y,"value"))});s("data-link",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link"));y.html(x.html());x.html(y)});s("data-link-wrap",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link-wrap"));x.wrap(y)});s("data-options",w,v,function(x,y){a(y).each(function(){var z=a("
");m.call(G,E,this,A)});return this}function c(y,w,v,x){if(t[y]){t[y].push({data:v,selection:w,settings:x})}else{t[y]=[{data:v,selection:w,settings:x}]}}function p(z,x,w,y){var v=u[z].clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success()}}function l(z,x,w,y){var v=a("
");u[z]=null;v.load(z,function(A,B){if(B==="error"){j(z,x,w,y)}else{k(v,z,x,w,y)}})}function n(v,y,x,z){var w=a("
");if(v.is("script")){v=a.parseHTML(a.trim(v.html()))}w.html(v);o.call(y,w,x,z);if(typeof z.success==="function"){z.success()}}function o(x,v,w){f(x,v);a(this).each(function(){var y=a(x.html());if(w.beforeInsert){w.beforeInsert(y)}if(w.append){a(this).append(y)}else{if(w.prepend){a(this).prepend(y)}else{a(this).html(y)}}if(w.afterInsert){w.afterInsert(y)}});if(typeof w.complete==="function"){w.complete.call(a(this))}}function j(y,w,v,x){var z;if(typeof x.error==="function"){x.error.call(w)}a(t[y]).each(function(A,B){if(typeof B.settings.error==="function"){B.settings.error.call(B.selection)}});if(typeof x.complete==="function"){x.complete.call(w)}while(t[y]&&(z=t[y].shift())){if(typeof z.settings.complete==="function"){z.settings.complete.call(z.selection)}}if(typeof t[y]!=="undefined"&&t[y].length>0){t[y]=[]}}function k(v,z,x,w,y){var A;u[z]=v.clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success.call(x)}while(t[z]&&(A=t[z].shift())){o.call(A.selection,u[z].clone(),A.data,A.settings);if(typeof A.settings.success==="function"){A.settings.success.call(A.selection)}}}function f(w,v){v=v||{};s("data-content",w,v,function(x,y){x.html(e(x,y,"content"))});s("data-content-append",w,v,function(x,y){x.append(e(x,y,"content"))});s("data-content-prepend",w,v,function(x,y){x.prepend(e(x,y,"content"))});s("data-src",w,v,function(x,y){x.attr("src",e(x,y,"src"))},function(x){x.remove()});s("data-alt",w,v,function(x,y){x.attr("alt",e(x,y,"alt"))});s("data-value",w,v,function(x,y){x.val(e(x,y,"value"))});s("data-link",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link"));y.html(x.html());x.html(y)});s("data-link-wrap",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link-wrap"));x.wrap(y)});s("data-options",w,v,function(x,y){a(y).each(function(){var z=a("
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.2.2.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.2.2.min.js deleted file mode 100644 index 8bb7888..0000000 --- a/jquery-loadTemplate/jquery.loadTemplate-1.2.2.min.js +++ /dev/null @@ -1 +0,0 @@ -(function(a){var u={},t={},h={};function m(B,x,z){var w=this,v,A,y;x=x||{};A=a.extend({overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(A.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null},z);if(a.type(x)==="array"){return r.call(this,B,x,A)}if(!g(B)){v=a(B)}y=A.isFile||(typeof A.isFile==="undefined"&&(typeof v==="undefined"||v.length===0));if(y&&!A.overwriteCache&&u[B]){p(B,w,x,A)}else{if(y&&!A.overwriteCache&&u.hasOwnProperty(B)){c(B,w,x,A)}else{if(y){l(B,w,x,A)}else{n(v,w,x,A)}}}return this}function b(w,v){if(v){h[w]=v}else{h=a.extend(h,w)}}function g(v){return typeof v==="string"&&v.indexOf("/")>-1}function r(E,w,B){B=B||{};var v=this,F=w.length,y=B.prepend&&!B.append,x=0,D=0,z=false,A;if(B.paged){var C=(B.pageNo-1)*B.elemPerPage;w=w.slice(C,C+B.elemPerPage);F=w.length}A=a.extend({},B,{complete:function(){if(y){v.prepend(this.html())}else{v.append(this.html())}x++;if(x===F){if(z&&B&&typeof B.error==="function"){B.error()}if(B&&typeof B.complete==="function"){B.complete()}}},success:function(){D++;if(D===F){if(B&&typeof B.success==="function"){B.success()}}},error:function(){z=true}});if(!B.append&&!B.prepend){v.html("")}if(y){w.reverse()}a(w).each(function(){var G=a("
");m.call(G,E,this,A)});return this}function c(y,w,v,x){if(t[y]){t[y].push({data:v,selection:w,settings:x})}else{t[y]=[{data:v,selection:w,settings:x}]}}function p(z,x,w,y){var v=u[z].clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success()}}function l(z,x,w,y){var v=a("
");u[z]=null;v.load(z,function(A,B){if(B==="error"){j(z,x,w,y)}else{k(v,z,x,w,y)}})}function n(v,y,x,z){var w=a("
");if(v.is("script")){v=a.parseHTML(a.trim(v.html()))}w.html(v);o.call(y,w,x,z);if(typeof z.success==="function"){z.success()}}function o(x,v,w){f(x,v);a(this).each(function(){var y=a(x.html());if(w.beforeInsert){w.beforeInsert(y)}if(w.append){a(this).append(y)}else{if(w.prepend){a(this).prepend(y)}else{a(this).html(y)}}if(w.afterInsert){w.afterInsert(y)}});if(typeof w.complete==="function"){w.complete.call(a(this))}}function j(y,w,v,x){var z;if(typeof x.error==="function"){x.error.call(w)}a(t[y]).each(function(A,B){if(typeof B.settings.error==="function"){B.settings.error.call(B.selection)}});if(typeof x.complete==="function"){x.complete.call(w)}while(t[y]&&(z=t[y].shift())){if(typeof z.settings.complete==="function"){z.settings.complete.call(z.selection)}}if(typeof t[y]!=="undefined"&&t[y].length>0){t[y]=[]}}function k(v,z,x,w,y){var A;u[z]=v.clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success.call(x)}while(t[z]&&(A=t[z].shift())){o.call(A.selection,u[z].clone(),A.data,A.settings);if(typeof A.settings.success==="function"){A.settings.success.call(A.selection)}}}function f(w,v){v=v||{};s("data-content",w,v,function(x,y){x.html(e(x,y,"content"))});s("data-content-append",w,v,function(x,y){x.append(e(x,y,"content"))});s("data-content-prepend",w,v,function(x,y){x.prepend(e(x,y,"content"))});s("data-src",w,v,function(x,y){x.attr("src",e(x,y,"src"))},function(x){x.remove()});s("data-alt",w,v,function(x,y){x.attr("alt",e(x,y,"alt"))});s("data-value",w,v,function(x,y){x.val(e(x,y,"value"))});s("data-link",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link"));y.html(x.html());x.html(y)});s("data-link-wrap",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link-wrap"));x.wrap(y)});s("data-options",w,v,function(x,y){a(y).each(function(){var z=a("
");m.call(G,E,this,A)});return this}function c(y,w,v,x){if(t[y]){t[y].push({data:v,selection:w,settings:x})}else{t[y]=[{data:v,selection:w,settings:x}]}}function p(z,x,w,y){var v=u[z].clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success()}}function l(z,x,w,y){var v=a("
");u[z]=null;v.load(z,function(A,B){if(B==="error"){j(z,x,w,y)}else{k(v,z,x,w,y)}})}function n(v,y,x,z){var w=a("
");if(v.is("script")){v=a.parseHTML(a.trim(v.html()))}w.html(v);o.call(y,w,x,z);if(typeof z.success==="function"){z.success()}}function o(x,v,w){f(x,v);a(this).each(function(){var y=a(x.html());if(w.beforeInsert){w.beforeInsert(y)}if(w.append){a(this).append(y)}else{if(w.prepend){a(this).prepend(y)}else{a(this).html(y)}}if(w.afterInsert){w.afterInsert(y)}});if(typeof w.complete==="function"){w.complete.call(a(this))}}function j(y,w,v,x){var z;if(typeof x.error==="function"){x.error.call(w)}a(t[y]).each(function(A,B){if(typeof B.settings.error==="function"){B.settings.error.call(B.selection)}});if(typeof x.complete==="function"){x.complete.call(w)}while(t[y]&&(z=t[y].shift())){if(typeof z.settings.complete==="function"){z.settings.complete.call(z.selection)}}if(typeof t[y]!=="undefined"&&t[y].length>0){t[y]=[]}}function k(v,z,x,w,y){var A;u[z]=v.clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success.call(x)}while(t[z]&&(A=t[z].shift())){o.call(A.selection,u[z].clone(),A.data,A.settings);if(typeof A.settings.success==="function"){A.settings.success.call(A.selection)}}}function f(w,v){v=v||{};s("data-content",w,v,function(x,y){x.html(e(x,y,"content"))});s("data-content-append",w,v,function(x,y){x.append(e(x,y,"content"))});s("data-content-prepend",w,v,function(x,y){x.prepend(e(x,y,"content"))});s("data-src",w,v,function(x,y){x.attr("src",e(x,y,"src"))},function(x){x.remove()});s("data-alt",w,v,function(x,y){x.attr("alt",e(x,y,"alt"))});s("data-value",w,v,function(x,y){x.val(e(x,y,"value"))});s("data-link",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link"));y.html(x.html());x.html(y)});s("data-link-wrap",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link-wrap"));x.wrap(y)});s("data-options",w,v,function(x,y){a(y).each(function(){var z=a("
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.2.3.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.2.3.min.js deleted file mode 100644 index 152c1a4..0000000 --- a/jquery-loadTemplate/jquery.loadTemplate-1.2.3.min.js +++ /dev/null @@ -1 +0,0 @@ -(function(a){var u={},t={},h={};function m(B,x,z){var w=this,v,A,y;x=x||{};A=a.extend({overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(A.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null},z);if(a.type(x)==="array"){return r.call(this,B,x,A)}if(!g(B)){v=a(B)}y=A.isFile||(typeof A.isFile==="undefined"&&(typeof v==="undefined"||v.length===0));if(y&&!A.overwriteCache&&u[B]){p(B,w,x,A)}else{if(y&&!A.overwriteCache&&u.hasOwnProperty(B)){c(B,w,x,A)}else{if(y){l(B,w,x,A)}else{n(v,w,x,A)}}}return this}function b(w,v){if(v){h[w]=v}else{h=a.extend(h,w)}}function g(v){return typeof v==="string"&&v.indexOf("/")>-1}function r(E,w,B){B=B||{};var v=this,F=w.length,y=B.prepend&&!B.append,x=0,D=0,z=false,A;if(B.paged){var C=(B.pageNo-1)*B.elemPerPage;w=w.slice(C,C+B.elemPerPage);F=w.length}A=a.extend({},B,{complete:function(){if(y){v.prepend(this.html())}else{v.append(this.html())}x++;if(x===F){if(z&&B&&typeof B.error==="function"){B.error.call(v)}if(B&&typeof B.complete==="function"){B.complete()}}},success:function(){D++;if(D===F){if(B&&typeof B.success==="function"){B.success()}}},error:function(){z=true}});if(!B.append&&!B.prepend){v.html("")}if(y){w.reverse()}a(w).each(function(){var G=a("
");m.call(G,E,this,A)});return this}function c(y,w,v,x){if(t[y]){t[y].push({data:v,selection:w,settings:x})}else{t[y]=[{data:v,selection:w,settings:x}]}}function p(z,x,w,y){var v=u[z].clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success()}}function l(z,x,w,y){var v=a("
");u[z]=null;v.load(z,function(A,B){if(B==="error"){j(z,x,w,y)}else{k(v,z,x,w,y)}})}function n(v,y,x,z){var w=a("
");if(v.is("script")){v=a.parseHTML(a.trim(v.html()))}w.html(v);o.call(y,w,x,z);if(typeof z.success==="function"){z.success()}}function o(x,v,w){f(x,v);a(this).each(function(){var y=a(x.html());if(w.beforeInsert){w.beforeInsert(y)}if(w.append){a(this).append(y)}else{if(w.prepend){a(this).prepend(y)}else{a(this).html(y)}}if(w.afterInsert){w.afterInsert(y)}});if(typeof w.complete==="function"){w.complete.call(a(this))}}function j(y,w,v,x){var z;if(typeof x.error==="function"){x.error.call(w)}a(t[y]).each(function(A,B){if(typeof B.settings.error==="function"){B.settings.error.call(B.selection)}});if(typeof x.complete==="function"){x.complete.call(w)}while(t[y]&&(z=t[y].shift())){if(typeof z.settings.complete==="function"){z.settings.complete.call(z.selection)}}if(typeof t[y]!=="undefined"&&t[y].length>0){t[y]=[]}}function k(v,z,x,w,y){var A;u[z]=v.clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success.call(x)}while(t[z]&&(A=t[z].shift())){o.call(A.selection,u[z].clone(),A.data,A.settings);if(typeof A.settings.success==="function"){A.settings.success.call(A.selection)}}}function f(w,v){v=v||{};s("data-content",w,v,function(x,y){x.html(e(x,y,"content"))});s("data-content-append",w,v,function(x,y){x.append(e(x,y,"content"))});s("data-content-prepend",w,v,function(x,y){x.prepend(e(x,y,"content"))});s("data-src",w,v,function(x,y){x.attr("src",e(x,y,"src"))},function(x){x.remove()});s("data-alt",w,v,function(x,y){x.attr("alt",e(x,y,"alt"))});s("data-value",w,v,function(x,y){x.val(e(x,y,"value"))});s("data-link",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link"));y.html(x.html());x.html(y)});s("data-link-wrap",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link-wrap"));x.wrap(y)});s("data-options",w,v,function(x,y){a(y).each(function(){var z=a("
");m.call(G,E,this,A)});return this}function c(y,w,v,x){if(t[y]){t[y].push({data:v,selection:w,settings:x})}else{t[y]=[{data:v,selection:w,settings:x}]}}function p(z,x,w,y){var v=u[z].clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success()}}function l(z,x,w,y){var v=a("
");u[z]=null;v.load(z,function(A,B){if(B==="error"){j(z,x,w,y)}else{k(v,z,x,w,y)}})}function n(v,y,x,z){var w=a("
");if(v.is("script")){v=a.parseHTML(a.trim(v.html()))}w.html(v);o.call(y,w,x,z);if(typeof z.success==="function"){z.success()}}function o(x,v,w){f(x,v);a(this).each(function(){var y=a(x.html());if(w.beforeInsert){w.beforeInsert(y)}if(w.append){a(this).append(y)}else{if(w.prepend){a(this).prepend(y)}else{a(this).html(y)}}if(w.afterInsert){w.afterInsert(y)}});if(typeof w.complete==="function"){w.complete.call(a(this))}}function j(y,w,v,x){var z;if(typeof x.error==="function"){x.error.call(w)}a(t[y]).each(function(A,B){if(typeof B.settings.error==="function"){B.settings.error.call(B.selection)}});if(typeof x.complete==="function"){x.complete.call(w)}while(t[y]&&(z=t[y].shift())){if(typeof z.settings.complete==="function"){z.settings.complete.call(z.selection)}}if(typeof t[y]!=="undefined"&&t[y].length>0){t[y]=[]}}function k(v,z,x,w,y){var A;u[z]=v.clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success.call(x)}while(t[z]&&(A=t[z].shift())){o.call(A.selection,u[z].clone(),A.data,A.settings);if(typeof A.settings.success==="function"){A.settings.success.call(A.selection)}}}function f(w,v){v=v||{};s("data-content",w,v,function(x,y){x.html(e(x,y,"content"))});s("data-content-append",w,v,function(x,y){x.append(e(x,y,"content"))});s("data-content-prepend",w,v,function(x,y){x.prepend(e(x,y,"content"))});s("data-src",w,v,function(x,y){x.attr("src",e(x,y,"src"))},function(x){x.remove()});s("data-alt",w,v,function(x,y){x.attr("alt",e(x,y,"alt"))});s("data-value",w,v,function(x,y){x.val(e(x,y,"value"))});s("data-link",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link"));y.html(x.html());x.html(y)});s("data-link-wrap",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link-wrap"));x.wrap(y)});s("data-options",w,v,function(x,y){a(y).each(function(){var z=a("
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.2.4.js b/jquery-loadTemplate/jquery.loadTemplate-1.2.5.js similarity index 99% rename from jquery-loadTemplate/jquery.loadTemplate-1.2.4.js rename to jquery-loadTemplate/jquery.loadTemplate-1.2.5.js index a07e04e..4de71ad 100644 --- a/jquery-loadTemplate/jquery.loadTemplate-1.2.4.js +++ b/jquery-loadTemplate/jquery.loadTemplate-1.2.5.js @@ -309,7 +309,7 @@ $this.removeAttr(attribute); - if (value && dataBindFunction) { + if (typeof value !== 'undefined' && dataBindFunction) { dataBindFunction($this, value); } else if (noDataFunction) { noDataFunction($this); diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.2.4.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.2.5.min.js similarity index 75% rename from jquery-loadTemplate/jquery.loadTemplate-1.2.4.min.js rename to jquery-loadTemplate/jquery.loadTemplate-1.2.5.min.js index 09ab345..3ca2948 100644 --- a/jquery-loadTemplate/jquery.loadTemplate-1.2.4.min.js +++ b/jquery-loadTemplate/jquery.loadTemplate-1.2.5.min.js @@ -1 +1 @@ -(function(a){var u={},t={},h={};function m(B,x,z){var w=this,v,A,y;x=x||{};A=a.extend({overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(A.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null},z);if(a.type(x)==="array"){return r.call(this,B,x,A)}if(!g(B)){v=a(B);if(typeof B==="string"&&B.indexOf("#")===0){A.isFile=false}}y=A.isFile||(typeof A.isFile==="undefined"&&(typeof v==="undefined"||v.length===0));if(y&&!A.overwriteCache&&u[B]){p(B,w,x,A)}else{if(y&&!A.overwriteCache&&u.hasOwnProperty(B)){c(B,w,x,A)}else{if(y){l(B,w,x,A)}else{n(v,w,x,A)}}}return this}function b(w,v){if(v){h[w]=v}else{h=a.extend(h,w)}}function g(v){return typeof v==="string"&&v.indexOf("/")>-1}function r(E,w,B){B=B||{};var v=this,F=w.length,y=B.prepend&&!B.append,x=0,D=0,z=false,A;if(B.paged){var C=(B.pageNo-1)*B.elemPerPage;w=w.slice(C,C+B.elemPerPage);F=w.length}A=a.extend({},B,{complete:function(){if(y){v.prepend(this.html())}else{v.append(this.html())}x++;if(x===F){if(z&&B&&typeof B.error==="function"){B.error.call(v)}if(B&&typeof B.complete==="function"){B.complete()}}},success:function(){D++;if(D===F){if(B&&typeof B.success==="function"){B.success()}}},error:function(){z=true}});if(!B.append&&!B.prepend){v.html("")}if(y){w.reverse()}a(w).each(function(){var G=a("
");m.call(G,E,this,A)});return this}function c(y,w,v,x){if(t[y]){t[y].push({data:v,selection:w,settings:x})}else{t[y]=[{data:v,selection:w,settings:x}]}}function p(z,x,w,y){var v=u[z].clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success()}}function l(z,x,w,y){var v=a("
");u[z]=null;v.load(z,function(A,B){if(B==="error"){j(z,x,w,y)}else{k(v,z,x,w,y)}})}function n(v,y,x,z){var w=a("
");if(v.is("script")){v=a.parseHTML(a.trim(v.html()))}w.html(v);o.call(y,w,x,z);if(typeof z.success==="function"){z.success()}}function o(x,v,w){f(x,v);a(this).each(function(){var y=a(x.html());if(w.beforeInsert){w.beforeInsert(y)}if(w.append){a(this).append(y)}else{if(w.prepend){a(this).prepend(y)}else{a(this).html(y)}}if(w.afterInsert){w.afterInsert(y)}});if(typeof w.complete==="function"){w.complete.call(a(this))}}function j(y,w,v,x){var z;if(typeof x.error==="function"){x.error.call(w)}a(t[y]).each(function(A,B){if(typeof B.settings.error==="function"){B.settings.error.call(B.selection)}});if(typeof x.complete==="function"){x.complete.call(w)}while(t[y]&&(z=t[y].shift())){if(typeof z.settings.complete==="function"){z.settings.complete.call(z.selection)}}if(typeof t[y]!=="undefined"&&t[y].length>0){t[y]=[]}}function k(v,z,x,w,y){var A;u[z]=v.clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success.call(x)}while(t[z]&&(A=t[z].shift())){o.call(A.selection,u[z].clone(),A.data,A.settings);if(typeof A.settings.success==="function"){A.settings.success.call(A.selection)}}}function f(w,v){v=v||{};s("data-content",w,v,function(x,y){x.html(e(x,y,"content"))});s("data-content-append",w,v,function(x,y){x.append(e(x,y,"content"))});s("data-content-prepend",w,v,function(x,y){x.prepend(e(x,y,"content"))});s("data-src",w,v,function(x,y){x.attr("src",e(x,y,"src"))},function(x){x.remove()});s("data-alt",w,v,function(x,y){x.attr("alt",e(x,y,"alt"))});s("data-value",w,v,function(x,y){x.val(e(x,y,"value"))});s("data-link",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link"));y.html(x.html());x.html(y)});s("data-link-wrap",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link-wrap"));x.wrap(y)});s("data-options",w,v,function(x,y){a(y).each(function(){var z=a("
");m.call(G,E,this,A)});return this}function c(y,w,v,x){if(t[y]){t[y].push({data:v,selection:w,settings:x})}else{t[y]=[{data:v,selection:w,settings:x}]}}function p(z,x,w,y){var v=u[z].clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success()}}function l(z,x,w,y){var v=a("
");u[z]=null;v.load(z,function(A,B){if(B==="error"){j(z,x,w,y)}else{k(v,z,x,w,y)}})}function n(v,y,x,z){var w=a("
");if(v.is("script")){v=a.parseHTML(a.trim(v.html()))}w.html(v);o.call(y,w,x,z);if(typeof z.success==="function"){z.success()}}function o(x,v,w){f(x,v);a(this).each(function(){var y=a(x.html());if(w.beforeInsert){w.beforeInsert(y)}if(w.append){a(this).append(y)}else{if(w.prepend){a(this).prepend(y)}else{a(this).html(y)}}if(w.afterInsert){w.afterInsert(y)}});if(typeof w.complete==="function"){w.complete.call(a(this))}}function j(y,w,v,x){var z;if(typeof x.error==="function"){x.error.call(w)}a(t[y]).each(function(A,B){if(typeof B.settings.error==="function"){B.settings.error.call(B.selection)}});if(typeof x.complete==="function"){x.complete.call(w)}while(t[y]&&(z=t[y].shift())){if(typeof z.settings.complete==="function"){z.settings.complete.call(z.selection)}}if(typeof t[y]!=="undefined"&&t[y].length>0){t[y]=[]}}function k(v,z,x,w,y){var A;u[z]=v.clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success.call(x)}while(t[z]&&(A=t[z].shift())){o.call(A.selection,u[z].clone(),A.data,A.settings);if(typeof A.settings.success==="function"){A.settings.success.call(A.selection)}}}function f(w,v){v=v||{};s("data-content",w,v,function(x,y){x.html(e(x,y,"content"))});s("data-content-append",w,v,function(x,y){x.append(e(x,y,"content"))});s("data-content-prepend",w,v,function(x,y){x.prepend(e(x,y,"content"))});s("data-src",w,v,function(x,y){x.attr("src",e(x,y,"src"))},function(x){x.remove()});s("data-alt",w,v,function(x,y){x.attr("alt",e(x,y,"alt"))});s("data-value",w,v,function(x,y){x.val(e(x,y,"value"))});s("data-link",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link"));y.html(x.html());x.html(y)});s("data-link-wrap",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link-wrap"));x.wrap(y)});s("data-options",w,v,function(x,y){a(y).each(function(){var z=a("
+
- +
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.2.5.js b/jquery-loadTemplate/jquery.loadTemplate-1.2.6.js similarity index 99% rename from jquery-loadTemplate/jquery.loadTemplate-1.2.5.js rename to jquery-loadTemplate/jquery.loadTemplate-1.2.6.js index 4de71ad..e9d5d09 100644 --- a/jquery-loadTemplate/jquery.loadTemplate-1.2.5.js +++ b/jquery-loadTemplate/jquery.loadTemplate-1.2.6.js @@ -275,7 +275,7 @@ }); processElements("data-value", template, data, function ($elem, value) { - $elem.val(applyFormatters($elem, value, "value")); + $elem.attr("value", applyFormatters($elem, value, "value")); }); processElements("data-link", template, data, function ($elem, value) { diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.2.5.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.2.6.min.js similarity index 66% rename from jquery-loadTemplate/jquery.loadTemplate-1.2.5.min.js rename to jquery-loadTemplate/jquery.loadTemplate-1.2.6.min.js index 3ca2948..b802e27 100644 --- a/jquery-loadTemplate/jquery.loadTemplate-1.2.5.min.js +++ b/jquery-loadTemplate/jquery.loadTemplate-1.2.6.min.js @@ -1 +1 @@ -(function(a){var u={},t={},h={};function m(B,x,z){var w=this,v,A,y;x=x||{};A=a.extend({overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(A.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null},z);if(a.type(x)==="array"){return r.call(this,B,x,A)}if(!g(B)){v=a(B);if(typeof B==="string"&&B.indexOf("#")===0){A.isFile=false}}y=A.isFile||(typeof A.isFile==="undefined"&&(typeof v==="undefined"||v.length===0));if(y&&!A.overwriteCache&&u[B]){p(B,w,x,A)}else{if(y&&!A.overwriteCache&&u.hasOwnProperty(B)){c(B,w,x,A)}else{if(y){l(B,w,x,A)}else{n(v,w,x,A)}}}return this}function b(w,v){if(v){h[w]=v}else{h=a.extend(h,w)}}function g(v){return typeof v==="string"&&v.indexOf("/")>-1}function r(E,w,B){B=B||{};var v=this,F=w.length,y=B.prepend&&!B.append,x=0,D=0,z=false,A;if(B.paged){var C=(B.pageNo-1)*B.elemPerPage;w=w.slice(C,C+B.elemPerPage);F=w.length}A=a.extend({},B,{complete:function(){if(y){v.prepend(this.html())}else{v.append(this.html())}x++;if(x===F){if(z&&B&&typeof B.error==="function"){B.error.call(v)}if(B&&typeof B.complete==="function"){B.complete()}}},success:function(){D++;if(D===F){if(B&&typeof B.success==="function"){B.success()}}},error:function(){z=true}});if(!B.append&&!B.prepend){v.html("")}if(y){w.reverse()}a(w).each(function(){var G=a("
");m.call(G,E,this,A)});return this}function c(y,w,v,x){if(t[y]){t[y].push({data:v,selection:w,settings:x})}else{t[y]=[{data:v,selection:w,settings:x}]}}function p(z,x,w,y){var v=u[z].clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success()}}function l(z,x,w,y){var v=a("
");u[z]=null;v.load(z,function(A,B){if(B==="error"){j(z,x,w,y)}else{k(v,z,x,w,y)}})}function n(v,y,x,z){var w=a("
");if(v.is("script")){v=a.parseHTML(a.trim(v.html()))}w.html(v);o.call(y,w,x,z);if(typeof z.success==="function"){z.success()}}function o(x,v,w){f(x,v);a(this).each(function(){var y=a(x.html());if(w.beforeInsert){w.beforeInsert(y)}if(w.append){a(this).append(y)}else{if(w.prepend){a(this).prepend(y)}else{a(this).html(y)}}if(w.afterInsert){w.afterInsert(y)}});if(typeof w.complete==="function"){w.complete.call(a(this))}}function j(y,w,v,x){var z;if(typeof x.error==="function"){x.error.call(w)}a(t[y]).each(function(A,B){if(typeof B.settings.error==="function"){B.settings.error.call(B.selection)}});if(typeof x.complete==="function"){x.complete.call(w)}while(t[y]&&(z=t[y].shift())){if(typeof z.settings.complete==="function"){z.settings.complete.call(z.selection)}}if(typeof t[y]!=="undefined"&&t[y].length>0){t[y]=[]}}function k(v,z,x,w,y){var A;u[z]=v.clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success.call(x)}while(t[z]&&(A=t[z].shift())){o.call(A.selection,u[z].clone(),A.data,A.settings);if(typeof A.settings.success==="function"){A.settings.success.call(A.selection)}}}function f(w,v){v=v||{};s("data-content",w,v,function(x,y){x.html(e(x,y,"content"))});s("data-content-append",w,v,function(x,y){x.append(e(x,y,"content"))});s("data-content-prepend",w,v,function(x,y){x.prepend(e(x,y,"content"))});s("data-src",w,v,function(x,y){x.attr("src",e(x,y,"src"))},function(x){x.remove()});s("data-alt",w,v,function(x,y){x.attr("alt",e(x,y,"alt"))});s("data-value",w,v,function(x,y){x.val(e(x,y,"value"))});s("data-link",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link"));y.html(x.html());x.html(y)});s("data-link-wrap",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link-wrap"));x.wrap(y)});s("data-options",w,v,function(x,y){a(y).each(function(){var z=a("
");m.call(G,E,this,A)});return this}function c(y,w,v,x){if(t[y]){t[y].push({data:v,selection:w,settings:x})}else{t[y]=[{data:v,selection:w,settings:x}]}}function p(z,x,w,y){var v=u[z].clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success()}}function l(z,x,w,y){var v=a("
");u[z]=null;v.load(z,function(A,B){if(B==="error"){j(z,x,w,y)}else{k(v,z,x,w,y)}})}function n(v,y,x,z){var w=a("
");if(v.is("script")){v=a.parseHTML(a.trim(v.html()))}w.html(v);o.call(y,w,x,z);if(typeof z.success==="function"){z.success()}}function o(x,v,w){f(x,v);a(this).each(function(){var y=a(x.html());if(w.beforeInsert){w.beforeInsert(y)}if(w.append){a(this).append(y)}else{if(w.prepend){a(this).prepend(y)}else{a(this).html(y)}}if(w.afterInsert){w.afterInsert(y)}});if(typeof w.complete==="function"){w.complete.call(a(this))}}function j(y,w,v,x){var z;if(typeof x.error==="function"){x.error.call(w)}a(t[y]).each(function(A,B){if(typeof B.settings.error==="function"){B.settings.error.call(B.selection)}});if(typeof x.complete==="function"){x.complete.call(w)}while(t[y]&&(z=t[y].shift())){if(typeof z.settings.complete==="function"){z.settings.complete.call(z.selection)}}if(typeof t[y]!=="undefined"&&t[y].length>0){t[y]=[]}}function k(v,z,x,w,y){var A;u[z]=v.clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success.call(x)}while(t[z]&&(A=t[z].shift())){o.call(A.selection,u[z].clone(),A.data,A.settings);if(typeof A.settings.success==="function"){A.settings.success.call(A.selection)}}}function f(w,v){v=v||{};s("data-content",w,v,function(x,y){x.html(e(x,y,"content"))});s("data-content-append",w,v,function(x,y){x.append(e(x,y,"content"))});s("data-content-prepend",w,v,function(x,y){x.prepend(e(x,y,"content"))});s("data-src",w,v,function(x,y){x.attr("src",e(x,y,"src"))},function(x){x.remove()});s("data-alt",w,v,function(x,y){x.attr("alt",e(x,y,"alt"))});s("data-value",w,v,function(x,y){x.attr("value",e(x,y,"value"))});s("data-link",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link"));y.html(x.html());x.html(y)});s("data-link-wrap",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link-wrap"));x.wrap(y)});s("data-options",w,v,function(x,y){a(y).each(function(){var z=a("
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.2.6.js b/jquery-loadTemplate/jquery.loadTemplate-1.2.7.js similarity index 100% rename from jquery-loadTemplate/jquery.loadTemplate-1.2.6.js rename to jquery-loadTemplate/jquery.loadTemplate-1.2.7.js diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.2.6.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.2.7.min.js similarity index 87% rename from jquery-loadTemplate/jquery.loadTemplate-1.2.6.min.js rename to jquery-loadTemplate/jquery.loadTemplate-1.2.7.min.js index b802e27..95164eb 100644 --- a/jquery-loadTemplate/jquery.loadTemplate-1.2.6.min.js +++ b/jquery-loadTemplate/jquery.loadTemplate-1.2.7.min.js @@ -1 +1 @@ -(function(a){var u={},t={},h={};function m(B,x,z){var w=this,v,A,y;x=x||{};A=a.extend({overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(A.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null},z);if(a.type(x)==="array"){return r.call(this,B,x,A)}if(!g(B)){v=a(B);if(typeof B==="string"&&B.indexOf("#")===0){A.isFile=false}}y=A.isFile||(typeof A.isFile==="undefined"&&(typeof v==="undefined"||v.length===0));if(y&&!A.overwriteCache&&u[B]){p(B,w,x,A)}else{if(y&&!A.overwriteCache&&u.hasOwnProperty(B)){c(B,w,x,A)}else{if(y){l(B,w,x,A)}else{n(v,w,x,A)}}}return this}function b(w,v){if(v){h[w]=v}else{h=a.extend(h,w)}}function g(v){return typeof v==="string"&&v.indexOf("/")>-1}function r(E,w,B){B=B||{};var v=this,F=w.length,y=B.prepend&&!B.append,x=0,D=0,z=false,A;if(B.paged){var C=(B.pageNo-1)*B.elemPerPage;w=w.slice(C,C+B.elemPerPage);F=w.length}A=a.extend({},B,{complete:function(){if(y){v.prepend(this.html())}else{v.append(this.html())}x++;if(x===F){if(z&&B&&typeof B.error==="function"){B.error.call(v)}if(B&&typeof B.complete==="function"){B.complete()}}},success:function(){D++;if(D===F){if(B&&typeof B.success==="function"){B.success()}}},error:function(){z=true}});if(!B.append&&!B.prepend){v.html("")}if(y){w.reverse()}a(w).each(function(){var G=a("
");m.call(G,E,this,A)});return this}function c(y,w,v,x){if(t[y]){t[y].push({data:v,selection:w,settings:x})}else{t[y]=[{data:v,selection:w,settings:x}]}}function p(z,x,w,y){var v=u[z].clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success()}}function l(z,x,w,y){var v=a("
");u[z]=null;v.load(z,function(A,B){if(B==="error"){j(z,x,w,y)}else{k(v,z,x,w,y)}})}function n(v,y,x,z){var w=a("
");if(v.is("script")){v=a.parseHTML(a.trim(v.html()))}w.html(v);o.call(y,w,x,z);if(typeof z.success==="function"){z.success()}}function o(x,v,w){f(x,v);a(this).each(function(){var y=a(x.html());if(w.beforeInsert){w.beforeInsert(y)}if(w.append){a(this).append(y)}else{if(w.prepend){a(this).prepend(y)}else{a(this).html(y)}}if(w.afterInsert){w.afterInsert(y)}});if(typeof w.complete==="function"){w.complete.call(a(this))}}function j(y,w,v,x){var z;if(typeof x.error==="function"){x.error.call(w)}a(t[y]).each(function(A,B){if(typeof B.settings.error==="function"){B.settings.error.call(B.selection)}});if(typeof x.complete==="function"){x.complete.call(w)}while(t[y]&&(z=t[y].shift())){if(typeof z.settings.complete==="function"){z.settings.complete.call(z.selection)}}if(typeof t[y]!=="undefined"&&t[y].length>0){t[y]=[]}}function k(v,z,x,w,y){var A;u[z]=v.clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success.call(x)}while(t[z]&&(A=t[z].shift())){o.call(A.selection,u[z].clone(),A.data,A.settings);if(typeof A.settings.success==="function"){A.settings.success.call(A.selection)}}}function f(w,v){v=v||{};s("data-content",w,v,function(x,y){x.html(e(x,y,"content"))});s("data-content-append",w,v,function(x,y){x.append(e(x,y,"content"))});s("data-content-prepend",w,v,function(x,y){x.prepend(e(x,y,"content"))});s("data-src",w,v,function(x,y){x.attr("src",e(x,y,"src"))},function(x){x.remove()});s("data-alt",w,v,function(x,y){x.attr("alt",e(x,y,"alt"))});s("data-value",w,v,function(x,y){x.attr("value",e(x,y,"value"))});s("data-link",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link"));y.html(x.html());x.html(y)});s("data-link-wrap",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link-wrap"));x.wrap(y)});s("data-options",w,v,function(x,y){a(y).each(function(){var z=a("
");m.call(G,E,this,A)});return this}function c(y,w,v,x){if(t[y]){t[y].push({data:v,selection:w,settings:x})}else{t[y]=[{data:v,selection:w,settings:x}]}}function p(z,x,w,y){var v=u[z].clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success()}}function l(z,x,w,y){var v=a("
");u[z]=null;v.load(z,function(A,B){if(B==="error"){j(z,x,w,y)}else{k(v,z,x,w,y)}})}function n(v,y,x,z){var w=a("
");if(v.is("script")){v=a.parseHTML(a.trim(v.html()))}w.html(v);o.call(y,w,x,z);if(typeof z.success==="function"){z.success()}}function o(x,v,w){f(x,v);a(this).each(function(){var y=a(x.html());if(w.beforeInsert){w.beforeInsert(y)}if(w.append){a(this).append(y)}else{if(w.prepend){a(this).prepend(y)}else{a(this).html(y)}}if(w.afterInsert){w.afterInsert(y)}});if(typeof w.complete==="function"){w.complete.call(a(this))}}function j(y,w,v,x){var z;if(typeof x.error==="function"){x.error.call(w)}a(t[y]).each(function(A,B){if(typeof B.settings.error==="function"){B.settings.error.call(B.selection)}});if(typeof x.complete==="function"){x.complete.call(w)}while(t[y]&&(z=t[y].shift())){if(typeof z.settings.complete==="function"){z.settings.complete.call(z.selection)}}if(typeof t[y]!=="undefined"&&t[y].length>0){t[y]=[]}}function k(v,z,x,w,y){var A;u[z]=v.clone();o.call(x,v,w,y);if(typeof y.success==="function"){y.success.call(x)}while(t[z]&&(A=t[z].shift())){o.call(A.selection,u[z].clone(),A.data,A.settings);if(typeof A.settings.success==="function"){A.settings.success.call(A.selection)}}}function f(w,v){v=v||{};s("data-content",w,v,function(x,y){x.html(e(x,y,"content"))});s("data-content-append",w,v,function(x,y){x.append(e(x,y,"content"))});s("data-content-prepend",w,v,function(x,y){x.prepend(e(x,y,"content"))});s("data-src",w,v,function(x,y){x.attr("src",e(x,y,"src"))},function(x){x.remove()});s("data-alt",w,v,function(x,y){x.attr("alt",e(x,y,"alt"))});s("data-value",w,v,function(x,y){x.attr("value",e(x,y,"value"))});s("data-link",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link"));y.html(x.html());x.html(y)});s("data-link-wrap",w,v,function(x,z){var y=a("");y.attr("href",e(x,z,"link-wrap"));x.wrap(y)});s("data-options",w,v,function(x,y){a(y).each(function(){var z=a("

Example of loading a template from a script tag within the same document. - +
@@ -48,10 +48,6 @@

Code

- + From 24b0695afb4072987ea78cca04fd9f099cee26ce Mon Sep 17 00:00:00 2001 From: Paul Burgess Date: Sun, 17 Nov 2013 16:02:17 +0000 Subject: [PATCH 20/71] Nesting templates basic support Added support for binding to "this" to bind to the object itself rather than a parameter on the object. Also support for nested templates has been improved by providing a default formatter for this. To nest a template you can use the 'nestedTemplateFormatter'. An example is below: data-format="nestedTemplateFormatter" data-format-options='{"parentElement": "ul", "template": "#templateThis"}' data-format-options is required to at least provide a template in the same format as the loadTemplate function requires. parentElement is the element to use to contain the template. If this isn't provided then parentElement will be a "div". It is also possible to just provide a template and not an object. Documentation will need to be produced on this change. --- Examples/SimpleExample/example.html | 40 ++++-- Examples/index.html | 2 +- ...-1.2.8.js => jquery.loadTemplate-1.3.0.js} | 15 +++ ...in.js => jquery.loadTemplate-1.3.0.min.js} | 2 +- loadTemplate.jquery.json | 2 +- tests/files/general.js | 126 +++++++++++------- tests/index.html | 15 ++- 7 files changed, 140 insertions(+), 62 deletions(-) rename jquery-loadTemplate/{jquery.loadTemplate-1.2.8.js => jquery.loadTemplate-1.3.0.js} (96%) rename jquery-loadTemplate/{jquery.loadTemplate-1.2.8.min.js => jquery.loadTemplate-1.3.0.min.js} (88%) diff --git a/Examples/SimpleExample/example.html b/Examples/SimpleExample/example.html index d2914d8..f338d81 100644 --- a/Examples/SimpleExample/example.html +++ b/Examples/SimpleExample/example.html @@ -9,6 +9,10 @@

Example of loading a template from a script tag within the same document.
+
    + +
    + + + + + diff --git a/Examples/index.html b/Examples/index.html index 6abdb18..401f90d 100644 --- a/Examples/index.html +++ b/Examples/index.html @@ -9,7 +9,7 @@ - +
    diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.2.8.js b/jquery-loadTemplate/jquery.loadTemplate-1.3.0.js similarity index 96% rename from jquery-loadTemplate/jquery.loadTemplate-1.2.8.js rename to jquery-loadTemplate/jquery.loadTemplate-1.3.0.js index b89b7b9..18909f6 100644 --- a/jquery-loadTemplate/jquery.loadTemplate-1.2.8.js +++ b/jquery-loadTemplate/jquery.loadTemplate-1.3.0.js @@ -387,6 +387,9 @@ } function getValue(data, param) { + if (param === "this") { + return data; + } var paramParts = param.split('.'), part, value = data; @@ -412,7 +415,19 @@ return value; } + addTemplateFormatter("nestedTemplateFormatter", function (value, options) { + if (!options) { + return; + } + + if (typeof options === "string") { + options = $.parseJSON(options); + } + var parentElement = options.parentElement || "div"; + var template = options.template || options; + return $("<" + parentElement + "/>").loadTemplate(template, value); + }); $.fn.loadTemplate = loadTemplate; $.addTemplateFormatter = addTemplateFormatter; diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.2.8.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.3.0.min.js similarity index 88% rename from jquery-loadTemplate/jquery.loadTemplate-1.2.8.min.js rename to jquery-loadTemplate/jquery.loadTemplate-1.3.0.min.js index a2d60d3..c633182 100644 --- a/jquery-loadTemplate/jquery.loadTemplate-1.2.8.min.js +++ b/jquery-loadTemplate/jquery.loadTemplate-1.3.0.min.js @@ -1 +1 @@ -(function(a){var u={},t={},h={};function m(D,z,B){var y=this,x,C,A;z=z||{};C=a.extend({overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(C.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null},B);if(a.type(z)==="array"){return r.call(this,D,z,C)}if(!g(D)){x=a(D);if(typeof D==="string"&&D.indexOf("#")===0){C.isFile=false}}A=C.isFile||(typeof C.isFile==="undefined"&&(typeof x==="undefined"||x.length===0));if(A&&!C.overwriteCache&&u[D]){p(D,y,z,C)}else{if(A&&!C.overwriteCache&&u.hasOwnProperty(D)){c(D,y,z,C)}else{if(A){l(D,y,z,C)}else{n(x,y,z,C)}}}return this}function b(y,x){if(x){h[y]=x}else{h=a.extend(h,y)}}function g(x){return typeof x==="string"&&x.indexOf("/")>-1}function r(G,y,D){D=D||{};var x=this,H=y.length,A=D.prepend&&!D.append,z=0,F=0,B=false,C;if(D.paged){var E=(D.pageNo-1)*D.elemPerPage;y=y.slice(E,E+D.elemPerPage);H=y.length}C=a.extend({},D,{complete:function(){if(A){x.prepend(this.html())}else{x.append(this.html())}z++;if(z===H){if(B&&D&&typeof D.error==="function"){D.error.call(x)}if(D&&typeof D.complete==="function"){D.complete()}}},success:function(){F++;if(F===H){if(D&&typeof D.success==="function"){D.success()}}},error:function(){B=true}});if(!D.append&&!D.prepend){x.html("")}if(A){y.reverse()}a(y).each(function(){var I=a("
    ");m.call(I,G,this,C)});return this}function c(A,y,x,z){if(t[A]){t[A].push({data:x,selection:y,settings:z})}else{t[A]=[{data:x,selection:y,settings:z}]}}function p(B,z,y,A){var x=u[B].clone();o.call(z,x,y,A);if(typeof A.success==="function"){A.success()}}function v(){return new Date().getTime()}function w(x){if(x.indexOf("?")!==-1){return x+="&_="+v()}else{return x+="?_="+v()}}function l(B,z,y,A){var x=a("
    ");u[B]=null;if(A.overwriteCache){B=w(B)}x.load(B,function(C,D){if(D==="error"){j(B,z,y,A)}else{k(x,B,z,y,A)}})}function n(x,A,z,B){var y=a("
    ");if(x.is("script")){x=a.parseHTML(a.trim(x.html()))}y.html(x);o.call(A,y,z,B);if(typeof B.success==="function"){B.success()}}function o(z,x,y){f(z,x);a(this).each(function(){var A=a(z.html());if(y.beforeInsert){y.beforeInsert(A)}if(y.append){a(this).append(A)}else{if(y.prepend){a(this).prepend(A)}else{a(this).html(A)}}if(y.afterInsert){y.afterInsert(A)}});if(typeof y.complete==="function"){y.complete.call(a(this))}}function j(A,y,x,z){var B;if(typeof z.error==="function"){z.error.call(y)}a(t[A]).each(function(C,D){if(typeof D.settings.error==="function"){D.settings.error.call(D.selection)}});if(typeof z.complete==="function"){z.complete.call(y)}while(t[A]&&(B=t[A].shift())){if(typeof B.settings.complete==="function"){B.settings.complete.call(B.selection)}}if(typeof t[A]!=="undefined"&&t[A].length>0){t[A]=[]}}function k(x,B,z,y,A){var C;u[B]=x.clone();o.call(z,x,y,A);if(typeof A.success==="function"){A.success.call(z)}while(t[B]&&(C=t[B].shift())){o.call(C.selection,u[B].clone(),C.data,C.settings);if(typeof C.settings.success==="function"){C.settings.success.call(C.selection)}}}function f(y,x){x=x||{};s("data-content",y,x,function(z,A){z.html(e(z,A,"content"))});s("data-content-append",y,x,function(z,A){z.append(e(z,A,"content"))});s("data-content-prepend",y,x,function(z,A){z.prepend(e(z,A,"content"))});s("data-src",y,x,function(z,A){z.attr("src",e(z,A,"src"))},function(z){z.remove()});s("data-alt",y,x,function(z,A){z.attr("alt",e(z,A,"alt"))});s("data-value",y,x,function(z,A){z.attr("value",e(z,A,"value"))});s("data-link",y,x,function(z,B){var A=a("");A.attr("href",e(z,B,"link"));A.html(z.html());z.html(A)});s("data-link-wrap",y,x,function(z,B){var A=a("");A.attr("href",e(z,B,"link-wrap"));z.wrap(A)});s("data-options",y,x,function(z,A){a(A).each(function(){var B=a("
    ");m.call(I,G,this,C)});return this}function c(A,y,x,z){if(t[A]){t[A].push({data:x,selection:y,settings:z})}else{t[A]=[{data:x,selection:y,settings:z}]}}function p(B,z,y,A){var x=u[B].clone();o.call(z,x,y,A);if(typeof A.success==="function"){A.success()}}function v(){return new Date().getTime()}function w(x){if(x.indexOf("?")!==-1){return x+="&_="+v()}else{return x+="?_="+v()}}function l(B,z,y,A){var x=a("
    ");u[B]=null;if(A.overwriteCache){B=w(B)}x.load(B,function(C,D){if(D==="error"){j(B,z,y,A)}else{k(x,B,z,y,A)}})}function n(x,A,z,B){var y=a("
    ");if(x.is("script")){x=a.parseHTML(a.trim(x.html()))}y.html(x);o.call(A,y,z,B);if(typeof B.success==="function"){B.success()}}function o(z,x,y){f(z,x);a(this).each(function(){var A=a(z.html());if(y.beforeInsert){y.beforeInsert(A)}if(y.append){a(this).append(A)}else{if(y.prepend){a(this).prepend(A)}else{a(this).html(A)}}if(y.afterInsert){y.afterInsert(A)}});if(typeof y.complete==="function"){y.complete.call(a(this))}}function j(A,y,x,z){var B;if(typeof z.error==="function"){z.error.call(y)}a(t[A]).each(function(C,D){if(typeof D.settings.error==="function"){D.settings.error.call(D.selection)}});if(typeof z.complete==="function"){z.complete.call(y)}while(t[A]&&(B=t[A].shift())){if(typeof B.settings.complete==="function"){B.settings.complete.call(B.selection)}}if(typeof t[A]!=="undefined"&&t[A].length>0){t[A]=[]}}function k(x,B,z,y,A){var C;u[B]=x.clone();o.call(z,x,y,A);if(typeof A.success==="function"){A.success.call(z)}while(t[B]&&(C=t[B].shift())){o.call(C.selection,u[B].clone(),C.data,C.settings);if(typeof C.settings.success==="function"){C.settings.success.call(C.selection)}}}function f(y,x){x=x||{};s("data-content",y,x,function(z,A){z.html(e(z,A,"content"))});s("data-content-append",y,x,function(z,A){z.append(e(z,A,"content"))});s("data-content-prepend",y,x,function(z,A){z.prepend(e(z,A,"content"))});s("data-src",y,x,function(z,A){z.attr("src",e(z,A,"src"))},function(z){z.remove()});s("data-alt",y,x,function(z,A){z.attr("alt",e(z,A,"alt"))});s("data-value",y,x,function(z,A){z.attr("value",e(z,A,"value"))});s("data-link",y,x,function(z,B){var A=a("");A.attr("href",e(z,B,"link"));A.html(z.html());z.html(A)});s("data-link-wrap",y,x,function(z,B){var A=a("");A.attr("href",e(z,B,"link-wrap"));z.wrap(A)});s("data-options",y,x,function(z,A){a(A).each(function(){var B=a("
    + + + + + +
    From dfeef54183ae326fd92170bb6ec873d42c1d4b5f Mon Sep 17 00:00:00 2001 From: ferkel Date: Thu, 21 Nov 2013 12:24:46 +0100 Subject: [PATCH 21/71] Update jquery.loadTemplate-1.3.0.js it should be possible to add content as text instead of html ( example: display xml output for Export or using something with tags ) --- jquery-loadTemplate/jquery.loadTemplate-1.3.0.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.3.0.js b/jquery-loadTemplate/jquery.loadTemplate-1.3.0.js index 18909f6..e45e22e 100644 --- a/jquery-loadTemplate/jquery.loadTemplate-1.3.0.js +++ b/jquery-loadTemplate/jquery.loadTemplate-1.3.0.js @@ -280,6 +280,10 @@ $elem.prepend(applyFormatters($elem, value, "content")); }); + processElements("data-content-text", template, data, function ($elem, value) { + $elem.text(applyFormatters($elem, value, "content")); + }); + processElements("data-src", template, data, function ($elem, value) { $elem.attr("src", applyFormatters($elem, value, "src")); }, function ($elem) { @@ -360,6 +364,9 @@ case "contentPrepend": $this.prepend(applyDataBindFormatters($this, value, this)); break; + case "contentText": + $this.text(applyDataBindFormatters($this, value, this)); + break; case "options": var optionsData = this; $(value).each(function () { From 6e65746dd409f0ce499bda33a4c7c48adda1457f Mon Sep 17 00:00:00 2001 From: Paul Burgess Date: Thu, 21 Nov 2013 19:27:25 +0000 Subject: [PATCH 22/71] Updating Version Updating to 1.3.1 --- Examples/index.html | 2 +- ...query.loadTemplate-1.3.0.js => jquery.loadTemplate-1.3.1.js} | 0 ...adTemplate-1.3.0.min.js => jquery.loadTemplate-1.3.1.min.js} | 2 +- loadTemplate.jquery.json | 2 +- tests/index.html | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) rename jquery-loadTemplate/{jquery.loadTemplate-1.3.0.js => jquery.loadTemplate-1.3.1.js} (100%) rename jquery-loadTemplate/{jquery.loadTemplate-1.3.0.min.js => jquery.loadTemplate-1.3.1.min.js} (59%) diff --git a/Examples/index.html b/Examples/index.html index 401f90d..e994327 100644 --- a/Examples/index.html +++ b/Examples/index.html @@ -9,7 +9,7 @@ - +
    diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.3.0.js b/jquery-loadTemplate/jquery.loadTemplate-1.3.1.js similarity index 100% rename from jquery-loadTemplate/jquery.loadTemplate-1.3.0.js rename to jquery-loadTemplate/jquery.loadTemplate-1.3.1.js diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.3.0.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.3.1.min.js similarity index 59% rename from jquery-loadTemplate/jquery.loadTemplate-1.3.0.min.js rename to jquery-loadTemplate/jquery.loadTemplate-1.3.1.min.js index c633182..32ae120 100644 --- a/jquery-loadTemplate/jquery.loadTemplate-1.3.0.min.js +++ b/jquery-loadTemplate/jquery.loadTemplate-1.3.1.min.js @@ -1 +1 @@ -(function(a){var u={},t={},h={};function m(D,z,B){var y=this,x,C,A;z=z||{};C=a.extend({overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(C.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null},B);if(a.type(z)==="array"){return r.call(this,D,z,C)}if(!g(D)){x=a(D);if(typeof D==="string"&&D.indexOf("#")===0){C.isFile=false}}A=C.isFile||(typeof C.isFile==="undefined"&&(typeof x==="undefined"||x.length===0));if(A&&!C.overwriteCache&&u[D]){p(D,y,z,C)}else{if(A&&!C.overwriteCache&&u.hasOwnProperty(D)){c(D,y,z,C)}else{if(A){l(D,y,z,C)}else{n(x,y,z,C)}}}return this}function b(y,x){if(x){h[y]=x}else{h=a.extend(h,y)}}function g(x){return typeof x==="string"&&x.indexOf("/")>-1}function r(G,y,D){D=D||{};var x=this,H=y.length,A=D.prepend&&!D.append,z=0,F=0,B=false,C;if(D.paged){var E=(D.pageNo-1)*D.elemPerPage;y=y.slice(E,E+D.elemPerPage);H=y.length}C=a.extend({},D,{complete:function(){if(A){x.prepend(this.html())}else{x.append(this.html())}z++;if(z===H){if(B&&D&&typeof D.error==="function"){D.error.call(x)}if(D&&typeof D.complete==="function"){D.complete()}}},success:function(){F++;if(F===H){if(D&&typeof D.success==="function"){D.success()}}},error:function(){B=true}});if(!D.append&&!D.prepend){x.html("")}if(A){y.reverse()}a(y).each(function(){var I=a("
    ");m.call(I,G,this,C)});return this}function c(A,y,x,z){if(t[A]){t[A].push({data:x,selection:y,settings:z})}else{t[A]=[{data:x,selection:y,settings:z}]}}function p(B,z,y,A){var x=u[B].clone();o.call(z,x,y,A);if(typeof A.success==="function"){A.success()}}function v(){return new Date().getTime()}function w(x){if(x.indexOf("?")!==-1){return x+="&_="+v()}else{return x+="?_="+v()}}function l(B,z,y,A){var x=a("
    ");u[B]=null;if(A.overwriteCache){B=w(B)}x.load(B,function(C,D){if(D==="error"){j(B,z,y,A)}else{k(x,B,z,y,A)}})}function n(x,A,z,B){var y=a("
    ");if(x.is("script")){x=a.parseHTML(a.trim(x.html()))}y.html(x);o.call(A,y,z,B);if(typeof B.success==="function"){B.success()}}function o(z,x,y){f(z,x);a(this).each(function(){var A=a(z.html());if(y.beforeInsert){y.beforeInsert(A)}if(y.append){a(this).append(A)}else{if(y.prepend){a(this).prepend(A)}else{a(this).html(A)}}if(y.afterInsert){y.afterInsert(A)}});if(typeof y.complete==="function"){y.complete.call(a(this))}}function j(A,y,x,z){var B;if(typeof z.error==="function"){z.error.call(y)}a(t[A]).each(function(C,D){if(typeof D.settings.error==="function"){D.settings.error.call(D.selection)}});if(typeof z.complete==="function"){z.complete.call(y)}while(t[A]&&(B=t[A].shift())){if(typeof B.settings.complete==="function"){B.settings.complete.call(B.selection)}}if(typeof t[A]!=="undefined"&&t[A].length>0){t[A]=[]}}function k(x,B,z,y,A){var C;u[B]=x.clone();o.call(z,x,y,A);if(typeof A.success==="function"){A.success.call(z)}while(t[B]&&(C=t[B].shift())){o.call(C.selection,u[B].clone(),C.data,C.settings);if(typeof C.settings.success==="function"){C.settings.success.call(C.selection)}}}function f(y,x){x=x||{};s("data-content",y,x,function(z,A){z.html(e(z,A,"content"))});s("data-content-append",y,x,function(z,A){z.append(e(z,A,"content"))});s("data-content-prepend",y,x,function(z,A){z.prepend(e(z,A,"content"))});s("data-src",y,x,function(z,A){z.attr("src",e(z,A,"src"))},function(z){z.remove()});s("data-alt",y,x,function(z,A){z.attr("alt",e(z,A,"alt"))});s("data-value",y,x,function(z,A){z.attr("value",e(z,A,"value"))});s("data-link",y,x,function(z,B){var A=a("");A.attr("href",e(z,B,"link"));A.html(z.html());z.html(A)});s("data-link-wrap",y,x,function(z,B){var A=a("");A.attr("href",e(z,B,"link-wrap"));z.wrap(A)});s("data-options",y,x,function(z,A){a(A).each(function(){var B=a("
    ");m.call(I,G,this,C)});return this}function c(A,y,x,z){if(t[A]){t[A].push({data:x,selection:y,settings:z})}else{t[A]=[{data:x,selection:y,settings:z}]}}function p(B,z,y,A){var x=u[B].clone();o.call(z,x,y,A);if(typeof A.success==="function"){A.success()}}function v(){return new Date().getTime()}function w(x){if(x.indexOf("?")!==-1){return x+="&_="+v()}else{return x+="?_="+v()}}function l(B,z,y,A){var x=a("
    ");u[B]=null;if(A.overwriteCache){B=w(B)}x.load(B,function(C,D){if(D==="error"){j(B,z,y,A)}else{k(x,B,z,y,A)}})}function n(x,A,z,B){var y=a("
    ");if(x.is("script")){x=a.parseHTML(a.trim(x.html()))}y.html(x);o.call(A,y,z,B);if(typeof B.success==="function"){B.success()}}function o(z,x,y){f(z,x);a(this).each(function(){var A=a(z.html());if(y.beforeInsert){y.beforeInsert(A)}if(y.append){a(this).append(A)}else{if(y.prepend){a(this).prepend(A)}else{a(this).html(A)}}if(y.afterInsert){y.afterInsert(A)}});if(typeof y.complete==="function"){y.complete.call(a(this))}}function j(A,y,x,z){var B;if(typeof z.error==="function"){z.error.call(y)}a(t[A]).each(function(C,D){if(typeof D.settings.error==="function"){D.settings.error.call(D.selection)}});if(typeof z.complete==="function"){z.complete.call(y)}while(t[A]&&(B=t[A].shift())){if(typeof B.settings.complete==="function"){B.settings.complete.call(B.selection)}}if(typeof t[A]!=="undefined"&&t[A].length>0){t[A]=[]}}function k(x,B,z,y,A){var C;u[B]=x.clone();o.call(z,x,y,A);if(typeof A.success==="function"){A.success.call(z)}while(t[B]&&(C=t[B].shift())){o.call(C.selection,u[B].clone(),C.data,C.settings);if(typeof C.settings.success==="function"){C.settings.success.call(C.selection)}}}function f(y,x){x=x||{};s("data-content",y,x,function(z,A){z.html(e(z,A,"content"))});s("data-content-append",y,x,function(z,A){z.append(e(z,A,"content"))});s("data-content-prepend",y,x,function(z,A){z.prepend(e(z,A,"content"))});s("data-content-text",y,x,function(z,A){z.text(e(z,A,"content"))});s("data-src",y,x,function(z,A){z.attr("src",e(z,A,"src"))},function(z){z.remove()});s("data-alt",y,x,function(z,A){z.attr("alt",e(z,A,"alt"))});s("data-value",y,x,function(z,A){z.attr("value",e(z,A,"value"))});s("data-link",y,x,function(z,B){var A=a("");A.attr("href",e(z,B,"link"));A.html(z.html());z.html(A)});s("data-link-wrap",y,x,function(z,B){var A=a("");A.attr("href",e(z,B,"link-wrap"));z.wrap(A)});s("data-options",y,x,function(z,A){a(A).each(function(){var B=a("

    Example of loading a template from a script tag within the same document.
    +
    - + From 81942be2884a40875c8ab3e6cd85cd2f98e187d4 Mon Sep 17 00:00:00 2001 From: Diego Adolf Date: Wed, 22 Jan 2014 15:38:01 +0100 Subject: [PATCH 24/71] Added binding options --- .../jquery.loadTemplate-1.3.2.js | 47 +++++++++++++-- tests/files/bindingOptions.js | 59 +++++++++++++++++++ tests/index.html | 15 ++++- 3 files changed, 115 insertions(+), 6 deletions(-) create mode 100644 tests/files/bindingOptions.js diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.3.2.js b/jquery-loadTemplate/jquery.loadTemplate-1.3.2.js index 60da5ee..353226b 100644 --- a/jquery-loadTemplate/jquery.loadTemplate-1.3.2.js +++ b/jquery-loadTemplate/jquery.loadTemplate-1.3.2.js @@ -2,17 +2,17 @@ "use strict"; var templates = {}, queue = {}, - formatters = {}; + formatters = {}, + settings; function loadTemplate(template, data, options) { var $that = this, $template, - settings, isFile; data = data || {}; - settings = $.extend({ + settings = $.extend(true, { // These are the defaults. overwriteCache: false, complete: null, @@ -29,7 +29,12 @@ append: false, prepend: false, beforeInsert: null, - afterInsert: null + afterInsert: null, + bindingOptions: { + ignoreUndefined: false, + ignoreNull: false, + ignoreEmptyString: false + } }, options); if ($.type(data) === "array") { @@ -327,7 +332,12 @@ param = $this.attr(attribute), value = getValue(data, param); - $this.removeAttr(attribute); + if (!valueIsAllowedByBindingOptions($this, value)) { + $this.remove(); + return; + } + + $this.removeAttr(attribute); if (typeof value !== 'undefined' && dataBindFunction) { dataBindFunction($this, value); @@ -338,6 +348,33 @@ return; } + function valueIsAllowedByBindingOptions($element, value) { + + var bindingOptions = {} + + if ($element.attr("data-binding-options")) { + bindingOptions = $.parseJSON($element.attr("data-binding-options")) + $element.removeAttr("data-binding-options"); + } + + // extend general bindingOptions with specific settings + bindingOptions = $.extend({}, settings.bindingOptions, bindingOptions) + + + if (bindingOptions.ignoreUndefined && typeof value === "undefined") { + return false; + + } else if (bindingOptions.ignoreNull && value === null){ + return false; + + } else if (bindingOptions.ignoreEmptyString && value === "") { + return false; + + } else { + return true; + } + } + function processAllElements(template, data) { $("[data-template-bind]", template).each(function () { var $this = $(this), diff --git a/tests/files/bindingOptions.js b/tests/files/bindingOptions.js new file mode 100644 index 0000000..908e781 --- /dev/null +++ b/tests/files/bindingOptions.js @@ -0,0 +1,59 @@ +(function () { + + var data = [{ + "title": "Super Mario World 2", + "subtitle": "Yoshi's Island" + },{ + "title": "The Little Prince", + "subtitle": null + },{ + "title": "The Da Vinci Code" + }]; + + + + function testLoadedWithFunctionParameters() { + $("#loadedWithBindingParametersAsFunctionParameters").loadTemplate($("#templateWithoutBindingParamters"), data, {bindingOptions: {"ignoreUndefined": true, "ignoreNull": true}}); + } + + function testLoadedWithTemplateParameters() { + $("#loadedWithBindingParametersAsTemplateParameters").loadTemplate($("#templateWithBindingParamters"), data); + } + + function test(assert, async) { + return [ + { + name: "jQuery Loaded", + test: function () { + assert(jQuery); + } + }, + { + name: "loadTemplate Loaded", + test: function () { + assert(typeof $.fn.loadTemplate === 'function'); + } + }, + { + name: "Load template with binding options as function parameters", + test: function () { + testLoadedWithFunctionParameters(); + + var childs = $('#loadedWithBindingParametersAsFunctionParameters h4').length; + assert(childs === 1); + } + }, + { + name: "Load template with binding options as template parameters", + test: function () { + testLoadedWithTemplateParameters(); + + var childs = $('#loadedWithBindingParametersAsTemplateParameters h4').length; + assert(childs === 1); + } + }]; + } + + addTests(test); + +})(); diff --git a/tests/index.html b/tests/index.html index 44f5d45..89d8c0f 100644 --- a/tests/index.html +++ b/tests/index.html @@ -12,7 +12,8 @@ 'files/general.js', 'files/formatters.js', 'files/callback.js', - 'files/error.js' + 'files/error.js', + 'files/bindingOptions.js' ]); @@ -112,6 +113,18 @@
    + +
    + + +
    +
    From fd84c404fb4df2bcd0d7451efcd7a02e2c4a4310 Mon Sep 17 00:00:00 2001 From: diegoadolf Date: Wed, 22 Jan 2014 15:43:07 +0100 Subject: [PATCH 25/71] removed unnecessary whitespace --- jquery-loadTemplate/jquery.loadTemplate-1.3.2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.3.2.js b/jquery-loadTemplate/jquery.loadTemplate-1.3.2.js index 353226b..9539577 100644 --- a/jquery-loadTemplate/jquery.loadTemplate-1.3.2.js +++ b/jquery-loadTemplate/jquery.loadTemplate-1.3.2.js @@ -3,7 +3,7 @@ var templates = {}, queue = {}, formatters = {}, - settings; + settings; function loadTemplate(template, data, options) { var $that = this, From 7b25f9e5f7069e9494623ad037cc5e95281bb8b3 Mon Sep 17 00:00:00 2001 From: Diego Adolf Date: Wed, 22 Jan 2014 16:25:13 +0100 Subject: [PATCH 26/71] added data to test ignoreEmptyString=true binding option --- jquery-loadTemplate/jquery.loadTemplate-1.3.2.min.js | 1 - tests/files/bindingOptions.js | 7 ++++--- tests/index.html | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) delete mode 100644 jquery-loadTemplate/jquery.loadTemplate-1.3.2.min.js diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.3.2.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.3.2.min.js deleted file mode 100644 index f3299a8..0000000 --- a/jquery-loadTemplate/jquery.loadTemplate-1.3.2.min.js +++ /dev/null @@ -1 +0,0 @@ -(function(a){var u={},t={},h={};function m(D,z,B){var y=this,x,C,A;z=z||{};C=a.extend({overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(C.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null},B);if(a.type(z)==="array"){return r.call(this,D,z,C)}if(!g(D)){x=a(D);if(typeof D==="string"&&D.indexOf("#")===0){C.isFile=false}}A=C.isFile||(typeof C.isFile==="undefined"&&(typeof x==="undefined"||x.length===0));if(A&&!C.overwriteCache&&u[D]){p(D,y,z,C)}else{if(A&&!C.overwriteCache&&u.hasOwnProperty(D)){c(D,y,z,C)}else{if(A){l(D,y,z,C)}else{n(x,y,z,C)}}}return this}function b(y,x){if(x){h[y]=x}else{h=a.extend(h,y)}}function g(x){return typeof x==="string"&&x.indexOf("/")>-1}function r(G,y,D){D=D||{};var x=this,H=y.length,A=D.prepend&&!D.append,z=0,F=0,B=false,C;if(D.paged){var E=(D.pageNo-1)*D.elemPerPage;y=y.slice(E,E+D.elemPerPage);H=y.length}C=a.extend({},D,{complete:function(){if(A){x.prepend(this.html())}else{x.append(this.html())}z++;if(z===H){if(B&&D&&typeof D.error==="function"){D.error.call(x)}if(D&&typeof D.complete==="function"){D.complete()}}},success:function(){F++;if(F===H){if(D&&typeof D.success==="function"){D.success()}}},error:function(){B=true}});if(!D.append&&!D.prepend){x.html("")}if(A){y.reverse()}a(y).each(function(){var I=a("
    ");m.call(I,G,this,C)});return this}function c(A,y,x,z){if(t[A]){t[A].push({data:x,selection:y,settings:z})}else{t[A]=[{data:x,selection:y,settings:z}]}}function p(B,z,y,A){var x=u[B].clone();o.call(z,x,y,A);if(typeof A.success==="function"){A.success()}}function v(){return new Date().getTime()}function w(x){if(x.indexOf("?")!==-1){return x+="&_="+v()}else{return x+="?_="+v()}}function l(B,z,y,A){var x=a("
    ");u[B]=null;if(A.overwriteCache){B=w(B)}x.load(B,function(C,D){if(D==="error"){j(B,z,y,A)}else{k(x,B,z,y,A)}})}function n(x,A,z,B){var y=a("
    ");if(x.is("script")){x=a.parseHTML(a.trim(x.html()))}y.html(x);o.call(A,y,z,B);if(typeof B.success==="function"){B.success()}}function o(z,x,y){f(z,x);a(this).each(function(){var A=a(z.html());if(y.beforeInsert){y.beforeInsert(A)}if(y.append){a(this).append(A)}else{if(y.prepend){a(this).prepend(A)}else{a(this).html(A)}}if(y.afterInsert){y.afterInsert(A)}});if(typeof y.complete==="function"){y.complete.call(a(this))}}function j(A,y,x,z){var B;if(typeof z.error==="function"){z.error.call(y)}a(t[A]).each(function(C,D){if(typeof D.settings.error==="function"){D.settings.error.call(D.selection)}});if(typeof z.complete==="function"){z.complete.call(y)}while(t[A]&&(B=t[A].shift())){if(typeof B.settings.complete==="function"){B.settings.complete.call(B.selection)}}if(typeof t[A]!=="undefined"&&t[A].length>0){t[A]=[]}}function k(x,B,z,y,A){var C;u[B]=x.clone();o.call(z,x,y,A);if(typeof A.success==="function"){A.success.call(z)}while(t[B]&&(C=t[B].shift())){o.call(C.selection,u[B].clone(),C.data,C.settings);if(typeof C.settings.success==="function"){C.settings.success.call(C.selection)}}}function f(y,x){x=x||{};s("data-content",y,x,function(z,A){z.html(e(z,A,"content"))});s("data-content-append",y,x,function(z,A){z.append(e(z,A,"content"))});s("data-content-prepend",y,x,function(z,A){z.prepend(e(z,A,"content"))});s("data-content-text",y,x,function(z,A){z.text(e(z,A,"content"))});s("data-src",y,x,function(z,A){z.attr("src",e(z,A,"src"))},function(z){z.remove()});s("data-alt",y,x,function(z,A){z.attr("alt",e(z,A,"alt"))});s("data-value",y,x,function(z,A){z.attr("value",e(z,A,"value"))});s("data-link",y,x,function(z,B){var A=a("");A.attr("href",e(z,B,"link"));A.html(z.html());z.html(A)});s("data-link-wrap",y,x,function(z,B){var A=a("");A.attr("href",e(z,B,"link-wrap"));z.wrap(A)});s("data-options",y,x,function(z,A){a(A).each(function(){var B=a("
    diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.3.2.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.3.2.min.js deleted file mode 100644 index f3299a8..0000000 --- a/jquery-loadTemplate/jquery.loadTemplate-1.3.2.min.js +++ /dev/null @@ -1 +0,0 @@ -(function(a){var u={},t={},h={};function m(D,z,B){var y=this,x,C,A;z=z||{};C=a.extend({overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(C.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null},B);if(a.type(z)==="array"){return r.call(this,D,z,C)}if(!g(D)){x=a(D);if(typeof D==="string"&&D.indexOf("#")===0){C.isFile=false}}A=C.isFile||(typeof C.isFile==="undefined"&&(typeof x==="undefined"||x.length===0));if(A&&!C.overwriteCache&&u[D]){p(D,y,z,C)}else{if(A&&!C.overwriteCache&&u.hasOwnProperty(D)){c(D,y,z,C)}else{if(A){l(D,y,z,C)}else{n(x,y,z,C)}}}return this}function b(y,x){if(x){h[y]=x}else{h=a.extend(h,y)}}function g(x){return typeof x==="string"&&x.indexOf("/")>-1}function r(G,y,D){D=D||{};var x=this,H=y.length,A=D.prepend&&!D.append,z=0,F=0,B=false,C;if(D.paged){var E=(D.pageNo-1)*D.elemPerPage;y=y.slice(E,E+D.elemPerPage);H=y.length}C=a.extend({},D,{complete:function(){if(A){x.prepend(this.html())}else{x.append(this.html())}z++;if(z===H){if(B&&D&&typeof D.error==="function"){D.error.call(x)}if(D&&typeof D.complete==="function"){D.complete()}}},success:function(){F++;if(F===H){if(D&&typeof D.success==="function"){D.success()}}},error:function(){B=true}});if(!D.append&&!D.prepend){x.html("")}if(A){y.reverse()}a(y).each(function(){var I=a("
    ");m.call(I,G,this,C)});return this}function c(A,y,x,z){if(t[A]){t[A].push({data:x,selection:y,settings:z})}else{t[A]=[{data:x,selection:y,settings:z}]}}function p(B,z,y,A){var x=u[B].clone();o.call(z,x,y,A);if(typeof A.success==="function"){A.success()}}function v(){return new Date().getTime()}function w(x){if(x.indexOf("?")!==-1){return x+="&_="+v()}else{return x+="?_="+v()}}function l(B,z,y,A){var x=a("
    ");u[B]=null;if(A.overwriteCache){B=w(B)}x.load(B,function(C,D){if(D==="error"){j(B,z,y,A)}else{k(x,B,z,y,A)}})}function n(x,A,z,B){var y=a("
    ");if(x.is("script")){x=a.parseHTML(a.trim(x.html()))}y.html(x);o.call(A,y,z,B);if(typeof B.success==="function"){B.success()}}function o(z,x,y){f(z,x);a(this).each(function(){var A=a(z.html());if(y.beforeInsert){y.beforeInsert(A)}if(y.append){a(this).append(A)}else{if(y.prepend){a(this).prepend(A)}else{a(this).html(A)}}if(y.afterInsert){y.afterInsert(A)}});if(typeof y.complete==="function"){y.complete.call(a(this))}}function j(A,y,x,z){var B;if(typeof z.error==="function"){z.error.call(y)}a(t[A]).each(function(C,D){if(typeof D.settings.error==="function"){D.settings.error.call(D.selection)}});if(typeof z.complete==="function"){z.complete.call(y)}while(t[A]&&(B=t[A].shift())){if(typeof B.settings.complete==="function"){B.settings.complete.call(B.selection)}}if(typeof t[A]!=="undefined"&&t[A].length>0){t[A]=[]}}function k(x,B,z,y,A){var C;u[B]=x.clone();o.call(z,x,y,A);if(typeof A.success==="function"){A.success.call(z)}while(t[B]&&(C=t[B].shift())){o.call(C.selection,u[B].clone(),C.data,C.settings);if(typeof C.settings.success==="function"){C.settings.success.call(C.selection)}}}function f(y,x){x=x||{};s("data-content",y,x,function(z,A){z.html(e(z,A,"content"))});s("data-content-append",y,x,function(z,A){z.append(e(z,A,"content"))});s("data-content-prepend",y,x,function(z,A){z.prepend(e(z,A,"content"))});s("data-content-text",y,x,function(z,A){z.text(e(z,A,"content"))});s("data-src",y,x,function(z,A){z.attr("src",e(z,A,"src"))},function(z){z.remove()});s("data-alt",y,x,function(z,A){z.attr("alt",e(z,A,"alt"))});s("data-value",y,x,function(z,A){z.attr("value",e(z,A,"value"))});s("data-link",y,x,function(z,B){var A=a("");A.attr("href",e(z,B,"link"));A.html(z.html());z.html(A)});s("data-link-wrap",y,x,function(z,B){var A=a("");A.attr("href",e(z,B,"link-wrap"));z.wrap(A)});s("data-options",y,x,function(z,A){a(A).each(function(){var B=a("
    "); loadTemplate.call($div, template, this, newOptions); + if (errored) { + return false; + } }); return this; @@ -169,11 +172,15 @@ if (settings.overwriteCache) { template = urlAvoidCache(template); } - $templateContainer.load(template, function (responseText, textStatus) { - if (textStatus === "error") { - handleTemplateLoadingError(template, selection, data, settings); - } else { + $.ajax({ + url: template, + async: false, + success: function (templateContent) { + $templateContainer.html(templateContent); handleTemplateLoadingSuccess($templateContainer, template, selection, data, settings); + }, + error: function () { + handleTemplateLoadingError(template, selection, data, settings); } }); } @@ -426,7 +433,7 @@ if (!options) { return; } - + if (typeof options === "string" && options[0] === "{") { options = $.parseJSON(options); } diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.3.3.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.3.3.min.js new file mode 100644 index 0000000..6eddef5 --- /dev/null +++ b/jquery-loadTemplate/jquery.loadTemplate-1.3.3.min.js @@ -0,0 +1 @@ +(function(a){var u={},t={},h={};function m(D,z,B){var y=this,x,C,A;z=z||{};C=a.extend({overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(C.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null},B);if(a.type(z)==="array"){return r.call(this,D,z,C)}if(!g(D)){x=a(D);if(typeof D==="string"&&D.indexOf("#")===0){C.isFile=false}}A=C.isFile||(typeof C.isFile==="undefined"&&(typeof x==="undefined"||x.length===0));if(A&&!C.overwriteCache&&u[D]){p(D,y,z,C)}else{if(A&&!C.overwriteCache&&u.hasOwnProperty(D)){c(D,y,z,C)}else{if(A){l(D,y,z,C)}else{n(x,y,z,C)}}}return this}function b(y,x){if(x){h[y]=x}else{h=a.extend(h,y)}}function g(x){return typeof x==="string"&&x.indexOf("/")>-1}function r(G,y,D){D=D||{};var x=this,H=y.length,A=D.prepend&&!D.append,z=0,F=0,B=false,C;if(D.paged){var E=(D.pageNo-1)*D.elemPerPage;y=y.slice(E,E+D.elemPerPage);H=y.length}C=a.extend({},D,{complete:function(){if(A){x.prepend(this.html())}else{x.append(this.html())}z++;if(z===H||B){if(B&&D&&typeof D.error==="function"){D.error.call(x)}if(D&&typeof D.complete==="function"){D.complete()}}},success:function(){F++;if(F===H){if(D&&typeof D.success==="function"){D.success()}}},error:function(){B=true}});if(!D.append&&!D.prepend){x.html("")}if(A){y.reverse()}a(y).each(function(){var I=a("
    ");m.call(I,G,this,C);if(B){return false}});return this}function c(A,y,x,z){if(t[A]){t[A].push({data:x,selection:y,settings:z})}else{t[A]=[{data:x,selection:y,settings:z}]}}function p(B,z,y,A){var x=u[B].clone();o.call(z,x,y,A);if(typeof A.success==="function"){A.success()}}function v(){return new Date().getTime()}function w(x){if(x.indexOf("?")!==-1){return x+="&_="+v()}else{return x+="?_="+v()}}function l(B,z,y,A){var x=a("
    ");u[B]=null;if(A.overwriteCache){B=w(B)}a.ajax({url:B,async:false,success:function(C){x.html(C);k(x,B,z,y,A)},error:function(){j(B,z,y,A)}})}function n(x,A,z,B){var y=a("
    ");if(x.is("script")){x=a.parseHTML(a.trim(x.html()))}y.html(x);o.call(A,y,z,B);if(typeof B.success==="function"){B.success()}}function o(z,x,y){f(z,x);a(this).each(function(){var A=a(z.html());if(y.beforeInsert){y.beforeInsert(A)}if(y.append){a(this).append(A)}else{if(y.prepend){a(this).prepend(A)}else{a(this).html(A)}}if(y.afterInsert){y.afterInsert(A)}});if(typeof y.complete==="function"){y.complete.call(a(this))}}function j(A,y,x,z){var B;if(typeof z.error==="function"){z.error.call(y)}a(t[A]).each(function(C,D){if(typeof D.settings.error==="function"){D.settings.error.call(D.selection)}});if(typeof z.complete==="function"){z.complete.call(y)}while(t[A]&&(B=t[A].shift())){if(typeof B.settings.complete==="function"){B.settings.complete.call(B.selection)}}if(typeof t[A]!=="undefined"&&t[A].length>0){t[A]=[]}}function k(x,B,z,y,A){var C;u[B]=x.clone();o.call(z,x,y,A);if(typeof A.success==="function"){A.success.call(z)}while(t[B]&&(C=t[B].shift())){o.call(C.selection,u[B].clone(),C.data,C.settings);if(typeof C.settings.success==="function"){C.settings.success.call(C.selection)}}}function f(y,x){x=x||{};s("data-content",y,x,function(z,A){z.html(e(z,A,"content"))});s("data-content-append",y,x,function(z,A){z.append(e(z,A,"content"))});s("data-content-prepend",y,x,function(z,A){z.prepend(e(z,A,"content"))});s("data-content-text",y,x,function(z,A){z.text(e(z,A,"content"))});s("data-src",y,x,function(z,A){z.attr("src",e(z,A,"src"))},function(z){z.remove()});s("data-alt",y,x,function(z,A){z.attr("alt",e(z,A,"alt"))});s("data-value",y,x,function(z,A){z.attr("value",e(z,A,"value"))});s("data-link",y,x,function(z,B){var A=a("");A.attr("href",e(z,B,"link"));A.html(z.html());z.html(A)});s("data-link-wrap",y,x,function(z,B){var A=a("");A.attr("href",e(z,B,"link-wrap"));z.wrap(A)});s("data-options",y,x,function(z,A){a(A).each(function(){var B=a("
    diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.3.3.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.3.3.min.js deleted file mode 100644 index 6eddef5..0000000 --- a/jquery-loadTemplate/jquery.loadTemplate-1.3.3.min.js +++ /dev/null @@ -1 +0,0 @@ -(function(a){var u={},t={},h={};function m(D,z,B){var y=this,x,C,A;z=z||{};C=a.extend({overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(C.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null},B);if(a.type(z)==="array"){return r.call(this,D,z,C)}if(!g(D)){x=a(D);if(typeof D==="string"&&D.indexOf("#")===0){C.isFile=false}}A=C.isFile||(typeof C.isFile==="undefined"&&(typeof x==="undefined"||x.length===0));if(A&&!C.overwriteCache&&u[D]){p(D,y,z,C)}else{if(A&&!C.overwriteCache&&u.hasOwnProperty(D)){c(D,y,z,C)}else{if(A){l(D,y,z,C)}else{n(x,y,z,C)}}}return this}function b(y,x){if(x){h[y]=x}else{h=a.extend(h,y)}}function g(x){return typeof x==="string"&&x.indexOf("/")>-1}function r(G,y,D){D=D||{};var x=this,H=y.length,A=D.prepend&&!D.append,z=0,F=0,B=false,C;if(D.paged){var E=(D.pageNo-1)*D.elemPerPage;y=y.slice(E,E+D.elemPerPage);H=y.length}C=a.extend({},D,{complete:function(){if(A){x.prepend(this.html())}else{x.append(this.html())}z++;if(z===H||B){if(B&&D&&typeof D.error==="function"){D.error.call(x)}if(D&&typeof D.complete==="function"){D.complete()}}},success:function(){F++;if(F===H){if(D&&typeof D.success==="function"){D.success()}}},error:function(){B=true}});if(!D.append&&!D.prepend){x.html("")}if(A){y.reverse()}a(y).each(function(){var I=a("
    ");m.call(I,G,this,C);if(B){return false}});return this}function c(A,y,x,z){if(t[A]){t[A].push({data:x,selection:y,settings:z})}else{t[A]=[{data:x,selection:y,settings:z}]}}function p(B,z,y,A){var x=u[B].clone();o.call(z,x,y,A);if(typeof A.success==="function"){A.success()}}function v(){return new Date().getTime()}function w(x){if(x.indexOf("?")!==-1){return x+="&_="+v()}else{return x+="?_="+v()}}function l(B,z,y,A){var x=a("
    ");u[B]=null;if(A.overwriteCache){B=w(B)}a.ajax({url:B,async:false,success:function(C){x.html(C);k(x,B,z,y,A)},error:function(){j(B,z,y,A)}})}function n(x,A,z,B){var y=a("
    ");if(x.is("script")){x=a.parseHTML(a.trim(x.html()))}y.html(x);o.call(A,y,z,B);if(typeof B.success==="function"){B.success()}}function o(z,x,y){f(z,x);a(this).each(function(){var A=a(z.html());if(y.beforeInsert){y.beforeInsert(A)}if(y.append){a(this).append(A)}else{if(y.prepend){a(this).prepend(A)}else{a(this).html(A)}}if(y.afterInsert){y.afterInsert(A)}});if(typeof y.complete==="function"){y.complete.call(a(this))}}function j(A,y,x,z){var B;if(typeof z.error==="function"){z.error.call(y)}a(t[A]).each(function(C,D){if(typeof D.settings.error==="function"){D.settings.error.call(D.selection)}});if(typeof z.complete==="function"){z.complete.call(y)}while(t[A]&&(B=t[A].shift())){if(typeof B.settings.complete==="function"){B.settings.complete.call(B.selection)}}if(typeof t[A]!=="undefined"&&t[A].length>0){t[A]=[]}}function k(x,B,z,y,A){var C;u[B]=x.clone();o.call(z,x,y,A);if(typeof A.success==="function"){A.success.call(z)}while(t[B]&&(C=t[B].shift())){o.call(C.selection,u[B].clone(),C.data,C.settings);if(typeof C.settings.success==="function"){C.settings.success.call(C.selection)}}}function f(y,x){x=x||{};s("data-content",y,x,function(z,A){z.html(e(z,A,"content"))});s("data-content-append",y,x,function(z,A){z.append(e(z,A,"content"))});s("data-content-prepend",y,x,function(z,A){z.prepend(e(z,A,"content"))});s("data-content-text",y,x,function(z,A){z.text(e(z,A,"content"))});s("data-src",y,x,function(z,A){z.attr("src",e(z,A,"src"))},function(z){z.remove()});s("data-alt",y,x,function(z,A){z.attr("alt",e(z,A,"alt"))});s("data-value",y,x,function(z,A){z.attr("value",e(z,A,"value"))});s("data-link",y,x,function(z,B){var A=a("");A.attr("href",e(z,B,"link"));A.html(z.html());z.html(A)});s("data-link-wrap",y,x,function(z,B){var A=a("");A.attr("href",e(z,B,"link-wrap"));z.wrap(A)});s("data-options",y,x,function(z,A){a(A).each(function(){var B=a("
    "); templates[template] = null; + var templateUrl = template; if (settings.overwriteCache) { - template = urlAvoidCache(template); + templateUrl = urlAvoidCache(templateUrl); } $.ajax({ - url: template, - async: false, + url: templateUrl, + async: settings.async, success: function (templateContent) { $templateContainer.html(templateContent); handleTemplateLoadingSuccess($templateContainer, template, selection, data, settings); diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.3.4.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.3.4.min.js new file mode 100644 index 0000000..b957523 --- /dev/null +++ b/jquery-loadTemplate/jquery.loadTemplate-1.3.4.min.js @@ -0,0 +1 @@ +(function(a){var u={},t={},h={};function m(D,z,B){var y=this,x,C,A;z=z||{};C=a.extend({async:true,overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(C.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null},B);if(a.type(z)==="array"){return r.call(this,D,z,C)}if(!g(D)){x=a(D);if(typeof D==="string"&&D.indexOf("#")===0){C.isFile=false}}A=C.isFile||(typeof C.isFile==="undefined"&&(typeof x==="undefined"||x.length===0));if(A&&!C.overwriteCache&&u[D]){p(D,y,z,C)}else{if(A&&!C.overwriteCache&&u.hasOwnProperty(D)){c(D,y,z,C)}else{if(A){l(D,y,z,C)}else{n(x,y,z,C)}}}return this}function b(y,x){if(x){h[y]=x}else{h=a.extend(h,y)}}function g(x){return typeof x==="string"&&x.indexOf("/")>-1}function r(G,y,D){D=D||{};var x=this,H=y.length,A=D.prepend&&!D.append,z=0,F=0,B=false,C;if(D.paged){var E=(D.pageNo-1)*D.elemPerPage;y=y.slice(E,E+D.elemPerPage);H=y.length}C=a.extend({},D,{complete:function(){if(A){x.prepend(this.html())}else{x.append(this.html())}z++;if(z===H||B){if(B&&D&&typeof D.error==="function"){D.error.call(x)}if(D&&typeof D.complete==="function"){D.complete()}}},success:function(){F++;if(F===H){if(D&&typeof D.success==="function"){D.success()}}},error:function(){B=true}});if(!D.append&&!D.prepend){x.html("")}if(A){y.reverse()}a(y).each(function(){var I=a("
    ");m.call(I,G,this,C);if(B){return false}});return this}function c(A,y,x,z){if(t[A]){t[A].push({data:x,selection:y,settings:z})}else{t[A]=[{data:x,selection:y,settings:z}]}}function p(B,z,y,A){var x=u[B].clone();o.call(z,x,y,A);if(typeof A.success==="function"){A.success()}}function v(){return new Date().getTime()}function w(x){if(x.indexOf("?")!==-1){return x+"&_="+v()}else{return x+"?_="+v()}}function l(B,z,y,A){var x=a("
    ");u[B]=null;var C=B;if(A.overwriteCache){C=w(C)}a.ajax({url:C,async:A.async,success:function(D){x.html(D);k(x,B,z,y,A)},error:function(){j(B,z,y,A)}})}function n(x,A,z,B){var y=a("
    ");if(x.is("script")){x=a.parseHTML(a.trim(x.html()))}y.html(x);o.call(A,y,z,B);if(typeof B.success==="function"){B.success()}}function o(z,x,y){f(z,x);a(this).each(function(){var A=a(z.html());if(y.beforeInsert){y.beforeInsert(A)}if(y.append){a(this).append(A)}else{if(y.prepend){a(this).prepend(A)}else{a(this).html(A)}}if(y.afterInsert){y.afterInsert(A)}});if(typeof y.complete==="function"){y.complete.call(a(this))}}function j(A,y,x,z){var B;if(typeof z.error==="function"){z.error.call(y)}a(t[A]).each(function(C,D){if(typeof D.settings.error==="function"){D.settings.error.call(D.selection)}});if(typeof z.complete==="function"){z.complete.call(y)}while(t[A]&&(B=t[A].shift())){if(typeof B.settings.complete==="function"){B.settings.complete.call(B.selection)}}if(typeof t[A]!=="undefined"&&t[A].length>0){t[A]=[]}}function k(x,B,z,y,A){var C;u[B]=x.clone();o.call(z,x,y,A);if(typeof A.success==="function"){A.success.call(z)}while(t[B]&&(C=t[B].shift())){o.call(C.selection,u[B].clone(),C.data,C.settings);if(typeof C.settings.success==="function"){C.settings.success.call(C.selection)}}}function f(y,x){x=x||{};s("data-content",y,x,function(z,A){z.html(e(z,A,"content"))});s("data-content-append",y,x,function(z,A){z.append(e(z,A,"content"))});s("data-content-prepend",y,x,function(z,A){z.prepend(e(z,A,"content"))});s("data-content-text",y,x,function(z,A){z.text(e(z,A,"content"))});s("data-src",y,x,function(z,A){z.attr("src",e(z,A,"src"))},function(z){z.remove()});s("data-alt",y,x,function(z,A){z.attr("alt",e(z,A,"alt"))});s("data-value",y,x,function(z,A){z.attr("value",e(z,A,"value"))});s("data-link",y,x,function(z,B){var A=a("");A.attr("href",e(z,B,"link"));A.html(z.html());z.html(A)});s("data-link-wrap",y,x,function(z,B){var A=a("");A.attr("href",e(z,B,"link-wrap"));z.wrap(A)});s("data-options",y,x,function(z,A){a(A).each(function(){var B=a("
    - -
    -
    -
    -

    Display

    -
    -
    -
    -
    -
    -
    -
    -

    Code

    -
    -
    -                        
    -                        
    -                    
    -
    -
    -
    - - - + + + + + Examples + + + + + + + + + +
    +

    Examples of jQuery.loadTemplate

    +
    + +
    +
    +
    + +
    +
    +
    +
    +
    +

    Display

    +
    +
    +
    +
    +
    +
    +
    +

    Code

    +
    +
    +                        
    +                        
    +                    
    +
    +
    +
    + + + diff --git a/readme.md b/readme.md index d296d8b..349eeec 100644 --- a/readme.md +++ b/readme.md @@ -1,143 +1,155 @@ -# jQuery.loadTemplate - -jQuery Template is a jQuery plugin that makes using templates easy and quick. The plugin supports loading HTML files as templates, or taking a jQuery object as the template (usually using script tags to hold the template). - -## Features - -jQuery.LoadTemplate provides the following: - -- Define Templates to display data -- Provide Formatters to process data into a more readable format -- Cache templates and data client side and pass processing to the client, allowing for a great user experience. -- Powerful but simple syntax, utilising pure html for templates. - -## Getting Started - -Simply clone the repo. The only file required is the jquery.loadTemplate-version.js file in the jquery.loadTemplate folder. There is also a folder for examples in the same folder. Take a look at the index file in here for examples and the code to create the examples. - -To see examples of usage, visit the project page: [http://codepb.github.io/jquery-template/](http://codepb.github.io/jquery-template/) - -## Potential Applications - -jQuery.loadTemplate was originally designed with a single page application for a blog in mind. The idea was to create templates for blog posts, post snippets, etc. This could then be called from the client when required, and cached. The post data was sent as a JSON object from the server, and processed into the templates using the plugin. This meant a very light load on the server, and a great user experience, with smooth page transitions, and JavaScript engines doing all the work. - -However I saw many other potential applications for this. Any application that deals with a large amount of data displayed in a regular format, for example search results, live commentary, blogs, online stores, social media sites, and the list could go on. - -## How it works - -The plugin parses a template using data attributes to populate the data. Simply pass in a JavaScript object, and the plugin does the rest. - -An example template is below: - - - -And to use this do the following: - - $("#template-container").loadTemplate($("#template"), - { - author: 'Joe Bloggs', - date: '25th May 2013', - authorPicture: 'Authors/JoeBloggs.jpg', - post: 'This is the contents of my post' - }); - -Similarly the content of the template could be held in a separate html file without the enclosing script tag, and used like the following: - - $("#template-container").loadTemplate("Templates/template.html", - { - author: 'Joe Bloggs', - date: '25th May 2013', - authorPicture: 'Authors/JoeBloggs.jpg', - post: 'This is the contents of my post' - }); - -The plugin has a number of data-... attributes that can be used to populate various attributes with the data. There is also the powerful data-template-bind attribute that accepts a JSON object, enabling binding to any attribute, or the content of the element. - -### Data Formatters - -It is also possible to define data formatters. These are assigned through the `$.addTemplateFormatter` method. This function either accepts a map of functions and the keys that they will be referenced by, or a single function with a single key as two separate parameters. Each formatter takes two values, the value being assigned, and a template to use to define how this data is displayed. The data-format-template may be empty. Example usage of this is below: - - $.addTemplateFormatter("UpperCaseFormatter", - function(value, template) { - return value.toUpperCase(); - }); - -Alternatively with a map: - - $.addTemplateFormatter({ - UpperCaseFormatter : function(value, template) { - return value.toUpperCase(); - }, - LowerCaseFormatter : function(value, template) { - return value.toLowerCase(); - }, - SameCaseFormatter : function(value, template) { - if(template == "upper") { - return value.toUpperCase(); - } else { - return value.toLowerCase(); - } - } - }); - -To call these formatters, simply the following will work: - -
    - -Formatters must be added before they are used else a template will not be able to access them. Formatters are used at the time of populating the data. You can also target any binding with the "data-format-target". The value of this is the binding to target so to target data-alt binding, set 'data-format-target="alt"'. - -### Bindings -There are a number of different bindings and ways to bind the data. The following attributes are available: - -- "data-content" - binds the value supplied to the content of the element (uses $(elem).html(value)) -- "data-content-append" - appends the value to the end of the element (uses $(elem).append(value)) -- "data-content-prepend" - prepends the value to the beginning of the element (uses $(elem).prepend(value)) -- "data-alt" - sets the alt value of the element to the value provided (uses $(elem).attr("alt", value)); -- "data-value" - sets the value attribute of the element to the value provided (uses $(elem).val(value)) -- "data-link" - sets the innerHtml of the element to be a link to the value provided (wraps the content in an <a> tag). -- "data-link-wrap" - wraps the element in a link to the value provided. Same as "data-link", but the <a> tag wraps the element as well as the content. -- "data-options" - adds options to a select box. The value for this should reference an array of strings, each option will be output as a separate option. The value will be the same as the displayed text for each option. For a more powerful version of this look at the data-template-bind option. - -On top of the attributes above, there is also a "data-template-bind" attribute. This is designed to handle more complex situations and allows a wide range of control. The attribute takes a JSON string and allows multiple bindings and options to be set in the one attribute. - -The "data-template-bind" value should be an array of objects. Each object represents one complete binding. Each object can contain the following properties: - -- "value" (required) - The property representing the value to bind to. -- "attribute" (required) - The attribute to bind to. This can be any attribute accepted by the jQuery.attr() method or one of the following: "content" - same as data-content, binds the innerHTML, "contentAppend" - same as data-append, appends the value, "contentPrepend" - same as data-prepend, prepends the value, "options" - same as data-options, but provides greater control. The value attribute for this is an object with a value property and a content property, and this will bind the value of the option to the value property, and the innerText of the option to the content property. -- "formatter" (optional) - provides the formatter to apply to the specific binding. Multiple different attributes can use different formatters using this syntax. -- "formatOptions" (optional) - the options to pass to the formatter applied. - -An example of using the "data-template-bind" attribute would be the following: - -
    - -### Options - -There are a number of options the plugin accepts. These are: - -- "overwriteCache" (default false) - Whether to ignore the cache and reload the template (if you've previously loaded the template, but it might have changed, you'll want to set this to true. -- "complete" (default null) - Callback function to call on complete. Will always be called regardless of success or failure. -- "success" (default null) - Callback function to call on successful completion. -- "error" (default, outputting error message to template container) - Callback function to call on error. -- "errorMessage" (default "There was an error loading the template.") - Error message for the default error callback to use. This will not be used if you set an error callback function. -- "isFile" (default undefined) - flag to help speed up the process of deciding where to load the template from. Set to true if the template is an external file to load via ajax, false if it's a jQuery selector for an element in the document. Default undefined means the plugin will check first in the document, then attempt to load external file. -- "paged" (default false) - A boolean flag to indicate whether arrays should be paged. -- "pageNo" (default 1) - An integer for which page to display if the data is being paged. -- "elemPerPage" (default 10) - The number of elements to display per page if the data is being paged. -- "append" (default false) - If set to true, the template will be appended to the element rather than replacing the contents of the element. -- "prepend" (default false) - If set to true, the template will be prepended to the element rather than replacing the contents of the element. The append option takes priority over prepend, so if both options are set to true, the element is appended and not prepended. -- "beforeInsert" (default null) - Callback function to be called before inserting the template into the document. The format of the function is function($elem) where $elem is the jQuery object of the populated template about to be inserted into the document. -- "afterInsert" (default null) - As above, a callback function to be called after inserting the template into the document. The format is the same as above. - -## Future Plans - +# jQuery.loadTemplate + +jQuery Template is a jQuery plugin that makes using templates easy and quick. The plugin supports loading HTML files as templates, or taking a jQuery object as the template (usually using script tags to hold the template). + +## Features + +jQuery.LoadTemplate provides the following: + +- Define Templates to display data +- Provide Formatters to process data into a more readable format +- Cache templates and data client side and pass processing to the client, allowing for a great user experience. +- Powerful but simple syntax, utilising pure html for templates. + +## Getting Started + +Simply clone the repo. The only file required is the jquery.loadTemplate-version.js file in the jquery.loadTemplate folder. There is also a folder for examples in the same folder. Take a look at the index file in here for examples and the code to create the examples. + +To see examples of usage, visit the project page: [http://codepb.github.io/jquery-template/](http://codepb.github.io/jquery-template/) + +## Potential Applications + +jQuery.loadTemplate was originally designed with a single page application for a blog in mind. The idea was to create templates for blog posts, post snippets, etc. This could then be called from the client when required, and cached. The post data was sent as a JSON object from the server, and processed into the templates using the plugin. This meant a very light load on the server, and a great user experience, with smooth page transitions, and JavaScript engines doing all the work. + +However I saw many other potential applications for this. Any application that deals with a large amount of data displayed in a regular format, for example search results, live commentary, blogs, online stores, social media sites, and the list could go on. + +## How it works + +The plugin parses a template using data attributes to populate the data. Simply pass in a JavaScript object, and the plugin does the rest. + +An example template is below: + + + +And to use this do the following: + + $("#template-container").loadTemplate($("#template"), + { + author: 'Joe Bloggs', + date: '25th May 2013', + authorPicture: 'Authors/JoeBloggs.jpg', + post: 'This is the contents of my post' + }); + +Similarly the content of the template could be held in a separate html file without the enclosing script tag, and used like the following: + + $("#template-container").loadTemplate("Templates/template.html", + { + author: 'Joe Bloggs', + date: '25th May 2013', + authorPicture: 'Authors/JoeBloggs.jpg', + post: 'This is the contents of my post' + }); + +Several options can be passed as function parameters. For example, to specify that 'null' values should not be rendered, load the template like this: + + $("#template-container").loadTemplate("Templates/template.html", + { + author: 'Joe Bloggs', + date: null, + authorPicture: 'Authors/JoeBloggs.jpg', + post: 'This is the contents of my post' + }, {"ignoreNull": true}}); + +In addition, the plugin has a number of data-... attributes that can be used to populate various attributes with the data. There is also the powerful data-template-bind attribute that accepts a JSON object, enabling binding to any attribute, or the content of the element. + +### Data Formatters + +It is also possible to define data formatters. These are assigned through the `$.addTemplateFormatter` method. This function either accepts a map of functions and the keys that they will be referenced by, or a single function with a single key as two separate parameters. Each formatter takes two values, the value being assigned, and a template to use to define how this data is displayed. The data-format-template may be empty. Example usage of this is below: + + $.addTemplateFormatter("UpperCaseFormatter", + function(value, template) { + return value.toUpperCase(); + }); + +Alternatively with a map: + + $.addTemplateFormatter({ + UpperCaseFormatter : function(value, template) { + return value.toUpperCase(); + }, + LowerCaseFormatter : function(value, template) { + return value.toLowerCase(); + }, + SameCaseFormatter : function(value, template) { + if(template == "upper") { + return value.toUpperCase(); + } else { + return value.toLowerCase(); + } + } + }); + +To call these formatters, simply the following will work: + +
    + +Formatters must be added before they are used else a template will not be able to access them. Formatters are used at the time of populating the data. You can also target any binding with the "data-format-target". The value of this is the binding to target so to target data-alt binding, set 'data-format-target="alt"'. + +### Bindings +There are a number of different bindings and ways to bind the data. The following attributes are available: + +- "data-content" - binds the value supplied to the content of the element (uses $(elem).html(value)) +- "data-content-append" - appends the value to the end of the element (uses $(elem).append(value)) +- "data-content-prepend" - prepends the value to the beginning of the element (uses $(elem).prepend(value)) +- "data-alt" - sets the alt value of the element to the value provided (uses $(elem).attr("alt", value)); +- "data-value" - sets the value attribute of the element to the value provided (uses $(elem).val(value)) +- "data-link" - sets the innerHtml of the element to be a link to the value provided (wraps the content in an <a> tag). +- "data-link-wrap" - wraps the element in a link to the value provided. Same as "data-link", but the <a> tag wraps the element as well as the content. +- "data-options" - adds options to a select box. The value for this should reference an array of strings, each option will be output as a separate option. The value will be the same as the displayed text for each option. For a more powerful version of this look at the data-template-bind option. +- "data-binding-options" - Overrides global binding options passed as function parameters for this binding. For details check the options section below. +On top of the attributes above, there is also a "data-template-bind" attribute. This is designed to handle more complex situations and allows a wide range of control. The attribute takes a JSON string and allows multiple bindings and options to be set in the one attribute. + +The "data-template-bind" value should be an array of objects. Each object represents one complete binding. Each object can contain the following properties: + +- "value" (required) - The property representing the value to bind to. +- "attribute" (required) - The attribute to bind to. This can be any attribute accepted by the jQuery.attr() method or one of the following: "content" - same as data-content, binds the innerHTML, "contentAppend" - same as data-append, appends the value, "contentPrepend" - same as data-prepend, prepends the value, "options" - same as data-options, but provides greater control. The value attribute for this is an object with a value property and a content property, and this will bind the value of the option to the value property, and the innerText of the option to the content property. +- "formatter" (optional) - provides the formatter to apply to the specific binding. Multiple different attributes can use different formatters using this syntax. +- "formatOptions" (optional) - the options to pass to the formatter applied. +- "bindingOptions" (optional) - Overrides global binding options passed as function parameters for this binding. For details check the options section below. + +An example of using the "data-template-bind" attribute would be the following: + +
    + +### Options + +There are a number of options the plugin accepts. These are: + +- "overwriteCache" (default false) - Whether to ignore the cache and reload the template (if you've previously loaded the template, but it might have changed, you'll want to set this to true. +- "complete" (default null) - Callback function to call on complete. Will always be called regardless of success or failure. +- "success" (default null) - Callback function to call on successful completion. +- "error" (default, outputting error message to template container) - Callback function to call on error. +- "errorMessage" (default "There was an error loading the template.") - Error message for the default error callback to use. This will not be used if you set an error callback function. +- "isFile" (default undefined) - flag to help speed up the process of deciding where to load the template from. Set to true if the template is an external file to load via ajax, false if it's a jQuery selector for an element in the document. Default undefined means the plugin will check first in the document, then attempt to load external file. +- "paged" (default false) - A boolean flag to indicate whether arrays should be paged. +- "pageNo" (default 1) - An integer for which page to display if the data is being paged. +- "elemPerPage" (default 10) - The number of elements to display per page if the data is being paged. +- "append" (default false) - If set to true, the template will be appended to the element rather than replacing the contents of the element. +- "prepend" (default false) - If set to true, the template will be prepended to the element rather than replacing the contents of the element. The append option takes priority over prepend, so if both options are set to true, the element is appended and not prepended. +- "beforeInsert" (default null) - Callback function to be called before inserting the template into the document. The format of the function is function($elem) where $elem is the jQuery object of the populated template about to be inserted into the document. +- "afterInsert" (default null) - As above, a callback function to be called after inserting the template into the document. The format is the same as above. +- "bindingOptions" (default all flags false): add flags to ignore certain types of values. {"ignoreUndefined": false, "ignoreNull": false, "ignoreEmptyString": false}. The flags you set here, are overwritten on an element level by those specified in a template with a "data-binding-options" or a "data-template-bind" attribute. Examples can be found in the Examples/OptionalBinding folder. + +## Future Plans + I would like to develop the plugin further so it would be possible to watch the objects holding the data, so any changes to the data would be reflected in the UI. This would have to be simple, lightweight, and ideally would work just with natural JavaScript objects. I also welcome any ideas as to how the plugin could be improved. \ No newline at end of file From d92fe8a4dce931e6959d663c90c078518f26da09 Mon Sep 17 00:00:00 2001 From: Diego Adolf Date: Thu, 6 Feb 2014 10:32:42 +0100 Subject: [PATCH 32/71] Settings are now inherted in $.loadTemplate calls for nested templates (optional binding works for nested templates now) --- Examples/OptionalBinding/example.html | 132 ++++++++++-------- .../jquery.loadTemplate-1.3.2.js | 2 +- 2 files changed, 74 insertions(+), 60 deletions(-) diff --git a/Examples/OptionalBinding/example.html b/Examples/OptionalBinding/example.html index 59fdab8..1f59f70 100644 --- a/Examples/OptionalBinding/example.html +++ b/Examples/OptionalBinding/example.html @@ -1,59 +1,73 @@ - - - - - - - - - - - -
    -Loaded with function parameters -
    -
    - -
    - -
    -Loaded with template parameters -
    -
    - -
    - -
    -Loaded with template as data-bind-template attribute -
    -
    - - + + + + + + + + + + + + + + +
    +Loaded with function parameters +
    +
    + +
    + +
    +Loaded with template parameters +
    +
    + +
    + +
    +Loaded with template as data-bind-template attribute +
    +
    + +
    +Loaded with nested template with function parameters +
    +
    + diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.3.2.js b/jquery-loadTemplate/jquery.loadTemplate-1.3.2.js index bd1be3c..6278ac3 100644 --- a/jquery-loadTemplate/jquery.loadTemplate-1.3.2.js +++ b/jquery-loadTemplate/jquery.loadTemplate-1.3.2.js @@ -486,7 +486,7 @@ var parentElement = options.parentElement || "div"; var template = options.template || options; - return $("<" + parentElement + "/>").loadTemplate(template, value); + return $("<" + parentElement + "/>").loadTemplate(template, value, settings); }); $.fn.loadTemplate = loadTemplate; $.addTemplateFormatter = addTemplateFormatter; From b0fa5ad281b71103a5231d72f4aefefeb455ba18 Mon Sep 17 00:00:00 2001 From: Diego Adolf Date: Thu, 6 Feb 2014 10:37:32 +0100 Subject: [PATCH 33/71] Corrected example for optional binding --- Examples/OptionalBinding/example.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/OptionalBinding/example.html b/Examples/OptionalBinding/example.html index 1f59f70..2efd244 100644 --- a/Examples/OptionalBinding/example.html +++ b/Examples/OptionalBinding/example.html @@ -38,7 +38,7 @@

    Name:

    articles: data}; $(document).ready(function(){ - $("#loadedWithFunctionParameters").loadTemplate($("#template"), data, {bindingOptions: {"ignoreUndefined": false, "ignoreNull": false}}); + $("#loadedWithFunctionParameters").loadTemplate($("#template"), data, {bindingOptions: {"ignoreUndefined": true, "ignoreNull": true}}); $("#loadedWithTemplateParameters").loadTemplate($("#templateWithParamters"), data); $("#bindingOptionsContainer").loadTemplate($("#templateWithBindingOptionsAsDataBindTemplateAttribute"), data); $("#containerForNestedTemplate").loadTemplate($("#wrapperForNestedTemplate"), nestedData, {bindingOptions: {"ignoreUndefined": true, "ignoreNull": true}}); From 80232245f6b3b36b043888df83186f7d268bf24d Mon Sep 17 00:00:00 2001 From: Paul Burgess Date: Sun, 9 Feb 2014 00:30:55 +0000 Subject: [PATCH 34/71] Updating to 1.4 Merged in Binding options and made fix for nested templates. Restructured to better scope the settings --- Examples/OptionalBinding/example.html | 3 - Examples/index.html | 102 +--------- .../jquery.loadTemplate-1.3.4.min.js | 1 - ...-1.3.4.js => jquery.loadTemplate-1.4.0.js} | 178 +++++++++--------- .../jquery.loadTemplate-1.4.0.min.js | 1 + loadTemplate.jquery.json | 2 +- readme.md | 156 --------------- tests/index.html | 2 +- 8 files changed, 95 insertions(+), 350 deletions(-) delete mode 100644 jquery-loadTemplate/jquery.loadTemplate-1.3.4.min.js rename jquery-loadTemplate/{jquery.loadTemplate-1.3.4.js => jquery.loadTemplate-1.4.0.js} (77%) create mode 100644 jquery-loadTemplate/jquery.loadTemplate-1.4.0.min.js diff --git a/Examples/OptionalBinding/example.html b/Examples/OptionalBinding/example.html index 2efd244..05aa2f8 100644 --- a/Examples/OptionalBinding/example.html +++ b/Examples/OptionalBinding/example.html @@ -1,6 +1,3 @@ - - - - - - -
    -

    Examples of jQuery.loadTemplate

    -
    - -
    -
    -
    - -
    -
    -
    -
    -
    -

    Display

    -
    -
    -
    -
    -
    -
    -
    -

    Code

    -
    -
    -                        
    -                        
    -                    
    -
    -
    -
    - - - -======= - - - - - Examples - - - - - - - +
    @@ -195,4 +96,3 @@

    Code

    ->>>>>>> b0fa5ad281b71103a5231d72f4aefefeb455ba18 diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.3.4.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.3.4.min.js deleted file mode 100644 index b957523..0000000 --- a/jquery-loadTemplate/jquery.loadTemplate-1.3.4.min.js +++ /dev/null @@ -1 +0,0 @@ -(function(a){var u={},t={},h={};function m(D,z,B){var y=this,x,C,A;z=z||{};C=a.extend({async:true,overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(C.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null},B);if(a.type(z)==="array"){return r.call(this,D,z,C)}if(!g(D)){x=a(D);if(typeof D==="string"&&D.indexOf("#")===0){C.isFile=false}}A=C.isFile||(typeof C.isFile==="undefined"&&(typeof x==="undefined"||x.length===0));if(A&&!C.overwriteCache&&u[D]){p(D,y,z,C)}else{if(A&&!C.overwriteCache&&u.hasOwnProperty(D)){c(D,y,z,C)}else{if(A){l(D,y,z,C)}else{n(x,y,z,C)}}}return this}function b(y,x){if(x){h[y]=x}else{h=a.extend(h,y)}}function g(x){return typeof x==="string"&&x.indexOf("/")>-1}function r(G,y,D){D=D||{};var x=this,H=y.length,A=D.prepend&&!D.append,z=0,F=0,B=false,C;if(D.paged){var E=(D.pageNo-1)*D.elemPerPage;y=y.slice(E,E+D.elemPerPage);H=y.length}C=a.extend({},D,{complete:function(){if(A){x.prepend(this.html())}else{x.append(this.html())}z++;if(z===H||B){if(B&&D&&typeof D.error==="function"){D.error.call(x)}if(D&&typeof D.complete==="function"){D.complete()}}},success:function(){F++;if(F===H){if(D&&typeof D.success==="function"){D.success()}}},error:function(){B=true}});if(!D.append&&!D.prepend){x.html("")}if(A){y.reverse()}a(y).each(function(){var I=a("
    ");m.call(I,G,this,C);if(B){return false}});return this}function c(A,y,x,z){if(t[A]){t[A].push({data:x,selection:y,settings:z})}else{t[A]=[{data:x,selection:y,settings:z}]}}function p(B,z,y,A){var x=u[B].clone();o.call(z,x,y,A);if(typeof A.success==="function"){A.success()}}function v(){return new Date().getTime()}function w(x){if(x.indexOf("?")!==-1){return x+"&_="+v()}else{return x+"?_="+v()}}function l(B,z,y,A){var x=a("
    ");u[B]=null;var C=B;if(A.overwriteCache){C=w(C)}a.ajax({url:C,async:A.async,success:function(D){x.html(D);k(x,B,z,y,A)},error:function(){j(B,z,y,A)}})}function n(x,A,z,B){var y=a("
    ");if(x.is("script")){x=a.parseHTML(a.trim(x.html()))}y.html(x);o.call(A,y,z,B);if(typeof B.success==="function"){B.success()}}function o(z,x,y){f(z,x);a(this).each(function(){var A=a(z.html());if(y.beforeInsert){y.beforeInsert(A)}if(y.append){a(this).append(A)}else{if(y.prepend){a(this).prepend(A)}else{a(this).html(A)}}if(y.afterInsert){y.afterInsert(A)}});if(typeof y.complete==="function"){y.complete.call(a(this))}}function j(A,y,x,z){var B;if(typeof z.error==="function"){z.error.call(y)}a(t[A]).each(function(C,D){if(typeof D.settings.error==="function"){D.settings.error.call(D.selection)}});if(typeof z.complete==="function"){z.complete.call(y)}while(t[A]&&(B=t[A].shift())){if(typeof B.settings.complete==="function"){B.settings.complete.call(B.selection)}}if(typeof t[A]!=="undefined"&&t[A].length>0){t[A]=[]}}function k(x,B,z,y,A){var C;u[B]=x.clone();o.call(z,x,y,A);if(typeof A.success==="function"){A.success.call(z)}while(t[B]&&(C=t[B].shift())){o.call(C.selection,u[B].clone(),C.data,C.settings);if(typeof C.settings.success==="function"){C.settings.success.call(C.selection)}}}function f(y,x){x=x||{};s("data-content",y,x,function(z,A){z.html(e(z,A,"content"))});s("data-content-append",y,x,function(z,A){z.append(e(z,A,"content"))});s("data-content-prepend",y,x,function(z,A){z.prepend(e(z,A,"content"))});s("data-content-text",y,x,function(z,A){z.text(e(z,A,"content"))});s("data-src",y,x,function(z,A){z.attr("src",e(z,A,"src"))},function(z){z.remove()});s("data-alt",y,x,function(z,A){z.attr("alt",e(z,A,"alt"))});s("data-value",y,x,function(z,A){z.attr("value",e(z,A,"value"))});s("data-link",y,x,function(z,B){var A=a("");A.attr("href",e(z,B,"link"));A.html(z.html());z.html(A)});s("data-link-wrap",y,x,function(z,B){var A=a("");A.attr("href",e(z,B,"link-wrap"));z.wrap(A)});s("data-options",y,x,function(z,A){a(A).each(function(){var B=a(""); - $linkElem.attr("href", applyFormatters($elem, value, "link")); + $linkElem.attr("href", applyFormatters($elem, value, "link", settings)); $linkElem.html($elem.html()); $elem.html($linkElem); }); - processElements("data-link-wrap", template, data, function ($elem, value) { + processElements("data-link-wrap", template, data, settings, function ($elem, value) { var $linkElem = $(""); - $linkElem.attr("href", applyFormatters($elem, value, "link-wrap")); + $linkElem.attr("href", applyFormatters($elem, value, "link-wrap", settings)); $elem.wrap($linkElem); }); - processElements("data-options", template, data, function ($elem, value) { + processElements("data-options", template, data, settings, function ($elem, value) { $(value).each(function () { var $option = $("
    ");n.call(K,I,this,E);if(D){return false}});return this}function c(C,A,z,B){if(u[C]){u[C].push({data:z,selection:A,settings:B})}else{u[C]=[{data:z,selection:A,settings:B}]}}function q(D,B,A,C){var z=v[D].clone();p.call(B,z,A,C);if(typeof C.success==="function"){C.success()}}function w(){return new Date().getTime()}function x(z){if(z.indexOf("?")!==-1){return z+"&_="+w()}else{return z+"?_="+w()}}function m(D,B,A,C){var z=a("
    ");v[D]=null;var E=D;if(C.overwriteCache){E=x(E)}a.ajax({url:E,async:C.async,success:function(F){z.html(F);l(z,D,B,A,C)},error:function(){k(D,B,A,C)}})}function o(z,C,B,D){var A=a("
    ");if(z.is("script")){z=a.parseHTML(a.trim(z.html()))}A.html(z);p.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function p(B,z,A){f(B,z,A);a(this).each(function(){var C=a(B.html());if(A.beforeInsert){A.beforeInsert(C)}if(A.append){a(this).append(C)}else{if(A.prepend){a(this).prepend(C)}else{a(this).html(C)}}if(A.afterInsert){A.afterInsert(C)}});if(typeof A.complete==="function"){A.complete.call(a(this))}}function k(C,A,z,B){var D;if(typeof B.error==="function"){B.error.call(A)}a(u[C]).each(function(E,F){if(typeof F.settings.error==="function"){F.settings.error.call(F.selection)}});if(typeof B.complete==="function"){B.complete.call(A)}while(u[C]&&(D=u[C].shift())){if(typeof D.settings.complete==="function"){D.settings.complete.call(D.selection)}}if(typeof u[C]!=="undefined"&&u[C].length>0){u[C]=[]}}function l(z,D,B,A,C){var E;v[D]=z.clone();p.call(B,z,A,C);if(typeof C.success==="function"){C.success.call(B)}while(u[D]&&(E=u[D].shift())){p.call(E.selection,v[D].clone(),E.data,E.settings);if(typeof E.settings.success==="function"){E.settings.success.call(E.selection)}}}function f(B,z,A){z=z||{};t("data-content",B,z,A,function(C,D){C.html(e(C,D,"content",A))});t("data-content-append",B,z,A,function(C,D){C.append(e(C,D,"content",A))});t("data-content-prepend",B,z,A,function(C,D){C.prepend(e(C,D,"content",A))});t("data-content-text",B,z,A,function(C,D){C.text(e(C,D,"content",A))});t("data-src",B,z,A,function(C,D){C.attr("src",e(C,D,"src",A))},function(C){C.remove()});t("data-alt",B,z,A,function(C,D){C.attr("alt",e(C,D,"alt",A))});t("data-value",B,z,A,function(C,D){C.attr("value",e(C,D,"value",A))});t("data-link",B,z,A,function(C,E){var D=a("");D.attr("href",e(C,E,"link",A));D.html(C.html());C.html(D)});t("data-link-wrap",B,z,A,function(C,E){var D=a("");D.attr("href",e(C,E,"link-wrap",A));C.wrap(D)});t("data-options",B,z,A,function(C,D){a(D).each(function(){var E=a("

    Example of loading a template from a script tag within the same document.
    +
    + + + + + + diff --git a/Examples/index.html b/Examples/index.html index b17919d..97b7e80 100644 --- a/Examples/index.html +++ b/Examples/index.html @@ -9,7 +9,7 @@ - +
    diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.4.0.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.4.0.min.js deleted file mode 100644 index 0ae3334..0000000 --- a/jquery-loadTemplate/jquery.loadTemplate-1.4.0.min.js +++ /dev/null @@ -1 +0,0 @@ -(function(a){var v={},u={},h={};function n(F,B,D){var A=this,z,C,E;B=B||{};E=a.extend(true,{async:true,overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(E.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null,bindingOptions:{ignoreUndefined:false,ignoreNull:false,ignoreEmptyString:false}},D);if(a.type(B)==="array"){return s.call(this,F,B,E)}if(!g(F)){z=a(F);if(typeof F==="string"&&F.indexOf("#")===0){E.isFile=false}}C=E.isFile||(typeof E.isFile==="undefined"&&(typeof z==="undefined"||z.length===0));if(C&&!E.overwriteCache&&v[F]){q(F,A,B,E)}else{if(C&&!E.overwriteCache&&v.hasOwnProperty(F)){c(F,A,B,E)}else{if(C){m(F,A,B,E)}else{o(z,A,B,E)}}}return this}function b(A,z){if(z){h[A]=z}else{h=a.extend(h,A)}}function g(z){return typeof z==="string"&&z.indexOf("/")>-1}function s(I,A,F){F=F||{};var z=this,J=A.length,C=F.prepend&&!F.append,B=0,H=0,D=false,E;if(F.paged){var G=(F.pageNo-1)*F.elemPerPage;A=A.slice(G,G+F.elemPerPage);J=A.length}E=a.extend({},F,{complete:function(){if(C){z.prepend(this.html())}else{z.append(this.html())}B++;if(B===J||D){if(D&&F&&typeof F.error==="function"){F.error.call(z)}if(F&&typeof F.complete==="function"){F.complete()}}},success:function(){H++;if(H===J){if(F&&typeof F.success==="function"){F.success()}}},error:function(){D=true}});if(!F.append&&!F.prepend){z.html("")}if(C){A.reverse()}a(A).each(function(){var K=a("
    ");n.call(K,I,this,E);if(D){return false}});return this}function c(C,A,z,B){if(u[C]){u[C].push({data:z,selection:A,settings:B})}else{u[C]=[{data:z,selection:A,settings:B}]}}function q(D,B,A,C){var z=v[D].clone();p.call(B,z,A,C);if(typeof C.success==="function"){C.success()}}function w(){return new Date().getTime()}function x(z){if(z.indexOf("?")!==-1){return z+"&_="+w()}else{return z+"?_="+w()}}function m(D,B,A,C){var z=a("
    ");v[D]=null;var E=D;if(C.overwriteCache){E=x(E)}a.ajax({url:E,async:C.async,success:function(F){z.html(F);l(z,D,B,A,C)},error:function(){k(D,B,A,C)}})}function o(z,C,B,D){var A=a("
    ");if(z.is("script")){z=a.parseHTML(a.trim(z.html()))}A.html(z);p.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function p(B,z,A){f(B,z,A);a(this).each(function(){var C=a(B.html());if(A.beforeInsert){A.beforeInsert(C)}if(A.append){a(this).append(C)}else{if(A.prepend){a(this).prepend(C)}else{a(this).html(C)}}if(A.afterInsert){A.afterInsert(C)}});if(typeof A.complete==="function"){A.complete.call(a(this))}}function k(C,A,z,B){var D;if(typeof B.error==="function"){B.error.call(A)}a(u[C]).each(function(E,F){if(typeof F.settings.error==="function"){F.settings.error.call(F.selection)}});if(typeof B.complete==="function"){B.complete.call(A)}while(u[C]&&(D=u[C].shift())){if(typeof D.settings.complete==="function"){D.settings.complete.call(D.selection)}}if(typeof u[C]!=="undefined"&&u[C].length>0){u[C]=[]}}function l(z,D,B,A,C){var E;v[D]=z.clone();p.call(B,z,A,C);if(typeof C.success==="function"){C.success.call(B)}while(u[D]&&(E=u[D].shift())){p.call(E.selection,v[D].clone(),E.data,E.settings);if(typeof E.settings.success==="function"){E.settings.success.call(E.selection)}}}function f(B,z,A){z=z||{};t("data-content",B,z,A,function(C,D){C.html(e(C,D,"content",A))});t("data-content-append",B,z,A,function(C,D){C.append(e(C,D,"content",A))});t("data-content-prepend",B,z,A,function(C,D){C.prepend(e(C,D,"content",A))});t("data-content-text",B,z,A,function(C,D){C.text(e(C,D,"content",A))});t("data-src",B,z,A,function(C,D){C.attr("src",e(C,D,"src",A))},function(C){C.remove()});t("data-alt",B,z,A,function(C,D){C.attr("alt",e(C,D,"alt",A))});t("data-value",B,z,A,function(C,D){C.attr("value",e(C,D,"value",A))});t("data-link",B,z,A,function(C,E){var D=a("");D.attr("href",e(C,E,"link",A));D.html(C.html());C.html(D)});t("data-link-wrap",B,z,A,function(C,E){var D=a("");D.attr("href",e(C,E,"link-wrap",A));C.wrap(D)});t("data-options",B,z,A,function(C,D){a(D).each(function(){var E=a("
    "); - if ($template.is("script")) { + if ($template.is("script") || $template.is("template")) { $template = $.parseHTML($.trim($template.html())); } diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.4.1.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.4.1.min.js new file mode 100644 index 0000000..3e570eb --- /dev/null +++ b/jquery-loadTemplate/jquery.loadTemplate-1.4.1.min.js @@ -0,0 +1 @@ +(function(a){var v={},u={},h={};function n(F,B,D){var A=this,z,C,E;B=B||{};E=a.extend(true,{async:true,overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(E.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null,bindingOptions:{ignoreUndefined:false,ignoreNull:false,ignoreEmptyString:false}},D);if(a.type(B)==="array"){return s.call(this,F,B,E)}if(!g(F)){z=a(F);if(typeof F==="string"&&F.indexOf("#")===0){E.isFile=false}}C=E.isFile||(typeof E.isFile==="undefined"&&(typeof z==="undefined"||z.length===0));if(C&&!E.overwriteCache&&v[F]){q(F,A,B,E)}else{if(C&&!E.overwriteCache&&v.hasOwnProperty(F)){c(F,A,B,E)}else{if(C){m(F,A,B,E)}else{o(z,A,B,E)}}}return this}function b(A,z){if(z){h[A]=z}else{h=a.extend(h,A)}}function g(z){return typeof z==="string"&&z.indexOf("/")>-1}function s(I,A,F){F=F||{};var z=this,J=A.length,C=F.prepend&&!F.append,B=0,H=0,D=false,E;if(F.paged){var G=(F.pageNo-1)*F.elemPerPage;A=A.slice(G,G+F.elemPerPage);J=A.length}E=a.extend({},F,{complete:function(){if(this.html){if(C){z.prepend(this.html())}else{z.append(this.html())}}B++;if(B===J||D){if(D&&F&&typeof F.error==="function"){F.error.call(z)}if(F&&typeof F.complete==="function"){F.complete()}}},success:function(){H++;if(H===J){if(F&&typeof F.success==="function"){F.success()}}},error:function(){D=true}});if(!F.append&&!F.prepend){z.html("")}if(C){A.reverse()}a(A).each(function(){var K=a("
    ");n.call(K,I,this,E);if(D){return false}});return this}function c(C,A,z,B){if(u[C]){u[C].push({data:z,selection:A,settings:B})}else{u[C]=[{data:z,selection:A,settings:B}]}}function q(D,B,A,C){var z=v[D].clone();p.call(B,z,A,C);if(typeof C.success==="function"){C.success()}}function w(){return new Date().getTime()}function x(z){if(z.indexOf("?")!==-1){return z+"&_="+w()}else{return z+"?_="+w()}}function m(D,B,A,C){var z=a("
    ");v[D]=null;var E=D;if(C.overwriteCache){E=x(E)}a.ajax({url:E,async:C.async,success:function(F){z.html(F);l(z,D,B,A,C)},error:function(){k(D,B,A,C)}})}function o(z,C,B,D){var A=a("
    ");if(z.is("script")||z.is("template")){z=a.parseHTML(a.trim(z.html()))}A.html(z);p.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function p(B,z,A){f(B,z,A);a(this).each(function(){var C=a(B.html());if(A.beforeInsert){A.beforeInsert(C)}if(A.append){a(this).append(C)}else{if(A.prepend){a(this).prepend(C)}else{a(this).html(C)}}if(A.afterInsert){A.afterInsert(C)}});if(typeof A.complete==="function"){A.complete.call(a(this))}}function k(C,A,z,B){var D;if(typeof B.error==="function"){B.error.call(A)}a(u[C]).each(function(E,F){if(typeof F.settings.error==="function"){F.settings.error.call(F.selection)}});if(typeof B.complete==="function"){B.complete.call(A)}while(u[C]&&(D=u[C].shift())){if(typeof D.settings.complete==="function"){D.settings.complete.call(D.selection)}}if(typeof u[C]!=="undefined"&&u[C].length>0){u[C]=[]}}function l(z,D,B,A,C){var E;v[D]=z.clone();p.call(B,z,A,C);if(typeof C.success==="function"){C.success.call(B)}while(u[D]&&(E=u[D].shift())){p.call(E.selection,v[D].clone(),E.data,E.settings);if(typeof E.settings.success==="function"){E.settings.success.call(E.selection)}}}function f(B,z,A){z=z||{};t("data-content",B,z,A,function(C,D){C.html(e(C,D,"content",A))});t("data-content-append",B,z,A,function(C,D){C.append(e(C,D,"content",A))});t("data-content-prepend",B,z,A,function(C,D){C.prepend(e(C,D,"content",A))});t("data-content-text",B,z,A,function(C,D){C.text(e(C,D,"content",A))});t("data-src",B,z,A,function(C,D){C.attr("src",e(C,D,"src",A))},function(C){C.remove()});t("data-alt",B,z,A,function(C,D){C.attr("alt",e(C,D,"alt",A))});t("data-value",B,z,A,function(C,D){C.attr("value",e(C,D,"value",A))});t("data-link",B,z,A,function(C,E){var D=a("");D.attr("href",e(C,E,"link",A));D.html(C.html());C.html(D)});t("data-link-wrap",B,z,A,function(C,E){var D=a("");D.attr("href",e(C,E,"link-wrap",A));C.wrap(D)});t("data-options",B,z,A,function(C,D){a(D).each(function(){var E=a("
    diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.4.1.js b/jquery-loadTemplate/jquery.loadTemplate-1.4.2.js similarity index 99% rename from jquery-loadTemplate/jquery.loadTemplate-1.4.1.js rename to jquery-loadTemplate/jquery.loadTemplate-1.4.2.js index 8c12924..52c43a0 100644 --- a/jquery-loadTemplate/jquery.loadTemplate-1.4.1.js +++ b/jquery-loadTemplate/jquery.loadTemplate-1.4.2.js @@ -310,6 +310,10 @@ $elem.attr("alt", applyFormatters($elem, value, "alt", settings)); }); + processElements("data-id", template, data, settings, function ($elem, value) { + $elem.attr("id", applyFormatters($elem, value, "id", settings)); + }); + processElements("data-value", template, data, settings, function ($elem, value) { $elem.attr("value", applyFormatters($elem, value, "value", settings)); }); diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.4.1.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.4.2.min.js similarity index 56% rename from jquery-loadTemplate/jquery.loadTemplate-1.4.1.min.js rename to jquery-loadTemplate/jquery.loadTemplate-1.4.2.min.js index 3e570eb..c162670 100644 --- a/jquery-loadTemplate/jquery.loadTemplate-1.4.1.min.js +++ b/jquery-loadTemplate/jquery.loadTemplate-1.4.2.min.js @@ -1 +1 @@ -(function(a){var v={},u={},h={};function n(F,B,D){var A=this,z,C,E;B=B||{};E=a.extend(true,{async:true,overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(E.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null,bindingOptions:{ignoreUndefined:false,ignoreNull:false,ignoreEmptyString:false}},D);if(a.type(B)==="array"){return s.call(this,F,B,E)}if(!g(F)){z=a(F);if(typeof F==="string"&&F.indexOf("#")===0){E.isFile=false}}C=E.isFile||(typeof E.isFile==="undefined"&&(typeof z==="undefined"||z.length===0));if(C&&!E.overwriteCache&&v[F]){q(F,A,B,E)}else{if(C&&!E.overwriteCache&&v.hasOwnProperty(F)){c(F,A,B,E)}else{if(C){m(F,A,B,E)}else{o(z,A,B,E)}}}return this}function b(A,z){if(z){h[A]=z}else{h=a.extend(h,A)}}function g(z){return typeof z==="string"&&z.indexOf("/")>-1}function s(I,A,F){F=F||{};var z=this,J=A.length,C=F.prepend&&!F.append,B=0,H=0,D=false,E;if(F.paged){var G=(F.pageNo-1)*F.elemPerPage;A=A.slice(G,G+F.elemPerPage);J=A.length}E=a.extend({},F,{complete:function(){if(this.html){if(C){z.prepend(this.html())}else{z.append(this.html())}}B++;if(B===J||D){if(D&&F&&typeof F.error==="function"){F.error.call(z)}if(F&&typeof F.complete==="function"){F.complete()}}},success:function(){H++;if(H===J){if(F&&typeof F.success==="function"){F.success()}}},error:function(){D=true}});if(!F.append&&!F.prepend){z.html("")}if(C){A.reverse()}a(A).each(function(){var K=a("
    ");n.call(K,I,this,E);if(D){return false}});return this}function c(C,A,z,B){if(u[C]){u[C].push({data:z,selection:A,settings:B})}else{u[C]=[{data:z,selection:A,settings:B}]}}function q(D,B,A,C){var z=v[D].clone();p.call(B,z,A,C);if(typeof C.success==="function"){C.success()}}function w(){return new Date().getTime()}function x(z){if(z.indexOf("?")!==-1){return z+"&_="+w()}else{return z+"?_="+w()}}function m(D,B,A,C){var z=a("
    ");v[D]=null;var E=D;if(C.overwriteCache){E=x(E)}a.ajax({url:E,async:C.async,success:function(F){z.html(F);l(z,D,B,A,C)},error:function(){k(D,B,A,C)}})}function o(z,C,B,D){var A=a("
    ");if(z.is("script")||z.is("template")){z=a.parseHTML(a.trim(z.html()))}A.html(z);p.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function p(B,z,A){f(B,z,A);a(this).each(function(){var C=a(B.html());if(A.beforeInsert){A.beforeInsert(C)}if(A.append){a(this).append(C)}else{if(A.prepend){a(this).prepend(C)}else{a(this).html(C)}}if(A.afterInsert){A.afterInsert(C)}});if(typeof A.complete==="function"){A.complete.call(a(this))}}function k(C,A,z,B){var D;if(typeof B.error==="function"){B.error.call(A)}a(u[C]).each(function(E,F){if(typeof F.settings.error==="function"){F.settings.error.call(F.selection)}});if(typeof B.complete==="function"){B.complete.call(A)}while(u[C]&&(D=u[C].shift())){if(typeof D.settings.complete==="function"){D.settings.complete.call(D.selection)}}if(typeof u[C]!=="undefined"&&u[C].length>0){u[C]=[]}}function l(z,D,B,A,C){var E;v[D]=z.clone();p.call(B,z,A,C);if(typeof C.success==="function"){C.success.call(B)}while(u[D]&&(E=u[D].shift())){p.call(E.selection,v[D].clone(),E.data,E.settings);if(typeof E.settings.success==="function"){E.settings.success.call(E.selection)}}}function f(B,z,A){z=z||{};t("data-content",B,z,A,function(C,D){C.html(e(C,D,"content",A))});t("data-content-append",B,z,A,function(C,D){C.append(e(C,D,"content",A))});t("data-content-prepend",B,z,A,function(C,D){C.prepend(e(C,D,"content",A))});t("data-content-text",B,z,A,function(C,D){C.text(e(C,D,"content",A))});t("data-src",B,z,A,function(C,D){C.attr("src",e(C,D,"src",A))},function(C){C.remove()});t("data-alt",B,z,A,function(C,D){C.attr("alt",e(C,D,"alt",A))});t("data-value",B,z,A,function(C,D){C.attr("value",e(C,D,"value",A))});t("data-link",B,z,A,function(C,E){var D=a("");D.attr("href",e(C,E,"link",A));D.html(C.html());C.html(D)});t("data-link-wrap",B,z,A,function(C,E){var D=a("");D.attr("href",e(C,E,"link-wrap",A));C.wrap(D)});t("data-options",B,z,A,function(C,D){a(D).each(function(){var E=a("
    ");n.call(K,I,this,E);if(D){return false}});return this}function c(C,A,z,B){if(u[C]){u[C].push({data:z,selection:A,settings:B})}else{u[C]=[{data:z,selection:A,settings:B}]}}function q(D,B,A,C){var z=v[D].clone();p.call(B,z,A,C);if(typeof C.success==="function"){C.success()}}function w(){return new Date().getTime()}function x(z){if(z.indexOf("?")!==-1){return z+"&_="+w()}else{return z+"?_="+w()}}function m(D,B,A,C){var z=a("
    ");v[D]=null;var E=D;if(C.overwriteCache){E=x(E)}a.ajax({url:E,async:C.async,success:function(F){z.html(F);l(z,D,B,A,C)},error:function(){k(D,B,A,C)}})}function o(z,C,B,D){var A=a("
    ");if(z.is("script")||z.is("template")){z=a.parseHTML(a.trim(z.html()))}A.html(z);p.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function p(B,z,A){f(B,z,A);a(this).each(function(){var C=a(B.html());if(A.beforeInsert){A.beforeInsert(C)}if(A.append){a(this).append(C)}else{if(A.prepend){a(this).prepend(C)}else{a(this).html(C)}}if(A.afterInsert){A.afterInsert(C)}});if(typeof A.complete==="function"){A.complete.call(a(this))}}function k(C,A,z,B){var D;if(typeof B.error==="function"){B.error.call(A)}a(u[C]).each(function(E,F){if(typeof F.settings.error==="function"){F.settings.error.call(F.selection)}});if(typeof B.complete==="function"){B.complete.call(A)}while(u[C]&&(D=u[C].shift())){if(typeof D.settings.complete==="function"){D.settings.complete.call(D.selection)}}if(typeof u[C]!=="undefined"&&u[C].length>0){u[C]=[]}}function l(z,D,B,A,C){var E;v[D]=z.clone();p.call(B,z,A,C);if(typeof C.success==="function"){C.success.call(B)}while(u[D]&&(E=u[D].shift())){p.call(E.selection,v[D].clone(),E.data,E.settings);if(typeof E.settings.success==="function"){E.settings.success.call(E.selection)}}}function f(B,z,A){z=z||{};t("data-content",B,z,A,function(C,D){C.html(e(C,D,"content",A))});t("data-content-append",B,z,A,function(C,D){C.append(e(C,D,"content",A))});t("data-content-prepend",B,z,A,function(C,D){C.prepend(e(C,D,"content",A))});t("data-content-text",B,z,A,function(C,D){C.text(e(C,D,"content",A))});t("data-src",B,z,A,function(C,D){C.attr("src",e(C,D,"src",A))},function(C){C.remove()});t("data-alt",B,z,A,function(C,D){C.attr("alt",e(C,D,"alt",A))});t("data-id",B,z,A,function(C,D){C.attr("id",e(C,D,"id",A))});t("data-value",B,z,A,function(C,D){C.attr("value",e(C,D,"value",A))});t("data-link",B,z,A,function(C,E){var D=a("");D.attr("href",e(C,E,"link",A));D.html(C.html());C.html(D)});t("data-link-wrap",B,z,A,function(C,E){var D=a("");D.attr("href",e(C,E,"link-wrap",A));C.wrap(D)});t("data-options",B,z,A,function(C,D){a(D).each(function(){var E=a("
    diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.4.2.js b/jquery-loadTemplate/jquery.loadTemplate-1.4.3.js similarity index 100% rename from jquery-loadTemplate/jquery.loadTemplate-1.4.2.js rename to jquery-loadTemplate/jquery.loadTemplate-1.4.3.js diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.4.2.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.4.3.min.js similarity index 100% rename from jquery-loadTemplate/jquery.loadTemplate-1.4.2.min.js rename to jquery-loadTemplate/jquery.loadTemplate-1.4.3.min.js diff --git a/loadTemplate.jquery.json b/loadTemplate.jquery.json index fa145e1..837eda8 100644 --- a/loadTemplate.jquery.json +++ b/loadTemplate.jquery.json @@ -6,7 +6,7 @@ "templates", "templating" ], - "version": "1.4.1", + "version": "1.4.3", "author": { "name": "Paul Burgess and other contributors", "url": "https://github.com/codepb/jquery-template" diff --git a/tests/index.html b/tests/index.html index bbba95e..3b28627 100644 --- a/tests/index.html +++ b/tests/index.html @@ -3,7 +3,7 @@ loadTemplate Test Suite - + From 1823add2ff5bfa27b307cb42e895932484be4e95 Mon Sep 17 00:00:00 2001 From: Chris Rogers Date: Tue, 6 May 2014 10:00:52 -0500 Subject: [PATCH 38/71] Updates to jquery.loadTemplate-1.4.3.js As per my two issue submissions: 1) Modified getValue to accommodate null values during data binding 2) Modified the nestedTemplateFormatter to only return the generated child nodes if the parentElement is not specified. --- jquery-loadTemplate/jquery.loadTemplate-1.4.3.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.4.3.js b/jquery-loadTemplate/jquery.loadTemplate-1.4.3.js index 52c43a0..b80b10e 100644 --- a/jquery-loadTemplate/jquery.loadTemplate-1.4.3.js +++ b/jquery-loadTemplate/jquery.loadTemplate-1.4.3.js @@ -471,7 +471,7 @@ part, value = data; - while ((part = paramParts.shift()) && typeof value !== "undefined") { + while ((part = paramParts.shift()) && typeof value !== "undefined" && value != null) { value = value[part]; } @@ -505,7 +505,12 @@ var parentElement = options.parentElement || "div"; var template = options.template || options; - return $("<" + parentElement + "/>").loadTemplate(template, value, internalSettings); + + //If a parent is specified, return it; otherwise only return the generated children. + if(options.parentElement) + return $("<" + parentElement + "/>").loadTemplate(template, value, internalSettings); + else + return $("<" + parentElement + "/>").loadTemplate(template, value, internalSettings).children(); }); $.fn.loadTemplate = loadTemplate; $.addTemplateFormatter = addTemplateFormatter; From 55407d3f7c65a7b086efd474f420d6a1d55b851a Mon Sep 17 00:00:00 2001 From: Adis Date: Wed, 14 May 2014 00:44:26 +0600 Subject: [PATCH 39/71] Added data-href binding Added data-href binding --- jquery-loadTemplate/jquery.loadTemplate-1.4.3.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.4.3.js b/jquery-loadTemplate/jquery.loadTemplate-1.4.3.js index 52c43a0..e2f60d9 100644 --- a/jquery-loadTemplate/jquery.loadTemplate-1.4.3.js +++ b/jquery-loadTemplate/jquery.loadTemplate-1.4.3.js @@ -305,6 +305,12 @@ }, function ($elem) { $elem.remove(); }); + + processElements("data-href", template, data, settings, function ($elem, value) { + $elem.attr("href", applyFormatters($elem, value, "href", settings)); + }, function ($elem) { + $elem.remove(); + }); processElements("data-alt", template, data, settings, function ($elem, value) { $elem.attr("alt", applyFormatters($elem, value, "alt", settings)); From 6964c08ba63eb49ce8d366fa4073a444cd5fb32d Mon Sep 17 00:00:00 2001 From: Paul Burgess Date: Sun, 18 May 2014 13:40:50 +0100 Subject: [PATCH 40/71] Updated documentation, and version --- Examples/index.html | 2 +- ...query.loadTemplate-1.4.3.js => jquery.loadTemplate-1.4.4.js} | 0 ...adTemplate-1.4.3.min.js => jquery.loadTemplate-1.4.4.min.js} | 2 +- loadTemplate.jquery.json | 2 +- readme.md | 1 + tests/index.html | 2 +- 6 files changed, 5 insertions(+), 4 deletions(-) rename jquery-loadTemplate/{jquery.loadTemplate-1.4.3.js => jquery.loadTemplate-1.4.4.js} (100%) rename jquery-loadTemplate/{jquery.loadTemplate-1.4.3.min.js => jquery.loadTemplate-1.4.4.min.js} (54%) diff --git a/Examples/index.html b/Examples/index.html index 6a4bc64..ad2f922 100644 --- a/Examples/index.html +++ b/Examples/index.html @@ -9,7 +9,7 @@ - +
    diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.4.3.js b/jquery-loadTemplate/jquery.loadTemplate-1.4.4.js similarity index 100% rename from jquery-loadTemplate/jquery.loadTemplate-1.4.3.js rename to jquery-loadTemplate/jquery.loadTemplate-1.4.4.js diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.4.3.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.4.4.min.js similarity index 54% rename from jquery-loadTemplate/jquery.loadTemplate-1.4.3.min.js rename to jquery-loadTemplate/jquery.loadTemplate-1.4.4.min.js index c162670..b21b477 100644 --- a/jquery-loadTemplate/jquery.loadTemplate-1.4.3.min.js +++ b/jquery-loadTemplate/jquery.loadTemplate-1.4.4.min.js @@ -1 +1 @@ -(function(a){var v={},u={},h={};function n(F,B,D){var A=this,z,C,E;B=B||{};E=a.extend(true,{async:true,overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(E.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null,bindingOptions:{ignoreUndefined:false,ignoreNull:false,ignoreEmptyString:false}},D);if(a.type(B)==="array"){return s.call(this,F,B,E)}if(!g(F)){z=a(F);if(typeof F==="string"&&F.indexOf("#")===0){E.isFile=false}}C=E.isFile||(typeof E.isFile==="undefined"&&(typeof z==="undefined"||z.length===0));if(C&&!E.overwriteCache&&v[F]){q(F,A,B,E)}else{if(C&&!E.overwriteCache&&v.hasOwnProperty(F)){c(F,A,B,E)}else{if(C){m(F,A,B,E)}else{o(z,A,B,E)}}}return this}function b(A,z){if(z){h[A]=z}else{h=a.extend(h,A)}}function g(z){return typeof z==="string"&&z.indexOf("/")>-1}function s(I,A,F){F=F||{};var z=this,J=A.length,C=F.prepend&&!F.append,B=0,H=0,D=false,E;if(F.paged){var G=(F.pageNo-1)*F.elemPerPage;A=A.slice(G,G+F.elemPerPage);J=A.length}E=a.extend({},F,{complete:function(){if(this.html){if(C){z.prepend(this.html())}else{z.append(this.html())}}B++;if(B===J||D){if(D&&F&&typeof F.error==="function"){F.error.call(z)}if(F&&typeof F.complete==="function"){F.complete()}}},success:function(){H++;if(H===J){if(F&&typeof F.success==="function"){F.success()}}},error:function(){D=true}});if(!F.append&&!F.prepend){z.html("")}if(C){A.reverse()}a(A).each(function(){var K=a("
    ");n.call(K,I,this,E);if(D){return false}});return this}function c(C,A,z,B){if(u[C]){u[C].push({data:z,selection:A,settings:B})}else{u[C]=[{data:z,selection:A,settings:B}]}}function q(D,B,A,C){var z=v[D].clone();p.call(B,z,A,C);if(typeof C.success==="function"){C.success()}}function w(){return new Date().getTime()}function x(z){if(z.indexOf("?")!==-1){return z+"&_="+w()}else{return z+"?_="+w()}}function m(D,B,A,C){var z=a("
    ");v[D]=null;var E=D;if(C.overwriteCache){E=x(E)}a.ajax({url:E,async:C.async,success:function(F){z.html(F);l(z,D,B,A,C)},error:function(){k(D,B,A,C)}})}function o(z,C,B,D){var A=a("
    ");if(z.is("script")||z.is("template")){z=a.parseHTML(a.trim(z.html()))}A.html(z);p.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function p(B,z,A){f(B,z,A);a(this).each(function(){var C=a(B.html());if(A.beforeInsert){A.beforeInsert(C)}if(A.append){a(this).append(C)}else{if(A.prepend){a(this).prepend(C)}else{a(this).html(C)}}if(A.afterInsert){A.afterInsert(C)}});if(typeof A.complete==="function"){A.complete.call(a(this))}}function k(C,A,z,B){var D;if(typeof B.error==="function"){B.error.call(A)}a(u[C]).each(function(E,F){if(typeof F.settings.error==="function"){F.settings.error.call(F.selection)}});if(typeof B.complete==="function"){B.complete.call(A)}while(u[C]&&(D=u[C].shift())){if(typeof D.settings.complete==="function"){D.settings.complete.call(D.selection)}}if(typeof u[C]!=="undefined"&&u[C].length>0){u[C]=[]}}function l(z,D,B,A,C){var E;v[D]=z.clone();p.call(B,z,A,C);if(typeof C.success==="function"){C.success.call(B)}while(u[D]&&(E=u[D].shift())){p.call(E.selection,v[D].clone(),E.data,E.settings);if(typeof E.settings.success==="function"){E.settings.success.call(E.selection)}}}function f(B,z,A){z=z||{};t("data-content",B,z,A,function(C,D){C.html(e(C,D,"content",A))});t("data-content-append",B,z,A,function(C,D){C.append(e(C,D,"content",A))});t("data-content-prepend",B,z,A,function(C,D){C.prepend(e(C,D,"content",A))});t("data-content-text",B,z,A,function(C,D){C.text(e(C,D,"content",A))});t("data-src",B,z,A,function(C,D){C.attr("src",e(C,D,"src",A))},function(C){C.remove()});t("data-alt",B,z,A,function(C,D){C.attr("alt",e(C,D,"alt",A))});t("data-id",B,z,A,function(C,D){C.attr("id",e(C,D,"id",A))});t("data-value",B,z,A,function(C,D){C.attr("value",e(C,D,"value",A))});t("data-link",B,z,A,function(C,E){var D=a("");D.attr("href",e(C,E,"link",A));D.html(C.html());C.html(D)});t("data-link-wrap",B,z,A,function(C,E){var D=a("");D.attr("href",e(C,E,"link-wrap",A));C.wrap(D)});t("data-options",B,z,A,function(C,D){a(D).each(function(){var E=a("
    ");n.call(K,I,this,E);if(D){return false}});return this}function c(C,A,z,B){if(u[C]){u[C].push({data:z,selection:A,settings:B})}else{u[C]=[{data:z,selection:A,settings:B}]}}function q(D,B,A,C){var z=v[D].clone();p.call(B,z,A,C);if(typeof C.success==="function"){C.success()}}function w(){return new Date().getTime()}function x(z){if(z.indexOf("?")!==-1){return z+"&_="+w()}else{return z+"?_="+w()}}function m(D,B,A,C){var z=a("
    ");v[D]=null;var E=D;if(C.overwriteCache){E=x(E)}a.ajax({url:E,async:C.async,success:function(F){z.html(F);l(z,D,B,A,C)},error:function(){k(D,B,A,C)}})}function o(z,C,B,D){var A=a("
    ");if(z.is("script")||z.is("template")){z=a.parseHTML(a.trim(z.html()))}A.html(z);p.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function p(B,z,A){f(B,z,A);a(this).each(function(){var C=a(B.html());if(A.beforeInsert){A.beforeInsert(C)}if(A.append){a(this).append(C)}else{if(A.prepend){a(this).prepend(C)}else{a(this).html(C)}}if(A.afterInsert){A.afterInsert(C)}});if(typeof A.complete==="function"){A.complete.call(a(this))}}function k(C,A,z,B){var D;if(typeof B.error==="function"){B.error.call(A)}a(u[C]).each(function(E,F){if(typeof F.settings.error==="function"){F.settings.error.call(F.selection)}});if(typeof B.complete==="function"){B.complete.call(A)}while(u[C]&&(D=u[C].shift())){if(typeof D.settings.complete==="function"){D.settings.complete.call(D.selection)}}if(typeof u[C]!=="undefined"&&u[C].length>0){u[C]=[]}}function l(z,D,B,A,C){var E;v[D]=z.clone();p.call(B,z,A,C);if(typeof C.success==="function"){C.success.call(B)}while(u[D]&&(E=u[D].shift())){p.call(E.selection,v[D].clone(),E.data,E.settings);if(typeof E.settings.success==="function"){E.settings.success.call(E.selection)}}}function f(B,z,A){z=z||{};t("data-content",B,z,A,function(C,D){C.html(e(C,D,"content",A))});t("data-content-append",B,z,A,function(C,D){C.append(e(C,D,"content",A))});t("data-content-prepend",B,z,A,function(C,D){C.prepend(e(C,D,"content",A))});t("data-content-text",B,z,A,function(C,D){C.text(e(C,D,"content",A))});t("data-src",B,z,A,function(C,D){C.attr("src",e(C,D,"src",A))},function(C){C.remove()});t("data-href",B,z,A,function(C,D){C.attr("href",e(C,D,"href",A))},function(C){C.remove()});t("data-alt",B,z,A,function(C,D){C.attr("alt",e(C,D,"alt",A))});t("data-id",B,z,A,function(C,D){C.attr("id",e(C,D,"id",A))});t("data-value",B,z,A,function(C,D){C.attr("value",e(C,D,"value",A))});t("data-link",B,z,A,function(C,E){var D=a("");D.attr("href",e(C,E,"link",A));D.html(C.html());C.html(D)});t("data-link-wrap",B,z,A,function(C,E){var D=a("");D.attr("href",e(C,E,"link-wrap",A));C.wrap(D)});t("data-options",B,z,A,function(C,D){a(D).each(function(){var E=a("

    Example of loading a template from a script tag within the same document. - +
    diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.4.4.js b/jquery-loadTemplate/jquery.loadTemplate-1.4.5.js similarity index 97% rename from jquery-loadTemplate/jquery.loadTemplate-1.4.4.js rename to jquery-loadTemplate/jquery.loadTemplate-1.4.5.js index b678cd8..46275a8 100644 --- a/jquery-loadTemplate/jquery.loadTemplate-1.4.4.js +++ b/jquery-loadTemplate/jquery.loadTemplate-1.4.5.js @@ -300,6 +300,10 @@ $elem.text(applyFormatters($elem, value, "content", settings)); }); + processElements("data-innerHTML", template, data, settings, function ($elem, value) { + $elem.html(applyFormatters($elem, value, "content", settings)); + }); + processElements("data-src", template, data, settings, function ($elem, value) { $elem.attr("src", applyFormatters($elem, value, "src", settings)); }, function ($elem) { @@ -324,6 +328,10 @@ $elem.attr("value", applyFormatters($elem, value, "value", settings)); }); + processElements("data-class", template, data, settings, function ($elem, value) { + $elem.addClass(applyFormatters($elem, value, "class", settings)); + }); + processElements("data-link", template, data, settings, function ($elem, value) { var $linkElem = $(""); $linkElem.attr("href", applyFormatters($elem, value, "link", settings)); @@ -430,6 +438,7 @@ switch (this.attribute) { case "content": + case "innerHTML": $this.html(applyDataBindFormatters($this, value, this)); break; case "contentAppend": diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.4.4.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.4.5.min.js similarity index 52% rename from jquery-loadTemplate/jquery.loadTemplate-1.4.4.min.js rename to jquery-loadTemplate/jquery.loadTemplate-1.4.5.min.js index b21b477..64dab52 100644 --- a/jquery-loadTemplate/jquery.loadTemplate-1.4.4.min.js +++ b/jquery-loadTemplate/jquery.loadTemplate-1.4.5.min.js @@ -1 +1 @@ -(function(a){var v={},u={},h={};function n(F,B,D){var A=this,z,C,E;B=B||{};E=a.extend(true,{async:true,overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(E.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null,bindingOptions:{ignoreUndefined:false,ignoreNull:false,ignoreEmptyString:false}},D);if(a.type(B)==="array"){return s.call(this,F,B,E)}if(!g(F)){z=a(F);if(typeof F==="string"&&F.indexOf("#")===0){E.isFile=false}}C=E.isFile||(typeof E.isFile==="undefined"&&(typeof z==="undefined"||z.length===0));if(C&&!E.overwriteCache&&v[F]){q(F,A,B,E)}else{if(C&&!E.overwriteCache&&v.hasOwnProperty(F)){c(F,A,B,E)}else{if(C){m(F,A,B,E)}else{o(z,A,B,E)}}}return this}function b(A,z){if(z){h[A]=z}else{h=a.extend(h,A)}}function g(z){return typeof z==="string"&&z.indexOf("/")>-1}function s(I,A,F){F=F||{};var z=this,J=A.length,C=F.prepend&&!F.append,B=0,H=0,D=false,E;if(F.paged){var G=(F.pageNo-1)*F.elemPerPage;A=A.slice(G,G+F.elemPerPage);J=A.length}E=a.extend({},F,{complete:function(){if(this.html){if(C){z.prepend(this.html())}else{z.append(this.html())}}B++;if(B===J||D){if(D&&F&&typeof F.error==="function"){F.error.call(z)}if(F&&typeof F.complete==="function"){F.complete()}}},success:function(){H++;if(H===J){if(F&&typeof F.success==="function"){F.success()}}},error:function(){D=true}});if(!F.append&&!F.prepend){z.html("")}if(C){A.reverse()}a(A).each(function(){var K=a("
    ");n.call(K,I,this,E);if(D){return false}});return this}function c(C,A,z,B){if(u[C]){u[C].push({data:z,selection:A,settings:B})}else{u[C]=[{data:z,selection:A,settings:B}]}}function q(D,B,A,C){var z=v[D].clone();p.call(B,z,A,C);if(typeof C.success==="function"){C.success()}}function w(){return new Date().getTime()}function x(z){if(z.indexOf("?")!==-1){return z+"&_="+w()}else{return z+"?_="+w()}}function m(D,B,A,C){var z=a("
    ");v[D]=null;var E=D;if(C.overwriteCache){E=x(E)}a.ajax({url:E,async:C.async,success:function(F){z.html(F);l(z,D,B,A,C)},error:function(){k(D,B,A,C)}})}function o(z,C,B,D){var A=a("
    ");if(z.is("script")||z.is("template")){z=a.parseHTML(a.trim(z.html()))}A.html(z);p.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function p(B,z,A){f(B,z,A);a(this).each(function(){var C=a(B.html());if(A.beforeInsert){A.beforeInsert(C)}if(A.append){a(this).append(C)}else{if(A.prepend){a(this).prepend(C)}else{a(this).html(C)}}if(A.afterInsert){A.afterInsert(C)}});if(typeof A.complete==="function"){A.complete.call(a(this))}}function k(C,A,z,B){var D;if(typeof B.error==="function"){B.error.call(A)}a(u[C]).each(function(E,F){if(typeof F.settings.error==="function"){F.settings.error.call(F.selection)}});if(typeof B.complete==="function"){B.complete.call(A)}while(u[C]&&(D=u[C].shift())){if(typeof D.settings.complete==="function"){D.settings.complete.call(D.selection)}}if(typeof u[C]!=="undefined"&&u[C].length>0){u[C]=[]}}function l(z,D,B,A,C){var E;v[D]=z.clone();p.call(B,z,A,C);if(typeof C.success==="function"){C.success.call(B)}while(u[D]&&(E=u[D].shift())){p.call(E.selection,v[D].clone(),E.data,E.settings);if(typeof E.settings.success==="function"){E.settings.success.call(E.selection)}}}function f(B,z,A){z=z||{};t("data-content",B,z,A,function(C,D){C.html(e(C,D,"content",A))});t("data-content-append",B,z,A,function(C,D){C.append(e(C,D,"content",A))});t("data-content-prepend",B,z,A,function(C,D){C.prepend(e(C,D,"content",A))});t("data-content-text",B,z,A,function(C,D){C.text(e(C,D,"content",A))});t("data-src",B,z,A,function(C,D){C.attr("src",e(C,D,"src",A))},function(C){C.remove()});t("data-href",B,z,A,function(C,D){C.attr("href",e(C,D,"href",A))},function(C){C.remove()});t("data-alt",B,z,A,function(C,D){C.attr("alt",e(C,D,"alt",A))});t("data-id",B,z,A,function(C,D){C.attr("id",e(C,D,"id",A))});t("data-value",B,z,A,function(C,D){C.attr("value",e(C,D,"value",A))});t("data-link",B,z,A,function(C,E){var D=a("");D.attr("href",e(C,E,"link",A));D.html(C.html());C.html(D)});t("data-link-wrap",B,z,A,function(C,E){var D=a("");D.attr("href",e(C,E,"link-wrap",A));C.wrap(D)});t("data-options",B,z,A,function(C,D){a(D).each(function(){var E=a("
    ");n.call(K,I,this,E);if(D){return false}});return this}function c(C,A,z,B){if(u[C]){u[C].push({data:z,selection:A,settings:B})}else{u[C]=[{data:z,selection:A,settings:B}]}}function q(D,B,A,C){var z=v[D].clone();p.call(B,z,A,C);if(typeof C.success==="function"){C.success()}}function w(){return new Date().getTime()}function x(z){if(z.indexOf("?")!==-1){return z+"&_="+w()}else{return z+"?_="+w()}}function m(D,B,A,C){var z=a("
    ");v[D]=null;var E=D;if(C.overwriteCache){E=x(E)}a.ajax({url:E,async:C.async,success:function(F){z.html(F);l(z,D,B,A,C)},error:function(){k(D,B,A,C)}})}function o(z,C,B,D){var A=a("
    ");if(z.is("script")||z.is("template")){z=a.parseHTML(a.trim(z.html()))}A.html(z);p.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function p(B,z,A){f(B,z,A);a(this).each(function(){var C=a(B.html());if(A.beforeInsert){A.beforeInsert(C)}if(A.append){a(this).append(C)}else{if(A.prepend){a(this).prepend(C)}else{a(this).html(C)}}if(A.afterInsert){A.afterInsert(C)}});if(typeof A.complete==="function"){A.complete.call(a(this))}}function k(C,A,z,B){var D;if(typeof B.error==="function"){B.error.call(A)}a(u[C]).each(function(E,F){if(typeof F.settings.error==="function"){F.settings.error.call(F.selection)}});if(typeof B.complete==="function"){B.complete.call(A)}while(u[C]&&(D=u[C].shift())){if(typeof D.settings.complete==="function"){D.settings.complete.call(D.selection)}}if(typeof u[C]!=="undefined"&&u[C].length>0){u[C]=[]}}function l(z,D,B,A,C){var E;v[D]=z.clone();p.call(B,z,A,C);if(typeof C.success==="function"){C.success.call(B)}while(u[D]&&(E=u[D].shift())){p.call(E.selection,v[D].clone(),E.data,E.settings);if(typeof E.settings.success==="function"){E.settings.success.call(E.selection)}}}function f(B,z,A){z=z||{};t("data-content",B,z,A,function(C,D){C.html(e(C,D,"content",A))});t("data-content-append",B,z,A,function(C,D){C.append(e(C,D,"content",A))});t("data-content-prepend",B,z,A,function(C,D){C.prepend(e(C,D,"content",A))});t("data-content-text",B,z,A,function(C,D){C.text(e(C,D,"content",A))});t("data-innerHTML",B,z,A,function(C,D){C.html(e(C,D,"content",A))});t("data-src",B,z,A,function(C,D){C.attr("src",e(C,D,"src",A))},function(C){C.remove()});t("data-href",B,z,A,function(C,D){C.attr("href",e(C,D,"href",A))},function(C){C.remove()});t("data-alt",B,z,A,function(C,D){C.attr("alt",e(C,D,"alt",A))});t("data-id",B,z,A,function(C,D){C.attr("id",e(C,D,"id",A))});t("data-value",B,z,A,function(C,D){C.attr("value",e(C,D,"value",A))});t("data-class",B,z,A,function(C,D){C.addClass(e(C,D,"class",A))});t("data-link",B,z,A,function(C,E){var D=a("");D.attr("href",e(C,E,"link",A));D.html(C.html());C.html(D)});t("data-link-wrap",B,z,A,function(C,E){var D=a("");D.attr("href",e(C,E,"link-wrap",A));C.wrap(D)});t("data-options",B,z,A,function(C,D){a(D).each(function(){var E=a("

    Example of loading a template from a script tag within the same document. - +
    diff --git a/bower.json b/bower.json index 01af15b..b33029b 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jquery-load-template", - "version": "1.4.5", + "version": "1.5.0", "authors": [ { "name": "Paul Burgess"} ], diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.4.5.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.4.5.min.js deleted file mode 100644 index 64dab52..0000000 --- a/jquery-loadTemplate/jquery.loadTemplate-1.4.5.min.js +++ /dev/null @@ -1 +0,0 @@ -(function(a){var v={},u={},h={};function n(F,B,D){var A=this,z,C,E;B=B||{};E=a.extend(true,{async:true,overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(E.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null,bindingOptions:{ignoreUndefined:false,ignoreNull:false,ignoreEmptyString:false}},D);if(a.type(B)==="array"){return s.call(this,F,B,E)}if(!g(F)){z=a(F);if(typeof F==="string"&&F.indexOf("#")===0){E.isFile=false}}C=E.isFile||(typeof E.isFile==="undefined"&&(typeof z==="undefined"||z.length===0));if(C&&!E.overwriteCache&&v[F]){q(F,A,B,E)}else{if(C&&!E.overwriteCache&&v.hasOwnProperty(F)){c(F,A,B,E)}else{if(C){m(F,A,B,E)}else{o(z,A,B,E)}}}return this}function b(A,z){if(z){h[A]=z}else{h=a.extend(h,A)}}function g(z){return typeof z==="string"&&z.indexOf("/")>-1}function s(I,A,F){F=F||{};var z=this,J=A.length,C=F.prepend&&!F.append,B=0,H=0,D=false,E;if(F.paged){var G=(F.pageNo-1)*F.elemPerPage;A=A.slice(G,G+F.elemPerPage);J=A.length}E=a.extend({},F,{complete:function(){if(this.html){if(C){z.prepend(this.html())}else{z.append(this.html())}}B++;if(B===J||D){if(D&&F&&typeof F.error==="function"){F.error.call(z)}if(F&&typeof F.complete==="function"){F.complete()}}},success:function(){H++;if(H===J){if(F&&typeof F.success==="function"){F.success()}}},error:function(){D=true}});if(!F.append&&!F.prepend){z.html("")}if(C){A.reverse()}a(A).each(function(){var K=a("
    ");n.call(K,I,this,E);if(D){return false}});return this}function c(C,A,z,B){if(u[C]){u[C].push({data:z,selection:A,settings:B})}else{u[C]=[{data:z,selection:A,settings:B}]}}function q(D,B,A,C){var z=v[D].clone();p.call(B,z,A,C);if(typeof C.success==="function"){C.success()}}function w(){return new Date().getTime()}function x(z){if(z.indexOf("?")!==-1){return z+"&_="+w()}else{return z+"?_="+w()}}function m(D,B,A,C){var z=a("
    ");v[D]=null;var E=D;if(C.overwriteCache){E=x(E)}a.ajax({url:E,async:C.async,success:function(F){z.html(F);l(z,D,B,A,C)},error:function(){k(D,B,A,C)}})}function o(z,C,B,D){var A=a("
    ");if(z.is("script")||z.is("template")){z=a.parseHTML(a.trim(z.html()))}A.html(z);p.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function p(B,z,A){f(B,z,A);a(this).each(function(){var C=a(B.html());if(A.beforeInsert){A.beforeInsert(C)}if(A.append){a(this).append(C)}else{if(A.prepend){a(this).prepend(C)}else{a(this).html(C)}}if(A.afterInsert){A.afterInsert(C)}});if(typeof A.complete==="function"){A.complete.call(a(this))}}function k(C,A,z,B){var D;if(typeof B.error==="function"){B.error.call(A)}a(u[C]).each(function(E,F){if(typeof F.settings.error==="function"){F.settings.error.call(F.selection)}});if(typeof B.complete==="function"){B.complete.call(A)}while(u[C]&&(D=u[C].shift())){if(typeof D.settings.complete==="function"){D.settings.complete.call(D.selection)}}if(typeof u[C]!=="undefined"&&u[C].length>0){u[C]=[]}}function l(z,D,B,A,C){var E;v[D]=z.clone();p.call(B,z,A,C);if(typeof C.success==="function"){C.success.call(B)}while(u[D]&&(E=u[D].shift())){p.call(E.selection,v[D].clone(),E.data,E.settings);if(typeof E.settings.success==="function"){E.settings.success.call(E.selection)}}}function f(B,z,A){z=z||{};t("data-content",B,z,A,function(C,D){C.html(e(C,D,"content",A))});t("data-content-append",B,z,A,function(C,D){C.append(e(C,D,"content",A))});t("data-content-prepend",B,z,A,function(C,D){C.prepend(e(C,D,"content",A))});t("data-content-text",B,z,A,function(C,D){C.text(e(C,D,"content",A))});t("data-innerHTML",B,z,A,function(C,D){C.html(e(C,D,"content",A))});t("data-src",B,z,A,function(C,D){C.attr("src",e(C,D,"src",A))},function(C){C.remove()});t("data-href",B,z,A,function(C,D){C.attr("href",e(C,D,"href",A))},function(C){C.remove()});t("data-alt",B,z,A,function(C,D){C.attr("alt",e(C,D,"alt",A))});t("data-id",B,z,A,function(C,D){C.attr("id",e(C,D,"id",A))});t("data-value",B,z,A,function(C,D){C.attr("value",e(C,D,"value",A))});t("data-class",B,z,A,function(C,D){C.addClass(e(C,D,"class",A))});t("data-link",B,z,A,function(C,E){var D=a("");D.attr("href",e(C,E,"link",A));D.html(C.html());C.html(D)});t("data-link-wrap",B,z,A,function(C,E){var D=a("");D.attr("href",e(C,E,"link-wrap",A));C.wrap(D)});t("data-options",B,z,A,function(C,D){a(D).each(function(){var E=a("
    ");n.call(L,J,this,F);if(D){return false}});return this}function c(C,A,z,B){if(u[C]){u[C].push({data:z,selection:A,settings:B})}else{u[C]=[{data:z,selection:A,settings:B}]}}function q(D,B,A,C){var z=v[D].clone();p.call(B,z,A,C);if(typeof C.success==="function"){C.success()}}function w(){return new Date().getTime()}function x(z){if(z.indexOf("?")!==-1){return z+"&_="+w()}else{return z+"?_="+w()}}function m(D,B,A,C){var z=a("
    ");v[D]=null;var E=D;if(C.overwriteCache){E=x(E)}a.ajax({url:E,async:C.async,success:function(F){z.html(F);l(z,D,B,A,C)},error:function(F){k(D,B,A,C,F)}})}function o(z,C,B,D){var A=a("
    ");if(z.is("script")||z.is("template")){z=a.parseHTML(a.trim(z.html()))}A.html(z);p.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function p(B,z,A){f(B,z,A);a(this).each(function(){var C=a(B.html());if(A.beforeInsert){A.beforeInsert(C,z)}if(A.append){a(this).append(C)}else{if(A.prepend){a(this).prepend(C)}else{a(this).html(C)}}if(A.afterInsert){A.afterInsert(C,z)}});if(typeof A.complete==="function"){A.complete.call(a(this))}}function k(D,B,z,C,A){var E;if(typeof C.error==="function"){C.error.call(B,A)}a(u[D]).each(function(F,G){if(typeof G.settings.error==="function"){G.settings.error.call(G.selection,A)}});if(typeof C.complete==="function"){C.complete.call(B)}while(u[D]&&(E=u[D].shift())){if(typeof E.settings.complete==="function"){E.settings.complete.call(E.selection)}}if(typeof u[D]!=="undefined"&&u[D].length>0){u[D]=[]}}function l(z,D,B,A,C){var E;v[D]=z.clone();p.call(B,z,A,C);if(typeof C.success==="function"){C.success.call(B)}while(u[D]&&(E=u[D].shift())){p.call(E.selection,v[D].clone(),E.data,E.settings);if(typeof E.settings.success==="function"){E.settings.success.call(E.selection)}}}function f(B,z,A){z=z||{};t("data-content",B,z,A,function(C,D){C.html(e(C,D,"content",A))});t("data-content-append",B,z,A,function(C,D){C.append(e(C,D,"content",A))});t("data-content-prepend",B,z,A,function(C,D){C.prepend(e(C,D,"content",A))});t("data-content-text",B,z,A,function(C,D){C.text(e(C,D,"content",A))});t("data-innerHTML",B,z,A,function(C,D){C.html(e(C,D,"content",A))});t("data-src",B,z,A,function(C,D){C.attr("src",e(C,D,"src",A))},function(C){C.remove()});t("data-href",B,z,A,function(C,D){C.attr("href",e(C,D,"href",A))},function(C){C.remove()});t("data-alt",B,z,A,function(C,D){C.attr("alt",e(C,D,"alt",A))});t("data-id",B,z,A,function(C,D){C.attr("id",e(C,D,"id",A))});t("data-value",B,z,A,function(C,D){C.attr("value",e(C,D,"value",A))});t("data-class",B,z,A,function(C,D){C.addClass(e(C,D,"class",A))});t("data-link",B,z,A,function(C,E){var D=a("");D.attr("href",e(C,E,"link",A));D.html(C.html());C.html(D)});t("data-link-wrap",B,z,A,function(C,E){var D=a("");D.attr("href",e(C,E,"link-wrap",A));C.wrap(D)});t("data-options",B,z,A,function(C,D){a(D).each(function(){var E=a("
    diff --git a/bower.json b/bower.json index 19cae22..dda5299 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jquery-load-template", - "version": "1.5.0", + "version": "1.5.1", "authors": [ { "name": "Paul Burgess"} ], diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.5.0.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.5.0.min.js deleted file mode 100644 index 1333b7b..0000000 --- a/jquery-loadTemplate/jquery.loadTemplate-1.5.0.min.js +++ /dev/null @@ -1 +0,0 @@ -(function(a){var v={},u={},h={};function n(F,B,D){var A=this,z,C,E;B=B||{};E=a.extend(true,{async:true,overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(E.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null,bindingOptions:{ignoreUndefined:false,ignoreNull:false,ignoreEmptyString:false}},D);if(a.type(B)==="array"){return s.call(this,F,B,E)}if(!g(F)){z=a(F);if(typeof F==="string"&&F.indexOf("#")===0){E.isFile=false}}C=E.isFile||(typeof E.isFile==="undefined"&&(typeof z==="undefined"||z.length===0));if(C&&!E.overwriteCache&&v[F]){q(F,A,B,E)}else{if(C&&!E.overwriteCache&&v.hasOwnProperty(F)){c(F,A,B,E)}else{if(C){m(F,A,B,E)}else{o(z,A,B,E)}}}return this}function b(A,z){if(z){h[A]=z}else{h=a.extend(h,A)}}function g(z){return typeof z==="string"&&z.indexOf("/")>-1}function s(J,A,G){G=G||{};var z=this,K=A.length,C=G.prepend&&!G.append,B=0,I=0,D=false,E=[],F;if(G.paged){var H=(G.pageNo-1)*G.elemPerPage;A=A.slice(H,H+G.elemPerPage);K=A.length}F=a.extend({},G,{async:false,complete:function(){if(this.html){if(C){z.prepend(this.html())}else{z.append(this.html())}}B++;if(B===K||D){if(D&&G&&typeof G.error==="function"){G.error.call(z,E)}if(G&&typeof G.complete==="function"){G.complete()}}},success:function(){I++;if(I===K){if(G&&typeof G.success==="function"){G.success()}}},error:function(L){D=true;E.push(L)}});if(!G.append&&!G.prepend){z.html("")}if(C){A.reverse()}a(A).each(function(){var L=a("
    ");n.call(L,J,this,F);if(D){return false}});return this}function c(C,A,z,B){if(u[C]){u[C].push({data:z,selection:A,settings:B})}else{u[C]=[{data:z,selection:A,settings:B}]}}function q(D,B,A,C){var z=v[D].clone();p.call(B,z,A,C);if(typeof C.success==="function"){C.success()}}function w(){return new Date().getTime()}function x(z){if(z.indexOf("?")!==-1){return z+"&_="+w()}else{return z+"?_="+w()}}function m(D,B,A,C){var z=a("
    ");v[D]=null;var E=D;if(C.overwriteCache){E=x(E)}a.ajax({url:E,async:C.async,success:function(F){z.html(F);l(z,D,B,A,C)},error:function(F){k(D,B,A,C,F)}})}function o(z,C,B,D){var A=a("
    ");if(z.is("script")||z.is("template")){z=a.parseHTML(a.trim(z.html()))}A.html(z);p.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function p(B,z,A){f(B,z,A);a(this).each(function(){var C=a(B.html());if(A.beforeInsert){A.beforeInsert(C,z)}if(A.append){a(this).append(C)}else{if(A.prepend){a(this).prepend(C)}else{a(this).html(C)}}if(A.afterInsert){A.afterInsert(C,z)}});if(typeof A.complete==="function"){A.complete.call(a(this))}}function k(D,B,z,C,A){var E;if(typeof C.error==="function"){C.error.call(B,A)}a(u[D]).each(function(F,G){if(typeof G.settings.error==="function"){G.settings.error.call(G.selection,A)}});if(typeof C.complete==="function"){C.complete.call(B)}while(u[D]&&(E=u[D].shift())){if(typeof E.settings.complete==="function"){E.settings.complete.call(E.selection)}}if(typeof u[D]!=="undefined"&&u[D].length>0){u[D]=[]}}function l(z,D,B,A,C){var E;v[D]=z.clone();p.call(B,z,A,C);if(typeof C.success==="function"){C.success.call(B)}while(u[D]&&(E=u[D].shift())){p.call(E.selection,v[D].clone(),E.data,E.settings);if(typeof E.settings.success==="function"){E.settings.success.call(E.selection)}}}function f(B,z,A){z=z||{};t("data-content",B,z,A,function(C,D){C.html(e(C,D,"content",A))});t("data-content-append",B,z,A,function(C,D){C.append(e(C,D,"content",A))});t("data-content-prepend",B,z,A,function(C,D){C.prepend(e(C,D,"content",A))});t("data-content-text",B,z,A,function(C,D){C.text(e(C,D,"content",A))});t("data-innerHTML",B,z,A,function(C,D){C.html(e(C,D,"content",A))});t("data-src",B,z,A,function(C,D){C.attr("src",e(C,D,"src",A))},function(C){C.remove()});t("data-href",B,z,A,function(C,D){C.attr("href",e(C,D,"href",A))},function(C){C.remove()});t("data-alt",B,z,A,function(C,D){C.attr("alt",e(C,D,"alt",A))});t("data-id",B,z,A,function(C,D){C.attr("id",e(C,D,"id",A))});t("data-value",B,z,A,function(C,D){C.attr("value",e(C,D,"value",A))});t("data-class",B,z,A,function(C,D){C.addClass(e(C,D,"class",A))});t("data-link",B,z,A,function(C,E){var D=a("");D.attr("href",e(C,E,"link",A));D.html(C.html());C.html(D)});t("data-link-wrap",B,z,A,function(C,E){var D=a("");D.attr("href",e(C,E,"link-wrap",A));C.wrap(D)});t("data-options",B,z,A,function(C,D){a(D).each(function(){var E=a("
    ");o.call(M,K,this,G);if(E){return false}});return this}function c(D,B,A,C){if(v[D]){v[D].push({data:A,selection:B,settings:C})}else{v[D]=[{data:A,selection:B,settings:C}]}}function r(E,C,B,D){var A=w[E].clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function x(){return new Date().getTime()}function y(A){if(A.indexOf("?")!==-1){return A+"&_="+x()}else{return A+"?_="+x()}}function n(E,C,B,D){var A=a("
    ");w[E]=null;var F=E;if(D.overwriteCache){F=y(F)}a.ajax({url:F,async:D.async,success:function(G){A.html(G);l(A,E,C,B,D)},error:function(G){k(E,C,B,D,G)}})}function p(A,D,C,E){var B=a("
    ");if(A.is("script")||A.is("template")){A=a.parseHTML(a.trim(A.html()))}B.html(A);q.call(D,B,C,E);if(typeof E.success==="function"){E.success()}}function q(C,A,B){f(C,A,B);a(this).each(function(){var D=a(C.html());if(B.beforeInsert){B.beforeInsert(D,A)}if(B.append){a(this).append(D)}else{if(B.prepend){a(this).prepend(D)}else{a(this).html(D)}}if(B.afterInsert&&!m){B.afterInsert(D,A)}});if(typeof B.complete==="function"){B.complete.call(a(this),A)}}function k(E,C,A,D,B){var F;if(typeof D.error==="function"){D.error.call(C,B)}a(v[E]).each(function(G,H){if(typeof H.settings.error==="function"){H.settings.error.call(H.selection,B)}});if(typeof D.complete==="function"){D.complete.call(C)}while(v[E]&&(F=v[E].shift())){if(typeof F.settings.complete==="function"){F.settings.complete.call(F.selection)}}if(typeof v[E]!=="undefined"&&v[E].length>0){v[E]=[]}}function l(A,E,C,B,D){var F;w[E]=A.clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success.call(C)}while(v[E]&&(F=v[E].shift())){q.call(F.selection,w[E].clone(),F.data,F.settings);if(typeof F.settings.success==="function"){F.settings.success.call(F.selection)}}}function f(C,A,B){A=A||{};u("data-content",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-content-append",C,A,B,function(D,E){D.append(e(D,E,"content",B))});u("data-content-prepend",C,A,B,function(D,E){D.prepend(e(D,E,"content",B))});u("data-content-text",C,A,B,function(D,E){D.text(e(D,E,"content",B))});u("data-innerHTML",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-src",C,A,B,function(D,E){D.attr("src",e(D,E,"src",B))},function(D){D.remove()});u("data-href",C,A,B,function(D,E){D.attr("href",e(D,E,"href",B))},function(D){D.remove()});u("data-alt",C,A,B,function(D,E){D.attr("alt",e(D,E,"alt",B))});u("data-id",C,A,B,function(D,E){D.attr("id",e(D,E,"id",B))});u("data-value",C,A,B,function(D,E){D.attr("value",e(D,E,"value",B))});u("data-class",C,A,B,function(D,E){D.addClass(e(D,E,"class",B))});u("data-link",C,A,B,function(D,F){var E=a("");E.attr("href",e(D,F,"link",B));E.html(D.html());D.html(E)});u("data-link-wrap",C,A,B,function(D,F){var E=a("");E.attr("href",e(D,F,"link-wrap",B));D.wrap(E)});u("data-options",C,A,B,function(D,E){a(E).each(function(){var F=a("
    diff --git a/bower.json b/bower.json index dda5299..6940479 100644 --- a/bower.json +++ b/bower.json @@ -1,16 +1,14 @@ { "name": "jquery-load-template", - "version": "1.5.1", "authors": [ { "name": "Paul Burgess"} ], "homepage": "http://codepb.github.io/jquery-template/", "repository": { "type": "git", - "url": "git://github.com/codepb/jquery-template.git" + "url": "https://github.com/codepb/jquery-template.git" }, "description": "jQuery plugin for loading and using templates. The plugin is designed to be simple yet powerful, and supports loading templates from within the page, or using AJAX to load html files.", - "main": "jquery-loadTemplate/jquery.loadTemplate.js", "ignore": [ "Examples", "tests", diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.5.1.js b/jquery-loadTemplate/jquery.loadTemplate-1.5.2.js similarity index 100% rename from jquery-loadTemplate/jquery.loadTemplate-1.5.1.js rename to jquery-loadTemplate/jquery.loadTemplate-1.5.2.js diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.5.1.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.5.2.min.js similarity index 100% rename from jquery-loadTemplate/jquery.loadTemplate-1.5.1.min.js rename to jquery-loadTemplate/jquery.loadTemplate-1.5.2.min.js diff --git a/loadTemplate.jquery.json b/loadTemplate.jquery.json index be5219b..6ed8bf6 100644 --- a/loadTemplate.jquery.json +++ b/loadTemplate.jquery.json @@ -6,7 +6,7 @@ "templates", "templating" ], - "version": "1.5.1", + "version": "1.5.2", "author": { "name": "Paul Burgess and other contributors", "url": "https://github.com/codepb/jquery-template" diff --git a/package.json b/package.json index b4133f8..15ab0af 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jquery.loadtemplate", - "version": "1.5.1", + "version": "1.5.2", "author": "Paul Burgess", "description": "jQuery plugin for loading and using templates. The plugin is designed to be simple yet powerful, and supports loading templates from within the page, or using AJAX to load html files.", "homepage": "http://codepb.github.io/jquery-template/", diff --git a/tests/index.html b/tests/index.html index eda91b2..3c74f9e 100644 --- a/tests/index.html +++ b/tests/index.html @@ -3,7 +3,7 @@ loadTemplate Test Suite - + From 538aad652d4e16eba1e88488e94980456df4d61c Mon Sep 17 00:00:00 2001 From: Paul Burgess Date: Mon, 29 Feb 2016 11:12:34 +0000 Subject: [PATCH 56/71] Attempting to fix bower.json --- Examples/index.html | 2 +- bower.json | 19 ++++++++++--------- ...-1.5.2.js => jquery.loadTemplate-1.5.3.js} | 0 ...in.js => jquery.loadTemplate-1.5.3.min.js} | 0 loadTemplate.jquery.json | 2 +- package.json | 2 +- tests/index.html | 2 +- 7 files changed, 14 insertions(+), 13 deletions(-) rename jquery-loadTemplate/{jquery.loadTemplate-1.5.2.js => jquery.loadTemplate-1.5.3.js} (100%) rename jquery-loadTemplate/{jquery.loadTemplate-1.5.2.min.js => jquery.loadTemplate-1.5.3.min.js} (100%) diff --git a/Examples/index.html b/Examples/index.html index 4b46dbe..8303ace 100644 --- a/Examples/index.html +++ b/Examples/index.html @@ -9,7 +9,7 @@ - +
    diff --git a/bower.json b/bower.json index 6940479..d90121b 100644 --- a/bower.json +++ b/bower.json @@ -1,31 +1,32 @@ { "name": "jquery-load-template", + "homepage": "http://codepb.github.io/jquery-template/", "authors": [ - { "name": "Paul Burgess"} + ["Paul Burgess "] ], - "homepage": "http://codepb.github.io/jquery-template/", + "description": "jQuery plugin for loading and using templates. The plugin is designed to be simple yet powerful, and supports loading templates from within the page, or using AJAX to load html files.", "repository": { "type": "git", "url": "https://github.com/codepb/jquery-template.git" }, - "description": "jQuery plugin for loading and using templates. The plugin is designed to be simple yet powerful, and supports loading templates from within the page, or using AJAX to load html files.", + "main": "jquery-loadTemplate-1.5.3.js" + "keywords": [ + "templates", + "templating", + "jquery-plugin" + ], "ignore": [ "Examples", "tests", ".gitattributes", ".gitignore", ".travis.yml", - "bower.json", "loadTemplate.jquery.json", "MIT-LICENSE.txt", "package.json", "readme.md" ], - "keywords": [ - "templates", - "templating", - "jquery-plugin" - ], + "dependencies": { "jquery": ">=1.8" } diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.5.2.js b/jquery-loadTemplate/jquery.loadTemplate-1.5.3.js similarity index 100% rename from jquery-loadTemplate/jquery.loadTemplate-1.5.2.js rename to jquery-loadTemplate/jquery.loadTemplate-1.5.3.js diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.5.2.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.5.3.min.js similarity index 100% rename from jquery-loadTemplate/jquery.loadTemplate-1.5.2.min.js rename to jquery-loadTemplate/jquery.loadTemplate-1.5.3.min.js diff --git a/loadTemplate.jquery.json b/loadTemplate.jquery.json index 6ed8bf6..6d5588b 100644 --- a/loadTemplate.jquery.json +++ b/loadTemplate.jquery.json @@ -6,7 +6,7 @@ "templates", "templating" ], - "version": "1.5.2", + "version": "1.5.3", "author": { "name": "Paul Burgess and other contributors", "url": "https://github.com/codepb/jquery-template" diff --git a/package.json b/package.json index 15ab0af..04cc460 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jquery.loadtemplate", - "version": "1.5.2", + "version": "1.5.3", "author": "Paul Burgess", "description": "jQuery plugin for loading and using templates. The plugin is designed to be simple yet powerful, and supports loading templates from within the page, or using AJAX to load html files.", "homepage": "http://codepb.github.io/jquery-template/", diff --git a/tests/index.html b/tests/index.html index 3c74f9e..005ff3b 100644 --- a/tests/index.html +++ b/tests/index.html @@ -3,7 +3,7 @@ loadTemplate Test Suite - + From d32135f3bf98312bf139afb765abf07fb962a910 Mon Sep 17 00:00:00 2001 From: Paul Burgess Date: Mon, 29 Feb 2016 11:15:49 +0000 Subject: [PATCH 57/71] Fixed issue with author tag in bower.json --- Examples/index.html | 2 +- bower.json | 7 +++---- ....loadTemplate-1.5.3.js => jquery.loadTemplate-1.5.4.js} | 0 ...plate-1.5.3.min.js => jquery.loadTemplate-1.5.4.min.js} | 0 loadTemplate.jquery.json | 2 +- package.json | 2 +- tests/index.html | 2 +- 7 files changed, 7 insertions(+), 8 deletions(-) rename jquery-loadTemplate/{jquery.loadTemplate-1.5.3.js => jquery.loadTemplate-1.5.4.js} (100%) rename jquery-loadTemplate/{jquery.loadTemplate-1.5.3.min.js => jquery.loadTemplate-1.5.4.min.js} (100%) diff --git a/Examples/index.html b/Examples/index.html index 8303ace..d0af2e8 100644 --- a/Examples/index.html +++ b/Examples/index.html @@ -9,7 +9,7 @@ - +
    diff --git a/bower.json b/bower.json index d90121b..49b4d26 100644 --- a/bower.json +++ b/bower.json @@ -2,14 +2,14 @@ "name": "jquery-load-template", "homepage": "http://codepb.github.io/jquery-template/", "authors": [ - ["Paul Burgess "] + "Paul Burgess " ], "description": "jQuery plugin for loading and using templates. The plugin is designed to be simple yet powerful, and supports loading templates from within the page, or using AJAX to load html files.", "repository": { "type": "git", "url": "https://github.com/codepb/jquery-template.git" }, - "main": "jquery-loadTemplate-1.5.3.js" + "main": "jquery.loadTemplate-1.5.4.js" "keywords": [ "templates", "templating", @@ -25,8 +25,7 @@ "MIT-LICENSE.txt", "package.json", "readme.md" - ], - + ], "dependencies": { "jquery": ">=1.8" } diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.5.3.js b/jquery-loadTemplate/jquery.loadTemplate-1.5.4.js similarity index 100% rename from jquery-loadTemplate/jquery.loadTemplate-1.5.3.js rename to jquery-loadTemplate/jquery.loadTemplate-1.5.4.js diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.5.3.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.5.4.min.js similarity index 100% rename from jquery-loadTemplate/jquery.loadTemplate-1.5.3.min.js rename to jquery-loadTemplate/jquery.loadTemplate-1.5.4.min.js diff --git a/loadTemplate.jquery.json b/loadTemplate.jquery.json index 6d5588b..7183432 100644 --- a/loadTemplate.jquery.json +++ b/loadTemplate.jquery.json @@ -6,7 +6,7 @@ "templates", "templating" ], - "version": "1.5.3", + "version": "1.5.4", "author": { "name": "Paul Burgess and other contributors", "url": "https://github.com/codepb/jquery-template" diff --git a/package.json b/package.json index 04cc460..7b1f717 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jquery.loadtemplate", - "version": "1.5.3", + "version": "1.5.4", "author": "Paul Burgess", "description": "jQuery plugin for loading and using templates. The plugin is designed to be simple yet powerful, and supports loading templates from within the page, or using AJAX to load html files.", "homepage": "http://codepb.github.io/jquery-template/", diff --git a/tests/index.html b/tests/index.html index 005ff3b..2c10302 100644 --- a/tests/index.html +++ b/tests/index.html @@ -3,7 +3,7 @@ loadTemplate Test Suite - + From ae7ffa01cfd399853923348b630180c116337e34 Mon Sep 17 00:00:00 2001 From: Paul Burgess Date: Mon, 29 Feb 2016 11:19:06 +0000 Subject: [PATCH 58/71] fixed missing comma after main in bower.json --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 49b4d26..4b5dbb2 100644 --- a/bower.json +++ b/bower.json @@ -9,7 +9,7 @@ "type": "git", "url": "https://github.com/codepb/jquery-template.git" }, - "main": "jquery.loadTemplate-1.5.4.js" + "main": "jquery.loadTemplate-1.5.4.js", "keywords": [ "templates", "templating", From 98b5eb84b4a948228b3bf4aa93160d44bcd5ff12 Mon Sep 17 00:00:00 2001 From: Paul Burgess Date: Mon, 29 Feb 2016 11:20:30 +0000 Subject: [PATCH 59/71] Updating Version --- Examples/index.html | 2 +- bower.json | 2 +- ...query.loadTemplate-1.5.4.js => jquery.loadTemplate-1.5.5.js} | 0 ...adTemplate-1.5.4.min.js => jquery.loadTemplate-1.5.5.min.js} | 0 loadTemplate.jquery.json | 2 +- package.json | 2 +- tests/index.html | 2 +- 7 files changed, 5 insertions(+), 5 deletions(-) rename jquery-loadTemplate/{jquery.loadTemplate-1.5.4.js => jquery.loadTemplate-1.5.5.js} (100%) rename jquery-loadTemplate/{jquery.loadTemplate-1.5.4.min.js => jquery.loadTemplate-1.5.5.min.js} (100%) diff --git a/Examples/index.html b/Examples/index.html index d0af2e8..f09337f 100644 --- a/Examples/index.html +++ b/Examples/index.html @@ -9,7 +9,7 @@ - +
    diff --git a/bower.json b/bower.json index 4b5dbb2..e9ad1c0 100644 --- a/bower.json +++ b/bower.json @@ -9,7 +9,7 @@ "type": "git", "url": "https://github.com/codepb/jquery-template.git" }, - "main": "jquery.loadTemplate-1.5.4.js", + "main": "jquery.loadTemplate-1.5.5.js", "keywords": [ "templates", "templating", diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.5.4.js b/jquery-loadTemplate/jquery.loadTemplate-1.5.5.js similarity index 100% rename from jquery-loadTemplate/jquery.loadTemplate-1.5.4.js rename to jquery-loadTemplate/jquery.loadTemplate-1.5.5.js diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.5.4.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.5.5.min.js similarity index 100% rename from jquery-loadTemplate/jquery.loadTemplate-1.5.4.min.js rename to jquery-loadTemplate/jquery.loadTemplate-1.5.5.min.js diff --git a/loadTemplate.jquery.json b/loadTemplate.jquery.json index 7183432..6f8ac34 100644 --- a/loadTemplate.jquery.json +++ b/loadTemplate.jquery.json @@ -6,7 +6,7 @@ "templates", "templating" ], - "version": "1.5.4", + "version": "1.5.5", "author": { "name": "Paul Burgess and other contributors", "url": "https://github.com/codepb/jquery-template" diff --git a/package.json b/package.json index 7b1f717..ba1a933 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jquery.loadtemplate", - "version": "1.5.4", + "version": "1.5.5", "author": "Paul Burgess", "description": "jQuery plugin for loading and using templates. The plugin is designed to be simple yet powerful, and supports loading templates from within the page, or using AJAX to load html files.", "homepage": "http://codepb.github.io/jquery-template/", diff --git a/tests/index.html b/tests/index.html index 2c10302..50e6ddf 100644 --- a/tests/index.html +++ b/tests/index.html @@ -3,7 +3,7 @@ loadTemplate Test Suite - + From 54c882c2aefa361e6faa7cdfc6abcf8c68bd505b Mon Sep 17 00:00:00 2001 From: Paul Burgess Date: Mon, 29 Feb 2016 11:31:33 +0000 Subject: [PATCH 60/71] moved to a new dist folder. New version --- .gitignore | 1 - Examples/index.html | 2 +- bower.json | 2 +- .../jquery.loadTemplate-1.5.6.js | 0 .../jquery.loadTemplate-1.5.6.min.js | 0 loadTemplate.jquery.json | 2 +- package.json | 2 +- tests/index.html | 2 +- 8 files changed, 5 insertions(+), 6 deletions(-) rename jquery-loadTemplate/jquery.loadTemplate-1.5.5.js => dist/jquery.loadTemplate-1.5.6.js (100%) rename jquery-loadTemplate/jquery.loadTemplate-1.5.5.min.js => dist/jquery.loadTemplate-1.5.6.min.js (100%) diff --git a/.gitignore b/.gitignore index b9d6bd9..38a363a 100644 --- a/.gitignore +++ b/.gitignore @@ -192,7 +192,6 @@ $RECYCLE.BIN/ # Packages *.egg *.egg-info -dist/ build/ eggs/ parts/ diff --git a/Examples/index.html b/Examples/index.html index f09337f..6d1388a 100644 --- a/Examples/index.html +++ b/Examples/index.html @@ -9,7 +9,7 @@ - +
    diff --git a/bower.json b/bower.json index e9ad1c0..1c946fa 100644 --- a/bower.json +++ b/bower.json @@ -9,7 +9,7 @@ "type": "git", "url": "https://github.com/codepb/jquery-template.git" }, - "main": "jquery.loadTemplate-1.5.5.js", + "main": "dist/jquery.loadTemplate-1.5.6.js", "keywords": [ "templates", "templating", diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.5.5.js b/dist/jquery.loadTemplate-1.5.6.js similarity index 100% rename from jquery-loadTemplate/jquery.loadTemplate-1.5.5.js rename to dist/jquery.loadTemplate-1.5.6.js diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.5.5.min.js b/dist/jquery.loadTemplate-1.5.6.min.js similarity index 100% rename from jquery-loadTemplate/jquery.loadTemplate-1.5.5.min.js rename to dist/jquery.loadTemplate-1.5.6.min.js diff --git a/loadTemplate.jquery.json b/loadTemplate.jquery.json index 6f8ac34..d8a6eea 100644 --- a/loadTemplate.jquery.json +++ b/loadTemplate.jquery.json @@ -6,7 +6,7 @@ "templates", "templating" ], - "version": "1.5.5", + "version": "1.5.6", "author": { "name": "Paul Burgess and other contributors", "url": "https://github.com/codepb/jquery-template" diff --git a/package.json b/package.json index ba1a933..a9339ae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jquery.loadtemplate", - "version": "1.5.5", + "version": "1.5.6", "author": "Paul Burgess", "description": "jQuery plugin for loading and using templates. The plugin is designed to be simple yet powerful, and supports loading templates from within the page, or using AJAX to load html files.", "homepage": "http://codepb.github.io/jquery-template/", diff --git a/tests/index.html b/tests/index.html index 50e6ddf..2b0a61d 100644 --- a/tests/index.html +++ b/tests/index.html @@ -3,7 +3,7 @@ loadTemplate Test Suite - + From 6733ea1c0e05f421fe5e9c43bd2bb1df3e6fde27 Mon Sep 17 00:00:00 2001 From: codepb Date: Tue, 8 Mar 2016 21:27:51 +0000 Subject: [PATCH 61/71] fixing reference to data-format-template fixes #90 --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index b8cb88b..7a6d4bd 100644 --- a/readme.md +++ b/readme.md @@ -64,7 +64,7 @@ You can pass an array of objects instead of a single object and the template wil ### Data Formatters -It is also possible to define data formatters. These are assigned through the `$.addTemplateFormatter` method. This function either accepts a map of functions and the keys that they will be referenced by, or a single function with a single key as two separate parameters. Each formatter takes two values, the value being assigned, and a template to use to define how this data is displayed. The data-format-template may be empty. Example usage of this is below: +It is also possible to define data formatters. These are assigned through the `$.addTemplateFormatter` method. This function either accepts a map of functions and the keys that they will be referenced by, or a single function with a single key as two separate parameters. Each formatter takes two values, the value being assigned, and a template to use to define how this data is displayed. The data-format-options may be empty. Example usage of this is below: $.addTemplateFormatter("UpperCaseFormatter", function(value, template) { From c57638100d464d9ecd33c4a53b2c80121daafc6a Mon Sep 17 00:00:00 2001 From: Michal Brauner Date: Fri, 25 Mar 2016 19:42:35 +0100 Subject: [PATCH 62/71] fix package.json - missing "main" option --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index a9339ae..ad8504e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "jquery.loadtemplate", "version": "1.5.6", + "main": "dist/jquery.loadTemplate-1.5.6.js", "author": "Paul Burgess", "description": "jQuery plugin for loading and using templates. The plugin is designed to be simple yet powerful, and supports loading templates from within the page, or using AJAX to load html files.", "homepage": "http://codepb.github.io/jquery-template/", From 62bb1f012f974b8961a73fe77784155b90806815 Mon Sep 17 00:00:00 2001 From: Paul Burgess Date: Fri, 1 Apr 2016 16:24:21 +0100 Subject: [PATCH 63/71] Fixed issue with binding the value of selects now uses .val to bind value. Fixed templates so the javascript properties are also copied with the template into the dom --- Examples/SimpleExample/Templates/simple.html | 2 +- Examples/SimpleExample/example.html | 4 +++- Examples/index.html | 4 ++-- bower.json | 2 +- dist/jquery.loadTemplate-1.5.6.min.js | 1 - ...-1.5.6.js => jquery.loadTemplate-1.5.7.js} | 21 ++++++++++++------- dist/jquery.loadTemplate-1.5.7.min.js | 1 + loadTemplate.jquery.json | 2 +- package.json | 4 ++-- tests/index.html | 2 +- 10 files changed, 26 insertions(+), 17 deletions(-) delete mode 100644 dist/jquery.loadTemplate-1.5.6.min.js rename dist/{jquery.loadTemplate-1.5.6.js => jquery.loadTemplate-1.5.7.js} (97%) create mode 100644 dist/jquery.loadTemplate-1.5.7.min.js diff --git a/Examples/SimpleExample/Templates/simple.html b/Examples/SimpleExample/Templates/simple.html index c844792..2e75af5 100644 --- a/Examples/SimpleExample/Templates/simple.html +++ b/Examples/SimpleExample/Templates/simple.html @@ -3,7 +3,7 @@
    - +

    Example of loading a template from a script tag within the same document. - +
    @@ -81,7 +81,7 @@

    Code

    $($div).load($(this).attr("href"), function () { $(".contentContainer > div").hide(); $(".codeContainer > div").hide(); - $(".contentContainer div.content").html($div.html()); + $(".contentContainer div.content").html("").append($div); $(".codeContainer pre code").text($div.html()); if(highlightSupported()) { $(".codeContainer pre code").each(function () { diff --git a/bower.json b/bower.json index 1c946fa..0387819 100644 --- a/bower.json +++ b/bower.json @@ -9,7 +9,7 @@ "type": "git", "url": "https://github.com/codepb/jquery-template.git" }, - "main": "dist/jquery.loadTemplate-1.5.6.js", + "main": "dist/jquery.loadTemplate-1.5.7.js", "keywords": [ "templates", "templating", diff --git a/dist/jquery.loadTemplate-1.5.6.min.js b/dist/jquery.loadTemplate-1.5.6.min.js deleted file mode 100644 index 7c30cb8..0000000 --- a/dist/jquery.loadTemplate-1.5.6.min.js +++ /dev/null @@ -1 +0,0 @@ -(function(a){var w={},v={},h={},m;function o(G,C,E){var B=this,A,D,F;C=C||{};F=a.extend(true,{async:true,overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(F.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null,bindingOptions:{ignoreUndefined:false,ignoreNull:false,ignoreEmptyString:false}},E);if(a.type(C)==="array"){m=true;return t.call(this,G,C,F)}if(!g(G)){A=a(G);if(typeof G==="string"&&G.indexOf("#")===0){F.isFile=false}}D=F.isFile||(typeof F.isFile==="undefined"&&(typeof A==="undefined"||A.length===0));if(D&&!F.overwriteCache&&w[G]){r(G,B,C,F)}else{if(D&&!F.overwriteCache&&w.hasOwnProperty(G)){c(G,B,C,F)}else{if(D){n(G,B,C,F)}else{p(A,B,C,F)}}}return this}function b(B,A){if(A){h[B]=A}else{h=a.extend(h,B)}}function g(A){return typeof A==="string"&&A.indexOf("/")>-1}function t(K,B,H){H=H||{};var A=this,L=B.length,D=H.prepend&&!H.append,C=0,J=0,E=false,F=[],G;if(H.paged){var I=(H.pageNo-1)*H.elemPerPage;B=B.slice(I,I+H.elemPerPage);L=B.length}G=a.extend({},H,{async:false,complete:function(M){if(this.html){var N;if(D){N=a(this.html()).prependTo(A)}else{N=a(this.html()).appendTo(A)}if(H.afterInsert&&M){H.afterInsert(N,M)}}C++;if(C===L||E){if(E&&H&&typeof H.error==="function"){H.error.call(A,F)}if(H&&typeof H.complete==="function"){H.complete()}}},success:function(){J++;if(J===L){if(H&&typeof H.success==="function"){H.success()}}},error:function(M){E=true;F.push(M)}});if(!H.append&&!H.prepend){A.html("")}if(D){B.reverse()}a(B).each(function(){var M=a("
    ");o.call(M,K,this,G);if(E){return false}});return this}function c(D,B,A,C){if(v[D]){v[D].push({data:A,selection:B,settings:C})}else{v[D]=[{data:A,selection:B,settings:C}]}}function r(E,C,B,D){var A=w[E].clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function x(){return new Date().getTime()}function y(A){if(A.indexOf("?")!==-1){return A+"&_="+x()}else{return A+"?_="+x()}}function n(E,C,B,D){var A=a("
    ");w[E]=null;var F=E;if(D.overwriteCache){F=y(F)}a.ajax({url:F,async:D.async,success:function(G){A.html(G);l(A,E,C,B,D)},error:function(G){k(E,C,B,D,G)}})}function p(A,D,C,E){var B=a("
    ");if(A.is("script")||A.is("template")){A=a.parseHTML(a.trim(A.html()))}B.html(A);q.call(D,B,C,E);if(typeof E.success==="function"){E.success()}}function q(C,A,B){f(C,A,B);a(this).each(function(){var D=a(C.html());if(B.beforeInsert){B.beforeInsert(D,A)}if(B.append){a(this).append(D)}else{if(B.prepend){a(this).prepend(D)}else{a(this).html(D)}}if(B.afterInsert&&!m){B.afterInsert(D,A)}});if(typeof B.complete==="function"){B.complete.call(a(this),A)}}function k(E,C,A,D,B){var F;if(typeof D.error==="function"){D.error.call(C,B)}a(v[E]).each(function(G,H){if(typeof H.settings.error==="function"){H.settings.error.call(H.selection,B)}});if(typeof D.complete==="function"){D.complete.call(C)}while(v[E]&&(F=v[E].shift())){if(typeof F.settings.complete==="function"){F.settings.complete.call(F.selection)}}if(typeof v[E]!=="undefined"&&v[E].length>0){v[E]=[]}}function l(A,E,C,B,D){var F;w[E]=A.clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success.call(C)}while(v[E]&&(F=v[E].shift())){q.call(F.selection,w[E].clone(),F.data,F.settings);if(typeof F.settings.success==="function"){F.settings.success.call(F.selection)}}}function f(C,A,B){A=A||{};u("data-content",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-content-append",C,A,B,function(D,E){D.append(e(D,E,"content",B))});u("data-content-prepend",C,A,B,function(D,E){D.prepend(e(D,E,"content",B))});u("data-content-text",C,A,B,function(D,E){D.text(e(D,E,"content",B))});u("data-innerHTML",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-src",C,A,B,function(D,E){D.attr("src",e(D,E,"src",B))},function(D){D.remove()});u("data-href",C,A,B,function(D,E){D.attr("href",e(D,E,"href",B))},function(D){D.remove()});u("data-alt",C,A,B,function(D,E){D.attr("alt",e(D,E,"alt",B))});u("data-id",C,A,B,function(D,E){D.attr("id",e(D,E,"id",B))});u("data-value",C,A,B,function(D,E){D.attr("value",e(D,E,"value",B))});u("data-class",C,A,B,function(D,E){D.addClass(e(D,E,"class",B))});u("data-link",C,A,B,function(D,F){var E=a("");E.attr("href",e(D,F,"link",B));E.html(D.html());D.html(E)});u("data-link-wrap",C,A,B,function(D,F){var E=a("");E.attr("href",e(D,F,"link-wrap",B));D.wrap(E)});u("data-options",C,A,B,function(D,E){a(E).each(function(){var F=a("
    ");o.call(M,K,this,G);if(E){return false}});return this}function c(D,B,A,C){if(v[D]){v[D].push({data:A,selection:B,settings:C})}else{v[D]=[{data:A,selection:B,settings:C}]}}function r(E,C,B,D){var A=w[E].clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function x(){return new Date().getTime()}function y(A){if(A.indexOf("?")!==-1){return A+"&_="+x()}else{return A+"?_="+x()}}function n(E,C,B,D){var A=a("
    ");w[E]=null;var F=E;if(D.overwriteCache){F=y(F)}a.ajax({url:F,async:D.async,success:function(G){A.html(G);l(A,E,C,B,D)},error:function(G){k(E,C,B,D,G)}})}function p(A,D,C,E){var B=a("
    ");if(A.is("script")||A.is("template")){A=a.parseHTML(a.trim(A.html()))}B.html(A);q.call(D,B,C,E);if(typeof E.success==="function"){E.success()}}function q(C,A,B){f(C,A,B);a(this).each(function(){var D=C.clone(true);a("select",D).each(function(E,F){a(this).val(a("select",C).eq(E).val())});if(B.beforeInsert){B.beforeInsert(D,A)}if(B.append){a(this).append(D)}else{if(B.prepend){a(this).prepend(D)}else{a(this).html("").append(D)}}if(B.afterInsert&&!m){B.afterInsert(D,A)}});if(typeof B.complete==="function"){B.complete.call(a(this),A)}}function k(E,C,A,D,B){var F;if(typeof D.error==="function"){D.error.call(C,B)}a(v[E]).each(function(G,H){if(typeof H.settings.error==="function"){H.settings.error.call(H.selection,B)}});if(typeof D.complete==="function"){D.complete.call(C)}while(v[E]&&(F=v[E].shift())){if(typeof F.settings.complete==="function"){F.settings.complete.call(F.selection)}}if(typeof v[E]!=="undefined"&&v[E].length>0){v[E]=[]}}function l(A,E,C,B,D){var F;w[E]=A.clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success.call(C)}while(v[E]&&(F=v[E].shift())){q.call(F.selection,w[E].clone(),F.data,F.settings);if(typeof F.settings.success==="function"){F.settings.success.call(F.selection)}}}function f(C,A,B){A=A||{};u("data-content",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-content-append",C,A,B,function(D,E){D.append(e(D,E,"content",B))});u("data-content-prepend",C,A,B,function(D,E){D.prepend(e(D,E,"content",B))});u("data-content-text",C,A,B,function(D,E){D.text(e(D,E,"content",B))});u("data-innerHTML",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-src",C,A,B,function(D,E){D.attr("src",e(D,E,"src",B))},function(D){D.remove()});u("data-href",C,A,B,function(D,E){D.attr("href",e(D,E,"href",B))},function(D){D.remove()});u("data-alt",C,A,B,function(D,E){D.attr("alt",e(D,E,"alt",B))});u("data-id",C,A,B,function(D,E){D.attr("id",e(D,E,"id",B))});u("data-class",C,A,B,function(D,E){D.addClass(e(D,E,"class",B))});u("data-link",C,A,B,function(D,F){var E=a("");E.attr("href",e(D,F,"link",B));E.html(D.html());D.html(E)});u("data-link-wrap",C,A,B,function(D,F){var E=a("");E.attr("href",e(D,F,"link-wrap",B));D.wrap(E)});u("data-options",C,A,B,function(D,E){a(E).each(function(){var F=a("
    diff --git a/bower.json b/bower.json index 0387819..e8f401f 100644 --- a/bower.json +++ b/bower.json @@ -9,7 +9,7 @@ "type": "git", "url": "https://github.com/codepb/jquery-template.git" }, - "main": "dist/jquery.loadTemplate-1.5.7.js", + "main": "dist/jquery.loadTemplate-1.5.8.js", "keywords": [ "templates", "templating", diff --git a/dist/jquery.loadTemplate-1.5.7.min.js b/dist/jquery.loadTemplate-1.5.7.min.js deleted file mode 100644 index 22b6087..0000000 --- a/dist/jquery.loadTemplate-1.5.7.min.js +++ /dev/null @@ -1 +0,0 @@ -(function(a){var w={},v={},h={},m;function o(G,C,E){var B=this,A,D,F;C=C||{};F=a.extend(true,{async:true,overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(F.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null,bindingOptions:{ignoreUndefined:false,ignoreNull:false,ignoreEmptyString:false}},E);if(a.type(C)==="array"){m=true;return t.call(this,G,C,F)}if(!g(G)){A=a(G);if(typeof G==="string"&&G.indexOf("#")===0){F.isFile=false}}D=F.isFile||(typeof F.isFile==="undefined"&&(typeof A==="undefined"||A.length===0));if(D&&!F.overwriteCache&&w[G]){r(G,B,C,F)}else{if(D&&!F.overwriteCache&&w.hasOwnProperty(G)){c(G,B,C,F)}else{if(D){n(G,B,C,F)}else{p(A,B,C,F)}}}return this}function b(B,A){if(A){h[B]=A}else{h=a.extend(h,B)}}function g(A){return typeof A==="string"&&A.indexOf("/")>-1}function t(K,B,H){H=H||{};var A=this,L=B.length,D=H.prepend&&!H.append,C=0,J=0,E=false,F=[],G;if(H.paged){var I=(H.pageNo-1)*H.elemPerPage;B=B.slice(I,I+H.elemPerPage);L=B.length}G=a.extend({},H,{async:false,complete:function(M){if(this.html){var N;if(D){N=a(this).prependTo(A)}else{N=a(this).appendTo(A)}if(H.afterInsert&&M){H.afterInsert(N,M)}}C++;if(C===L||E){if(E&&H&&typeof H.error==="function"){H.error.call(A,F)}if(H&&typeof H.complete==="function"){H.complete()}}},success:function(){J++;if(J===L){if(H&&typeof H.success==="function"){H.success()}}},error:function(M){E=true;F.push(M)}});if(!H.append&&!H.prepend){A.html("")}if(D){B.reverse()}a(B).each(function(){var M=a("
    ");o.call(M,K,this,G);if(E){return false}});return this}function c(D,B,A,C){if(v[D]){v[D].push({data:A,selection:B,settings:C})}else{v[D]=[{data:A,selection:B,settings:C}]}}function r(E,C,B,D){var A=w[E].clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function x(){return new Date().getTime()}function y(A){if(A.indexOf("?")!==-1){return A+"&_="+x()}else{return A+"?_="+x()}}function n(E,C,B,D){var A=a("
    ");w[E]=null;var F=E;if(D.overwriteCache){F=y(F)}a.ajax({url:F,async:D.async,success:function(G){A.html(G);l(A,E,C,B,D)},error:function(G){k(E,C,B,D,G)}})}function p(A,D,C,E){var B=a("
    ");if(A.is("script")||A.is("template")){A=a.parseHTML(a.trim(A.html()))}B.html(A);q.call(D,B,C,E);if(typeof E.success==="function"){E.success()}}function q(C,A,B){f(C,A,B);a(this).each(function(){var D=C.clone(true);a("select",D).each(function(E,F){a(this).val(a("select",C).eq(E).val())});if(B.beforeInsert){B.beforeInsert(D,A)}if(B.append){a(this).append(D)}else{if(B.prepend){a(this).prepend(D)}else{a(this).html("").append(D)}}if(B.afterInsert&&!m){B.afterInsert(D,A)}});if(typeof B.complete==="function"){B.complete.call(a(this),A)}}function k(E,C,A,D,B){var F;if(typeof D.error==="function"){D.error.call(C,B)}a(v[E]).each(function(G,H){if(typeof H.settings.error==="function"){H.settings.error.call(H.selection,B)}});if(typeof D.complete==="function"){D.complete.call(C)}while(v[E]&&(F=v[E].shift())){if(typeof F.settings.complete==="function"){F.settings.complete.call(F.selection)}}if(typeof v[E]!=="undefined"&&v[E].length>0){v[E]=[]}}function l(A,E,C,B,D){var F;w[E]=A.clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success.call(C)}while(v[E]&&(F=v[E].shift())){q.call(F.selection,w[E].clone(),F.data,F.settings);if(typeof F.settings.success==="function"){F.settings.success.call(F.selection)}}}function f(C,A,B){A=A||{};u("data-content",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-content-append",C,A,B,function(D,E){D.append(e(D,E,"content",B))});u("data-content-prepend",C,A,B,function(D,E){D.prepend(e(D,E,"content",B))});u("data-content-text",C,A,B,function(D,E){D.text(e(D,E,"content",B))});u("data-innerHTML",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-src",C,A,B,function(D,E){D.attr("src",e(D,E,"src",B))},function(D){D.remove()});u("data-href",C,A,B,function(D,E){D.attr("href",e(D,E,"href",B))},function(D){D.remove()});u("data-alt",C,A,B,function(D,E){D.attr("alt",e(D,E,"alt",B))});u("data-id",C,A,B,function(D,E){D.attr("id",e(D,E,"id",B))});u("data-class",C,A,B,function(D,E){D.addClass(e(D,E,"class",B))});u("data-link",C,A,B,function(D,F){var E=a("");E.attr("href",e(D,F,"link",B));E.html(D.html());D.html(E)});u("data-link-wrap",C,A,B,function(D,F){var E=a("");E.attr("href",e(D,F,"link-wrap",B));D.wrap(E)});u("data-options",C,A,B,function(D,E){a(E).each(function(){var F=a("
    "); - loadTemplate.call($div, template, this, newOptions); + + loadTemplate.call($that, template, this, newOptions); if (errored) { return false; } @@ -183,7 +175,6 @@ } function loadAndPrepareTemplate(template, selection, data, settings) { - var $templateContainer = $("
    "); templates[template] = null; var templateUrl = template; @@ -194,8 +185,7 @@ url: templateUrl, async: settings.async, success: function (templateContent) { - $templateContainer.html(templateContent); - handleTemplateLoadingSuccess($templateContainer, template, selection, data, settings); + handleTemplateLoadingSuccess($(templateContent), template, selection, data, settings); }, error: function (e) { handleTemplateLoadingError(template, selection, data, settings, e); @@ -204,14 +194,11 @@ } function loadTemplateFromDocument($template, selection, data, settings) { - var $templateContainer = $("
    "); - if ($template.is("script") || $template.is("template")) { $template = $.parseHTML($.trim($template.html())); } - $templateContainer.html($template); - prepareTemplate.call(selection, $templateContainer, data, settings); + prepareTemplate.call(selection, $template, data, settings); if (typeof settings.success === "function") { settings.success(); @@ -222,7 +209,7 @@ bindData(template, data, settings); $(this).each(function () { - var $templateHtml = template.clone(true); + var $templateHtml = $(template).clone(true); $("select", $templateHtml).each(function (key, value) { $(this).val($("select", template).eq(key).val()) }); @@ -372,7 +359,7 @@ } function processElements(attribute, template, data, settings, dataBindFunction, noDataFunction) { - $("[" + attribute + "]", template).each(function () { + $("[" + attribute + "]", $("
    ").append(template)).each(function () { var $this = $(this), param = $this.attr(attribute), value = getValue(data, param); @@ -431,7 +418,7 @@ } function processAllElements(template, data, settings) { - $("[data-template-bind]", template).each(function () { + $("[data-template-bind]", $("
    ").append(template)).each(function () { var $this = $(this), param = $.parseJSON($this.attr("data-template-bind")); diff --git a/dist/jquery.loadTemplate-1.5.8.min.js b/dist/jquery.loadTemplate-1.5.8.min.js new file mode 100644 index 0000000..b1b6793 --- /dev/null +++ b/dist/jquery.loadTemplate-1.5.8.min.js @@ -0,0 +1 @@ +(function(a){var w={},v={},h={},m;function o(G,C,E){var B=this,A,D,F;C=C||{};F=a.extend(true,{async:true,overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(F.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null,bindingOptions:{ignoreUndefined:false,ignoreNull:false,ignoreEmptyString:false}},E);if(a.type(C)==="array"){m=true;return t.call(this,G,C,F)}if(!g(G)){A=a(G);if(typeof G==="string"&&G.indexOf("#")===0){F.isFile=false}}D=F.isFile||(typeof F.isFile==="undefined"&&(typeof A==="undefined"||A.length===0));if(D&&!F.overwriteCache&&w[G]){r(G,B,C,F)}else{if(D&&!F.overwriteCache&&w.hasOwnProperty(G)){c(G,B,C,F)}else{if(D){n(G,B,C,F)}else{p(A,B,C,F)}}}return this}function b(B,A){if(A){h[B]=A}else{h=a.extend(h,B)}}function g(A){return typeof A==="string"&&A.indexOf("/")>-1}function t(K,B,H){H=H||{};var A=this,L=B.length,D=H.prepend&&!H.append,C=0,J=0,E=false,F=[],G;if(H.paged){var I=(H.pageNo-1)*H.elemPerPage;B=B.slice(I,I+H.elemPerPage);L=B.length}if(!H.append&&!H.prepend){A.html("")}G=a.extend({},H,{async:false,append:!H.prepend&&true,complete:function(M){C++;if(C===L||E){if(E&&H&&typeof H.error==="function"){H.error.call(A,F)}if(H&&typeof H.complete==="function"){H.complete()}}},success:function(){J++;if(J===L){if(H&&typeof H.success==="function"){H.success()}}},error:function(M){E=true;F.push(M)}});if(D){B.reverse()}a(B).each(function(){o.call(A,K,this,G);if(E){return false}});return this}function c(D,B,A,C){if(v[D]){v[D].push({data:A,selection:B,settings:C})}else{v[D]=[{data:A,selection:B,settings:C}]}}function r(E,C,B,D){var A=w[E].clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function x(){return new Date().getTime()}function y(A){if(A.indexOf("?")!==-1){return A+"&_="+x()}else{return A+"?_="+x()}}function n(D,B,A,C){w[D]=null;var E=D;if(C.overwriteCache){E=y(E)}a.ajax({url:E,async:C.async,success:function(F){l(a(F),D,B,A,C)},error:function(F){k(D,B,A,C,F)}})}function p(A,C,B,D){if(A.is("script")||A.is("template")){A=a.parseHTML(a.trim(A.html()))}q.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function q(C,A,B){f(C,A,B);a(this).each(function(){var D=a(C).clone(true);a("select",D).each(function(E,F){a(this).val(a("select",C).eq(E).val())});if(B.beforeInsert){B.beforeInsert(D,A)}if(B.append){a(this).append(D)}else{if(B.prepend){a(this).prepend(D)}else{a(this).html("").append(D)}}if(B.afterInsert&&!m){B.afterInsert(D,A)}});if(typeof B.complete==="function"){B.complete.call(a(this),A)}}function k(E,C,A,D,B){var F;if(typeof D.error==="function"){D.error.call(C,B)}a(v[E]).each(function(G,H){if(typeof H.settings.error==="function"){H.settings.error.call(H.selection,B)}});if(typeof D.complete==="function"){D.complete.call(C)}while(v[E]&&(F=v[E].shift())){if(typeof F.settings.complete==="function"){F.settings.complete.call(F.selection)}}if(typeof v[E]!=="undefined"&&v[E].length>0){v[E]=[]}}function l(A,E,C,B,D){var F;w[E]=A.clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success.call(C)}while(v[E]&&(F=v[E].shift())){q.call(F.selection,w[E].clone(),F.data,F.settings);if(typeof F.settings.success==="function"){F.settings.success.call(F.selection)}}}function f(C,A,B){A=A||{};u("data-content",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-content-append",C,A,B,function(D,E){D.append(e(D,E,"content",B))});u("data-content-prepend",C,A,B,function(D,E){D.prepend(e(D,E,"content",B))});u("data-content-text",C,A,B,function(D,E){D.text(e(D,E,"content",B))});u("data-innerHTML",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-src",C,A,B,function(D,E){D.attr("src",e(D,E,"src",B))},function(D){D.remove()});u("data-href",C,A,B,function(D,E){D.attr("href",e(D,E,"href",B))},function(D){D.remove()});u("data-alt",C,A,B,function(D,E){D.attr("alt",e(D,E,"alt",B))});u("data-id",C,A,B,function(D,E){D.attr("id",e(D,E,"id",B))});u("data-class",C,A,B,function(D,E){D.addClass(e(D,E,"class",B))});u("data-link",C,A,B,function(D,F){var E=a("");E.attr("href",e(D,F,"link",B));E.html(D.html());D.html(E)});u("data-link-wrap",C,A,B,function(D,F){var E=a("");E.attr("href",e(D,F,"link-wrap",B));D.wrap(E)});u("data-options",C,A,B,function(D,E){a(E).each(function(){var F=a("
    ").append(F)).each(function(){var G=a(this),H=G.attr(A),I=j(B,H);if(!z(G,I,E)){G.remove();return}G.removeAttr(A);if(typeof I!=="undefined"&&C){C(G,I)}else{if(D){D(G)}}});return}function z(B,D,C){var A=i(B,C);if(A.ignoreUndefined&&typeof D==="undefined"){return false}else{if(A.ignoreNull&&D===null){return false}else{if(A.ignoreEmptyString&&D===""){return false}else{return true}}}}function i(B,C){var A={};if(B instanceof jQuery&&B.attr("data-binding-options")){A=a.parseJSON(B.attr("data-binding-options"));B.removeAttr("data-binding-options")}else{if(typeof B==="object"&&B.hasOwnProperty("bindingOptions")){A=B.bindingOptions}}return a.extend({},C.bindingOptions,A)}function s(C,A,B){a("[data-template-bind]",a("
    ").append(C)).each(function(){var D=a(this),E=a.parseJSON(D.attr("data-template-bind"));D.removeAttr("data-template-bind");a(E).each(function(){var G;if(typeof(this.value)==="object"){G=j(A,this.value.data)}else{G=j(A,this.value)}if(this.attribute){if(!z(this,G,B)){D.remove();return}switch(this.attribute){case"content":case"innerHTML":D.html(d(D,G,this));break;case"contentAppend":D.append(d(D,G,this));break;case"contentPrepend":D.prepend(d(D,G,this));break;case"contentText":D.text(d(D,G,this));break;case"options":var F=this;a(G).each(function(){var H=a("
    diff --git a/bower.json b/bower.json index e8f401f..2e75fef 100644 --- a/bower.json +++ b/bower.json @@ -9,7 +9,7 @@ "type": "git", "url": "https://github.com/codepb/jquery-template.git" }, - "main": "dist/jquery.loadTemplate-1.5.8.js", + "main": "dist/jquery.loadTemplate-1.5.9.js", "keywords": [ "templates", "templating", diff --git a/dist/jquery.loadTemplate-1.5.8.min.js b/dist/jquery.loadTemplate-1.5.8.min.js deleted file mode 100644 index b1b6793..0000000 --- a/dist/jquery.loadTemplate-1.5.8.min.js +++ /dev/null @@ -1 +0,0 @@ -(function(a){var w={},v={},h={},m;function o(G,C,E){var B=this,A,D,F;C=C||{};F=a.extend(true,{async:true,overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(F.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null,bindingOptions:{ignoreUndefined:false,ignoreNull:false,ignoreEmptyString:false}},E);if(a.type(C)==="array"){m=true;return t.call(this,G,C,F)}if(!g(G)){A=a(G);if(typeof G==="string"&&G.indexOf("#")===0){F.isFile=false}}D=F.isFile||(typeof F.isFile==="undefined"&&(typeof A==="undefined"||A.length===0));if(D&&!F.overwriteCache&&w[G]){r(G,B,C,F)}else{if(D&&!F.overwriteCache&&w.hasOwnProperty(G)){c(G,B,C,F)}else{if(D){n(G,B,C,F)}else{p(A,B,C,F)}}}return this}function b(B,A){if(A){h[B]=A}else{h=a.extend(h,B)}}function g(A){return typeof A==="string"&&A.indexOf("/")>-1}function t(K,B,H){H=H||{};var A=this,L=B.length,D=H.prepend&&!H.append,C=0,J=0,E=false,F=[],G;if(H.paged){var I=(H.pageNo-1)*H.elemPerPage;B=B.slice(I,I+H.elemPerPage);L=B.length}if(!H.append&&!H.prepend){A.html("")}G=a.extend({},H,{async:false,append:!H.prepend&&true,complete:function(M){C++;if(C===L||E){if(E&&H&&typeof H.error==="function"){H.error.call(A,F)}if(H&&typeof H.complete==="function"){H.complete()}}},success:function(){J++;if(J===L){if(H&&typeof H.success==="function"){H.success()}}},error:function(M){E=true;F.push(M)}});if(D){B.reverse()}a(B).each(function(){o.call(A,K,this,G);if(E){return false}});return this}function c(D,B,A,C){if(v[D]){v[D].push({data:A,selection:B,settings:C})}else{v[D]=[{data:A,selection:B,settings:C}]}}function r(E,C,B,D){var A=w[E].clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function x(){return new Date().getTime()}function y(A){if(A.indexOf("?")!==-1){return A+"&_="+x()}else{return A+"?_="+x()}}function n(D,B,A,C){w[D]=null;var E=D;if(C.overwriteCache){E=y(E)}a.ajax({url:E,async:C.async,success:function(F){l(a(F),D,B,A,C)},error:function(F){k(D,B,A,C,F)}})}function p(A,C,B,D){if(A.is("script")||A.is("template")){A=a.parseHTML(a.trim(A.html()))}q.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function q(C,A,B){f(C,A,B);a(this).each(function(){var D=a(C).clone(true);a("select",D).each(function(E,F){a(this).val(a("select",C).eq(E).val())});if(B.beforeInsert){B.beforeInsert(D,A)}if(B.append){a(this).append(D)}else{if(B.prepend){a(this).prepend(D)}else{a(this).html("").append(D)}}if(B.afterInsert&&!m){B.afterInsert(D,A)}});if(typeof B.complete==="function"){B.complete.call(a(this),A)}}function k(E,C,A,D,B){var F;if(typeof D.error==="function"){D.error.call(C,B)}a(v[E]).each(function(G,H){if(typeof H.settings.error==="function"){H.settings.error.call(H.selection,B)}});if(typeof D.complete==="function"){D.complete.call(C)}while(v[E]&&(F=v[E].shift())){if(typeof F.settings.complete==="function"){F.settings.complete.call(F.selection)}}if(typeof v[E]!=="undefined"&&v[E].length>0){v[E]=[]}}function l(A,E,C,B,D){var F;w[E]=A.clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success.call(C)}while(v[E]&&(F=v[E].shift())){q.call(F.selection,w[E].clone(),F.data,F.settings);if(typeof F.settings.success==="function"){F.settings.success.call(F.selection)}}}function f(C,A,B){A=A||{};u("data-content",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-content-append",C,A,B,function(D,E){D.append(e(D,E,"content",B))});u("data-content-prepend",C,A,B,function(D,E){D.prepend(e(D,E,"content",B))});u("data-content-text",C,A,B,function(D,E){D.text(e(D,E,"content",B))});u("data-innerHTML",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-src",C,A,B,function(D,E){D.attr("src",e(D,E,"src",B))},function(D){D.remove()});u("data-href",C,A,B,function(D,E){D.attr("href",e(D,E,"href",B))},function(D){D.remove()});u("data-alt",C,A,B,function(D,E){D.attr("alt",e(D,E,"alt",B))});u("data-id",C,A,B,function(D,E){D.attr("id",e(D,E,"id",B))});u("data-class",C,A,B,function(D,E){D.addClass(e(D,E,"class",B))});u("data-link",C,A,B,function(D,F){var E=a("");E.attr("href",e(D,F,"link",B));E.html(D.html());D.html(E)});u("data-link-wrap",C,A,B,function(D,F){var E=a("");E.attr("href",e(D,F,"link-wrap",B));D.wrap(E)});u("data-options",C,A,B,function(D,E){a(E).each(function(){var F=a("
    ").append(F)).each(function(){var G=a(this),H=G.attr(A),I=j(B,H);if(!z(G,I,E)){G.remove();return}G.removeAttr(A);if(typeof I!=="undefined"&&C){C(G,I)}else{if(D){D(G)}}});return}function z(B,D,C){var A=i(B,C);if(A.ignoreUndefined&&typeof D==="undefined"){return false}else{if(A.ignoreNull&&D===null){return false}else{if(A.ignoreEmptyString&&D===""){return false}else{return true}}}}function i(B,C){var A={};if(B instanceof jQuery&&B.attr("data-binding-options")){A=a.parseJSON(B.attr("data-binding-options"));B.removeAttr("data-binding-options")}else{if(typeof B==="object"&&B.hasOwnProperty("bindingOptions")){A=B.bindingOptions}}return a.extend({},C.bindingOptions,A)}function s(C,A,B){a("[data-template-bind]",a("
    ").append(C)).each(function(){var D=a(this),E=a.parseJSON(D.attr("data-template-bind"));D.removeAttr("data-template-bind");a(E).each(function(){var G;if(typeof(this.value)==="object"){G=j(A,this.value.data)}else{G=j(A,this.value)}if(this.attribute){if(!z(this,G,B)){D.remove();return}switch(this.attribute){case"content":case"innerHTML":D.html(d(D,G,this));break;case"contentAppend":D.append(d(D,G,this));break;case"contentPrepend":D.prepend(d(D,G,this));break;case"contentText":D.text(d(D,G,this));break;case"options":var F=this;a(G).each(function(){var H=a("
    ").append(template); bindData(template, data, settings); $(this).each(function () { - var $templateHtml = $(template).clone(true); + var $templateHtml = template.children().clone(true); $("select", $templateHtml).each(function (key, value) { $(this).val($("select", template).eq(key).val()) }); @@ -224,7 +225,7 @@ } else { $(this).html("").append($templateHtml); } - if (settings.afterInsert && !isArray) { + if (settings.afterInsert) { settings.afterInsert($templateHtml, data); } }); @@ -359,7 +360,7 @@ } function processElements(attribute, template, data, settings, dataBindFunction, noDataFunction) { - $("[" + attribute + "]", $("
    ").append(template)).each(function () { + $("[" + attribute + "]", template).each(function () { var $this = $(this), param = $this.attr(attribute), value = getValue(data, param); @@ -418,7 +419,7 @@ } function processAllElements(template, data, settings) { - $("[data-template-bind]", $("
    ").append(template)).each(function () { + $("[data-template-bind]", template).each(function () { var $this = $(this), param = $.parseJSON($this.attr("data-template-bind")); diff --git a/dist/jquery.loadTemplate-1.5.9.min.js b/dist/jquery.loadTemplate-1.5.9.min.js new file mode 100644 index 0000000..8488916 --- /dev/null +++ b/dist/jquery.loadTemplate-1.5.9.min.js @@ -0,0 +1 @@ +(function(a){var w={},v={},h={},m;function o(G,C,E){var B=this,A,D,F;C=C||{};F=a.extend(true,{async:true,overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(F.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null,bindingOptions:{ignoreUndefined:false,ignoreNull:false,ignoreEmptyString:false}},E);if(a.type(C)==="array"){m=true;return t.call(this,G,C,F)}if(!g(G)){A=a(G);if(typeof G==="string"&&G.indexOf("#")===0){F.isFile=false}}D=F.isFile||(typeof F.isFile==="undefined"&&(typeof A==="undefined"||A.length===0));if(D&&!F.overwriteCache&&w[G]){r(G,B,C,F)}else{if(D&&!F.overwriteCache&&w.hasOwnProperty(G)){c(G,B,C,F)}else{if(D){n(G,B,C,F)}else{p(A,B,C,F)}}}return this}function b(B,A){if(A){h[B]=A}else{h=a.extend(h,B)}}function g(A){return typeof A==="string"&&A.indexOf("/")>-1}function t(K,B,H){H=H||{};var A=this,L=B.length,D=H.prepend&&!H.append,C=0,J=0,E=false,F=[],G;if(H.paged){var I=(H.pageNo-1)*H.elemPerPage;B=B.slice(I,I+H.elemPerPage);L=B.length}if(!H.append&&!H.prepend){A.html("")}G=a.extend({},H,{async:false,append:!H.prepend&&true,complete:function(M){C++;if(C===L||E){if(E&&H&&typeof H.error==="function"){H.error.call(A,F)}if(H&&typeof H.complete==="function"){H.complete()}}},success:function(){J++;if(J===L){if(H&&typeof H.success==="function"){H.success()}}},error:function(M){E=true;F.push(M)}});if(D){B.reverse()}a(B).each(function(){o.call(A,K,this,G);if(E){return false}});return this}function c(D,B,A,C){if(v[D]){v[D].push({data:A,selection:B,settings:C})}else{v[D]=[{data:A,selection:B,settings:C}]}}function r(E,C,B,D){var A=w[E].clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function x(){return new Date().getTime()}function y(A){if(A.indexOf("?")!==-1){return A+"&_="+x()}else{return A+"?_="+x()}}function n(D,B,A,C){w[D]=null;var E=D;if(C.overwriteCache){E=y(E)}a.ajax({url:E,async:C.async,success:function(F){l(a(F),D,B,A,C)},error:function(F){k(D,B,A,C,F)}})}function p(A,C,B,D){if(A.is("script")||A.is("template")){A=a.parseHTML(a.trim(A.html()))}q.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function q(C,A,B){var C=a("
    ").append(C);f(C,A,B);a(this).each(function(){var D=C.children().clone(true);a("select",D).each(function(E,F){a(this).val(a("select",C).eq(E).val())});if(B.beforeInsert){B.beforeInsert(D,A)}if(B.append){a(this).append(D)}else{if(B.prepend){a(this).prepend(D)}else{a(this).html("").append(D)}}if(B.afterInsert){B.afterInsert(D,A)}});if(typeof B.complete==="function"){B.complete.call(a(this),A)}}function k(E,C,A,D,B){var F;if(typeof D.error==="function"){D.error.call(C,B)}a(v[E]).each(function(G,H){if(typeof H.settings.error==="function"){H.settings.error.call(H.selection,B)}});if(typeof D.complete==="function"){D.complete.call(C)}while(v[E]&&(F=v[E].shift())){if(typeof F.settings.complete==="function"){F.settings.complete.call(F.selection)}}if(typeof v[E]!=="undefined"&&v[E].length>0){v[E]=[]}}function l(A,E,C,B,D){var F;w[E]=A.clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success.call(C)}while(v[E]&&(F=v[E].shift())){q.call(F.selection,w[E].clone(),F.data,F.settings);if(typeof F.settings.success==="function"){F.settings.success.call(F.selection)}}}function f(C,A,B){A=A||{};u("data-content",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-content-append",C,A,B,function(D,E){D.append(e(D,E,"content",B))});u("data-content-prepend",C,A,B,function(D,E){D.prepend(e(D,E,"content",B))});u("data-content-text",C,A,B,function(D,E){D.text(e(D,E,"content",B))});u("data-innerHTML",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-src",C,A,B,function(D,E){D.attr("src",e(D,E,"src",B))},function(D){D.remove()});u("data-href",C,A,B,function(D,E){D.attr("href",e(D,E,"href",B))},function(D){D.remove()});u("data-alt",C,A,B,function(D,E){D.attr("alt",e(D,E,"alt",B))});u("data-id",C,A,B,function(D,E){D.attr("id",e(D,E,"id",B))});u("data-class",C,A,B,function(D,E){D.addClass(e(D,E,"class",B))});u("data-link",C,A,B,function(D,F){var E=a("");E.attr("href",e(D,F,"link",B));E.html(D.html());D.html(E)});u("data-link-wrap",C,A,B,function(D,F){var E=a("");E.attr("href",e(D,F,"link-wrap",B));D.wrap(E)});u("data-options",C,A,B,function(D,E){a(E).each(function(){var F=a("
    diff --git a/bower.json b/bower.json index 2e75fef..cbbf747 100644 --- a/bower.json +++ b/bower.json @@ -9,7 +9,7 @@ "type": "git", "url": "https://github.com/codepb/jquery-template.git" }, - "main": "dist/jquery.loadTemplate-1.5.9.js", + "main": "dist/jquery.loadTemplate.js", "keywords": [ "templates", "templating", diff --git a/dist/jquery.loadTemplate-1.5.9.min.js b/dist/jquery.loadTemplate-1.5.9.min.js deleted file mode 100644 index 8488916..0000000 --- a/dist/jquery.loadTemplate-1.5.9.min.js +++ /dev/null @@ -1 +0,0 @@ -(function(a){var w={},v={},h={},m;function o(G,C,E){var B=this,A,D,F;C=C||{};F=a.extend(true,{async:true,overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(F.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null,bindingOptions:{ignoreUndefined:false,ignoreNull:false,ignoreEmptyString:false}},E);if(a.type(C)==="array"){m=true;return t.call(this,G,C,F)}if(!g(G)){A=a(G);if(typeof G==="string"&&G.indexOf("#")===0){F.isFile=false}}D=F.isFile||(typeof F.isFile==="undefined"&&(typeof A==="undefined"||A.length===0));if(D&&!F.overwriteCache&&w[G]){r(G,B,C,F)}else{if(D&&!F.overwriteCache&&w.hasOwnProperty(G)){c(G,B,C,F)}else{if(D){n(G,B,C,F)}else{p(A,B,C,F)}}}return this}function b(B,A){if(A){h[B]=A}else{h=a.extend(h,B)}}function g(A){return typeof A==="string"&&A.indexOf("/")>-1}function t(K,B,H){H=H||{};var A=this,L=B.length,D=H.prepend&&!H.append,C=0,J=0,E=false,F=[],G;if(H.paged){var I=(H.pageNo-1)*H.elemPerPage;B=B.slice(I,I+H.elemPerPage);L=B.length}if(!H.append&&!H.prepend){A.html("")}G=a.extend({},H,{async:false,append:!H.prepend&&true,complete:function(M){C++;if(C===L||E){if(E&&H&&typeof H.error==="function"){H.error.call(A,F)}if(H&&typeof H.complete==="function"){H.complete()}}},success:function(){J++;if(J===L){if(H&&typeof H.success==="function"){H.success()}}},error:function(M){E=true;F.push(M)}});if(D){B.reverse()}a(B).each(function(){o.call(A,K,this,G);if(E){return false}});return this}function c(D,B,A,C){if(v[D]){v[D].push({data:A,selection:B,settings:C})}else{v[D]=[{data:A,selection:B,settings:C}]}}function r(E,C,B,D){var A=w[E].clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function x(){return new Date().getTime()}function y(A){if(A.indexOf("?")!==-1){return A+"&_="+x()}else{return A+"?_="+x()}}function n(D,B,A,C){w[D]=null;var E=D;if(C.overwriteCache){E=y(E)}a.ajax({url:E,async:C.async,success:function(F){l(a(F),D,B,A,C)},error:function(F){k(D,B,A,C,F)}})}function p(A,C,B,D){if(A.is("script")||A.is("template")){A=a.parseHTML(a.trim(A.html()))}q.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function q(C,A,B){var C=a("
    ").append(C);f(C,A,B);a(this).each(function(){var D=C.children().clone(true);a("select",D).each(function(E,F){a(this).val(a("select",C).eq(E).val())});if(B.beforeInsert){B.beforeInsert(D,A)}if(B.append){a(this).append(D)}else{if(B.prepend){a(this).prepend(D)}else{a(this).html("").append(D)}}if(B.afterInsert){B.afterInsert(D,A)}});if(typeof B.complete==="function"){B.complete.call(a(this),A)}}function k(E,C,A,D,B){var F;if(typeof D.error==="function"){D.error.call(C,B)}a(v[E]).each(function(G,H){if(typeof H.settings.error==="function"){H.settings.error.call(H.selection,B)}});if(typeof D.complete==="function"){D.complete.call(C)}while(v[E]&&(F=v[E].shift())){if(typeof F.settings.complete==="function"){F.settings.complete.call(F.selection)}}if(typeof v[E]!=="undefined"&&v[E].length>0){v[E]=[]}}function l(A,E,C,B,D){var F;w[E]=A.clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success.call(C)}while(v[E]&&(F=v[E].shift())){q.call(F.selection,w[E].clone(),F.data,F.settings);if(typeof F.settings.success==="function"){F.settings.success.call(F.selection)}}}function f(C,A,B){A=A||{};u("data-content",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-content-append",C,A,B,function(D,E){D.append(e(D,E,"content",B))});u("data-content-prepend",C,A,B,function(D,E){D.prepend(e(D,E,"content",B))});u("data-content-text",C,A,B,function(D,E){D.text(e(D,E,"content",B))});u("data-innerHTML",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-src",C,A,B,function(D,E){D.attr("src",e(D,E,"src",B))},function(D){D.remove()});u("data-href",C,A,B,function(D,E){D.attr("href",e(D,E,"href",B))},function(D){D.remove()});u("data-alt",C,A,B,function(D,E){D.attr("alt",e(D,E,"alt",B))});u("data-id",C,A,B,function(D,E){D.attr("id",e(D,E,"id",B))});u("data-class",C,A,B,function(D,E){D.addClass(e(D,E,"class",B))});u("data-link",C,A,B,function(D,F){var E=a("");E.attr("href",e(D,F,"link",B));E.html(D.html());D.html(E)});u("data-link-wrap",C,A,B,function(D,F){var E=a("");E.attr("href",e(D,F,"link-wrap",B));D.wrap(E)});u("data-options",C,A,B,function(D,E){a(E).each(function(){var F=a("
    ").append(C);f(C,A,B);a(this).each(function(){var D=C.children().clone(true);a("select",D).each(function(E,F){a(this).val(a("select",C).eq(E).val())});if(B.beforeInsert){B.beforeInsert(D,A)}if(B.append){a(this).append(D)}else{if(B.prepend){a(this).prepend(D)}else{a(this).html("").append(D)}}if(B.afterInsert){B.afterInsert(D,A)}});if(typeof B.complete==="function"){B.complete.call(a(this),A)}}function k(E,C,A,D,B){var F;if(typeof D.error==="function"){D.error.call(C,B)}a(v[E]).each(function(G,H){if(typeof H.settings.error==="function"){H.settings.error.call(H.selection,B)}});if(typeof D.complete==="function"){D.complete.call(C)}while(v[E]&&(F=v[E].shift())){if(typeof F.settings.complete==="function"){F.settings.complete.call(F.selection)}}if(typeof v[E]!=="undefined"&&v[E].length>0){v[E]=[]}}function l(A,E,C,B,D){var F;w[E]=A.clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success.call(C)}while(v[E]&&(F=v[E].shift())){q.call(F.selection,w[E].clone(),F.data,F.settings);if(typeof F.settings.success==="function"){F.settings.success.call(F.selection)}}}function f(C,A,B){A=A||{};u("data-content",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-content-append",C,A,B,function(D,E){D.append(e(D,E,"content",B))});u("data-content-prepend",C,A,B,function(D,E){D.prepend(e(D,E,"content",B))});u("data-content-text",C,A,B,function(D,E){D.text(e(D,E,"content",B))});u("data-innerHTML",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-src",C,A,B,function(D,E){D.attr("src",e(D,E,"src",B))},function(D){D.remove()});u("data-href",C,A,B,function(D,E){D.attr("href",e(D,E,"href",B))},function(D){D.remove()});u("data-alt",C,A,B,function(D,E){D.attr("alt",e(D,E,"alt",B))});u("data-id",C,A,B,function(D,E){D.attr("id",e(D,E,"id",B))});u("data-class",C,A,B,function(D,E){D.addClass(e(D,E,"class",B))});u("data-link",C,A,B,function(D,F){var E=a("");E.attr("href",e(D,F,"link",B));E.html(D.html());D.html(E)});u("data-link-wrap",C,A,B,function(D,F){var E=a("");E.attr("href",e(D,F,"link-wrap",B));D.wrap(E)});u("data-options",C,A,B,function(D,E){a(E).each(function(){var F=a("
    ").append(C);f(C,A,B);a(this).each(function(){var D=C.children().clone(true);a("select",D).each(function(E,F){a(this).val(a("select",C).eq(E).val())});if(B.beforeInsert){B.beforeInsert(D,A)}if(B.append){a(this).append(D)}else{if(B.prepend){a(this).prepend(D)}else{a(this).html("").append(D)}}if(B.afterInsert){B.afterInsert(D,A)}});if(typeof B.complete==="function"){B.complete.call(a(this),A)}}function k(E,C,A,D,B){var F;if(typeof D.error==="function"){D.error.call(C,B)}a(v[E]).each(function(G,H){if(typeof H.settings.error==="function"){H.settings.error.call(H.selection,B)}});if(typeof D.complete==="function"){D.complete.call(C)}while(v[E]&&(F=v[E].shift())){if(typeof F.settings.complete==="function"){F.settings.complete.call(F.selection)}}if(typeof v[E]!=="undefined"&&v[E].length>0){v[E]=[]}}function l(A,E,C,B,D){var F;w[E]=A.clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success.call(C)}while(v[E]&&(F=v[E].shift())){q.call(F.selection,w[E].clone(),F.data,F.settings);if(typeof F.settings.success==="function"){F.settings.success.call(F.selection)}}}function f(C,A,B){A=A||{};u("data-content",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-content-append",C,A,B,function(D,E){D.append(e(D,E,"content",B))});u("data-content-prepend",C,A,B,function(D,E){D.prepend(e(D,E,"content",B))});u("data-content-text",C,A,B,function(D,E){D.text(e(D,E,"content",B))});u("data-innerHTML",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-src",C,A,B,function(D,E){D.attr("src",e(D,E,"src",B))},function(D){D.remove()});u("data-href",C,A,B,function(D,E){D.attr("href",e(D,E,"href",B))},function(D){D.remove()});u("data-alt",C,A,B,function(D,E){D.attr("alt",e(D,E,"alt",B))});u("data-id",C,A,B,function(D,E){D.attr("id",e(D,E,"id",B))});u("data-class",C,A,B,function(D,E){D.addClass(e(D,E,"class",B))});u("data-link",C,A,B,function(D,F){var E=a("");E.attr("href",e(D,F,"link",B));E.html(D.html());D.html(E)});u("data-link-wrap",C,A,B,function(D,F){var E=a("");E.attr("href",e(D,F,"link-wrap",B));D.wrap(E)});u("data-options",C,A,B,function(D,E){a(E).each(function(){var F=a("
    ").append(e);h(e,n,a),t(this).each(function(){var r=e.children().clone(!0);t("select",r).each(function(n,a){t(this).val(t("select",e).eq(n).val())}),a.beforeInsert&&a.beforeInsert(r,n),a.append?t(this).append(r):a.prepend?t(this).prepend(r):t(this).html("").append(r),a.afterInsert&&a.afterInsert(r,n)}),"function"==typeof a.complete&&a.complete.call(t(this),n)}function p(e,n,a,r,i){var o;for("function"==typeof r.error&&r.error.call(n,i),t(k[e]).each(function(t,e){"function"==typeof e.settings.error&&e.settings.error.call(e.selection,i)}),"function"==typeof r.complete&&r.complete.call(n);k[e]&&(o=k[e].shift());)"function"==typeof o.settings.complete&&o.settings.complete.call(o.selection);"undefined"!=typeof k[e]&&k[e].length>0&&(k[e]=[])}function d(t,e,n,a,r){var i;for(w[e]=t.clone(),u.call(n,t,a,r),"function"==typeof r.success&&r.success.call(n);k[e]&&(i=k[e].shift());)u.call(i.selection,w[e].clone(),i.data,i.settings),"function"==typeof i.settings.success&&i.settings.success.call(i.selection)}function h(e,n,a){n=n||{},v("data-content",e,n,a,function(t,e){t.html(O(t,e,"content",a))}),v("data-content-append",e,n,a,function(t,e){t.append(O(t,e,"content",a))}),v("data-content-prepend",e,n,a,function(t,e){t.prepend(O(t,e,"content",a))}),v("data-content-text",e,n,a,function(t,e){t.text(O(t,e,"content",a))}),v("data-innerHTML",e,n,a,function(t,e){t.html(O(t,e,"content",a))}),v("data-src",e,n,a,function(t,e){t.attr("src",O(t,e,"src",a))},function(t){t.remove()}),v("data-href",e,n,a,function(t,e){t.attr("href",O(t,e,"href",a))},function(t){t.remove()}),v("data-alt",e,n,a,function(t,e){t.attr("alt",O(t,e,"alt",a))}),v("data-id",e,n,a,function(t,e){t.attr("id",O(t,e,"id",a))}),v("data-css",e,n,a,function(t,e){t.css(O(t,e,"css",a))}),v("data-class",e,n,a,function(t,e){t.addClass(O(t,e,"class",a))}),v("data-link",e,n,a,function(e,n){var r=t("");r.attr("href",O(e,n,"link",a)),r.html(e.html()),e.html(r)}),v("data-link-wrap",e,n,a,function(e,n){var r=t("");r.attr("href",O(e,n,"link-wrap",a)),e.wrap(r)}),v("data-options",e,n,a,function(e,n){t(n).each(function(){var n=t("
    ").append(e);h(e,n,a),t(this).each(function(){var r=e.children().clone(!0);t("select",r).each(function(n,a){t(this).val(t("select",e).eq(n).val())}),a.beforeInsert&&a.beforeInsert(r,n),a.append?t(this).append(r):a.prepend?t(this).prepend(r):t(this).html("").append(r),a.afterInsert&&a.afterInsert(r,n)}),"function"==typeof a.complete&&a.complete.call(t(this),n)}function p(e,n,a,r,i){var o;for("function"==typeof r.error&&r.error.call(n,i),t(k[e]).each(function(t,e){"function"==typeof e.settings.error&&e.settings.error.call(e.selection,i)}),"function"==typeof r.complete&&r.complete.call(n);k[e]&&(o=k[e].shift());)"function"==typeof o.settings.complete&&o.settings.complete.call(o.selection);"undefined"!=typeof k[e]&&k[e].length>0&&(k[e]=[])}function d(t,e,n,a,r){var i;for(w[e]=t.clone(),u.call(n,t,a,r),"function"==typeof r.success&&r.success.call(n);k[e]&&(i=k[e].shift());)u.call(i.selection,w[e].clone(),i.data,i.settings),"function"==typeof i.settings.success&&i.settings.success.call(i.selection)}function h(e,n,a){n=n||{},v("data-content",e,n,a,function(t,e){t.html(O(t,e,"content",a))}),v("data-content-append",e,n,a,function(t,e){t.append(O(t,e,"content",a))}),v("data-content-prepend",e,n,a,function(t,e){t.prepend(O(t,e,"content",a))}),v("data-content-text",e,n,a,function(t,e){t.text(O(t,e,"content",a))}),v("data-innerHTML",e,n,a,function(t,e){t.html(O(t,e,"content",a))}),v("data-src",e,n,a,function(t,e){t.attr("src",O(t,e,"src",a))},function(t){t.remove()}),v("data-href",e,n,a,function(t,e){t.attr("href",O(t,e,"href",a))},function(t){t.remove()}),v("data-alt",e,n,a,function(t,e){t.attr("alt",O(t,e,"alt",a))}),v("data-id",e,n,a,function(t,e){t.attr("id",O(t,e,"id",a))}),v("data-css",e,n,a,function(t,e){t.css(O(t,e,"css",a))}),v("data-class",e,n,a,function(t,e){t.addClass(O(t,e,"class",a))}),v("data-link",e,n,a,function(e,n){var r=t("");r.attr("href",O(e,n,"link",a)),r.html(e.html()),e.html(r)}),v("data-link-wrap",e,n,a,function(e,n){var r=t("");r.attr("href",O(e,n,"link-wrap",a)),e.wrap(r)}),v("data-options",e,n,a,function(e,n){t(n).each(function(){var n=t("
    ").append(e),n,a),t(this).each(function(){var i=e.children().clone(!0);t("select",i).each(function(n,a){t(this).val(t("select",e).eq(n).val())}),a.beforeInsert&&a.beforeInsert(i,n),a.append?t(this).append(i):a.prepend?t(this).prepend(i):t(this).html("").append(i),a.afterInsert&&a.afterInsert(i,n)}),"function"==typeof a.complete&&a.complete.call(t(this),n)}function p(e,n,a,i,r){var o;for("function"==typeof i.error&&i.error.call(n,r),t(k[e]).each(function(t,e){"function"==typeof e.settings.error&&e.settings.error.call(e.selection,r)}),"function"==typeof i.complete&&i.complete.call(n);k[e]&&(o=k[e].shift());)"function"==typeof o.settings.complete&&o.settings.complete.call(o.selection);void 0!==k[e]&&k[e].length>0&&(k[e]=[])}function d(t,e,n,a,i){var r;for(w[e]=t.clone(),f.call(n,t,a,i),"function"==typeof i.success&&i.success.call(n);k[e]&&(r=k[e].shift());)f.call(r.selection,w[e].clone(),r.data,r.settings),"function"==typeof r.settings.success&&r.settings.success.call(r.selection)}function h(e,n,a){v("data-content",e,n=n||{},a,function(t,e){t.html(O(t,e,"content",a))}),v("data-content-append",e,n,a,function(t,e){t.append(O(t,e,"content",a))}),v("data-content-prepend",e,n,a,function(t,e){t.prepend(O(t,e,"content",a))}),v("data-content-text",e,n,a,function(t,e){t.text(O(t,e,"content",a))}),v("data-innerHTML",e,n,a,function(t,e){t.html(O(t,e,"content",a))}),v("data-src",e,n,a,function(t,e){t.attr("src",O(t,e,"src",a))},function(t){t.remove()}),v("data-href",e,n,a,function(t,e){t.attr("href",O(t,e,"href",a))},function(t){t.remove()}),v("data-alt",e,n,a,function(t,e){t.attr("alt",O(t,e,"alt",a))}),v("data-title",e,n,a,function(t,e){t.attr("title",O(t,e,"title",a))}),v("data-id",e,n,a,function(t,e){t.attr("id",O(t,e,"id",a))}),v("data-css",e,n,a,function(t,e){t.css(O(t,e,"css",a))}),v("data-class",e,n,a,function(t,e){t.addClass(O(t,e,"class",a))}),v("data-link",e,n,a,function(e,n){var i=t("");i.attr("href",O(e,n,"link",a)),i.html(e.html()),e.html(i)}),v("data-link-wrap",e,n,a,function(e,n){var i=t("");i.attr("href",O(e,n,"link-wrap",a)),e.wrap(i)}),v("data-options",e,n,a,function(e,n){t(n).each(function(){t("