javascript.html 83.6 KB
Newer Older
Mark Otto's avatar
Mark Otto committed
1001
1002
1003
1004
1005
            </tr>
            <tr>
              <td>content</td>
              <td>string | function</td>
              <td>''</td>
1006
              <td>default content value if <code>data-content</code> attribute isn't present</td>
Mark Otto's avatar
Mark Otto committed
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
            </tr>
            <tr>
              <td>delay</td>
              <td>number | object</td>
              <td>0</td>
              <td>
               <p>delay showing and hiding the popover (ms) - does not apply to manual trigger type</p>
               <p>If a number is supplied, delay is applied to both hide/show</p>
               <p>Object structure is: <code>delay: { show: 500, hide: 100 }</code></p>
              </td>
            </tr>
            <tr>
              <td>container</td>
              <td>string | false</td>
              <td>false</td>
              <td>
Chris Rebert's avatar
Chris Rebert committed
1023
               <p>Appends the popover to a specific element. Example: <code>container: 'body'</code></p>
Mark Otto's avatar
Mark Otto committed
1024
1025
1026
1027
              </td>
            </tr>
          </tbody>
        </table>
1028
        <div class="bs-callout bs-callout-info">
Mark Otto's avatar
Mark Otto committed
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
          <h4>Data attributes for individual popovers</h4>
          <p>Options for individual popovers can alternatively be specified through the use of data attributes, as explained above.</p>
        </div>

        <h3>Markup</h3>
        <p>For performance reasons, the Tooltip and Popover data-apis are opt in. If you would like to use them just specify a selector option.</p>

        <h3>Methods</h3>
        <h4>$().popover(options)</h4>
        <p>Initializes popovers for an element collection.</p>

        <h4>.popover('show')</h4>
        <p>Reveals an elements popover.</p>
        {% highlight js %}$('#element').popover('show'){% endhighlight %}

        <h4>.popover('hide')</h4>
        <p>Hides an elements popover.</p>
        {% highlight js %}$('#element').popover('hide'){% endhighlight %}

        <h4>.popover('toggle')</h4>
        <p>Toggles an elements popover.</p>
        {% highlight js %}$('#element').popover('toggle'){% endhighlight %}

        <h4>.popover('destroy')</h4>
        <p>Hides and destroys an element's popover.</p>
        {% highlight js %}$('#element').popover('destroy'){% endhighlight %}
      </section>



      <!-- Alert
      ================================================== -->
      <div class="bs-docs-section" id="js-alerts">
        <div class="page-header">
Julian Thilo's avatar
Julian Thilo committed
1063
          <h1>Alert messages <small>alert.js</small></h1>
Mark Otto's avatar
Mark Otto committed
1064
1065
1066
1067
1068
        </div>


        <h2>Example alerts</h2>
        <p>Add dismiss functionality to all alert messages with this plugin.</p>
Mark Otto's avatar
Mark Otto committed
1069
        <div class="bs-example">
Mark Otto's avatar
Mark Otto committed
1070
1071
1072
1073
1074
1075
          <div class="alert fade in">
            <button type="button" class="close" data-dismiss="alert">&times;</button>
            <strong>Holy guacamole!</strong> Best check yo self, you're not looking too good.
          </div>
        </div><!-- /example -->

Mark Otto's avatar
Mark Otto committed
1076
        <div class="bs-example">
Mark Otto's avatar
Mark Otto committed
1077
1078
1079
1080
1081
          <div class="alert alert-block alert-error fade in">
            <button type="button" class="close" data-dismiss="alert">&times;</button>
            <h4>Oh snap! You got an error!</h4>
            <p>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.</p>
            <p>
Mark Otto's avatar
Mark Otto committed
1082
              <a class="btn btn-danger" href="#">Take this action</a> <a class="btn btn-default" href="#">Or do this</a>
