// Generated by CoffeeScript 1.10.0 (function() { var QueryView, extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; window.QueryView = observer(QueryView = (function(superClass) { extend(QueryView, superClass); function QueryView(conf) { var country_options, year_options; QueryView.__super__.constructor.call(this, conf); this.init(); this.query = conf.query; this.select_year_el = this.d3el.append('select'); year_options = this.select_year_el.selectAll('option').data(this.query.get_years().sort(), function(d) { return d; }); year_options.enter().append('option').text(function(d) { return d; }).attrs({ value: function(d) { return d; } }); this.select_year_el.on('change', (function(_this) { return function() { return _this.query.set_year(_this.select_year_el.node().options[_this.select_year_el.node().selectedIndex].value); }; })(this)); this.select_country_el = this.d3el.append('select'); country_options = this.select_country_el.selectAll('option').data(this.query.get_countries().sort(), function(d) { return d; }); country_options.enter().append('option').text(function(d) { return d; }).attrs({ value: function(d) { return d; } }); this.select_country_el.on('change', (function(_this) { return function() { return _this.query.set_country(_this.select_country_el.node().options[_this.select_country_el.node().selectedIndex].value); }; })(this)); this.select_airport_el = this.d3el.append('select'); this.select_airport_el.on('change', (function(_this) { return function() { return _this.query.set_airport(_this.select_airport_el.node().options[_this.select_airport_el.node().selectedIndex].value); }; })(this)); this.listen_to(this.query, 'change_country', (function(_this) { return function() { _this.select_country_option(_this.query.get_country()); return _this.redraw(); }; })(this)); this.listen_to(this.query, 'change', (function(_this) { return function() { _this.select_year_option(_this.query.get_year()); return _this.select_airport_option(_this.query.get_airport().icao); }; })(this)); } QueryView.prototype.select_year_option = function(year) { return this.select_year_el.select("option[value='" + year + "']").property('selected', true); }; QueryView.prototype.select_country_option = function(name) { return this.select_country_el.select("option[value='" + name + "']").property('selected', true); }; QueryView.prototype.select_airport_option = function(icao) { return this.select_airport_el.select("option[value='" + icao + "']").property('selected', true); }; QueryView.prototype.redraw = function() { var airport_options; airport_options = this.select_airport_el.selectAll('option').data(this.query.get_all().sort(function(a, b) { return d3.ascending(a.city, b.city); }), function(d) { return d.icao; }); airport_options.enter().append('option').text(function(d) { return d.city + " (" + d.icao + ")"; }).attrs({ value: function(d) { return d.icao; } }); return airport_options.exit().remove(); }; return QueryView; })(View)); }).call(this);