Permalink
Browse files

gallery-2010.09.08-19-45 apipkin gallery-button-group

  • Loading branch information...
1 parent aed7c9f commit 8ade0c4f260e5225464fd27907bc8383438187ef YUI Builder committed Sep 8, 2010
@@ -1,27 +1,27 @@
-# Button Group Build Properties
-
-# As long as the 'builder' project is cloned to the default folder
-# next to the 'yui3-gallery' project folder, the 'builddir' property does not
-# need to be changed
-#
-# If the 'builder' project is checked out to an alternate location, this
-# property should be updated to point to the checkout location.
-builddir=../../../builder/componentbuild
-
-# The name of the component. E.g. event, attribute, widget
-component=gallery-button-group
-
-# The list of files which should be concatenated to create the component.
-# NOTE: For a css component (e.g. cssfonts, cssgrids etc.) use component.cssfiles instead.
-# component.jsfiles=button-group.js, button-groupHelperClass.js, button-groupSubComponentClass.js
-component.jsfiles=button-group.js
-
-# The list of modules this component requires. Used to set up the Y.add module call for YUI 3.
-component.requires=widget-parent,widget-child
-
-# The list of modules this component supersedes. Used to set up the Y.add module call for YUI 3.
-component.supersedes=
-
-# The list of modules that are optional for this module. Used to set up the Y.add module call for YUI 3.
-component.optional=
+# Button Group Build Properties
+
+# As long as the 'builder' project is cloned to the default folder
+# next to the 'yui3-gallery' project folder, the 'builddir' property does not
+# need to be changed
+#
+# If the 'builder' project is checked out to an alternate location, this
+# property should be updated to point to the checkout location.
+builddir=../../../builder/componentbuild
+
+# The name of the component. E.g. event, attribute, widget
+component=gallery-button-group
+
+# The list of files which should be concatenated to create the component.
+# NOTE: For a css component (e.g. cssfonts, cssgrids etc.) use component.cssfiles instead.
+# component.jsfiles=button-group.js, button-groupHelperClass.js, button-groupSubComponentClass.js
+component.jsfiles=button-group.js
+
+# The list of modules this component requires. Used to set up the Y.add module call for YUI 3.
+component.requires=widget-parent,widget-child
+
+# The list of modules this component supersedes. Used to set up the Y.add module call for YUI 3.
+component.supersedes=
+
+# The list of modules that are optional for this module. Used to set up the Y.add module call for YUI 3.
+component.optional=
@@ -1,7 +1,7 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- YUI 3 Gallery Component Build File -->
-<project name="Button Group" default="local">
- <description>Button Group Build File</description>
- <property file="build.properties" />
- <import file="${builddir}/3.x/bootstrap.xml" description="Default Build Properties and Targets" />
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- YUI 3 Gallery Component Build File -->
+<project name="Button Group" default="local">
+ <description>Button Group Build File</description>
+ <property file="build.properties" />
+ <import file="${builddir}/3.x/bootstrap.xml" description="Default Build Properties and Targets" />
</project>
@@ -1,38 +1,64 @@
- var YL = Y.Lang;
-
- Y.ButtonGroup = Y.Base.create('button-group', Y.Widget, [Y.WidgetParent,Y.WidgetChild], {
-
- labelNode : null,
-
- initializer : function(config) {
- this.labelNode = Y.Node.create('<span class="' + this.getClassName('label') + '"/>');
- },
-
- renderUI : function() {
- this.get('boundingBox').prepend(this.labelNode);
- },
-
- syncUI : function() {
- this.labelNode.set('text',this.get('label'));
- }
-
-
- }, {
- ATTRS : {
- label : {
- validator : YL.isString,
- setter : function(val) {
- this.labelNode.set('text', val);
- return val;
- }
- },
-
- defaultChildType : {
- value : Y.Button
- },
-
- alwaysSelected : {
- value : false
- }
- }
- });
+var YL = Y.Lang;
+
+Y.ButtonGroup = Y.Base.create('button-group', Y.Widget, [Y.WidgetParent,Y.WidgetChild], {
+
+ labelNode : null,
+
+ initializer : function(config) {
+ Y.log('Y.ButtonGroup::initializer');
+
+ this.labelNode = Y.Node.create('<span class="' + this.getClassName('label') + '"/>');
+ },
+
+ renderUI : function() {
+ Y.log('Y.ButtonGroup::renderUI');
+
+ this.get('boundingBox').prepend(this.labelNode);
+ },
+
+ bindUI : function() {
+ Y.log('Y.ButtonGroup::bindUI');
+
+ this.on('button:press', function(e) {
+ if(this.get('alwaysSelected')) {
+ var selection = this.get('selection'),
+ button = e.target;
+
+ if(selection === button || ( // selection is the button OR
+ selection instanceof Y.ArrayList && // selection is an array AND
+ selection.size() === 1 && // there is only one item AND
+ selection.item(0) === button) // that one itme is the button
+ ) {
+ e.preventDefault();
+ }
+
+ }
+ },this);
+ },
+
+ syncUI : function() {
+ Y.log('Y.ButtonGroup::syncUI');
+
+ this.labelNode.set('text',this.get('label'));
+ }
+
+}, {
+ ATTRS : {
+
+ label : {
+ validator : YL.isString,
+ setter : function(val) {
+ this.labelNode.set('text', val);
+ return val;
+ }
+ },
+
+ defaultChildType : {
+ value : Y.Button
+ },
+
+ alwaysSelected : {
+ value : false
+ }
+ }
+});

0 comments on commit 8ade0c4

Please sign in to comment.