Mark Otto's avatar
Mark Otto committed
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
            </p>
          </div>
        </div><!-- /example -->


        <hr class="bs-docs-separator">


        <h2>Usage</h2>
        <p>Enable dismissal of an alert via JavaScript:</p>
        {% highlight js %}$(".alert").alert(){% endhighlight %}

        <h3>Markup</h3>
        <p>Just add <code>data-dismiss="alert"</code> to your close button to automatically give an alert close functionality.</p>
        {% highlight html %}<a class="close" data-dismiss="alert" href="#">&times;</a>{% endhighlight %}

        <h3>Methods</h3>

        <h4>$().alert()</h4>
        <p>Wraps all alerts with close functionality. To have your alerts animate out when closed, make sure they have the <code>.fade</code> and <code>.in</code> class already applied to them.</p>

        <h4>.alert('close')</h4>
        <p>Closes an alert.</p>
        {% highlight js %}$(".alert").alert('close'){% endhighlight %}


        <h3>Events</h3>
        <p>Bootstrap's alert class exposes a few events for hooking into alert functionality.</p>
        <table class="table table-bordered table-striped">
          <thead>
            <tr>
fat's avatar
fat committed
1114
              <th style="width: 150px;">Event Type</th>
Mark Otto's avatar
Mark Otto committed
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
              <th>Description</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>close</td>
              <td>This event fires immediately when the <code>close</code> instance method is called.</td>
            </tr>
            <tr>
              <td>closed</td>
Chris Rebert's avatar
Chris Rebert committed
1125
              <td>This event is fired when the alert has been closed (will wait for CSS transitions to complete).</td>
Mark Otto's avatar
Mark Otto committed
1126
1127
1128
1129
            </tr>
          </tbody>
        </table>
{% highlight js %}
fat's avatar
fat committed
1130
$('#my-alert').bind('closed.bs.alert', function () {
Mark Otto's avatar
Mark Otto committed
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
  // do something…
})
{% endhighlight %}
      </div>



          <!-- Buttons
          ================================================== -->
          <div class="bs-docs-section" id="js-buttons">
            <div class="page-header">
Julian Thilo's avatar
Julian Thilo committed
1142
              <h1>Buttons <small>button.js</small></h1>
Mark Otto's avatar
Mark Otto committed
1143
1144
1145
1146
1147
1148
1149
            </div>

            <h2>Example uses</h2>
            <p>Do more with buttons. Control button states or create groups of buttons for more components like toolbars.</p>

            <h4>Stateful</h4>
            <p>Add <code>data-loading-text="Loading..."</code> to use a loading state on a button.</p>
Mark Otto's avatar
Mark Otto committed
1150
            <div class="bs-example" style="padding-bottom: 24px;">
Mark Otto's avatar
Mark Otto committed
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
              <button type="button" id="fat-btn" data-loading-text="Loading..." class="btn btn-primary">
                Loading state
              </button>
            </div><!-- /example -->
{% highlight html %}
<button type="button" id="fat-btn" data-loading-text="Loading..." class="btn btn-primary">
  Loading state
</button>
{% endhighlight %}

            <h4>Single toggle</h4>
            <p>Add <code>data-toggle="button"</code> to activate toggling on a single button.</p>
Mark Otto's avatar
Mark Otto committed
1163
            <div class="bs-example" style="padding-bottom: 24px;">
Mark Otto's avatar
Mark Otto committed
1164
1165
1166
1167
1168
1169
1170
              <button type="button" class="btn btn-primary" data-toggle="button">Single toggle</button>
            </div><!-- /example -->
{% highlight html %}
<button type="button" class="btn btn-primary" data-toggle="button">Single toggle</button>
{% endhighlight %}

            <h4>Checkbox</h4>
1171
            <p>Add <code>data-toggle="buttons"</code> to a group of checkboxes for checkbox style toggling on btn-group.</p>
