From: Steve Sutton Date: Wed, 23 Aug 2017 20:11:30 +0000 (-0400) Subject: Rename main app view file. X-Git-Tag: v1.0.0^2~448 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=2dd7f615dbfb3db80faeb01a2074296d45aa4168;p=WP-Plugins%2Fglm-member-db-registrations.git Rename main app view file. Seemed redundant to have view in the file name when it is in the folder nave as well. renaming to app.js --- diff --git a/js/views/app.js b/js/views/app.js new file mode 100644 index 0000000..d48e687 --- /dev/null +++ b/js/views/app.js @@ -0,0 +1,67 @@ +// js/views/app.js +var app = app || {}; + +// Event Registrant List View +app.AppView = Backbone.View.extend({ + + el: '.glm-reg-level', + + initialize: function(){ + this.$newName = this.$('.addName'); + this.$newEmail = this.$('.addEmail'); + + this.listenTo( app.EventRegistrants, 'add', this.addOne ); + this.listenTo( app.EventRegistrants, 'reset', this.addAll ); + app.EventRegistrants.fetch(); + //this.collection.bind('add', this.onModelAdded, this); + //this.render(); + }, + + deleteOne: function( el ){ + console.log( el ); + console.log( 'deleteOne called on listView' ); + //app.EventRegistrants.fetch(); + }, + + events: { + 'click .addRegistrant': 'newEntry', + }, + + newEntry: function(){ + if ( !this.$newName.val().trim() || !this.$newEmail.val().trim() ) { + return; + } + var emailMatches = app.EventRegistrants.where({email: this.$newEmail.val().trim()}); + app.EventRegistrants.create( this.newAttributes() ); + this.$newName.val(''); + this.$newEmail.val(''); + }, + + newAttributes: function(){ + return { + name: this.$newName.val().trim(), + email: this.$newEmail.val().trim() + }; + }, + + addOne: function(item){ + if ( item.isValid() ) { + var view = new app.EventRegistrantView({ model: item }); + this.$el.append( view.render().el ); + } + }, + + addAll: function(){ + this.$('.glm-reg-level').html(''); + app.EventRegistrants.each(this.addOne, this); + }, + + render: function(){ + var eventRegistrantView = this.collection.map(function(item){ + return (new app.EventRegistrantView({ model: item })).render().el; + }); + this.$el.append(eventRegistrantView); + return this; + }, + +}); diff --git a/js/views/appView.js b/js/views/appView.js deleted file mode 100644 index 4c7aa7f..0000000 --- a/js/views/appView.js +++ /dev/null @@ -1,67 +0,0 @@ -// js/views/appView.js -var app = app || {}; - -// Event Registrant List View -app.AppView = Backbone.View.extend({ - - el: '.glm-reg-level', - - initialize: function(){ - this.$newName = this.$('.addName'); - this.$newEmail = this.$('.addEmail'); - - this.listenTo( app.EventRegistrants, 'add', this.addOne ); - this.listenTo( app.EventRegistrants, 'reset', this.addAll ); - app.EventRegistrants.fetch(); - //this.collection.bind('add', this.onModelAdded, this); - //this.render(); - }, - - deleteOne: function( el ){ - console.log( el ); - console.log( 'deleteOne called on listView' ); - //app.EventRegistrants.fetch(); - }, - - events: { - 'click .addRegistrant': 'newEntry', - }, - - newEntry: function(){ - if ( !this.$newName.val().trim() || !this.$newEmail.val().trim() ) { - return; - } - var emailMatches = app.EventRegistrants.where({email: this.$newEmail.val().trim()}); - app.EventRegistrants.create( this.newAttributes() ); - this.$newName.val(''); - this.$newEmail.val(''); - }, - - newAttributes: function(){ - return { - name: this.$newName.val().trim(), - email: this.$newEmail.val().trim() - }; - }, - - addOne: function(item){ - if ( item.isValid() ) { - var view = new app.EventRegistrantView({ model: item }); - this.$el.append( view.render().el ); - } - }, - - addAll: function(){ - this.$('.glm-reg-level').html(''); - app.EventRegistrants.each(this.addOne, this); - }, - - render: function(){ - var eventRegistrantView = this.collection.map(function(item){ - return (new app.EventRegistrantView({ model: item })).render().el; - }); - this.$el.append(eventRegistrantView); - return this; - }, - -}); diff --git a/models/front/registrations/registration.php b/models/front/registrations/registration.php index d91acc9..daeaaca 100644 --- a/models/front/registrations/registration.php +++ b/models/front/registrations/registration.php @@ -40,7 +40,7 @@ $scripts = array( 'backbone-local' => 'js/lib/backbone.localStorage.min.js', 'registrantView' => 'js/views/eventRegistrant.js', - 'appView' => 'js/views/appView.js', + 'appView' => 'js/views/app.js', 'registrantModel' => 'js/models/eventRegistrant.js', 'registrantList' => 'js/collections/eventRegistrantList.js', 'mybackboneapp' => 'js/eventRegApp.js',