diff options
| author | mo khan <mo@mokhan.ca> | 2014-07-05 23:10:12 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-07-05 23:10:12 -0600 |
| commit | e8788db6985d944445027dd4a686ff8d49e2c742 (patch) | |
| tree | 3a06945dfc9338b94203ab9d84277aeda2e65cb9 /app/assets/javascripts | |
| parent | 58e49cf1034e220a518425a7a8c8bd9fd77503ae (diff) | |
extract photos controller from the photos router.
Diffstat (limited to 'app/assets/javascripts')
| -rw-r--r-- | app/assets/javascripts/backbone/controllers/photos_controller.js.coffee | 13 | ||||
| -rw-r--r-- | app/assets/javascripts/backbone/routers/photos_router.js.coffee | 19 |
2 files changed, 17 insertions, 15 deletions
diff --git a/app/assets/javascripts/backbone/controllers/photos_controller.js.coffee b/app/assets/javascripts/backbone/controllers/photos_controller.js.coffee new file mode 100644 index 00000000..15e08585 --- /dev/null +++ b/app/assets/javascripts/backbone/controllers/photos_controller.js.coffee @@ -0,0 +1,13 @@ +class CakeSide.Controllers.PhotosController + show: (cake_id, id) -> + @photos = CakeSide.Application.request('PhotosRepository', cake_id) + photo = new CakeSide.Models.Photo({cake_id: cake_id, id: id}) + photo.fetch() + cake = CakeSide.Application.request('CakesRepository').get(cake_id) + @view = new CakeSide.Views.Photos.ShowView(model: photo, collection: @photos) + CakeSide.Application.content_region.show(@view) + CakeSide.Application.request('CommentView').render + identifier: "c-#{cake_id}" + title: cake.get('name') + url: cake.public_url() + diff --git a/app/assets/javascripts/backbone/routers/photos_router.js.coffee b/app/assets/javascripts/backbone/routers/photos_router.js.coffee index 7e7e4004..c2823ba6 100644 --- a/app/assets/javascripts/backbone/routers/photos_router.js.coffee +++ b/app/assets/javascripts/backbone/routers/photos_router.js.coffee @@ -1,15 +1,4 @@ -class CakeSide.Routers.PhotosRouter extends Backbone.Router - routes: - "cakes/:cake_id/photos/:id" : "show" - - show: (cake_id, id) -> - @photos = CakeSide.Application.request('PhotosRepository', cake_id) - photo = new CakeSide.Models.Photo({cake_id: cake_id, id: id}) - photo.fetch() - cake = CakeSide.Application.request('CakesRepository').get(cake_id) - @view = new CakeSide.Views.Photos.ShowView(model: photo, collection: @photos) - CakeSide.Application.content_region.show(@view) - CakeSide.Application.request('CommentView').render - identifier: "c-#{cake_id}" - title: cake.get('name') - url: cake.public_url() +class CakeSide.Routers.PhotosRouter extends Marionette.AppRouter + controller: new CakeSide.Controllers.PhotosController() + appRoutes: + "cakes/:cake_id/photos/:id": "show" |
