PageRenderTime 25ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/pyjs/tests/test012.js

http://pyjamas.googlecode.com/
JavaScript | 30 lines | 30 code | 0 blank | 0 comment | 6 complexity | 88c0824571d59a1c0dae80b8145ad56f MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
  1. __Widget.prototype.__class__ = "Widget";
  2. function Widget() {
  3. return new __Widget();
  4. }
  5. function __Widget() {
  6. this.attached = false;
  7. }
  8. __Widget.prototype.setParent = function(parent) {
  9. this.parent = parent;
  10. if ((parent == null)) {
  11. this.onDetach();
  12. }
  13. else if (parent.attached) {
  14. this.onAttach();
  15. }
  16. };
  17. __Widget.prototype.onAttach = function() {
  18. if (this.attached) {
  19. return;
  20. }
  21. this.attached = true;
  22. DOM_setEventListener(this.getElement(), this);
  23. };
  24. __Widget.prototype.onDetach = function() {
  25. if (!(this.attached)) {
  26. return;
  27. }
  28. this.attached = false;
  29. DOM_setEventListener(this.getElement(), null);
  30. };