]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
add some more events to alerts and modal and update docs
authorJacob Thornton <jacobthornton@gmail.com>
Sat, 10 Sep 2011 21:04:22 +0000 (14:04 -0700)
committerJacob Thornton <jacobthornton@gmail.com>
Sat, 10 Sep 2011 21:04:22 +0000 (14:04 -0700)
docs/javascript.html
js/bootstrap-alerts.js
js/bootstrap-modal.js

index 8a4636bb3d8286a77ca76859f8318fb72330e9e6..47cd34414bb47c5b237794f58f86635524a0460f 100644 (file)
@@ -85,9 +85,9 @@ $('#modal-content').modal({
   closeOnEscape: true
 })</pre>
           <h3>Events</h3>
-          <p>Trigger events to make things happen!</p>
+          <p>Bootstraps modal class makes use of custom events. You can use <code>trigger</code> to make things happen manually or <code>bind</code> to listen for things happening.</p>
           <h4>modal:toggle</h4>
-          <p> Toggle the modal open state.</p>
+          <p>Toggle the modal open state.</p>
           <pre class="prettyprint linenums">$('#modal-content').trigger('modal:toggle')</pre>
           <h4>modal:show</h4>
           <p>Opens the modal.</p>
@@ -95,8 +95,21 @@ $('#modal-content').modal({
           <h4>modal:hide</h4>
           <p>Closes the modal.</p>
           <pre class="prettyprint linenums">$('#modal-content').trigger('modal:hide')</pre>
+          <h4>modal:shown</h4>
+          <p>Fired when the modal has been made visible.</p>
+  <pre class="prettyprint linenums">
+$('#modal-content')
+  .bind('modal:shown', function () {
+    // do something here...
+  })</pre>
+          <h4>modal:hidden</h4>
+          <p>Fired when the modal has become hidden</p>
+<pre class="prettyprint linenums">
+$('#modal-content')
+  .bind('modal:hidden', function () {
+    $(this).remove() // cleanup jQuery plugin data on hide
+  })</pre>
           <h3>Demo</h3>
-
           <!-- sample modal content -->
           <div id="modal-from-dom" class="modal hide fade">
             <div class="modal-header">
@@ -235,6 +248,8 @@ $('#modal-content').modal({
   &lt;div id="settings"&gt;...&lt;/div&gt;
 &lt;/ul&gt;</pre>
           </p>
+          <p><strong>note:</strong> To manually activate a tab just fire a click event on one of the tabs.</p>
+          <pre class="prettyprint linenums">$('.tabs a[href="#messages"]').click()</pre>
           <h3>Demo</h3>
           <script>
             $(function () {
@@ -296,6 +311,14 @@ Sunt qui biodiesel mollit officia, fanny pack put a bird on it thundercats seita
           <h3>Methods</h3>
           <h4>$().twipsy</h4>
           <p>Attaches a twipsy handler to an element collection.</p>
+          <h3>Events</h3>
+          <p>You can manually control twipsies by firing events on the controlling element.</p>
+          <h4>twipsy:show</h4>
+          <p>Reveals an elements twipsy.</p>
+          <pre class="prettyprint linenums">$('#element').trigger('twipsy:show')</pre>
+          <h4>twipsy:hide</h4>
+          <p>Hides an elements twipsy.</p>
+          <pre class="prettyprint linenums">$('#element').trigger('twipsy:hide')</pre>
           <h3>Demo</h3>
           <div class="well">
             <p class="muted">Tight pants next level keffiyeh <a href="#" rel='twipsy' title='Some title text'>you probably</a> haven't heard of them. Photo booth beard raw denim letterpress vegan messenger bag stumptown. Farm-to-table seitan, mcsweeney's fixie sustainable quinoa 8-bit american apparel <a href="#" rel='twipsy' title='Another twipsy'>have a</a> terry richardson vinyl chambray. Beard stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel williamsburg marfa, four loko mcsweeney's cleanse vegan chambray. A <a href="#" rel='twipsy' title='Another one here too'>really ironic</a> artisan whatever keytar, scenester farm-to-table banksy Austin <a href="#" rel='twipsy' title='The last tip!'>twitter handle</a> freegan cred raw denim single-origin coffee viral.
@@ -344,8 +367,16 @@ Sunt qui biodiesel mollit officia, fanny pack put a bird on it thundercats seita
           <h3>Methods</h3>
           <h4>$().popover</h4>
           <p>Initializes popovers for an element collection.</p>
+          <h3>Events</h3>
+          <p>You can manually control popovers by firing events on the controlling element.</p>
+          <h4>popover:show</h4>
+          <p>Reveals an elements popover.</p>
+          <pre class="prettyprint linenums">$('#element').trigger('popover:show')</pre>
+          <h4>popover:hide</h4>
+          <p>Hides an elements popover.</p>
+          <pre class="prettyprint linenums">$('#element').trigger('popover:hide')</pre>
           <h3>Demo</h3>
-          <a href="#" class="btn danger" rel="popover" data-title="A Title" data-content="And here's some amazing content. It's very engaging. right?">hover</a>
+          <a href="#" class="btn danger" rel="popover" data-title="A Title" data-content="And here's some amazing content. It's very engaging. right?">hover for popover</a>
           <script>
             $(function () {
               $("a[rel=popover]").popover({
@@ -376,6 +407,11 @@ Sunt qui biodiesel mollit officia, fanny pack put a bird on it thundercats seita
           <h3>Methods</h3>
           <h4>$().alert</h4>
           <p>Wraps all alerts with close functionality. To have your alerts animate out when closed, make sure they have the <code>.fade</code> and <code>.in</code> class already applied to them.</p>
+          <h3>Events</h3>
+          <p>You can manually control alerts by firing events on them.</p>
+          <h4>alert:close</h4>
+          <p>Closes an alert.</p>
+          <pre class="prettyprint linenums">$(".alert-message").trigger('alert:close')</pre>
           <h3>Demo</h3>
           <div class="alert-message warning fade in">
             <a class="close" href="#">&times;</a>
index e27ac648294d8e48322529e04311da7750c16b1a..4c9c9394d6c2a7e6cfa6f1179c5efefd3f715114 100644 (file)
   var Alert = function ( content ) {
     var that = this
     this.$element = $(content)
-    this.$element.delegate('.close', 'click', function (e) {
-      e.preventDefault()
-      that.close()
-    })
+      .bind('alert:hide', $.proxy(this.close, this))
+      .delegate('.close', 'click', function (e) {
+        e.preventDefault()
+        that.close()
+      })
   }
 
   Alert.prototype = {
index 54cbad4b110d9cb635146e6ef6338d88c888d0e5..de972a8aa14ce2f0c6f4103c63497feeb238a0ac 100644 (file)
@@ -66,7 +66,7 @@
         .show()
 
       setTimeout(function () {
-        that.$element.addClass('in')
+        that.$element.addClass('in').trigger('modal:shown')
         that.$backdrop && that.$backdrop.addClass('in')
       }, 1)
 
       this.$element.removeClass('in')
 
       function removeElement () {
-        that.$element.unbind(transitionEnd)
-        that.$element.detach()
+        that.$element
+          .unbind(transitionEnd)
+          .detach()
+          .trigger('modal:hidden')
       }
 
       $.support.transition && this.$element.hasClass('fade') ?