Mark Otto's avatar
Mark Otto committed
1172
            <div class="bs-example" style="padding-bottom: 24px;">
1173
              <div class="btn-group" data-toggle="buttons">
Mark Otto's avatar
Mark Otto committed
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
                <label class="btn btn-primary">
                  <input type="checkbox"> Option 1
                </label>
                <label class="btn btn-primary">
                  <input type="checkbox"> Option 2
                </label>
                <label class="btn btn-primary">
                  <input type="checkbox"> Option 3
                </label>
              </div>
            </div><!-- /example -->
{% highlight html %}
1186
<div class="btn-group" data-toggle="buttons">
Mark Otto's avatar
Mark Otto committed
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
  <label class="btn btn-primary">
    <input type="checkbox"> Option 1
  </label>
  <label class="btn btn-primary">
    <input type="checkbox"> Option 2
  </label>
  <label class="btn btn-primary">
    <input type="checkbox"> Option 3
  </label>
</div>
{% endhighlight %}

            <h4>Radio</h4>
1200
            <p>Add <code>data-toggle="buttons"</code> to a group of radio inputs for radio style toggling on btn-group.</p>
Mark Otto's avatar
Mark Otto committed
1201
            <div class="bs-example" style="padding-bottom: 24px;">
1202
              <div class="btn-group" data-toggle="buttons">
Mark Otto's avatar
Mark Otto committed
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
                <label class="btn btn-primary">
                  <input type="radio" name="options" id="option1"> Option 1
                </label>
                <label class="btn btn-primary">
                  <input type="radio" name="options" id="option2"> Option 2
                </label>
                <label class="btn btn-primary">
                  <input type="radio" name="options" id="option3"> Option 3
                </label>
              </div>
            </div><!-- /example -->
{% highlight html %}
1215
<div class="btn-group" data-toggle="buttons">
Mark Otto's avatar
Mark Otto committed
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
  <label class="btn btn-primary">
    <input type="radio" name="options" id="option1"> Option 1
  </label>
  <label class="btn btn-primary">
    <input type="radio" name="options" id="option2"> Option 2
  </label>
  <label class="btn btn-primary">
    <input type="radio" name="options" id="option3"> Option 3
  </label>
</div>
{% endhighlight %}


            <hr class="bs-docs-separator">


            <h2>Usage</h2>
            <p>Enable buttons via JavaScript:</p>
{% highlight js %}
$('.nav-tabs').button()
{% endhighlight %}

            <h3>Markup</h3>
            <p>Data attributes are integral to the button plugin. Check out the example code below for the various markup types.</p>

            <h3>Options</h3>
            <p><em>None</em></p>

            <h3>Methods</h3>

            <h4>$().button('toggle')</h4>
            <p>Toggles push state. Gives the button the appearance that it has been activated.</p>
1248
            <div class="bs-callout bs-callout-info">
Mark Otto's avatar
Mark Otto committed
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
              <h4>Auto toggling</h4>
              <p>You can enable auto toggling of a button by using the <code>data-toggle</code> attribute.</p>
            </div>
{% highlight html %}
<button type="button" class="btn" data-toggle="button">...</button>
{% endhighlight %}

            <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>
{% highlight html %}
<button type="button" class="btn" data-loading-text="loading stuff...">...</button>
{% endhighlight %}

1263
            <div class="bs-callout bs-callout-danger">
Mark Otto's avatar
Mark Otto committed
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
              <h4>Cross-browser compatibility</h4>
              <p><a href="https://github.com/twitter/bootstrap/issues/793">Firefox persists the disabled state across page loads</a>. A workaround for this is to use <code>autocomplete="off"</code>.</p>
            </div>

            <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>
{% highlight html %}
<button type="button" class="btn" data-complete-text="finished!" >...</button>
<script>
  $('.btn').button('complete')
</script>
{% endhighlight %}
          </div>



          <!-- Collapse
          ================================================== -->
          <section id="collapse">
            <div class="page-header">
