1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/b61927f340f3/ Changeset: b61927f340f3 User: jgoecks Date: 2013-10-08 18:25:10 Summary: Fixes for 82b1789: (a) incorporate default values correctly and (b) use Backbone-style gets to access config values. Affected #: 1 file diff -r 5d5729d40b4f394dc6884d22daa39e3696842b80 -r b61927f340f30a636204ec560522acf9b76fd262 static/scripts/viz/trackster/tracks.js --- a/static/scripts/viz/trackster/tracks.js +++ b/static/scripts/viz/trackster/tracks.js @@ -222,7 +222,7 @@ ], saved_values: obj_dict.prefs, onchange: function() { - this.track.set_name(this.track.config.values.name); + this.track.set_name(this.track.config.get('values').name); } }); this.prefs = this.config.get('values'); @@ -1136,7 +1136,7 @@ }, get_base_color: function(base) { - return this.config.values[ base.toLowerCase() + '_color' ] || this.config.values[ 'n_color' ]; + return this.config.get('values')[ base.toLowerCase() + '_color' ] || this.config.get('values')[ 'n_color' ]; } }); @@ -1893,16 +1893,29 @@ */ var Config = Backbone.Model.extend({ initialize: function(options) { - // values is a simple param_key -- value dictionary shared with drawables. - this.set('values', {}); + // values is a simple param_key-to-value dictionary used to store + // param values. + var values = {}; + + // Set default values. + _.each(options.params, function(p) { + values[p.key] = p.default_value; + }); // Restore saved values. if (options.saved_values) { - this.restore_values(options.saved_values); + _.each( this.get('params'), function(p) { + if (p.key in options.saved_values) { + values[p.key] = options.saved_values[p.key]; + } + }); } + + this.set('values', values); + + // HACK: to make onchange work as written, attach track at the + // top level of model and call onchange on custom event. if (options.onchange) { - // HACK: to make onchange work as written, attach track at the - // top level of model and call onchange on custom event. this.track = options.track; this.on('change:values', options.onchange, this); } @@ -1955,18 +1968,7 @@ else { return false; } - }, - - /** - * Restore config values from a dictionary. - */ - restore_values: function( values ) { - var self = this; - _.each( this.get('params'), function(param) { - self.set_param_value(param.key, values[param.key] || param.default_value); - }); - }, - + } }); var ConfigView = Backbone.View.extend({ @@ -2563,7 +2565,7 @@ track.tile_cache.clear(); in_drag = false; if (!in_handle) { drag_control.hide(); } - track.config.values.height = track.visible_height_px; + track.config.get('values').height = track.visible_height_px; track.changed(); }).appendTo(track.container_div); }, @@ -2575,8 +2577,8 @@ // Set modes, init mode. this.display_modes = new_modes; this.mode = (init_mode ? init_mode : - (this.config && this.config.values['mode'] ? - this.config.values['mode'] : this.display_modes[0]) + (this.config && this.config.get('values')['mode'] ? + this.config.get('values')['mode'] : this.display_modes[0]) ); this.action_icons.mode_icon.attr("title", "Set display mode (now: " + this.mode + ")"); @@ -2926,7 +2928,7 @@ var track = this; // TODO: is it necessary to store the mode in two places (.mode and track_config)? track.mode = new_mode; - track.config.values['mode'] = new_mode; + track.config.get('values')['mode'] = new_mode; // FIXME: find a better way to get Auto data w/o clearing cache; using mode in the // data manager would work if Auto data were checked for compatibility when a specific // mode is chosen. @@ -3955,7 +3957,7 @@ extend(FeatureTrack.prototype, Drawable.prototype, TiledTrack.prototype, { set_painter_from_config: function() { - if ( this.config.values['connector_style'] === 'arcs' ) { + if ( this.config.get('values')['connector_style'] === 'arcs' ) { this.painter = painters.ArcLinkedFeaturePainter; } else { this.painter = painters.LinkedFeaturePainter; Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.