Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

assorted refactorings

  • Loading branch information...
commit 68967dcf669934792cb92833ece6fd70959c353e 1 parent a424131
Brent Vatne authored
12  app/assets/dynamic/coffeescripts/views/app_view.coffee
@@ -12,8 +12,6 @@ class AppView extends Backbone.View
12 12
     preloadData = options['preloadData']
13 13
 
14 14
     da.app = this
15  
-    @instances   = {}
16  
-    @content     = {}
17 15
     @currentUser = new da.models.CurrentUser(email: preloadData.currentUserEmail)
18 16
 
19 17
     @render()
@@ -27,19 +25,19 @@ class AppView extends Backbone.View
27 25
     @$content = @$el.find(".paper")
28 26
 
29 27
   showDeckIndex: ->
30  
-    @$content.empty()
  28
+    @clearContainers()
31 29
 
32 30
     @content = new da.views.DeckIndexView
33 31
     @$content.append(@content.el)
34 32
 
35 33
   showDeckNew: ->
36  
-    @$content.empty()
  34
+    @clearContainers()
37 35
 
38 36
     @content = new da.views.DeckNewView
39 37
     @$content.append(@content.el)
40 38
 
41 39
   showDeckEdit: (id) ->
42  
-    @$content.empty()
  40
+    @clearContainers()
43 41
 
44 42
     @content = new da.views.DeckEditView(id: id)
45 43
     @$content.append(@content.el)
@@ -53,5 +51,9 @@ class AppView extends Backbone.View
53 51
     path = $(e.currentTarget).attr('href')
54 52
     Backbone.history.navigate(path, true)
55 53
 
  54
+  clearContainers: ->
  55
+    @$content.empty()
  56
+    @instances = {}
  57
+
56 58
 @da = window.da
57 59
 @da.views.AppView = AppView
2  app/assets/dynamic/coffeescripts/views/deck/edit_view.coffee
@@ -22,7 +22,7 @@ class DeckEditView extends Backbone.View
22 22
     if @slides.length == 0
23 23
       @slideView = new da.views.EmptySlideListView
24 24
     else
25  
-      @slideView = new da.views.SlideIconListView(collection: @slides)
  25
+      @slideView = new da.views.SlideListView(collection: @slides)
26 26
 
27 27
     @$el.append(@slideView.el)
28 28
 
5  app/assets/dynamic/coffeescripts/views/deck/icon_view.coffee
@@ -6,10 +6,11 @@ class DeckIconView extends Backbone.View
6 6
   template: _.template($('#deck-icon-template').html())
7 7
 
8 8
   initialize: ->
9  
-    @model.on 'sync', @render, this
  9
+    @deck = @model
  10
+    @deck.on 'sync', @render, this
10 11
 
11 12
   render: ->
12  
-    @$el.html(@template(@model.toJSON()))
  13
+    @$el.html @template(@deck.toJSON())
13 14
 
14 15
 @da = window.da
15 16
 @da.views.DeckIconView = DeckIconView
24  app/assets/dynamic/coffeescripts/views/slide/icon_list_view.coffee
... ...
@@ -1,24 +0,0 @@
1  
-class SlideIconListView extends Backbone.View
2  
-  tagName: 'ul'
3  
-
4  
-  className: 'slide-list'
5  
-
6  
-  initialize: ->
7  
-    da.app.instances.slideIconListView = this
8  
-    da.app.instances.slideIconViews    = []
9  
-
10  
-    @slides = @collection
11  
-    @slides.on 'reset',        @render,       this
12  
-    @slides.on 'change:order', @slides.fetch, @slides
13  
-
14  
-    @render()
15  
-
16  
-  render: ->
17  
-    @$el.empty()
18  
-
19  
-    _.each @slides.models, (slide) =>
20  
-      slide.on 'change:order', @render, this
21  
-      @$el.append (new da.views.SlideIconView(slide: slide)).el
22  
-
23  
-@da = window.da
24  
-@da.views.SlideIconListView = SlideIconListView
2  app/views/single_page.erb
@@ -36,7 +36,7 @@
36 36
 <script src='/javascripts/views/deck/new_view.js'></script>
37 37
 <script src='/javascripts/views/deck/edit_view.js'></script>
38 38
 
39  
-<script src='/javascripts/views/slide/icon_list_view.js'></script>
  39
+<script src='/javascripts/views/slide/list_view.js'></script>
40 40
 <script src='/javascripts/views/slide/icon_view.js'></script>
41 41
 
42 42
 <script src='/javascripts/models/deck.js'></script>

0 notes on commit 68967dc

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