From 27b15eb88e17290c1b6913beeac6fcfc96002434 Mon Sep 17 00:00:00 2001 From: David Mignot Date: Tue, 29 Sep 2015 08:25:29 +0200 Subject: [PATCH 1/2] Add a onShow callback for more control --- README.md | 3 +++ jquery.smartbanner.js | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 2b579fd..96de11c 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,9 @@ brings this feature to older iOS versions, Android devices and for Windows Store }, onClose: function() { // alert('Click close'); + }, + onShow: function() { + // alert('Banner shown'); } }) diff --git a/jquery.smartbanner.js b/jquery.smartbanner.js index e9bd32b..4edb26d 100644 --- a/jquery.smartbanner.js +++ b/jquery.smartbanner.js @@ -74,6 +74,13 @@ this.options.onClose = function() {}; } + // Set default onClose callback if not set in options + if (typeof this.options.onShow === 'function') { + this.options.onShow = this.options.onShow; + } else { + this.options.onShow = function() {}; + } + // Create banner this.create() this.show() @@ -162,6 +169,7 @@ banner.slideDown(this.options.speedIn).addClass('shown'); } } + this.options.onShow(e); } , hide: function(callback) { From b46e070f11a0e5ddd9093ce0cc2f7234b0ae59af Mon Sep 17 00:00:00 2001 From: David Mignot Date: Tue, 29 Sep 2015 08:30:35 +0200 Subject: [PATCH 2/2] don't pass undefined event value to onShow callback --- jquery.smartbanner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.smartbanner.js b/jquery.smartbanner.js index 4edb26d..7af2f5e 100644 --- a/jquery.smartbanner.js +++ b/jquery.smartbanner.js @@ -169,7 +169,7 @@ banner.slideDown(this.options.speedIn).addClass('shown'); } } - this.options.onShow(e); + this.options.onShow(); } , hide: function(callback) {