Commit 9fb38015 authored by Mark Otto's avatar Mark Otto

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

Conflicts:
	bootstrap.css
	docs/javascript.html
parents 12a0d694 a5a98a8a
...@@ -6,7 +6,7 @@ ...@@ -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 { ...@@ -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 { ...@@ -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%;
......
...@@ -321,13 +321,21 @@ button.btn::-moz-focus-inner,input[type=submit].btn::-moz-focus-inner{padding:0; ...@@ -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;}
......
...@@ -68,7 +68,7 @@ $(function(){ ...@@ -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({
......
This diff is collapsed.
## 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 ...@@ -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 ...@@ -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: ...@@ -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 ...@@ -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"
......
...@@ -27,7 +27,7 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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 )
\ No newline at end of file \ No newline at end of file
...@@ -24,16 +24,16 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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 )
\ No newline at end of file \ No newline at end of file
...@@ -25,8 +25,8 @@ ...@@ -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 @@ ...@@ -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
/* CAROUSEL DATA-API
* ================= */
// $(function () {
// $('body').delegate(dismiss, 'click.alert.data-api', Alert.prototype.close)
// })
}( window.jQuery || window.ender ) }( window.jQuery )
\ No newline at end of file \ No newline at end of file
...@@ -23,13 +23,13 @@ ...@@ -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 @@ ...@@ -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 )
\ No newline at end of file \ No newline at end of file
...@@ -35,11 +35,15 @@ ...@@ -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 @@ ...@@ -47,7 +51,7 @@
} }
function clearMenus() { function clearMenus() {
$(toggle).parent('li').removeClass('open') $(toggle).parent().removeClass('open')
} }
...@@ -63,13 +67,15 @@ ...@@ -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 )
\ No newline at end of file \ No newline at end of file
...@@ -26,10 +26,9 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -107,7 +106,7 @@
}) })
} }
function hideModal (that) { function hideModal( that ) {
this.$element this.$element
.hide() .hide()
.trigger('hidden') .trigger('hidden')
...@@ -115,17 +114,17 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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 )
\ No newline at end of file \ No newline at end of file
...@@ -23,16 +23,13 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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 )
\ No newline at end of file
}( window.jQuery || window.ender )
\ No newline at end of file
...@@ -27,11 +27,11 @@ ...@@ -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 @@ ...@@ -103,7 +103,7 @@
}) })
} }
$.fn.scrollspy.ScrollSpy = ScrollSpy $.fn.scrollspy.Constructor = ScrollSpy
/* SCROLLSPY DATA-API /* SCROLLSPY DATA-API
...@@ -111,4 +111,4 @@ ...@@ -111,4 +111,4 @@
$(function () { $('[data-spy="scroll"]').scrollspy() }) $(function () { $('[data-spy="scroll"]').scrollspy() })
}( window.jQuery || window.ender ) }( window.jQuery )
\ No newline at end of file \ No newline at end of file
...@@ -52,26 +52,45 @@ ...@@ -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')
function next() {
$active
.removeClass('active')
.find('> .dropdown-menu > .active')
.removeClass('active')
element.addClass('active') element.addClass('active')
if ( element.parent('.dropdown-menu') ) { if (transition) {
element.closest('li.dropdown').addClass('active') 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 @@ ...@@ -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 @@ ...@@ -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 )
\ No newline at end of file \ No newline at end of file
/* ===================================================
* 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
}())
}
})()
})
\ No newline at end of file
/* ========================================================== /* ==========================================================
* 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 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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 = $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*$)/, "") title = title.toString().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 @@ ...@@ -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 @@ ...@@ -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
$.fn.twipsy.initWith = function (options, Base, name) { if (!data) $this.data('twipsy', (data = new Twipsy(this, options)))
var twipsy if (typeof option == 'string') data[option]()
, 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.Constructor = 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' ]
$.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 ) }( window.jQuery )
\ No newline at end of file \ No newline at end of file
...@@ -4,28 +4,36 @@ ...@@ -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 @@ ...@@ -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>
\ No newline at end of file
...@@ -12,7 +12,7 @@ $(function () { ...@@ -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, you’re not looking too good.</p>' + '<p><strong>Holy guacamole!</strong> Best check yo self, you’re not looking too good.</p>'
+ '</div>' + '</div>'
, alert = $(alertHTML).alert() , alert = $(alertHTML).alert()
...@@ -26,16 +26,16 @@ $(function () { ...@@ -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, you’re not looking too good.</p>' + '<p><strong>Holy guacamole!</strong> Best check yo self, you’re 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')
}) })
}) })
\ No newline at end of file
$(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')
})
})
\ No newline at end of file
$(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')
})
})
\ No newline at end of file
...@@ -13,7 +13,7 @@ $(function () { ...@@ -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 () { ...@@ -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 () { ...@@ -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()
}) })
......
...@@ -10,6 +10,7 @@ $(function () { ...@@ -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 () { ...@@ -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 () { ...@@ -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 () { ...@@ -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 () { ...@@ -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")
}) })
......
...@@ -15,14 +15,12 @@ $(function () { ...@@ -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 () { ...@@ -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 () { ...@@ -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 () { ...@@ -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()
}) })
}) })
\ No newline at end of file
...@@ -12,7 +12,7 @@ $(function () { ...@@ -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 () { ...@@ -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))
}) })
}) })
\ No newline at end of file
...@@ -3,47 +3,44 @@ $(function () { ...@@ -3,47 +3,44 @@ $(function () {
module("bootstrap-tabs") module("bootstrap-tabs")
test("should be defined on jquery object", function () { test("should be defined on jquery object", function () {
ok($(document.body).tabs, 'tabs method is defined') ok($(document.body).tab, 'tabs method is defined')
}) })
test("should return element", function () { test("should return element", function () {
ok($(document.body).tabs()[0] == document.body, 'document.body returned') ok($(document.body).tab()[0] == document.body, 'document.body returned')
}) })
test("should activate element by tab id", function () { test("should activate element by tab id", function () {
var tabsHTML = '<ul class="tabs">' var tabsHTML =
+ '<li class="active"><a href="#home">Home</a></li>' '<ul class="tabs">'
+ '<li><a href="#home">Home</a></li>'
+ '<li><a href="#profile">Profile</a></li>' + '<li><a href="#profile">Profile</a></li>'
+ '</ul>' + '</ul>'
$('<ul><li id="home"></li><li id="profile"></li></ul>').appendTo("#qunit-runoff") $('<ul><li id="home"></li><li id="profile"></li></ul>').appendTo("#qunit-fixture")
$(tabsHTML).tabs().find('a').last().click() $(tabsHTML).find('li:last a').tab('show')
equals($("#qunit-runoff").find('.active').attr('id'), "profile") equals($("#qunit-fixture").find('.active').attr('id'), "profile")
$(tabsHTML).tabs().find('a').first().click() $(tabsHTML).find('li:first a').tab('show')
equals($("#qunit-runoff").find('.active').attr('id'), "home") equals($("#qunit-fixture").find('.active').attr('id'), "home")
$("#qunit-runoff").empty()
}) })
test("should activate element by pill id", function () { test("should activate element by tab id", function () {
var pillsHTML = '<ul class="pills">' var pillsHTML =
+ '<li class="active"><a href="#home">Home</a></li>' '<ul class="pills">'
+ '<li><a href="#home">Home</a></li>'
+ '<li><a href="#profile">Profile</a></li>' + '<li><a href="#profile">Profile</a></li>'
+ '</ul>' + '</ul>'
$('<ul><li id="home"></li><li id="profile"></li></ul>').appendTo("#qunit-fixture")
$('<ul><li id="home"></li><li id="profile"></li></ul>').appendTo("#qunit-runoff") $(pillsHTML).find('li:last a').tab('show')
equals($("#qunit-fixture").find('.active').attr('id'), "profile")
$(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() $(pillsHTML).find('li:first a').tab('show')
equals($("#qunit-fixture").find('.active').attr('id'), "home")
}) })
}) })
\ No newline at end of file
$(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')
})
})
\ No newline at end of file
...@@ -29,53 +29,23 @@ $(function () { ...@@ -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 () {
$.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
var twipsy = $('<a href="#" rel="twipsy" title="<b>@fat</b>"></a>')
.appendTo('#qunit-runoff')
.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 () { test("should always 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({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()
}) })
}) })
\ No newline at end of file
This diff is collapsed.
...@@ -227,6 +227,6 @@ ...@@ -227,6 +227,6 @@
/** Runoff */ /** Runoff */
#qunit-runoff { #qunit-fixture {
display:none; display:none;
} }
\ No newline at end of file
...@@ -8,10 +8,14 @@ ...@@ -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;
......
...@@ -9,9 +9,11 @@ ...@@ -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(); }
......
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