Skip to content

Commit

Permalink
gallery-2010.09.08-19-45 apipkin gallery-button-toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
YUI Builder committed Sep 8, 2010
1 parent 3450a87 commit aed7c9f
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 88 deletions.
52 changes: 26 additions & 26 deletions src/gallery-button-toggle/build.properties
@@ -1,27 +1,27 @@
# Button Toggle Build Properties # Button Toggle Build Properties

# As long as the 'builder' project is cloned to the default folder # As long as the 'builder' project is cloned to the default folder
# next to the 'yui3-gallery' project folder, the 'builddir' property does not # next to the 'yui3-gallery' project folder, the 'builddir' property does not
# need to be changed # need to be changed
# #
# If the 'builder' project is checked out to an alternate location, this # If the 'builder' project is checked out to an alternate location, this
# property should be updated to point to the checkout location. # property should be updated to point to the checkout location.
builddir=../../../builder/componentbuild builddir=../../../builder/componentbuild

# The name of the component. E.g. event, attribute, widget # The name of the component. E.g. event, attribute, widget
component=gallery-button-toggle component=gallery-button-toggle

# The list of files which should be concatenated to create the component. # 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. # NOTE: For a css component (e.g. cssfonts, cssgrids etc.) use component.cssfiles instead.
# component.jsfiles=button-toggle.js, button-toggleHelperClass.js, button-toggleSubComponentClass.js # component.jsfiles=button-toggle.js, button-toggleHelperClass.js, button-toggleSubComponentClass.js
component.jsfiles=button-toggle.js component.jsfiles=button-toggle.js

# The list of modules this component requires. Used to set up the Y.add module call for YUI 3. # The list of modules this component requires. Used to set up the Y.add module call for YUI 3.
component.requires=gallery-button component.requires=gallery-button

# The list of modules this component supersedes. Used to set up the Y.add module call for YUI 3. # The list of modules this component supersedes. Used to set up the Y.add module call for YUI 3.
component.supersedes= component.supersedes=

# The list of modules that are optional for this module. Used to set up the Y.add module call for YUI 3. # The list of modules that are optional for this module. Used to set up the Y.add module call for YUI 3.
component.optional= component.optional=


12 changes: 6 additions & 6 deletions src/gallery-button-toggle/build.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- YUI 3 Gallery Component Build File --> <!-- YUI 3 Gallery Component Build File -->
<project name="Button Toggle" default="local"> <project name="Button Toggle" default="local">
<description>Button Toggle Build File</description> <description>Button Toggle Build File</description>
<property file="build.properties" /> <property file="build.properties" />
<import file="${builddir}/3.x/bootstrap.xml" description="Default Build Properties and Targets" /> <import file="${builddir}/3.x/bootstrap.xml" description="Default Build Properties and Targets" />
</project> </project>
91 changes: 35 additions & 56 deletions src/gallery-button-toggle/js/button-toggle.js
@@ -1,56 +1,35 @@
var YL = Y.Lang, var YL = Y.Lang,
DESELECTED_CALLBACK = 'deselectedCallback'; DESELECTED_CALLBACK = 'deselectedCallback';



Y.ButtonToggle = Y.Base.create('button', Y.Button, [], {
Y.ButtonToggle = Y.Base.create('button', Y.Button, [], {

initializer : function(config) {
initializer : function(config) { this.after('selectedChange',this._afterSelectedChanged, this);
this.after('selectedChange',this._selectedChanged, this); },
},

_defPressFn : function(e) {
_bindClick : function() { this.set('selected', (this.get('selected') === 0) ? 1 : 0);

},
this.get('boundingBox').after('click',function(e){
var parent = null; _afterSelectedChanged : function(e) {
if(!this.isRoot()) { if(e.newVal) {
var parent = this.get('parent'), this._executeCallback();
selection = parent.get('selection'); }else{
if( this._executeDeselectCallback();
parent instanceof Y.ButtonGroup && // we are in a button group }
parent.get('alwaysSelected') && // there should always be at least one },
this.get('selected') === 1 && // this is selected
( _executeDeselectCallback : function(e) {
selection === this || Y.log('Y.ButtonToggle::_executeDeselectCallback');
( if(this.get(DESELECTED_CALLBACK)) {
selection instanceof Y.ArrayList && (this.get(DESELECTED_CALLBACK))();
selection.size() === 1 && }
selection.item(0) === this }
)
) // this is the only selected }, {
) { ATTRS : {
return; deselectedCallback : {
} validator : YL.isFunction
} }
this.set('selected', (this.get('selected') === 0) ? 1 : 0); }
},this); });
},

_selectedChanged : function(e) {
if(e.newVal) {
if(this.get('callback')) {
(Y.bind(this.get('callback'),this))();
}
}else{
if(this.get(DESELECTED_CALLBACK)) {
(Y.bind(this.get(DESELECTED_CALLBACK),this))();
}
}
}

}, {
ATTRS : {
deselectedCallback : {
validator : YL.isFunction
}
}
});

0 comments on commit aed7c9f

Please sign in to comment.