diff --git a/.gitignore b/.gitignore index 496ee2ca6a..38ad090992 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.DS_Store \ No newline at end of file +.DS_Store +js/min \ No newline at end of file diff --git a/Makefile b/Makefile index b3dce89ac4..e5c083ae6f 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,10 @@ -VERSION=1.2.0 +VERSION=2.0.0 DATE=$(shell DATE) BOOTSTRAP = ./bootstrap.css BOOTSTRAP_MIN = ./bootstrap.min.css BOOTSTRAP_LESS = ./lib/bootstrap.less LESS_COMPESSOR ?= `which lessc` +UGLIFY_JS ?= `which uglifyjs` WATCHR ?= `which watchr` build: @@ -18,6 +19,24 @@ build: echo "You can install it by running: npm install less -g"; \ fi +uglify: + @@if test ! -z ${UGLIFY_JS}; then \ + mkdir -p js/min; \ + uglifyjs -o js/min/bootstrap-accordion.js js/bootstrap-accordion.js;\ + uglifyjs -o js/min/bootstrap-alerts.js js/bootstrap-alerts.js;\ + uglifyjs -o js/min/bootstrap-buttons.js js/bootstrap-buttons.js;\ + uglifyjs -o js/min/bootstrap-dropdown.js js/bootstrap-dropdown.js;\ + uglifyjs -o js/min/bootstrap-modal.js js/bootstrap-modal.js;\ + uglifyjs -o js/min/bootstrap-popover.js js/bootstrap-popover.js;\ + uglifyjs -o js/min/bootstrap-scrollspy.js js/bootstrap-scrollspy.js;\ + uglifyjs -o js/min/bootstrap-tabs.js js/bootstrap-tabs.js;\ + uglifyjs -o js/min/bootstrap-transitions.js js/bootstrap-transitions.js;\ + uglifyjs -o js/min/bootstrap-twipsy.js js/bootstrap-twipsy.js;\ + else \ + echo "You must have the UGLIFYJS minifier installed in order to minify Bootstrap's js."; \ + echo "You can install it by running: npm install uglify-js -g"; \ + fi + watch: @@if test ! -z ${WATCHR}; then \ echo "Watching less files..."; \ diff --git a/README.md b/README.md index ad51b16fc1..fd97265840 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Here's what the LESS version looks like: ``` -Or if you prefer, the standard css way: +Or if you prefer, the standard CSS way: ``` html @@ -72,7 +72,7 @@ http://groups.google.com/group/twitter-bootstrap Developers ---------- -We have included a makefile with convenience methods for working with the bootstrap library. +We have included a makefile with convenience methods for working with the Bootstrap library. + **build** - `make build` This will run the less compiler on the bootstrap lib and generate a bootstrap.css and bootstrap.min.css file. diff --git a/bootstrap.css b/bootstrap.css index 87e12fca0b..e7c0a732f2 100644 --- a/bootstrap.css +++ b/bootstrap.css @@ -1,16 +1,13 @@ /*! - * Bootstrap v1.2.0 + * Bootstrap v2.0.0 * * Copyright 2011 Twitter, Inc * Licensed under the Apache License v2.0 * http://www.apache.org/licenses/LICENSE-2.0 * * Designed and built with all the love in the world @twitter by @mdo and @fat. - * Date: Tue Nov 29 22:34:51 PST 2011 + * Date: Tue Nov 29 22:35:45 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). - * ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */ html, body { margin: 0; padding: 0; @@ -170,16 +167,6 @@ textarea { overflow: auto; vertical-align: top; } -/* Variables.less - * Variables to customize the look and feel of Bootstrap - * ----------------------------------------------------- */ -/* Mixins.less - * Snippets of reusable CSS to develop faster and keep code readable - * ----------------------------------------------------------------- */ -/* - * Scaffolding - * Basic and global styles for generating a grid system, structural layout, and page templates - * ------------------------------------------------------------------------------------------- */ body { margin: 0; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; @@ -344,9 +331,6 @@ a:hover { .offset11 { margin-left: 900px; } -/* Typography.less - * Headings, body text, lists, code, and more for a versatile and durable typography system - * ---------------------------------------------------------------------------------------- */ p { margin-bottom: 9px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; @@ -534,9 +518,6 @@ pre code { padding: 0; background-color: transparent; } -/* Forms.less - * Base styles for various input types, form layouts, and states - * ------------------------------------------------------------- */ form { margin-bottom: 18px; } @@ -676,7 +657,7 @@ select.span2, .uneditable-input.span2 { display: inline-block; float: none; - width: 150px; + width: 130px; margin-left: 0; } input.span3, @@ -685,7 +666,7 @@ select.span3, .uneditable-input.span3 { display: inline-block; float: none; - width: 250px; + width: 210px; margin-left: 0; } input.span4, @@ -694,7 +675,7 @@ select.span4, .uneditable-input.span4 { display: inline-block; float: none; - width: 350px; + width: 290px; margin-left: 0; } input.span5, @@ -703,7 +684,7 @@ select.span5, .uneditable-input.span5 { display: inline-block; float: none; - width: 450px; + width: 370px; margin-left: 0; } input.span6, @@ -712,7 +693,7 @@ select.span6, .uneditable-input.span6 { display: inline-block; float: none; - width: 550px; + width: 450px; margin-left: 0; } input.span7, @@ -721,7 +702,7 @@ select.span7, .uneditable-input.span7 { display: inline-block; float: none; - width: 650px; + width: 530px; margin-left: 0; } input.span8, @@ -730,7 +711,7 @@ select.span8, .uneditable-input.span8 { display: inline-block; float: none; - width: 750px; + width: 610px; margin-left: 0; } input.span9, @@ -739,7 +720,7 @@ select.span9, .uneditable-input.span9 { display: inline-block; float: none; - width: 850px; + width: 690px; margin-left: 0; } input.span10, @@ -748,7 +729,7 @@ select.span10, .uneditable-input.span10 { display: inline-block; float: none; - width: 950px; + width: 770px; margin-left: 0; } input.span11, @@ -757,7 +738,7 @@ select.span11, .uneditable-input.span11 { display: inline-block; float: none; - width: 1050px; + width: 850px; margin-left: 0; } input.span12, @@ -766,7 +747,7 @@ select.span12, .uneditable-input.span12 { display: inline-block; float: none; - width: 1150px; + width: 930px; margin-left: 0; } input.span13, @@ -775,7 +756,7 @@ select.span13, .uneditable-input.span13 { display: inline-block; float: none; - width: 1250px; + width: 1010px; margin-left: 0; } input.span14, @@ -784,7 +765,7 @@ select.span14, .uneditable-input.span14 { display: inline-block; float: none; - width: 1350px; + width: 1090px; margin-left: 0; } input.span15, @@ -793,7 +774,7 @@ select.span15, .uneditable-input.span15 { display: inline-block; float: none; - width: 1450px; + width: 1170px; margin-left: 0; } input.span16, @@ -802,7 +783,7 @@ select.span16, .uneditable-input.span16 { display: inline-block; float: none; - width: 1550px; + width: 1250px; margin-left: 0; } input[disabled], @@ -999,10 +980,6 @@ form .clearfix.success .input-prepend .add-on, form .clearfix.success .input-app .horizontal-form .form-actions { padding-left: 150px; } -/* - * Tables.less - * Tables for, you guessed it, tabular data - * ---------------------------------------- */ table { width: 100%; margin-bottom: 18px; @@ -1193,9 +1170,7 @@ table { .headerSortDown.purple { background-color: lighten(@purple, 40%); } -}*//* Patterns.less - * Repeatable UI elements outside the base styles provided from the scaffolding - * ---------------------------------------------------------------------------- */ +}*/ .navbar { height: 40px; overflow: visible; @@ -1638,7 +1613,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); @@ -1874,6 +1849,19 @@ button.btn::-moz-focus-inner, input[type=submit].btn::-moz-focus-inner { .fade.in { opacity: 1; } +.collapse { + -webkit-transition: height 0.35s ease; + -moz-transition: height 0.35s ease; + -ms-transition: height 0.35s ease; + -o-transition: height 0.35s ease; + transition: height 0.35s ease; + position: relative; + overflow: hidden; + height: 0; +} +.collapse.in { + height: auto; +} .label { padding: 1px 3px 2px; font-size: 9.75px; @@ -2264,11 +2252,11 @@ button.btn::-moz-focus-inner, input[type=submit].btn::-moz-focus-inner { visibility: visible; padding: 5px; font-size: 11px; - filter: alpha(opacity=80); - -moz-opacity: 0.8; - opacity: 0.8; + filter: alpha(opacity=0); + -moz-opacity: 0; + opacity: 0; } -.twipsy.fade.in { +.twipsy.in { filter: alpha(opacity=80); -moz-opacity: 0.8; opacity: 0.8; @@ -2439,9 +2427,6 @@ button.btn::-moz-focus-inner, input[type=submit].btn::-moz-focus-inner { -moz-box-shadow: 0 1px 4px rgba(0, 105, 214, 0.25); box-shadow: 0 1px 4px rgba(0, 105, 214, 0.25); } -/* Responsive.less - * For phone and tablet devices - * ------------------------------------------------------------- */ @media (max-width: 480px) { .container { width: auto; diff --git a/bootstrap.min.css b/bootstrap.min.css index 32d4a9967a..fdd3db70ba 100644 --- a/bootstrap.min.css +++ b/bootstrap.min.css @@ -111,21 +111,21 @@ input[type=file]:focus,input[type=checkbox]:focus,select:focus{-webkit-box-shado .input-xlarge{width:270px;} .input-xxlarge{width:530px;} input.span1,textarea.span1,select.span1,.uneditable-input.span1{display:inline-block;float:none;width:50px;margin-left:0;} -input.span2,textarea.span2,select.span2,.uneditable-input.span2{display:inline-block;float:none;width:150px;margin-left:0;} -input.span3,textarea.span3,select.span3,.uneditable-input.span3{display:inline-block;float:none;width:250px;margin-left:0;} -input.span4,textarea.span4,select.span4,.uneditable-input.span4{display:inline-block;float:none;width:350px;margin-left:0;} -input.span5,textarea.span5,select.span5,.uneditable-input.span5{display:inline-block;float:none;width:450px;margin-left:0;} -input.span6,textarea.span6,select.span6,.uneditable-input.span6{display:inline-block;float:none;width:550px;margin-left:0;} -input.span7,textarea.span7,select.span7,.uneditable-input.span7{display:inline-block;float:none;width:650px;margin-left:0;} -input.span8,textarea.span8,select.span8,.uneditable-input.span8{display:inline-block;float:none;width:750px;margin-left:0;} -input.span9,textarea.span9,select.span9,.uneditable-input.span9{display:inline-block;float:none;width:850px;margin-left:0;} -input.span10,textarea.span10,select.span10,.uneditable-input.span10{display:inline-block;float:none;width:950px;margin-left:0;} -input.span11,textarea.span11,select.span11,.uneditable-input.span11{display:inline-block;float:none;width:1050px;margin-left:0;} -input.span12,textarea.span12,select.span12,.uneditable-input.span12{display:inline-block;float:none;width:1150px;margin-left:0;} -input.span13,textarea.span13,select.span13,.uneditable-input.span13{display:inline-block;float:none;width:1250px;margin-left:0;} -input.span14,textarea.span14,select.span14,.uneditable-input.span14{display:inline-block;float:none;width:1350px;margin-left:0;} -input.span15,textarea.span15,select.span15,.uneditable-input.span15{display:inline-block;float:none;width:1450px;margin-left:0;} -input.span16,textarea.span16,select.span16,.uneditable-input.span16{display:inline-block;float:none;width:1550px;margin-left:0;} +input.span2,textarea.span2,select.span2,.uneditable-input.span2{display:inline-block;float:none;width:130px;margin-left:0;} +input.span3,textarea.span3,select.span3,.uneditable-input.span3{display:inline-block;float:none;width:210px;margin-left:0;} +input.span4,textarea.span4,select.span4,.uneditable-input.span4{display:inline-block;float:none;width:290px;margin-left:0;} +input.span5,textarea.span5,select.span5,.uneditable-input.span5{display:inline-block;float:none;width:370px;margin-left:0;} +input.span6,textarea.span6,select.span6,.uneditable-input.span6{display:inline-block;float:none;width:450px;margin-left:0;} +input.span7,textarea.span7,select.span7,.uneditable-input.span7{display:inline-block;float:none;width:530px;margin-left:0;} +input.span8,textarea.span8,select.span8,.uneditable-input.span8{display:inline-block;float:none;width:610px;margin-left:0;} +input.span9,textarea.span9,select.span9,.uneditable-input.span9{display:inline-block;float:none;width:690px;margin-left:0;} +input.span10,textarea.span10,select.span10,.uneditable-input.span10{display:inline-block;float:none;width:770px;margin-left:0;} +input.span11,textarea.span11,select.span11,.uneditable-input.span11{display:inline-block;float:none;width:850px;margin-left:0;} +input.span12,textarea.span12,select.span12,.uneditable-input.span12{display:inline-block;float:none;width:930px;margin-left:0;} +input.span13,textarea.span13,select.span13,.uneditable-input.span13{display:inline-block;float:none;width:1010px;margin-left:0;} +input.span14,textarea.span14,select.span14,.uneditable-input.span14{display:inline-block;float:none;width:1090px;margin-left:0;} +input.span15,textarea.span15,select.span15,.uneditable-input.span15{display:inline-block;float:none;width:1170px;margin-left:0;} +input.span16,textarea.span16,select.span16,.uneditable-input.span16{display:inline-block;float:none;width:1250px;margin-left:0;} input[disabled],select[disabled],textarea[disabled],input[readonly],select[readonly],textarea[readonly]{background-color:#f5f5f5;border-color:#ddd;cursor:not-allowed;} form .clearfix.error>label,form .clearfix.error .help-block,form .clearfix.error .help-inline{color:#b94a48;} form .clearfix.error input,form .clearfix.error textarea{color:#b94a48;border-color:#ee5f5b;}form .clearfix.error input:focus,form .clearfix.error textarea:focus{border-color:#e9322d;-webkit-box-shadow:0 0 6px #f8b9b7;-moz-box-shadow:0 0 6px #f8b9b7;box-shadow:0 0 6px #f8b9b7;} @@ -214,7 +214,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;} @@ -245,6 +245,7 @@ button.btn::-moz-focus-inner,input[type=submit].btn::-moz-focus-inner{padding:0; .alert-message.block-message.info{background-color:#ddf4fb;border-color:#c6edf9;} .well{min-height:20px;padding:19px;margin-bottom:20px;background-color:#f5f5f5;border:1px solid #eee;border:1px solid rgba(0, 0, 0, 0.05);-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.05);-moz-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.05);box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.05);}.well blockquote{border-color:#ddd;border-color:rgba(0, 0, 0, 0.15);} .fade{-webkit-transition:opacity 0.15s linear;-moz-transition:opacity 0.15s linear;-ms-transition:opacity 0.15s linear;-o-transition:opacity 0.15s linear;transition:opacity 0.15s linear;opacity:0;}.fade.in{opacity:1;} +.collapse{-webkit-transition:height 0.35s ease;-moz-transition:height 0.35s ease;-ms-transition:height 0.35s ease;-o-transition:height 0.35s ease;transition:height 0.35s ease;position:relative;overflow:hidden;height:0;}.collapse.in{height:auto;} .label{padding:1px 3px 2px;font-size:9.75px;font-weight:bold;color:#ffffff;text-transform:uppercase;background-color:#bfbfbf;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;}.label.important{background-color:#c43c35;} .label.warning{background-color:#f89406;} .label.success{background-color:#46a546;} @@ -296,7 +297,7 @@ button.btn::-moz-focus-inner,input[type=submit].btn::-moz-focus-inner{padding:0; .modal-footer{padding:14px 15px 15px;margin-bottom:0;background-color:#f5f5f5;border-top:1px solid #ddd;-webkit-border-radius:0 0 6px 6px;-moz-border-radius:0 0 6px 6px;border-radius:0 0 6px 6px;-webkit-box-shadow:inset 0 1px 0 #ffffff;-moz-box-shadow:inset 0 1px 0 #ffffff;box-shadow:inset 0 1px 0 #ffffff;zoom:1;}.modal-footer:before,.modal-footer:after{display:table;*display:inline;content:"";zoom:1;} .modal-footer:after{clear:both;} .modal-footer .btn{float:right;margin-left:5px;} -.twipsy{position:absolute;z-index:1000;display:block;visibility:visible;padding:5px;font-size:11px;filter:alpha(opacity=80);-moz-opacity:0.8;opacity:0.8;}.twipsy.fade.in{filter:alpha(opacity=80);-moz-opacity:0.8;opacity:0.8;} +.twipsy{position:absolute;z-index:1000;display:block;visibility:visible;padding:5px;font-size:11px;filter:alpha(opacity=0);-moz-opacity:0;opacity:0;}.twipsy.in{filter:alpha(opacity=80);-moz-opacity:0.8;opacity:0.8;} .twipsy.above .twipsy-arrow{bottom:0;left:50%;margin-left:-5px;border-left:5px solid transparent;border-right:5px solid transparent;border-top:5px solid #000000;} .twipsy.left .twipsy-arrow{top:50%;right:0;margin-top:-5px;border-top:5px solid transparent;border-bottom:5px solid transparent;border-left:5px solid #000000;} .twipsy.below .twipsy-arrow{top:0;left:50%;margin-left:-5px;border-left:5px solid transparent;border-right:5px solid transparent;border-bottom:5px solid #000000;} diff --git a/docs/assets/css/docs.css b/docs/assets/css/docs.css index 6c57fddabd..ec3cd83cb2 100644 --- a/docs/assets/css/docs.css +++ b/docs/assets/css/docs.css @@ -330,6 +330,13 @@ body > .navbar-fixed .brand:hover { margin-left: 10px; } +/* scrollspy docs */ + +.scrollspy-example { + overflow: auto; + height: 200px; + position: relative; +} /* Popover docs -------------------------------------------------- */ @@ -492,3 +499,19 @@ h2 + table { } } +#accordion dt a{ + display:block; + padding: 9px 15px; + line-height: 1; + background-color: whiteSmoke; + border: 1px solid #EEE; + border-top-color: #fff; +} + +#accordion dt:first-child a { + border-top-color:#eee; +} + +#accordion dd p { + padding: 10px; +} diff --git a/docs/base-css.html b/docs/base-css.html index 48704cbd49..bab55f0e44 100644 --- a/docs/base-css.html +++ b/docs/base-css.html @@ -37,7 +37,7 @@
  • Scaffolding
  • Base CSS
  • Components
  • -
  • Javascript
  • +
  • Javascript plugins
  • Using LESS
  • diff --git a/docs/javascript.html b/docs/javascript.html index a962e043c8..2db37a9fe1 100644 --- a/docs/javascript.html +++ b/docs/javascript.html @@ -22,6 +22,40 @@ + + + + + + + + + + + + + + + + + + @@ -44,26 +78,6 @@ - -
    @@ -101,11 +115,11 @@ Our Modal plugin is a super slim take on the traditional modal js plugin! We took special care to include only the bare functionality that we require at twitter. - bootstrap-alerts.js + bootstrap-alert.js The alert plugin is a super tiny class for adding close functionality to alerts. - bootstrap-dropdown.js + bootstrap-dropdown.js This plugin is for adding dropdown interaction to the bootstrap navbar or tabbed navigations. @@ -113,7 +127,7 @@ The ScrollSpy plugin is for adding an auto updating nav based on scroll position to the bootstrap navbar. - bootstrap-tabs.js + bootstrap-tab.js This plugin adds quick, dynamic tab and pill functionality for cycling through local content. @@ -124,6 +138,14 @@ bootstrap-popover.js The popover plugin provides a simple interface for adding popovers to your application. It extends the boostrap-twipsy.js plugin, so be sure to grab that file as well when including popovers in your project! + + bootstrap-button.js + This plugin offers additional functionality for managing button state. + + + bootstrap-collapse.js + The collapse plugin offers simple, generic collapsible element support for making accordions and other collapsible ui components. +

    Is javascript necessary?

    @@ -149,7 +171,7 @@

    Using bootstrap-modal

    -
    $('#my-modal').modal(options)
    +
    $('#myModal').modal(options)

    Options

    @@ -164,49 +186,45 @@ - + - + - +
    backdrop booleanfalsetrue Includes a modal-backdrop element
    keyboard booleanfalsetrue Closes the modal when escape key is pressed
    show booleanfalsetrue Opens modal on class initialization

    Markup

    -

    You can activate modals on your page easily without having to write a single line of javascript. Just give an element a data-controls-modal attribute which corresponds to a modal element id, and when clicked, it will launch your modal. To add modal options, just include them as data attributes as well.

    +

    You can activate modals on your page easily without having to write a single line of javascript. Just set data-toggle="modal" on a controller element with a data-target="#foo" or href="#foo" which corresponds to a modal element id, and when clicked, it will launch your modal. To add modal options, just include them as additoinal data attributes.

    -<a class="btn" data-controls-modal="my-modal" data-backdrop="true" >Launch Modal</a>
    +<a class="btn" data-toggle="modal" href="#myModal" >Launch Modal</a>
     
    -

    Notice If you want your modal to animate in and out, just add a .fade class to your .modal element (refer to the demo to see this in action).

    +

    Notice If you want your modal to animate in and out, just add a .fade class to the .modal element (refer to the demo to see this in action).

    Methods

    .modal(options)

    Activates your content as a modal. Accepts an optional options object.

    -$('#my-modal').modal({
    -  closeOnEscape: true
    +$('#myModal').modal({
    +  keyboard: false
     })

    .modal('toggle')

    Manually toggles a modal.

    -
    $('#my-modal').modal('toggle')
    +
    $('#myModal').modal('toggle')

    .modal('show')

    Manually opens a modal.

    -
    $('#my-modal').modal('show')
    +
    $('#myModal').modal('show')

    .modal('hide')

    Manually hides a modal.

    -
    $('#my-modal').modal('hide')
    -

    .modal(true)

    -

    Returns an elements modal class instance.

    -
    $('#my-modal').modal(true)
    -

    Notice Alternatively, this can be retrieved with $().data('modal').

    +
    $('#myModal').modal('hide')

    Events

    Bootstrap's modal class exposes a few events for hooking into modal functionality.

    @@ -237,14 +255,14 @@ $('#my-modal').modal({
    -$('#my-modal').bind('hidden', function () {
    +$('#myModal').bind('hidden', function () {
       // do something ...
     })

    Demo

    -
    @@ -275,14 +296,14 @@ $('#my-modal').bind('hidden', function () {

    Using boostrap-dropdown.js

    -
    $('#navbar').dropdown()
    +
    $('.dropdown-toggle').dropdown()

    Markup

    -

    To quickly add dropdown functionality to any nav element, use the data-dropdown attribute. Any valid bootstrap dropdown will automatically be activated.

    +

    To quickly add dropdown functionality to any element just add data-toggle="dropdown". Any valid bootstrap dropdown will automatically be activated.

     <ul class="tabs">
       <li class="active"><a href="#">Home</a></li>
    -  <li class="dropdown" data-dropdown="true" >
    -    <a href="#" class="dropdown-toggle">Dropdown</a>
    +  <li class="dropdown">
    +    <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>
         <ul class="dropdown-menu">
           <li><a href="#">Secondary link</a></li>
           <li><a href="#">Something else here</a></li>
    @@ -310,7 +331,7 @@ $('#my-modal').bind('hidden', function () {
                     
                     
    @@ -375,23 +435,28 @@ $('#my-modal').bind('hidden', function () {

    This plugin adds quick, dynamic tab and pill functionality.

    - Download + Download
    -

    Using boostrap-tabs.js

    -
    $('.tabs').tabs()
    +

    Using boostrap-tab.js

    +
    $('#myTab').tab('show')

    Markup

    -

    You can activate a tab or pill navigation without writing any javascript by simply giving them a data-tabs or data-pills attribute.

    -
     <ul class="tabs" data-tabs="tabs" >...</ul>
    +

    You can activate a tab or pill navigation without writing any javascript by simply specifying data-toggle="tab" or data-toggle="pill" on an element.

    +
    +<ul class="tabs">
    +  <li><a href="#home" data-toggle="tab">Home</a></li>
    +  <li><a href="#profile" data-toggle="tab">Profile</a></li>
    +  <li><a href="http://twitter.com/fat">twitter</a></li>
    +</ul>

    Methods

    -

    $().tabs or $().pills

    +

    $().tab

    - Activates tab and pill functionality for a given container. Tab links should reference id's in the document. + Activates tab functionality for a given element controller. Tab should have either a `data-target` or an `href` referencing a node in the dom.

     <ul class="tabs">
    @@ -410,31 +475,67 @@ $('#my-modal').bind('hidden', function () {
     
     <script>
       $(function () {
    -    $('.tabs').tabs()
    +    $('.tabs a:last').tab('show')
       })
     </script>

    +

    Events

    + + + + + + + + + + + + + + + + + +
    EventDescription
    showThis event fires on tab show, but before the new tab has been shown. Use event.target and event.relatedTarget to target the active tab and the previous active tab (if available) respectively.
    showThis event fires on tab show after a tab has been shown. Use event.target and event.relatedTarget to target the active tab and the previous active tab (if available) respectively.
    + +
    +$('a[data-toggle="tab"]').bind('shown', function (e) {
    +  e.target // activated tab
    +  e.relatedTarget // previous tab
    +})

    Demo

    -
    - -
    -
    -

    Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.

    -
    -
    -

    Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid. Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco ad vinyl cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.

    -
    -
    -

    Banksy do proident, brooklyn photo booth delectus sunt artisan sed organic exercitation eiusmod four loko. Quis tattooed iphone esse aliqua. Master cleanse vero fixie mcsweeney's. Ethical portland aute, irony food truck pitchfork lomo eu anim. Aesthetic blog DIY, ethical beard leggings tofu consequat whatever cardigan nostrud. Helvetica you probably haven't heard of them carles, marfa veniam occaecat lomo before they sold out in shoreditch scenester sustainable thundercats. Consectetur tofu craft beer, mollit brunch fap echo park pitchfork mustache dolor.

    -
    -
    -

    Sunt qui biodiesel mollit officia, fanny pack put a bird on it thundercats seitan squid ad wolf bicycle rights blog. Et aute readymade farm-to-table carles 8-bit, nesciunt nulla etsy adipisicing organic ea. Master cleanse mollit high life, next level Austin nesciunt american apparel twee mustache adipisicing reprehenderit hoodie portland irony. Aliqua tofu quinoa +1 commodo eiusmod. High life williamsburg cupidatat twee homo leggings. Four loko vinyl DIY consectetur nisi, marfa retro keffiyeh vegan. Fanny pack viral retro consectetur gentrify fap.

    -
    + +
    +
    +

    Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.

    +
    +
    +

    Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid. Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco ad vinyl cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.

    +
    +
    +

    Banksy do proident, brooklyn photo booth delectus sunt artisan sed organic exercitation eiusmod four loko. Quis tattooed iphone esse aliqua. Master cleanse vero fixie mcsweeney's. Ethical portland aute, irony food truck pitchfork lomo eu anim. Aesthetic blog DIY, ethical beard leggings tofu consequat whatever cardigan nostrud. Helvetica you probably haven't heard of them carles, marfa veniam occaecat lomo before they sold out in shoreditch scenester sustainable thundercats. Consectetur tofu craft beer, mollit brunch fap echo park pitchfork mustache dolor.

    +
    +
    +

    Sunt qui biodiesel mollit officia, fanny pack put a bird on it thundercats seitan squid ad wolf bicycle rights blog. Et aute readymade farm-to-table carles 8-bit, nesciunt nulla etsy adipisicing organic ea. Master cleanse mollit high life, next level Austin nesciunt american apparel twee mustache adipisicing reprehenderit hoodie portland irony. Aliqua tofu quinoa +1 commodo eiusmod. High life williamsburg cupidatat twee homo leggings. Four loko vinyl DIY consectetur nisi, marfa retro keffiyeh vegan. Fanny pack viral retro consectetur gentrify fap.

    +
    + +
    @@ -473,36 +574,12 @@ $('#my-modal').bind('hidden', function () { true apply a css fade transition to the tooltip - - delayIn - number - 0 - delay before showing tooltip (ms) - - - delayOut - number - 0 - delay before hiding tooltip (ms) - - - fallback - string - '' - text to use when no tooltip title is present - placement string 'above' how to position the tooltip - above | below | left | right - - html - boolean - false - allows html content within tooltip - live boolean @@ -515,20 +592,27 @@ $('#my-modal').bind('hidden', function () { 0 pixel offset of tooltip from target element - - title - string | function - 'title' - attribute or method for retrieving title text - trigger string 'hover' how tooltip is triggered - hover | focus | manual + + delay + number | object + 0 + +

    delay showing/hiding the tooltip (ms)

    +

    If a number is supplied, delay is applied to both hide/show

    +

    Object structure is: delay: { show: 500, hide: 100 }

    + + +

    Notice Individual twipsy instance options can alternatively be specified through the use of data attributes.

    +

    Markup

    + For performance reasons, the Twipsy and Popover data-apis are opt in. If you would like to use them just set the live flag to true, however we recommend you know what you are doing if you do that. :)

    Methods

    $().twipsy(options)

    Attaches a twipsy handler to an element collection.

    @@ -538,22 +622,11 @@ $('#my-modal').bind('hidden', function () {

    .twipsy('hide')

    Hides an elements twipsy.

    $('#element').twipsy('hide')
    -

    .twipsy(true)

    -

    Returns an elements twipsy class instance.

    -
    $('#element').twipsy(true)
    -

    Notice Alternatively, this can be retrieved with $().data('twipsy').

    Demo

    Tight pants next level keffiyeh you probably haven't heard of them. Photo booth beard raw denim letterpress vegan messenger bag stumptown. Farm-to-table seitan, mcsweeney's fixie sustainable quinoa 8-bit american apparel have a terry richardson vinyl chambray. Beard stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel williamsburg marfa, four loko mcsweeney's cleanse vegan chambray. A really ironic artisan whatever keytar, scenester farm-to-table banksy Austin twitter handle freegan cred raw denim single-origin coffee viral.

    -
    @@ -591,34 +664,16 @@ $('#my-modal').bind('hidden', function () { apply a css fade transition to the tooltip - delayIn - number + delay + number | object 0 - delay before showing tooltip (ms) - - - delayOut - number - 0 - delay before hiding tooltip (ms) - - - fallback - string - '' - text to use when no tooltip title is present + delay before showing/hiding the tooltip (ms) placement string 'right' - how to position the tooltip - above | below | left | right - - - html - boolean - false - allows html content within tooltip + how to position the popover - above | below | left | right live @@ -632,18 +687,6 @@ $('#my-modal').bind('hidden', function () { 0 pixel offset of tooltip from target element - - title - string | function - 'title' - attribute or method for retrieving title text - - - content - string | function - 'data-content' - attribute or method for retrieving content text - trigger string @@ -652,6 +695,11 @@ $('#my-modal').bind('hidden', function () { +

    Notice Individual popover instance options can alternatively be specified through the use of data attributes.

    +

    Markup

    +

    + For performance reasons, the Twipsy and Popover data-apis are opt in. If you would like to use them just set the live flag to true, however we recommend you know what you are doing if you do that. :) +

    Methods

    $().popover(options)

    Initializes popovers for an element collection.

    @@ -663,28 +711,17 @@ $('#my-modal').bind('hidden', function () {
    $('#element').popover('hide')

    Demo

    hover for popover - - -
    +
    @@ -695,7 +732,8 @@ $('#my-modal').bind('hidden', function () {

    Using bootstrap-alerts.js

    $(".alert-message").alert()

    Markup

    -

    Just add a data-alert attribute to your alert messages to automatically give them close functionality.

    +

    Just add data-dismiss="alert" to your close button to automatically give an alert close functionality.

    +
    <a class="close" data-dismiss="alert" href="#">&times;</a>

    Methods

    $().alert()

    Wraps all alerts with close functionality. To have your alerts animate out when closed, make sure they have the .fade and .in class already applied to them.

    @@ -703,12 +741,12 @@ $('#my-modal').bind('hidden', function () {

    Closes an alert.

    $(".alert-message").alert('close')

    Demo

    -
    - × +
    + ×

    Holy guacamole! Best check yo self, you’re not looking too good.

    -
    - × +
    + ×

    Oh snap! You got an error! Change this and that and try again. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum.

    Take this action Or do this @@ -719,6 +757,259 @@ $('#my-modal').bind('hidden', function () {
    + + +
    + +
    +
    +

    This plugin offers additional functionality for managing button state.

    + Download +
    +
    +

    Using bootstrap-button.js

    +
    $('.tabs').button()
    +

    Markup

    +

    Data attributes are integral to the button plugin. Check out the example code below for the various markup types.

    +
    +<!-- 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>
    +
    +

    Methods

    +

    $().button('toggle')

    +

    Toggles push state. Gives btn the look that it's been activated.

    +

    Notice You can enable auto toggling of a button by using the data-toggle attribute.

    +
    <button class="btn" data-toggle="button" >...</button>
    +

    $().button('loading')

    +

    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 data-loading-text. +

    +
    <button class="btn" data-loading-text="loading stuff..." >...</button>
    +

    $().button('reset')

    +

    Resets button state - swaps text to original text.

    +

    $().button(string)

    +

    Resets button state - swaps text to any data defined text state.

    +
    <button class="btn" data-complete-text="finished!" >...</button>
    +<script>
    +  $('.btn').button('complete')
    +</scrip>
    +

    Demo

    + + + + + + + + + + + + + + + + + + + +
    Stateful + + +
    Single Toggle + +
    Checkbox +
    + + + +
    +
    Radio +
    + + + +
    +
    +
    +
    +
    + + + + +
    + +
    +
    +

    The collapse plugin offers simple, flexible collapsible element support for making accordions and other collapsible ui components.

    + Download +
    +
    +

    Using bootstrap-collapse.js

    +
    $(".collapse").collapse()
    +

    Options

    + + + + + + + + + + + + + + + + + + + + + + + +
    Nametypedefaultdescription
    parentselectorfalseIf selector then all collapsible elements under the specified parent will be closed when this collasabile item is shown. (similar to traditional accordion behavior)
    togglebooleantrueToggles the collapsible element on invocation
    +

    Markup

    +

    Just add data-toggle="collapse" and a data-target to element to automatically assign control of a collapsible element. The data-target attribute accepts a css selector to apply the collapse to. Be sure to add the class collapse to the collapsible element. If you'd like it to default open, add the additional class in.

    +
    +<button class="btn danger" data-toggle="collapse" data-target="#demo">
    +  simple collapsible
    +</button>
    +
    +<div id="demo" class="collapse in"> … </div>
    +

    Notice To add accordion like group management to a collapsible control just add the additional data attribute data-parent="#selector". Refer to the demo below to see this in action.

    +

    Methods

    +

    .collapse(options)

    +

    Activates your content as a collapsible element. Accepts an optional options object. +

    +$('#myCollapsible').collapse({
    +  toggle: false
    +})
    +

    .collapse('toggle')

    +

    Toggles a collapsible element to shown or hidden.

    +

    .collapse('show')

    +

    Shows a collapsible element.

    +

    .collapse('hide')

    +

    Hides a collapsible element.

    +

    Events

    +

    + Bootstrap's collapse class exposes a few events for hooking into collapse functionality. +

    + + + + + + + + + + + + + + + + + + + + + + + + + +
    EventDescription
    showThis event fires immediately when the show instance method is called.
    shownThis event is fired when a collapse element has been made visible to the user (will wait for css transitions to complete).
    hide + This event is fired immediately when the hide method has been called. +
    hiddenThis event is fired when a collapse element has been hidden from the user (will wait for css transitions to complete).
    + +
    +$('#myCollapsible').bind('hidden', function () {
    +  // do something ...
    +})
    +

    Demo

    + + +

    + +

    + +
    + +
    +
    + + Collapsible Group Item #1 + +
    +
    +

    + Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS. +

    +
    +
    + + Collapsible Group Item #2 + +
    +
    +

    + Blog +1 eiusmod, williamsburg chambray craft beer brooklyn. Trust fund squid whatever, sunt hoodie skateboard mustache 3 wolf moon art party wes anderson ad leggings officia. Skateboard keytar incididunt gluten-free retro sartorial, single-origin coffee et viral. Art party blog sunt, readymade fugiat 8-bit aesthetic ex echo park fanny pack keytar. Thundercats sustainable labore, mustache adipisicing tattooed dolore aute occaecat velit 8-bit raw denim letterpress. In occaecat freegan, next level single-origin coffee chambray excepteur nihil duis exercitation adipisicing ex sartorial twee squid. You probably haven't heard of them fugiat ea retro eiusmod quis cosby sweater, +1 fap sapiente biodiesel banksy. +

    +
    +
    + + Collapsible Group Item #3 + +
    +
    +

    + Tempor gentrify pariatur nihil salvia, irony synth incididunt odio commodo brunch aute. Four loko est vice echo park wes anderson jean shorts, tempor ea vero locavore. Seitan DIY dolore readymade williamsburg viral. Dolor fap master cleanse delectus, ad butcher labore duis vice mollit cillum exercitation eu banh mi. Austin banksy 3 wolf moon locavore sed, helvetica next level VHS you probably haven't heard of them ethical odio. Incididunt locavore minim, do seitan consequat qui thundercats labore before they sold out retro laborum. Esse twee readymade laboris fap vice, voluptate DIY. +

    +
    +
    +
    +
    +
    +
    + - - - - - - - - - - - - diff --git a/js/README.md b/js/README.md new file mode 100644 index 0000000000..2eef9e7357 --- /dev/null +++ b/js/README.md @@ -0,0 +1,88 @@ +## 2.0 BOOTSTRAP JS PHILOSOPHY +These are the high-level design rules which guide the development of Bootstrap's JS plugins. + +--- + +### DATA-ATTRIBUTE API + +We believe you should be able to use all plugins provided by Bootstrap purely through the markup API without writing a single line of javascript. + +We acknowledge that this isn't always the most performant and sometimes it may be desirable to turn this functionality off altogether. Therefore, as of 2.0 we provide the ability to disable the data attribute API by unbinding all events on the body namespaced with `'data-api'`. This looks like this: + + $('body').unbind('.data-api') + +To target a specific plugin, just include the plugins name as a namespace along with the data-api namespace like this: + + $('body').unbind('.alert.data-api') + +--- + +### PROGRAMATIC API + +We also believe you should be able to use all plugins provided by Bootstrap purely through the JS API. + +All public APIs should be a single, chainable method, and return the collection acted upon. + + $(".btn.danger").button("toggle").addClass("fat") + +All methods should accept an optional options object, a string which targets a particular method, or null which initiates the default behavior: + + $("#myModal").modal() // initialized with defaults + +--- + +### PLUGIN OPTIONS + +Options should be sparse and add universal value. We should pick the right defaults. + +All plugins should have a default object which can be modified to effect all instance's default options. The defaults object should be available via `$.fn.plugin.defaults`. + + $.fn.modal.defaults = { … } + +An options definition should take the following form: + + *noun*: *adjective* - describes or modifies a quality of an instance + +examples: + + backdrop: true + keyboard: false + placement: 'above' + +--- + +### PLUGIN EVENTS + +All events should have an infinitive and past participle form. The infinitive is fired just before an action takes place, the past participle on completion of the action. + + show | shown + hide | hidden + +--- + + +### DATA ATTRIBUTES + +Data attributes should take the following form: + +- data-*(verb)* - defines main interaction +- data-target || href^=# - defined on controller element (if element interacts with an element other than self) +- data-*(noun)* - defines options for element invocation + +examples: + + // control other targets + data-toggle="modal" data-target="#foo" + data-toggle="collapse" data-target="#foo" data-parent="#foo" + + // defined on element they control + data-spy="scroll" + + data-dismiss="modal" + data-dismiss="alert" + + data-toggle="dropdown" + + data-toggle="button" + data-toggle="buttons-checkbox" + data-toggle="buttons-radio" \ No newline at end of file diff --git a/js/bootstrap-accordion.js b/js/bootstrap-accordion.js deleted file mode 100644 index 9a24b5ddfc..0000000000 --- a/js/bootstrap-accordion.js +++ /dev/null @@ -1,41 +0,0 @@ -/* ============================================================= - * bootstrap-accordion.js v2.0.0 - * http://twitter.github.com/bootstrap/javascript.html#accordion - * ============================================================= - * Copyright 2011 Twitter, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================ */ - -(function( $ ){ - - var Accordion = function ( element, options ) {} - - Accordion.prototype = {} - - /* ALERT PLUGIN DEFINITION - * ======================= */ - - $.fn.accordion = function ( options ) { - - if ( options === true ) { - return this.data('accordion') - } - - return this.each(function () { - new Accordion(this, options) - }) - } - - -})( window.jQuery || window.ender ) \ No newline at end of file diff --git a/js/bootstrap-alert.js b/js/bootstrap-alert.js new file mode 100644 index 0000000000..210512a8b3 --- /dev/null +++ b/js/bootstrap-alert.js @@ -0,0 +1,76 @@ +/* ========================================================== + * bootstrap-alert.js v2.0.0 + * http://twitter.github.com/bootstrap/javascript.html#alerts + * ========================================================== + * Copyright 2011 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================================================== */ + + +!function( $ ){ + + "use strict" + + /* ALERT CLASS DEFINITION + * ====================== */ + + var dismiss = '[data-dismiss="alert"]' + , Alert = function ( el ) { + $(el).delegate(dismiss, 'click', this.close) + } + + Alert.prototype = { + + close: function ( e ) { + var $element = $(this) + + $element = $element.hasClass('alert-message') ? $element : $element.parent() + e && e.preventDefault() + $element.removeClass('in') + + function removeElement() { + $element.remove() + } + + $.support.transition && $element.hasClass('fade') ? + $element.bind($.support.transition.end, removeElement) : + removeElement() + } + + } + + + /* ALERT PLUGIN DEFINITION + * ======================= */ + + $.fn.alert = function ( option ) { + return this.each(function () { + var $this = $(this) + , data = $this.data('alert') + if (!data) $this.data('alert', (data = new Alert(this))) + if (typeof option == 'string') data[option].call($this) + }) + } + + $.fn.alert.Alert = Alert + + + /* ALERT DATA-API + * ============== */ + + $(function () { + $('body').delegate(dismiss, 'click.alert.data-api', Alert.prototype.close) + }) + +}( window.jQuery || window.ender ) \ No newline at end of file diff --git a/js/bootstrap-alerts.js b/js/bootstrap-alerts.js deleted file mode 100644 index 4f1acfa3d0..0000000000 --- a/js/bootstrap-alerts.js +++ /dev/null @@ -1,48 +0,0 @@ -/* ========================================================== - * bootstrap-alerts.js v2.0.0 - * http://twitter.github.com/bootstrap/javascript.html#alerts - * ========================================================== - * Copyright 2011 Twitter, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ========================================================== */ - -(function( $ ){ - - /* ALERT CLASS DEFINITION - * ====================== */ - - function close(e) { - var $element = $(this).parent('.alert-message') - - e && e.preventDefault() - $element.removeClass('in') - - function removeElement () { - $element.remove() - } - - $.support.transition && $element.hasClass('fade') ? - $element.bind($.support.transition.end, removeElement) : - removeElement() - } - - - /* ALERT PLUGIN DEFINITION - * ======================= */ - - $(function () { - $('body').delegate('[data-alert-dismiss]', 'click', close) - }) - -})( window.jQuery || window.ender ) \ No newline at end of file diff --git a/js/bootstrap-button.js b/js/bootstrap-button.js new file mode 100644 index 0000000000..1cafe4d688 --- /dev/null +++ b/js/bootstrap-button.js @@ -0,0 +1,96 @@ +/* ============================================================ + * bootstrap-buttons.js v2.0.0 + * http://twitter.github.com/bootstrap/javascript.html#buttons + * ============================================================ + * Copyright 2011 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================ */ + +!function( $ ){ + + "use strict" + + /* BUTTON PUBLIC CLASS DEFINITION + * ============================== */ + + var Button = function (element, options) { + this.$element = $(element) + this.settings = $.extend({}, $.fn.button.defaults, options) + } + + Button.prototype = { + + setState: function (state) { + var d = 'disabled' + , $el = this.$element + , data = $el.data() + , val = $el.is('input') ? 'val' : 'html' + + state = state + 'Text' + data.resetText || $el.data('resetText', $el[val]()) + + $el[val](data[state] || this.settings[state]) + + // push to event loop to allow forms to submit + setTimeout(function () { + state == 'loadingText' ? + $el.addClass(d).attr(d, d) : + $el.removeClass(d).removeAttr(d) + }, 0) + } + + , toggle: function () { + var $parent = this.$element.parent('[data-toggle="buttons-radio"]') + + $parent && $parent + .find('.active') + .removeClass('active') + + this.$element.toggleClass('active') + } + + } + + + /* BUTTON PLUGIN DEFINITION + * ======================== */ + + $.fn.button = function ( option ) { + return this.each(function () { + var $this = $(this) + , data = $this.data('button') + , options = typeof option == 'object' && option + if (!data) $this.data('button', (data = new Button(this, options))) + if (option == 'toggle') data.toggle() + else if (option) data.setState(option) + }) + } + + $.fn.button.defaults = { + loadingText: 'loading...' + } + + $.fn.button.Button = Button + + + /* BUTTON DATA-API + * =============== */ + + $(function () { + $('body').delegate('[data-toggle^=button]', 'click.button.data-api', function (e) { + $(e.srcElement).button('toggle') + }) + }) + +}( window.jQuery || window.ender ) \ No newline at end of file diff --git a/js/bootstrap-collapse.js b/js/bootstrap-collapse.js new file mode 100644 index 0000000000..93f91513e3 --- /dev/null +++ b/js/bootstrap-collapse.js @@ -0,0 +1,133 @@ +/* ============================================================= + * bootstrap-collapsible.js v2.0.0 + * http://twitter.github.com/bootstrap/javascript.html#collapsible + * ============================================================= + * Copyright 2011 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================ */ + +(function( $ ){ + + "use strict" + + var Collapse = function ( element, options ) { + this.$element = $(element) + this.settings = $.extend({}, $.fn.collapse.defaults, options) + + if (this.settings["parent"]) { + this.$parent = $(this.settings["parent"]) + } + + this.settings.toggle && this.toggle() + } + + Collapse.prototype = { + + dimension: function () { + var hasWidth = this.$element.hasClass('width') + return hasWidth ? 'width' : 'height' + } + + , show: function () { + var dimension = this.dimension() + , scroll = $.camelCase(['scroll', dimension].join('-')) + , actives = this.$parent && this.$parent.find('.in') + , hasData + + if (actives && actives.length) { + hasData = actives.data('collapse') + actives.collapse('hide') + hasData || actives.data('collapse', null) + } + + this.$element[dimension](0) + this.transition('addClass', 'show', 'shown') + this.$element[dimension](this.$element[0][scroll]) + + } + + , hide: function () { + var dimension = this.dimension() + this.reset(this.$element[dimension]()) + this.transition('removeClass', 'hide', 'hidden') + this.$element[dimension](0) + } + + , reset: function ( size ) { + var dimension = this.dimension() + + this.$element + .removeClass('collapse') + [dimension](size || '') + [0].offsetWidth + + this.$element.addClass('collapse') + } + + , transition: function ( method, startEvent, completeEvent ) { + var that = this + , complete = function () { + if (startEvent == 'show') that.reset() + that.$element.trigger(completeEvent) + } + + this.$element + .trigger(startEvent) + [method]('in') + + $.support.transition && this.$element.hasClass('collapse') ? + this.$element.one($.support.transition.end, complete) : + complete() + } + + , toggle: function () { + this[this.$element.hasClass('in') ? 'hide' : 'show']() + } + + } + + /* COLLAPSIBLE PLUGIN DEFINITION + * ============================== */ + + $.fn.collapse = function ( option ) { + return this.each(function () { + var $this = $(this) + , data = $this.data('collapse') + , options = typeof option == 'object' && option + if (!data) $this.data('collapse', (data = new Collapse(this, options))) + if (typeof option == 'string') data[option]() + }) + } + + $.fn.collapse.defaults = { + toggle: true + } + + $.fn.collapse.Collapse = Collapse + + + /* COLLAPSIBLE DATA-API + * ==================== */ + + $(function () { + $('body').delegate('[data-toggle=collapse]', 'click.collapse.data-api', function ( e ) { + var $this = $(this) + , target = $this.attr('data-target') || $this.attr('href') + , option = $(target).data('collapse') ? 'toggle' : $this.data() + e.preventDefault() + $(target).collapse(option) + }) + }) + +})( window.jQuery || window.ender ) \ No newline at end of file diff --git a/js/bootstrap-dropdown.js b/js/bootstrap-dropdown.js index d12fe48cb6..7259284bfe 100644 --- a/js/bootstrap-dropdown.js +++ b/js/bootstrap-dropdown.js @@ -18,25 +18,56 @@ * ============================================================ */ -(function( $ ){ +!function( $ ){ + + "use strict" + + /* DROPDOWN CLASS DEFINITION + * ========================= */ + + var toggle = '[data-toggle="dropdown"]' + , Dropdown = function ( element ) { + $(element).bind('click', this.toggle) + } + + Dropdown.prototype = { + + toggle: function ( e ) { + var li = $(this).parent('li') + , isActive = li.hasClass('open') + + clearMenus() + !isActive && li.toggleClass('open') + + return false + } + + } + + function clearMenus() { + $(toggle).parent('li').removeClass('open') + } + + + /* DROPDOWN PLUGIN DEFINITION + * ========================== */ + + $.fn.dropdown = function ( option ) { + return this.each(function () { + var $this = $(this) + , data = $this.data('dropdown') + if (!data) $this.data('dropdown', (data = new Dropdown(this))) + if (typeof option == 'string') data[option].call($this) + }) + } + /* APPLY TO STANDARD DROPDOWN ELEMENTS * =================================== */ - var selector = '[data-dropdown]' - - function clearMenus() { - $(selector).parent('li').removeClass('open') - } $(function () { - $('html').bind("click", clearMenus) - $('body').delegate(selector, 'click', function (e) { - var li = $(this).parent('li') - , isActive = li.hasClass('open') - clearMenus() - !isActive && li.toggleClass('open') - return false - }) + $('html').bind('click.dropdown.data-api', clearMenus) + $('body').delegate(toggle, 'click.dropdown.data-api', Dropdown.prototype.toggle) }) -})( window.jQuery || window.ender ) \ No newline at end of file +}( window.jQuery || window.ender ) \ No newline at end of file diff --git a/js/bootstrap-modal.js b/js/bootstrap-modal.js index 984b091d61..5f543c5537 100644 --- a/js/bootstrap-modal.js +++ b/js/bootstrap-modal.js @@ -20,19 +20,16 @@ !function( $ ){ - /* MODAL PUBLIC CLASS DEFINITION - * ============================= */ + "use strict" + + /* MODAL CLASS DEFINITION + * ====================== */ var Modal = function ( content, options ) { this.settings = $.extend({}, $.fn.modal.defaults, options) this.$element = $(content) - .delegate('[data-modal-dismiss]', 'click', $.proxy(this.hide, this)) - - if ( this.settings.show ) { - this.show() - } - - return this + .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this)) + this.settings.show && this.show() } Modal.prototype = { @@ -43,21 +40,37 @@ , show: function () { var that = this + + if (this.isShown) return + this.isShown = true this.$element.trigger('show') escape.call(this) - backdrop.call(this) + backdrop.call(this, function () { + var transition = $.support.transition && that.$element.hasClass('fade') - return this + that.$element + .appendTo(document.body) + .show() + + if (transition) { + that.$element[0].offsetWidth // force reflow + } + + that.$element.addClass('in') + + transition ? + that.$element.one($.support.transition.end, function () { that.$element.trigger('shown') }) : + that.$element.trigger('shown') + + }) } - , hide: function (e) { + , hide: function ( e ) { e && e.preventDefault() - if ( !this.isShown ) { - return this - } + if (!this.isShown) return var that = this this.isShown = false @@ -68,19 +81,9 @@ .trigger('hide') .removeClass('in') - function removeElement () { - that.$element - .hide() - .trigger('hidden') - - backdrop.call(that) - } - $.support.transition && this.$element.hasClass('fade') ? - this.$element.one($.support.transition.end, removeElement) : - removeElement() - - return this + hideWithTransition.call(this) : + hideModal.call(this) } } @@ -89,24 +92,42 @@ /* MODAL PRIVATE METHODS * ===================== */ - function backdrop () { + function hideWithTransition() { + var that = this + , timeout = setTimeout(function () { + that.$element.unbind($.support.transition.end) + hideModal.call(that) + }, 500) + + this.$element.one($.support.transition.end, function () { + clearTimeout(timeout) + hideModal.call(that) + }) + } + + function hideModal (that) { + this.$element + .hide() + .trigger('hidden') + + backdrop.call(this) + } + + function backdrop ( callback ) { var that = this , animate = this.$element.hasClass('fade') ? 'fade' : '' - , callback = $.proxy(show, this) - if ( this.isShown && this.settings.backdrop ) { + if (this.isShown && this.settings.backdrop) { var doAnimate = $.support.transition && animate this.$backdrop = $('