summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/landing.js
diff options
context:
space:
mode:
authorLuke "Jared" Bennett <lbennett@gitlab.com>2017-05-02 08:05:43 +0000
committerPhil Hughes <me@iamphill.com>2017-05-02 08:05:43 +0000
commit5412020762b676fdfba5991b59ebec7adc59aeca (patch)
treefe3754b7bc5dcf79e60af58bdfcede76d9e830ef /app/assets/javascripts/landing.js
parent54beb93ac30371c978d80b03a8e0c386ca75fdb5 (diff)
downloadgitlab-ce-5412020762b676fdfba5991b59ebec7adc59aeca.tar.gz
Better Explore Groups view
Diffstat (limited to 'app/assets/javascripts/landing.js')
-rw-r--r--app/assets/javascripts/landing.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/app/assets/javascripts/landing.js b/app/assets/javascripts/landing.js
new file mode 100644
index 00000000000..8c0950ad5d5
--- /dev/null
+++ b/app/assets/javascripts/landing.js
@@ -0,0 +1,37 @@
+import Cookies from 'js-cookie';
+
+class Landing {
+ constructor(landingElement, dismissButton, cookieName) {
+ this.landingElement = landingElement;
+ this.cookieName = cookieName;
+ this.dismissButton = dismissButton;
+ this.eventWrapper = {};
+ }
+
+ toggle() {
+ const isDismissed = this.isDismissed();
+
+ this.landingElement.classList.toggle('hidden', isDismissed);
+ if (!isDismissed) this.addEvents();
+ }
+
+ addEvents() {
+ this.eventWrapper.dismissLanding = this.dismissLanding.bind(this);
+ this.dismissButton.addEventListener('click', this.eventWrapper.dismissLanding);
+ }
+
+ removeEvents() {
+ this.dismissButton.removeEventListener('click', this.eventWrapper.dismissLanding);
+ }
+
+ dismissLanding() {
+ this.landingElement.classList.add('hidden');
+ Cookies.set(this.cookieName, 'true', { expires: 365 });
+ }
+
+ isDismissed() {
+ return Cookies.get(this.cookieName) === 'true';
+ }
+}
+
+export default Landing;