[view/graph][xs]: refactor to have methods in standard order and events in events hash.
This commit is contained in:
parent
b183e70688
commit
1ae8985b00
46
src/view.js
46
src/view.js
@ -629,6 +629,10 @@ my.FlotGraph = Backbone.View.extend({
|
||||
</div> \
|
||||
',
|
||||
|
||||
events: {
|
||||
'change form select': 'onEditorSubmit'
|
||||
},
|
||||
|
||||
initialize: function(options, chart) {
|
||||
var self = this;
|
||||
this.el = $(this.el);
|
||||
@ -643,27 +647,6 @@ my.FlotGraph = Backbone.View.extend({
|
||||
};
|
||||
},
|
||||
|
||||
events: {
|
||||
// 'change select': 'onEditorSubmit'
|
||||
},
|
||||
|
||||
onEditorSubmit: function(e) {
|
||||
var select = this.el.find('.editor-group select');
|
||||
this._getEditorData();
|
||||
this.plot.setData(this.createSeries());
|
||||
this.plot.resize();
|
||||
this.plot.setupGrid();
|
||||
this.plot.draw();
|
||||
},
|
||||
_getEditorData: function() {
|
||||
$editor = this
|
||||
var series = this.$series.map(function () {
|
||||
return $(this).val();
|
||||
});
|
||||
this.chartConfig.series = $.makeArray(series)
|
||||
this.chartConfig.group = this.el.find('.editor-group select').val();
|
||||
},
|
||||
|
||||
toTemplateJSON: function() {
|
||||
return this.model.toJSON();
|
||||
},
|
||||
@ -677,12 +660,27 @@ my.FlotGraph = Backbone.View.extend({
|
||||
this.$series = this.el.find('.editor-series select');
|
||||
this.$seriesClone = this.$series.parent().clone();
|
||||
var self = this;
|
||||
this.el.find('form select').change(function() {
|
||||
self.onEditorSubmit.apply(self, arguments)
|
||||
});
|
||||
return this;
|
||||
},
|
||||
|
||||
onEditorSubmit: function(e) {
|
||||
var select = this.el.find('.editor-group select');
|
||||
this._getEditorData();
|
||||
this.plot.setData(this.createSeries());
|
||||
this.plot.resize();
|
||||
this.plot.setupGrid();
|
||||
this.plot.draw();
|
||||
},
|
||||
|
||||
_getEditorData: function() {
|
||||
$editor = this
|
||||
var series = this.$series.map(function () {
|
||||
return $(this).val();
|
||||
});
|
||||
this.chartConfig.series = $.makeArray(series)
|
||||
this.chartConfig.group = this.el.find('.editor-group select').val();
|
||||
},
|
||||
|
||||
createPlot: function () {
|
||||
// only lines for the present
|
||||
options = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user