Bug 675821 - Part 1: add Sync Setup and Pair links to aboutHome. r=gavin.sharp

This commit is contained in:
Chenxia Liu 2011-10-26 21:26:51 -04:00
parent c687810549
commit 5586d8dab2
5 changed files with 72 additions and 2 deletions

View File

@ -369,6 +369,31 @@ body[dir=rtl] #restorePreviousSession::before {
bottom: 2%;
}
#syncLinksContainer {
padding-top: 1em;
}
/* Hack to make buttons appear as links. Necessary to piggyback on browser.js
* OnBrowserClick listener, which checks that click originates from a button.
*/
.sync-link {
-moz-appearance: none;
outline: none;
border: none;
color: -moz-hyperlinktext;
background-color: transparent;
}
.sync-link:hover {
color: -moz-activehyperlinktext;
text-decoration: underline;
cursor: pointer;
}
.sync-link:active {
padding: 0px 6px 0px 6px;
}
@media all and (max-height: 370px) {
#bottomSection {
visibility: hidden;

View File

@ -51,6 +51,8 @@
%aboutHomeDTD;
<!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd" >
%browserDTD;
<!ENTITY % syncSetupDTD SYSTEM "chrome://browser/locale/syncSetup.dtd" >
%syncSetupDTD;
]>
<html xmlns="http://www.w3.org/1999/xhtml">
@ -102,6 +104,10 @@
<div id="aboutMozilla">
<a href="http://www.mozilla.com/about/">&abouthome.aboutMozilla;</a>
</div>
<div id="syncLinksContainer">
<button class="sync-link" id="setupSyncLink">&aboutHomeSyncSetup.label;</button>
<button class="sync-link" id="pairDeviceLink">&pairDevice.title.label;</button>
</div>
</div>
</body>
</html>

View File

@ -291,16 +291,40 @@ let gSyncUI = {
//XXXzpao should be part of syncCommon.js - which we might want to make a module...
// To be fixed in a followup (bug 583366)
openSetup: function SUI_openSetup() {
/**
* Invoke the Sync setup wizard.
*
* @param wizardType
* Indicates type of wizard to launch:
* null -- regular set up wizard
* "pair" -- pair a device first
* "reset" -- reset sync
*/
openSetup: function SUI_openSetup(wizardType) {
let win = Services.wm.getMostRecentWindow("Weave:AccountSetup");
if (win)
win.focus();
else {
window.openDialog("chrome://browser/content/syncSetup.xul",
"weaveSetup", "centerscreen,chrome,resizable=no");
"weaveSetup", "centerscreen,chrome,resizable=no",
wizardType);
}
},
openAddDevice: function () {
if (!Weave.Utils.ensureMPUnlocked())
return;
let win = Services.wm.getMostRecentWindow("Sync:AddDevice");
if (win)
win.focus();
else
window.openDialog("chrome://browser/content/syncAddDevice.xul",
"syncAddDevice", "centerscreen,chrome,resizable=no");
},
openQuotaDialog: function SUI_openQuotaDialog() {
let win = Services.wm.getMostRecentWindow("Sync:ViewQuota");
if (win)

View File

@ -2665,6 +2665,10 @@ function BrowserOnAboutPageLoad(document) {
getService(Components.interfaces.nsISessionStore);
if (!ss.canRestoreLastSession)
document.getElementById("sessionRestoreContainer").hidden = true;
// Sync-related links
if (Services.prefs.prefHasUserValue("services.sync.username")) {
document.getElementById("setupSyncLink").hidden = true;
}
}
}
@ -2803,6 +2807,16 @@ function BrowserOnClick(event) {
ss.restoreLastSession();
errorDoc.getElementById("sessionRestoreContainer").hidden = true;
}
else if (ot == errorDoc.getElementById("pairDeviceLink")) {
if (Services.prefs.prefHasUserValue("services.sync.username")) {
gSyncUI.openAddDevice();
} else {
gSyncUI.openSetup("pair");
}
}
else if (ot == errorDoc.getElementById("setupSyncLink")) {
gSyncUI.openSetup(null);
}
}
}

View File

@ -1,4 +1,5 @@
<!ENTITY accountSetupTitle.label "&syncBrand.fullName.label; Setup">
<!ENTITY aboutHomeSyncSetup.label "Set Up Sync">
<!-- First page of the wizard -->