Sha256: 97d93801eff43091fae38fd1a1d0f90fb64a5e6533e5a7515333da6be3693c48

Contents?: true

Size: 1.95 KB

Versions: 3

Compression:

Stored size: 1.95 KB

Contents

// ==========================================================================
// Project:   SproutCore - JavaScript Application Framework
// Copyright: ©2006-2011 Strobe Inc. and contributors.
//            Portions ©2008-2010 Apple Inc. All rights reserved.
// License:   Licensed under MIT license (see license.js)
// ==========================================================================

/**
  @class
  
  Disclosure triangle button. As a subclass of SC.ButtonView, this view
  takes a lot of the same properties as a button:
  
  - isEnabled: whether disclosure triangle is clickable or not
  - value: YES or NO (where YES implies expanded/open)
  
  @extends SC.ButtonView
  @since SproutCore
*/
SC.DisclosureView = SC.ButtonView.extend(
/** @scope SC.DisclosureView.prototype */ {
  
  classNames: ['sc-disclosure-view'],

  /**
    The WAI-ARIA attribute for the disclosure button. This property is assigned
    to 'aria-label' attribute, which defines a string value that labels the
    the element. Used to support voiceover. It is used when it is not
    possible to have a visible label on the screen.
  */
  ariaLabel: null,

  renderDelegateName: 'disclosureRenderDelegate',

  buttonBehavior: SC.TOGGLE_BEHAVIOR,
  
  /**
    This is the value that will be set when the disclosure triangle is toggled
    open.
  */
  toggleOnValue: YES,
  
  /**
    The value that will be set when the disclosure triangle is toggled closed.
  */
  toggleOffValue: NO,
  
  /** @private */
  valueBindingDefault: SC.Binding.bool() ,

  /**
    Allows toggling of the value with the right and left arrow keys. 
    Extends the behavior inherted from SC.ButtonView.
    @param evt
  */
  keyDown: function(evt) {
    if (evt.which === 37 || evt.which === 38) {  
      this.set('value', this.get('toggleOffValue')) ;
      return YES;
    }
    if (evt.which === 39 || evt.which === 40) {  
      this.set('value', this.get('toggleOnValue')) ;
      return YES;
    }
    sc_super();
  }
  
});

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
spade-0.0.1 sproutcore/frameworks/desktop/views/disclosure.js
sproutcore-1.5.0.pre.5 lib/frameworks/sproutcore/frameworks/desktop/views/disclosure.js
sproutcore-1.5.0.pre.4.1 lib/frameworks/sproutcore/frameworks/desktop/views/disclosure.js