Julian Thilo's avatar
Julian Thilo committed
1287
              <h1>Collapse <small>collapse.js</small></h1>
Mark Otto's avatar
Mark Otto committed
1288
1289
1290
1291
1292
            </div>

            <h3>About</h3>
            <p>Get base styles and flexible support for collapsible components like accordions and navigation.</p>

1293
            <div class="bs-callout bs-callout-danger">
Mark Otto's avatar
Mark Otto committed
1294
1295
1296
1297
1298
1299
1300
              <h4>Plugin dependency</h4>
              <p>Collapse requires the <a href="#transitions">transitions plugin</a> to be included in your version of Bootstrap.</p>
            </div>

            <h2>Example accordion</h2>
            <p>Using the collapse plugin, we built a simple accordion style widget:</p>

Mark Otto's avatar
Mark Otto committed
1301
            <div class="bs-example">
Mark Otto's avatar
Mark Otto committed
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
              <div class="accordion" id="accordion2">
                <div class="accordion-group">
                  <div class="accordion-heading">
                    <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">
                      Collapsible Group Item #1
                    </a>
                  </div>
                  <div id="collapseOne" class="accordion-body collapse in">
                    <div class="accordion-inner">
                      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.
                    </div>
                  </div>
                </div>
                <div class="accordion-group">
                  <div class="accordion-heading">
                    <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo">
                      Collapsible Group Item #2
                    </a>
                  </div>
                  <div id="collapseTwo" class="accordion-body collapse">
                    <div class="accordion-inner">
                      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.
                    </div>
                  </div>
                </div>
                <div class="accordion-group">
                  <div class="accordion-heading">
                    <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseThree">
                      Collapsible Group Item #3
                    </a>
                  </div>
                  <div id="collapseThree" class="accordion-body collapse">
                    <div class="accordion-inner">
                      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.
                    </div>
                  </div>
                </div>
              </div>
            </div><!-- /example -->
{% highlight html %}
<div class="accordion" id="accordion2">
  <div class="accordion-group">
    <div class="accordion-heading">
      <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">
        Collapsible Group Item #1
      </a>
    </div>
    <div id="collapseOne" class="accordion-body collapse in">
      <div class="accordion-inner">
        ...
      </div>
    </div>
  </div>
  <div class="accordion-group">
    <div class="accordion-heading">
      <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo">
        Collapsible Group Item #2
      </a>
    </div>
    <div id="collapseTwo" class="accordion-body collapse">
      <div class="accordion-inner">
        ...
      </div>
    </div>
  </div>
  <div class="accordion-group">
    <div class="accordion-heading">
      <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseThree">
        Collapsible Group Item #3
      </a>
    </div>
    <div id="collapseThree" class="accordion-body collapse">
      <div class="accordion-inner">
        ...
      </div>
    </div>
  </div>
</div>
{% endhighlight %}

            <p>You can also use the plugin without the accordion markup. Make a button toggle the expanding and collapsing of another element.</p>
{% highlight html %}
<button type="button" class="btn btn-danger" data-toggle="collapse" data-target="#demo">
  simple collapsible
</button>

<div id="demo" class="collapse in">...</div>
{% endhighlight %}


            <hr class="bs-docs-separator">


            <h2>Usage</h2>

            <h3>Via data attributes</h3>
Chris Rebert's avatar
Chris Rebert committed
1398
            <p>Just add <code>data-toggle="collapse"</code> and a <code>data-target</code> to element to automatically assign control of a collapsible element. The <code>data-target</code> attribute accepts a CSS selector to apply the collapse to. Be sure to add the class <code>collapse</code> to the collapsible element. If you'd like it to default open, add the additional class <code>in</code>.</p>
