From 3878b92070c3c322aa60f666af503c300a0f9a27 Mon Sep 17 00:00:00 2001 From: goliatone Date: Thu, 16 May 2013 14:01:33 -0400 Subject: [PATCH 1/2] Updated .gitignore. --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 15cdb46..ad878bc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ .idea archive node_modules -_SpecRunner.html \ No newline at end of file +_SpecRunner.html + +*.sublime-project +*.sublime-workspace \ No newline at end of file From 38f81dba1f86a2dd0ae4d1846776bd6adc03e83b Mon Sep 17 00:00:00 2001 From: goliatone Date: Thu, 16 May 2013 14:07:23 -0400 Subject: [PATCH 2/2] Added Image.onerror handler and options.error callback. --- src/jail.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/jail.js b/src/jail.js index 32073d1..3ed5ec3 100644 --- a/src/jail.js +++ b/src/jail.js @@ -359,6 +359,22 @@ isCallbackDone = true; } }; + + /* + * Basic on error handler. For now we limit + * the plugin to exectute any callback passed + * in the options object. Let the developer + * decide what to do with it. + */ + cache.onerror = function(){ + + if(!('error' in options)) return; + + var args = Array.prototype.slice.call(arguments, 0); + args = [$img, options].concat(args); + options.error.apply($.jail, args); + }; + cache.src = $img.attr("data-src"); }