m);varr=s.createElement("OL");r.className="linenums";for(varn=Math.max(0,m-1|0)||0,g=0,z=d.length;g<z;++g)l=d[g],l.className="L"+(g+n)%10,l.firstChild||l.appendChild(s.createTextNode("\xa0")),r.appendChild(l);a.appendChild(r)}functionk(a,m){for(vare=m.length;--e>=0;){varh=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}functionC(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*</.test(m)?"default-markup":"default-code";returnA[a]}functionE(a){varm=
<p>You can use all Bootstrap plugins purely through the markup API without writing a single line of JavaScript. This is Bootstrap's first class API and should be your first consideration when using a plugin.</p>
<p>You can use all Bootstrap plugins purely through the markup API without writing a single line of JavaScript. This is Bootstrap's first class API and should be your first consideration when using a plugin.</p>
<p>That said, in some situations it may be desirable to turn this functionality off. Therefore, we also provide the ability to disable the data attribute API by unbinding all events on the body namespaced with `'data-api'`. This looks like this:
<p>That said, in some situations it may be desirable to turn this functionality off. Therefore, we also provide the ability to disable the data attribute API by unbinding all events on the body namespaced with `'data-api'`. This looks like this:
<p>We also believe you should be able to use all Bootstrap plugins purely through the JavaScript API. All public APIs are single, chainable methods, and return the collection acted upon.</p>
<p>We also believe you should be able to use all Bootstrap plugins purely through the JavaScript API. All public APIs are single, chainable methods, and return the collection acted upon.</p>
<p>All methods should accept an optional options object, a string which targets a particular method, or nothing (which initiates a plugin with default behavior):</p>
<p>All methods should accept an optional options object, a string which targets a particular method, or nothing (which initiates a plugin with default behavior):</p>
<preclass="prettyprint linenums">
{% highlight js linenos %}
$("#myModal").modal() // initialized with defaults
$("#myModal").modal() // initialized with defaults
$("#myModal").modal({ keyboard: false }) // initialized with no keyboard
$("#myModal").modal({ keyboard: false }) // initialized with no keyboard
$("#myModal").modal('show') // initializes and invokes show immediately</p>
$("#myModal").modal('show') // initializes and invokes show immediately</p>
</pre>
{% endhighlight %}
<p>Each plugin also exposes its raw constructor on a `Constructor` property: <code>$.fn.popover.Constructor</code>. If you'd like to get a particular plugin instance, retrieve it directly from an element: <code>$('[rel=popover]').data('popover')</code>.</p>
<p>Each plugin also exposes its raw constructor on a `Constructor` property: <code>$.fn.popover.Constructor</code>. If you'd like to get a particular plugin instance, retrieve it directly from an element: <code>$('[rel=popover]').data('popover')</code>.</p>
<h3>No conflict</h3>
<h3>No conflict</h3>
<p>Sometimes it is necessary to use Bootstrap plugins with other UI frameworks. In these circumstances, namespace collisions can occasionally occur. If this happens, you may call <code>.noConflict</code> on the plugin you wish to revert the value of.</p>
<p>Sometimes it is necessary to use Bootstrap plugins with other UI frameworks. In these circumstances, namespace collisions can occasionally occur. If this happens, you may call <code>.noConflict</code> on the plugin you wish to revert the value of.</p>
{% highlight js linenos %}
<preclass="prettyprint linenums">
var bootstrapButton = $.fn.button.noConflict() // return $.fn.button to previously assigned value
var bootstrapButton = $.fn.button.noConflict() // return $.fn.button to previously assigned value
$.fn.bootstrapBtn = bootstrapButton // give $().bootstrapBtn the bootstrap functionality
$.fn.bootstrapBtn = bootstrapButton // give $().bootstrapBtn the bootstrap functionality
</pre>
{% endhighlight %}
<h3>Events</h3>
<h3>Events</h3>
<p>Bootstrap provides custom events for most plugin's unique actions. Generally, these come in an infinitive and past participle form - where the infinitive (ex. <code>show</code>) is triggered at the start of an event, and its past participle form (ex. <code>shown</code>) is trigger on the completion of an action.</p>
<p>Bootstrap provides custom events for most plugin's unique actions. Generally, these come in an infinitive and past participle form - where the infinitive (ex. <code>show</code>) is triggered at the start of an event, and its past participle form (ex. <code>shown</code>) is trigger on the completion of an action.</p>
<p>All infinitive events provide <code>preventDefault</code> functionality. This provides the ability to stop the execution of an action before it starts.</p>
<p>All infinitive events provide <code>preventDefault</code> functionality. This provides the ability to stop the execution of an action before it starts.</p>
<preclass="prettyprint linenums">
{% highlight js linenos %}
$('#myModal').on('show', function (e) {
$('#myModal').on('show', function (e) {
if (!data) return e.preventDefault() // stops modal from being shown
if (!data) return e.preventDefault() // stops modal from being shown
})
})
</pre>
{% endhighlight %}
</section>
</section>
...
@@ -124,7 +133,6 @@ $('#myModal').on('show', function (e) {
...
@@ -124,7 +133,6 @@ $('#myModal').on('show', function (e) {
<h3>Static example</h3>
<h3>Static example</h3>
<p>A rendered modal with header, body, and set of actions in the footer.</p>
<p>A rendered modal with header, body, and set of actions in the footer.</p>
<p>Activate a modal without writing JavaScript. Set <code>data-toggle="modal"</code> on a controller element, like a button, along with a <code>data-target="#foo"</code> or <code>href="#foo"</code> to target a specific modal to toggle.</p>
<p>Activate a modal without writing JavaScript. Set <code>data-toggle="modal"</code> on a controller element, like a button, along with a <code>data-target="#foo"</code> or <code>href="#foo"</code> to target a specific modal to toggle.</p>
<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-backdrop=""</code>.</p>
<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-backdrop=""</code>.</p>
...
@@ -281,28 +287,35 @@ $('#myModal').on('show', function (e) {
...
@@ -281,28 +287,35 @@ $('#myModal').on('show', function (e) {
<td>path</td>
<td>path</td>
<td>false</td>
<td>false</td>
<td><p>If a remote url is provided, content will be loaded via jQuery's <code>load</code> method and injected into the <code>.modal-body</code>. If you're using the data api, you may alternatively use the <code>href</code> tag to specify the remote source. An example of this is shown below:</p>
<td><p>If a remote url is provided, content will be loaded via jQuery's <code>load</code> method and injected into the <code>.modal-body</code>. If you're using the data api, you may alternatively use the <code>href</code> tag to specify the remote source. An example of this is shown below:</p>
@@ -531,11 +545,17 @@ $('#myModal').on('hidden', function () {
...
@@ -531,11 +545,17 @@ $('#myModal').on('hidden', function () {
<h3>Via data attributes</h3>
<h3>Via data attributes</h3>
<p>To easily add scrollspy behavior to your topbar navigation, just add <code>data-spy="scroll"</code> to the element you want to spy on (most typically this would be the body) and <code>data-target=".navbar"</code> to select which nav to use. You'll want to use scrollspy with a <code>.nav</code> component.</p>
<p>To easily add scrollspy behavior to your topbar navigation, just add <code>data-spy="scroll"</code> to the element you want to spy on (most typically this would be the body) and <code>data-target=".navbar"</code> to select which nav to use. You'll want to use scrollspy with a <code>.nav</code> component.</p>
@@ -545,11 +565,12 @@ $('#myModal').on('hidden', function () {
...
@@ -545,11 +565,12 @@ $('#myModal').on('hidden', function () {
<h3>Methods</h3>
<h3>Methods</h3>
<h4>.scrollspy('refresh')</h4>
<h4>.scrollspy('refresh')</h4>
<p>When using scrollspy in conjunction with adding or removing of elements from the DOM, you'll need to call the refresh method like so:</p>
<p>When using scrollspy in conjunction with adding or removing of elements from the DOM, you'll need to call the refresh method like so:</p>
<preclass="prettyprint linenums">
{% highlight js linenos %}
$('[data-spy="scroll"]').each(function () {
$('[data-spy="scroll"]').each(function () {
var $spy = $(this).scrollspy('refresh')
var $spy = $(this).scrollspy('refresh')
});
});
</pre>
{% endhighlight %}
<h3>Options</h3>
<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=""</code>.</p>
<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=""</code>.</p>
<p>Enable tabbable tabs via JavaScript (each tab needs to be activated individually):</p>
<p>Enable tabbable tabs via JavaScript (each tab needs to be activated individually):</p>
<preclass="prettyprint linenums">
{% highlight js linenos %}
$('#myTab a').click(function (e) {
$('#myTab a').click(function (e) {
e.preventDefault();
e.preventDefault();
$(this).tab('show');
$(this).tab('show');
})</pre>
})
{% endhighlight %}
<p>You can activate individual tabs in several ways:</p>
<p>You can activate individual tabs in several ways:</p>
<preclass="prettyprint linenums">
{% highlight js linenos %}
$('#myTab a[href="#profile"]').tab('show'); // Select tab by name
$('#myTab a[href="#profile"]').tab('show'); // Select tab by name
$('#myTab a:first').tab('show'); // Select first tab
$('#myTab a:first').tab('show'); // Select first tab
$('#myTab a:last').tab('show'); // Select last tab
$('#myTab a:last').tab('show'); // Select last tab
$('#myTab li:eq(2) a').tab('show'); // Select third tab (0-indexed)
$('#myTab li:eq(2) a').tab('show'); // Select third tab (0-indexed)
</pre>
{% endhighlight %}
<h3>Markup</h3>
<h3>Markup</h3>
<p>You can activate a tab or pill navigation without writing any JavaScript by simply specifying <code>data-toggle="tab"</code> or <code>data-toggle="pill"</code> on an element. Adding the <code>nav</code> and <code>nav-tabs</code> classes to the tab <code>ul</code> will apply the Bootstrap tab styling.</p>
<p>You can activate a tab or pill navigation without writing any JavaScript by simply specifying <code>data-toggle="tab"</code> or <code>data-toggle="pill"</code> on an element. Adding the <code>nav</code> and <code>nav-tabs</code> classes to the tab <code>ul</code> will apply the Bootstrap tab styling.</p>
Activates a tab element and content container. Tab should have either a <code>data-target</code> or an <code>href</code> targeting a container node in the DOM.
Activates a tab element and content container. Tab should have either a <code>data-target</code> or an <code>href</code> targeting a container node in the DOM.
<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-animation=""</code>.</p>
<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-animation=""</code>.</p>
...
@@ -825,23 +852,30 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
...
@@ -825,23 +852,30 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
</div>
</div>
<h3>Markup</h3>
<h3>Markup</h3>
<preclass="prettyprint linenums"><a href="#" data-toggle="tooltip" title="first tooltip">hover over me</a></pre>
{% highlight html linenos %}
<ahref="#"data-toggle="tooltip"title="first tooltip">Hover over me</a>
{% endhighlight %}
<h3>Methods</h3>
<h3>Methods</h3>
<h4>$().tooltip(options)</h4>
<h4>$().tooltip(options)</h4>
<p>Attaches a tooltip handler to an element collection.</p>
<p>Attaches a tooltip handler to an element collection.</p>
<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-animation=""</code>.</p>
<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-animation=""</code>.</p>
...
@@ -1003,18 +1037,22 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
...
@@ -1003,18 +1037,22 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
<h3>Methods</h3>
<h3>Methods</h3>
<h4>$().popover(options)</h4>
<h4>$().popover(options)</h4>
<p>Initializes popovers for an element collection.</p>
<p>Initializes popovers for an element collection.</p>
{% highlight html linenos %}<aclass="close"data-dismiss="alert"href="#">×</a>{% endhighlight %}
<h3>Methods</h3>
<h3>Methods</h3>
<h4>$().alert()</h4>
<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>
<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>
<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>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>.
<ahref="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>.
<ahref="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>.
</div>
</div>
<h4>$().button('reset')</h4>
<h4>$().button('reset')</h4>
<p>Resets button state - swaps text to original text.</p>
<p>Resets button state - swaps text to original text.</p>
<h4>$().button(string)</h4>
<h4>$().button(string)</h4>
<p>Resets button state - swaps text to any data defined text state.</p>
<p>Resets button state - swaps text to any data defined text state.</p>
<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>
<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>
...
@@ -1334,17 +1406,21 @@ $('#my-alert').bind('closed', function () {
...
@@ -1334,17 +1406,21 @@ $('#my-alert').bind('closed', function () {
<h3>Methods</h3>
<h3>Methods</h3>
<h4>.collapse(options)</h4>
<h4>.collapse(options)</h4>
<p>Activates your content as a collapsible element. Accepts an optional options <code>object</code>.
<p>Activates your content as a collapsible element. Accepts an optional options <code>object</code>.
<preclass="prettyprint linenums">
{% highlight js linenos %}
$('#myCollapsible').collapse({
$('#myCollapsible').collapse({
toggle: false
toggle: false
})
})
</pre>
{% endhighlight %}
<h4>.collapse('toggle')</h4>
<h4>.collapse('toggle')</h4>
<p>Toggles a collapsible element to shown or hidden.</p>
<p>Toggles a collapsible element to shown or hidden.</p>
<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>
<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>
...
@@ -1498,21 +1588,27 @@ $('#myCollapsible').on('hidden', function () {
...
@@ -1498,21 +1588,27 @@ $('#myCollapsible').on('hidden', function () {
</table>
</table>
<h3>Methods</h3>
<h3>Methods</h3>
<h4>.carousel(options)</h4>
<h4>.carousel(options)</h4>
<p>Initializes the carousel with an optional options <code>object</code> and starts cycling through items.</p>
<p>Initializes the carousel with an optional options <code>object</code> and starts cycling through items.</p>
<preclass="prettyprint linenums">
{% highlight html linenos %}
$('.carousel').carousel({
$('.carousel').carousel({
interval: 2000
interval: 2000
})
})
</pre>
{% endhighlight %}
<h4>.carousel('cycle')</h4>
<h4>.carousel('cycle')</h4>
<p>Cycles through the carousel items from left to right.</p>
<p>Cycles through the carousel items from left to right.</p>
<h4>.carousel('pause')</h4>
<h4>.carousel('pause')</h4>
<p>Stops the carousel from cycling through items.</p>
<p>Stops the carousel from cycling through items.</p>
<h4>.carousel(number)</h4>
<h4>.carousel(number)</h4>
<p>Cycles the carousel to a particular frame (0 based, similar to an array).</p>
<p>Cycles the carousel to a particular frame (0 based, similar to an array).</p>
<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-source=""</code>.</p>
<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-source=""</code>.</p>
...
@@ -1649,7 +1750,9 @@ $('.carousel').carousel({
...
@@ -1649,7 +1750,9 @@ $('.carousel').carousel({
<h3>Via data attributes</h3>
<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>
<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>
<p>When using affix in conjunction with adding or removing of elements from the DOM, you'll want to call the refresh method:</p>
<p>When using affix in conjunction with adding or removing of elements from the DOM, you'll want to call the refresh method:</p>
<preclass="prettyprint linenums">
{% highlight js linenos %}
$('[data-spy="affix"]').each(function () {
$('[data-spy="affix"]').each(function () {
$(this).affix('refresh')
$(this).affix('refresh')
});
});
</pre>
{% endhighlight %}
<h3>Options</h3>
<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>
<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>