jQuery Sliding Button
Fancy sliding button jQuery plugin.
by jrdiaz
HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Slide Button Test page</title>
</head>
<body>
<div class="slideButton"> <!-- a.k.a "container" -->
<a>Sliding <span>contents</span></a> <!-- a.k.a "contents" or "A" -->
<a>Butt<span>on</span></a> <!-- a.k.a "control" or "B" -->
</div>
</body>
</html>
CSS
/**
* Slide Button Styles.
* ================================================
* (C) 2011 José Ramón Díaz - jrdiazweb@gmail.com
*
* http://3nibbles.blogspot.com/2011/07/plugin-jquery-sliding-buttons.html
*
* Slide Button CSS styles. Note that rounded borders is a CSS3 feature,
* so, it will be represented correctly in CSS3 ready browsers.
*
* Legal stuff
* You are free to use this CSS, but you must give credit or keep header intact.
* Please, tell me if you find it useful. An email will be enough.
* If you enhance this code or correct a bug, please, tell me.
*/
.slideButton { font-weight: bold; font-size: 11px; font-family: Arial } /* Container */
.slideButton a { text-decoration: none; } /* a components containers */
.slideButton .button { background-color: #FFFFFF; color: #000000; text-align: center;
cursor: pointer; text-transform: uppercase; } /* Control */
.slideButton.deployed .button { background-color: #9AFF66; color: #FFFFFF; } /* Control - Deployed state */
.slideButton .content { background-color: #36A300; color: #FFFFFF; } /* Content */
.slideButton.deployed .content { } /* Content - Deployed state */
/* Depends on contents of the content component */
.slideButton .button span { color: #9AFF66; } /* Control spans */
.slideButton.deployed .button span { color: #36A300; } /* Control spans - Deployed */
.slideButton .content span span { color: #9AFF66; } /* Content spans ...
JavaScript
/**
* jquery.slideButton-0.1.js - Slide Button plugin for jQuery
* ==========================================================
* (C) 2011 José Ramón Díaz - jrdiazweb@gmail.com
*
* http://3nibbles.blogspot.com/2011/07/plugin-jquery-sliding-buttons.html
*
* INSTANTIATION
* Any container with the .slideButton class will be initialized
* on domReady event using the options defined in object
* "slideButtonDefaults". This feature can be disabled by setting
* the variable "slideButtonAutoload" to the false value.
*
* Manual instantiation
* $('.slideButton').slideButton( [ options_object ] );
*
* OPTIONS
* - direction : 'left', Slide direction "left" = LtR, "right" = RtL
* - border : '3px', Border width == difference in height of control(>) and contents(<)
* - radius : '20px', Border radius of the slideButton
* - height : '36px', Maximum height of the slideButton. Includes all borders
* - width : '70px', Minimum width. Applied to control
* - deployedWidth: '225px', Maximum width. Applied to container and deployed contents
* - inAnimation : 'swing', Function used to deploy (slide in) the elements. For more functions needs the easing packs
* - outAnimation : 'swing', Function used to hide (slide out) the elements. For more functions needs the easing packs
* - inSpeed : 500, deploy effect duration
* - outSpeed : 300, hide effect duration
* - onClick : null, button click trigger callback function
* - onBlur : null, blur (slide out) trigger callback function
* - onDeploy : null, deploy (slide in) trigger callback function
* - onHide : null, hide (end of slide out) trigger callback function
*
* API
* - show() Deploys the sliding contents
* - hide() Hides the sliding contents
* - lock() Locks the sliding contents open
* - locked Indicates that the control is...