Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to accomodate changing javascript load based on controller ac…
…tion and other stuff
- Loading branch information
Showing
9 changed files
with
96 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,32 @@ | ||
window.App = | ||
start: -> | ||
window.eventCollection = new App.EventsCollection(bootstrapEvents) | ||
new App.Router() | ||
Backbone.history.start | ||
root: "/events" | ||
common: | ||
init: -> | ||
events: | ||
init: -> | ||
index: -> | ||
window.eventCollection = new App.EventsCollection(bootstrapEvents) | ||
new App.EventsRouter() | ||
Backbone.history.start | ||
root: "/events" | ||
show: | ||
console.log("You're in event show") | ||
|
||
UTIL = | ||
exec: ( controller, action )-> | ||
ns = App | ||
action or= "init" | ||
|
||
if ( controller != "" && ns[controller] && typeof ns[controller][action] == "function" ) | ||
ns[controller][action]() | ||
|
||
init: -> | ||
body = document.body | ||
controller = body.getAttribute( "data-controller" ) | ||
action = body.getAttribute( "data-action" ) | ||
|
||
UTIL.exec( "common" ) | ||
UTIL.exec( controller ) | ||
UTIL.exec( controller, action ) | ||
|
||
$(UTIL.init) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
app/assets/javascripts/router.js.coffee → ...ripts/routers/eventsIndexRouter.js.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
16 changes: 8 additions & 8 deletions
16
...javascripts/views/eventEditView.js.coffee → ...vascripts/views/createEventView.js.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<div id="edit_event"> | ||
<form accept-charset="UTF-8" action="/events" class="new_event" id="new_event" method="post"> | ||
<label for="event_name">Name</label> | ||
<input id="event_name" name="event[name]" size="30" type="text" > | ||
<label for="event_description">Description</label> | ||
<input id="event_description" name="event[description]" size="30" type="text"> | ||
<input name="commit" type="submit" value="Create Event"> | ||
</form> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
describe("CreateEventView", function() { | ||
beforeEach(function() { | ||
loadFixtures("eventForm.html"); | ||
this.view = new App.CreateEventView(); | ||
this.form = $(this.view.el).find("form")[0]; | ||
}); | ||
it("should provide a form", function() { | ||
expect($(this.view.el).find("form").length).toEqual(1); | ||
}); | ||
|
||
describe("creating an event", function() { | ||
beforeEach(function() { | ||
window.eventCollection = new Backbone.Collection(); | ||
this.createStub = sinon.stub(window.eventCollection, "create"); | ||
$(this.form).find("#event_name").val("Test Event"); | ||
$(this.form).find("#event_description").val("Test Event Description"); | ||
this.view.createEvent(); | ||
}); | ||
|
||
it("should call create on the EventCollection", function() { | ||
expect(this.createStub).toHaveBeenCalled(); | ||
}); | ||
|
||
}); | ||
describe("parsing form attributes", function() { | ||
it("should have the correct attribute values", function() { | ||
$(this.form).find("#event_name").val("Test Event"); | ||
$(this.form).find("#event_description").val("Test Event Description"); | ||
var attributes = this.view.parseFormAttributes().event; | ||
expect(attributes.name).toEqual("Test Event"); | ||
expect(attributes.description).toEqual("Test Event Description"); | ||
}); | ||
}); | ||
}); |