From ad7b561dd4208b375d0face3f4ce67d1d7e66ca2 Mon Sep 17 00:00:00 2001
From: Peter Jaszkowiak
Date: Sun, 3 May 2015 23:36:23 -0600
Subject: [PATCH] Fixed translator backwards compatibility issue
Also removed the _clearMenus global object because populating the global namespace is bad, bad, bad
---
public/src/modules/translator.js | 6 +++--
public/src/overrides.js | 38 +++++++++++++++++---------------
2 files changed, 24 insertions(+), 20 deletions(-)
diff --git a/public/src/modules/translator.js b/public/src/modules/translator.js
index ac3be2728e..df8ac5d5ef 100644
--- a/public/src/modules/translator.js
+++ b/public/src/modules/translator.js
@@ -295,11 +295,13 @@
if (typeof define === 'function' && define.amd) {
define('translator', translator);
+ var _translator = translator;
+
// Expose a global `translator` object for backwards compatibility
window.translator = {
translate: function() {
console.warn('[translator] Global invocation of the translator is now deprecated, please `require` the module instead.');
- translator.translate.apply(translator, arguments);
+ _translator.translate.apply(_translator, arguments);
}
}
}
@@ -307,4 +309,4 @@
typeof exports === 'object' ? exports :
typeof define === 'function' && define.amd ? {} :
translator = {}
-);
\ No newline at end of file
+);
diff --git a/public/src/overrides.js b/public/src/overrides.js
index 8c0e492cce..dde1b55dd3 100644
--- a/public/src/overrides.js
+++ b/public/src/overrides.js
@@ -79,25 +79,27 @@ if ('undefined' !== typeof window) {
})(jQuery || {fn:{}});
+ (function(){
+ // FIX FOR #1245 - https://github.com/NodeBB/NodeBB/issues/1245
+ // from http://stackoverflow.com/questions/15931962/bootstrap-dropdown-disappear-with-right-click-on-firefox
+ // obtain a reference to the original handler
+ var _clearMenus = $._data(document, "events").click.filter(function (el) {
+ return el.namespace === 'bs.data-api.dropdown' && el.selector === undefined;
+ });
- // FIX FOR #1245 - https://github.com/NodeBB/NodeBB/issues/1245
- // from http://stackoverflow.com/questions/15931962/bootstrap-dropdown-disappear-with-right-click-on-firefox
- // obtain a reference to the original handler
- var _clearMenus = $._data(document, "events").click.filter(function (el) {
- return el.namespace === 'bs.data-api.dropdown' && el.selector === undefined;
- });
+ if(_clearMenus.length) {
+ _clearMenus = _clearMenus[0].handler;
+ }
- if(_clearMenus.length) {
- _clearMenus = _clearMenus[0].handler;
- }
+ // disable the old listener
+ $(document)
+ .off('click.data-api.dropdown', _clearMenus)
+ .on('click.data-api.dropdown', function (e) {
+ // call the handler only when not right-click
+ if (e.button !== 2) {
+ _clearMenus();
+ }
+ });
+ })();
- // disable the old listener
- $(document)
- .off('click.data-api.dropdown', _clearMenus)
- .on('click.data-api.dropdown', function (e) {
- // call the handler only when not right-click
- if (e.button !== 2) {
- _clearMenus();
- }
- });
}