Code coverage report for lib/components/base.js

Statements: 26.67% (4 / 15)      Branches: 0% (0 / 2)      Functions: 0% (0 / 6)      Lines: 28.57% (4 / 14)      Ignored: none     

All files » lib/components/ » base.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 611 1         1                               1                                                                            
var protoclass = require("protoclass");
var _bind      = require("../utils/bind");
 
/**
 */
 
function Component(options) {
 
  this.attributes    = options.attributes;
  this.childTemplate = options.childTemplate;
  this.view          = options.view;
  this.section       = options.section;
  this.document   = this.view.template.document;
  this.didChange     = _bind(this.didChange, this);
 
  // initialize the DOM elements
  this.initialize();
}
 
/**
 */
 
module.exports = protoclass(Component, {
 
  /**
   */
 
  initialize: function() {
    // override me - this is where the DOM elements should be added to the
    // section
  },
 
  /**
   */
 
  bind: function() {
    this.update();
  },
 
  /**
   */
 
  didChange: function() {
    this.view.runloop.deferOnce(this);
  },
 
  /**
   */
 
  unbind: function() {
    if (this._changeListener) this._changeListener.dispose();
  },
 
  /**
   */
 
  update: function() {
    // apply DOM changes here
  }
});