Mark Otto's avatar
Mark Otto committed
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
            <p>To add accordion-like group management to a collapsible control, add the data attribute <code>data-parent="#selector"</code>. Refer to the demo to see this in action.</p>

            <h3>Via JavaScript</h3>
            <p>Enable manually with:</p>
{% highlight js %}
$(".collapse").collapse()
{% endhighlight %}

            <h3>Options</h3>
            <p>Options can be passed via data attributes or JavaScript. For data attributes, append the option name to <code>data-</code>, as in <code>data-parent=""</code>.</p>
            <table class="table table-bordered table-striped">
              <thead>
               <tr>
                 <th style="width: 100px;">Name</th>
                 <th style="width: 50px;">type</th>
                 <th style="width: 50px;">default</th>
                 <th>description</th>
               </tr>
              </thead>
              <tbody>
               <tr>
                 <td>parent</td>
                 <td>selector</td>
                 <td>false</td>
                 <td>If selector then all collapsible elements under the specified parent will be closed when this collapsible item is shown. (similar to traditional accordion behavior)</td>
               </tr>
               <tr>
                 <td>toggle</td>
                 <td>boolean</td>
                 <td>true</td>
                 <td>Toggles the collapsible element on invocation</td>
               </tr>
              </tbody>
            </table>


            <h3>Methods</h3>

            <h4>.collapse(options)</h4>
            <p>Activates your content as a collapsible element. Accepts an optional options <code>object</code>.
{% highlight js %}
$('#myCollapsible').collapse({
  toggle: false
})
{% endhighlight %}

            <h4>.collapse('toggle')</h4>
            <p>Toggles a collapsible element to shown or hidden.</p>

            <h4>.collapse('show')</h4>
            <p>Shows a collapsible element.</p>

            <h4>.collapse('hide')</h4>
            <p>Hides a collapsible element.</p>

            <h3>Events</h3>
            <p>Bootstrap's collapse class exposes a few events for hooking into collapse functionality.</p>
            <table class="table table-bordered table-striped">
              <thead>
               <tr>
fat's avatar
fat committed
1459
                 <th style="width: 150px;">Event Type</th>
Mark Otto's avatar
Mark Otto committed
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
                 <th>Description</th>
               </tr>
              </thead>
              <tbody>
               <tr>
                 <td>show</td>
                 <td>This event fires immediately when the <code>show</code> instance method is called.</td>
               </tr>
               <tr>
                 <td>shown</td>
Chris Rebert's avatar
Chris Rebert committed
1470
                 <td>This event is fired when a collapse element has been made visible to the user (will wait for CSS transitions to complete).</td>
Mark Otto's avatar
Mark Otto committed
1471
1472
1473
1474
1475
1476
1477
1478
1479
               </tr>
               <tr>
                 <td>hide</td>
                 <td>
                  This event is fired immediately when the <code>hide</code> method has been called.
                 </td>
               </tr>
               <tr>
                 <td>hidden</td>
Chris Rebert's avatar
Chris Rebert committed
1480
                 <td>This event is fired when a collapse element has been hidden from the user (will wait for CSS transitions to complete).</td>
Mark Otto's avatar
Mark Otto committed
1481
1482
1483
1484
               </tr>
              </tbody>
            </table>
{% highlight js %}
fat's avatar
fat committed
1485
$('#myCollapsible').on('hidden.bs.collapse', function () {
Mark Otto's avatar
Mark Otto committed
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
  // do something…
})
{% endhighlight %}
          </section>



           <!-- Carousel
          ================================================== -->
          <section id="carousel">
            <div class="page-header">
Julian Thilo's avatar
Julian Thilo committed
1497
              <h1>Carousel <small>carousel.js</small></h1>
Mark Otto's avatar
Mark Otto committed
1498
1499
1500
1501
            </div>

            <h2>Examples</h2>
            <p>The slideshow below shows a generic plugin and component for cycling through elements like a carousel.</p>
Mark Otto's avatar
Mark Otto committed
1502
            <div class="bs-example">
