diff options
author | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-02-17 20:28:52 +0300 |
---|---|---|
committer | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-02-24 00:47:23 +0300 |
commit | bcab4bb5efd1cc499dc7d753115fe91b98f27bda (patch) | |
tree | 712923e168785037162b4c96fe6c9705db84fa4c /app/assets/javascripts | |
parent | 19a21107d7f4a256271306ae10bb376dfbc8bbad (diff) |
Changed the javascript class from using the global scope to exporting it via webpack
Also improved accesibility and change the id from user_callouts to a class
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r-- | app/assets/javascripts/dispatcher.js.es6 | 5 | ||||
-rw-r--r-- | app/assets/javascripts/user_callout.js | 50 |
2 files changed, 29 insertions, 26 deletions
diff --git a/app/assets/javascripts/dispatcher.js.es6 b/app/assets/javascripts/dispatcher.js.es6 index 089ecedeb78..0f678492d4c 100644 --- a/app/assets/javascripts/dispatcher.js.es6 +++ b/app/assets/javascripts/dispatcher.js.es6 @@ -36,6 +36,7 @@ /* global Shortcuts */ const ShortcutsBlob = require('./shortcuts_blob'); +const UserCallout = require('./user_callout'); (function() { var Dispatcher; @@ -277,6 +278,9 @@ const ShortcutsBlob = require('./shortcuts_blob'); case 'ci:lints:show': new gl.CILintEditor(); break; + case 'users:show': + new UserCallout(); + break; } switch (path.first()) { case 'sessions': @@ -313,6 +317,7 @@ const ShortcutsBlob = require('./shortcuts_blob'); case 'dashboard': case 'root': shortcut_handler = new ShortcutsDashboardNavigation(); + new UserCallout(); break; case 'profiles': new NotificationsForm(); diff --git a/app/assets/javascripts/user_callout.js b/app/assets/javascripts/user_callout.js index 5d10bfc8290..85f85674e59 100644 --- a/app/assets/javascripts/user_callout.js +++ b/app/assets/javascripts/user_callout.js @@ -1,37 +1,35 @@ /* eslint-disable arrow-parens, class-methods-use-this, no-param-reassign */ /* global Cookies */ -((global) => { - const userCalloutElementName = '#user-callout'; - const dismissIcon = '.dismiss-icon'; - const userCalloutBtn = '.user-callout-btn'; +const userCalloutElementName = '.user-callout'; +const dismissIcon = '.dismiss-icon'; +const userCalloutBtn = '.user-callout-btn'; - const USER_CALLOUT_COOKIE = 'user_callout_dismissed'; +const USER_CALLOUT_COOKIE = 'user_callout_dismissed'; - class UserCallout { - constructor() { - this.isCalloutDismissed = Cookies.get(USER_CALLOUT_COOKIE); - this.init(); - } +class UserCallout { + constructor() { + this.isCalloutDismissed = Cookies.get(USER_CALLOUT_COOKIE); + this.init(); + this.isUserCalloutDismissed(); + } - init() { - $(document) - .on('click', dismissIcon, () => this.closeAndDismissCallout()) - .on('click', userCalloutBtn, () => this.closeAndDismissCallout()) - .on('DOMContentLoaded', () => this.isUserCalloutDismissed()); - } + init() { + $(document) + .on('click', dismissIcon, () => this.closeAndDismissCallout()) + .on('click', userCalloutBtn, () => this.closeAndDismissCallout()); + } - closeAndDismissCallout() { - $(userCalloutElementName).hide(); - Cookies.set(USER_CALLOUT_COOKIE, '1'); - } + closeAndDismissCallout() { + $(userCalloutElementName).hide(); + Cookies.set(USER_CALLOUT_COOKIE, '1'); + } - isUserCalloutDismissed() { - if (!this.isCalloutDismissed) { - $(userCalloutElementName).show(); - } + isUserCalloutDismissed() { + if (!this.isCalloutDismissed) { + $(userCalloutElementName).show(); } } +} - global.UserCallout = UserCallout; -})(window.gl || (window.gl = {})); +module.exports = UserCallout; |