1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/a2f88681c8d9/ Changeset: a2f88681c8d9 User: guerler Date: 2014-03-08 05:53:16 Summary: Charts: Modularize option form fields Affected #: 2 files diff -r 7efdd4019ed122743ca920d2d30811737277d6a8 -r a2f88681c8d9a3bf8d5f124be7ddf365c2e33eab config/plugins/visualizations/charts/static/library/ui-table-form.js --- /dev/null +++ b/config/plugins/visualizations/charts/static/library/ui-table-form.js @@ -0,0 +1,87 @@ +// dependencies +define(['plugin/library/table', 'plugin/library/ui', 'utils/utils'], + function(Table, Ui, Utils) { + +// widget +var View = Backbone.View.extend( +{ + // initialize + initialize: function(options) { + // ui elements + this.table = new Table({content: options.content}); + + // create element + var $view = $('<div/>'); + $view.append(Utils.wrap((new Ui.Label({title: options.title})).$el)); + $view.append(Utils.wrap(this.table.$el)); + + // add element + this.setElement($view); + }, + + // update + update: function(settings, model) { + // reset table + this.table.removeAll(); + + // load settings elements into table + for (var id in settings) { + this._add(id, settings[id], model); + } + }, + + // add table row + _add: function(id, settings_def, model) { + // field wrapper + var field = null; + + // create select field + switch(settings_def.type) { + // text input field + case 'text' : + field = new Ui.Input({ + placeholder: settings_def.placeholder, + onchange: function() { + model.set(id, field.value()); + } + }); + break; + // slider input field + case 'slider' : + field = new Ui.Input({ + placeholder: settings_def.placeholder, + onchange: function() { + model.set(id, field.value()); + } + }); + break; + // skip unkown types + default: + console.log('ui-table-form:_add', 'Unknown setting type (' + settings_def.type + ')'); + return; + + } + + // set value + if (!model.get(id)) { + model.set(id, settings_def.init); + } + field.value(model.get(id)); + + // combine field and info + var $input = $('<div/>'); + $input.append(field.$el); + $input.append('<div class="toolParamHelp">' + settings_def.info + '</div>'); + + // add row to table + this.table.add('<span style="white-space: nowrap;">' + settings_def.title + ':</span>'); + this.table.add($input); + this.table.append(id); + } +}); + +return { + View : View +} + +}); \ No newline at end of file diff -r 7efdd4019ed122743ca920d2d30811737277d6a8 -r a2f88681c8d9a3bf8d5f124be7ddf365c2e33eab config/plugins/visualizations/charts/static/views/settings.js --- /dev/null +++ b/config/plugins/visualizations/charts/static/views/settings.js @@ -0,0 +1,50 @@ +// dependencies +define(['plugin/library/ui', 'plugin/library/ui-table-form', 'utils/utils'], + function(Ui, TableForm, Utils) { + +// widget +return Backbone.View.extend( +{ + // initialize + initialize: function(app, options) { + // link app + this.app = app; + + // link this + var self = this; + + // get current chart object + this.chart = this.app.chart; + + this.form = new TableForm.View({ + title : 'Chart options:', + content : 'This chart type does not provide any options.' + }); + + // set element + this.setElement(this.form.$el); + + // change + var self = this; + this.chart.on('change', function() { + self._refreshTable(); + }); + }, + + // update dataset + _refreshTable: function() { + // identify datasets + var chart_type = this.chart.get('type'); + + // check if dataset is available + if (!chart_type) { + return; + } + + // update table form model + var chart_definition = this.app.types.get(chart_type); + this.form.update(chart_definition.settings, this.chart.settings); + } +}); + +}); \ No newline at end of file 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.