From a55f164e1b60c6d52a5e4affe0408f9797d88c6d Mon Sep 17 00:00:00 2001 From: Luciano Bustos Date: Mon, 8 Jan 2018 14:55:52 -0300 Subject: [PATCH] Adding title attribute support. --- dist/jquery.loadTemplate.js | 4 ++++ dist/jquery.loadTemplate.min.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dist/jquery.loadTemplate.js b/dist/jquery.loadTemplate.js index de8e3d8..aa9ba52 100644 --- a/dist/jquery.loadTemplate.js +++ b/dist/jquery.loadTemplate.js @@ -318,6 +318,10 @@ processElements("data-alt", template, data, settings, function ($elem, value) { $elem.attr("alt", applyFormatters($elem, value, "alt", settings)); }); + + processElements("data-title", template, data, settings, function ($elem, value) { + $elem.attr("title", applyFormatters($elem, value, "title", settings)); + }); processElements("data-id", template, data, settings, function ($elem, value) { $elem.attr("id", applyFormatters($elem, value, "id", settings)); diff --git a/dist/jquery.loadTemplate.min.js b/dist/jquery.loadTemplate.min.js index c418890..bf88099 100644 --- a/dist/jquery.loadTemplate.min.js +++ b/dist/jquery.loadTemplate.min.js @@ -1 +1 @@ -!function(t){"use strict";function e(e,n,c){var s,u,p,d=this;return n=n||{},p=t.extend(!0,{async:!0,overwriteCache:!1,complete:null,success:null,error:function(){t(this).each(function(){t(this).html(p.errorMessage)})},errorMessage:"There was an error loading the template.",paged:!1,pageNo:1,elemPerPage:10,append:!1,prepend:!1,beforeInsert:null,afterInsert:null,bindingOptions:{ignoreUndefined:!1,ignoreNull:!1,ignoreEmptyString:!1}},c),"array"===t.type(n)?(T=!0,r.call(this,e,n,p)):(a(e)||(s=t(e),"string"==typeof e&&0===e.indexOf("#")&&(p.isFile=!1)),u=p.isFile||"undefined"==typeof p.isFile&&("undefined"==typeof s||0===s.length),u&&!p.overwriteCache&&w[e]?o(e,d,n,p):u&&!p.overwriteCache&&w.hasOwnProperty(e)?i(e,d,n,p):u?l(e,d,n,p):f(s,d,n,p),this)}function n(e,n){n?P[e]=n:P=t.extend(P,e)}function a(t){return"string"==typeof t&&t.indexOf("/")>-1}function r(n,a,r){r=r||{};var i,o=this,c=a.length,s=r.prepend&&!r.append,l=0,f=0,u=!1,p=[];if(r.paged){var d=(r.pageNo-1)*r.elemPerPage;a=a.slice(d,d+r.elemPerPage),c=a.length}return r.append||r.prepend||o.html(""),i=t.extend({},r,{append:!r.prepend&&!0,complete:function(t){l++,(l===c||u)&&(u&&r&&"function"==typeof r.error&&r.error.call(o,p),r&&"function"==typeof r.complete&&r.complete())},success:function(){f++,f===c&&r&&"function"==typeof r.success&&r.success()},error:function(t){u=!0,p.push(t)}}),s&&a.reverse(),t(a).each(function(){return e.call(o,n,this,i),u?!1:void 0}),this}function i(t,e,n,a){k[t]?k[t].push({data:n,selection:e,settings:a}):k[t]=[{data:n,selection:e,settings:a}]}function o(t,e,n,a){var r=w[t].clone();u.call(e,r,n,a),"function"==typeof a.success&&a.success()}function c(){return(new Date).getTime()}function s(t){return-1!==t.indexOf("?")?t+"&_="+c():t+"?_="+c()}function l(e,n,a,r){w[e]=null;var i=e;r.overwriteCache&&(i=s(i)),t.ajax({url:i,async:r.async,success:function(i){d(t(i),e,n,a,r)},error:function(t){p(e,n,a,r,t)}})}function f(e,n,a,r){(e.is("script")||e.is("template"))&&(e=t.parseHTML(t.trim(e.html()))),u.call(n,e,a,r),"function"==typeof r.success&&r.success()}function u(e,n,a){var e=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("