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:
authorJose Ivan Vargas <jvargas@gitlab.com>2017-02-17 01:02:40 +0300
committerJose Ivan Vargas <jvargas@gitlab.com>2017-02-24 00:47:23 +0300
commit103f5a116b1ae6ecbef69d6903b26f7259f090cb (patch)
tree0e3d762be03e421a0f07a96c8ad94dc333724f89 /app/assets/javascripts/user_callout.js
parent4802bd512a2492c7560acde077fee2f4cd9483b3 (diff)
Created unit tests, fixtures and integration tests
Also changed the user_callout haml to a partial and added the corresponding SVG icon
Diffstat (limited to 'app/assets/javascripts/user_callout.js')
-rw-r--r--app/assets/javascripts/user_callout.js25
1 files changed, 20 insertions, 5 deletions
diff --git a/app/assets/javascripts/user_callout.js b/app/assets/javascripts/user_callout.js
index b91fc698629..5d10bfc8290 100644
--- a/app/assets/javascripts/user_callout.js
+++ b/app/assets/javascripts/user_callout.js
@@ -3,20 +3,35 @@
((global) => {
const userCalloutElementName = '#user-callout';
+ const dismissIcon = '.dismiss-icon';
+ const userCalloutBtn = '.user-callout-btn';
+
+ const USER_CALLOUT_COOKIE = 'user_callout_dismissed';
class UserCallout {
constructor() {
+ this.isCalloutDismissed = Cookies.get(USER_CALLOUT_COOKIE);
this.init();
}
init() {
$(document)
- .on('DOMContentLoaded', () => {
- const element = $(userCalloutElementName);
- console.log('element:', element);
- });
+ .on('click', dismissIcon, () => this.closeAndDismissCallout())
+ .on('click', userCalloutBtn, () => this.closeAndDismissCallout())
+ .on('DOMContentLoaded', () => this.isUserCalloutDismissed());
+ }
+
+ closeAndDismissCallout() {
+ $(userCalloutElementName).hide();
+ Cookies.set(USER_CALLOUT_COOKIE, '1');
+ }
+
+ isUserCalloutDismissed() {
+ if (!this.isCalloutDismissed) {
+ $(userCalloutElementName).show();
+ }
}
}
global.UserCallout = UserCallout;
-})(window.gl || (window.gl = {})); \ No newline at end of file
+})(window.gl || (window.gl = {}));