Adding tab support for main page, splitting charts in core and non-core metrics
authordeclerambaul <fabian.kaelin@gmail.com>
Wed, 2 May 2012 13:10:56 +0000 (09:10 -0400)
committerdeclerambaul <fabian.kaelin@gmail.com>
Wed, 2 May 2012 13:10:56 +0000 (09:10 -0400)
lib/dashboard/dashboard-view.co
lib/template/dashboard.jade
www/css/dashboard.styl

index 470647b..3705f43 100644 (file)
@@ -33,6 +33,9 @@ DashboardView = exports.DashboardView = BaseView.extend do # {{{
         active_editors_target
         very_active_editors
     ]>
+
+    core_graph_ids : ["unique_visitors ","pageviews","pageviews_mobile", "new_editors","active_editors", "active_editors_target"]
+
     subviews : []
     graphs   : null
     ready    : false
@@ -46,7 +49,8 @@ DashboardView = exports.DashboardView = BaseView.extend do # {{{
     initialize: ->
         @model or= new Dashboard
         BaseView::initialize ...
-        @graphs.on 'add', @attachGraphs, this
+        # @graphs.on 'add', @attachGraphs, this
+        @graphs.on 'add', @attachGraph, this
         @load()
     
     
@@ -67,6 +71,29 @@ DashboardView = exports.DashboardView = BaseView.extend do # {{{
                 @attachGraphs()
                 @trigger 'ready', this
     
+    attachGraph: (graph) ->            
+        console.log 'Attach graph',graph
+
+        return if graph.view.isAttached       
+
+        # graphs_el = if graph.id in @core_graph_ids then @$el.find '.core-graphs-pane' else @$el.find '.other-graphs-pane'
+
+        graphs_el = @$el.find '.other-graphs-pane'   # @$el.find '.core-graphs-pane' 
+
+        console.log graph.id
+        console.log @core_graph_ids
+        console.log "if graph.id in @core_graph_ids" , (graph.id in @core_graph_ids)
+
+        graphs_el.append graph.view.el 
+        @subviews.push graph.view
+        graph.view.isAttached = true
+        graph.on 'ready', ->
+            graph.off 'ready', arguments.callee
+            graph.view.renderChart()
+
+        this
+
+
     attachGraphs: ->
         graphs_el = @$el.find '#graphs'
         for id of @graph_ids
index 654be23..ff0827f 100644 (file)
@@ -5,3 +5,14 @@ section#graph-list
     
     section#graphs
 
+    .row
+        .graphs.tabbable 
+            nav           
+                ul.nav.subnav.nav-pills
+                    li:         h3 Graphs    
+                    li.active:  a(href="#core-graphs", data-toggle="tab") Core 
+                    li:         a(href="#other-graphs", data-toggle="tab") Others
+                            
+            .tab-content
+                .core-graphs-pane.tab-pane.active(id="core-graphs")
+                .other-graphs-pane.tab-pane(id="other-graphs")
index e69de29..6f3eaa7 100644 (file)
@@ -0,0 +1,20 @@
+/* * * *  Subnav & Tabs  * * * {{{ */
+    
+.graphs.tabbable
+    .nav
+        margin-bottom 0
+        
+        li h3
+            line-height 14px
+            margin 2px
+            padding 8px 12px
+            border-radius 5px
+        li
+            margin-right 4px
+    
+    .tab-pane
+        padding 0.5em
+        margin-top 18px
+        
+
+/* }}} */
\ No newline at end of file