Sha256: 09e3fb53908013a5ca53d1a0d394fa135cadc2d594fbacb28adfc51a2e03e023

Contents?: true

Size: 1.81 KB

Versions: 2

Compression:

Stored size: 1.81 KB

Contents

// ========================================================================
// SproutCore -- JavaScript Application Framework
// Copyright ©2006-2011, Strobe Inc. and contributors.
// Portions copyright ©2008 Apple Inc.  All rights reserved.
// ========================================================================

/** 
  Extend SC.Page to emit a design document for the entire page.
*/
SC.Page.prototype.emitDesign = function() {

  // awake all views.  this is needed to emit the design for them.
  this.awake();

  // the pageName must be set on the page so we can emit properly
  var pageName = this.get('pageName');
  
  // now encode the page.
  var ret = SC.DesignCoder.encode(this);
  
  // and add some wrapper
  ret = ['// SproutCore ViewBuilder Design Format v1.0',
    '// WARNING: This file is automatically generated.  DO NOT EDIT.  Changes you',
    '// make to this file will be lost.', '',
    '%@ = %@;'.fmt(pageName, ret),''].join("\n");
  
  return ret ;
};

/**
  Extend SC.Page to create a PageDesignController on demand.
  
  @property {SC.PageDesignController}
*/
SC.Page.prototype.designController = function() {
  if (!this._designController) {
    this._designController = SC.PageDesignController.create({ page: this });
  }
  return this._designController ;
}.property().cacheable();

/** @private implement support for encoders */
SC.Page.prototype.encodeDesign = function(c) {
  // step through and find all views.  encode them.
  for(var key in this) {
    if(!this.hasOwnProperty(key)) continue;
    var view = this[key];
    if (key !== '__sc_super__' && key !== '_designController' &&
        (view instanceof SC.View || view instanceof SC.Controller || view instanceof SC.Object)){
     c.js(key, view.emitDesign());      
    }
  }
  
  // save page name;
  c.string('pageName', this.get('pageName'));
};
  

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
spade-0.0.1 sproutcore/frameworks/designer/ext/page.js
sproutcore-1.5.0.pre.5 lib/frameworks/sproutcore/frameworks/designer/ext/page.js