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 SC.BaseTheme.disclosureRenderDelegate = SC.RenderDelegate.create({ 10 className: 'disclosure', 11 12 render: function(dataSource, context) { 13 this.addSizeClassName(dataSource, context); 14 15 var theme = dataSource.get('theme'), 16 value = dataSource.get('value'), 17 labelClassNames = ['sc-button-label', 'sc-disclosure-label']; 18 19 var labelId = SC.guidFor(dataSource) + "-label"; 20 21 //addressing accessibility 22 context.setAttr('aria-expanded', value); 23 context.setAttr('aria-labelledby', labelId); 24 25 if (dataSource.get('isSelected')) context.addClass('sel'); 26 27 var state = ''; 28 state += dataSource.get('isSelected') ? 'open' : 'closed'; 29 if (dataSource.get('isActive')) state += ' active'; 30 31 context.push('<img src = "' + SC.BLANK_IMAGE_URL + '" class = "disclosure button ' + state + '" />'); 32 33 context = context.begin('span').addClass(labelClassNames).id(labelId); 34 theme.labelRenderDelegate.render(dataSource, context); 35 context = context.end(); 36 }, 37 38 update: function(dataSource, jquery) { 39 this.updateSizeClassName(dataSource, jquery); 40 41 var theme = dataSource.get('theme'), 42 value = dataSource.get('value'); 43 44 //addressing accessibility 45 jquery.attr('aria-expanded', value); 46 47 if (dataSource.get('isSelected')) jquery.addClass('sel'); 48 49 jquery.find('img').setClass({ 50 open: dataSource.get('isSelected'), 51 closed: !dataSource.get('isSelected'), 52 active: dataSource.get('isActive') 53 }); 54 55 theme.labelRenderDelegate.update(dataSource, jquery.find('span.sc-disclosure-label')); 56 } 57 }); 58 59