Skip to content
Snippets Groups Projects
Commit eb9e8e08 authored by Shane Tomlinson's avatar Shane Tomlinson
Browse files

Removing the last of the inline scripts into their own files - signin and signup.

parent 4f7ccae9
No related branches found
No related tags found
No related merge requests found
......@@ -44,7 +44,7 @@ echo ''
cd ../js
# re-minimize everything together
cat jquery-1.6.2.min.js json2.js ../dialog/resources/underscore-min.js ../dialog/resources/storage.js ../dialog/resources/browserid-network.js ../dialog/resources/browserid-identities.js browserid.js pages/index.js pages/add_email_address.js pages/verify_email_address.js pages/manage_account.js > lib.js
cat jquery-1.6.2.min.js json2.js ../dialog/resources/underscore-min.js ../dialog/resources/storage.js ../dialog/resources/browserid-network.js ../dialog/resources/browserid-identities.js browserid.js pages/index.js pages/add_email_address.js pages/verify_email_address.js pages/manage_account.js pages/signin.js pages/signup.js > lib.js
$UGLIFY < lib.js > lib.min.js
cd ../css
......
......@@ -58,9 +58,15 @@ $(function() {
path = document.location.pathname,
bid = BrowserID;
if (path === "/") {
if (!path || path === "/") {
bid.index();
}
else if (path === "/signin") {
bid.signIn();
}
else if (path === "/signup") {
bid.signUp();
}
else if (token && path === "/add_email_address") {
bid.addEmailAddress(token);
}
......
/*globals BrowserID:true, BrowserIDNetwork: true, $:true*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla BrowserID.
*
* The Initial Developer of the Original Code is Mozilla.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
(function() {
"use strict";
BrowserID.signIn = function () {
$("form input[autofocus]").focus();
$("#signUpForm").bind("submit", function(event) {
event.preventDefault();
var email = $("#email").val(),
password = $("#password").val();
BrowserIDNetwork.authenticate(email, password, function onSuccess(authenticated) {
if (authenticated) {
document.location = "/";
}
else {
// bad authentication
$(".notifications .notification.doh").fadeIn();
}
}, function onFailure() {
// Wah wah. Network error
});
});
};
}());
/*globals BrowserID:true, BrowserIDIdentities: true, $:true*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla BrowserID.
*
* The Initial Developer of the Original Code is Mozilla.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
(function() {
"use strict";
BrowserID.signUp = function () {
var ANIMATION_SPEED = 250;
function replaceWithMessage(selector) {
$('.forminputs').fadeOut(ANIMATION_SPEED, function() {
$(selector).fadeIn(ANIMATION_SPEED);
});
}
function showNotice(selector) {
$(selector).fadeIn(ANIMATION_SPEED);
}
function onFailure() {
replaceWithMessage(".doh");
}
$(function () {
var identities = BrowserIDIdentities;
$("form input[autofocus]").focus();
$("#email").bind("keyup", function(event) {
if (event.which !== 13) {
$(".notification").fadeOut(ANIMATION_SPEED);
}
});
$("#signUpForm").bind("submit", function(event) {
event.preventDefault();
var email = $("#email").val();
identities.emailRegistered(email, function(registered) {
if (!registered) {
identities.createUser(email, function onSuccess(keypair) {
$('#sentToEmail').html(email);
replaceWithMessage(".emailsent");
}, onFailure);
}
else {
$('#registeredEmail').html(email);
showNotice(".alreadyRegistered");
}
}, onFailure);
});
});
};
}());
......@@ -38,20 +38,3 @@
</li>
</script>
<script type="text/javascript">
$(function () {
$('.granted').hover(function() {
$('#card').toggleClass('insert');
$('#status').delay(400).toggleClass('green');
});
$('.create').hover(function() {
$('#hint').addClass('signUp').removeClass('info');
});
$('.info').hover(function() {
$('#hint').removeClass('signUp').addClass('info');
});
});
</script>
......@@ -22,6 +22,8 @@
<script src="/js/pages/add_email_address.js" type="text/javascript"></script>
<script src="/js/pages/verify_email_address.js" type="text/javascript"></script>
<script src="/js/pages/manage_account.js" type="text/javascript"></script>
<script src="/js/pages/signin.js" type="text/javascript"></script>
<script src="/js/pages/signup.js" type="text/javascript"></script>
<script src="/dialog/resources/storage.js" type="text/javascript"></script>
<script src="/dialog/resources/browserid-network.js" type="text/javascript"></script>
<script src="/dialog/resources/browserid-identities.js" type="text/javascript"></script>
......
......@@ -37,28 +37,3 @@
</div>
</div>
<script type="text/javascript">
$(document).ready(function () {
$("form input[autofocus]").focus();
$("#signUpForm").bind("submit", function(event) {
event.preventDefault();
var email = $("#email").val(),
password = $("#password").val();
BrowserIDNetwork.authenticate(email, password, function onSuccess(authenticated) {
if (authenticated) {
document.location = "/";
}
else {
// bad authentication
$(".notifications .notification.doh").fadeIn();
}
}, function onFailure() {
// Wah wah. Network error
});
});
});
</script>
......@@ -28,52 +28,3 @@
</div>
</div>
<script type="text/javascript">
var ANIMATION_SPEED = 250;
function replaceWithMessage(selector) {
$('.forminputs').fadeOut(ANIMATION_SPEED, function() {
$(selector).fadeIn(ANIMATION_SPEED);
});
}
function showNotice(selector) {
$(selector).fadeIn(ANIMATION_SPEED);
}
function onFailure() {
replaceWithMessage(".doh");
}
$(function () {
var identities = BrowserIDIdentities;
$("form input[autofocus]").focus();
$("#email").bind("keyup", function(event) {
if (event.which !== 13) {
$(".notification").fadeOut(ANIMATION_SPEED);
}
});
$("#signUpForm").bind("submit", function(event) {
event.preventDefault();
var email = $("#email").val();
identities.emailRegistered(email, function(registered) {
if (!registered) {
identities.createUser(email, function onSuccess(keypair) {
$('#sentToEmail').html(email);
replaceWithMessage(".emailsent");
}, onFailure);
}
else {
$('#registeredEmail').html(email);
showNotice(".alreadyRegistered");
}
}, onFailure);
});
});
</script>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment