1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-26 21:39:08 +02:00

Merge branch '2.0-wip' of github.com:twitter/bootstrap into 2.0-wip

Conflicts:
	bootstrap.css
	docs/javascript.html
This commit is contained in:
Mark Otto
2011-12-21 18:39:02 -06:00
32 changed files with 9848 additions and 525 deletions

26
bootstrap.css vendored
View File

@@ -6,7 +6,7 @@
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Designed and built with all the love in the world @twitter by @mdo and @fat. * Designed and built with all the love in the world @twitter by @mdo and @fat.
* Date: Wed Dec 21 18:20:33 CST 2011 * Date: Wed Dec 21 18:38:56 CST 2011
*/ */
html, body { html, body {
margin: 0; margin: 0;
@@ -2466,6 +2466,18 @@ button.btn::-moz-focus-inner, input[type=submit].btn::-moz-focus-inner {
-moz-opacity: 0.8; -moz-opacity: 0.8;
opacity: 0.8; opacity: 0.8;
} }
.twipsy.above {
margin-top: -2px;
}
.twipsy.right {
margin-left: 2px;
}
.twipsy.below {
margin-top: 2px;
}
.twipsy.left {
margin-left: -2px;
}
.twipsy.above .twipsy-arrow { .twipsy.above .twipsy-arrow {
bottom: 0; bottom: 0;
left: 50%; left: 50%;
@@ -2522,6 +2534,18 @@ button.btn::-moz-focus-inner, input[type=submit].btn::-moz-focus-inner {
display: none; display: none;
padding: 5px; padding: 5px;
} }
.popover.above {
margin-top: -5px;
}
.popover.right {
margin-left: 5px;
}
.popover.below {
margin-top: 5px;
}
.popover.left {
margin-left: -5px;
}
.popover.above .arrow { .popover.above .arrow {
bottom: 0; bottom: 0;
left: 50%; left: 50%;

10
bootstrap.min.css vendored
View File

@@ -321,13 +321,21 @@ button.btn::-moz-focus-inner,input[type=submit].btn::-moz-focus-inner{padding:0;
.modal-footer:after{clear:both;} .modal-footer:after{clear:both;}
.modal-footer .btn{float:right;margin-left:5px;} .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=0);-moz-opacity:0;opacity:0;}.twipsy.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{margin-top:-2px;}
.twipsy.right{margin-left:2px;}
.twipsy.below{margin-top:2px;}
.twipsy.left{margin-left:-2px;}
.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.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.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;} .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;}
.twipsy.right .twipsy-arrow{top:50%;left:0;margin-top:-5px;border-top:5px solid transparent;border-bottom:5px solid transparent;border-right:5px solid #000000;} .twipsy.right .twipsy-arrow{top:50%;left:0;margin-top:-5px;border-top:5px solid transparent;border-bottom:5px solid transparent;border-right:5px solid #000000;}
.twipsy-inner{max-width:200px;padding:3px 8px;color:white;text-align:center;text-decoration:none;background-color:#000000;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;} .twipsy-inner{max-width:200px;padding:3px 8px;color:white;text-align:center;text-decoration:none;background-color:#000000;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;}
.twipsy-arrow{position:absolute;width:0;height:0;} .twipsy-arrow{position:absolute;width:0;height:0;}
.popover{position:absolute;top:0;left:0;z-index:1000;display:none;padding:5px;}.popover.above .arrow{bottom:0;left:50%;margin-left:-5px;border-left:5px solid transparent;border-right:5px solid transparent;border-top:5px solid #000000;} .popover{position:absolute;top:0;left:0;z-index:1000;display:none;padding:5px;}.popover.above{margin-top:-5px;}
.popover.right{margin-left:5px;}
.popover.below{margin-top:5px;}
.popover.left{margin-left:-5px;}
.popover.above .arrow{bottom:0;left:50%;margin-left:-5px;border-left:5px solid transparent;border-right:5px solid transparent;border-top:5px solid #000000;}
.popover.right .arrow{top:50%;left:0;margin-top:-5px;border-top:5px solid transparent;border-bottom:5px solid transparent;border-right:5px solid #000000;} .popover.right .arrow{top:50%;left:0;margin-top:-5px;border-top:5px solid transparent;border-bottom:5px solid transparent;border-right:5px solid #000000;}
.popover.below .arrow{top:0;left:50%;margin-left:-5px;border-left:5px solid transparent;border-right:5px solid transparent;border-bottom:5px solid #000000;} .popover.below .arrow{top:0;left:50%;margin-left:-5px;border-left:5px solid transparent;border-right:5px solid transparent;border-bottom:5px solid #000000;}
.popover.left .arrow{top:50%;right:0;margin-top:-5px;border-top:5px solid transparent;border-bottom:5px solid transparent;border-left:5px solid #000000;} .popover.left .arrow{top:50%;right:0;margin-top:-5px;border-top:5px solid transparent;border-bottom:5px solid transparent;border-left:5px solid #000000;}

View File

@@ -68,7 +68,7 @@ $(function(){
// POSITION STATIC TWIPSIES // POSITION STATIC TWIPSIES
// ======================== // ========================
$(window).bind( 'load resize', function () { $(window).on('load resize', function () {
$(".twipsies a").each(function () { $(".twipsies a").each(function () {
$(this) $(this)
.twipsy({ .twipsy({

View File

@@ -25,7 +25,8 @@
<!-- Le javascript --> <!-- Le javascript -->
<!-- placed up here so that the inline demos can be next to their markup --> <!-- placed up here so that the inline demos can be next to their markup -->
<script src="http://code.jquery.com/jquery-1.7.min.js"></script> <!-- <script src="http://code.jquery.com/jquery-1.7.min.js"></script> -->
<script src="../js/tests/vendor/jquery.js"></script>
<script src="assets/js/google-code-prettify/prettify.js"></script> <script src="assets/js/google-code-prettify/prettify.js"></script>
<script>$(function () { prettyPrint() })</script> <script>$(function () { prettyPrint() })</script>
<script src="../js/bootstrap-transition.js"></script> <script src="../js/bootstrap-transition.js"></script>
@@ -41,15 +42,13 @@
<script> <script>
$(function () { $(function () {
// twipsy demo // twipsy demo
$("a[rel=twipsy]").twipsy({ $('.twipsy-demo.well').twipsy({
live: true selector: "a[rel=twipsy]"
}) })
//popover demo //popover demo
$("a[rel=popover]") $("a[rel=popover]")
.popover({ .popover()
offset: 10
})
.click(function(e) { .click(function(e) {
e.preventDefault() e.preventDefault()
}) })
@@ -83,7 +82,7 @@
================================================== --> ================================================== -->
<header class="jumbotron subhead" id="overview"> <header class="jumbotron subhead" id="overview">
<h1>Javascript for Bootstrap</h1> <h1>Javascript for Bootstrap</h1>
<p class="lead">Bring Bootstrap's components to life with flexible, custom javascript plugins for many of our custom components that work with <a href="http://jquery.com/" target="_blank">jQuery</a> and <a href="http://ender.no.de" target="_blank">Ender</a>.</p> <p class="lead">Bring Bootstrap's components to life &mdash; now with 12 custom <a href="http://jquery.com/" target="_blank">jQuery</a> plugins.
</header> </header>
@@ -101,8 +100,8 @@
</div> </div>
<div class="span9"> <div class="span9">
<h3>What's included</h3> <h3>What's included</h3>
<p>Bring some of Bootstrap's primary components to life with new custom plugins that work with <a href="http://jquery.com/" target="_blank">jQuery</a> and <a href="http://ender.no.de" target="_blank">Ender</a>. We encourage you to extend and modify them to fit your specific development needs.</p> <p>Bring some of Bootstrap's primary components to life with custom <a href="http://jquery.com/" target="_blank">jQuery</a> plugins. We encourage you to extend and modify them to fit your specific development needs.</p>
<table class="striped-table"> <table class="bordered-table striped-table">
<thead> <thead>
<tr> <tr>
<th style="width: 150px;">File</th> <th style="width: 150px;">File</th>
@@ -111,36 +110,40 @@
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td><a href="./javascript.html#modal">bootstrap-modal.js</a></td> <td><a href="./javascript.html#transition">bootstrap-transition.js</a></td>
<td>Our Modal plugin is a <strong>super</strong> slim take on the traditional modal js plugin! We took special care to include only the bare functionality that we require at twitter.</td> <td>The transition plugin is required for adding animation to other bootstrap plugins. Include this plugin (only once) when sliding in modals or fading out alerts.</td>
</tr> </tr>
<tr> <tr>
<td><a href="./javascript.html#alert">bootstrap-alert.js</a></td> <td><a href="./javascript.html#modal">bootstrap-modal.js</a></td>
<td>The alert plugin is a super tiny class for adding close functionality to alerts.</td> <td>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 here at twitter.</td>
</tr> </tr>
<tr> <tr>
<td><a href="./javascript.html#dropdown">bootstrap-dropdown.js</a></td> <td><a href="./javascript.html#dropdown">bootstrap-dropdown.js</a></td>
<td>This plugin is for adding dropdown interaction to the bootstrap navbar or tabbed navigations.</td> <td>This plugin is for adding generic dropdown interactions to things like navigation top bars and tabs.</td>
</tr> </tr>
<tr> <tr>
<td><a href="./javascript.html#scrollspy">bootstrap-scrollspy.js</a></td> <td><a href="./javascript.html#scrollspy">bootstrap-scrollspy.js</a></td>
<td>The ScrollSpy plugin is for adding an auto updating nav based on scroll position to the bootstrap navbar.</td> <td>The ScrollSpy plugin is for automatically updating nav targets based on scroll position.</td>
</tr> </tr>
<tr> <tr>
<td><a href="./javascript.html#tabs">bootstrap-tab.js</a></td> <td><a href="./javascript.html#tab">bootstrap-tab.js</a></td>
<td>This plugin adds quick, dynamic tab and pill functionality for cycling through local content.</td> <td>This plugin adds quick, dynamic tab and pill functionality for transitioning through local content.</td>
</tr>
<tr> <tr>
<td><a href="./javascript.html#twipsy">bootstrap-twipsy.js</a></td> <td><a href="./javascript.html#twipsy">bootstrap-twipsy.js</a></td>
<td>Based on the excellent jQuery.tipsy plugin written by Jason Frame; twipsy is an updated version, which doesn't rely on images, uses css3 for animations, and data-attributes for local title storage!</td> <td>Inspired by the excellent jQuery.tipsy plugin written by Jason Frame; twipsy is an updated version, which doesn't rely on images, uses css3 for animations, data-attributes for local title storage, and now jquery 1.7's new event api!</td>
</tr> </tr>
<tr> <tr>
<td><a href="./javascript.html#popover">bootstrap-popover.js</a></td> <td><a href="./javascript.html#popover">bootstrap-popover.js</a></td>
<td>The popover plugin provides a simple interface for adding popovers to your application. It extends the <a href="#twipsy">bootstrap-twipsy.js</a> plugin, so be sure to grab that file as well when including popovers in your project!</td> <td>The popover plugin provides a simple interface for adding popovers to your application. It extends the <a href="#twipsy">bootstrap-twipsy.js</a> plugin, so be sure to grab that file as well when including popovers in your project!</td>
</tr> </tr>
</tr>
<tr>
<td><a href="./javascript.html#alert">bootstrap-alert.js</a></td>
<td>The alert plugin is a tiny class for adding close functionality to alerts.</td>
</tr>
<tr> <tr>
<td><a href="./javascript.html#button">bootstrap-button.js</a></td> <td><a href="./javascript.html#button">bootstrap-button.js</a></td>
<td>This plugin offers additional functionality for managing button state.</td> <td>This plugin offers additional functionality for managing button state in single buttons and button sets.</td>
</tr> </tr>
<tr> <tr>
<td><a href="./javascript.html#collapse">bootstrap-collapse.js</a></td> <td><a href="./javascript.html#collapse">bootstrap-collapse.js</a></td>
@@ -151,7 +154,6 @@
<h3>Is javascript necessary?</h3> <h3>Is javascript necessary?</h3>
<p><strong>Nope!</strong> Bootstrap is designed first and foremost to be a CSS library. This javascript provides a basic interactive layer on top of the included styles.</p> <p><strong>Nope!</strong> Bootstrap is designed first and foremost to be a CSS library. This javascript provides a basic interactive layer on top of the included styles.</p>
<p>However, for those who do need javascript, we've provided the plugins above to help you understand how to integrate Bootstrap with javascript and to give you a quick, lightweight option for the basic functionality right away.</p> <p>However, for those who do need javascript, we've provided the plugins above to help you understand how to integrate Bootstrap with javascript and to give you a quick, lightweight option for the basic functionality right away.</p>
<p>For more information and to see some live demos, please refer to our <a href="./javascript.html">plugin documentation page</a>.</p>
</div> </div>
</div> </div>
</section> </section>
@@ -173,7 +175,7 @@
<h3>Using bootstrap-modal</h3> <h3>Using bootstrap-modal</h3>
<pre class="prettyprint linenums">$('#myModal').modal(options)</pre> <pre class="prettyprint linenums">$('#myModal').modal(options)</pre>
<h3>Options</h3> <h3>Options</h3>
<table class="striped-table"> <table class="bordered-table striped-table">
<thead> <thead>
<tr> <tr>
<th style="width: 100px;">Name</th> <th style="width: 100px;">Name</th>
@@ -195,16 +197,11 @@
<td>true</td> <td>true</td>
<td>Closes the modal when escape key is pressed</td> <td>Closes the modal when escape key is pressed</td>
</tr> </tr>
<tr>
<td>show</td>
<td>boolean</td>
<td>true</td>
<td>Opens modal on class initialization</td>
</tr>
</tbody> </tbody>
</table> </table>
<h3>Markup</h3> <h3>Markup</h3>
<p>You can activate modals on your page easily without having to write a single line of javascript. Just set <code>data-toggle="modal"</code> on a controller element with a <code>data-target="#foo"</code> or <code>href="#foo"</code> 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.</p> <p>You can activate modals on your page easily without having to write a single line of javascript. Just set <code>data-toggle="modal"</code> on a controller element with a <code>data-target="#foo"</code> or <code>href="#foo"</code> which corresponds to a modal element id, and when clicked, it will launch your modal.</p>
<p>Also, to add options to your modal instance, just include them as additional data attributes on either the control element or the modal markup itself.</p>
<pre class="prettyprint linenums"> <pre class="prettyprint linenums">
&lt;a class="btn" data-toggle="modal" href="#myModal" &gt;Launch Modal&lt;/a&gt; &lt;a class="btn" data-toggle="modal" href="#myModal" &gt;Launch Modal&lt;/a&gt;
</pre> </pre>
@@ -227,7 +224,7 @@ $('#myModal').modal({
<pre class="prettyprint linenums">$('#myModal').modal('hide')</pre> <pre class="prettyprint linenums">$('#myModal').modal('hide')</pre>
<h3>Events</h3> <h3>Events</h3>
<p>Bootstrap's modal class exposes a few events for hooking into modal functionality. </p> <p>Bootstrap's modal class exposes a few events for hooking into modal functionality. </p>
<table class="striped-table"> <table class="bordered-table striped-table">
<thead> <thead>
<tr> <tr>
<th style="width: 150px;">Event</th> <th style="width: 150px;">Event</th>
@@ -255,7 +252,7 @@ $('#myModal').modal({
</table> </table>
<pre class="prettyprint linenums"> <pre class="prettyprint linenums">
$('#myModal').bind('hidden', function () { $('#myModal').on('hidden', function () {
// do something ... // do something ...
})</pre> })</pre>
<h3>Demo</h3> <h3>Demo</h3>
@@ -291,19 +288,21 @@ $('#myModal').bind('hidden', function () {
</div> </div>
<div class="row"> <div class="row">
<div class="span3 columns"> <div class="span3 columns">
<p>This plugin is for adding dropdown interaction to the Bootstrap navbar or tabbed navigations.</p> <p>This plugin is for adding generic dropdown interactions to things like navigation top bars and tabs.</p>
<a href="../js/bootstrap-dropdown.js" target="_blank" class="btn primary">Download</a> <a href="../js/bootstrap-dropdown.js" target="_blank" class="btn primary">Download</a>
</div> </div>
<div class="span9 columns"> <div class="span9 columns">
<h3>Using bootstrap-dropdown.js</h3> <h3>Using bootstrap-dropdown.js</h3>
<pre class="prettyprint linenums">$('.dropdown-toggle').dropdown()</pre> <pre class="prettyprint linenums">$('.dropdown-toggle').dropdown()</pre>
<h3>Markup</h3> <h3>Markup</h3>
<p>To quickly add dropdown functionality to any element just add <code>data-toggle="dropdown"</code>. Any valid bootstrap dropdown will automatically be activated.</p> <p>To quickly add dropdown functionality to any element just add <code>data-toggle="dropdown"</code> and any valid bootstrap dropdown will automatically be activated.</p>
<p><span class="label notice">Notice</span> For added control and flexibility, optionally specify a <code>data-target="#fat"</code> or <code>href="#fat"</code> - this allows you to target specific dropdowns.</p>
<pre class="prettyprint linenums"> <pre class="prettyprint linenums">
&lt;ul class="tabs"&gt; &lt;ul class="tabs"&gt;
&lt;li class="active"&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li class="active"&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt;
&lt;li class="dropdown"&gt; &lt;li id="secondary" class="dropdown"&gt;
&lt;a href="#" class="dropdown-toggle" data-toggle="dropdown"&gt;Dropdown&lt;/a&gt; &lt;a href="#secondary" class="dropdown-toggle" data-toggle="dropdown"&gt;Dropdown&lt;/a&gt;
&lt;ul class="dropdown-menu"&gt; &lt;ul class="dropdown-menu"&gt;
&lt;li&gt;&lt;a href="#"&gt;Secondary link&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Secondary link&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;Something else here&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Something else here&lt;/a&gt;&lt;/li&gt;
@@ -330,7 +329,7 @@ $('#myModal').bind('hidden', function () {
<input type="text" class="search-query span2" placeholder="Search"> <input type="text" class="search-query span2" placeholder="Search">
</form> </form>
<ul class="nav secondary-nav"> <ul class="nav secondary-nav">
<li class="dropdown"> <li id="fat-menu" class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown 1</a> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown 1</a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a href="#">Secondary link</a></li> <li><a href="#">Secondary link</a></li>
@@ -339,7 +338,7 @@ $('#myModal').bind('hidden', function () {
<li><a href="#">Another link</a></li> <li><a href="#">Another link</a></li>
</ul> </ul>
</li> </li>
<li class="dropdown"> <li id="mdo-menu" class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown 2</a> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown 2</a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a href="#">Secondary link</a></li> <li><a href="#">Secondary link</a></li>
@@ -365,7 +364,7 @@ $('#myModal').bind('hidden', function () {
</div> </div>
<div class="row"> <div class="row">
<div class="span3 columns"> <div class="span3 columns">
<p>This plugin is for adding the scrollspy (auto updating nav) interaction to the bootstrap navbar.</p> <p>The ScrollSpy plugin is for automatically updating nav targets based on scroll position.</p>
<a href="../js/bootstrap-scrollspy.js" target="_blank" class="btn primary">Download</a> <a href="../js/bootstrap-scrollspy.js" target="_blank" class="btn primary">Download</a>
</div> </div>
<div class="span9 columns"> <div class="span9 columns">
@@ -433,13 +432,13 @@ $('#myModal').bind('hidden', function () {
<!-- Tabs <!-- Tabs
================================================== --> ================================================== -->
<section id="tabs"> <section id="tab">
<div class="page-header"> <div class="page-header">
<h1>Tabs <small>bootstrap-tab.js</small></h1> <h1>Tab <small>bootstrap-tab.js</small></h1>
</div> </div>
<div class="row"> <div class="row">
<div class="span3 columns"> <div class="span3 columns">
<p>This plugin adds quick, dynamic tab and pill functionality.</p> <p>This plugin adds quick, dynamic tab and pill functionality for transitioning through local content.</p>
<a href="../js/bootstrap-tab.js" target="_blank" class="btn primary">Download</a> <a href="../js/bootstrap-tab.js" target="_blank" class="btn primary">Download</a>
</div> </div>
<div class="span9 columns"> <div class="span9 columns">
@@ -456,7 +455,7 @@ $('#myModal').bind('hidden', function () {
<h3>Methods</h3> <h3>Methods</h3>
<h4>$().tab</h4> <h4>$().tab</h4>
<p> <p>
Activates tab functionality for a given element controller. Tab should have either a `data-target` or an `href` referencing a node in the dom. Activates a tab element and content container. Tab should have either a `data-target` or an `href` targeting a container node in the dom.
</p> </p>
<pre class="prettyprint linenums"> <pre class="prettyprint linenums">
&lt;ul class="tabs"&gt; &lt;ul class="tabs"&gt;
@@ -480,7 +479,7 @@ $('#myModal').bind('hidden', function () {
&lt;/script&gt;</pre> &lt;/script&gt;</pre>
</p> </p>
<h3>Events</h3> <h3>Events</h3>
<table class="zebra-striped"> <table class="bordered-table striped-table">
<thead> <thead>
<tr> <tr>
<th style="width: 150px;">Event</th> <th style="width: 150px;">Event</th>
@@ -493,14 +492,14 @@ $('#myModal').bind('hidden', function () {
<td>This event fires on tab show, but before the new tab has been shown. Use <code>event.target</code> and <code>event.relatedTarget</code> to target the active tab and the previous active tab (if available) respectively.</td> <td>This event fires on tab show, but before the new tab has been shown. Use <code>event.target</code> and <code>event.relatedTarget</code> to target the active tab and the previous active tab (if available) respectively.</td>
</tr> </tr>
<tr> <tr>
<td>show</td> <td>shown</td>
<td>This event fires on tab show after a tab has been shown. Use <code>event.target</code> and <code>event.relatedTarget</code> to target the active tab and the previous active tab (if available) respectively.</td> <td>This event fires on tab show after a tab has been shown. Use <code>event.target</code> and <code>event.relatedTarget</code> to target the active tab and the previous active tab (if available) respectively.</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<pre class="prettyprint linenums"> <pre class="prettyprint linenums">
$('a[data-toggle="tab"]').bind('shown', function (e) { $('a[data-toggle="tab"]').on('shown', function (e) {
e.target // activated tab e.target // activated tab
e.relatedTarget // previous tab e.relatedTarget // previous tab
})</pre> })</pre>
@@ -519,22 +518,22 @@ $('a[data-toggle="tab"]').bind('shown', function (e) {
</li> </li>
</ul> </ul>
<div id="myTabContent" class="tab-content"> <div id="myTabContent" class="tab-content">
<div class="active tab-pane" id="home"> <div class="tab-pane fade in active" id="home">
<p>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.</p> <p>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.</p>
</div> </div>
<div class="tab-pane" id="profile"> <div class="tab-pane fade" id="profile">
<p>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.</p> <p>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.</p>
</div> </div>
<div class="tab-pane" id="messages"> <div class="tab-pane fade" id="messages">
<p>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.</p> <p>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.</p>
</div> </div>
<div class="tab-pane" id="settings"> <div class="tab-pane fade" id="settings">
<p>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.</p> <p>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.</p>
</div> </div>
<div class="tab-pane" id="dropdown1"> <div class="tab-pane fade" id="dropdown1">
<p>Etsy mixtape wayfarers, ethical wes anderson tofu before they sold out mcsweeney's organic lomo retro fanny pack lo-fi farm-to-table readymade. Messenger bag gentrify pitchfork tattooed craft beer, iphone skateboard locavore carles etsy salvia banksy hoodie helvetica. DIY synth PBR banksy irony. Leggings gentrify squid 8-bit cred pitchfork. Williamsburg banh mi whatever gluten-free, carles pitchfork biodiesel fixie etsy retro mlkshk vice blog. Scenester cred you probably haven't heard of them, vinyl craft beer blog stumptown. Pitchfork sustainable tofu synth chambray yr.</p> <p>Etsy mixtape wayfarers, ethical wes anderson tofu before they sold out mcsweeney's organic lomo retro fanny pack lo-fi farm-to-table readymade. Messenger bag gentrify pitchfork tattooed craft beer, iphone skateboard locavore carles etsy salvia banksy hoodie helvetica. DIY synth PBR banksy irony. Leggings gentrify squid 8-bit cred pitchfork. Williamsburg banh mi whatever gluten-free, carles pitchfork biodiesel fixie etsy retro mlkshk vice blog. Scenester cred you probably haven't heard of them, vinyl craft beer blog stumptown. Pitchfork sustainable tofu synth chambray yr.</p>
</div> </div>
<div class="tab-pane" id="dropdown2"> <div class="tab-pane fade" id="dropdown2">
<p>Trust fund seitan letterpress, keytar raw denim keffiyeh etsy art party before they sold out master cleanse gluten-free squid scenester freegan cosby sweater. Fanny pack portland seitan DIY, art party locavore wolf cliche high life echo park Austin. Cred vinyl keffiyeh DIY salvia PBR, banh mi before they sold out farm-to-table VHS viral locavore cosby sweater. Lomo wolf viral, mustache readymade thundercats keffiyeh craft beer marfa ethical. Wolf salvia freegan, sartorial keffiyeh echo park vegan.</p> <p>Trust fund seitan letterpress, keytar raw denim keffiyeh etsy art party before they sold out master cleanse gluten-free squid scenester freegan cosby sweater. Fanny pack portland seitan DIY, art party locavore wolf cliche high life echo park Austin. Cred vinyl keffiyeh DIY salvia PBR, banh mi before they sold out farm-to-table VHS viral locavore cosby sweater. Lomo wolf viral, mustache readymade thundercats keffiyeh craft beer marfa ethical. Wolf salvia freegan, sartorial keffiyeh echo park vegan.</p>
</div> </div>
</div> </div>
@@ -551,14 +550,14 @@ $('a[data-toggle="tab"]').bind('shown', function (e) {
</div> </div>
<div class="row"> <div class="row">
<div class="span3 columns"> <div class="span3 columns">
<p>Based on the excellent jQuery.tipsy plugin written by Jason Frame; twipsy is an updated version, which doesn't rely on images, uses css3 for animations, and data-attributes for title storage!</p> <p>Inspired by the excellent jQuery.tipsy plugin written by Jason Frame; twipsy is an updated version, which doesn't rely on images, uses css3 for animations, data-attributes for local title storage, and now jquery 1.7's new event api!</p>
<a href="../js/bootstrap-twipsy.js" target="_blank" class="btn primary">Download</a> <a href="../js/bootstrap-twipsy.js" target="_blank" class="btn primary">Download</a>
</div> </div>
<div class="span9 columns"> <div class="span9 columns">
<h3>Using bootstrap-twipsy.js</h3> <h3>Using bootstrap-twipsy.js</h3>
<pre class="prettyprint linenums">$('#example').twipsy(options)</pre> <pre class="prettyprint linenums">$('#example').twipsy(options)</pre>
<h3>Options</h3> <h3>Options</h3>
<table class="striped-table"> <table class="bordered-table striped-table">
<thead> <thead>
<tr> <tr>
<th style="width: 100px;">Name</th> <th style="width: 100px;">Name</th>
@@ -569,7 +568,7 @@ $('a[data-toggle="tab"]').bind('shown', function (e) {
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td>animate</td> <td>animation</td>
<td>boolean</td> <td>boolean</td>
<td>true</td> <td>true</td>
<td>apply a css fade transition to the tooltip</td> <td>apply a css fade transition to the tooltip</td>
@@ -581,16 +580,16 @@ $('a[data-toggle="tab"]').bind('shown', function (e) {
<td>how to position the tooltip - above | below | left | right</td> <td>how to position the tooltip - above | below | left | right</td>
</tr> </tr>
<tr> <tr>
<td>live</td> <td>selector</td>
<td>boolean</td> <td>string</td>
<td>false</td> <td>false</td>
<td>use event delegation instead of individual event handlers</td> <td>If a selector is provided, twipsy objects will be delegated to the specified targets.</td>
</tr> </tr>
<tr> <tr>
<td>offset</td> <td>title</td>
<td>number</td> <td>string | function</td>
<td>0</td> <td>''</td>
<td>pixel offset of tooltip from target element</td> <td>default title value if `title` tag isn't present</td>
</tr> </tr>
<tr> <tr>
<td>trigger</td> <td>trigger</td>
@@ -612,7 +611,8 @@ $('a[data-toggle="tab"]').bind('shown', function (e) {
</table> </table>
<p><span class="label notice">Notice</span> Individual twipsy instance options can alternatively be specified through the use of data attributes.</code></p> <p><span class="label notice">Notice</span> Individual twipsy instance options can alternatively be specified through the use of data attributes.</code></p>
<h3>Markup</h3> <h3>Markup</h3>
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. :) <p>
For performance reasons, the Twipsy and Popover data-apis are opt in. If you would like to use them just specify a selector option.</p>
<h3>Methods</h3> <h3>Methods</h3>
<h4>$().twipsy(options)</h4> <h4>$().twipsy(options)</h4>
<p>Attaches a twipsy handler to an element collection.</p> <p>Attaches a twipsy handler to an element collection.</p>
@@ -623,8 +623,8 @@ $('a[data-toggle="tab"]').bind('shown', function (e) {
<p>Hides an elements twipsy.</p> <p>Hides an elements twipsy.</p>
<pre class="prettyprint linenums">$('#element').twipsy('hide')</pre> <pre class="prettyprint linenums">$('#element').twipsy('hide')</pre>
<h3>Demo</h3> <h3>Demo</h3>
<div class="well"> <div class="twipsy-demo well">
<p class="muted">Tight pants next level keffiyeh <a href="#" rel='twipsy' title='Some title text'>you probably</a> 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 <a href="#" rel='twipsy' title='Another twipsy'>have a</a> terry richardson vinyl chambray. Beard stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel williamsburg marfa, four loko mcsweeney's cleanse vegan chambray. A <a href="#" rel='twipsy' title='Another one here too'>really ironic</a> artisan whatever keytar, scenester farm-to-table banksy Austin <a href="#" rel='twipsy' title='The last tip!'>twitter handle</a> freegan cred raw denim single-origin coffee viral. <p class="muted">Tight pants next level keffiyeh <a href="#" rel='twipsy' title="first twipsy">you probably</a> 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 <a href="#" rel='twipsy' title='Another twipsy'>have a</a> terry richardson vinyl chambray. Beard stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel williamsburg marfa, four loko mcsweeney's cleanse vegan chambray. A <a href="#" rel='twipsy' title='Another one here too'>really ironic</a> artisan whatever keytar, scenester farm-to-table banksy Austin <a href="#" rel='twipsy' title='The last tip!'>twitter handle</a> freegan cred raw denim single-origin coffee viral.
</p> </p>
</div> </div>
</div> </div>
@@ -647,7 +647,7 @@ $('a[data-toggle="tab"]').bind('shown', function (e) {
<h3>Using bootstrap-popover.js</h3> <h3>Using bootstrap-popover.js</h3>
<pre class="prettyprint linenums">$('#example').popover(options)</pre> <pre class="prettyprint linenums">$('#example').popover(options)</pre>
<h3>Options</h3> <h3>Options</h3>
<table class="striped-table"> <table class="bordered-table striped-table">
<thead> <thead>
<tr> <tr>
<th style="width: 100px;">Name</th> <th style="width: 100px;">Name</th>
@@ -658,17 +658,11 @@ $('a[data-toggle="tab"]').bind('shown', function (e) {
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td>animate</td> <td>animation</td>
<td>boolean</td> <td>boolean</td>
<td>true</td> <td>true</td>
<td>apply a css fade transition to the tooltip</td> <td>apply a css fade transition to the tooltip</td>
</tr> </tr>
<tr>
<td>delay</td>
<td>number | object</td>
<td>0</td>
<td>delay before showing/hiding the tooltip (ms)</td>
</tr>
<tr> <tr>
<td>placement</td> <td>placement</td>
<td>string</td> <td>string</td>
@@ -676,16 +670,10 @@ $('a[data-toggle="tab"]').bind('shown', function (e) {
<td>how to position the popover - above | below | left | right</td> <td>how to position the popover - above | below | left | right</td>
</tr> </tr>
<tr> <tr>
<td>live</td> <td>selector</td>
<td>boolean</td> <td>string</td>
<td>false</td> <td>false</td>
<td>use event delegation instead of individual event handlers</td> <td>if a selector is provided, twipsy objects will be delegated to the specified targets</td>
</tr>
<tr>
<td>offset</td>
<td>number</td>
<td>0</td>
<td>pixel offset of tooltip from target element</td>
</tr> </tr>
<tr> <tr>
<td>trigger</td> <td>trigger</td>
@@ -693,12 +681,34 @@ $('a[data-toggle="tab"]').bind('shown', function (e) {
<td>'hover'</td> <td>'hover'</td>
<td>how tooltip is triggered - hover | focus | manual</td> <td>how tooltip is triggered - hover | focus | manual</td>
</tr> </tr>
<tr>
<td>title</td>
<td>string | function</td>
<td>''</td>
<td>default title value if `title` attribute isn't present</td>
</tr>
<tr>
<td>content</td>
<td>string | function</td>
<td>''</td>
<td>default content value if `data-content` attribute isn't present</td>
</tr>
<tr>
<td>delay</td>
<td>number | object</td>
<td>0</td>
<td>
<p>delay showing/hiding the popover (ms)</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>
</tbody> </tbody>
</table> </table>
<p><span class="label notice">Notice</span> Individual popover instance options can alternatively be specified through the use of data attributes.</code></p> <p><span class="label notice">Notice</span> Individual popover instance options can alternatively be specified through the use of data attributes.</code></p>
<h3>Markup</h3> <h3>Markup</h3>
<p> <p>
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. :) For performance reasons, the Twipsy and Popover data-apis are opt in. If you would like to use them just specify a the selector option.
</p> </p>
<h3>Methods</h3> <h3>Methods</h3>
<h4>$().popover(options)</h4> <h4>$().popover(options)</h4>
@@ -810,7 +820,7 @@ $('a[data-toggle="tab"]').bind('shown', function (e) {
$('.btn').button('complete') $('.btn').button('complete')
&lt;/script&gt;</pre> &lt;/script&gt;</pre>
<h3>Demo</h3> <h3>Demo</h3>
<table class="striped-table"> <table class="bordered-table striped-table">
<tbody> <tbody>
<tr> <tr>
<td>Stateful</td> <td>Stateful</td>
@@ -879,7 +889,7 @@ $('a[data-toggle="tab"]').bind('shown', function (e) {
<h3>Using bootstrap-collapse.js</h3> <h3>Using bootstrap-collapse.js</h3>
<pre class="prettyprint linenums">$(".collapse").collapse()</pre> <pre class="prettyprint linenums">$(".collapse").collapse()</pre>
<h3>Options</h3> <h3>Options</h3>
<table class="striped-table"> <table class="bordered-table striped-table">
<thead> <thead>
<tr> <tr>
<th style="width: 100px;">Name</th> <th style="width: 100px;">Name</th>
@@ -929,7 +939,7 @@ $('#myCollapsible').collapse({
<p> <p>
Bootstrap's collapse class exposes a few events for hooking into collapse functionality. Bootstrap's collapse class exposes a few events for hooking into collapse functionality.
</p> </p>
<table class="striped-table"> <table class="bordered-table striped-table">
<thead> <thead>
<tr> <tr>
<th style="width: 150px;">Event</th> <th style="width: 150px;">Event</th>
@@ -959,7 +969,7 @@ $('#myCollapsible').collapse({
</table> </table>
<pre class="prettyprint linenums"> <pre class="prettyprint linenums">
$('#myCollapsible').bind('hidden', function () { $('#myCollapsible').on('hidden', function () {
// do something ... // do something ...
})</pre> })</pre>
<h3>Demo</h3> <h3>Demo</h3>

View File

@@ -1,5 +1,5 @@
## 2.0 BOOTSTRAP JS PHILOSOPHY ## 2.0 BOOTSTRAP JS PHILOSOPHY
These are the high-level design rules which guide the development of Bootstrap's JS plugins. These are the high-level design rules which guide the development of Bootstrap's plugin apis.
--- ---
@@ -9,11 +9,11 @@ We believe you should be able to use all plugins provided by Bootstrap purely th
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: 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') $('body').off('.data-api')
To target a specific plugin, just include the plugins name as a namespace along with the data-api namespace like this: 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') $('body').off('.alert.data-api')
--- ---
@@ -21,17 +21,19 @@ To target a specific plugin, just include the plugins name as a namespace along
We also believe you should be able to use all plugins provided by Bootstrap purely through the JS 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. All public APIs should be single, chainable methods, and return the collection acted upon.
$(".btn.danger").button("toggle").addClass("fat") $(".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: 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 $("#myModal").modal() // initialized with defaults
$("#myModal").modal({ keyboard: false }) // initialized with now keyboard
$("#myModal").modal('show') // initializes and invokes show immediately afterqwe2
--- ---
### PLUGIN OPTIONS ### OPTIONS
Options should be sparse and add universal value. We should pick the right defaults. Options should be sparse and add universal value. We should pick the right defaults.
@@ -51,7 +53,7 @@ examples:
--- ---
### PLUGIN EVENTS ### 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. 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.
@@ -60,20 +62,36 @@ All events should have an infinitive and past participle form. The infinitive is
--- ---
### CONSTRUCTORS
Each plugin should expose it's raw constructor on a `Constructor` property -- accessed in the following way:
$.fn.popover.Constructor
---
### DATA ACCESSOR
Each plugin stores a copy of the invoked class on an object. This class instance can be accessed directly through jQuery's data api like this:
$('[rel=popover]').data('popover') instanceof $.fn.popover.Constructor
---
### DATA ATTRIBUTES ### DATA ATTRIBUTES
Data attributes should take the following form: Data attributes should take the following form:
- data-*(verb)* - defines main interaction - data-{{verb}}={{plugin}} - defines main interaction
- data-target || href^=# - defined on controller element (if element interacts with an element other than self) - data-target || href^=# - defined on "control" element (if element controls an element other than self)
- data-*(noun)* - defines options for element invocation - data-{{noun}} - defines class instance options
examples: examples:
// control other targets // control other targets
data-toggle="modal" data-target="#foo" data-toggle="modal" data-target="#foo"
data-toggle="collapse" data-target="#foo" data-parent="#foo" data-toggle="collapse" data-target="#foo" data-parent="#bar"
// defined on element they control // defined on element they control
data-spy="scroll" data-spy="scroll"

24
js/bootstrap-alert.js vendored
View File

@@ -27,7 +27,7 @@
var dismiss = '[data-dismiss="alert"]' var dismiss = '[data-dismiss="alert"]'
, Alert = function ( el ) { , Alert = function ( el ) {
$(el).delegate(dismiss, 'click', this.close) $(el).on('click', dismiss, this.close)
} }
Alert.prototype = { Alert.prototype = {
@@ -35,18 +35,22 @@
constructor: Alert constructor: Alert
, close: function ( e ) { , close: function ( e ) {
var $element = $(this) var $this = $(this)
, selector = $this.attr('data-target') || $this.attr('href')
, $parent = $(selector)
$element = $element.hasClass('alert-message') ? $element : $element.parent()
e && e.preventDefault() e && e.preventDefault()
$element.removeClass('in')
$parent.length || ($parent = $this.hasClass('alert-message') ? $this : $this.parent())
$parent.removeClass('in')
function removeElement() { function removeElement() {
$element.remove() $parent.remove()
} }
$.support.transition && $element.hasClass('fade') ? $.support.transition && $parent.hasClass('fade') ?
$element.bind($.support.transition.end, removeElement) : $parent.on($.support.transition.end, removeElement) :
removeElement() removeElement()
} }
@@ -65,14 +69,14 @@
}) })
} }
$.fn.alert.Alert = Alert $.fn.alert.Constructor = Alert
/* ALERT DATA-API /* ALERT DATA-API
* ============== */ * ============== */
$(function () { $(function () {
$('body').delegate(dismiss, 'click.alert.data-api', Alert.prototype.close) $('body').on('click.alert.data-api', dismiss, Alert.prototype.close)
}) })
}( window.jQuery || window.ender ) }( window.jQuery )

View File

@@ -24,16 +24,16 @@
/* BUTTON PUBLIC CLASS DEFINITION /* BUTTON PUBLIC CLASS DEFINITION
* ============================== */ * ============================== */
var Button = function (element, options) { var Button = function ( element, options ) {
this.$element = $(element) this.$element = $(element)
this.settings = $.extend({}, $.fn.button.defaults, options) this.options = $.extend({}, $.fn.button.defaults, options)
} }
Button.prototype = { Button.prototype = {
constructor: Button constructor: Button
, setState: function (state) { , setState: function ( state ) {
var d = 'disabled' var d = 'disabled'
, $el = this.$element , $el = this.$element
, data = $el.data() , data = $el.data()
@@ -42,7 +42,7 @@
state = state + 'Text' state = state + 'Text'
data.resetText || $el.data('resetText', $el[val]()) data.resetText || $el.data('resetText', $el[val]())
$el[val](data[state] || this.settings[state]) $el[val](data[state] || this.options[state])
// push to event loop to allow forms to submit // push to event loop to allow forms to submit
setTimeout(function () { setTimeout(function () {
@@ -83,16 +83,16 @@
loadingText: 'loading...' loadingText: 'loading...'
} }
$.fn.button.Button = Button $.fn.button.Constructor = Button
/* BUTTON DATA-API /* BUTTON DATA-API
* =============== */ * =============== */
$(function () { $(function () {
$('body').delegate('[data-toggle^=button]', 'click.button.data-api', function (e) { $('body').on('click.button.data-api', '[data-toggle^=button]', function ( e ) {
$(e.srcElement).button('toggle') $(e.srcElement).button('toggle')
}) })
}) })
}( window.jQuery || window.ender ) }( window.jQuery )

View File

@@ -25,8 +25,8 @@
/* CAROUSEL CLASS DEFINITION /* CAROUSEL CLASS DEFINITION
* ========================= */ * ========================= */
var Carousel = function ( el ) { var Carousel = function () {
$(el).delegate(dismiss, 'click', this.close)
} }
Carousel.prototype = { Carousel.prototype = {
@@ -40,20 +40,12 @@
$.fn.carousel = function ( option ) { $.fn.carousel = function ( option ) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
, data = $this.data('alert') , data = $this.data('carousel')
if (!data) $this.data('alert', (data = new Alert(this))) if (!data) $this.data('carousel', (data = new Carousel(this)))
if (typeof option == 'string') data[option].call($this) if (typeof option == 'string') data[option].call($this)
}) })
} }
$.fn.carousel.Carousel = Carousel $.fn.carousel.Constructor = Carousel
}( window.jQuery )
/* CAROUSEL DATA-API
* ================= */
// $(function () {
// $('body').delegate(dismiss, 'click.alert.data-api', Alert.prototype.close)
// })
}( window.jQuery || window.ender )

View File

@@ -23,13 +23,13 @@
var Collapse = function ( element, options ) { var Collapse = function ( element, options ) {
this.$element = $(element) this.$element = $(element)
this.settings = $.extend({}, $.fn.collapse.defaults, options) this.options = $.extend({}, $.fn.collapse.defaults, options)
if (this.settings["parent"]) { if (this.options["parent"]) {
this.$parent = $(this.settings["parent"]) this.$parent = $(this.options["parent"])
} }
this.settings.toggle && this.toggle() this.options.toggle && this.toggle()
} }
Collapse.prototype = { Collapse.prototype = {
@@ -116,20 +116,20 @@
toggle: true toggle: true
} }
$.fn.collapse.Collapse = Collapse $.fn.collapse.Constructor = Collapse
/* COLLAPSIBLE DATA-API /* COLLAPSIBLE DATA-API
* ==================== */ * ==================== */
$(function () { $(function () {
$('body').delegate('[data-toggle=collapse]', 'click.collapse.data-api', function ( e ) { $('body').on('click.collapse.data-api', '[data-toggle=collapse]', function ( e ) {
var $this = $(this) var $this = $(this)
, target = $this.attr('data-target') || $this.attr('href') , target = $this.attr('data-target') || $this.attr('href')
, option = $(target).data('collapse') ? 'toggle' : $this.data() , option = $(target).data('collapse') ? 'toggle' : $this.data()
e.preventDefault() e.preventDefault()
$(target).collapse(option) $(target).collapse(option)
}) })
}) })
})( window.jQuery || window.ender ) })( window.jQuery )

View File

@@ -35,11 +35,15 @@
constructor: Dropdown constructor: Dropdown
, toggle: function ( e ) { , toggle: function ( e ) {
var li = $(this).parent('li') var $this = $(this)
, isActive = li.hasClass('open') , selector = $this.attr('data-target') || $this.attr('href')
, $parent = $(selector)
$parent.length || ($parent = $this.parent())
clearMenus() clearMenus()
!isActive && li.toggleClass('open')
!$parent.hasClass('open') && $parent.toggleClass('open')
return false return false
} }
@@ -47,7 +51,7 @@
} }
function clearMenus() { function clearMenus() {
$(toggle).parent('li').removeClass('open') $(toggle).parent().removeClass('open')
} }
@@ -63,13 +67,15 @@
}) })
} }
$.fn.dropdown.Constructor = Dropdown
/* APPLY TO STANDARD DROPDOWN ELEMENTS /* APPLY TO STANDARD DROPDOWN ELEMENTS
* =================================== */ * =================================== */
$(function () { $(function () {
$('html').bind('click.dropdown.data-api', clearMenus) $('html').on('click.dropdown.data-api', clearMenus)
$('body').delegate(toggle, 'click.dropdown.data-api', Dropdown.prototype.toggle) $('body').on('click.dropdown.data-api', toggle, Dropdown.prototype.toggle)
}) })
}( window.jQuery || window.ender ) }( window.jQuery )

36
js/bootstrap-modal.js vendored
View File

@@ -26,10 +26,9 @@
* ====================== */ * ====================== */
var Modal = function ( content, options ) { var Modal = function ( content, options ) {
this.settings = $.extend({}, $.fn.modal.defaults, options) this.options = $.extend({}, $.fn.modal.defaults, options)
this.$element = $(content) this.$element = $(content)
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this)) .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
this.settings.show && this.show()
} }
Modal.prototype = { Modal.prototype = {
@@ -97,7 +96,7 @@
function hideWithTransition() { function hideWithTransition() {
var that = this var that = this
, timeout = setTimeout(function () { , timeout = setTimeout(function () {
that.$element.unbind($.support.transition.end) that.$element.off($.support.transition.end)
hideModal.call(that) hideModal.call(that)
}, 500) }, 500)
@@ -107,7 +106,7 @@
}) })
} }
function hideModal (that) { function hideModal( that ) {
this.$element this.$element
.hide() .hide()
.trigger('hidden') .trigger('hidden')
@@ -115,17 +114,17 @@
backdrop.call(this) backdrop.call(this)
} }
function backdrop ( callback ) { function backdrop( callback ) {
var that = this var that = this
, animate = this.$element.hasClass('fade') ? 'fade' : '' , animate = this.$element.hasClass('fade') ? 'fade' : ''
if (this.isShown && this.settings.backdrop) { if (this.isShown && this.options.backdrop) {
var doAnimate = $.support.transition && animate var doAnimate = $.support.transition && animate
this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />') this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
.appendTo(document.body) .appendTo(document.body)
if (this.settings.backdrop != 'static') { if (this.options.backdrop != 'static') {
this.$backdrop.click($.proxy(this.hide, this)) this.$backdrop.click($.proxy(this.hide, this))
} }
@@ -156,12 +155,12 @@
function escape() { function escape() {
var that = this var that = this
if (this.isShown && this.settings.keyboard) { if (this.isShown && this.options.keyboard) {
$(document).bind('keyup.dismiss.modal', function ( e ) { $(document).on('keyup.dismiss.modal', function ( e ) {
e.which == 27 && that.hide() e.which == 27 && that.hide()
}) })
} else if (!this.isShown) { } else if (!this.isShown) {
$(document).unbind('keyup.dismiss.modal') $(document).off('keyup.dismiss.modal')
} }
} }
@@ -176,29 +175,30 @@
, options = typeof option == 'object' && option , options = typeof option == 'object' && option
if (!data) $this.data('modal', (data = new Modal(this, options))) if (!data) $this.data('modal', (data = new Modal(this, options)))
if (typeof option == 'string') data[option]() if (typeof option == 'string') data[option]()
else data.show()
}) })
} }
$.fn.modal.defaults = { $.fn.modal.defaults = {
backdrop: true backdrop: true
, keyboard: true , keyboard: true
, show: true
} }
$.fn.modal.Modal = Modal $.fn.modal.Constructor = Modal
/* MODAL DATA-API /* MODAL DATA-API
* ============== */ * ============== */
$(document).ready(function () { $(function () {
$('body').delegate('[data-toggle="modal"]', 'click.modal.data-api', function ( e ) { $('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) {
var $this = $(this) var $this = $(this)
, target = $this.attr('data-target') || $this.attr('href') , $target = $($this.attr('data-target') || $this.attr('href'))
, option = $(target).data('modal') ? 'toggle' : $this.data() , option = $target.data('modal') ? 'toggle' : $.extend({}, $target.data(), $this.data())
e.preventDefault() e.preventDefault()
$(target).modal(option) $target.modal(option)
}) })
}) })
}( window.jQuery || window.ender ) }( window.jQuery )

View File

@@ -23,16 +23,13 @@
"use strict" "use strict"
var Popover = function ( element, options ) { var Popover = function ( element, options ) {
this.$element = $(element) this.init('popover', element, options)
this.options = options
this.enabled = true
this.fixTitle()
} }
/* NOTE: POPOVER EXTENDS BOOTSTRAP-TWIPSY.js /* NOTE: POPOVER EXTENDS BOOTSTRAP-TWIPSY.js
========================================= */ ========================================= */
Popover.prototype = $.extend({}, $.fn.twipsy.Twipsy.prototype, { Popover.prototype = $.extend({}, $.fn.twipsy.Constructor.prototype, {
constructor: Popover constructor: Popover
@@ -53,22 +50,20 @@
, getContent: function () { , getContent: function () {
var content var content
, $e = this.$element , $e = this.$element
, o = this.options , o = this.options
if (typeof this.options.content == 'string') { content = $e.attr('data-content')
content = $e.attr(this.options.content) || (typeof o.content == 'function' ? o.content.call($e[0]) : o.content)
} else if (typeof this.options.content == 'function') {
content = this.options.content.call(this.$element[0]) content = content.toString().replace(/(^\s*|\s*$)/, "")
}
return content return content
} }
, tip: function() { , tip: function() {
if (!this.$tip) { if (!this.$tip) {
this.$tip = $('<div class="popover" />') this.$tip = $(this.options.template)
.html(this.options.template)
} }
return this.$tip return this.$tip
} }
@@ -79,18 +74,22 @@
/* POPOVER PLUGIN DEFINITION /* POPOVER PLUGIN DEFINITION
* ======================= */ * ======================= */
$.fn.popover = function (options) { $.fn.popover = function ( option ) {
if (typeof options == 'object') options = $.extend({}, $.fn.popover.defaults, options) return this.each(function () {
$.fn.twipsy.initWith.call(this, options, Popover, 'popover') var $this = $(this)
return this , data = $this.data('popover')
, options = typeof option == 'object' && option
if (!data) $this.data('popover', (data = new Popover(this, options)))
if (typeof option == 'string') data[option]()
})
} }
$.fn.popover.Constructor = Popover
$.fn.popover.defaults = $.extend({} , $.fn.twipsy.defaults, { $.fn.popover.defaults = $.extend({} , $.fn.twipsy.defaults, {
placement: 'right' placement: 'right'
, content: 'data-content' , content: ''
, template: '<div class="arrow"></div><div class="inner"><h3 class="title"></h3><div class="content"><p></p></div></div>' , template: '<div class="popover"><div class="arrow"></div><div class="inner"><h3 class="title"></h3><div class="content"><p></p></div></div></div>'
}) })
$.fn.twipsy.rejectAttrOptions.push( 'content' ) }( window.jQuery )
}( window.jQuery || window.ender )

View File

@@ -27,11 +27,11 @@
function ScrollSpy( element ) { function ScrollSpy( element ) {
var process = $.proxy(this.process, this) var process = $.proxy(this.process, this)
this.$scrollElement = $(element).bind('scroll.scroll.data-api', process) this.$scrollElement = $(element).on('scroll.scroll.data-api', process)
this.selector = (this.$scrollElement.attr('data-target') this.selector = (this.$scrollElement.attr('data-target')
|| this.$scrollElement.attr('href') || this.$scrollElement.attr('href')
|| '') + ' .nav li > a' || '') + ' .nav li > a'
this.$body = $('body').delegate(this.selector, 'click.scroll.data-api', process) this.$body = $('body').on('click.scroll.data-api', this.selector, process)
this.refresh() this.refresh()
this.process() this.process()
@@ -103,7 +103,7 @@
}) })
} }
$.fn.scrollspy.ScrollSpy = ScrollSpy $.fn.scrollspy.Constructor = ScrollSpy
/* SCROLLSPY DATA-API /* SCROLLSPY DATA-API
@@ -111,4 +111,4 @@
$(function () { $('[data-spy="scroll"]').scrollspy() }) $(function () { $('[data-spy="scroll"]').scrollspy() })
}( window.jQuery || window.ender ) }( window.jQuery )

57
js/bootstrap-tab.js vendored
View File

@@ -52,26 +52,45 @@
$href = $(href) $href = $(href)
this.activate($this.parent('li'), $ul) this.activate($this.parent('li'), $ul)
this.activate($href, $href.parent()) this.activate($href, $href.parent(), function () {
$this.trigger({
$this.trigger({ type: 'shown'
type: 'shown' , relatedTarget: previous
, relatedTarget: previous })
}) })
} }
, activate: function ( element, container ) { , activate: function ( element, container, callback) {
container var $active = container.find('> .active')
.find('> .active') , transition = callback
.removeClass('active') && $.support.transition
.find('> .dropdown-menu > .active') && $active.hasClass('fade')
.removeClass('active')
element.addClass('active') function next() {
$active
.removeClass('active')
.find('> .dropdown-menu > .active')
.removeClass('active')
if ( element.parent('.dropdown-menu') ) { element.addClass('active')
element.closest('li.dropdown').addClass('active')
if (transition) {
element[0].offsetWidth // reflow for transition
element.addClass('in')
}
if ( element.parent('.dropdown-menu') ) {
element.closest('li.dropdown').addClass('active')
}
callback && callback()
} }
transition ?
$active.one($.support.transition.end, next) :
next()
$active.removeClass('in')
} }
} }
@@ -79,7 +98,7 @@
/* TAB PLUGIN DEFINITION /* TAB PLUGIN DEFINITION
* ===================== */ * ===================== */
$.fn.tab = function (option) { $.fn.tab = function ( option ) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
, data = $this.data('tab') , data = $this.data('tab')
@@ -88,17 +107,17 @@
}) })
} }
$.fn.tab.Tab = Tab $.fn.tab.Constructor = Tab
/* TAB DATA-API /* TAB DATA-API
* ============ */ * ============ */
$(document).ready(function () { $(function () {
$('body').delegate('[data-toggle="tab"], [data-toggle="pill"]', 'click.tab.data-api', function (e) { $('body').on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
e.preventDefault() e.preventDefault()
$(this).tab('show') $(this).tab('show')
}) })
}) })
}( window.jQuery || window.ender ) }( window.jQuery )

View File

@@ -1,45 +0,0 @@
/* ===================================================
* bootstrap-transitions.js v2.0.0
* http://twitter.github.com/bootstrap/javascript.html
* ===================================================
* 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 () {
/* CSS TRANSITION SUPPORT (https://gist.github.com/373874)
* ======================================================= */
$.support.transition = (function () {
var thisBody = document.body || document.documentElement
, thisStyle = thisBody.style
, support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined
return support && {
end: (function () {
var transitionEnd = "TransitionEnd"
if ( $.browser.webkit ) {
transitionEnd = "webkitTransitionEnd"
} else if ( $.browser.mozilla ) {
transitionEnd = "transitionend"
} else if ( $.browser.opera ) {
transitionEnd = "oTransitionEnd"
}
return transitionEnd
}())
}
})()
})

238
js/bootstrap-twipsy.js vendored
View File

@@ -1,7 +1,7 @@
/* ========================================================== /* ==========================================================
* bootstrap-twipsy.js v2.0.0 * bootstrap-twipsy.js v2.0.0
* http://twitter.github.com/bootstrap/javascript.html#twipsy * http://twitter.github.com/bootstrap/javascript.html#twipsy
* Adapted from the original jQuery.tipsy by Jason Frame * Inspired by the original jQuery.tipsy by Jason Frame
* ========================================================== * ==========================================================
* Copyright 2011 Twitter, Inc. * Copyright 2011 Twitter, Inc.
* *
@@ -26,29 +26,90 @@
* ============================== */ * ============================== */
var Twipsy = function ( element, options ) { var Twipsy = function ( element, options ) {
this.$element = $(element) this.init('twipsy', element, options)
this.options = options
this.enabled = true
this.fixTitle()
} }
Twipsy.prototype = { Twipsy.prototype = {
constructor: Twipsy constructor: Twipsy
, show: function() { , init: function ( type, element, options ) {
var pos var eventIn
, eventOut
this.type = type
this.$element = $(element)
this.options = this.getOptions(options)
this.enabled = true
if (this.options.trigger != 'manual') {
eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus'
eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur'
this.$element.on(eventIn, this.options.selector, $.proxy(this.enter, this))
this.$element.on(eventOut, this.options.selector, $.proxy(this.leave, this))
}
this.options.selector ?
(this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
this.fixTitle()
}
, getOptions: function ( options ) {
options = $.extend({}, $.fn[this.type].defaults, options, this.$element.data())
if (options.delay && typeof options.delay == 'number') {
options.delay = {
show: options.delay
, hide: options.delay
}
}
return options
}
, enter: function ( e ) {
var self = $(e.currentTarget)[this.type](this._options).data(this.type)
if (!self.options.delay || !self.options.delay.show) {
self.show()
} else {
self.hoverState = 'in'
setTimeout(function() {
if (self.hoverState == 'in') {
self.show()
}
}, self.options.delay.show)
}
}
, leave: function ( e ) {
var self = $(e.currentTarget)[this.type](this._options).data(this.type)
if (!self.options.delay || !self.options.delay.hide) {
self.hide()
} else {
setTimeout(function() {
self.hoverState = 'out'
if (self.hoverState == 'out') {
self.hide()
}
}, self.options.delay.hide)
}
}
, show: function () {
var $tip
, pos
, actualWidth , actualWidth
, actualHeight , actualHeight
, placement , placement
, $tip
, tp , tp
if (this.hasContent() && this.enabled) { if (this.hasContent() && this.enabled) {
$tip = this.tip() $tip = this.tip()
this.setContent() this.setContent()
if (this.options.animate) { if (this.options.animation) {
$tip.addClass('fade') $tip.addClass('fade')
} }
@@ -69,16 +130,16 @@
switch (placement) { switch (placement) {
case 'below': case 'below':
tp = {top: pos.top + pos.height + this.options.offset, left: pos.left + pos.width / 2 - actualWidth / 2} tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
break break
case 'above': case 'above':
tp = {top: pos.top - actualHeight - this.options.offset, left: pos.left + pos.width / 2 - actualWidth / 2} tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
break break
case 'left': case 'left':
tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth - this.options.offset} tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
break break
case 'right': case 'right':
tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width + this.options.offset} tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
break break
} }
@@ -95,7 +156,7 @@
$tip[0].className = 'twipsy' $tip[0].className = 'twipsy'
} }
, hide: function() { , hide: function () {
var that = this var that = this
, $tip = this.tip() , $tip = this.tip()
@@ -106,11 +167,11 @@
} }
$.support.transition && this.$tip.hasClass('fade') ? $.support.transition && this.$tip.hasClass('fade') ?
$tip.bind( $.support.transition.end, removeElement) : $tip.on($.support.transition.end, removeElement) :
removeElement() removeElement()
} }
, fixTitle: function() { , fixTitle: function () {
var $e = this.$element var $e = this.$element
if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') { if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
$e.attr('data-original-title', $e.attr('title') || '').removeAttr('title') $e.attr('data-original-title', $e.attr('title') || '').removeAttr('title')
@@ -121,29 +182,24 @@
return this.getTitle() return this.getTitle()
} }
, getTitle: function() { , getTitle: function () {
var title var title
, $e = this.$element , $e = this.$element
, o = this.options , o = this.options
this.fixTitle() title = $e.attr('data-original-title')
|| (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
if (typeof o.title == 'string') { title = title.toString().replace(/(^\s*|\s*$)/, "")
title = $e.attr(o.title == 'title' ? 'data-original-title' : o.title)
} else if (typeof o.title == 'function') {
title = o.title.call($e[0])
}
title = ('' + title).replace(/(^\s*|\s*$)/, "") return title
return title
} }
, tip: function() { , tip: function () {
return this.$tip = this.$tip || $('<div class="twipsy" />').html(this.options.template) return this.$tip = this.$tip || $(this.options.template)
} }
, validate: function() { , validate: function () {
if (!this.$element[0].parentNode) { if (!this.$element[0].parentNode) {
this.hide() this.hide()
this.$element = null this.$element = null
@@ -151,15 +207,15 @@
} }
} }
, enable: function() { , enable: function () {
this.enabled = true this.enabled = true
} }
, disable: function() { , disable: function () {
this.enabled = false this.enabled = false
} }
, toggleEnabled: function() { , toggleEnabled: function () {
this.enabled = !this.enabled this.enabled = !this.enabled
} }
@@ -177,118 +233,30 @@
return typeof thing == 'function' ? thing.apply(ctx, args) : thing return typeof thing == 'function' ? thing.apply(ctx, args) : thing
} }
/* TWIPSY PLUGIN DEFINITION /* TWIPSY PLUGIN DEFINITION
* ======================== */ * ======================== */
$.fn.twipsy = function (options) { $.fn.twipsy = function ( option ) {
$.fn.twipsy.initWith.call(this, options, Twipsy, 'twipsy') return this.each(function () {
return this var $this = $(this)
, data = $this.data('twipsy')
, options = typeof option == 'object' && option
if (!data) $this.data('twipsy', (data = new Twipsy(this, options)))
if (typeof option == 'string') data[option]()
})
} }
$.fn.twipsy.initWith = function (options, Base, name) { $.fn.twipsy.Constructor = Twipsy
var twipsy
, binder
, eventIn
, eventOut
if (typeof options == 'string') {
return this.each(function (){
twipsy = $.data(this, name)
if (twipsy) twipsy[options]()
})
}
options = $.extend({}, $.fn[name].defaults, options)
if (options.delay && typeof options.delay == 'number') {
options.delay = {
show: options.delay
, hide: options.delay
}
}
function get(ele) {
var twipsy = $.data(ele, name)
if (!twipsy) {
twipsy = new Base(ele, $.fn.twipsy.elementOptions(ele, options))
$.data(ele, name, twipsy)
}
return twipsy
}
function enter() {
var twipsy = get(this)
twipsy.hoverState = 'in'
if (!options.delay || !options.delay.show) {
twipsy.show()
} else {
twipsy.fixTitle()
setTimeout(function() {
if (twipsy.hoverState == 'in') {
twipsy.show()
}
}, options.delay.show)
}
}
function leave() {
var twipsy = get(this)
twipsy.hoverState = 'out'
if (!options.delay || !options.delay.hide) {
twipsy.hide()
} else {
setTimeout(function() {
if (twipsy.hoverState == 'out') {
twipsy.hide()
}
}, options.delay.hide)
}
}
if (!options.live) {
this.each(function() {
get(this)
})
}
if (options.trigger != 'manual') {
binder = options.live ? 'live' : 'bind'
eventIn = options.trigger == 'hover' ? 'mouseenter' : 'focus'
eventOut = options.trigger == 'hover' ? 'mouseleave' : 'blur'
this[binder](eventIn, enter)[binder](eventOut, leave)
}
return this
}
$.fn.twipsy.Twipsy = Twipsy
$.fn.twipsy.defaults = { $.fn.twipsy.defaults = {
animate: true animation: true
, delay: 0 , delay: 0
, selector: false
, placement: 'above' , placement: 'above'
, live: false
, offset: 0
, trigger: 'hover' , trigger: 'hover'
, title: 'title' , title: ''
, template: '<div class="twipsy-arrow"></div><div class="twipsy-inner"></div>' , template: '<div class="twipsy"><div class="twipsy-arrow"></div><div class="twipsy-inner"></div></div>'
} }
$.fn.twipsy.rejectAttrOptions = [ 'title' ] }( window.jQuery )
$.fn.twipsy.elementOptions = function(ele, options) {
var data = $(ele).data()
, rejects = $.fn.twipsy.rejectAttrOptions
, i = rejects.length
while (i--) {
delete data[rejects[i]]
}
return $.extend({}, options, data)
}
}( window.jQuery || window.ender )

View File

@@ -4,28 +4,36 @@
<title>Bootstrap Plugin Test Suite</title> <title>Bootstrap Plugin Test Suite</title>
<!-- jquery --> <!-- jquery -->
<script src="http://code.jquery.com/jquery-1.5.2.min.js"></script> <!--<script src="http://code.jquery.com/jquery-1.7.min.js"></script>-->
<script src="vendor/jquery.js"></script>
<!-- qunit --> <!-- qunit -->
<link rel="stylesheet" href="vendor/qunit.css" type="text/css" media="screen" /> <link rel="stylesheet" href="vendor/qunit.css" type="text/css" media="screen" />
<script src="vendor/qunit.js"></script> <script src="vendor/qunit.js"></script>
<!-- plugin sources --> <!-- plugin sources -->
<script src="../../js/bootstrap-transitions.js"></script> <script src="../../js/bootstrap-transition.js"></script>
<script src="../../js/bootstrap-alerts.js"></script> <script src="../../js/bootstrap-alert.js"></script>
<script src="../../js/bootstrap-button.js"></script>
<script src="../../js/bootstrap-collapse.js"></script>
<script src="../../js/bootstrap-dropdown.js"></script> <script src="../../js/bootstrap-dropdown.js"></script>
<script src="../../js/bootstrap-modal.js"></script> <script src="../../js/bootstrap-modal.js"></script>
<script src="../../js/bootstrap-tabs.js"></script> <script src="../../js/bootstrap-scrollspy.js"></script>
<script src="../../js/bootstrap-tab.js"></script>
<script src="../../js/bootstrap-twipsy.js"></script> <script src="../../js/bootstrap-twipsy.js"></script>
<script src="../../js/bootstrap-popover.js"></script> <script src="../../js/bootstrap-popover.js"></script>
<!-- unit tests --> <!-- unit tests -->
<script src="unit/bootstrap-alerts.js"></script> <script src="unit/bootstrap-transition.js"></script>
<script src="unit/bootstrap-alert.js"></script>
<script src="unit/bootstrap-button.js"></script>
<script src="unit/bootstrap-collapse.js"></script>
<script src="unit/bootstrap-dropdown.js"></script> <script src="unit/bootstrap-dropdown.js"></script>
<script src="unit/bootstrap-modal.js"></script> <script src="unit/bootstrap-modal.js"></script>
<script src="unit/bootstrap-popover.js"></script> <script src="unit/bootstrap-scrollspy.js"></script>
<script src="unit/bootstrap-tabs.js"></script> <script src="unit/bootstrap-tab.js"></script>
<script src="unit/bootstrap-twipsy.js"></script> <script src="unit/bootstrap-twipsy.js"></script>
<script src="unit/bootstrap-popover.js"></script>
<body> <body>
<div> <div>
@@ -33,7 +41,7 @@
<h2 id="qunit-banner"></h2> <h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2> <h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol> <ol id="qunit-tests"></ol>
<div id="qunit-runoff"></div> <div id="qunit-fixture"></div>
</div> </div>
</body> </body>
</html> </html>

View File

@@ -12,7 +12,7 @@ $(function () {
test("should fade element out on clicking .close", function () { test("should fade element out on clicking .close", function () {
var alertHTML = '<div class="alert-message warning fade in">' var alertHTML = '<div class="alert-message warning fade in">'
+ '<a class="close" href="#">×</a>' + '<a class="close" href="#" data-dismiss="alert">×</a>'
+ '<p><strong>Holy guacamole!</strong> Best check yo self, youre not looking too good.</p>' + '<p><strong>Holy guacamole!</strong> Best check yo self, youre not looking too good.</p>'
+ '</div>' + '</div>'
, alert = $(alertHTML).alert() , alert = $(alertHTML).alert()
@@ -26,16 +26,16 @@ $(function () {
$.support.transition = false $.support.transition = false
var alertHTML = '<div class="alert-message warning fade in">' var alertHTML = '<div class="alert-message warning fade in">'
+ '<a class="close" href="#">×</a>' + '<a class="close" href="#" data-dismiss="alert">×</a>'
+ '<p><strong>Holy guacamole!</strong> Best check yo self, youre not looking too good.</p>' + '<p><strong>Holy guacamole!</strong> Best check yo self, youre not looking too good.</p>'
+ '</div>' + '</div>'
, alert = $(alertHTML).appendTo('#qunit-runoff').alert() , alert = $(alertHTML).appendTo('#qunit-fixture').alert()
ok($('#qunit-runoff').find('.alert-message').length, 'element added to dom') ok($('#qunit-fixture').find('.alert-message').length, 'element added to dom')
alert.find('.close').click() alert.find('.close').click()
ok(!$('#qunit-runoff').find('.alert-message').length, 'element removed from dom') ok(!$('#qunit-fixture').find('.alert-message').length, 'element removed from dom')
}) })
}) })

54
js/tests/unit/bootstrap-button.js vendored Normal file
View File

@@ -0,0 +1,54 @@
$(function () {
module("bootstrap-buttons")
test("should be defined on jquery object", function () {
ok($(document.body).button, 'tabs method is defined')
})
test("should return element", function () {
ok($(document.body).button()[0] == document.body, 'document.body returned')
})
test("should return set state to loading", function () {
var btn = $('<button class="btn" data-loading-text="fat">mdo</button>')
equals(btn.html(), 'mdo', 'btn text equals mdo')
btn.button('loading')
equals(btn.html(), 'fat', 'btn text equals fat')
stop()
setTimeout(function () {
ok(btn.attr('disabled'), 'btn is disabled')
ok(btn.hasClass('disabled'), 'btn has disabled class')
start()
}, 0)
})
test("should return reset state", function () {
var btn = $('<button class="btn" data-loading-text="fat">mdo</button>')
equals(btn.html(), 'mdo', 'btn text equals mdo')
btn.button('loading')
equals(btn.html(), 'fat', 'btn text equals fat')
stop()
setTimeout(function () {
ok(btn.attr('disabled'), 'btn is disabled')
ok(btn.hasClass('disabled'), 'btn has disabled class')
start()
stop()
}, 0)
btn.button('reset')
equals(btn.html(), 'mdo', 'btn text equals mdo')
setTimeout(function () {
ok(!btn.attr('disabled'), 'btn is not disabled')
ok(!btn.hasClass('disabled'), 'btn does not have disabled class')
start()
}, 0)
})
test("should toggle active", function () {
var btn = $('<button class="btn" data-loading-text="fat">mdo</button>')
ok(!btn.hasClass('active'), 'btn does not have active class')
btn.button('toggle')
ok(btn.hasClass('active'), 'btn has class active')
})
})

25
js/tests/unit/bootstrap-collapse.js vendored Normal file
View File

@@ -0,0 +1,25 @@
$(function () {
module("bootstrap-collapse")
test("should be defined on jquery object", function () {
ok($(document.body).collapse, 'collapse method is defined')
})
test("should return element", function () {
ok($(document.body).collapse()[0] == document.body, 'document.body returned')
})
test("should show a collapsed element", function () {
var el = $('<div class="collapse"></div>').collapse('show')
ok(el.hasClass('in'), 'has class in')
ok(/height/.test(el.attr('style')), 'has height set')
})
test("should hide a collapsed element", function () {
var el = $('<div class="collapse"></div>').collapse('hide')
ok(!el.hasClass('in'), 'does not have class in')
ok(/height/.test(el.attr('style')), 'has height set')
})
})

View File

@@ -13,7 +13,7 @@ $(function () {
test("should add class open to menu if clicked", function () { test("should add class open to menu if clicked", function () {
var dropdownHTML = '<ul class="tabs">' var dropdownHTML = '<ul class="tabs">'
+ '<li class="dropdown">' + '<li class="dropdown">'
+ '<a href="#" class="dropdown-toggle">Dropdown</a>' + '<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>'
+ '<ul class="dropdown-menu">' + '<ul class="dropdown-menu">'
+ '<li><a href="#">Secondary link</a></li>' + '<li><a href="#">Secondary link</a></li>'
+ '<li><a href="#">Something else here</a></li>' + '<li><a href="#">Something else here</a></li>'
@@ -22,16 +22,15 @@ $(function () {
+ '</ul>' + '</ul>'
+ '</li>' + '</li>'
+ '</ul>' + '</ul>'
, dropdown = $(dropdownHTML).dropdown() , dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').dropdown().click()
dropdown.find('.dropdown-toggle').click() ok(dropdown.parent('.dropdown').hasClass('open'), 'open class added on click')
ok(dropdown.find('.dropdown').hasClass('open'), 'open class added on click')
}) })
test("should remove open class if body clicked", function () { test("should remove open class if body clicked", function () {
var dropdownHTML = '<ul class="tabs">' var dropdownHTML = '<ul class="tabs">'
+ '<li class="dropdown">' + '<li class="dropdown">'
+ '<a href="#" class="dropdown-toggle">Dropdown</a>' + '<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>'
+ '<ul class="dropdown-menu">' + '<ul class="dropdown-menu">'
+ '<li><a href="#">Secondary link</a></li>' + '<li><a href="#">Secondary link</a></li>'
+ '<li><a href="#">Something else here</a></li>' + '<li><a href="#">Something else here</a></li>'
@@ -40,12 +39,14 @@ $(function () {
+ '</ul>' + '</ul>'
+ '</li>' + '</li>'
+ '</ul>' + '</ul>'
, dropdown = $(dropdownHTML).dropdown().appendTo('#qunit-runoff') , dropdown = $(dropdownHTML)
.appendTo('#qunit-fixture')
dropdown.find('.dropdown-toggle').click() .find('[data-toggle="dropdown"]')
ok(dropdown.find('.dropdown').hasClass('open'), 'open class added on click') .dropdown()
.click()
ok(dropdown.parent('.dropdown').hasClass('open'), 'open class added on click')
$('body').click() $('body').click()
ok(!dropdown.find('.dropdown').hasClass('open'), 'open class removed') ok(!dropdown.parent('.dropdown').hasClass('open'), 'open class removed')
dropdown.remove() dropdown.remove()
}) })

View File

@@ -10,6 +10,7 @@ $(function () {
test("should return element", function () { test("should return element", function () {
var div = $("<div id='modal-test'></div>") var div = $("<div id='modal-test'></div>")
ok(div.modal() == div, 'document.body returned') ok(div.modal() == div, 'document.body returned')
$('#modal-test').remove()
}) })
test("should expose defaults var for settings", function () { test("should expose defaults var for settings", function () {
@@ -19,32 +20,29 @@ $(function () {
test("should insert into dom when show method is called", function () { test("should insert into dom when show method is called", function () {
stop() stop()
$.support.transition = false $.support.transition = false
var div = $("<div id='modal-test'></div>") $("<div id='modal-test'></div>")
div
.modal()
.modal("show")
.bind("shown", function () { .bind("shown", function () {
ok($('#modal-test').length, 'modal insterted into dom') ok($('#modal-test').length, 'modal insterted into dom')
$(this).remove()
start() start()
div.remove()
}) })
.modal("show")
}) })
test("should hide modal when hide is called", function () { test("should hide modal when hide is called", function () {
stop() stop()
$.support.transition = false $.support.transition = false
var div = $("<div id='modal-test'></div>")
div $("<div id='modal-test'></div>")
.modal()
.bind("shown", function () { .bind("shown", function () {
ok($('#modal-test').is(":visible"), 'modal visible') ok($('#modal-test').is(":visible"), 'modal visible')
ok($('#modal-test').length, 'modal insterted into dom') ok($('#modal-test').length, 'modal insterted into dom')
div.modal("hide") $(this).modal("hide")
}) })
.bind("hidden", function() { .bind("hidden", function() {
ok(!$('#modal-test').is(":visible"), 'modal hidden') ok(!$('#modal-test').is(":visible"), 'modal hidden')
$('#modal-test').remove()
start() start()
div.remove()
}) })
.modal("show") .modal("show")
}) })
@@ -54,7 +52,6 @@ $(function () {
$.support.transition = false $.support.transition = false
var div = $("<div id='modal-test'></div>") var div = $("<div id='modal-test'></div>")
div div
.modal()
.bind("shown", function () { .bind("shown", function () {
ok($('#modal-test').is(":visible"), 'modal visible') ok($('#modal-test').is(":visible"), 'modal visible')
ok($('#modal-test').length, 'modal insterted into dom') ok($('#modal-test').length, 'modal insterted into dom')
@@ -62,18 +59,17 @@ $(function () {
}) })
.bind("hidden", function() { .bind("hidden", function() {
ok(!$('#modal-test').is(":visible"), 'modal hidden') ok(!$('#modal-test').is(":visible"), 'modal hidden')
start()
div.remove() div.remove()
start()
}) })
.modal("toggle") .modal("toggle")
}) })
test("should remove from dom when click .close", function () { test("should remove from dom when click [data-dismiss=modal]", function () {
stop() stop()
$.support.transition = false $.support.transition = false
var div = $("<div id='modal-test'><span class='close'></span></div>") var div = $("<div id='modal-test'><span class='close' data-dismiss='modal'></span></div>")
div div
.modal()
.bind("shown", function () { .bind("shown", function () {
ok($('#modal-test').is(":visible"), 'modal visible') ok($('#modal-test').is(":visible"), 'modal visible')
ok($('#modal-test').length, 'modal insterted into dom') ok($('#modal-test').length, 'modal insterted into dom')
@@ -81,8 +77,8 @@ $(function () {
}) })
.bind("hidden", function() { .bind("hidden", function() {
ok(!$('#modal-test').is(":visible"), 'modal hidden') ok(!$('#modal-test').is(":visible"), 'modal hidden')
start()
div.remove() div.remove()
start()
}) })
.modal("toggle") .modal("toggle")
}) })

View File

@@ -15,14 +15,12 @@ $(function () {
test("should render popover element", function () { test("should render popover element", function () {
$.support.transition = false $.support.transition = false
var popover = $('<a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a>') var popover = $('<a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a>')
.appendTo('#qunit-runoff') .appendTo('#qunit-fixture')
.popover()
.popover('show') .popover('show')
ok($('.popover').length, 'popover was inserted') ok($('.popover').length, 'popover was inserted')
popover.popover('hide') popover.popover('hide')
ok(!$(".popover").length, 'popover removed') ok(!$(".popover").length, 'popover removed')
$('#qunit-runoff').empty()
}) })
test("should store popover instance in popover data object", function () { test("should store popover instance in popover data object", function () {
@@ -36,7 +34,7 @@ $(function () {
test("should get title and content from options", function () { test("should get title and content from options", function () {
$.support.transition = false $.support.transition = false
var popover = $('<a href="#">@fat</a>') var popover = $('<a href="#">@fat</a>')
.appendTo('#qunit-runoff') .appendTo('#qunit-fixture')
.popover({ .popover({
title: function () { title: function () {
return '@fat' return '@fat'
@@ -54,13 +52,13 @@ $(function () {
popover.popover('hide') popover.popover('hide')
ok(!$('.popover').length, 'popover was removed') ok(!$('.popover').length, 'popover was removed')
$('#qunit-runoff').empty() $('#qunit-fixture').empty()
}) })
test("should get title and content from attributes", function () { test("should get title and content from attributes", function () {
$.support.transition = false $.support.transition = false
var popover = $('<a href="#" title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>') var popover = $('<a href="#" title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>')
.appendTo('#qunit-runoff') .appendTo('#qunit-fixture')
.popover() .popover()
.popover('show') .popover('show')
@@ -70,7 +68,7 @@ $(function () {
popover.popover('hide') popover.popover('hide')
ok(!$('.popover').length, 'popover was removed') ok(!$('.popover').length, 'popover was removed')
$('#qunit-runoff').empty() $('#qunit-fixture').empty()
}) })
}) })

View File

@@ -12,7 +12,7 @@ $(function () {
test("should switch active class on scroll", function () { test("should switch active class on scroll", function () {
var sectionHTML = '<div id="masthead"></div>' var sectionHTML = '<div id="masthead"></div>'
, $section = $(sectionHTML).append('#qunit-runoff') , $section = $(sectionHTML).append('#qunit-fixture')
, topbarHTML ='<div class="topbar">' , topbarHTML ='<div class="topbar">'
+ '<div class="topbar-inner">' + '<div class="topbar-inner">'
+ '<div class="container">' + '<div class="container">'
@@ -23,9 +23,9 @@ $(function () {
+ '</div>' + '</div>'
+ '</div>' + '</div>'
+ '</div>' + '</div>'
, $topbar = $(topbarHTML).topbar() , $topbar = $(topbarHTML).scrollspy()
ok(topbar.find('.active', true) ok($topbar.find('.active', true))
}) })
}) })

46
js/tests/unit/bootstrap-tab.js vendored Normal file
View File

@@ -0,0 +1,46 @@
$(function () {
module("bootstrap-tabs")
test("should be defined on jquery object", function () {
ok($(document.body).tab, 'tabs method is defined')
})
test("should return element", function () {
ok($(document.body).tab()[0] == document.body, 'document.body returned')
})
test("should activate element by tab id", function () {
var tabsHTML =
'<ul class="tabs">'
+ '<li><a href="#home">Home</a></li>'
+ '<li><a href="#profile">Profile</a></li>'
+ '</ul>'
$('<ul><li id="home"></li><li id="profile"></li></ul>').appendTo("#qunit-fixture")
$(tabsHTML).find('li:last a').tab('show')
equals($("#qunit-fixture").find('.active').attr('id'), "profile")
$(tabsHTML).find('li:first a').tab('show')
equals($("#qunit-fixture").find('.active').attr('id'), "home")
})
test("should activate element by tab id", function () {
var pillsHTML =
'<ul class="pills">'
+ '<li><a href="#home">Home</a></li>'
+ '<li><a href="#profile">Profile</a></li>'
+ '</ul>'
$('<ul><li id="home"></li><li id="profile"></li></ul>').appendTo("#qunit-fixture")
$(pillsHTML).find('li:last a').tab('show')
equals($("#qunit-fixture").find('.active').attr('id'), "profile")
$(pillsHTML).find('li:first a').tab('show')
equals($("#qunit-fixture").find('.active').attr('id'), "home")
})
})

View File

@@ -1,49 +0,0 @@
$(function () {
module("bootstrap-tabs")
test("should be defined on jquery object", function () {
ok($(document.body).tabs, 'tabs method is defined')
})
test("should return element", function () {
ok($(document.body).tabs()[0] == document.body, 'document.body returned')
})
test("should activate element by tab id", function () {
var tabsHTML = '<ul class="tabs">'
+ '<li class="active"><a href="#home">Home</a></li>'
+ '<li><a href="#profile">Profile</a></li>'
+ '</ul>'
$('<ul><li id="home"></li><li id="profile"></li></ul>').appendTo("#qunit-runoff")
$(tabsHTML).tabs().find('a').last().click()
equals($("#qunit-runoff").find('.active').attr('id'), "profile")
$(tabsHTML).tabs().find('a').first().click()
equals($("#qunit-runoff").find('.active').attr('id'), "home")
$("#qunit-runoff").empty()
})
test("should activate element by pill id", function () {
var pillsHTML = '<ul class="pills">'
+ '<li class="active"><a href="#home">Home</a></li>'
+ '<li><a href="#profile">Profile</a></li>'
+ '</ul>'
$('<ul><li id="home"></li><li id="profile"></li></ul>').appendTo("#qunit-runoff")
$(pillsHTML).pills().find('a').last().click()
equals($("#qunit-runoff").find('.active').attr('id'), "profile")
$(pillsHTML).pills().find('a').first().click()
equals($("#qunit-runoff").find('.active').attr('id'), "home")
$("#qunit-runoff").empty()
})
})

13
js/tests/unit/bootstrap-transition.js vendored Normal file
View File

@@ -0,0 +1,13 @@
$(function () {
module("bootstrap-transition")
test("should be defined on jquery support object", function () {
ok($.support.transition != undefined, 'transition object is defined')
})
test("should provide an end object", function () {
ok($.support.transition.end, 'end string is defined')
})
})

View File

@@ -29,53 +29,23 @@ $(function () {
test("should place tooltips relative to placement option", function () { test("should place tooltips relative to placement option", function () {
$.support.transition = false $.support.transition = false
var twipsy = $('<a href="#" rel="twipsy" title="Another twipsy"></a>') var twipsy = $('<a href="#" rel="twipsy" title="Another twipsy"></a>')
.appendTo('#qunit-runoff') .appendTo('#qunit-fixture')
.twipsy({placement: 'below'}) .twipsy({placement: 'below'})
.twipsy('show') .twipsy('show')
ok($(".twipsy").hasClass('fade below in'), 'has correct classes applied') ok($(".twipsy").hasClass('fade below in'), 'has correct classes applied')
twipsy.twipsy('hide') twipsy.twipsy('hide')
ok(!$(".twipsy").length, 'twipsy removed')
$('#qunit-runoff').empty()
}) })
test("should add a fallback in cases where elements have no title tag", function () { test("should always allow html entities", function () {
$.support.transition = false
var twipsy = $('<a href="#" rel="twipsy"></a>')
.appendTo('#qunit-runoff')
.twipsy({fallback: '@fat'})
.twipsy('show')
equals($(".twipsy").text(), "@fat", 'has correct default text')
twipsy.twipsy('hide')
ok(!$(".twipsy").length, 'twipsy removed')
$('#qunit-runoff').empty()
})
test("should not allow html entities", function () {
$.support.transition = false $.support.transition = false
var twipsy = $('<a href="#" rel="twipsy" title="<b>@fat</b>"></a>') var twipsy = $('<a href="#" rel="twipsy" title="<b>@fat</b>"></a>')
.appendTo('#qunit-runoff') .appendTo('#qunit-fixture')
.twipsy()
.twipsy('show')
ok(!$('.twipsy b').length, 'b tag was not inserted')
twipsy.twipsy('hide')
ok(!$(".twipsy").length, 'twipsy removed')
$('#qunit-runoff').empty()
})
test("should allow html entities if html option set to true", function () {
$.support.transition = false
var twipsy = $('<a href="#" rel="twipsy" title="<b>@fat</b>"></a>')
.appendTo('#qunit-runoff')
.twipsy({html: true})
.twipsy('show') .twipsy('show')
ok($('.twipsy b').length, 'b tag was inserted') ok($('.twipsy b').length, 'b tag was inserted')
twipsy.twipsy('hide') twipsy.twipsy('hide')
ok(!$(".twipsy").length, 'twipsy removed') ok(!$(".twipsy").length, 'twipsy removed')
$('#qunit-runoff').empty()
}) })
}) })

9252
js/tests/vendor/jquery.js vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -227,6 +227,6 @@
/** Runoff */ /** Runoff */
#qunit-runoff { #qunit-fixture {
display:none; display:none;
} }

View File

@@ -8,10 +8,14 @@
z-index: 1000; z-index: 1000;
display: none; display: none;
padding: 5px; padding: 5px;
&.above { margin-top: -5px; }
&.right { margin-left: 5px; }
&.below { margin-top: 5px; }
&.left { margin-left: -5px; }
&.above .arrow { #popoverArrow > .above(); } &.above .arrow { #popoverArrow > .above(); }
&.right .arrow { #popoverArrow > .right(); } &.right .arrow { #popoverArrow > .right(); }
&.below .arrow { #popoverArrow > .below(); } &.below .arrow { #popoverArrow > .below(); }
&.left .arrow { #popoverArrow > .left(); } &.left .arrow { #popoverArrow > .left(); }
.arrow { .arrow {
position: absolute; position: absolute;
width: 0; width: 0;

View File

@@ -9,9 +9,11 @@
padding: 5px; padding: 5px;
font-size: 11px; font-size: 11px;
.opacity(0); .opacity(0);
&.in { &.in { .opacity(80); }
.opacity(80); &.above { margin-top: -2px; }
} &.right { margin-left: 2px; }
&.below { margin-top: 2px; }
&.left { margin-left: -2px; }
&.above .twipsy-arrow { #popoverArrow > .above(); } &.above .twipsy-arrow { #popoverArrow > .above(); }
&.left .twipsy-arrow { #popoverArrow > .left(); } &.left .twipsy-arrow { #popoverArrow > .left(); }
&.below .twipsy-arrow { #popoverArrow > .below(); } &.below .twipsy-arrow { #popoverArrow > .below(); }