Mark Otto's avatar
Mark Otto committed
1503
1504
1505
1506
1507
1508
1509
1510
              <div id="carousel-example-generic" class="carousel slide bs-docs-carousel-example">
                <ol class="carousel-indicators">
                  <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
                  <li data-target="#carousel-example-generic" data-slide-to="1"></li>
                  <li data-target="#carousel-example-generic" data-slide-to="2"></li>
                </ol>
                <div class="carousel-inner">
                  <div class="item active">
1511
                    <img data-src="holder.js/900x500/auto/#777:#555/text:First slide" alt="">
Mark Otto's avatar
Mark Otto committed
1512
1513
                  </div>
                  <div class="item">
1514
                    <img data-src="holder.js/900x500/auto/#666:#444/text:Second slide" alt="">
Mark Otto's avatar
Mark Otto committed
1515
1516
                  </div>
                  <div class="item">
1517
                    <img data-src="holder.js/900x500/auto/#555:#333/text:Third slide" alt="">
Mark Otto's avatar
Mark Otto committed
1518
1519
1520
                  </div>
                </div>
                <a class="left carousel-control" href="#carousel-example-generic" data-slide="prev">
1521
                  <span class="icon-prev"></span>
Mark Otto's avatar
Mark Otto committed
1522
1523
                </a>
                <a class="right carousel-control" href="#carousel-example-generic" data-slide="next">
1524
                  <span class="icon-next"></span>
Mark Otto's avatar
Mark Otto committed
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
                </a>
              </div>
            </div><!-- /example -->
{% highlight html %}
<div id="carousel-example-generic" class="carousel slide">
  <!-- Indicators -->
  <ol class="carousel-indicators">
    <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
    <li data-target="#carousel-example-generic" data-slide-to="1"></li>
    <li data-target="#carousel-example-generic" data-slide-to="2"></li>
  </ol>

  <!-- Wrapper for slides -->
  <div class="carousel-inner">
    <div class="item active">
      <img src="..." alt="">
      <div class="carousel-caption">
        ...
      </div>
    </div>
    ...
  </div>

  <!-- Controls -->
  <a class="left carousel-control" href="#carousel-example-generic" data-slide="prev">
1550
    <span class="icon-prev"></span>
Mark Otto's avatar
Mark Otto committed
1551
1552
  </a>
  <a class="right carousel-control" href="#carousel-example-generic" data-slide="next">
1553
    <span class="icon-next"></span>
Mark Otto's avatar
Mark Otto committed
1554
1555
1556
  </a>
</div>
{% endhighlight %}
1557
<div class="bs-callout bs-callout-info">
1558
  <h4>Glyphicon Alternative</h4>
1559
  <p>With <a href="/css/#glyphicons">Glyphicons</a> available, you may choose to style the left and right toggle buttons with <code>.glyphicon .glyphicon-chevron-left</code> and <code>.glyphicon .glyphicon-chevron-right</code>.</p>
1560
</div>
Mark Otto's avatar
Mark Otto committed
1561
1562
1563

            <h3>Optional captions</h3>
            <p>Add captions to your slides easily with the <code>.carousel-caption</code> element within any <code>.item</code>. Place just about any optional HTML within there and it will be automatically aligned and formatted.</p>
Mark Otto's avatar
Mark Otto committed
1564
            <div class="bs-example">
Mark Otto's avatar
Mark Otto committed
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
              <div id="carousel-example-captions" class="carousel slide bs-docs-carousel-example">
                <ol class="carousel-indicators">
                  <li data-target="#carousel-example-captions" data-slide-to="0" class="active"></li>
                  <li data-target="#carousel-example-captions" data-slide-to="1"></li>
                  <li data-target="#carousel-example-captions" data-slide-to="2"></li>
                </ol>
                <div class="carousel-inner">
                  <div class="item active">
                    <img data-src="holder.js/900x500/auto/#777:#777" alt="">
                    <div class="carousel-caption">
                      <h3>First slide label</h3>
                      <p>Nulla vitae elit libero, a pharetra augue mollis interdum.</p>
                    </div>
                  </div>
                  <div class="item">
