Commit f085dbad authored by Mark Otto's avatar Mark Otto

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

Conflicts:
	docs/assets/css/docs.css
	docs/base-css.html
	docs/components.html
	docs/customize.html
	docs/getting-started.html
	docs/javascript.html
	docs/scaffolding.html
	docs/templates/pages/base-css.mustache
	docs/templates/pages/components.mustache
	docs/templates/pages/customize.mustache
	docs/templates/pages/getting-started.mustache
	docs/templates/pages/javascript.mustache
	docs/templates/pages/scaffolding.mustache
parents 0dda2c46 614d52bd
......@@ -67,6 +67,7 @@ sub {
}
img {
height: auto;
max-width: 100%;
vertical-align: middle;
border: 0;
......@@ -5501,3 +5502,7 @@ a.badge:hover {
.invisible {
visibility: hidden;
}
.affix {
position: fixed;
}
......@@ -893,6 +893,7 @@ form.bs-docs-example {
margin-right: 10px;
background-color: #fff;
border: 1px solid #e5e5e5;
margin-left: 0;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
......@@ -932,8 +933,16 @@ form.bs-docs-example {
opacity: .75;
}
.bs-docs-sidenav.affix {
top: 40px;
}
@media (max-width: 979px) {
.bs-docs-sidenav.affix {
top: 0px;
}
.bs-docs-sidenav {
margin-top: 30px;
margin-right: 0;
......@@ -972,3 +981,9 @@ form.bs-docs-example {
top: 240px;
}
}
@media (max-width: 767px) {
.bs-docs-sidenav.affix {
position: relative;
}
}
......@@ -43,32 +43,6 @@
})
}
// fix sub nav on scroll
var $win = $(window)
, $nav = $('.subhead .navbar-subnav')
, navTop = $('.subhead .navbar-subnav').length && $('.subhead .navbar-subnav').offset().top - 40
, isFixed = 0
processScroll()
// hack sad times - holdover until rewrite for 2.1
$nav.on('click', function () {
if (!isFixed) setTimeout(function () { $win.scrollTop($win.scrollTop() - 47) }, 10)
})
$win.on('scroll', processScroll)
function processScroll() {
var i, scrollTop = $win.scrollTop()
if (scrollTop >= navTop && !isFixed) {
isFixed = 1
$nav.addClass('navbar-subnav-fixed')
} else if (scrollTop <= navTop && isFixed) {
isFixed = 0
$nav.removeClass('navbar-subnav-fixed')
}
}
// tooltip demo
$('.tooltip-demo').tooltip({
selector: "a[rel=tooltip]"
......
/* ==========================================================
* bootstrap-affix.js v2.1.0
* http://twitter.github.com/bootstrap/javascript.html#affix
* ==========================================================
* Copyright 2012 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ========================================================== */
!function ($) {
"use strict"; // jshint ;_;
/* AFFIX CLASS DEFINITION
* ====================== */
var Affix = function (element, options) {
this.options = $.extend({}, $.fn.affix.defaults, options)
this.$window = $(window)
.on('scroll.affix.data-api', $.proxy(this.checkPosition, this))
.on('resize.affix.data-api', $.proxy(this.refresh, this))
this.$element = $(element)
this.refresh()
}
Affix.prototype.refresh = function () {
this.position = this.$element.offset()
}
Affix.prototype.checkPosition = function () {
if (!this.$element.is(':visible')) return
var scrollLeft = this.$window.scrollLeft()
, scrollTop = this.$window.scrollTop()
, position = this.position
, offset = this.options.offset
, affix
if (typeof offset != 'object') offset = { x: offset, y: offset }
affix = (offset.x == null || (position.left - scrollLeft <= offset.x))
&& (offset.y == null || (position.top - scrollTop <= offset.y))
if (affix == this.affixed) return
this.affixed = affix
this.$element[affix ? 'addClass' : 'removeClass']('affix')
}
/* AFFIX PLUGIN DEFINITION
* ======================= */
$.fn.affix = function (option) {
return this.each(function () {
var $this = $(this)
, data = $this.data('affix')
, options = typeof option == 'object' && option
if (!data) $this.data('affix', (data = new Affix(this, options)))
if (typeof option == 'string') data[option]()
})
}
$.fn.affix.Constructor = Affix
$.fn.affix.defaults = {
offset: 0
}
/* AFFIX DATA-API
* ============== */
$(function () {
$('[data-spy="affix"]').each(function () {
var $spy = $(this)
, data = $spy.data()
data.offset = data.offset || {}
data.offsetX && (data.offset.x = data.offsetX)
data.offsetY && (data.offset.y = data.offsetY)
$spy.affix(data)
})
})
}(window.jQuery);
\ No newline at end of file
......@@ -26,9 +26,9 @@
/* MODAL CLASS DEFINITION
* ====================== */
var Modal = function (content, options) {
var Modal = function (element, options) {
this.options = options
this.$element = $(content)
this.$element = $(element)
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
this.options.remote && this.$element.find('.modal-body').load(this.options.remote)
}
......
......@@ -26,7 +26,7 @@
/* POPOVER PUBLIC CLASS DEFINITION
* =============================== */
var Popover = function ( element, options ) {
var Popover = function (element, options) {
this.init('popover', element, options)
}
......@@ -72,7 +72,7 @@
}
, destroy: function () {
this.$element.off().removeData('popover')
this.hide().$element.off('.' + this.type).removeData(this.type)
}
})
......
......@@ -23,15 +23,15 @@
"use strict"; // jshint ;_;
/* SCROLLSPY CLASS DEFINITION
* ========================== */
/* SCROLLSPY CLASS DEFINITION
* ========================== */
function ScrollSpy( element, options) {
function ScrollSpy(element, options) {
var process = $.proxy(this.process, this)
, $element = $(element).is('body') ? $(window) : $(element)
, href
this.options = $.extend({}, $.fn.scrollspy.defaults, options)
this.$scrollElement = $element.on('scroll.scroll.data-api', process)
this.$scrollElement = $element.on('scroll.scroll-spy.data-api', process)
this.selector = (this.options.target
|| ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
|| '') + ' .nav li > a'
......@@ -121,7 +121,7 @@
/* SCROLLSPY PLUGIN DEFINITION
* =========================== */
$.fn.scrollspy = function ( option ) {
$.fn.scrollspy = function (option) {
return this.each(function () {
var $this = $(this)
, data = $this.data('scrollspy')
......@@ -141,7 +141,7 @@
/* SCROLLSPY DATA-API
* ================== */
$(function () {
$(window).on('load', function () {
$('[data-spy="scroll"]').each(function () {
var $spy = $(this)
$spy.scrollspy($spy.data())
......
......@@ -26,7 +26,7 @@
/* TAB CLASS DEFINITION
* ==================== */
var Tab = function ( element ) {
var Tab = function (element) {
this.element = $(element)
}
......
......@@ -47,8 +47,8 @@
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.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
}
this.options.selector ?
......@@ -176,6 +176,8 @@
$.support.transition && this.$tip.hasClass('fade') ?
removeWithAnimation() :
$tip.remove()
return this
}
, fixTitle: function () {
......@@ -236,7 +238,7 @@
}
, destroy: function () {
this.$element.off().removeData('tooltip')
this.hide().$element.off('.' + this.type).removeData(this.type)
}
}
......
......@@ -36,7 +36,7 @@
, transEndEventNames = {
'WebkitTransition' : 'webkitTransitionEnd'
, 'MozTransition' : 'transitionend'
, 'OTransition' : 'otransitionend'
, 'OTransition' : 'oTransitionEnd otransitionend'
, 'msTransition' : 'MSTransitionEnd'
, 'transition' : 'transitionend'
}
......
......@@ -81,7 +81,7 @@
this.query = this.$element.val()
if (!this.query) {
if (!this.query || this.query.length < this.options.minLength) {
return this.shown ? this.hide() : this
}
......@@ -279,12 +279,13 @@
, items: 8
, menu: '<ul class="typeahead dropdown-menu"></ul>'
, item: '<li><a href="#"></a></li>'
, minLength: 1
}
$.fn.typeahead.Constructor = Typeahead
/* TYPEAHEAD DATA-API
/* TYPEAHEAD DATA-API
* ================== */
$(function () {
......
......@@ -36,7 +36,7 @@
, transEndEventNames = {
'WebkitTransition' : 'webkitTransitionEnd'
, 'MozTransition' : 'transitionend'
, 'OTransition' : 'otransitionend'
, 'OTransition' : 'oTransitionEnd otransitionend'
, 'msTransition' : 'MSTransitionEnd'
, 'transition' : 'transitionend'
}
......@@ -751,9 +751,9 @@
/* MODAL CLASS DEFINITION
* ====================== */
var Modal = function (content, options) {
var Modal = function (element, options) {
this.options = options
this.$element = $(content)
this.$element = $(element)
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
this.options.remote && this.$element.find('.modal-body').load(this.options.remote)
}
......@@ -1000,8 +1000,8 @@
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.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
}
this.options.selector ?
......@@ -1129,6 +1129,8 @@
$.support.transition && this.$tip.hasClass('fade') ?
removeWithAnimation() :
$tip.remove()
return this
}
, fixTitle: function () {
......@@ -1189,7 +1191,7 @@
}
, destroy: function () {
this.$element.off().removeData('tooltip')
this.hide().$element.off('.' + this.type).removeData(this.type)
}
}
......@@ -1250,7 +1252,7 @@
/* POPOVER PUBLIC CLASS DEFINITION
* =============================== */
var Popover = function ( element, options ) {
var Popover = function (element, options) {
this.init('popover', element, options)
}
......@@ -1296,7 +1298,7 @@
}
, destroy: function () {
this.$element.off().removeData('popover')
this.hide().$element.off('.' + this.type).removeData(this.type)
}
})
......@@ -1348,15 +1350,15 @@
"use strict"; // jshint ;_;
/* SCROLLSPY CLASS DEFINITION
* ========================== */
/* SCROLLSPY CLASS DEFINITION
* ========================== */
function ScrollSpy( element, options) {
function ScrollSpy(element, options) {
var process = $.proxy(this.process, this)
, $element = $(element).is('body') ? $(window) : $(element)
, href
this.options = $.extend({}, $.fn.scrollspy.defaults, options)
this.$scrollElement = $element.on('scroll.scroll.data-api', process)
this.$scrollElement = $element.on('scroll.scroll-spy.data-api', process)
this.selector = (this.options.target
|| ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
|| '') + ' .nav li > a'
......@@ -1446,7 +1448,7 @@
/* SCROLLSPY PLUGIN DEFINITION
* =========================== */
$.fn.scrollspy = function ( option ) {
$.fn.scrollspy = function (option) {
return this.each(function () {
var $this = $(this)
, data = $this.data('scrollspy')
......@@ -1466,7 +1468,7 @@
/* SCROLLSPY DATA-API
* ================== */
$(function () {
$(window).on('load', function () {
$('[data-spy="scroll"]').each(function () {
var $spy = $(this)
$spy.scrollspy($spy.data())
......@@ -1501,7 +1503,7 @@
/* TAB CLASS DEFINITION
* ==================== */
var Tab = function ( element ) {
var Tab = function (element) {
this.element = $(element)
}
......@@ -1690,7 +1692,7 @@
this.query = this.$element.val()
if (!this.query) {
if (!this.query || this.query.length < this.options.minLength) {
return this.shown ? this.hide() : this
}
......@@ -1888,12 +1890,13 @@
, items: 8
, menu: '<ul class="typeahead dropdown-menu"></ul>'
, item: '<li><a href="#"></a></li>'
, minLength: 1
}
$.fn.typeahead.Constructor = Typeahead
/* TYPEAHEAD DATA-API
/* TYPEAHEAD DATA-API
* ================== */
$(function () {
......
This diff is collapsed.
......@@ -78,7 +78,6 @@
</div>
</header>
<div class="bs-docs-canvas">
<div class="container">
......@@ -1798,6 +1797,7 @@ For example, &lt;code&gt;section&lt;/code&gt; should be wrapped as inline.
<script src="assets/js/bootstrap-collapse.js"></script>
<script src="assets/js/bootstrap-carousel.js"></script>
<script src="assets/js/bootstrap-typeahead.js"></script>
<script src="assets/js/bootstrap-affix.js"></script>
<script src="assets/js/application.js"></script>
......
......@@ -2198,6 +2198,7 @@ class="clearfix"
<script src="assets/js/bootstrap-collapse.js"></script>
<script src="assets/js/bootstrap-carousel.js"></script>
<script src="assets/js/bootstrap-typeahead.js"></script>
<script src="assets/js/bootstrap-affix.js"></script>
<script src="assets/js/application.js"></script>
......
......@@ -96,7 +96,6 @@
<div class="span9">
<!-- Customize form
================================================== -->
<form>
......@@ -470,6 +469,7 @@
<script src="assets/js/bootstrap-collapse.js"></script>
<script src="assets/js/bootstrap-carousel.js"></script>
<script src="assets/js/bootstrap-typeahead.js"></script>
<script src="assets/js/bootstrap-affix.js"></script>
<script src="assets/js/application.js"></script>
......
......@@ -85,7 +85,7 @@
================================================== -->
<div class="row">
<div class="span3 bs-docs-sidebar">
<ul class="nav nav-list bs-docs-sidenav">
<ul class="nav nav-list bs-docs-sidenav" data-spy="affix" data-offset-y="80">
<li><a href="#built-with-less">Built with LESS <i class="icon-chevron-right"></i></a></li>
<li><a href="#compiling">Compiling Bootstrap <i class="icon-chevron-right"></i></a></li>
<li><a href="#static-assets">Use as static assets <i class="icon-chevron-right"></i></a></li>
......@@ -281,6 +281,7 @@
<script src="assets/js/bootstrap-collapse.js"></script>
<script src="assets/js/bootstrap-carousel.js"></script>
<script src="assets/js/bootstrap-typeahead.js"></script>
<script src="assets/js/bootstrap-affix.js"></script>
<script src="assets/js/application.js"></script>
......
......@@ -327,6 +327,7 @@
<script src="assets/js/bootstrap-collapse.js"></script>
<script src="assets/js/bootstrap-carousel.js"></script>
<script src="assets/js/bootstrap-typeahead.js"></script>
<script src="assets/js/bootstrap-affix.js"></script>
<script src="assets/js/application.js"></script>
......
......@@ -201,6 +201,7 @@
<script src="assets/js/bootstrap-collapse.js"></script>
<script src="assets/js/bootstrap-carousel.js"></script>
<script src="assets/js/bootstrap-typeahead.js"></script>
<script src="assets/js/bootstrap-affix.js"></script>
<script src="assets/js/application.js"></script>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -581,6 +581,7 @@
<script src="assets/js/bootstrap-collapse.js"></script>
<script src="assets/js/bootstrap-carousel.js"></script>
<script src="assets/js/bootstrap-typeahead.js"></script>
<script src="assets/js/bootstrap-affix.js"></script>
<script src="assets/js/application.js"></script>
......
......@@ -121,6 +121,7 @@
<script src="assets/js/bootstrap-collapse.js"></script>
<script src="assets/js/bootstrap-carousel.js"></script>
<script src="assets/js/bootstrap-typeahead.js"></script>
<script src="assets/js/bootstrap-affix.js"></script>
<script src="assets/js/application.js"></script>
{{#production}}
......
......@@ -7,7 +7,6 @@
</div>
</header>
<div class="bs-docs-canvas">
<div class="container">
......
......@@ -25,7 +25,6 @@
<div class="span9">
<!-- Customize form
================================================== -->
<form>
......
......@@ -14,7 +14,7 @@
================================================== -->
<div class="row">
<div class="span3 bs-docs-sidebar">
<ul class="nav nav-list bs-docs-sidenav">
<ul class="nav nav-list bs-docs-sidenav" data-spy="affix" data-offset-y="80">
<li><a href="#built-with-less">{{_i}}Built with LESS{{/i}} <i class="icon-chevron-right"></i></a></li>
<li><a href="#compiling">{{_i}}Compiling Bootstrap{{/i}} <i class="icon-chevron-right"></i></a></li>
<li><a href="#static-assets">{{_i}}Use as static assets{{/i}} <i class="icon-chevron-right"></i></a></li>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -302,6 +302,7 @@
<script src="assets/js/bootstrap-collapse.js"></script>
<script src="assets/js/bootstrap-carousel.js"></script>
<script src="assets/js/bootstrap-typeahead.js"></script>
<script src="assets/js/bootstrap-affix.js"></script>
<script src="assets/js/application.js"></script>
......
......@@ -3,6 +3,7 @@
"laxcomma" : true,
"laxbreak" : true,
"browser" : true,
"eqnull" : true,
"debug" : true,
"devel" : true,
"boss" : true,
......
## 2.0 BOOTSTRAP JS PHILOSOPHY
These are the high-level design rules which guide the development of Bootstrap's plugin apis.
---
### DATA-ATTRIBUTE API
We believe you should be able to use all plugins provided by Bootstrap purely through the markup API without writing a single line of JavaScript. This is Bootstrap's first class API.
We acknowledge that this isn't always the most performant and it may sometimes 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').off('.data-api')
To target a specific plugin, just include the plugins name as a namespace along with the data-api namespace like this:
$('body').off('.alert.data-api')
---
### PROGRAMATIC API
We also believe you should be able to use all plugins provided by Bootstrap purely through the JavaScript API.
All public APIs should be single, chainable methods, and return the collection acted upon.
$(".btn.danger").button("toggle").addClass("fat")
All methods should accept an optional options object, a string which targets a particular method, or null which initiates the default behavior:
$("#myModal").modal() // initialized with defaults
$("#myModal").modal({ keyboard: false }) // initialized with no keyboard
$("#myModal").modal('show') // initializes and invokes show immediately
---
### OPTIONS
Options should be sparse and add universal value. We should pick the right defaults.
All plugins should have a default object which can be modified to affect all instances' default options. The defaults object should be available via `$.fn.plugin.defaults`.
$.fn.modal.defaults = { … }
An options definition should take the following form:
*noun*: *adjective* - describes or modifies a quality of an instance
Examples:
backdrop: true
keyboard: false
placement: 'top'
---
### EVENTS
All events should have an infinitive and past participle form. The infinitive is fired just before an action takes place, the past participle on completion of the action.
show | shown
hide | hidden
All infinitive events should provide preventDefault functionality. This provides the abililty to stop the execution of an action.
$('#myModal').on('show', function (e) {
if (!data) return e.preventDefault() // stops modal from being shown
})
---
### CONSTRUCTORS
Each plugin should expose its 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 should take the following form:
- data-{{verb}}={{plugin}} - defines main interaction
- data-target || href^=# - defined on "control" element (if element controls an element other than self)
- data-{{noun}} - defines class instance options
Examples:
// control other targets
data-toggle="modal" data-target="#foo"
data-toggle="collapse" data-target="#foo" data-parent="#bar"
// defined on element they control
data-spy="scroll"
data-dismiss="modal"
data-dismiss="alert"
data-toggle="dropdown"
data-toggle="button"
data-toggle="buttons-checkbox"
data-toggle="buttons-radio"
\ No newline at end of file
/* ==========================================================
* bootstrap-affix.js v2.1.0
* http://twitter.github.com/bootstrap/javascript.html#affix
* ==========================================================
* Copyright 2012 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ========================================================== */
!function ($) {
"use strict"; // jshint ;_;
/* AFFIX CLASS DEFINITION
* ====================== */
var Affix = function (element, options) {
this.options = $.extend({}, $.fn.affix.defaults, options)
this.$window = $(window)
.on('scroll.affix.data-api', $.proxy(this.checkPosition, this))
.on('resize.affix.data-api', $.proxy(this.refresh, this))
this.$element = $(element)
this.refresh()
}
Affix.prototype.refresh = function () {
this.position = this.$element.offset()
}
Affix.prototype.checkPosition = function () {
if (!this.$element.is(':visible')) return
var scrollLeft = this.$window.scrollLeft()
, scrollTop = this.$window.scrollTop()
, position = this.position
, offset = this.options.offset
, affix
if (typeof offset != 'object') offset = { x: offset, y: offset }
affix = (offset.x == null || (position.left - scrollLeft <= offset.x))
&& (offset.y == null || (position.top - scrollTop <= offset.y))
if (affix == this.affixed) return
this.affixed = affix
this.$element[affix ? 'addClass' : 'removeClass']('affix')
}
/* AFFIX PLUGIN DEFINITION
* ======================= */
$.fn.affix = function (option) {
return this.each(function () {
var $this = $(this)
, data = $this.data('affix')
, options = typeof option == 'object' && option
if (!data) $this.data('affix', (data = new Affix(this, options)))
if (typeof option == 'string') data[option]()
})
}
$.fn.affix.Constructor = Affix
$.fn.affix.defaults = {
offset: 0
}
/* AFFIX DATA-API
* ============== */
$(function () {
$('[data-spy="affix"]').each(function () {
var $spy = $(this)
, data = $spy.data()
data.offset = data.offset || {}
data.offsetX && (data.offset.x = data.offsetX)
data.offsetY && (data.offset.y = data.offsetY)
$spy.affix(data)
})
})
}(window.jQuery);
\ No newline at end of file
......@@ -26,9 +26,9 @@
/* MODAL CLASS DEFINITION
* ====================== */
var Modal = function (content, options) {
var Modal = function (element, options) {
this.options = options
this.$element = $(content)
this.$element = $(element)
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
this.options.remote && this.$element.find('.modal-body').load(this.options.remote)
}
......
......@@ -26,7 +26,7 @@
/* POPOVER PUBLIC CLASS DEFINITION
* =============================== */
var Popover = function ( element, options ) {
var Popover = function (element, options) {
this.init('popover', element, options)
}
......@@ -72,7 +72,7 @@
}
, destroy: function () {
this.$element.off().removeData('popover')
this.hide().$element.off('.' + this.type).removeData(this.type)
}
})
......
......@@ -23,15 +23,15 @@
"use strict"; // jshint ;_;
/* SCROLLSPY CLASS DEFINITION
* ========================== */
/* SCROLLSPY CLASS DEFINITION
* ========================== */
function ScrollSpy( element, options) {
function ScrollSpy(element, options) {
var process = $.proxy(this.process, this)
, $element = $(element).is('body') ? $(window) : $(element)
, href
this.options = $.extend({}, $.fn.scrollspy.defaults, options)
this.$scrollElement = $element.on('scroll.scroll.data-api', process)
this.$scrollElement = $element.on('scroll.scroll-spy.data-api', process)
this.selector = (this.options.target
|| ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
|| '') + ' .nav li > a'
......@@ -121,7 +121,7 @@
/* SCROLLSPY PLUGIN DEFINITION
* =========================== */
$.fn.scrollspy = function ( option ) {
$.fn.scrollspy = function (option) {
return this.each(function () {
var $this = $(this)
, data = $this.data('scrollspy')
......@@ -141,7 +141,7 @@
/* SCROLLSPY DATA-API
* ================== */
$(function () {
$(window).on('load', function () {
$('[data-spy="scroll"]').each(function () {
var $spy = $(this)
$spy.scrollspy($spy.data())
......
......@@ -26,7 +26,7 @@
/* TAB CLASS DEFINITION
* ==================== */
var Tab = function ( element ) {
var Tab = function (element) {
this.element = $(element)
}
......
......@@ -47,8 +47,8 @@
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.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
}
this.options.selector ?
......@@ -176,6 +176,8 @@
$.support.transition && this.$tip.hasClass('fade') ?
removeWithAnimation() :
$tip.remove()
return this
}
, fixTitle: function () {
......@@ -236,7 +238,7 @@
}
, destroy: function () {
this.$element.off().removeData('tooltip')
this.hide().$element.off('.' + this.type).removeData(this.type)
}
}
......
......@@ -36,7 +36,7 @@
, transEndEventNames = {
'WebkitTransition' : 'webkitTransitionEnd'
, 'MozTransition' : 'transitionend'
, 'OTransition' : 'otransitionend'
, 'OTransition' : 'oTransitionEnd otransitionend'
, 'msTransition' : 'MSTransitionEnd'
, 'transition' : 'transitionend'
}
......
......@@ -81,7 +81,7 @@
this.query = this.$element.val()
if (!this.query) {
if (!this.query || this.query.length < this.options.minLength) {
return this.shown ? this.hide() : this
}
......@@ -279,12 +279,13 @@
, items: 8
, menu: '<ul class="typeahead dropdown-menu"></ul>'
, item: '<li><a href="#"></a></li>'
, minLength: 1
}
$.fn.typeahead.Constructor = Typeahead
/* TYPEAHEAD DATA-API
/* TYPEAHEAD DATA-API
* ================== */
$(function () {
......
......@@ -27,6 +27,7 @@
<script src="../../js/bootstrap-tooltip.js"></script>
<script src="../../js/bootstrap-popover.js"></script>
<script src="../../js/bootstrap-typeahead.js"></script>
<script src="../../js/bootstrap-affix.js"></script>
<!-- unit tests -->
<script src="unit/bootstrap-transition.js"></script>
......@@ -41,6 +42,7 @@
<script src="unit/bootstrap-tooltip.js"></script>
<script src="unit/bootstrap-popover.js"></script>
<script src="unit/bootstrap-typeahead.js"></script>
<script src="unit/bootstrap-affix.js"></script>
</head>
<body>
<div>
......
$(function () {
module("bootstrap-affix")
test("should be defined on jquery object", function () {
ok($(document.body).affix, 'affix method is defined')
})
test("should return element", function () {
ok($(document.body).affix()[0] == document.body, 'document.body returned')
})
test("should exit early if element is not visible", function () {
var $affix = $('<div style="display: none"></div>').affix()
$affix.data('affix').checkPosition()
ok(!$affix.hasClass('affix'), 'affix class was not added')
})
})
\ No newline at end of file
......@@ -92,12 +92,16 @@ $(function () {
})
test("should destroy popover", function () {
var popover = $('<div/>').popover()
var popover = $('<div/>').popover().on('click.foo', function(){})
ok(popover.data('popover'), 'popover has data')
ok(popover.data('events').mouseover && popover.data('events').mouseout, 'popover has hover event')
ok(popover.data('events').click[0].namespace == 'foo', 'popover has extra click.foo event')
popover.popover('show')
popover.popover('destroy')
ok(!popover.hasClass('in'), 'popover is hidden')
ok(!popover.data('popover'), 'popover does not have data')
ok(!popover.data('events'), 'popover does not have any events')
ok(popover.data('events').click[0].namespace == 'foo', 'popover still has click.foo')
ok(!popover.data('events').mouseover && !popover.data('events').mouseout, 'popover does not have any events')
})
})
\ No newline at end of file
......@@ -129,12 +129,16 @@ $(function () {
})
test("should destroy tooltip", function () {
var tooltip = $('<div/>').tooltip()
var tooltip = $('<div/>').tooltip().on('click.foo', function(){})
ok(tooltip.data('tooltip'), 'tooltip has data')
ok(tooltip.data('events').mouseover && tooltip.data('events').mouseout, 'tooltip has hover event')
ok(tooltip.data('events').click[0].namespace == 'foo', 'tooltip has extra click.foo event')
tooltip.tooltip('show')
tooltip.tooltip('destroy')
ok(!tooltip.hasClass('in'), 'tooltip is hidden')
ok(!tooltip.data('tooltip'), 'tooltip does not have data')
ok(!tooltip.data('events'), 'tooltip does not have any events')
ok(tooltip.data('events').click[0].namespace == 'foo', 'tooltip still has click.foo')
ok(!tooltip.data('events').mouseover && !tooltip.data('events').mouseout, 'tooltip does not have any events')
})
})
......@@ -181,4 +181,24 @@ $(function () {
typeahead.$menu.remove()
})
test("should start querying when minLength is met", function () {
var $input = $('<input />').typeahead({
source: ['aaaa', 'aaab', 'aaac'],
minLength: 3
})
, typeahead = $input.data('typeahead')
$input.val('aa')
typeahead.lookup()
equals(typeahead.$menu.find('li').length, 0, 'has 0 items in menu')
$input.val('aaa')
typeahead.lookup()
equals(typeahead.$menu.find('li').length, 3, 'has 3 items in menu')
typeahead.$menu.remove()
})
})
......@@ -78,6 +78,7 @@ sub {
img {
max-width: 100%; // Make images inherently responsive
height: auto; // Make images inherently responsive
vertical-align: middle;
border: 0;
-ms-interpolation-mode: bicubic;
......
......@@ -24,3 +24,7 @@
.invisible {
visibility: hidden;
}
.affix {
position: fixed;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment