Sha256: 854f4ea0366643909ee594c45b13469dd4148346bb2d0961ceb2ecfeaf3c2829

Contents?: true

Size: 1.56 KB

Versions: 5

Compression:

Stored size: 1.56 KB

Contents

// ==========================================================================
// Project:   Welcome.targetsController
// Copyright: ©2010 Apple Inc.
// ==========================================================================
/*globals CoreTools Welcome */

/** @class
  
  Manages the list of targets

  @extends SC.ArrayController
*/
Welcome.targetsController = SC.ArrayController.create(
/** @scope Welcome.targetsController.prototype */ {

  /**
    Call this method whenever you want to relaod the targets from the server.
  */
  reload: function() {
    var targets = Welcome.store.find(CoreTools.TARGETS_QUERY);
    this.set('content', targets);
  },
  
  appsOnly: function() {
    return this.filter(function(t) { 
      return (t.get('kind') === 'app') && 
             (t.get('name') !== '/sproutcore/welcome'); 
    });
  }.property('[]').cacheable(),
  
  loadApplication: function() {
    var app = this.get('selection').firstObject(),
        url = app ? app.get('appUrl') : null;
        
    if (url) {
      this.set('canLoadApp', NO);
      this.invokeLater(function() { 
        window.location.href = url; // load new app
      });
    }
  },
  
  launchEnabled: function() {
    var canLoadApp = this.get('canLoadApp'),
        selection = this.get('selection'),
        selectedObject = selection.firstObject();
    return canLoadApp && selectedObject && selectedObject.get('name') !== '/sproutcore';
  }.property('canLoadApp', 'selection').cacheable(),

  // used to disable all controls
  canLoadApp: YES,
  
  allowsEmptySelection: NO,
  allowsMultipleSelection: NO

}) ;

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
spade-0.0.1 sproutcore/apps/welcome/controllers/targets.js
sproutcore-1.5.0.pre.5 lib/frameworks/sproutcore/apps/welcome/controllers/targets.js
sproutcore-1.5.0.pre.4.1 lib/frameworks/sproutcore/apps/welcome/controllers/targets.js
sproutcore-1.5.0.pre.4 lib/frameworks/sproutcore/apps/welcome/controllers/targets.js
sproutcore-1.5.0.pre.3 lib/frameworks/sproutcore/apps/welcome/controllers/targets.js