Sha256: 2572f7b5162c716368e4f1a63f0e07e9bbb450f2b9ed34b758eff592740d0015

Contents?: true

Size: 1.28 KB

Versions: 2

Compression:

Stored size: 1.28 KB

Contents

// ==========================================================================
// Project:   SproutCore Bricks
// Copyright: ©2011 Paul Chavard
// Author :   Paul Chavard
//
// layout_manager.js
// ==========================================================================
SB = this.SB || {};

SB.layoutManager = SC.Object.create({
  windowWidth: 0,
  windowHeight: 0,

  init: function() {
    this._windowSize();
    this._window.resize(SC.$.proxy(this, '_onResize'));
  },
  registerLayout: function(view) {
    this._managedViews.pushObject(view);
    this._callApplyLayout(view);
  },

  _managedViews: [],
  _window: SC.$(window),

  _onResize: function() {
    this._windowSize();
    this._managedViews.forEach(this._callApplyLayout, this);
  },
  _windowSize: function() {
    this.set('windowWidth', this._window.width());
    this.set('windowHeight', this._window.height());
  },
  _callApplyLayout: function(view) {
    if (view && view.get('state') === 'inDOM'
      && view.get('hasLayout') === true
      && typeof view.applyLayout === 'function') {
        view.applyLayout(this.windowWidth, this.windowHeight);
    }
  }
});

SB.ManagedLayoutSupport = SC.Mixin.create({
  hasLayout: true,

  didInsertElement: function() {
    this._super();
    SB.layoutManager.registerLayout(this);
  }
});

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rasputin-0.7.1 vendor/assets/javascripts/bricks/layout_manager.js
rasputin-0.7.0 vendor/assets/javascripts/bricks/layout_manager.js