diff --git a/browserid/compress.sh b/browserid/compress.sh index 3ff73d706e6158b2788f647b2dddf47ed9be3482..67707a8b1162c455e8d4daa861bec57bb6bc47d3 100755 --- a/browserid/compress.sh +++ b/browserid/compress.sh @@ -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 pages/signin.js pages/signup.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 pages/forgot.js > lib.js $UGLIFY < lib.js > lib.min.js cd ../css diff --git a/browserid/static/js/browserid.js b/browserid/static/js/browserid.js index f6759e8d5286cc17a40a563499ba1057e37e8fae..3c7974a999611114a6f8891c33a39eb0645295a3 100644 --- a/browserid/static/js/browserid.js +++ b/browserid/static/js/browserid.js @@ -67,6 +67,9 @@ $(function() { else if (path === "/signup") { bid.signUp(); } + else if (path === "/forgot") { + bid.forgot(); + } else if (token && path === "/add_email_address") { bid.addEmailAddress(token); } diff --git a/browserid/static/js/pages/forgot.js b/browserid/static/js/pages/forgot.js new file mode 100644 index 0000000000000000000000000000000000000000..9ee24e23a6b673b5a1b756abec69fd3003c2b353 --- /dev/null +++ b/browserid/static/js/pages/forgot.js @@ -0,0 +1,69 @@ +/*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 ***** */ + +BrowserID.forgot = (function() { + "use strict"; + + return function() { + $("form input[autofocus]").focus(); + + $("#signUpForm").bind("submit", function(event) { + event.preventDefault(); + $(".notifications .notification").hide(); + + var email = $("#email").val(), + password = $("#password").val(), + vpassword = $("#vpassword").val(); + + if (password != vpassword) { + $(".notifications .notification.mismatchpassword").fadeIn(); + return false; + } + + BrowserIDIdentities.createUser(email, function onSuccess(keypair) { + $('#sent_to_email').html(email); + $('#forminputs').fadeOut(); + $(".notifications .notification.emailsent").fadeIn(); + }, function onFailure() { + // bad authentication + $(".notifications .notification.doh").fadeIn(); + }); + }); + }; + + +}()); + diff --git a/browserid/static/js/pages/verify_email_address.js b/browserid/static/js/pages/verify_email_address.js index 5315582c6657ce83dd7c842d3e99025cc0b10218..123a5b4b54c649ea74762b53cf3dd52c531facf2 100644 --- a/browserid/static/js/pages/verify_email_address.js +++ b/browserid/static/js/pages/verify_email_address.js @@ -55,5 +55,24 @@ }); } }); + + var staged = BrowserIDStorage.getStagedOnBehalfOf(); + if (staged) { + $('.website').html(staged); + } + else { + $('.hint').hide(); + } + + // go get the email address + BrowserIDNetwork.emailForVerificationToken(token, function(email) { + if (email) { + $('#email').val(email); + } + else { + $('#signUpFormWrap').html('There was a problem with your signup link.'); + } + }); + }; }()); diff --git a/browserid/views/forgot.ejs b/browserid/views/forgot.ejs index 6c05a8f1bd3151226a618a1a46ae0aba36665121..b280f3f463253fa63f3673465396e16c2031b611 100644 --- a/browserid/views/forgot.ejs +++ b/browserid/views/forgot.ejs @@ -26,33 +26,3 @@ </div> </div> -<script type="text/javascript"> - $(document).ready(function () { - $("form input[autofocus]").focus(); - - $("#signUpForm").bind("submit", function(event) { - event.preventDefault(); - $(".notifications .notification").hide(); - - var email = $("#email").val(), - password = $("#password").val(), - vpassword = $("#vpassword").val(); - - if (password != vpassword) { - $(".notifications .notification.mismatchpassword").fadeIn(); - return false; - } - - BrowserIDIdentities.createUser(email, function onSuccess(keypair) { - $('#sent_to_email').html(email); - $('#forminputs').fadeOut(); - $(".notifications .notification.emailsent").fadeIn(); - }, function onFailure() { - // bad authentication - $(".notifications .notification.doh").fadeIn(); - }); - return false; - }); - - }); -</script> diff --git a/browserid/views/layout.ejs b/browserid/views/layout.ejs index 1ec6942c3cfe31cc9647e78d647c37c77d78d329..8ca015da271214e526685b2fe1324dddbd8fb8ef 100644 --- a/browserid/views/layout.ejs +++ b/browserid/views/layout.ejs @@ -21,6 +21,7 @@ <script src="/js/pages/index.js" type="text/javascript"></script> <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/forgot.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> diff --git a/browserid/views/verifyuser.ejs b/browserid/views/verifyuser.ejs index 66ce2e6203a0783e0b5d2f23d38673c389863b5d..811b1763d54927af76023f9ae35a56bf1d48c736 100644 --- a/browserid/views/verifyuser.ejs +++ b/browserid/views/verifyuser.ejs @@ -29,20 +29,3 @@ </div> </div> -<script> -$(document).ready(function() { - var staged = BrowserIDStorage.getStagedOnBehalfOf(); - if (staged) - $('.website').html(staged); - else - $('.hint').hide(); - - // go get the email address - BrowserIDNetwork.emailForVerificationToken("<%= token %>", function(email) { - if (email) - $('#email').val(email); - else - $('#signUpFormWrap').html('There was a problem with your signup link.'); - }); -}); -</script>