Permalink
Browse files

Centralizes definition of view "theme" (colors, palettes)

  • Loading branch information...
1 parent 215eb53 commit e7ff61bdf91ce394826987473344b35350a1f6ce @sagemintblue sagemintblue committed Apr 3, 2013
@@ -17,8 +17,8 @@ limitations under the License.
/**
* Ambrose module "chord" provides a chord diagram of the job graph.
*/
-define(['jquery', 'd3', 'colorbrewer', '../core', './core'], function(
- $, d3, colorbrewer, Ambrose, View
+define(['jquery', 'd3', '../core', './core'], function(
+ $, d3, Ambrose, View
) {
// Chord ctor
var Chord = View.Chord = function(workflow, container, params) {
@@ -43,16 +43,6 @@ define(['jquery', 'd3', 'colorbrewer', '../core', './core'], function(
// define default params and override with user supplied params
var params = this.params = $.extend(true, {
- colors: {
- running: d3.rgb(98, 196, 98),
- selected: d3.rgb(98, 98, 196),
- mouseover: d3.rgb(98, 98, 196).brighter(),
- },
- palettes: {
- queued: colorbrewer.Greys,
- complete: colorbrewer.Greens,
- failed: colorbrewer.Reds,
- },
dimensions: {
padding: 20,
radius: {
@@ -64,7 +54,7 @@ define(['jquery', 'd3', 'colorbrewer', '../core', './core'], function(
labelMargin: 10,
labelSize: 12,
},
- }, params);
+ }, View.Theme, params);
// initialize dimensions
var dim = this.dimensions = {};
@@ -17,6 +17,23 @@ limitations under the License.
/**
* This module defines the Ambrose.View namespace in which other view modules are registered.
*/
-define(['../core'], function(Ambrose) {
- return Ambrose.View = {};
+define(['jquery', '../core', 'd3', 'colorbrewer'], function(
+ $, Ambrose, d3, colorbrewer
+) {
+ return Ambrose.View = {
+ Theme: {
+ colors: {
+ running: d3.rgb(98, 196, 98).brighter(),
+ complete: d3.rgb(98, 196, 98),
+ failed: d3.rgb(196, 98, 98),
+ mouseover: d3.rgb(98, 98, 196).brighter().brighter(),
+ selected: d3.rgb(98, 98, 196).brighter(),
+ },
+ palettes: {
+ queued: colorbrewer.Greys,
+ complete: colorbrewer.Greens,
+ failed: colorbrewer.Reds,
+ },
+ }
+ };
})
@@ -17,8 +17,8 @@ limitations under the License.
/**
* This module defines the Graph view which generates horizontal DAG view of Workflow jobs.
*/
-define(['jquery', 'd3', 'colorbrewer', '../core', './core'], function(
- $, d3, colorbrewer, Ambrose, View
+define(['jquery', 'd3', '../core', './core'], function(
+ $, d3, Ambrose, View
) {
// utility functions
function isPseudo(node) { return node.pseudo; }
@@ -47,22 +47,10 @@ define(['jquery', 'd3', 'colorbrewer', '../core', './core'], function(
// define default params and override with user supplied params
var params = this.params = $.extend(true, {
- colors: {
- running: d3.rgb(98, 196, 98).brighter(),
- complete: d3.rgb(98, 196, 98),
- failed: d3.rgb(196, 98, 98),
- mouseover: d3.rgb(98, 98, 196).brighter(),
- selected: d3.rgb(98, 98, 196),
- },
- palettes: {
- queued: colorbrewer.Greys,
- complete: colorbrewer.Greens,
- failed: colorbrewer.Reds,
- },
dimensions: {
padding: 20,
},
- }, params);
+ }, View.Theme, params);
this.resetView();
@@ -38,15 +38,7 @@ define(['jquery', 'd3', '../core', './core'], function($, d3, Ambrose, View) {
this.workflow = workflow;
this.container = $(container);
this.initTable();
- this.params = $.extend(true, {
- colors: {
- running: d3.rgb(98, 196, 98).brighter(),
- complete: d3.rgb(98, 196, 98),
- failed: d3.rgb(196, 98, 98),
- mouseover: d3.rgb(98, 98, 196).brighter(),
- selected: d3.rgb(98, 98, 196),
- },
- }, params);
+ this.params = $.extend(true, {}, View.Theme, params);
var self = this;
workflow.on('jobsLoaded', function(event, jobs) {
self.loadTable(jobs);

0 comments on commit e7ff61b

Please sign in to comment.