]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
improve alert api - $("#fat").alert("close") should just work.
authorJacob Thornton <jacobthornton@gmail.com>
Wed, 16 Nov 2011 08:27:04 +0000 (00:27 -0800)
committerJacob Thornton <jacobthornton@gmail.com>
Wed, 16 Nov 2011 08:27:04 +0000 (00:27 -0800)
bootstrap.css
js/bootstrap-alerts.js

index ac267a028406cdc573c8508fac2b454e0e76c312..91216cc32d52bed933accce52bc3b1b3201aa9a4 100644 (file)
@@ -6,7 +6,7 @@
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Designed and built with all the love in the world @twitter by @mdo and @fat.
- * Date: Sat Nov  5 17:07:48 PDT 2011
+ * Date: Sat Nov 12 20:22:29 PST 2011
  */
 /* Reset.less
  * Props to Eric Meyer (meyerweb.com) for his CSS reset file. We're using an adapted version here      that cuts out some of the reset HTML elements we will never need here (i.e., dfn, samp, etc).
index 37bb430aa2737326dc9586e8457968f552db746f..7c4b919f700a56009d79a353f33ba9900bc2f851 100644 (file)
@@ -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)
   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')
       var $this = $(this)
 
       if ( typeof options == 'string' ) {
-        return $this.data('alert')[options]()
+        var data = $this.data('alert')
+
+        if (typeof data == 'object') {
+          return data[options].call( $this )
+        }
+
       }
 
       $(this).data('alert', new Alert( this, options ))