Sha256: 0a36a5bdfbd88bc7896c29e37d0b6ae442bbc90cfc4eddab76ca7e24a1afd7f0

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 KB

Contents

/*
---
 
script: Root.js
 
description: The topmost widget easily accessible.
 
license: Public domain (http://unlicense.org).
 
requires:
  - LSD.Mixin
  - LSD.Behavior
 
provides: 
  - LSD.Mixin.Root
 
...
*/

LSD.Mixin.Root = new Class({
  options: {
    events: {
      _root: {
        nodeInserted: function(node) {
          node.root = this;
          node.fireEvent('setRoot', this);
          node.fireEvent('register', ['root', this]);
          node.fireEvent('relate', [this, 'root']);
        },
        nodeRemoved: function(node) {
          if (node.root == this) {
            node.fireEvent('unsetRoot', this);
            node.fireEvent('unregister', ['root', this]);
            node.fireEvent('unrelate', [this, 'root']);
            delete node.root;
          }
        }
      }
    }
  },
  
  onMix: function() {
    this.root = this;
    this.fireEvent('setRoot', this);
    this.fireEvent('relate', [this, 'root']);
    this.fireEvent('register', ['root', this]);
  },
  
  onUnmix: function() {
    delete this.root;
    this.fireEvent('unsetRoot', this);
    this.fireEvent('unregister', ['root', this]);
    this.fireEvent('unrelate', [this, 'root']);
  }
});

LSD.Behavior.define(':root', 'root');

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lsd_rails-0.1.6 Packages/lsd/Source/Mixin/Root.js
lsd_rails-0.1.5 Packages/lsd/Source/Mixin/Root.js
lsd_rails-0.1.4 Packages/lsd/Source/Mixin/Root.js
lsd_rails-0.1.3 Packages/lsd/Source/Mixin/Root.js