From: declerambaul Date: Wed, 2 May 2012 13:10:56 +0000 (-0400) Subject: Adding tab support for main page, splitting charts in core and non-core metrics X-Git-Url: http://git.less.ly:3516/?a=commitdiff_plain;h=ad4b1c6cb0359f9af1f9b49b647ea7f809a5090a;p=kraken-ui.git Adding tab support for main page, splitting charts in core and non-core metrics --- diff --git a/lib/dashboard/dashboard-view.co b/lib/dashboard/dashboard-view.co index 470647b..3705f43 100644 --- a/lib/dashboard/dashboard-view.co +++ b/lib/dashboard/dashboard-view.co @@ -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 diff --git a/lib/template/dashboard.jade b/lib/template/dashboard.jade index 654be23..ff0827f 100644 --- a/lib/template/dashboard.jade +++ b/lib/template/dashboard.jade @@ -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") diff --git a/www/css/dashboard.styl b/www/css/dashboard.styl index e69de29..6f3eaa7 100644 --- a/www/css/dashboard.styl +++ b/www/css/dashboard.styl @@ -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