summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_realtime_listener/index.js
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2017-04-07 16:20:17 +0800
committerLin Jen-Shin <godfat@godfat.org>2017-04-07 16:20:17 +0800
commit3aed06cfa387406c2e0257a8783bc05b53d4385a (patch)
tree91d12caf54a468bc272d92bca4542722a42e2033 /app/assets/javascripts/vue_realtime_listener/index.js
parent964814e99a30dd9fb0194e64cc01fee79bd027aa (diff)
parentc970fa973d482c50820db75d08d74bd5c1e9d475 (diff)
downloadgitlab-ce-3aed06cfa387406c2e0257a8783bc05b53d4385a.tar.gz
Merge remote-tracking branch 'upstream/master' into test-pg-mysql
* upstream/master: (590 commits) Fixes failing spec Fix icon name error Rewrite system note helper Change edit icon Leave icon area blank if legacy note; remove diamond icon Fix positioning of note icons Fix newline errors Add remaining system note icons Add system notes icon helper; add icons Fixed specs Updated JS that was causing the hints to appear & then disappear Update tests Fix broken spinach test Reuse code Improve shortcuts code Adds ShortcutsDashboardNavigation to globals comment since its a global variable Fix shortcut specs Reorganize shortcut help menu Change todos shortcut to shift Change shortcuts Switch global shortcuts to shift; reuse key styles from help menu ...
Diffstat (limited to 'app/assets/javascripts/vue_realtime_listener/index.js')
-rw-r--r--app/assets/javascripts/vue_realtime_listener/index.js38
1 files changed, 9 insertions, 29 deletions
diff --git a/app/assets/javascripts/vue_realtime_listener/index.js b/app/assets/javascripts/vue_realtime_listener/index.js
index 30f6680a673..4ddb2f975b0 100644
--- a/app/assets/javascripts/vue_realtime_listener/index.js
+++ b/app/assets/javascripts/vue_realtime_listener/index.js
@@ -1,29 +1,9 @@
-/* eslint-disable no-param-reassign */
-
-((gl) => {
- gl.VueRealtimeListener = (removeIntervals, startIntervals) => {
- const removeAll = () => {
- removeIntervals();
- window.removeEventListener('beforeunload', removeIntervals);
- window.removeEventListener('focus', startIntervals);
- window.removeEventListener('blur', removeIntervals);
- document.removeEventListener('beforeunload', removeAll);
- };
-
- window.addEventListener('beforeunload', removeIntervals);
- window.addEventListener('focus', startIntervals);
- window.addEventListener('blur', removeIntervals);
- document.addEventListener('beforeunload', removeAll);
-
- // add removeAll methods to stack
- const stack = gl.VueRealtimeListener.reset;
- gl.VueRealtimeListener.reset = () => {
- gl.VueRealtimeListener.reset = stack;
- removeAll();
- stack();
- };
- };
-
- // remove all event listeners and intervals
- gl.VueRealtimeListener.reset = () => undefined; // noop
-})(window.gl || (window.gl = {}));
+export default (removeIntervals, startIntervals) => {
+ window.removeEventListener('focus', startIntervals);
+ window.removeEventListener('blur', removeIntervals);
+ window.removeEventListener('onbeforeload', removeIntervals);
+
+ window.addEventListener('focus', startIntervals);
+ window.addEventListener('blur', removeIntervals);
+ window.addEventListener('onbeforeload', removeIntervals);
+};