aboutsummaryrefslogtreecommitdiffstats
path: root/www/js/views/login.js
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2013-07-12 09:47:56 +0100
committerStruan Donald <struan@exo.org.uk>2013-07-12 11:00:11 +0100
commit25e3a0c94551b0faac3f16e0598e6f4bdffcf7d8 (patch)
treef78f68ba8ed39e5b5004e41435aac3e9bbe9c044 /www/js/views/login.js
parent4c2206c97250b7f72eb04d13ae886a7fb4f4086a (diff)
instead of using js to inject the correct cordova js file in to
index.html restructure things so that the common files are a level down and the platofrm specific ones are directly placed in the relevant project. This both makes for less fuss and also avoids the error with Android < v3 instantiating cordova twice. Note that the iOS common assets are included by a build script rather than a symlink as symlinking doesn't seem to agree with Xcode
Diffstat (limited to 'www/js/views/login.js')
-rw-r--r--www/js/views/login.js108
1 files changed, 0 insertions, 108 deletions
diff --git a/www/js/views/login.js b/www/js/views/login.js
deleted file mode 100644
index a24daa9..0000000
--- a/www/js/views/login.js
+++ /dev/null
@@ -1,108 +0,0 @@
-(function (FMS, Backbone, _, $) {
- _.extend( FMS, {
- LoginView: FMS.FMSView.extend({
- template: 'login',
- id: 'login',
- next: 'home',
-
- events: {
- 'pagehide': 'destroy',
- 'pagebeforeshow': 'beforeDisplay',
- 'pageshow': 'afterDisplay',
- 'vclick #login': 'onClickLogin',
- 'submit #signinForm': 'onClickLogin',
- 'vclick #logout': 'onClickLogout',
- 'vclick .ui-btn-left': 'onClickButtonPrev',
- 'vclick .ui-btn-right': 'onClickButtonNext'
- },
-
- onClickLogin: function(e) {
- // prevent form submission from onscreen keyboard
- e.preventDefault();
- if ( this.validate() ) {
- var that = this;
- $.ajax( {
- url: CONFIG.FMS_URL + '/auth/ajax/sign_in',
- type: 'POST',
- data: {
- email: $('#form_email').val(),
- password_sign_in: $('#form_password').val(),
- remember_me: 1
- },
- dataType: 'json',
- timeout: 30000,
- success: function( data, status ) {
- if ( data.name ) {
- that.model.set('password', $('#form_password').val());
- that.model.set('email', $('#form_email').val());
- that.model.set('name', data.name);
- that.model.save();
- FMS.isLoggedIn = 1;
- that.$('#password_row').hide();
- that.$('#success_row').show();
- $('#logout').focus();
- } else {
- $('#login').focus();
- that.validationError('form_email', FMS.strings.login_details_error);
- }
- },
- error: function() {
- that.validationError('form_email', FMS.strings.login_error);
- }
- } );
- }
- },
-
- onClickLogout: function(e) {
- e.preventDefault();
- var that = this;
- $.ajax( {
- url: CONFIG.FMS_URL + '/auth/ajax/sign_out',
- type: 'GET',
- dataType: 'json',
- timeout: 30000,
- success: function( data, status ) {
- FMS.isLoggedIn = 0;
- that.model.set('password', '');
- that.model.save();
- that.$('#form_email').val('');
- that.$('#form_password').val('');
- that.$('#success_row').hide();
- that.$('#signed_in_row').hide();
- that.$('#password_row').show();
- },
- error: function() {
- that.validationError('err', FMS.strings.logout_error);
- }
- } );
- },
-
- validate: function() {
- this.clearValidationErrors();
- var isValid = 1;
-
- if ( !$('#form_password').val() ) {
- isValid = 0;
- this.validationError('form_password', FMS.validationStrings.password );
- }
-
- var email = $('#form_email').val();
- if ( !email ) {
- isValid = 0;
- this.validationError('form_email', FMS.validationStrings.email.required);
- // regexp stolen from jquery validate module
- } else if ( ! /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(email) ) {
- isValid = 0;
- this.validationError('form_email', FMS.validationStrings.email.email);
- }
-
- if ( !isValid ) {
- // this makes sure the onscreen keyboard is dismissed
- $('#login').focus();
- }
-
- return isValid;
- }
- })
- });
-})(FMS, Backbone, _, $);