(function(app) {
  'use strict';

  var dom = app.dom || require('../dom.js');

  var GeoNamesInputs = function(el, props) {
    this.el = el;
    this._geonamesAttrs = props.geonamesAttrs;
    this._geonamesData = props.geonamesData;
    this._inputElement = this.el.querySelector('input');
    this._tableElement = this.el.querySelector('.preferences-table');
    this._tableControlsElement = this.el.querySelector('.preferences-table-controls');
  };

  GeoNamesInputs.prototype.init = function() {
    this._inputElement.addEventListener('change', this._changeEnabled.bind(this));
    this._geonamesAttrs.on('change:enabled', this._updateEnabled.bind(this));
    this._geonamesData.on('loading', this._updateState.bind(this, 'loading'));
    this._geonamesData.on('loaded', this._updateState.bind(this, 'loaded'));
    this._geonamesData.on('error', this._updateState.bind(this, 'error'));
  };

  GeoNamesInputs.prototype._changeEnabled = function(event) {
    this._geonamesAttrs.set('enabled', event.target.checked);
  };

  GeoNamesInputs.prototype._updateEnabled = function(enabled) {
    this._inputElement.checked = enabled;
    dom.toggleClass(this._tableElement, 'disabled', !enabled);
    dom.toggleClass(this._tableControlsElement, 'disabled', !enabled);
  };

  GeoNamesInputs.prototype._updateState = function(state) {
    this.el.setAttribute('data-state', state);
  };

  if (typeof module !== 'undefined' && module.exports) {
    module.exports = GeoNamesInputs;
  } else {
    app.GeoNamesInputs = GeoNamesInputs;
  }
})(this.app || (this.app = {}));

@@ -300,26 +300,44 @@
 s._table
-Element = 
+ = new GeoNamesInputs.Table(
 this.el.
@@ -371,16 +371,24 @@
 -table')
+, props)
 ;%0A    th
@@ -517,24 +517,48 @@
 unction() %7B%0A
+    this._table.init();%0A
     this._in
@@ -1183,71 +1183,8 @@
 ed;%0A
-    dom.toggleClass(this._tableElement, 'disabled', !enabled);%0A
     
@@ -1363,22 +1363,450 @@
 state);%0A
-
   %7D;%0A%0A
+  GeoNamesInputs.Table = (function() %7B%0A    var Table = function(el, props) %7B%0A      this.el = el;%0A      this._geonamesAttrs = props.geonamesAttrs;%0A    %7D;%0A%0A    Table.prototype.init = function() %7B%0A      this._geonamesAttrs.on('change:enabled', this._updateEnabled.bind(this));%0A    %7D;%0A%0A    Table.prototype._updateEnabled = function(enabled) %7B%0A      dom.toggleClass(this.el, 'disabled', !enabled);%0A    %7D;%0A%0A    return Table;%0A  %7D)();%0A%0A
   if (ty

Refactor code for table of GeoNames inputs