validated: false,
},
+ // url used for ajax request
url: ajaxUrl+'&glm_action=regFront&collection=account',
initialize: function(){
});
},
+ // validate method for the model
validate: function( attribs, options ){
if ( attribs.email === undefined || attribs.email === '' ) {
return 'Need an email address!';
this.classes = new app.Collections.Front.RegClasses();
},
+ // setClasses
+ // To setup the classes collection
setClasses: function( regClasses ){
this.classes.reset( regClasses );
},
+ // setClassRegistrants
+ // To setup the registrant
+ // Has to create a regTime first for the class
+ // Then is can add the registrant into that regTime model.
setClassRegistrants: function( registrants ){
for ( var i = 0; i < registrants.length; i++ ) {
// console.log(registrants[i]);
country: '',
},
+ // url used for ajax request
url: ajaxUrl+'&glm_action=regFront&collection=registrant',
+ // Validate method for the model
validate: function( attribs, options ){
if ( attribs.fname === undefined || attribs.fname === '' ) {
return 'First Name Required';
last_update: '',
},
+ // url used for ajax request
url: ajaxUrl+'&glm_action=regFront&collection=request',
});
app.Collections.Front.Accounts = Backbone.Collection.extend({
model: app.Models.Front.Account,
+ // url used for all ajax request
url: ajaxUrl+'&glm_action=regFront&collection=accounts',
});
// Registration Rate Collection
app.Collections.Front.RegRates = Backbone.Collection.extend({
model: app.Models.Front.RegRate,
-
- // localStorage
});
app.Collections.Front.RegRequestRegistrants = Backbone.Collection.extend({
model: app.Models.Front.RegRequestRegistrant,
+
+ // url used for all ajax request
url: ajaxUrl+'&glm_action=regFront&collection=registrant=',
+
+ // comparator used for keeping the collection sorted.
comparator: function(reg1, reg2){
if ( reg1.get('lname') < reg2.get('lname') ) {
return -1;
// reg time collection
app.Collections.Front.RegTimes = Backbone.Collection.extend({
model: app.Models.Front.RegTime,
+
+ // url is used for all ajax calls for models in this collection
url: ajaxUrl+'&glm_action=regFront&collection=regTime=',
+
+ // comparator is used to keep the collection ordered
comparator: function(regTime1, regTime2){
var time1 = regTime1.get('start_datetime');
var time2 = regTime2.get('start_datetime');
template: _.template( jQuery('#account-template').html() ),
+ // used to bind events for the view
events: {
},
+ // setup the view
initialize: function(){
this.listenTo( this.model, 'change', this.render );
return this;
},
+ // render the view
render: function(){
this.$el.html( this.template( this.model.toJSON() ) );
return this;
el: '#regApp',
+ // initialize
+ // used for init settings
initialize: function(){
this.cart = cart;
this.event = new app.Views.Front.RegEvent({ model: regEvent });
this.render();
},
+ // render
+ // Used to render the view
render: function(){
// Check to see if there's a login
// if ( loginAccount ) {
return this;
},
+ // events
+ // used to bind events for the view
events: {
'click #glm-reg-cart-continue': 'continue',
},
+ // continue
+ // used to goto the next page (cart)
continue: function(){
window.location.href = nextPageUrl;
},
template: _.template( jQuery('#regClass-template').html() ),
+ // used for initializing the view
initialize: function(){
- this.listenTo( this.model.registrants, 'add', this.addOne );
- this.listenTo( this.model.registrants, 'create', this.addOne );
- this.listenTo( this.model.registrants, 'remove', this.deleteOne );
this.listenTo( this.model, 'change', this.render );
this.listenTo( this.model.regTimes, 'add', this.render );
return this;
},
+ // used for binding events to the view
events: {
'click .addRegistrant': 'newEntry',
'click .fc-event-container': 'updateTimeSelection',
'click .show-hide-address': 'toggleClass',
},
+ // togle the ereg-addr class for the registrant form
toggleClass: function(){
this.$('.ereg-addr').toggle();
},
+ // used to add the regTime view/model to the class
updateTimeSelection: function(e){
var timeId = this.$('.timeSelection').val().trim();
// Check to see if the time is already in the collection
}
},
+ // used to render the regClass view
render: function(){
// this.model.set({ reg_count: this.model.registrants.length });
this.$el.html( this.template( this.model.toJSON() ) );
return this;
},
+ // return the times object as an array
getTimeArray: function(){
var times = this.model.get( 'times' );
var timeParts = [];
return timeParts;
},
+ // called durring render to check for this.el in document
+ // then it can setup the fullCaldendar
onRenderComplete: function() {
if (!$.contains(document.documentElement, this.el)) {
var that = this;
}
},
+ // called to setup the fullCalendar per class
setCalendar: function(){
var times = this.model.get( 'times' );
var startTime = this.model.get('startingTime');
});
},
- deleteOne: function( item ){
- this.render();
- },
-
+ // used to add login account to the class
addAccount: function(){
// Check to make sure the loginAccount is not empty
if ( loginAccount !== '' ) {
}
},
- addNew: function(){
- var findByEmail = [];
- var fname = this.$('.add_reg_fname').val().trim();
- var lname = this.$('.add_reg_lname').val().trim();
- var email = this.$('.add_reg_email').val().trim();
- var addr1 = this.$('.add_reg_addr1').val().trim();
- var addr2 = this.$('.add_reg_addr2').val().trim();
- var city = this.$('.add_reg_city').val().trim();
- var state = this.$('.add_reg_state').val().trim();
- var zip = this.$('.add_reg_zip').val().trim();
- var country = this.$('.add_reg_country').val().trim();
- var sTime = this.model.get( 'selectedTime' );
- if ( this.$('#add_reg-select-time').length ) {
- var times = this.model.get( 'times' );
- var rateId = null;
- // Setup the needed reg_rate
- _.each( times, function( time ){
- if ( time.id == sTime ) {
- rateId = time.rate_id;
- }
- } );
- } else {
- var times = this.model.get( 'times' );
- var rateId = null;
- _.each( times, function( time ){
- rateId = time.rate_id;
- } );
- }
- if ( app.timeSpecific && !sTime ) {
- alert( 'You must select a time!' );
- return;
- }
- if ( fname === '' || lname === '' ) {
- alert( 'First and Last name required!' );
- return;
- }
- if ( email === '' ) {
- var confAnsw = confirm( 'You have no email address! Are you sure you want to add this registrant?' );
- if ( !confAnsw ) {
- return;
- }
- } else {
- findByEmail = this.model.registrants.where({email: email});
- }
- var regRequest = cart.get( 'request' );
- if ( findByEmail.length === 0 ) {
- this.model.registrants.create({
- option: 'add',
- reg_request: regRequest.id,
- reg_time: sTime,
- reg_event: this.model.get( 'reg_event' ),
- reg_class: this.model.get( 'id' ),
- event_name: regEvent.get( 'event_name' ),
- reg_rate: rateId,
- email: email,
- fname: fname,
- lname: lname,
- addr1: addr1,
- addr2: addr2,
- city: city,
- state: state,
- zip: zip,
- country: country,
- });
- }
- // this.newRegAccount.destroy();
- this.newRegAccountView.remove();
- // app.calendar = false;
- },
-
+ // cancel add new
cancelAddNew: function(){
this.$('.glm-add-new-account').show();
this.newRegAccountView.remove();
},
+ // add new account
addNewAccount: function(){
this.$('.glm-add-new-account').hide();
// Create the new Registrant View
this.$el.append( this.newRegAccountView.render().el );
},
- toggleClassOpen: function(){
- this.$('.reg-class-detail').show();
- this.$('.toggle-class-open').hide();
- this.$('.toggle-class-close').show();
- },
-
- toggleClassClose: function(){
- this.$('.reg-class-detail').hide();
- this.$('.toggle-class-close').hide();
- this.$('.toggle-class-open').show();
- },
-
// For the new entry check the email from the server and see
// if there's already an account setup.
newEntry: function(){
});
},
- addOne: function( item ){
- this.model.set({selectedTime: item.get('reg_time') })
- this.render();
- },
-
- addAll: function(){
- jQuery('.glm-reg-level').html('');
- },
-
});
// js/views/regEvent.js
this.listenTo( this.model, 'change', this.render );
},
+ // render the view
render: function(){
this.$el.html( this.template( this.model.toJSON() ) );
var view = regEvent.classes.map(function(item){
return this;
},
+ // setup the count of classes
getClassCount: function(){
return this.model.classes.length;
},
template: _.template( jQuery('#registrant-template').html() ),
+ // used to setup initial class
initialize: function(){
this.listenTo( this.model, 'change', this.render );
return this;
},
+ // used for binding events to the view
events: {
'click .glm-reg-level-registrant-delete': 'deleteOne',
'click .glm-registrant-edit': 'editRegistrant',
'click .update-registrant': 'update',
},
+ // update the model
update: function(){
var modelId = this.model.get( 'id' );
var fname = this.$('.reg_fname').val().trim();
this.$('.reg-edit-form').hide();
},
- setCalendar: function(){
- var modelId = this.model.get( 'id' );
- // Find the class for this registrant
- // Use findWhere to get the correct regClass
- var regLevel = regEvent.classes.findWhere({ id: this.model.get( 'reg_class' ) });
- var times = regLevel.get( 'times' );
- $( '#eventCalendar-' + modelId ).fullCalendar({
- events: function(start, end, timezone, callback) {
- var events = [];
- _.each( times, function( time ){
- events.push({
- title: time.name,
- start: time.start_datetime.datetime,
- end: time.end_datetime.datetime,
- allday: time.all_day.value,
- reg_time: time.id,
- });
- });
- callback( events );
- },
- defaultDate: startTime,
- timeFormat: 'h:mma',
- fixedWeekCount: false,
- eventClick: function( calEvent, jsEvent, view ){
- $('.fc-event').css( 'background-color', '#3a67ad' );
- $(this).css( 'background-color', 'red' );
- jQuery( '#reg-time-' + modelId ).val( calEvent.reg_time );
- jQuery( '#reg-time-display-' + modelId ).html( calEvent.start.format( 'L LT' ) );
- },
- });
- },
+ // cancel the edit of model
cancelEdit: function(){
this.$('.reg-edit-form').hide();
},
+ // show the edit form
editRegistrant: function(){
this.$('.reg-edit-form').show();
- if ( app.timeSpecific === true ) {
- this.$('#reg-select-time').val( this.model.get( 'reg_time' ) );
- this.setCalendar();
- }
},
+ // render the view
render: function(){
this.$el.html( this.template( this.model.toJSON() ) );
this.$emailInput = this.$('.editEmail');
return this;
},
+ // delete the model/view
deleteOne: function(){
// Remove model here
var modelId = this.model.get('id');
template: _.template( jQuery('#regTime-template').html() ),
+ // initialize the view
initialize: function(){
this.listenTo( this.model.registrants, 'add', this.addOne );
this.listenTo( this.model.registrants, 'create', this.addOne );
return this;
},
+ // bind event to the view
events: {
'click .glm-add-new-account': 'addNewAccount',
'click .add-new-registrant': 'insertNew',
'click .add-new-registrant-cancel': 'cancelAddNew',
},
+ // render the view
render: function(){
this.model.set({ reg_count: this.model.registrants.length });
this.$el.html( this.template( this.model.toJSON() ) );
return this;
},
+ // add new account
addNewAccount: function(){
this.$('.glm-add-new-account').hide();
// Create the new Registrant View
this.$el.append( this.newRegAccountView.render().el );
},
+ // insert new registrant
insertNew: function(){
var findByEmail = [];
var fname = this.$('.add_reg_fname').val().trim();
// app.calendar = false;
},
+ // cancel add new registrant
cancelAddNew: function(){
this.$('.glm-add-new-account').show();
// this.newRegAccount.destroy();
this.newRegAccountView.remove();
},
+ // add a registrant to collection
addOne: function( item ){
this.model.set({selectedTime: item.get('reg_time') })
this.render();
},
+ // delete a registrant in collection
deleteOne: function( item ){
this.render();
},
template: _.template( jQuery('#eventReg-registrant-add').html() ),
+ // bind events to the view
events: {
'focusout .add_reg_email': 'verifyEmail'
},
+ // setup the view
initialize: function(){
return this;
},
+ // render the view
render: function(){
this.$el.html( this.template( this.model.toJSON() ) );
return this;
},
+ // verify the email address
verifyEmail: function(){
var email = this.$('.add_reg_email').val().trim();
if ( email == '' ) {
}
},
+ // lock the form
lockForm: function(){
this.$('.add_reg_fname').prop('disabled', true);
this.$('.add_reg_lname').prop('disabled', true);
this.$('.add_reg_country').prop('disabled', true);
},
+ // unlock the form
unLockForm: function(){
this.$('.add_reg_fname').prop('disabled', false);
this.$('.add_reg_lname').prop('disabled', false);
template: _.template( jQuery('#regClass-template').html() ),
+ // used for initializing the view
initialize: function(){
- this.listenTo( this.model.registrants, 'add', this.addOne );
- this.listenTo( this.model.registrants, 'create', this.addOne );
- this.listenTo( this.model.registrants, 'remove', this.deleteOne );
this.listenTo( this.model, 'change', this.render );
this.listenTo( this.model.regTimes, 'add', this.render );
return this;
},
+ // used for binding events to the view
events: {
'click .addRegistrant': 'newEntry',
'click .fc-event-container': 'updateTimeSelection',
'click .show-hide-address': 'toggleClass',
},
+ // togle the ereg-addr class for the registrant form
toggleClass: function(){
this.$('.ereg-addr').toggle();
},
+ // used to add the regTime view/model to the class
updateTimeSelection: function(e){
var timeId = this.$('.timeSelection').val().trim();
// Check to see if the time is already in the collection
}
},
+ // used to render the regClass view
render: function(){
// this.model.set({ reg_count: this.model.registrants.length });
this.$el.html( this.template( this.model.toJSON() ) );
return this;
},
+ // return the times object as an array
getTimeArray: function(){
var times = this.model.get( 'times' );
var timeParts = [];
return timeParts;
},
+ // called durring render to check for this.el in document
+ // then it can setup the fullCaldendar
onRenderComplete: function() {
if (!$.contains(document.documentElement, this.el)) {
var that = this;
}
},
+ // called to setup the fullCalendar per class
setCalendar: function(){
var times = this.model.get( 'times' );
var startTime = this.model.get('startingTime');
});
},
- deleteOne: function( item ){
- this.render();
- },
-
+ // used to add login account to the class
addAccount: function(){
// Check to make sure the loginAccount is not empty
if ( loginAccount !== '' ) {
}
},
- addNew: function(){
- var findByEmail = [];
- var fname = this.$('.add_reg_fname').val().trim();
- var lname = this.$('.add_reg_lname').val().trim();
- var email = this.$('.add_reg_email').val().trim();
- var addr1 = this.$('.add_reg_addr1').val().trim();
- var addr2 = this.$('.add_reg_addr2').val().trim();
- var city = this.$('.add_reg_city').val().trim();
- var state = this.$('.add_reg_state').val().trim();
- var zip = this.$('.add_reg_zip').val().trim();
- var country = this.$('.add_reg_country').val().trim();
- var sTime = this.model.get( 'selectedTime' );
- if ( this.$('#add_reg-select-time').length ) {
- var times = this.model.get( 'times' );
- var rateId = null;
- // Setup the needed reg_rate
- _.each( times, function( time ){
- if ( time.id == sTime ) {
- rateId = time.rate_id;
- }
- } );
- } else {
- var times = this.model.get( 'times' );
- var rateId = null;
- _.each( times, function( time ){
- rateId = time.rate_id;
- } );
- }
- if ( app.timeSpecific && !sTime ) {
- alert( 'You must select a time!' );
- return;
- }
- if ( fname === '' || lname === '' ) {
- alert( 'First and Last name required!' );
- return;
- }
- if ( email === '' ) {
- var confAnsw = confirm( 'You have no email address! Are you sure you want to add this registrant?' );
- if ( !confAnsw ) {
- return;
- }
- } else {
- findByEmail = this.model.registrants.where({email: email});
- }
- var regRequest = cart.get( 'request' );
- if ( findByEmail.length === 0 ) {
- this.model.registrants.create({
- option: 'add',
- reg_request: regRequest.id,
- reg_time: sTime,
- reg_event: this.model.get( 'reg_event' ),
- reg_class: this.model.get( 'id' ),
- event_name: regEvent.get( 'event_name' ),
- reg_rate: rateId,
- email: email,
- fname: fname,
- lname: lname,
- addr1: addr1,
- addr2: addr2,
- city: city,
- state: state,
- zip: zip,
- country: country,
- });
- }
- // this.newRegAccount.destroy();
- this.newRegAccountView.remove();
- // app.calendar = false;
- },
-
+ // cancel add new
cancelAddNew: function(){
this.$('.glm-add-new-account').show();
this.newRegAccountView.remove();
},
+ // add new account
addNewAccount: function(){
this.$('.glm-add-new-account').hide();
// Create the new Registrant View
this.$el.append( this.newRegAccountView.render().el );
},
- toggleClassOpen: function(){
- this.$('.reg-class-detail').show();
- this.$('.toggle-class-open').hide();
- this.$('.toggle-class-close').show();
- },
-
- toggleClassClose: function(){
- this.$('.reg-class-detail').hide();
- this.$('.toggle-class-close').hide();
- this.$('.toggle-class-open').show();
- },
-
// For the new entry check the email from the server and see
// if there's already an account setup.
newEntry: function(){
});
},
- addOne: function( item ){
- this.model.set({selectedTime: item.get('reg_time') })
- this.render();
- },
-
- addAll: function(){
- jQuery('.glm-reg-level').html('');
- },
-
});