Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/groups/landing.js')
-rw-r--r--app/assets/javascripts/groups/landing.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/app/assets/javascripts/groups/landing.js b/app/assets/javascripts/groups/landing.js
new file mode 100644
index 00000000000..bfb4d9ce67b
--- /dev/null
+++ b/app/assets/javascripts/groups/landing.js
@@ -0,0 +1,38 @@
+import Cookies from 'js-cookie';
+import { parseBoolean } from '~/lib/utils/common_utils';
+
+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 parseBoolean(Cookies.get(this.cookieName));
+ }
+}
+
+export default Landing;