Skip to content
Browse files

DG DC OMG FORMZ

  • Loading branch information...
1 parent 9fbc4b7 commit 3a47590d0610c11de81fd1f7dcbb70f4eb980d12 @denniscollective denniscollective committed Mar 7, 2012
View
2 config/assets.yml
@@ -43,6 +43,7 @@ javascripts:
- public/javascripts/app/helpers/*
- public/javascripts/app/router.js
- public/javascripts/app/views.js
+ - public/javascripts/app/forms.js
- public/javascripts/app/models/post.js
- public/javascripts/app/models/*
- public/javascripts/app/pages/*
@@ -51,6 +52,7 @@ javascripts:
- public/javascripts/app/views/content_view.js
- public/javascripts/app/views/*.js
- public/javascripts/app/views/**/*.js
+ - public/javascripts/app/forms/*.js
- public/javascripts/diaspora.js
- public/javascripts/helpers/*.js
View
1 public/javascripts/app/app.js
@@ -4,6 +4,7 @@ var app = {
helpers: {},
views: {},
pages: {},
+ forms: {},
user: function(userAttrs) {
if(userAttrs) { return this._user = new app.models.User(userAttrs) }
View
18 ...c/javascripts/app/views/post_form_view.js → public/javascripts/app/forms.js
@@ -1,22 +1,8 @@
-app.views.PostForm = app.views.Base.extend({
- templateName : "post-form",
-
+app.forms.Base = app.views.Base.extend({
events :{
'submit form' : 'setModelAttributes'
},
-// subviews : {
-// ".aspect_form" : "aspectDropdown"
-// },
-
- formAttrs : {
- ".text" : "text"
- },
-
-// initialize : function(){
-//// this.aspectsDropdown = new app.views.AspectDropdown()
-// },
-
setModelAttributes : function(evt){
if(evt){ evt.preventDefault(); }
@@ -30,4 +16,4 @@ app.views.PostForm = app.views.Base.extend({
this.model.set(_.inject(this.formAttrs, setValueFromField, {}))
this.model.trigger("setFromForm")
}
-});
+})
View
16 public/javascripts/app/forms/post_form_view.js
@@ -0,0 +1,16 @@
+app.forms.Post = app.forms.Base.extend({
+ templateName : "post-form",
+
+ subviews : {
+ ".aspect_selector" : "aspectsDropdown"
+ },
+
+ formAttrs : {
+ ".text" : "text",
+// ".aspect_ids" : "aspect_ids"
+ },
+
+ initialize : function(){
+ this.aspectsDropdown = new app.views.AspectsDropdown()
+ }
+});
View
2 public/javascripts/app/pages/post-new.js
@@ -5,7 +5,7 @@ app.pages.PostNew = app.views.Base.extend({
initialize : function(){
this.model = new app.models.StatusMessage()
- this.postForm = new app.views.PostForm({model : this.model})
+ this.postForm = new app.forms.Post({model : this.model})
this.model.bind("setFromForm", this.saveModel, this)
},
View
5 public/javascripts/app/views.js
@@ -9,7 +9,10 @@ app.views.Base = Backbone.View.extend({
},
setupRenderEvents : function(){
- this.model.bind('remove', this.remove, this);
+ if(this.model) {
+ //this should be in streamobjects view
+ this.model.bind('remove', this.remove, this);
+ }
// this line is too generic. we usually only want to re-render on
// feedback changes as the post content, author, and time do not change.
View
3 public/javascripts/app/views/aspects_dropdown_view.js
@@ -0,0 +1,3 @@
+app.views.AspectsDropdown = app.views.Base.extend({
+ templateName : "aspects-dropdown"
+})
View
4 spec/javascripts/app/views/post_form_spec.js → spec/javascripts/app/forms/post_form_spec.js
@@ -1,7 +1,7 @@
-describe("app.views.PostForm", function(){
+describe("app.forms.Post", function(){
beforeEach(function(){
this.post = new app.models.Post();
- this.view = new app.views.PostForm({model : this.post})
+ this.view = new app.forms.Post({model : this.post})
})
describe("rendering", function(){
View
2 spec/javascripts/support/jasmine.yml
@@ -46,6 +46,7 @@ src_files:
- public/javascripts/app/helpers/*
- public/javascripts/app/router.js
- public/javascripts/app/views.js
+ - public/javascripts/app/forms.js
- public/javascripts/app/models/post.js
- public/javascripts/app/models/*
- public/javascripts/app/collections/*
@@ -54,6 +55,7 @@ src_files:
- public/javascripts/app/views/*.js
- public/javascripts/app/views/**/*.js
- public/javascripts/app/pages/**/*.js
+ - public/javascripts/app/forms/**/*.js
- public/javascripts/mobile.js
- public/javascripts/contact-list.js

0 comments on commit 3a47590

Please sign in to comment.
Something went wrong with that request. Please try again.