Commit 4003a3e5 authored by kushalpandya's avatar kushalpandya

Fix secondary nav margin handling

parent ccdc7c7a
......@@ -4,12 +4,14 @@ export default class EETrialBanner {
constructor($trialBanner) {
this.COOKIE_KEY = 'show_ee_trial_banner';
this.$trialBanner = $trialBanner;
this.$navbar = this.$trialBanner.siblings('.js-navbar-gitlab');
this.$mainNavbar = this.$trialBanner.siblings('.js-navbar-gitlab');
this.$secondaryNavbar = this.$mainNavbar.siblings('.js-page-with-sidebar');
this.licenseExpiresOn = new Date(this.$trialBanner.data('license-expiry'));
}
init() {
// Wait for navbars to render before querying
this.setCookies();
this.$trialBanner.on('close.bs.alert', e => this.handleTrialBannerDismiss(e));
}
......@@ -72,13 +74,27 @@ export default class EETrialBanner {
}
}
toggleMainNavbarMargin(state) {
if (this.$mainNavbar.length) {
this.$mainNavbar.toggleClass('has-trial-banner', state);
}
}
toggleSecondaryNavbarMargin(state) {
if (this.$secondaryNavbar.length) {
this.$secondaryNavbar.toggleClass('has-trial-banner', state);
}
}
toggleBanner(state) {
this.$trialBanner.toggleClass('hidden', !state);
this.$navbar.toggleClass('has-trial-banner', state);
this.toggleMainNavbarMargin(state);
this.toggleSecondaryNavbarMargin(state);
}
handleTrialBannerDismiss() {
this.$navbar.removeClass('has-trial-banner');
this.toggleMainNavbarMargin(false);
this.toggleSecondaryNavbarMargin(false);
if (Cookies.get(this.COOKIE_KEY)) {
Cookies.set(this.COOKIE_KEY, 'false');
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment