YUI Button Lite

Do you want the cool clean look of the new YUI Button component, but without all the seedy overhead of split buttons or button groups or components that shouldn’t even be pigeonholed into a button component to begin with? Keep in mind that this app…


This content originally appeared on Zach Leatherman and was authored by Zach Leatherman

Do you want the cool clean look of the new YUI Button component, but without all the seedy overhead of split buttons or button groups or components that shouldn’t even be pigeonholed into a button component to begin with? Keep in mind that this approach only works for the method called “Using pre-defined Button Control HTML.

Well, here’s the trick to do it.

Create the button as the YUI Button Examples and Documentation say to do so. Include the Button CSS file button/assets/button.css. But just don’t include the YUI JavaScript file button-beta[-min].js.

Instead, use the following JavaScript to replace the functions for button coloring for hover, focus, and active.

YAHOO.util.Event.addListener( window, 'load', function( e )
{
    var yuiButtons = YAHOO.util.Dom.getElementsByClassName( 'yuibutton', 'span' );
    YAHOO.util.Event.addListener( yuiButtons, 'mouseover', function( e )
    {
        YAHOO.util.Dom.addClass( this, 'hover' );
    } );
    YAHOO.util.Event.addListener( yuiButtons, 'mouseout', function( e )
    {
        YAHOO.util.Dom.removeClass( this, 'hover' );
    } );
    YAHOO.util.Event.addListener( yuiButtons, 'mousedown', function( e )
    {
        YAHOO.util.Dom.addClass( this, 'active' );
    } );
    YAHOO.util.Event.addListener( yuiButtons, 'mouseup', function( e )
    {
        YAHOO.util.Dom.removeClass( this, 'active' );
    } );
    YAHOO.util.Event.addListener( yuiButtons, 'focus', function( e )
    {
        YAHOO.util.Dom.addClass( this, 'focus' );
    } );
    YAHOO.util.Event.addListener( yuiButtons, 'blur', function( e )
    {
        YAHOO.util.Dom.removeClass( this, 'focus' );
    } );
} );

If you’re just using the standard buttons anyway, you’re going to see a speed improvement in performance on hover color changes.


This content originally appeared on Zach Leatherman and was authored by Zach Leatherman


Print Share Comment Cite Upload Translate Updates
APA

Zach Leatherman | Sciencx (2007-03-23T05:00:00+00:00) YUI Button Lite. Retrieved from https://www.scien.cx/2007/03/23/yui-button-lite/

MLA
" » YUI Button Lite." Zach Leatherman | Sciencx - Friday March 23, 2007, https://www.scien.cx/2007/03/23/yui-button-lite/
HARVARD
Zach Leatherman | Sciencx Friday March 23, 2007 » YUI Button Lite., viewed ,<https://www.scien.cx/2007/03/23/yui-button-lite/>
VANCOUVER
Zach Leatherman | Sciencx - » YUI Button Lite. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2007/03/23/yui-button-lite/
CHICAGO
" » YUI Button Lite." Zach Leatherman | Sciencx - Accessed . https://www.scien.cx/2007/03/23/yui-button-lite/
IEEE
" » YUI Button Lite." Zach Leatherman | Sciencx [Online]. Available: https://www.scien.cx/2007/03/23/yui-button-lite/. [Accessed: ]
rf:citation
» YUI Button Lite | Zach Leatherman | Sciencx | https://www.scien.cx/2007/03/23/yui-button-lite/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.