1580
                    <img data-src="holder.js/900x500/auto/#666:#666" alt="">
Mark Otto's avatar
Mark Otto committed
1581
1582
1583
1584
1585
1586
                    <div class="carousel-caption">
                      <h3>Second slide label</h3>
                      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
                    </div>
                  </div>
                  <div class="item">
1587
                    <img data-src="holder.js/900x500/auto/#555:#5555" alt="">
Mark Otto's avatar
Mark Otto committed
1588
1589
1590
1591
1592
1593
1594
                    <div class="carousel-caption">
                      <h3>Third slide label</h3>
                      <p>Praesent commodo cursus magna, vel scelerisque nisl consectetur.</p>
                    </div>
                  </div>
                </div>
                <a class="left carousel-control" href="#carousel-example-captions" data-slide="prev">
1595
                  <span class="icon-prev"></span>
Mark Otto's avatar
Mark Otto committed
1596
1597
                </a>
                <a class="right carousel-control" href="#carousel-example-captions" data-slide="next">
1598
                  <span class="icon-next"></span>
Mark Otto's avatar
Mark Otto committed
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
                </a>
              </div>
            </div><!-- /example -->
{% highlight html %}
<div class="item active">
  <img src="..." alt="">
  <div class="carousel-caption">
    <h3>...</h3>
    <p>...</p>
  </div>
</div>
{% endhighlight %}



            <hr class="bs-docs-separator">


            <h2>Usage</h2>

            <h3>Via data attributes</h3>
            <p>Use data attributes to easily control the position of the carousel. <code>data-slide</code> accepts the keywords <code>prev</code> or <code>next</code>, which alters the slide position relative to its current position. Alternatively, use <code>data-slide-to</code> to pass a raw slide index to the carousel <code>data-slide-to="2"</code>, which shifts the slide position to a particular index beginning with <code>0</code>.</p>

            <h3>Via JavaScript</h3>
            <p>Call carousel manually with:</p>
{% highlight js %}
$('.carousel').carousel()
{% endhighlight %}

            <h3>Options</h3>
            <p>Options can be passed via data attributes or JavaScript. For data attributes, append the option name to <code>data-</code>, as in <code>data-interval=""</code>.</p>
            <table class="table table-bordered table-striped">
              <thead>
               <tr>
                 <th style="width: 100px;">Name</th>
                 <th style="width: 50px;">type</th>
                 <th style="width: 50px;">default</th>
                 <th>description</th>
               </tr>
              </thead>
              <tbody>
               <tr>
                 <td>interval</td>
                 <td>number</td>
                 <td>5000</td>
                 <td>The amount of time to delay between automatically cycling an item. If false, carousel will not automatically cycle.</td>
               </tr>
               <tr>
                 <td>pause</td>
                 <td>string</td>
                 <td>"hover"</td>
                 <td>Pauses the cycling of the carousel on mouseenter and resumes the cycling of the carousel on mouseleave.</td>
               </tr>
              </tbody>
            </table>

            <h3>Methods</h3>

            <h4>.carousel(options)</h4>
            <p>Initializes the carousel with an optional options <code>object</code> and starts cycling through items.</p>
{% highlight html %}
$('.carousel').carousel({
  interval: 2000
})
{% endhighlight %}

            <h4>.carousel('cycle')</h4>
            <p>Cycles through the carousel items from left to right.</p>

            <h4>.carousel('pause')</h4>
            <p>Stops the carousel from cycling through items.</p>


            <h4>.carousel(number)</h4>
            <p>Cycles the carousel to a particular frame (0 based, similar to an array).</p>

            <h4>.carousel('prev')</h4>
            <p>Cycles to the previous item.</p>

            <h4>.carousel('next')</h4>
            <p>Cycles to the next item.</p>

            <h3>Events</h3>
            <p>Bootstrap's carousel class exposes two events for hooking into carousel functionality.</p>
            <table class="table table-bordered table-striped">
              <thead>
               <tr>
