bug 818234 prevent quickly tapping on bluetooth and wifi settings #6875

Merged
merged 2 commits into from Dec 10, 2012

2 participants

@evelynhung
Mozilla-B2G member

No description provided.

@evelynhung
Mozilla-B2G member

In my patch above, I didn't spend too much time in CSS tweak, @RudyLu will help me on the switch style, and submit a follow-up patch here. Thanks.

@timdream timdream commented on an outdated diff Dec 7, 2012
apps/system/js/quick_settings.js
SettingsListener.observe('bluetooth.enabled', true, function(value) {
- self.bluetooth.dataset.enabled = value;
+ // check self.bluetooth.dataset.enabled and value are identical
+ if ((self.bluetooth.dataset.enabled && value) ||
+ (typeof(self.bluetooth.dataset.enabled) === 'undefined' && !value))
@timdream
Mozilla-B2G member
timdream added a note Dec 7, 2012

typeof(self.bluetooth.dataset.enabled) === 'undefined'

can be

self.bluetooth.dataset.enabled === undefined

or

!('enabled' in self.bluetooth.dataset)

you may update your code if you want

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@timdream timdream commented on an outdated diff Dec 7, 2012
apps/system/js/quick_settings.js
SettingsListener.observe('bluetooth.enabled', true, function(value) {
- self.bluetooth.dataset.enabled = value;
+ // check self.bluetooth.dataset.enabled and value are identical
+ if ((self.bluetooth.dataset.enabled && value) ||
+ (typeof(self.bluetooth.dataset.enabled) === 'undefined' && !value))
+ return;
+
+ if (value) {
+ self.bluetooth.dataset.enabled = 'true';
+ } else {
+ delete self.bluetooth.dataset.enabled;
+ }
+
+ if (!bt_first)
@timdream
Mozilla-B2G member
timdream added a note Dec 7, 2012

camelCase please. Also, please add this comment

// Set to the initializing state to block user interaction until the operation completes.
// (unless we are being called for the first time, where Bluetooth is already initialized)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@timdream timdream commented on an outdated diff Dec 7, 2012
apps/system/js/quick_settings.js
});
- // monitor wifi status
+ window.addEventListener('bluetooth-adapter-added', function() {
@timdream
Mozilla-B2G member
timdream added a note Dec 7, 2012

Can you centralize these event listeners into handleEvent function? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@timdream timdream commented on an outdated diff Dec 7, 2012
apps/system/style/quick_settings/quick_settings.css
background-image: url(images/wifi-on.svg);
}
+#quick-settings > #quick-settings-wifi[data-initializing] {
@timdream
Mozilla-B2G member
timdream added a note Dec 7, 2012

#quick-settings > *[data-initializing] {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@timdream timdream commented on an outdated diff Dec 7, 2012
apps/system/js/quick_settings.js
@@ -51,8 +115,10 @@ var QuickSettings = {
case 'click':
switch (evt.target) {
case this.wifi:
- var enabled = (this.wifi.dataset.enabled == 'true');
- this.wifi.dataset.enabled = !enabled;
+ // do nothing if wifi isn't ready
+ if (this.wifi.dataset.initializing)
+ return;
+ var enabled = (this.wifi.dataset.enabled) ? true : false;
@timdream
Mozilla-B2G member
timdream added a note Dec 7, 2012

!!this.wifi.dataset.enabled since the value will be either underfined or string 'true'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@RudyLu RudyLu and 1 other commented on an outdated diff Dec 8, 2012
shared/style/switches.css
@@ -110,3 +110,6 @@ label input[data-type="switch"]:checked + span:after {
transform: translateX(0);
}
+label input[data-type="switch"]:disabled + span {
+ opacity: 0.5;
+}
@RudyLu
RudyLu added a note Dec 8, 2012

Hi Evelyn,

This part has been refined in #6905.
So you could remove this and reply on #6905 to do the "disabled" style

Thanks.

@evelynhung
Mozilla-B2G member

Hi @RudyLu,
Per @timdream's suggestion before (face to face), I will pick you commit into this PR, so we could solve this issue within one PR but with two commits.
I'm doing it right now, will let you know once I'm done.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@evelynhung
Mozilla-B2G member

get r+ from @timdream, merging. Thanks!

@evelynhung evelynhung merged commit a34e199 into mozilla-b2g:master Dec 10, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment