Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bug 828188 - Don't override the wifi event listeners. r=kaze

  • Loading branch information...
commit f06c44bd8924d2bb1ac38a5b115e7e972009410c 1 parent 31a820f
@mrbkap mrbkap authored
Showing with 26 additions and 8 deletions.
  1. +23 −5 apps/settings/js/connectivity.js
  2. +3 −3 apps/settings/js/wifi.js
View
28 apps/settings/js/connectivity.js
@@ -210,13 +210,16 @@ var gBluetooth = (function(window) {
// display connectivity status on the main panel
var Connectivity = (function(window, document, undefined) {
var _ = navigator.mozL10n.get;
+ var wifiEnabledListeners = [updateWifi];
+ var wifiDisabledListeners = [updateWifi];
+ var wifiStatusChangeListeners = [updateWifi];
var settings = Settings.mozSettings;
+ gWifiManager.onenabled = wifiEnabled;
+ gWifiManager.ondisabled = wifiDisabled;
+ gWifiManager.onstatuschange = wifiStatusChange;
+
function init() {
- // these listeners are replaced when wifi.js is loaded
- gWifiManager.onenabled = updateWifi;
- gWifiManager.ondisabled = updateWifi;
- gWifiManager.onstatuschange = updateWifi;
updateWifi();
// this event listener is not cleared by carrier.js
@@ -255,6 +258,18 @@ var Connectivity = (function(window, document, undefined) {
}
}
+ function wifiEnabled() {
+ wifiEnabledListeners.forEach(function(listener) { listener(); });
+ }
+
+ function wifiDisabled() {
+ wifiDisabledListeners.forEach(function(listener) { listener(); });
+ }
+
+ function wifiStatusChange(event) {
+ wifiStatusChangeListeners.forEach(function(listener) { listener(event); });
+ }
+
/**
* Mobile Connection Manager
*/
@@ -408,7 +423,10 @@ var Connectivity = (function(window, document, undefined) {
hotspot: document.getElementById('hotspot-desc').textContent,
bluetooth: document.getElementById('bluetooth-desc').textContent
};
- }
+ },
+ set wifiEnabled(listener) { wifiEnabledListeners.push(listener) },
+ set wifiDisabled(listener) { wifiDisabledListeners.push(listener); },
+ set wifiStatusChange(listener) { wifiStatusChangeListeners.push(listener); }
};
})(this, document);
View
6 apps/settings/js/wifi.js
@@ -68,7 +68,7 @@ onLocalized(function wifiSettings() {
*/
var gScanStates = new Set(['connected', 'connectingfailed', 'disconnected']);
- gWifiManager.onstatuschange = function(event) {
+ Connectivity.wifiStatusChange = function(event) {
updateNetworkState();
if (gScanStates.has(event.status)) {
@@ -80,7 +80,7 @@ onLocalized(function wifiSettings() {
}
};
- gWifiManager.onenabled = function onWifiEnabled() {
+ Connectivity.wifiEnabled = function onWifiEnabled() {
// enable UI toggle
if (!lastMozSettingValue) {
// Wifi just came up, but the last known value of the setting was false.
@@ -99,7 +99,7 @@ onLocalized(function wifiSettings() {
gNetworkList.scan();
};
- gWifiManager.ondisabled = function onWifiDisabled() {
+ Connectivity.wifiDisabled = function onWifiDisabled() {
// enable UI toggle
if (lastMozSettingValue) {
// See the comment in onWifiEnabled for why we do this.
Please sign in to comment.
Something went wrong with that request. Please try again.