commit/galaxy-central: guerler: Charts: Update panel
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/ac52aab8cb0e/ Changeset: ac52aab8cb0e User: guerler Date: 2014-05-15 04:21:36 Summary: Charts: Update panel Affected #: 1 file diff -r f05fe632cbc70d4694b5a4aa5e30b4f003952aa1 -r ac52aab8cb0e0ae989b3429b895743849dfb7e3a config/plugins/visualizations/charts/static/views/types.js --- /dev/null +++ b/config/plugins/visualizations/charts/static/views/types.js @@ -0,0 +1,133 @@ +define(['utils/utils', 'plugin/library/ui'], function(Utils, Ui) { + +return Backbone.View.extend( +{ + // defaults options + optionsDefault: { + onchange : null, + ondblclick : null + }, + + // events + events : { + 'click' : '_onclick', + 'dblclick' : '_ondblclick' + }, + + // initialize + initialize : function(app, options) { + + // link app + this.app = app; + + // configure options + this.options = Utils.merge(options, this.optionsDefault); + + // create new element + var $el = $('<div class="charts-grid"/>'); + + // set element + this.setElement($el); + + // load chart types into categories + var categories = {}; + var types = app.types.attributes; + for (var id in types) { + var type = types[id]; + var category = type.category; + if (!categories[category]) { + categories[category] = {}; + } + categories[category][id] = type; + } + + // add categories and charts to screen + for (var category in categories) { + // create empty element + var $el = $('<div style="clear: both;"/>') + + // add header label + $el.append(Utils.wrap(this._template_header({title: category}))); + + // add chart types + for (var id in categories[category]) { + var type = categories[category][id]; + $el.append(Utils.wrap(this._template_item({ + id : id, + title : type.title, + url : config.app_root + 'charts/' + id + '/logo.png' + }))); + } + + // add to view + this.$el.append(Utils.wrap($el)); + } + }, + + // value + value: function(new_value) { + // get current element + var before = this.$el.find('.current').attr('id'); + + // check if new_value is defined + if (new_value !== undefined) { + + // remove current class + this.$el.find('.current').removeClass('current'); + + // add current class + this.$el.find('#' + new_value).addClass('current'); + } + + // get current id/value + var after = this.$el.find('.current').attr('id'); + if(after === undefined) { + return null; + } else { + // fire onchange + if (after != before && this.options.onchange) { + this.options.onchange(new_value); + } + + // return current value + return after; + } + }, + + // onclick + _onclick: function(e) { + var old_value = this.value(); + var new_value = $(e.target).closest('.item').attr('id'); + if (new_value != '') { + if (new_value && old_value != new_value) { + this.value(new_value); + } + } + }, + + // ondblclick + _ondblclick: function(e) { + var value = this.value(); + if (value && this.options.ondblclick) { + this.options.ondblclick(value); + } + }, + + // template + _template_header: function(options) { + return '<div class="header">' + + '• ' + options.title + + '<div>'; + }, + + // template + _template_item: function(options) { + return '<div id="' + options.id + '" class="item">' + + '<img class="image" src="' + options.url + '">' + + '<div class="title">' + options.title + '</div>' + + '<div>'; + } + +}); + +}); 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