Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #32658 from ferjm/bug1217376.signout.confirmation
Browse files Browse the repository at this point in the history
Bug 1217376 - [TV] Ask user for confirmation before signing the user out. r=yifan
  • Loading branch information
ferjm committed Oct 23, 2015
2 parents 3727df6 + 5cd902b commit 7ac56f3
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 12 deletions.
52 changes: 41 additions & 11 deletions tv_apps/browser/js/browser_dialog.js
Expand Up @@ -17,6 +17,7 @@ var BrowserDialog = {
focusElement: [],
focusIndex: {x:0, y:0},
defaultFocusIndex: {x:0, y:0},
deferredActions: new Map(),

/** Get all elements when inited. */
getAllElements: function dialog_getAllElements() {
Expand Down Expand Up @@ -89,6 +90,7 @@ var BrowserDialog = {
this.dialogEvt = evt;
this.browserDialogBase.style.display = 'block';

var promise;
switch(type) {
case 'del_cookie':
opt = {
Expand Down Expand Up @@ -167,10 +169,17 @@ var BrowserDialog = {
case 'signout_confirm':
opt = {
title: null,
msg: _('fxa-sign-out-confirm-msg'),
msg: _('fxsync-confirm-disconnect'),
bt1: _('LT_CANCEL'),
bt2: _('fxa-sign-out')
bt2: _('fxsync-disconnect')
};
var deferred = {};
deferred.promise = new Promise(function(resolve, reject) {
deferred.resolve = resolve;
deferred.reject = reject;
});
promise = deferred.promise;
this.deferredActions.set('signout_confirm', deferred);
break;

default:
Expand Down Expand Up @@ -229,7 +238,7 @@ var BrowserDialog = {
this.browserDialogInput.style.display = 'none';
}

// initiarlize position
// initialize position
countIndex = 0;
if(opt.bt1 && opt.bt2) {
this.defaultFocusIndex.x = 0;
Expand All @@ -247,6 +256,7 @@ var BrowserDialog = {
}
Awesomescreen.focusImgFunc(this.focusElement[this.focusIndex.x][this.focusIndex.y]);
this.focusElement[this.focusIndex.x][this.focusIndex.y].focus();
return promise;
},

isDisplayed: function dialog_isDisplayed() {
Expand Down Expand Up @@ -275,9 +285,22 @@ var BrowserDialog = {
}
},

completeDeferredAction: function(type, resolution) {
if (!this.deferredActions.has(type)) {
return;
}
this.deferredActions.get(type)[resolution]();
this.deferredActions.delete(type);
},

dialogButton1: function dialog_dialogButton1(evt) {
if( evt ) evt.preventDefault();
switch(this.browserDialogButton1.dataset.type) {
if (evt) {
evt.preventDefault();
}

var type = this.browserDialogButton1.dataset.type;

switch(type) {
case 'del_cookie':
case 'clear_history':
case 'close_browser':
Expand All @@ -291,8 +314,10 @@ var BrowserDialog = {
break;

default:
break;
return;
}

this.completeDeferredAction(type, 'reject');
},

dialogButton2End: function dialog_dialogButton2End(target) {
Expand All @@ -305,9 +330,13 @@ var BrowserDialog = {
},

dialogButton2: function dialog_dialogButton2(evt) {
if( evt ) evt.preventDefault();
if (evt) {
evt.preventDefault();
}

this.argEvt = evt.currentTarget;
switch(this.browserDialogButton2.dataset.type) {
var type = this.browserDialogButton2.dataset.type;
switch (type) {
case 'del_cookie':
var request = navigator.mozApps.getSelf();
request.onsuccess = function() {
Expand Down Expand Up @@ -358,7 +387,7 @@ var BrowserDialog = {
break;

case 'prompt':
if( this.dialogEvt != null ) {
if (this.dialogEvt != null) {
this.dialogEvt.detail.returnValue = this.browserDialogInputArea.value;
if (this.dialogEvt.detail.unblock) {
this.dialogEvt.detail.unblock();
Expand All @@ -370,7 +399,7 @@ var BrowserDialog = {
break;

case 'confirm':
if( this.dialogEvt != null ) {
if (this.dialogEvt != null) {
this.dialogEvt.detail.returnValue = true;
if (this.dialogEvt.detail.unblock) {
this.dialogEvt.detail.unblock();
Expand All @@ -383,12 +412,13 @@ var BrowserDialog = {

case 'signout_confirm':
BrowserDialog.dialogButton2End(BrowserDialog.argEvt);
Settings.disconnectAccount();
break;

default:
break;
}

this.completeDeferredAction(type, 'resolve');
},

dialogInput: function dialog_dialogInput(evt) {
Expand Down
5 changes: 4 additions & 1 deletion tv_apps/browser/js/sync/settings.js
Expand Up @@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/* global BrowserDialog */
/* global LazyLoader */
/* global Settings */
/* global SettingsListener */
Expand Down Expand Up @@ -270,7 +271,9 @@
},

disable() {
SyncManagerBridge.disable();
BrowserDialog.createDialog('signout_confirm').then(() => {
SyncManagerBridge.disable();
});
},

sync() {
Expand Down
1 change: 1 addition & 0 deletions tv_apps/browser/locales/browser.en-US.properties
Expand Up @@ -98,6 +98,7 @@ fxsync-sign-in=Sign In
fxsync-collection-bookmarks=Bookmarks
fxsync-collection-history=History
fxsync-disconnect=Disconnect
fxsync-confirm-disconnect=Are you sure? Your Firefox bookmarks and history will not be available on this TV until you sign in again.
fxsync-firefox-sync=Firefox Sync
fxsync-signed-in-as={{email}}
fxsync-sign-in-to-sync=Sign in to Sync
Expand Down

0 comments on commit 7ac56f3

Please sign in to comment.