From f9129ee84867edf8b94c400c9837f64153b86abe Mon Sep 17 00:00:00 2001 From: Thomas McDonald Date: Fri, 2 Dec 2011 22:20:23 +0000 Subject: [PATCH] Update javascripts to Bootstrap master --- vendor/assets/javascripts/bootstrap-alerts.js | 15 +++++++++++-- .../assets/javascripts/bootstrap-buttons.js | 10 +++++---- .../assets/javascripts/bootstrap-popover.js | 8 +++++-- vendor/assets/javascripts/bootstrap-twipsy.js | 21 ++++++++++++++----- 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/vendor/assets/javascripts/bootstrap-alerts.js b/vendor/assets/javascripts/bootstrap-alerts.js index afcfe7b5..fbbdc4f9 100644 --- a/vendor/assets/javascripts/bootstrap-alerts.js +++ b/vendor/assets/javascripts/bootstrap-alerts.js @@ -54,6 +54,7 @@ * ====================== */ var Alert = function ( content, options ) { + if (options == 'close') return this.close.call(content) this.settings = $.extend({}, $.fn.alert.defaults, options) this.$element = $(content) .delegate(this.settings.selector, 'click', this.close) @@ -62,7 +63,10 @@ Alert.prototype = { close: function (e) { - var $element = $(this).parent('.alert-message') + var $element = $(this) + , className = 'alert-message' + + $element = $element.hasClass(className) ? $element : $element.parent() e && e.preventDefault() $element.removeClass('in') @@ -90,9 +94,16 @@ return this.each(function () { var $this = $(this) + , data if ( typeof options == 'string' ) { - return $this.data('alert')[options]() + + data = $this.data('alert') + + if (typeof data == 'object') { + return data[options].call( $this ) + } + } $(this).data('alert', new Alert( this, options )) diff --git a/vendor/assets/javascripts/bootstrap-buttons.js b/vendor/assets/javascripts/bootstrap-buttons.js index 2055042e..4a3853a7 100644 --- a/vendor/assets/javascripts/bootstrap-buttons.js +++ b/vendor/assets/javascripts/bootstrap-buttons.js @@ -1,6 +1,6 @@ /* ============================================================ * bootstrap-buttons.js v1.4.0 - * http://twitter.github.com/bootstrap/javascript.html#dropdown + * http://twitter.github.com/bootstrap/javascript.html#buttons * ============================================================ * Copyright 2011 Twitter, Inc. * @@ -31,9 +31,11 @@ $el.html( data[state] || $.fn.button.defaults[state] ) - state == 'loadingText' ? - $el.addClass(d).attr(d, d) : - $el.removeClass(d).removeAttr(d) + setTimeout(function () { + state == 'loadingText' ? + $el.addClass(d).attr(d, d) : + $el.removeClass(d).removeAttr(d) + }, 0) } function toggle(el) { diff --git a/vendor/assets/javascripts/bootstrap-popover.js b/vendor/assets/javascripts/bootstrap-popover.js index 781a095a..39fb575b 100644 --- a/vendor/assets/javascripts/bootstrap-popover.js +++ b/vendor/assets/javascripts/bootstrap-popover.js @@ -37,7 +37,7 @@ setContent: function () { var $tip = this.tip() $tip.find('.title')[this.options.html ? 'html' : 'text'](this.getTitle()) - $tip.find('.content p')[this.options.html ? 'html' : 'text'](this.getContent()) + $tip.find('.content > *')[this.options.html ? 'html' : 'text'](this.getContent()) $tip[0].className = 'popover' } @@ -51,10 +51,11 @@ , o = this.options if (typeof this.options.content == 'string') { - content = this.options.content + content = $e.attr(this.options.content) } else if (typeof this.options.content == 'function') { content = this.options.content.call(this.$element[0]) } + return content } @@ -80,7 +81,10 @@ $.fn.popover.defaults = $.extend({} , $.fn.twipsy.defaults, { placement: 'right' + , content: 'data-content' , template: '

' }) + $.fn.twipsy.rejectAttrOptions.push( 'content' ) + }( window.jQuery || window.ender ); diff --git a/vendor/assets/javascripts/bootstrap-twipsy.js b/vendor/assets/javascripts/bootstrap-twipsy.js index b9d99e7c..ca409fd5 100644 --- a/vendor/assets/javascripts/bootstrap-twipsy.js +++ b/vendor/assets/javascripts/bootstrap-twipsy.js @@ -168,10 +168,7 @@ } , tip: function() { - if (!this.$tip) { - this.$tip = $('
').html(this.options.template) - } - return this.$tip + return this.$tip = this.$tip || $('
').html(this.options.template) } , validate: function() { @@ -194,6 +191,10 @@ this.enabled = !this.enabled } + , toggle: function () { + this[this.tip().hasClass('in') ? 'hide' : 'show']() + } + } @@ -303,8 +304,18 @@ , template: '
' } + $.fn.twipsy.rejectAttrOptions = [ 'title' ] + $.fn.twipsy.elementOptions = function(ele, options) { - return $.extend({}, options, $(ele).data()) + 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 );