This repository was archived by the owner on Dec 9, 2025. It is now read-only.
add event hooks to smart app banner#97
Open
lendormi wants to merge 3 commits into
Open
Conversation
TSMMark
reviewed
Jan 10, 2018
TSMMark
left a comment
Collaborator
There was a problem hiding this comment.
The code looks good to me. This obviously would be a breaking change which is unfortunate. Is there a way to keep backwards-compatibility? Perhaps we can continue to call this.options.close, but add an argument which is the action that triggered the close.
For example, the hide callback might look like this:
hide: function () {
root.classList.remove('smartbanner-show');
if (typeof this.options.close === 'function') {
return this.options.close('hide');
}
},
Author
|
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){},
}); |
added 3 commits
June 19, 2018 11:30
the event only hook close and hide function, extend it to all method call in smartBanner class features: - to keep backwards-compatibility for options.close and options.show - use hook name function for better understanding - include argument type to trigger os type note: update smart-app-banner on last node_modules version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.