Open lendormi opened 6 years ago
I understand. I'm sorry i didn't think to keep backwards-compatibility.
however, i think the callback like this is not good semantically:
if (typeof this.options.close === 'function') {
return this.options.close('hide');
}
i suggest to keep it simple and deprecated theses callbacks:
if (typeof this.options.hookHide === 'function') {
return this.options.hookHide(this.type);
} else if (typeof this.options.close === 'function') { //deprecated: backwards-compatibility
return this.options.close();
}
After somes changes in the main part of the code, it look like this :
//backwards-compatibility with old version below tag 1.4.0
if (typeof this.options.close === 'function' && this.options.hookClose === null) {
this.options.hookClose = this.options.close;
}
if (typeof this.options.show === 'function' && this.options.hookShow === null) {
this.options.hookShow = this.options.show;
}
// ...
if (typeof this.options.hookHide === 'function') {
return this.options.hookHide(this.type);
} else if (typeof this.options.hookClose === 'function') { //deprecated: backwards-compatibility
return this.options.hookClose(this.type);
}
For example :
new SmartBanner({
daysHidden: 15, // days to hide banner after close button is clicked (defaults to 15)
daysReminder: 90, // days to hide banner after "VIEW" button is clicked (defaults to 90)
appStoreLanguage: 'us', // language code for the App Store (defaults to user's browser language)
title: 'MyPage',
author: 'MyCompany LLC',
button: 'VIEW',
store: {
ios: 'On the App Store',
android: 'In Google Play',
windows: 'In Windows store'
},
price: {
ios: 'FREE',
android: 'FREE',
windows: 'FREE'
}
// , theme: '' // put platform type ('ios', 'android', etc.) here to force single theme on all device
// , icon: '' // full path to icon image if not using website icon image
// , force: 'ios' // Uncomment for platform emulation
hookInstall: function(type){},
hookShow: function(type){},
hookHide: function(type){},
hookClose: function(type){},
});
the event only hook close and hide function, extend it to all method call in smartBanner class.
For few use cases we need to call an event hook only on install call and not with close event hook.