Sha256: bab32e911ef2ffc241b03fd9ed80736ef49a5c8225c316170dff92f7452a4307

Contents?: true

Size: 2 KB

Versions: 9

Compression:

Stored size: 2 KB

Contents

// ==========================================================================
// Project:   SproutCore - JavaScript Application Framework
// Copyright: ©2006-2009 Sprout Systems, Inc. and contributors.
//            Portions ©2008-2009 Apple, Inc. All rights reserved.
// License:   Licened under MIT license (see license.js)
// ==========================================================================
/*globals TestRunner */

/**
  Initial state of application before it has loaded targets.
*/
TestRunner.READY = SC.Responder.create({
  
  /**
    Invoked when you select a target.  Set the target controller then show 
    list state if needed.
  */
  selectTarget: function(sender, target) {
    if (target && target.isEnumerable) target = target.firstObject();

    TestRunner.sourceController.selectObject(target);
    
    if (target) {
      var tests = target.get('tests');
      if (tests && (tests.get('state') === SC.Record.BUSY_LOADING)) {
        TestRunner.makeFirstResponder(TestRunner.READY_LOADING);
      } else if (!tests || (tests.get('length')===0)) {
        TestRunner.makeFirstResponder(TestRunner.READY_NO_TESTS);
      } else TestRunner.makeFirstResponder(TestRunner.READY_LIST);
      
    } else TestRunner.makeFirstResponder(TestRunner.READY_EMPTY);
  },

  /**
    Invoked when you select the test.
  */
  selectTest: function(sender, test) {
    if (!TestRunner.targetController.get('hasContent')) return NO ;

    if (test && test.isEnumerable) test = test.firstObject();
    TestRunner.detailController.set('content', test);
    TestRunner.set('routeName', test ? test.get('filename') : null);

    if (test) TestRunner.makeFirstResponder(TestRunner.READY_DETAIL);
    else TestRunner.makeFirstResponder(TestRunner.READY_LIST);
  },
  
  route: function(sender, params) {
    var target = TestRunner.computeRouteTarget(),
        test   = TestRunner.computeRouteTest();

    if (test) TestRunner.sendAction('selectTest', this, test);
    else TestRunner.sendAction('selectTarget', this, target);
  }
      
});

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sproutit-sproutcore-1.0.0.20090720093355 frameworks/sproutcore/apps/tests/states/ready.js
sproutit-sproutcore-1.0.0.20090720202429 frameworks/sproutcore/apps/tests/states/ready.js
sproutit-sproutcore-1.0.0.20090721125122 frameworks/sproutcore/apps/tests/states/ready.js
sproutit-sproutcore-1.0.126 frameworks/sproutcore/apps/tests/states/ready.js
sproutit-sproutcore-1.0.20090721145251 frameworks/sproutcore/apps/tests/states/ready.js
sproutit-sproutcore-1.0.20090721145280 frameworks/sproutcore/apps/tests/states/ready.js
sproutit-sproutcore-1.0.20090721145281 frameworks/sproutcore/apps/tests/states/ready.js
sproutit-sproutcore-1.0.20090721145282 frameworks/sproutcore/apps/tests/states/ready.js
sproutit-sproutcore-1.0.203 frameworks/sproutcore/apps/tests/states/ready.js