commit/galaxy-central: guerler: Charts: Improve form field handling
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/839806334584/ Changeset: 839806334584 User: guerler Date: 2014-05-24 07:16:14 Summary: Charts: Improve form field handling Affected #: 6 files diff -r 16bf4453c97a108105930e7f5d6cbf39151316fd -r 8398063345841d5c9530d9326661405df30c2125 config/plugins/visualizations/charts/static/charts/nvd3/config.js --- a/config/plugins/visualizations/charts/static/charts/nvd3/config.js +++ b/config/plugins/visualizations/charts/static/charts/nvd3/config.js @@ -26,42 +26,42 @@ { label : '-- Do not show values --', value : 'hide', - hide : 'x_axis_tick' + hide : ['x_axis_tick'] }, { label : 'Auto', value : 'auto', - hide : 'x_axis_tick' + hide : ['x_axis_tick'] }, { label : 'Float', value : 'f', - show : 'x_axis_tick' + show : ['x_axis_tick'] }, { label : 'Exponent', value : 'e', - show : 'x_axis_tick' + show : ['x_axis_tick'] }, { label : 'Integer', value : 'd', - hide : 'x_axis_tick' + hide : ['x_axis_tick'] }, { label : 'Percentage', value : 'p', - show : 'x_axis_tick' + show : ['x_axis_tick'] }, { label : 'Rounded', value : 'r', - show : 'x_axis_tick' + show : ['x_axis_tick'] }, { label : 'SI-prefix', value : 's', - show : 'x_axis_tick' + show : ['x_axis_tick'] } ] }, @@ -118,42 +118,42 @@ { label : '-- Do not show values --', value : 'hide', - hide : 'y_axis_tick' + hide : ['y_axis_tick'] }, { label : 'Auto', value : 'auto', - hide : 'y_axis_tick' + hide : ['y_axis_tick'] }, { label : 'Float', value : 'f', - show : 'y_axis_tick' + show : ['y_axis_tick'] }, { label : 'Exponent', value : 'e', - show : 'y_axis_tick' + show : ['y_axis_tick'] }, { label : 'Integer', value : 'd', - hide : 'y_axis_tick' + hide : ['y_axis_tick'] }, { label : 'Percentage', value : 'p', - show : 'y_axis_tick' + show : ['y_axis_tick'] }, { label : 'Rounded', value : 'r', - show : 'y_axis_tick' + show : ['y_axis_tick'] }, { label : 'SI-prefix', value : 's', - show : 'y_axis_tick' + show : ['y_axis_tick'] } ] }, diff -r 16bf4453c97a108105930e7f5d6cbf39151316fd -r 8398063345841d5c9530d9326661405df30c2125 config/plugins/visualizations/charts/static/library/ui-select.js --- a/config/plugins/visualizations/charts/static/library/ui-select.js +++ b/config/plugins/visualizations/charts/static/library/ui-select.js @@ -37,6 +37,13 @@ self.value(self.$select.val()); }); + // add change event. fires on trigger + this.on('change', function() { + if (self.options.onchange) { + self.options.onchange(self.value()); + } + }); + // refresh this._refresh(); diff -r 16bf4453c97a108105930e7f5d6cbf39151316fd -r 8398063345841d5c9530d9326661405df30c2125 config/plugins/visualizations/charts/static/library/ui-table-form.js --- a/config/plugins/visualizations/charts/static/library/ui-table-form.js +++ b/config/plugins/visualizations/charts/static/library/ui-table-form.js @@ -31,7 +31,7 @@ // update update: function(settings, model) { // reset table - this.table.removeAll(); + this.table.delAll(); // reset list this.list = []; @@ -40,6 +40,11 @@ for (var id in settings) { this._add(id, settings[id], model); } + + // trigger change + for (var id in this.list) { + this.list[id].trigger('change'); + } }, // add table row @@ -56,36 +61,38 @@ // text input field case 'text' : field = new Ui.Input({ - id : id, - placeholder : settings_def.placeholder, - value : model.get(id), - onchange : function(value) { - model.set(id, value); - } - }); + id : 'field_' + id, + placeholder : settings_def.placeholder, + value : model.get(id), + onchange : function(value) { + model.set(id, value); + } + }); break; // select field case 'select' : field = new Ui.Select.View({ - id : id, - data : settings_def.data, - value : model.get(id), - onchange : function(value) { - // set new value - model.set(id, value); - - // find selected dictionary - var dict = _.findWhere(settings_def.data, {value: value}); - if (dict) { - if (dict.show) { - self.$el.find('#' + dict.show).fadeIn('fast'); - } - if (dict.hide) { - self.$el.find('#' + dict.hide).fadeOut('fast'); - } - } + id : 'field_' + id, + data : settings_def.data, + value : model.get(id), + onchange : function(value) { + // set new value + model.set(id, value); + + // find selected dictionary + var dict = _.findWhere(settings_def.data, {value: value}); + if (dict) { + for (var i in dict.show) { + var target = dict.show[i]; + self.table.get(target).show(); } - }); + for (var i in dict.hide) { + var target = dict.hide[i]; + self.table.get(target).hide(); + } + } + } + }); break; // slider input field case 'separator' : diff -r 16bf4453c97a108105930e7f5d6cbf39151316fd -r 8398063345841d5c9530d9326661405df30c2125 config/plugins/visualizations/charts/static/library/ui-table.js --- a/config/plugins/visualizations/charts/static/library/ui-table.js +++ b/config/plugins/visualizations/charts/static/library/ui-table.js @@ -81,8 +81,13 @@ this._commit(id, true); }, - // remove - remove: function(id) { + // get element + get: function(id) { + return this.$el.find('#' + id); + }, + + // delete + del: function(id) { var item = this.$tbody.find('#' + id); if (item.length > 0) { item.remove(); @@ -91,8 +96,8 @@ } }, - // remove - removeAll: function() { + // delete all + delAll: function() { this.$tbody.html(''); this.row_count = 0; this._refresh(); @@ -134,7 +139,7 @@ // commit _commit: function(id, prepend) { // remove previous item with same id - this.remove(id); + this.del(id); // add this.row.attr('id', id); diff -r 16bf4453c97a108105930e7f5d6cbf39151316fd -r 8398063345841d5c9530d9326661405df30c2125 config/plugins/visualizations/charts/static/views/group.js --- a/config/plugins/visualizations/charts/static/views/group.js +++ b/config/plugins/visualizations/charts/static/views/group.js @@ -77,7 +77,7 @@ var chart_settings = this.app.types.get(chart_type); // reset table - this.table.removeAll(); + this.table.delAll(); // load list var list = {}; diff -r 16bf4453c97a108105930e7f5d6cbf39151316fd -r 8398063345841d5c9530d9326661405df30c2125 config/plugins/visualizations/charts/static/views/settings.js --- a/config/plugins/visualizations/charts/static/views/settings.js +++ b/config/plugins/visualizations/charts/static/views/settings.js @@ -40,6 +40,7 @@ if (!chart_type) { return; } + // get settings var chart_definition = this.app.types.get(chart_type); 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.
participants (1)
-
commits-noreply@bitbucket.org