Sha256: 0812a5af70c9c33c6e4622de18123a799162d101d838c4153230299b6abe9c2c

Contents?: true

Size: 1.59 KB

Versions: 7

Compression:

Stored size: 1.59 KB

Contents

// ==========================================================================
// Project:   Showcase
// Copyright: ©2012 7x7 Software, Inc.
// License:   Licensed under MIT license
// ==========================================================================
/*globals Showcase */


/**
  This class is used to provide content to the lists of Views & Controls.
*/
Showcase.ViewsItemContent = SC.Object.extend({

  example: null,

  /**
    Takes the example snippet and generates a multiline String.
  */
  exampleString: function() {
    var example = this.get('example'),
        padding = '  ',
        parts;

    parts = example.split('  ');
    parts.forEach(function(part, index) {
      if (part.indexOf('.extend(') >= 0 || part.indexOf('function(') >= 0 || part.indexOf('({') >= 0) {
        parts[index] = padding + part;
        padding += '  ';
      } else if (part.indexOf('}.property') >= 0 || part.indexOf('})') >= 0) {
        padding = padding.substr(2);
        parts[index] = padding + part;
      } else {
        parts[index] = padding + part;
      }
    });

    return '\n' + parts.join('\n') + '\n';
  }.property().cacheable(),

  /**
    Takes the example snippet and generates a JavaScript class.
  */
  exampleView: function() {
    var el,
        example = this.get('example');

    // Remove the HTML formatting from the snippet.
    // el = document.createElement("div");
    // el.innerHTML = example;
    // example = el.textContent || el.innerText;

    // Return the JavaScript interpretation.
    return eval(example);
  }.property().cacheable(),

  supportTitle: null,

  title: null

});

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sproutcore-1.10.3.1 lib/frameworks/sproutcore/apps/showcase/system/views_item_content.js
sproutcore-1.10.2 lib/frameworks/sproutcore/apps/showcase/system/views_item_content.js
sproutcore-1.10.1 lib/frameworks/sproutcore/apps/showcase/system/views_item_content.js
sproutcore-1.10.0 lib/frameworks/sproutcore/apps/showcase/system/views_item_content.js
sproutcore-1.10.0.rc.3 lib/frameworks/sproutcore/apps/showcase/system/views_item_content.js
sproutcore-1.10.0.rc.2 lib/frameworks/sproutcore/apps/showcase/system/views_item_content.js
sproutcore-1.10.0.rc.1 lib/frameworks/sproutcore/apps/showcase/system/views_item_content.js