Create install flow

* Refactor options.js into a view
* Break up install flow into a series of screens
* Remove bootstrap
* Make installer window static size, mostly to facilitate positioning

// FREEBIE
This commit is contained in:
lilia 2015-11-02 19:19:30 -08:00
parent 675be2b569
commit 14cb6b58a2
12 changed files with 1299 additions and 6461 deletions

1
images/flags.png Symbolic link
View File

@ -0,0 +1 @@
../components/intl-tel-input/build/img/flags.png

BIN
images/icon_250.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
images/signal-laptop.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

BIN
images/signal-phone.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

View File

@ -165,7 +165,9 @@
extension.windows.open({
id: id,
url: url,
bounds: { width: 800, height: 666 }
bounds: { width: 800, height: 666, },
minWidth: 800,
minHeight: 666
});
}
};

View File

@ -4,97 +4,49 @@
;(function() {
'use strict';
extension.windows.getBackground(function(bg) {
$('.notifications .on button').click(function() {
bg.Whisper.Notifications.disable();
initOptions();
});
$('.notifications .off button').click(function() {
bg.Whisper.Notifications.enable(initOptions);
initOptions();
});
function initOptions() {
if (bg.Whisper.Notifications.isEnabled()) {
$('.notifications .on').show();
$('.notifications .off').hide();
} else {
$('.notifications .on').hide();
$('.notifications .off').show();
}
}
function setProvisioningUrl(url) {
$('#status').text('');
new QRCode($('#qr')[0]).makeCode(url);
}
function confirmNumber(number) {
return new Promise(function(resolve, reject) {
$('#qr').hide();
$('.confirmation-dialog .number').text(number);
$('.confirmation-dialog .cancel').click(function(e) {
reject();
bg.storage.onready(function() {
$(function() {
var view = new Whisper.InstallView({
el: $('#install'),
deviceName: bg.textsecure.storage.user.getDeviceName()
});
$('.confirmation-dialog .ok').click(function(e) {
e.stopPropagation();
var name = $('#device-name').val();
if (name.trim().length === 0) {
return;
}
$('.confirmation-dialog').hide();
$('.progress-dialog').show();
$('.progress-dialog .status').text('Generating Keys');
resolve(name);
});
$('.modal-container').show();
if (bg.textsecure.registration.isDone()) {
view.selectStep(3);
}
view.$el.show();
var accountManager = new bg.getAccountManager();
var init = function() {
view.clearQR();
accountManager.registerSecondDevice(
view.setProvisioningUrl.bind(view),
view.confirmNumber.bind(view),
view.incrementCounter.bind(view)
).then(function() {
var launch = function() {
bg.openInbox();
bg.removeEventListener('textsecure:contactsync', launch);
clearTimeout(timeout);
window.close();
};
var timeout = setTimeout(launch, 60000);
bg.addEventListener('textsecure:contactsync', launch);
view.showSync();
}).catch(function(e) {
if (e.message === 'websocket closed') {
init();
} else if (e.name === 'HTTPError' && e.code == 411) {
view.showTooManyDevices();
}
else {
throw e;
}
});
};
$('.error-dialog .ok').click(init);
init();
});
}
var counter = 0;
function incrementCounter() {
$('.progress-dialog .bar').css('width', (++counter * 100 / 100) + '%');
}
$('.modal-container .cancel').click(function() {
$('.modal-container').hide();
});
$(function() {
var accountManager = new bg.getAccountManager();
var init = function() {
$('#init-setup').show().addClass('in');
$('#qr').html('');
$('#status').text("Connecting...");
accountManager.registerSecondDevice(setProvisioningUrl, confirmNumber, incrementCounter).then(function() {
var launch = function() {
bg.openInbox();
bg.removeEventListener('textsecure:contactsync', launch);
clearTimeout(timeout);
window.close();
};
var timeout = setTimeout(launch, 60000);
bg.addEventListener('textsecure:contactsync', launch);
$('.progress-dialog .status').text('Syncing groups and contacts');
$('.progress-dialog .bar').addClass('progress-bar-striped active');
}).catch(function(e) {
if (e.message === 'websocket closed') {
init();
} else if (e.name === 'HTTPError' && e.code == 411) {
$('.progress-dialog').hide();
$('.error-dialog').show();
$('.error-dialog .ok').click(function(e) {
chrome.runtime.reload();
});
}
else {
throw e;
}
});
};
init();
});
});
})();

67
js/views/install_view.js Normal file
View File

@ -0,0 +1,67 @@
/*
* vim: ts=4:sw=4:expandtab
*/
(function () {
'use strict';
window.Whisper = window.Whisper || {};
Whisper.InstallView = Whisper.View.extend({
initialize: function(options) {
this.counter = 0;
this.$('#device-name').val(options.deviceName);
this.$('#step1').show();
},
events: function() {
return {
'click .step1': this.selectStep.bind(this, 1),
'click .step2': this.selectStep.bind(this, 2),
'click .step3': this.selectStep.bind(this, 3)
};
},
clearQR: function() {
this.$('#qr').text("Connecting...");
},
setProvisioningUrl: function(url) {
this.$('#qr').html('');
new QRCode(this.$('#qr')[0]).makeCode(url);
},
confirmNumber: function(number) {
this.$('#step4 .number').text(libphonenumber.format(
libphonenumber.parse(number),
libphonenumber.PhoneNumberFormat.INTERNATIONAL
));
this.selectStep(4);
this.$('#device-name').focus();
return new Promise(function(resolve, reject) {
this.$('#step4 .cancel').click(function(e) {
reject();
});
this.$('#sync').click(function(e) {
e.stopPropagation();
var name = this.$('#device-name').val();
if (name.trim().length === 0) {
this.$('#device-name').focus();
return;
}
this.$('.progress-dialog .status').text('Generating Keys');
this.selectStep(5);
resolve(name);
}.bind(this));
}.bind(this));
},
incrementCounter: function() {
this.$('.progress-dialog .bar').css('width', (++this.counter * 100 / 100) + '%');
},
selectStep: function(step) {
this.$('.step').hide();
this.$('#step' + step).show();
},
showSync: function() {
this.$('.progress-dialog .status').text('Syncing groups and contacts');
this.$('.progress-dialog .bar').addClass('progress-bar-striped active');
},
showTooManyDevices: function() {
this.selectStep('TooManyDevices');
}
});
})();

View File

@ -1,113 +1,90 @@
<!DOCTYPE html>
<html>
<head>
<title>Signal Options</title>
<title>Signal</title>
<meta charset="utf-8">
<link rel="stylesheet" href="stylesheets/options.css">
<link href='/images/icon_128.png' rel='shortcut icon'>
</head>
<body>
<div id='init-setup' class='collapse'>
<header>
<div class='container'>
<div class='row'>
<div class='col-xs-2 col-md-1'>
<img id='textsecure-icon' src='/images/icon_128.png'/>
</div>
<div class='col-xs-10 col-md-11'>
<h1>Welcome to Signal for Chrome</h1>
<h4 class='tagline'>Private messaging from your web browser.</h4>
</div>
</div>
</div>
</header>
<div class='container'>
<div class='row'>
<div class='col-xs-6'>
<h4 id='step1'>Step 1</h4>
<h3 class='step'>Download the Mobile App</h3>
</div>
<div class='col-xs-6'>
<h4 id='step2'>Step 2</h4>
<h3 class='step'>Pair Your Device</h3>
</div>
</div>
<div class='row'>
<div class='col-xs-6'>
<p class='help'>
To get started, download the TextSecure app for your Android phone.
Once you've installed it, proceed to <a href='#step2'>Step 2</a>.
<p>
</div>
<div class='col-xs-6'>
<p class='help'>
Using a QR code scanning app on your phone, scan the QR code below, then
open the link to pair your device.
</p>
</div>
</div>
<div class='row'>
<div class='col-xs-6'>
<div class='cta'>
<a class='install' href='https://play.google.com/store/apps/details?id=org.thoughtcrime.securesms' target='_blank'>
<img src='/images/playstore.png' />
</a>
</div>
</div>
<div class='col-xs-6'>
<div class='cta'>
<div id='status'></div>
<div id="qr"></div>
</div>
</div>
<div id='install' class='main'>
<div id='step1' class='step'>
<img id='signal-icon' src='/images/icon_250.png'/>
<div class='nav'>
<h1>Welcome to Signal for Chrome</h1>
<p>Privacy is possible. Signal makes it easy.</p>
<div> <a class='button step2'>Get started</a> </div>
<span class='dot step1 selected'></span>
<span class='dot step2'></span>
<span class='dot step3'></span>
</div>
</div>
</div>
<div id="setup-complete" class="collapse">
<header>
<div class='container'>
<div class='row'>
<div class='col-xs-2 col-md-1'>
<img id='textsecure-icon' src='/images/icon_128.png'/>
</div>
<div class='col-xs-10 col-md-11'>
<h1>Signal for Chrome</h1>
<h4 class='tagline'>Private messaging from your web browser.</h4>
</div>
</div>
</div>
</header>
<div class='container'>
<h3>You are registered with number <span id="complete-number"></span></h3>
<div class='notifications'>
<span class='on'>Desktop notifcations are enabled. <button class='disable'>Turn off Notifications</button></span>
<span class='off'>Desktop notifcations are not enabled. <button class='enable'>Turn on Notifications</button></span>
<div id='step2' class='step'>
<img id='signal-phone' src='/images/signal-phone.png'>
<div class='nav'>
<p>First, install <a class='link' href='https://play.google.com/store/apps/details?id=org.thoughtcrime.securesms' target='_blank'>Signal</a> on your Android phone.<br /> We'll link your devices and keep your messages in sync.</p>
<div> <a class='button step3'>I have Signal for Android</a> </div>
<p>
<a class='link' href='https://twitter.com/whispersystems'>Follow us</a>
for updates about multi-device support for iOS.
</p>
<span class='dot step1'></span>
<span class='dot step2 selected'></span>
<span class='dot step3'></span>
</div>
</div>
</div>
<div class='modal-container'>
<div class='modal-main'>
<h4>Pairing</h4>
<div class='confirmation-dialog clearfix'>
<div class='panel'>
Name this device: <input type='text' id='device-name'></input>
</div>
<div class='panel'>
Your phone number: <span class='number'></span>
</div>
<button class='ok'>Continue</span>
<button class='cancel'>Cancel</span>
<div id='step3' class='step'>
<div id="qr"></div>
<p>Using barcode code scanning app on your phone, scan the QR code above, then select "Open link" or "Open browser" to add this computer to your account.</p>
<!--
<p>Open Signal on your phone and select "Add device" from the menu, then scan the QR code above to add this computer to your account.</p>
-->
<div class='nav'>
<span class='dot step1'></span>
<span class='dot step2'></span>
<span class='dot step3 selected'></span>
</div>
</div>
<div id='step4' class='step'>
<p>Registering as</p>
<h3 class='number'></h3>
<p>Verify your phone number above, then give this computer a name.</p>
<div>
<input type='text' id='device-name' spellcheck='false'></input>
</div>
<img id='signal-computer' src='/images/signal-laptop.png'>
<div class='nav'>
<div> <a class='button' id='sync'>Lookin good</a> </div>
</div>
</div>
<div id='step5' class='step'>
<img id='signal-icon' src='/images/icon_250.png'/>
<div class='progress-dialog'>
<div class='status'></div>
<p class='status'></p>
<div class='bar-container'><div class='bar progress-bar'></div></div>
</div>
<div class='error-dialog clearfix'>
<div class='panel'>Sorry, you have too many devices registered already. Try removing some.</div>
<button class='ok'>Ok</button>
<div class='nav'>
</div>
</div>
<div id='stepTooManyDevices' class='step'>
<div class='error-dialog clearfix'>
<div class='panel'>
Sorry, you have too many devices registered already.
Try removing some.
</div>
<div class='nav'>
<button class='ok step3'>Ok</button>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="js/components.js"></script>
<script type="text/javascript" src="js/database.js"></script>
@ -118,6 +95,7 @@
<script type="text/javascript" src="js/chromium.js"></script>
<script type="text/javascript" src="js/views/whisper_view.js"></script>
<script type="text/javascript" src="js/views/phone-input-view.js"></script>
<script type="text/javascript" src="js/views/install_view.js"></script>
<script type="text/javascript" src="js/options.js"></script>
</body>
</html>

View File

@ -4,7 +4,6 @@
<title>Register for Signal</title>
<meta charset="utf-8">
<link rel="stylesheet" href="stylesheets/options.css">
<link rel="stylesheet" href="components/intl-tel-input/build/css/intlTelInput.css">
</head>
<body>
<header>

View File

@ -0,0 +1 @@
../components/intl-tel-input/build/css/intlTelInput.css

File diff suppressed because it is too large Load Diff

View File

@ -1,19 +1,118 @@
@import 'variables';
@import 'bootstrap';
@import 'intlTelInput';
.iti-flag {
// override intlTelInput's flags image location
background: url("/images/flags.png");
}
* {
box-sizing: border-box;
}
html,body {
height: 100%;
}
body {
margin: 0;
font-family: $roboto;
position: relative;
background: #2090ea;
color: white;
text-align: center;
font-size: 16px;
overflow: auto;
}
header {
background: $blue;
color: white;
padding-bottom: 2em;
margin-bottom: 2em;
.clearfix:before,
.clearfix:after {
display: table;
content: " ";
}
.clearfix:after {
clear: both;
}
input, button, select, textarea {
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
#install {
display: none;
}
.main {
padding: 70px 0 10em;
}
.step {
display: none;
}
#signal-computer,
#signal-phone {
max-width: 50%;
max-height: 250px;
}
p {
max-width: 30em;
margin: 1em auto;
line-height: 1.5em;
}
a {
cursor: pointer;
&, &:visited, &:hover {
text-decoration: none;
}
}
.button {
display: inline-block;
text-transform: uppercase;
border: none;
font-weight: bold;
min-width: 300px;
padding: 0.5em;
margin: 0.5em 0;
background: white;
color: $blue;
}
.nav {
width: 100%;
position: fixed;
bottom: 50px;
margin-top: 2em;
padding: 0 20px;
.button {
margin-bottom: 3em;
}
.dot {
display: inline-block;
cursor: pointer;
margin: 10px;
width: 20px;
height: 20px;
border-radius: 10px;
background: white;
border: solid 5px $blue;
&.selected {
background: $blue_l;
}
}
}
.link {
&, &:visited, &:hover {
color: white;
font-weight: bold;
border-bottom: dashed 1px white;
text-decoration: none;
}
}
.container {
@ -26,21 +125,8 @@ h1 {
padding-bottom: 10px;
}
.tagline {
font-style: italic;
}
#textsecure-icon {
float: left;
#signal-icon {
margin-top: 20px;
max-width: 100%;
}
#step1, #step2 {
color: $blue;
font-weight: bold;
font-size: small;
text-transform: uppercase;
}
h3.step {
@ -48,14 +134,6 @@ h3.step {
font-weight: bold;
}
.cta {
text-align: center;
border: 2px solid $grey_l;
border-radius: 10px;
padding: 1em 0;
min-height: 293px;
}
.help {
border-top: 2px solid $grey_l;
padding: 1.5em 0.1em;
@ -68,12 +146,38 @@ h3.step {
#qr {
display: inline-block;
min-height: 266px;
img {
border: 5px solid white;
}
canvas {
display: none;
}
}
#device-name {
border: none;
border-bottom: 1px solid white;
background: transparent;
color: white;
font-weight: bold;
text-align: center;
&::selection, a::selection {
color: $grey_d;
background: white;
}
&::-moz-selection, a::-moz-selection {
color: $grey_d;
background: white;
}
&:focus {
outline: white auto 5px;
}
}
#verifyCode,
#code,
#number {
@ -81,6 +185,7 @@ h3.step {
width: 100%;
display: block;
margin-bottom: 0.5em;
text-align: center;
}
#request-voice,
@ -144,6 +249,7 @@ h3.step {
padding-right: 0.5em;
}
.narrow {
margin: auto;
box-sizing: border-box;
width: 275px;
max-width: 100%;
@ -153,6 +259,69 @@ ul.country-list {
min-width: 197px !important;
}
.confirmation-dialog, .progress-dialog, .error-dialog {
padding: 1em;
text-align: left;
}
.number { text-align: center; }
.confirmation-dialog, .error-dialog {
button {
float: right;
margin-left: 10px;
}
}
@keyframes progress-bar-stripes {
from {
background-position: 40px 0;
}
to {
background-position: 0 0;
}
}
.progress-bar-striped {
background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .75) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .75) 50%, rgba(255, 255, 255, .75) 75%, transparent 75%, transparent);
background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, .75) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .75) 50%, rgba(255, 255, 255, .75) 75%, transparent 75%, transparent);
background-image: linear-gradient(45deg, rgba(255, 255, 255, .75) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .75) 50%, rgba(255, 255, 255, .75) 75%, transparent 75%, transparent);
-webkit-background-size: 40px 40px;
background-size: 40px 40px;
}
.progress-bar-striped {
background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .75) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .75) 50%, rgba(255, 255, 255, .75) 75%, transparent 75%, transparent);
background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, .75) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .75) 50%, rgba(255, 255, 255, .75) 75%, transparent 75%, transparent);
background-image: linear-gradient(45deg, rgba(255, 255, 255, .75) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .75) 50%, rgba(255, 255, 255, .75) 75%, transparent 75%, transparent);
}
.progress-bar.active {
-webkit-animation: progress-bar-stripes 2s linear infinite;
-o-animation: progress-bar-stripes 2s linear infinite;
animation: progress-bar-stripes 2s linear infinite;
}
.progress-dialog {
text-align: center;
padding: 1em;
max-width: 600px;
margin: auto;
.status { padding: 1em; }
.bar-container {
height: 1em;
background-color: $grey_l;
border: solid 1px white;
}
.bar {
width: 0;
height: 100%;
background-color: $blue_l;
transition: width 0.25s;
&.active {
}
}
}
.error-dialog {
display: none;
}
.modal-container {
display: none;
position: absolute;
@ -180,37 +349,5 @@ ul.country-list {
text-align: left;
}
.confirmation-dialog, .progress-dialog, .error-dialog {
padding: 1em;
text-align: left;
}
.confirmation-dialog .number { text-align: center; }
.confirmation-dialog, .error-dialog {
button {
float: right;
margin-left: 10px;
}
}
.progress-dialog {
display: none;
text-align: center;
padding: 1em;
.status { padding: 1em; }
.bar-container {
height: 1em;
background-color: $grey_l;
}
.bar {
width: 0;
height: 100%;
background-color: $blue;
transition: width 0.25s;
}
}
.error-dialog {
display: none;
}
}
}