fat's avatar
fat committed
1686
                 <th style="width: 150px;">Event Type</th>
Mark Otto's avatar
Mark Otto committed
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
                 <th>Description</th>
               </tr>
              </thead>
              <tbody>
               <tr>
                 <td>slide</td>
                 <td>This event fires immediately when the <code>slide</code> instance method is invoked.</td>
               </tr>
               <tr>
                 <td>slid</td>
                 <td>This event is fired when the carousel has completed its slide transition.</td>
               </tr>
              </tbody>
            </table>
fat's avatar
fat committed
1701
1702
1703
1704
1705
            {% highlight js %}
$('#myCarousel').on('slide.bs.carousel', function () {
  // do something…
})
{% endhighlight %}
Mark Otto's avatar
Mark Otto committed
1706
1707
1708
1709
1710
1711
1712
1713
          </section>



          <!-- Affix
          ================================================== -->
          <section id="affix">
            <div class="page-header">
Julian Thilo's avatar
Julian Thilo committed
1714
              <h1>Affix <small>affix.js</small></h1>
Mark Otto's avatar
Mark Otto committed
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
            </div>

            <h2>Example</h2>
            <p>The subnavigation on the left is a live demo of the affix plugin.</p>

            <hr class="bs-docs-separator">

            <h2>Usage</h2>

            <h3>Via data attributes</h3>
            <p>To easily add affix behavior to any element, just add <code>data-spy="affix"</code> to the element you want to spy on. Then use offsets to define when to toggle the pinning of an element on and off.</p>

{% highlight html %}
<div data-spy="affix" data-offset-top="200">...</div>
{% endhighlight %}

1731
            <div class="bs-callout bs-callout-warning">
Mark Otto's avatar
Mark Otto committed
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
              <h4>Requires positioning</h4>
              <p>You must manage the position of a pinned element and the behavior of its immediate parent. Position is controlled by <code>affix</code>, <code>affix-top</code>, and <code>affix-bottom</code>. Remember to check for a potentially collapsed parent when the affix kicks in as it's removing content from the normal flow of the page.</p>
            </div>

            <h3>Via JavaScript</h3>
            <p>Call the affix plugin via JavaScript:</p>
{% highlight js %}
$('#navbar').affix()
{% endhighlight %}

            <h3>Methods</h3>
            <h4>.affix('refresh')</h4>
            <p>When using affix in conjunction with adding or removing of elements from the DOM, you'll want to call the refresh method:</p>
{% highlight js %}
$('[data-spy="affix"]').each(function () {
  $(this).affix('refresh')
});
{% endhighlight %}

          <h3>Options</h3>
          <p>Options can be passed via data attributes or JavaScript. For data attributes, append the option name to <code>data-</code>, as in <code>data-offset-top="200"</code>.</p>

          <table class="table table-bordered table-striped">
            <thead>
             <tr>
               <th style="width: 100px;">Name</th>
               <th style="width: 100px;">type</th>
               <th style="width: 50px;">default</th>
               <th>description</th>
             </tr>
            </thead>
            <tbody>
             <tr>
               <td>offset</td>
               <td>number | function | object</td>
               <td>10</td>
               <td>Pixels to offset from screen when calculating position of scroll. If a single number is provided, the offset will be applied in both top and left directions. To listen for a single direction, or multiple unique offsets, just provide an object <code>offset: { x: 10 }</code>. Use a function when you need to dynamically provide an offset (useful for some responsive designs).</td>
             </tr>
            </tbody>
          </table>
        </section>
For faster browsing, not all history is shown. View entire blame