Requires

Provides

Render.js

A module that provides rendering workflow

License:
Public domain (http://unlicense.org).
Authors:
Yaroslaff Fedin
  1. 24
  2. 25
  3. 26
  4. 27
  5. 28
  6. 29
  7. 30
  8. 31
  9. 32
  10. 33
  11. 34
  12. 35
  13. 36
  14. 37
  15. 38
  16. 39
  17. 40
  18. 41
  19. 42
  20. 43
LSD.Module.Render = new Class({ build: function() { this.redraws = 0; this.parent.apply(this, arguments) }, stateChange: function() { if (this.redraws > 0) this.refresh(true); }, render: function() { if (!this.built) this.build(); delete this.halted; this.redraws++; this.childNodes.each(function(child){ if (child.render) child.render(); }); },

setDocument: function(document) { //var halted = []; //this.render(); this.walk(function(child) {

//if (child.halted) halted.push(child);
      child.ownerDocument = child.document = document;
      child.fireEvent('dominject', [child.element.parentNode, document]);
      child.dominjected = true;
      

}); //halted.each(function(child) { // child.refresh(); //}) },

Halt marks widget as failed to render.

Possible use cases:

  1. 68
  2. 69
  3. 70
  4. 71
  5. 72
halt: function() { if (this.halted) return false; this.halted = true; return true; },

Update marks widget as willing to render. That can be followed by a call to render to trigger redrawing mechanism. Otherwise, the widget stay marked and can be rendered together with ascendant widget.

  1. 82
  2. 83
  3. 84
  4. 85
  5. 86
update: function(recursive) { if (recursive) this.walk(function(widget) { widget.update(); }); },

Refresh updates and renders widget (or a widget tree if optional argument is true). It is a reliable way to have all elements redrawn, but a costly too.

Should be avoided when possible to let internals handle the rendering and avoid some unnecessary calculations.

  1. 98
  2. 99
  3. 100
  4. 101
  5. 102
refresh: function(recursive) { this.update(recursive); return this.render(); } });