mirror of
https://github.com/twbs/bootstrap.git
synced 2025-02-19 16:54:24 +01:00
update buttons js for button groups
This commit is contained in:
parent
36a7eb3851
commit
b2650859d6
4
bootstrap.css
vendored
4
bootstrap.css
vendored
@ -6,7 +6,7 @@
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Designed and built with all the love in the world @twitter by @mdo and @fat.
|
||||
* Date: Sun Nov 20 20:05:48 PST 2011
|
||||
* Date: Thu Nov 24 13:45:21 PST 2011
|
||||
*/
|
||||
/* Reset.less
|
||||
* Props to Eric Meyer (meyerweb.com) for his CSS reset file. We're using an adapted version here that cuts out some of the reset HTML elements we will never need here (i.e., dfn, samp, etc).
|
||||
@ -1643,7 +1643,7 @@ footer {
|
||||
border-color: #0064cd #0064cd #003f81;
|
||||
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
.btn:active {
|
||||
.btn.active, .btn:active {
|
||||
-webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
-moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
|
2
bootstrap.min.css
vendored
2
bootstrap.min.css
vendored
@ -247,7 +247,7 @@ footer{padding-top:17px;margin-top:17px;border-top:1px solid #eee;}
|
||||
.btn{display:inline-block;padding:5px 14px 6px;font-size:13px;line-height:normal;color:#333;text-shadow:0 1px 1px rgba(255, 255, 255, 0.75);background-color:#e6e6e6;background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), color-stop(25%, #ffffff), to(#e6e6e6));background-image:-webkit-linear-gradient(#ffffff, #ffffff 25%, #e6e6e6);background-image:-moz-linear-gradient(top, #ffffff, #ffffff 25%, #e6e6e6);background-image:-ms-linear-gradient(#ffffff, #ffffff 25%, #e6e6e6);background-image:-o-linear-gradient(#ffffff, #ffffff 25%, #e6e6e6);background-image:linear-gradient(#ffffff, #ffffff 25%, #e6e6e6);background-repeat:no-repeat;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#e6e6e6', GradientType=0);border:1px solid #ccc;border-bottom-color:#bbb;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:inset 0 1px 0 rgba(255, 255, 255, 0.2),0 1px 2px rgba(0, 0, 0, 0.05);-moz-box-shadow:inset 0 1px 0 rgba(255, 255, 255, 0.2),0 1px 2px rgba(0, 0, 0, 0.05);box-shadow:inset 0 1px 0 rgba(255, 255, 255, 0.2),0 1px 2px rgba(0, 0, 0, 0.05);cursor:pointer;-webkit-transition:0.1s linear all;-moz-transition:0.1s linear all;-ms-transition:0.1s linear all;-o-transition:0.1s linear all;transition:0.1s linear all;}.btn:hover{color:#333;text-decoration:none;background-position:0 -15px;}
|
||||
.btn:focus{outline:1px dotted #666;}
|
||||
.btn.primary{color:#ffffff;text-shadow:0 -1px 0 rgba(0, 0, 0, 0.25);background-color:#0064cd;background-image:-khtml-gradient(linear, left top, left bottom, from(#049cdb), to(#0064cd));background-image:-moz-linear-gradient(top, #049cdb, #0064cd);background-image:-ms-linear-gradient(top, #049cdb, #0064cd);background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #049cdb), color-stop(100%, #0064cd));background-image:-webkit-linear-gradient(top, #049cdb, #0064cd);background-image:-o-linear-gradient(top, #049cdb, #0064cd);background-image:linear-gradient(top, #049cdb, #0064cd);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#049cdb', endColorstr='#0064cd', GradientType=0);border-color:#0064cd #0064cd #003f81;border-color:rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);}
|
||||
.btn:active{-webkit-box-shadow:inset 0 2px 4px rgba(0, 0, 0, 0.25),0 1px 2px rgba(0, 0, 0, 0.05);-moz-box-shadow:inset 0 2px 4px rgba(0, 0, 0, 0.25),0 1px 2px rgba(0, 0, 0, 0.05);box-shadow:inset 0 2px 4px rgba(0, 0, 0, 0.25),0 1px 2px rgba(0, 0, 0, 0.05);}
|
||||
.btn.active,.btn:active{-webkit-box-shadow:inset 0 2px 4px rgba(0, 0, 0, 0.25),0 1px 2px rgba(0, 0, 0, 0.05);-moz-box-shadow:inset 0 2px 4px rgba(0, 0, 0, 0.25),0 1px 2px rgba(0, 0, 0, 0.05);box-shadow:inset 0 2px 4px rgba(0, 0, 0, 0.25),0 1px 2px rgba(0, 0, 0, 0.05);}
|
||||
.btn.disabled{cursor:default;background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);filter:alpha(opacity=65);-moz-opacity:0.65;opacity:0.65;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;}
|
||||
.btn[disabled]{cursor:default;background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);filter:alpha(opacity=65);-moz-opacity:0.65;opacity:0.65;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;}
|
||||
.btn.large{padding:9px 14px 9px;font-size:15px;line-height:normal;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;}
|
||||
|
@ -26,7 +26,6 @@
|
||||
<!-- Le javascript -->
|
||||
<!-- placed up here so that the inline demos can be next to their markup -->
|
||||
<script src="http://code.jquery.com/jquery-1.7.js"></script>
|
||||
<script src="http://autobahn.tablesorter.com/jquery.tablesorter.min.js"></script>
|
||||
<script src="assets/js/google-code-prettify/prettify.js"></script>
|
||||
<script>$(function () { prettyPrint() })</script>
|
||||
<script src="../js/bootstrap-transitions.js"></script>
|
||||
@ -37,6 +36,7 @@
|
||||
<script src="../js/bootstrap-tabs.js"></script>
|
||||
<script src="../js/bootstrap-twipsy.js"></script>
|
||||
<script src="../js/bootstrap-popover.js"></script>
|
||||
<script src="../js/bootstrap-buttons.js"></script>
|
||||
<script>
|
||||
$(function () {
|
||||
|
||||
@ -138,6 +138,10 @@
|
||||
<td><a href="./javascript.html#popover">bootstrap-popover.js</a></td>
|
||||
<td>The popover plugin provides a simple interface for adding popovers to your application. It extends the <a href="#twipsy">boostrap-twipsy.js</a> plugin, so be sure to grab that file as well when including popovers in your project!</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="./javascript.html#buttons">bootstrap-buttons.js</a></td>
|
||||
<td>This plugin offers additional functionality for managing button state.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h3>Is javascript necessary?</h3>
|
||||
@ -739,6 +743,112 @@ $('.tabs a').bind('change', function (e) {
|
||||
</section>
|
||||
|
||||
|
||||
<!-- Buttons
|
||||
================================================== -->
|
||||
|
||||
<section id="buttons">
|
||||
<div class="page-header">
|
||||
<h1>Buttons <small>bootstrap-buttons.js</small></h1>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span3 columns">
|
||||
<p>This plugin offers additional functionality for managing button state.</p>
|
||||
<a href="../js/bootstrap-buttons.js" target="_blank" class="btn primary">Download</a>
|
||||
</div>
|
||||
<div class="span9 columns">
|
||||
<h3>Using bootstrap-buttons.js</h3>
|
||||
<pre class="prettyprint linenums">$('.tabs').button()</pre>
|
||||
<h3>Markup</h3>
|
||||
<p>Data attributes are integral to the button plugin. Check out the example code below for the various markup types.</p>
|
||||
<pre class="prettyprint linenums">
|
||||
<!-- Add data-toggle="button" to activate toggling on a single button -->
|
||||
<button class="btn" data-toggle="button">Single Toggle</button>
|
||||
|
||||
<!-- Add data-toggle="buttons-checkbox" for checkbox style toggling on btn-group -->
|
||||
<div class="btn-group" data-toggle="buttons-checkbox">
|
||||
<button class="btn">Left</button>
|
||||
<button class="btn">Middle</button>
|
||||
<button class="btn">Right</button>
|
||||
</div>
|
||||
|
||||
<!-- Add data-toggle="buttons-radio" for radio style toggling on btn-group -->
|
||||
<div class="btn-group" data-toggle="buttons-radio">
|
||||
<button class="btn">Left</button>
|
||||
<button class="btn">Middle</button>
|
||||
<button class="btn">Right</button>
|
||||
</div>
|
||||
</pre>
|
||||
<h3>Methods</h3>
|
||||
<h4>$().button('toggle')</h4>
|
||||
<p>Toggles push state. Gives btn the look that it's been activated.</p>
|
||||
<p><span class="label notice">Notice</span> You can enable auto toggling of a button by using the <code>data-toggle</code> attribute.</p>
|
||||
<pre class="prettyprint linenums"><button class="btn" data-toggle="button" >...</button></pre>
|
||||
<h4>$().button('loading')</h4>
|
||||
<p>Sets button state to loading - disables button and swaps text to loading text. Loading text should be defined on the button element using the data attribute <code>data-loading-text</code>.
|
||||
</p>
|
||||
<pre class="prettyprint linenums"><button class="btn" data-loading-text="loading stuff..." >...</button></pre>
|
||||
<h4>$().button('reset')</h4>
|
||||
<p>Resets button state - swaps text to original text.</p>
|
||||
<h4>$().button(string)</h4>
|
||||
<p>Resets button state - swaps text to any data defined text state.</p>
|
||||
<pre class="prettyprint linenums"><button class="btn" data-complete-text="finished!" >...</button>
|
||||
<script>
|
||||
$('.btn').button('complete')
|
||||
</scrip></pre>
|
||||
<h3>Demo</h3>
|
||||
<table class="striped-table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Stateful</td>
|
||||
<td>
|
||||
<button id="fat-btn" data-loading-text="loading..." class="btn">
|
||||
Loading State
|
||||
</button>
|
||||
<script>
|
||||
$(function() {
|
||||
var btn = $('#fat-btn').click(function () {
|
||||
btn.button('loading')
|
||||
setTimeout(function () {
|
||||
btn.button('reset')
|
||||
}, 3000)
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Single Toggle</td>
|
||||
<td>
|
||||
<button class="btn" data-toggle="button">Single Toggle</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Checkbox</td>
|
||||
<td>
|
||||
<div class="btn-group" data-toggle="buttons-checkbox">
|
||||
<button class="btn">Left</button>
|
||||
<button class="btn">Middle</button>
|
||||
<button class="btn">Right</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Radio</td>
|
||||
<td>
|
||||
<div class="btn-group" data-toggle="buttons-radio">
|
||||
<button class="btn">Left</button>
|
||||
<button class="btn">Middle</button>
|
||||
<button class="btn">Right</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
<!-- Footer
|
||||
================================================== -->
|
||||
<footer class="footer">
|
||||
|
32
js/bootstrap-buttons.js
vendored
32
js/bootstrap-buttons.js
vendored
@ -25,26 +25,36 @@
|
||||
var d = 'disabled'
|
||||
, $el = $(el)
|
||||
, data = $el.data()
|
||||
, val = $el.is('input') ? 'val' : 'html'
|
||||
|
||||
state = state + 'Text'
|
||||
data.resetText || $el.data('resetText', $el.html())
|
||||
data.resetText || $el.data('resetText', $el[val]())
|
||||
|
||||
$el.html( data[state] || $.fn.button.defaults[state] )
|
||||
$el[val]( data[state] || $.fn.button.defaults[state] )
|
||||
|
||||
state == 'loadingText' ?
|
||||
$el.addClass(d).attr(d, d) :
|
||||
$el.removeClass(d).removeAttr(d)
|
||||
setTimeout(function () {
|
||||
state == 'loadingText' ?
|
||||
$el.addClass(d).attr(d, d) :
|
||||
$el.removeClass(d).removeAttr(d)
|
||||
}, 0)
|
||||
}
|
||||
|
||||
function toggle(el) {
|
||||
$(el).toggleClass('active')
|
||||
var $el = $(el)
|
||||
, $parent = $el.parent('[data-toggle="buttons-radio"]')
|
||||
|
||||
if ($parent) {
|
||||
$parent
|
||||
.find('.active')
|
||||
.removeClass('active')
|
||||
}
|
||||
|
||||
$el.toggleClass('active')
|
||||
}
|
||||
|
||||
$.fn.button = function(options) {
|
||||
return this.each(function () {
|
||||
if (options == 'toggle') {
|
||||
return toggle(this)
|
||||
}
|
||||
if (options == 'toggle') return toggle(this)
|
||||
options && setState(this, options)
|
||||
})
|
||||
}
|
||||
@ -54,8 +64,8 @@
|
||||
}
|
||||
|
||||
$(function () {
|
||||
$('body').delegate('.btn[data-toggle]', 'click', function () {
|
||||
$(this).button('toggle')
|
||||
$('body').delegate('[data-toggle^=button]', 'click', function (e) {
|
||||
$(e.srcElement).button('toggle')
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -415,6 +415,7 @@ footer {
|
||||
.transition(.1s linear all);
|
||||
|
||||
// Active and Disabled states
|
||||
&.active,
|
||||
&:active {
|
||||
@shadow: inset 0 2px 4px rgba(0,0,0,.25), 0 1px 2px rgba(0,0,0,.05);
|
||||
.box-shadow(@shadow);
|
||||
|
Loading…
x
Reference in New Issue
Block a user