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-24 00:23:33 +0300
committerJose Ivan Vargas <jvargas@gitlab.com>2017-02-24 00:47:23 +0300
commit2f681138dc2338b50af0b4d2bfbd24032e97f2e3 (patch)
tree193846079dc7a920539e2eb8391a54a12f13484a /app/assets/javascripts/user_callout.js
parent621bfdaa9f9abe977310fb2692a4194b5a87347c (diff)
Modified the user_callout behaviour
Now it appends a template instead of relying in a partial to show it.
Diffstat (limited to 'app/assets/javascripts/user_callout.js')
-rw-r--r--app/assets/javascripts/user_callout.js45
1 files changed, 35 insertions, 10 deletions
diff --git a/app/assets/javascripts/user_callout.js b/app/assets/javascripts/user_callout.js
index c10f0e8de5e..300d825ec9a 100644
--- a/app/assets/javascripts/user_callout.js
+++ b/app/assets/javascripts/user_callout.js
@@ -4,29 +4,54 @@
const userCalloutElementName = '.user-callout';
const closeButton = '.close-user-callout';
const userCalloutBtn = '.user-callout-btn';
+const userCalloutSvgAttrName = 'callout-svg';
const USER_CALLOUT_COOKIE = 'user_callout_dismissed';
+const USER_CALLOUT_TEMPLATE = `
+ <div class="bordered-box landing content-block">
+ <button class="btn btn-default close close-user-callout" type="button">
+ <i class="fa fa-times dismiss-icon"></i>
+ </button>
+ <div class="row">
+ <div class="col-sm-3 col-xs-12 svg-container">
+ </div>
+ <div class="col-sm-8 col-xs-12 inner-content">
+ <h4>
+ Customize your experience
+ </h4>
+ <p>
+ Change syntax themes, default project pages, and more in preferences.
+ </p>
+ <a class="btn user-callout-btn" href="/profile/preferences">Check it out</a>
+ </div>
+ </div>
+</div>`;
+
class UserCallout {
constructor() {
this.isCalloutDismissed = Cookies.get(USER_CALLOUT_COOKIE);
+ this.userCalloutBody = $(userCalloutElementName);
+ this.userCalloutSvg = $(userCalloutElementName).attr(userCalloutSvgAttrName);
+ $(userCalloutElementName).removeAttr(userCalloutSvgAttrName);
this.init();
- this.toggleUserCallout();
}
init() {
- $(document)
- .on('click', closeButton, () => this.dismissCallout())
- .on('click', userCalloutBtn, () => this.dismissCallout());
+ const $template = $(USER_CALLOUT_TEMPLATE);
+ if (!this.isCalloutDismissed || this.isCalloutDismissed === 'false') {
+ $template.find('.svg-container').append(this.userCalloutSvg);
+ this.userCalloutBody.append($template);
+ $template.find(closeButton).on('click', e => this.dismissCallout(e));
+ $template.find(userCalloutBtn).on('click', e => this.dismissCallout(e));
+ }
}
- dismissCallout() {
+ dismissCallout(e) {
Cookies.set(USER_CALLOUT_COOKIE, 'true');
- }
-
- toggleUserCallout() {
- if (!this.isCalloutDismissed) {
- $(userCalloutElementName).show();
+ const $currentTarget = $(e.currentTarget);
+ if ($currentTarget.hasClass('close-user-callout')) {
+ this.userCalloutBody.empty();
}
}
}