From: declerambaul Date: Fri, 11 May 2012 19:27:53 +0000 (-0400) Subject: Rudimentary tab support. Tabs are hardcoded in dashboard-view.co. Issue: when changin... X-Git-Url: http://git.less.ly:3516/?a=commitdiff_plain;h=f748a240c3467c3f143e42a73a7680f28d43ff9d;p=kraken-ui.git Rudimentary tab support. Tabs are hardcoded in dashboard-view.co. Issue: when changing tabs, the charts have to be rerendered - for a brief moment a distored chart is visible before rendering is complete. --- diff --git a/lib/dashboard/dashboard-view.co b/lib/dashboard/dashboard-view.co index 4085ad2..71e820d 100644 --- a/lib/dashboard/dashboard-view.co +++ b/lib/dashboard/dashboard-view.co @@ -35,15 +35,41 @@ DashboardView = exports.DashboardView = BaseView.extend do # {{{ very_active_editors ]> - # mobile_devices - # mobile_devices_browsers - # mobile_devices_applications + core_tab : + graph_ids : <[ + unique_visitors + pageviews + pageviews_mobile + pageviews_mobile_target + new_editors + active_editors + active_editors_target + ]> + name: ".core-graphs-pane" - core_graph_ids : ["unique_visitors ","pageviews","pageviews_mobile", "new_editors","active_editors", "active_editors_target"] + other_tab : + graph_ids : <[ + reach + commons + articles + articles_per_day + edits + very_active_editors + ]> + name: ".other-graphs-pane" + dev_tab : + graph_ids : <[ + mobile_devices + mobile_devices_browsers + mobile_devices_applications + ]> + name: ".dev-graphs-pane" + events: - # Select the whole permalink URI text when it receives focus. - 'click .core_graphs a' : 'redraw' + # Select the whole permalink URI text when it receives focus. + # 'click a[data-target="#other-graphs"]' : 'tab_shown' + 'shown a' : 'tab_shown' # 'click .load-button' : 'load' subviews : [] @@ -60,66 +86,34 @@ DashboardView = exports.DashboardView = BaseView.extend do # {{{ @model or= new Dashboard BaseView::initialize ... # @graphs.on 'add', @attachGraphs, this - @graphs.on 'add', @attachGraph, this + # @graphs.on 'add', @attachGraph, this @load() - - load: -> - self = this - Seq(@graph_ids) - .parMap_ (next_phase, id) -> - Seq() - .seq Graph.lookup, id, Seq - .seq (graph) -> - view = new GraphDisplayView {model:graph} - view.on 'ready', @ok - self.graphs.add graph - .seq next_phase.ok - .seq_ (next) ~> - console.log "#this.ready!" - @ready = true - @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() - - - @graph ... render - this - - redraw: -> - console.log 'redraw!', arguments + load: -> + @addTab(@core_tab) + @addTab(@other_tab) + @addTab(@dev_tab) + + addTab: (tab) -> + self = this + Seq(tab.graph_ids) + .parMap (id) -> + Graph.lookup id, this + .parMap (graph) -> + self.graphs.add graph + this null, new GraphDisplayView {model:graph} + .parMap (view) -> + return if view.isAttached + graphs_el = self.$el.find tab.name + graphs_el.append view.el + self.subviews.push view + view.isAttached = true + + tab_shown: (e) -> + # console.log 'tab_shown!', e + Seq(@subviews) + .parMap (view) -> + view.renderChart() - attachGraphs: -> - graphs_el = @$el.find '#graphs' - for id of @graph_ids - break unless graph = @graphs.get id - continue if graph.view.isAttached - 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 - -# }}} diff --git a/lib/template/dashboard.jade b/lib/template/dashboard.jade index 4086126..b4edcca 100644 --- a/lib/template/dashboard.jade +++ b/lib/template/dashboard.jade @@ -3,16 +3,20 @@ section#graph-list h1 Wikimedia Report Card small March 2012 - 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 + li.active: a(data-target="#core-graphs",data-toggle="tab") Core + li: a(data-target="#other-graphs",data-toggle="tab") Others + if ENV == 'dev' + li: a(data-target="#dev-graphs",data-toggle="tab") Dev .tab-content .core-graphs-pane.tab-pane.active(id="core-graphs") .other-graphs-pane.tab-pane(id="other-graphs") + if ENV == 'dev' + .dev-graphs-pane.tab-pane(id="dev-graphs") + +