1 // ========================================================================== 2 // Project: SproutCore - JavaScript Application Framework 3 // Copyright: ©2006-2011 Strobe Inc. and contributors. 4 // Portions ©2008-2011 Apple Inc. All rights reserved. 5 // License: Licensed under MIT license (see license.js) 6 // ========================================================================== 7 8 /** 9 @class 10 11 Disclosure triangle button. As a subclass of SC.ButtonView, this view 12 takes a lot of the same properties as a button: 13 14 - isEnabled: whether disclosure triangle is clickable or not 15 - value: `YES` or `NO` (where `YES` implies expanded/open) 16 17 A disclosure view also supports expanding and collapsing via 18 the keyboard. 19 20 @extends SC.ButtonView 21 @since SproutCore 1.0 22 */ 23 SC.DisclosureView = SC.ButtonView.extend( 24 /** @scope SC.DisclosureView.prototype */ { 25 26 /** 27 @type Array 28 @default ['sc-disclosure-view'] 29 @see SC.View#classNames 30 */ 31 classNames: ['sc-disclosure-view'], 32 33 /** 34 @type String 35 @default 'disclosureRenderDelegate' 36 */ 37 renderDelegateName: 'disclosureRenderDelegate', 38 39 /** 40 @type String 41 @default SC.TOGGLE_BEHAVIOR 42 @see SC.ButtonView#buttonBehavior 43 */ 44 buttonBehavior: SC.TOGGLE_BEHAVIOR, 45 46 /** 47 This is the value that will be set when the disclosure triangle is toggled 48 open. 49 50 @type Boolean 51 @default YES 52 */ 53 toggleOnValue: YES, 54 55 /** 56 The value that will be set when the disclosure triangle is toggled closed. 57 58 @type Boolean 59 @default YES 60 */ 61 toggleOffValue: NO, 62 63 /** @private */ 64 valueBindingDefault: SC.Binding.bool(), 65 66 /** @private 67 68 Allows toggling of the value with the right and left arrow keys. 69 Extends the behavior inherited from SC.ButtonView. 70 @param evt 71 */ 72 keyDown: function(evt) { 73 if (evt.which === 37 || evt.which === 38) { 74 this.set('value', this.get('toggleOffValue')) ; 75 return YES; 76 } 77 78 if (evt.which === 39 || evt.which === 40) { 79 this.set('value', this.get('toggleOnValue')) ; 80 return YES; 81 } 82 sc_super(); 83 } 84 85 }); 86