Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
bfa3aad3
Commit
bfa3aad3
authored
Jul 05, 2017
by
kushalpandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EE Trial banner bundle
parent
56ac23b4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
0 deletions
+63
-0
app/assets/javascripts/ee_trial_banner/ee_trial_banner.js
app/assets/javascripts/ee_trial_banner/ee_trial_banner.js
+54
-0
app/assets/javascripts/ee_trial_banner/index.js
app/assets/javascripts/ee_trial_banner/index.js
+9
-0
No files found.
app/assets/javascripts/ee_trial_banner/ee_trial_banner.js
0 → 100644
View file @
bfa3aad3
import
Cookies
from
'
js-cookie
'
;
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
.
licenseExpiresOn
=
new
Date
(
this
.
$trialBanner
.
data
(
'
license-expiry
'
));
}
init
()
{
const
today
=
new
Date
();
// Check if Cookie is defined
if
(
!
Cookies
.
get
(
this
.
COOKIE_KEY
))
{
// Cookie was not defined, let's define with default value
// Check if License is yet to expire
if
(
today
<
this
.
licenseExpiresOn
)
{
// License has not expired yet, we show initial banner of 7 days
// with cookie set to validity same as license expiry
Cookies
.
set
(
this
.
COOKIE_KEY
,
'
true
'
,
{
expires
:
this
.
licenseExpiresOn
});
}
else
{
// License is already expired so we show final Banner with cookie set to 20 years validity.
Cookies
.
set
(
this
.
COOKIE_KEY
,
'
true
'
,
{
expires
:
7300
});
}
this
.
toggleBanner
(
true
);
}
else
{
// Cookie was defined, let's read value and show/hide banner
this
.
toggleBanner
(
Cookies
.
get
(
this
.
COOKIE_KEY
)
===
'
true
'
);
}
this
.
$trialBanner
.
on
(
'
close.bs.alert
'
,
e
=>
this
.
handleTrialBannerDismiss
(
e
));
}
toggleBanner
(
state
)
{
if
(
state
)
{
this
.
$trialBanner
.
removeClass
(
'
hidden
'
);
this
.
$navbar
.
addClass
(
'
has-trial-banner
'
);
}
else
{
this
.
$trialBanner
.
addClass
(
'
hidden
'
);
this
.
$navbar
.
removeClass
(
'
has-trial-banner
'
);
}
}
handleTrialBannerDismiss
()
{
this
.
$navbar
.
removeClass
(
'
has-trial-banner
'
);
if
(
Cookies
.
get
(
this
.
COOKIE_KEY
))
{
Cookies
.
set
(
this
.
COOKIE_KEY
,
'
false
'
);
}
}
}
app/assets/javascripts/ee_trial_banner/index.js
0 → 100644
View file @
bfa3aad3
import
EETrialBanner
from
'
./ee_trial_banner
'
;
$
(()
=>
{
const
$trialBanner
=
$
(
'
.js-gitlab-ee-trial-banner
'
);
if
(
$trialBanner
.
length
)
{
const
eeTrialBanner
=
new
EETrialBanner
(
$trialBanner
);
eeTrialBanner
.
init
();
}
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment