Clean up for the js front end
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 19 Oct 2017 19:06:50 +0000 (15:06 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 19 Oct 2017 19:07:49 +0000 (15:07 -0400)
Removing the login and register models and views.

js/collections/front/accounts.js
js/frontRegApp.js
js/models/front/account.js
js/models/front/login.js [deleted file]
js/models/front/regRequestRegistrant.js
js/models/front/register.js [deleted file]
js/views/front/app.js
js/views/front/login.js [deleted file]
js/views/front/register.js [deleted file]

index f24f5bd..d017c0c 100644 (file)
@@ -4,44 +4,8 @@
 app.Collections.Front.Accounts = Backbone.Collection.extend({
     model: app.Models.Front.Account,
 
-    // initialize: function( parent ){
-    //     this.parent = parent;
-    // },
-
     url: ajaxUrl+'&glm_action=regFront&collection=accounts',
 
-    // create: function( model ){
-    //     console.log( model );
-    //     //model.save();
-    //     //localStorage.setItem('Account-' + model.parent + '-'+ model.id, JSON.stringify( model ) );
-    //     //this.add( model );
-    // },
-
-    // remove: function( model ){
-    //     //localStorage.removeItem( localStorage.key('Account-' + model.parent + '-'+ model.id ) );
-    //     //console.log( 'Delete called in collection ' );
-    // },
-
-    // read: function(){
-    //     console.log( 'Read called' );
-    // },
-
-    // save: function(){
-    //     console.log('Update Called');
-    // },
-
-    // fetch: function(){
-    //     var newModels = [];
-    //     for ( var i = 0; i < localStorage.length; i++ ) {
-    //         var curItem = JSON.parse( localStorage.getItem( localStorage.key( i ) ) );
-    //         if ( curItem.parent === this.parent ) {
-    //             // now add it to this collection
-    //             newModels.push( new app.Models.Front.Account( curItem ) );
-    //         }
-    //     }
-    //     this.reset( newModels );
-    // },
-
 });
 
 
index 28e43f7..4b1e55e 100644 (file)
@@ -15,19 +15,6 @@ app.Models.Front.Account = Backbone.Model.extend({
 
     url: ajaxUrl+'&glm_action=regFront&collection=account',
 
-    // sync: function( method, model ){
-    //     console.log( 'sync in model' );
-    //     // console.log( method );
-    //     // console.log( model );
-    //     switch ( method ) {
-    //         case 'delete':
-    //             console.log( 'Delete called in account model' );
-    //             break;
-    //     }
-    //     Backbone.sync.apply(this, arguments);
-    //
-    // },
-
     initialize: function(){
         this.on( 'invalid', function( model, error ){
             console.log( error );
@@ -96,36 +83,6 @@ app.Models.Front.Cart = Backbone.Model.extend({
     },
 });
 
-// js/models/login.js
-
-// Login Model
-app.Models.Front.Login = Backbone.Model.extend({
-
-    defaults:  {
-        username: '',
-        password: '',
-        message: '',
-    },
-
-    urlRoot: appLoginUrl,
-
-    initialize: function(){
-        this.on( 'invalid', function( model, error ){
-            console.log( error );
-        });
-    },
-
-    validate: function( attribs, options ){
-        if ( attribs.username === undefined || attribs.username === '' ){
-            return 'Username required!';
-        }
-        if ( attribs.password === undefined || attribs.password === '' ){
-            return 'Password required!';
-        }
-    },
-
-});
-
 // js/models/regClass.js
 
 // Registration Class Model
@@ -279,48 +236,6 @@ app.Models.Front.RegRequestRegistrant = Backbone.Model.extend({
         }
     },
 
-    // sync: function( method, model ){
-    //     //console.log( 'sync in model' );
-    //     // console.log( method );
-    //     // console.log( model );
-    //     switch ( method ) {
-    //         case 'delete':
-    //             console.log( 'Delete called in registrant model' );
-    //             return false;
-    //             //this.url = url + 'model=' + model.toJSON();
-    //             break;
-    //     }
-    //     Backbone.sync.apply(this, arguments);
-    //
-    // },
-});
-
-app.Models.Front.Register = Backbone.Model.extend({
-    defaults: {
-        validEmail: false,
-        name: 'register',
-        email: '',
-        emailError: '',
-        password: '',
-        fname: '',
-        lname: '',
-        org: '',
-        title: '',
-        addr1: '',
-        addr2: '',
-        city: '',
-        state: '',
-        zip: '',
-        country: '',
-        phone: '',
-        fax: '',
-    },
-
-    urlRoot: ajaxUrl + 'glm_action=register',
-
-    validate: function(){
-        // Validation stuff here
-    },
 });
 
 app.Models.Front.Request = Backbone.Model.extend({
@@ -367,44 +282,8 @@ app.Models.Front.Request = Backbone.Model.extend({
 app.Collections.Front.Accounts = Backbone.Collection.extend({
     model: app.Models.Front.Account,
 
-    // initialize: function( parent ){
-    //     this.parent = parent;
-    // },
-
     url: ajaxUrl+'&glm_action=regFront&collection=accounts',
 
-    // create: function( model ){
-    //     console.log( model );
-    //     //model.save();
-    //     //localStorage.setItem('Account-' + model.parent + '-'+ model.id, JSON.stringify( model ) );
-    //     //this.add( model );
-    // },
-
-    // remove: function( model ){
-    //     //localStorage.removeItem( localStorage.key('Account-' + model.parent + '-'+ model.id ) );
-    //     //console.log( 'Delete called in collection ' );
-    // },
-
-    // read: function(){
-    //     console.log( 'Read called' );
-    // },
-
-    // save: function(){
-    //     console.log('Update Called');
-    // },
-
-    // fetch: function(){
-    //     var newModels = [];
-    //     for ( var i = 0; i < localStorage.length; i++ ) {
-    //         var curItem = JSON.parse( localStorage.getItem( localStorage.key( i ) ) );
-    //         if ( curItem.parent === this.parent ) {
-    //             // now add it to this collection
-    //             newModels.push( new app.Models.Front.Account( curItem ) );
-    //         }
-    //     }
-    //     this.reset( newModels );
-    // },
-
 });
 
 
@@ -501,204 +380,22 @@ app.Views.Front.App = Backbone.View.extend({
     render: function(){
         // Check to see if there's a login
         if ( loginAccount ) {
-            // jQuery('#appLogin').hide();
             jQuery('#register').hide();
-            // this.accountView = new app.Views.Front.Account({ model: loginAccount });
-            // this.$el.append( this.accountView.render().el );
         }
         this.$el.append( this.event.render().el );
         return this;
     },
 
     events: {
-        // 'click #appLogin': 'login',
         'click #glm-reg-cart-continue': 'continue',
-        // 'click #accountLogin': 'loginToAccount',
-        // 'click #accountRegister': 'registerNewAccount',
-        // 'click #accountLogout': 'logout',
-        // 'click #register': 'register',
     },
 
     continue: function(){
-        console.log( cart );
         // Confirm they are done and goto the next page
         var isDone = confirm( 'Are you done?' );
         if ( isDone ) {
             window.location.href = nextPageUrl;
         }
-        // Need to update the cart
-    },
-
-    // logout: function(){
-    //     // Send data to Logout
-    //     jQuery.ajax({
-    //         context: this,
-    //         url: appAccountUrl,
-    //         dataType: 'json',
-    //         data: 'option=logout'
-    //     })
-    //     .done(function( msg ){
-    //         // Here we can update.
-    //         loginAccount = '';
-    //         this.accountView.remove();
-    //         this.render();
-    //         this.event.model.classes.map(function(item){
-    //             item.set({ loggedIn: false });
-    //         });
-    //         jQuery('#appLogin').show();
-    //         // Need to reload the page now
-    //         window.location.href = thisPageUrl;
-    //     })
-    //     .fail(function(msg){
-    //         console.log('Fail:');
-    //         console.log( msg );
-    //     });
-    // },
-
-    loginToAccount: function(){
-        this.$userInput = jQuery('.login');
-        this.$pwdInput = jQuery('.password');
-
-        // Send data to login ajax and verify user login
-        jQuery.ajax({
-            context: this,
-            url: appAccountUrl,
-            dataType: 'json',
-            data: 'option=login&username=' + this.$userInput.val().trim() + '&password=' + this.$pwdInput.val().trim()
-        })
-        .done(function(account){
-            if ( account.valid !== false ) {
-                // Create account model and assign to this.loginAccount
-                loginAccount = new app.Models.Front.Account({
-                    id: account.id,
-                    email: account.email,
-                    fname: account.fname,
-                    lname: account.lname
-                });
-                // Destroy the model and remove the view
-                this.loginModel.destroy();
-                this.loginView.remove();
-                this.render();
-                this.event.model.classes.map(function(item){
-                    item.set({ loggedIn: true });
-                });
-            } else {
-                console.log( 'Login failed' );
-                this.loginModel.set({ message: 'Failed login!' });
-            }
-        })
-        .fail(function(msg){
-            console.log('Fail: ' );
-            console.log( msg );
-        });
-    },
-
-    registerNewAccount: function(){
-        this.$email    = this.$('.account_email').val().trim();
-        this.$password = this.$('.account_password').val().trim();
-        this.$fname    = this.$('.account_fname').val().trim();
-        this.$lname    = this.$('.account_lname').val().trim();
-        this.$addr1    = this.$('.account_addr1').val().trim();
-        this.$addr2    = this.$('.account_addr2').val().trim();
-        this.$city     = this.$('.account_city').val().trim();
-        this.$state    = this.$('.account_state').val().trim();
-        this.$zip      = this.$('.account_zip').val().trim();
-        this.$country  = this.$('.account_country').val().trim();
-
-        // Send request to backend
-        jQuery.ajax({
-            context: this,
-            url: appAccountUrl,
-            dataType: 'json',
-            data:{
-                option: 'register',
-                email: this.$email,
-                password: this.$password,
-                fname: this.$fname,
-                lname: this.$lname,
-                addr1: this.$addr1,
-                addr2: this.$addr2,
-                city: this.$city,
-                state: this.$state,
-                zip: this.$zip,
-                country: this.$country,
-            }
-        })
-        .done(function(account){
-            console.log('return from ajax for register new');
-            console.log(account);
-            if ( account.id != undefined && account.id !== '' ) {
-                // Account was created.
-                // Now use this account for login.
-                loginAccount = new app.Models.Front.Account({
-                    id: account.id,
-                    email: account.email,
-                    fname: account.fname,
-                    lname: account.lname
-                });
-                this.registerModel.destroy();
-                this.registerView.remove();
-                this.render();
-            }
-        })
-        .fail(function(msg){
-            console.log('Fail: ' );
-            console.log( msg );
-        });
-    },
-
-    // login: function(){
-    //     this.loginModel = new app.Models.Front.Login();
-    //     this.loginView  = new app.Views.Front.Login({ model: this.loginModel });
-    //     this.$el.append( this.loginView.render().el );
-    //     jQuery('#accountHeader').hide();
-    // },
-
-    // register: function(){
-    //     this.registerModel = new app.Models.Front.Register();
-    //     this.registerView  = new app.Views.Front.Register({ model: this.registerModel });
-    //     this.$el.append( this.registerView.render().el );
-    //     jQuery('#accountHeader').hide();
-    // },
-
-});
-
-// js/views/login.js
-
-// Login View
-app.Views.Front.Login = Backbone.View.extend({
-    tagName: 'div',
-
-    className: 'glm-reg-login',
-
-    template: _.template( jQuery('#eventReg-account-login').html() ),
-
-    events: {
-        'click #loginCancel': 'closeLoginForm',
-        //'keydown': 'keyAction',
-    },
-
-    initialize: function(){
-        this.listenTo( this.model, 'change', this.render );
-        return this;
-    },
-
-    closeLoginForm: function(){
-        this.remove();
-        jQuery('#accountHeader').show();
-        return;
-    },
-
-    render: function(){
-        this.$el.html( this.template( this.model.toJSON() ) );
-        //jQuery('.login').focus();
-        return this;
-    },
-
-    keyAction: function(e){
-        if ( e.which === 13 ) {
-            console.log( 'Enter key used' );
-        }
     },
 
 });
@@ -1131,117 +828,6 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({
 
 });
 
-app.Views.Front.Register = Backbone.View.extend({
-    tagName: 'div',
-
-    className: 'glm-reg-register',
-
-    template: _.template( jQuery('#register-new-account').html() ),
-
-    events: {
-        'click #registerCancel': 'closeForm',
-        'focusout .account_email': 'checkEmail',
-        'focusout .account_password': 'checkPassword',
-    },
-
-    initialize: function(){
-        this.listenTo( this.model, 'change', this.render );
-    },
-
-    render: function(){
-        this.$el.html( this.template( this.model.toJSON() ) );
-        return this;
-    },
-
-    closeForm: function(){
-        this.remove();
-        jQuery('#accountHeader').show();
-        return;
-    },
-
-    addErrorMsg: function( error ){
-        var errors = this.model.get( 'errors' );
-        console.log( 'in addErrorMsg' );
-        errors.push( error );
-        console.log( errors );
-    },
-
-    checkEmail: function(){
-        console.log( 'focusout for email' );
-        this.$('.account_email').removeClass('error');
-        this.model.set({ emailError: '' });
-        // if they entered email then test for existing email
-        if ( this.model.get( 'validEmail' ) === true ){
-            return;
-        }
-        var cEmail = this.$('.account_email').val().trim();
-        if ( cEmail === undefined || cEmail === '' ) {
-            return;
-        }
-        console.log( cEmail );
-        jQuery.ajax({
-            context: this,
-            url: ajaxUrl + '&glm_action=account&option=checkEmail',
-            dataType: 'json',
-            data:{
-                email: cEmail,
-            }
-        })
-        .done(function(account){
-            if ( account.validEmail !== true ) {
-                this.$('.account_email').addClass('error');
-                //this.model.errors.push('Must be a valid email address!');
-                //this.addErrorMsg( 'Must be a valid email address!' );
-                //alert('Must be a valid email address!');
-                //jQuery('.account_email').focus();
-                this.model.set({ emailError: 'Must be a valid email address!' });
-            } else if ( account.id !== undefined && account.email !== undefined ) {
-                alert('There is an account already with that email address.\nPlease use another one!');
-                jQuery('.account_email').val('');
-                //jQuery('.account_email').focus();
-            } else {
-                // email is not existing account and valid
-                this.model.set({ validEmail: true });
-                this.$('.account_email').removeClass('error');
-            }
-        })
-        .fail(function(msg){
-            console.log('Fail: ' + msg);
-        });
-    },
-
-    checkPassword: function(){
-        console.log( 'focusout for password' );
-        this.$('.account_password').removeClass('error');
-        // only check if there's something in the field
-        var tPass = this.$('.account_password').val().trim();
-        if ( tPass === '' ) {
-            return;
-        }
-        jQuery.ajax({
-            context: this,
-            url: ajaxUrl + '&glm_action=account&option=checkPassword',
-            dataType: 'json',
-            data: {
-                password: this.$('.account_password').val().trim()
-            }
-        })
-        .done(function(data){
-            console.log( data );
-            if ( data.msg ) {
-                this.$('.account_password').addClass('error');
-                alert( 'Password Error: \n' + data.msg );
-            } else {
-                this.$('.account_password').removeClass('error');
-            }
-        })
-        .fail(function(msg){
-            console.log( 'Fail: ' + msg );
-        });
-    },
-
-});
-
 app.Views.Front.RegistrantForm = Backbone.View.extend({
     tagName: 'div',
 
index f9827a1..77aa868 100644 (file)
@@ -15,19 +15,6 @@ app.Models.Front.Account = Backbone.Model.extend({
 
     url: ajaxUrl+'&glm_action=regFront&collection=account',
 
-    // sync: function( method, model ){
-    //     console.log( 'sync in model' );
-    //     // console.log( method );
-    //     // console.log( model );
-    //     switch ( method ) {
-    //         case 'delete':
-    //             console.log( 'Delete called in account model' );
-    //             break;
-    //     }
-    //     Backbone.sync.apply(this, arguments);
-    //
-    // },
-
     initialize: function(){
         this.on( 'invalid', function( model, error ){
             console.log( error );
diff --git a/js/models/front/login.js b/js/models/front/login.js
deleted file mode 100644 (file)
index 6280f38..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-// js/models/login.js
-
-// Login Model
-app.Models.Front.Login = Backbone.Model.extend({
-
-    defaults:  {
-        username: '',
-        password: '',
-        message: '',
-    },
-
-    urlRoot: appLoginUrl,
-
-    initialize: function(){
-        this.on( 'invalid', function( model, error ){
-            console.log( error );
-        });
-    },
-
-    validate: function( attribs, options ){
-        if ( attribs.username === undefined || attribs.username === '' ){
-            return 'Username required!';
-        }
-        if ( attribs.password === undefined || attribs.password === '' ){
-            return 'Password required!';
-        }
-    },
-
-});
index 75863b6..fe70b66 100644 (file)
@@ -44,18 +44,4 @@ app.Models.Front.RegRequestRegistrant = Backbone.Model.extend({
         }
     },
 
-    // sync: function( method, model ){
-    //     //console.log( 'sync in model' );
-    //     // console.log( method );
-    //     // console.log( model );
-    //     switch ( method ) {
-    //         case 'delete':
-    //             console.log( 'Delete called in registrant model' );
-    //             return false;
-    //             //this.url = url + 'model=' + model.toJSON();
-    //             break;
-    //     }
-    //     Backbone.sync.apply(this, arguments);
-    //
-    // },
 });
diff --git a/js/models/front/register.js b/js/models/front/register.js
deleted file mode 100644 (file)
index b3fbe53..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-app.Models.Front.Register = Backbone.Model.extend({
-    defaults: {
-        validEmail: false,
-        name: 'register',
-        email: '',
-        emailError: '',
-        password: '',
-        fname: '',
-        lname: '',
-        org: '',
-        title: '',
-        addr1: '',
-        addr2: '',
-        city: '',
-        state: '',
-        zip: '',
-        country: '',
-        phone: '',
-        fax: '',
-    },
-
-    urlRoot: ajaxUrl + 'glm_action=register',
-
-    validate: function(){
-        // Validation stuff here
-    },
-});
index 8fb67dc..be928d8 100644 (file)
@@ -17,164 +17,22 @@ app.Views.Front.App = Backbone.View.extend({
     render: function(){
         // Check to see if there's a login
         if ( loginAccount ) {
-            // jQuery('#appLogin').hide();
             jQuery('#register').hide();
-            // this.accountView = new app.Views.Front.Account({ model: loginAccount });
-            // this.$el.append( this.accountView.render().el );
         }
         this.$el.append( this.event.render().el );
         return this;
     },
 
     events: {
-        // 'click #appLogin': 'login',
         'click #glm-reg-cart-continue': 'continue',
-        // 'click #accountLogin': 'loginToAccount',
-        // 'click #accountRegister': 'registerNewAccount',
-        // 'click #accountLogout': 'logout',
-        // 'click #register': 'register',
     },
 
     continue: function(){
-        console.log( cart );
         // Confirm they are done and goto the next page
         var isDone = confirm( 'Are you done?' );
         if ( isDone ) {
             window.location.href = nextPageUrl;
         }
-        // Need to update the cart
     },
 
-    // logout: function(){
-    //     // Send data to Logout
-    //     jQuery.ajax({
-    //         context: this,
-    //         url: appAccountUrl,
-    //         dataType: 'json',
-    //         data: 'option=logout'
-    //     })
-    //     .done(function( msg ){
-    //         // Here we can update.
-    //         loginAccount = '';
-    //         this.accountView.remove();
-    //         this.render();
-    //         this.event.model.classes.map(function(item){
-    //             item.set({ loggedIn: false });
-    //         });
-    //         jQuery('#appLogin').show();
-    //         // Need to reload the page now
-    //         window.location.href = thisPageUrl;
-    //     })
-    //     .fail(function(msg){
-    //         console.log('Fail:');
-    //         console.log( msg );
-    //     });
-    // },
-
-    loginToAccount: function(){
-        this.$userInput = jQuery('.login');
-        this.$pwdInput = jQuery('.password');
-
-        // Send data to login ajax and verify user login
-        jQuery.ajax({
-            context: this,
-            url: appAccountUrl,
-            dataType: 'json',
-            data: 'option=login&username=' + this.$userInput.val().trim() + '&password=' + this.$pwdInput.val().trim()
-        })
-        .done(function(account){
-            if ( account.valid !== false ) {
-                // Create account model and assign to this.loginAccount
-                loginAccount = new app.Models.Front.Account({
-                    id: account.id,
-                    email: account.email,
-                    fname: account.fname,
-                    lname: account.lname
-                });
-                // Destroy the model and remove the view
-                this.loginModel.destroy();
-                this.loginView.remove();
-                this.render();
-                this.event.model.classes.map(function(item){
-                    item.set({ loggedIn: true });
-                });
-            } else {
-                console.log( 'Login failed' );
-                this.loginModel.set({ message: 'Failed login!' });
-            }
-        })
-        .fail(function(msg){
-            console.log('Fail: ' );
-            console.log( msg );
-        });
-    },
-
-    registerNewAccount: function(){
-        this.$email    = this.$('.account_email').val().trim();
-        this.$password = this.$('.account_password').val().trim();
-        this.$fname    = this.$('.account_fname').val().trim();
-        this.$lname    = this.$('.account_lname').val().trim();
-        this.$addr1    = this.$('.account_addr1').val().trim();
-        this.$addr2    = this.$('.account_addr2').val().trim();
-        this.$city     = this.$('.account_city').val().trim();
-        this.$state    = this.$('.account_state').val().trim();
-        this.$zip      = this.$('.account_zip').val().trim();
-        this.$country  = this.$('.account_country').val().trim();
-
-        // Send request to backend
-        jQuery.ajax({
-            context: this,
-            url: appAccountUrl,
-            dataType: 'json',
-            data:{
-                option: 'register',
-                email: this.$email,
-                password: this.$password,
-                fname: this.$fname,
-                lname: this.$lname,
-                addr1: this.$addr1,
-                addr2: this.$addr2,
-                city: this.$city,
-                state: this.$state,
-                zip: this.$zip,
-                country: this.$country,
-            }
-        })
-        .done(function(account){
-            console.log('return from ajax for register new');
-            console.log(account);
-            if ( account.id != undefined && account.id !== '' ) {
-                // Account was created.
-                // Now use this account for login.
-                loginAccount = new app.Models.Front.Account({
-                    id: account.id,
-                    email: account.email,
-                    fname: account.fname,
-                    lname: account.lname
-                });
-                this.registerModel.destroy();
-                this.registerView.remove();
-                this.render();
-            }
-        })
-        .fail(function(msg){
-            console.log('Fail: ' );
-            console.log( msg );
-        });
-    },
-
-    // login: function(){
-    //     this.loginModel = new app.Models.Front.Login();
-    //     this.loginView  = new app.Views.Front.Login({ model: this.loginModel });
-    //     this.$el.append( this.loginView.render().el );
-    //     jQuery('#accountHeader').hide();
-    // },
-
-    // register: function(){
-    //     this.registerModel = new app.Models.Front.Register();
-    //     this.registerView  = new app.Views.Front.Register({ model: this.registerModel });
-    //     this.$el.append( this.registerView.render().el );
-    //     jQuery('#accountHeader').hide();
-    // },
-
 });
diff --git a/js/views/front/login.js b/js/views/front/login.js
deleted file mode 100644 (file)
index 3e748b6..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-// js/views/login.js
-
-// Login View
-app.Views.Front.Login = Backbone.View.extend({
-    tagName: 'div',
-
-    className: 'glm-reg-login',
-
-    template: _.template( jQuery('#eventReg-account-login').html() ),
-
-    events: {
-        'click #loginCancel': 'closeLoginForm',
-        //'keydown': 'keyAction',
-    },
-
-    initialize: function(){
-        this.listenTo( this.model, 'change', this.render );
-        return this;
-    },
-
-    closeLoginForm: function(){
-        this.remove();
-        jQuery('#accountHeader').show();
-        return;
-    },
-
-    render: function(){
-        this.$el.html( this.template( this.model.toJSON() ) );
-        //jQuery('.login').focus();
-        return this;
-    },
-
-    keyAction: function(e){
-        if ( e.which === 13 ) {
-            console.log( 'Enter key used' );
-        }
-    },
-
-});
diff --git a/js/views/front/register.js b/js/views/front/register.js
deleted file mode 100644 (file)
index 7126d98..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-app.Views.Front.Register = Backbone.View.extend({
-    tagName: 'div',
-
-    className: 'glm-reg-register',
-
-    template: _.template( jQuery('#register-new-account').html() ),
-
-    events: {
-        'click #registerCancel': 'closeForm',
-        'focusout .account_email': 'checkEmail',
-        'focusout .account_password': 'checkPassword',
-    },
-
-    initialize: function(){
-        this.listenTo( this.model, 'change', this.render );
-    },
-
-    render: function(){
-        this.$el.html( this.template( this.model.toJSON() ) );
-        return this;
-    },
-
-    closeForm: function(){
-        this.remove();
-        jQuery('#accountHeader').show();
-        return;
-    },
-
-    addErrorMsg: function( error ){
-        var errors = this.model.get( 'errors' );
-        console.log( 'in addErrorMsg' );
-        errors.push( error );
-        console.log( errors );
-    },
-
-    checkEmail: function(){
-        console.log( 'focusout for email' );
-        this.$('.account_email').removeClass('error');
-        this.model.set({ emailError: '' });
-        // if they entered email then test for existing email
-        if ( this.model.get( 'validEmail' ) === true ){
-            return;
-        }
-        var cEmail = this.$('.account_email').val().trim();
-        if ( cEmail === undefined || cEmail === '' ) {
-            return;
-        }
-        console.log( cEmail );
-        jQuery.ajax({
-            context: this,
-            url: ajaxUrl + '&glm_action=account&option=checkEmail',
-            dataType: 'json',
-            data:{
-                email: cEmail,
-            }
-        })
-        .done(function(account){
-            if ( account.validEmail !== true ) {
-                this.$('.account_email').addClass('error');
-                //this.model.errors.push('Must be a valid email address!');
-                //this.addErrorMsg( 'Must be a valid email address!' );
-                //alert('Must be a valid email address!');
-                //jQuery('.account_email').focus();
-                this.model.set({ emailError: 'Must be a valid email address!' });
-            } else if ( account.id !== undefined && account.email !== undefined ) {
-                alert('There is an account already with that email address.\nPlease use another one!');
-                jQuery('.account_email').val('');
-                //jQuery('.account_email').focus();
-            } else {
-                // email is not existing account and valid
-                this.model.set({ validEmail: true });
-                this.$('.account_email').removeClass('error');
-            }
-        })
-        .fail(function(msg){
-            console.log('Fail: ' + msg);
-        });
-    },
-
-    checkPassword: function(){
-        console.log( 'focusout for password' );
-        this.$('.account_password').removeClass('error');
-        // only check if there's something in the field
-        var tPass = this.$('.account_password').val().trim();
-        if ( tPass === '' ) {
-            return;
-        }
-        jQuery.ajax({
-            context: this,
-            url: ajaxUrl + '&glm_action=account&option=checkPassword',
-            dataType: 'json',
-            data: {
-                password: this.$('.account_password').val().trim()
-            }
-        })
-        .done(function(data){
-            console.log( data );
-            if ( data.msg ) {
-                this.$('.account_password').addClass('error');
-                alert( 'Password Error: \n' + data.msg );
-            } else {
-                this.$('.account_password').removeClass('error');
-            }
-        })
-        .fail(function(msg){
-            console.log( 'Fail: ' + msg );
-        });
-    },
-
-});