From 0d76eea6085dfffc82a032da23cf3ef272e96215 Mon Sep 17 00:00:00 2001
From: Paris Holley <mail@parisholley.com>
Date: Sat, 8 Sep 2012 10:56:02 -0500
Subject: [PATCH 1/7] add pagination javascript component

---
 docs/assets/js/bootstrap-pagination.js   | 147 ++++++++++++++++
 docs/base-css.html                       |  26 +++
 docs/components.html                     |  26 +++
 docs/customize.html                      |  28 ++-
 docs/extend.html                         |  26 +++
 docs/getting-started.html                |  34 +++-
 docs/index.html                          |  32 +++-
 docs/javascript.html                     | 136 ++++++++++++++-
 docs/scaffolding.html                    |  26 +++
 docs/templates/layout.mustache           |   1 +
 docs/templates/pages/javascript.mustache | 110 +++++++++++-
 js/bootstrap-pagination.js               | 137 +++++++++++++++
 js/tests/index.html                      |   2 +
 js/tests/unit/bootstrap-pagination.js    | 212 +++++++++++++++++++++++
 14 files changed, 933 insertions(+), 10 deletions(-)
 create mode 100644 docs/assets/js/bootstrap-pagination.js
 create mode 100644 js/bootstrap-pagination.js
 create mode 100644 js/tests/unit/bootstrap-pagination.js

diff --git a/docs/assets/js/bootstrap-pagination.js b/docs/assets/js/bootstrap-pagination.js
new file mode 100644
index 0000000000..c961989c8f
--- /dev/null
+++ b/docs/assets/js/bootstrap-pagination.js
@@ -0,0 +1,147 @@
+/* ===========================================================
+ * bootstrap-pagination.js v2.1.1
+ * http://twitter.github.com/bootstrap/javascript.html#pagintation
+ * ===========================================================
+ * 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 ;_;
+
+
+ /* PAGINATION PUBLIC CLASS DEFINITION
+  * =============================== */
+
+  var Pagination = function (element, options) {
+    this.$element = $(element)
+
+    this.options = $.extend({}, $.fn.pagination.defaults, options)
+    this.$paged  = $(this.options.paged).children()
+    this.total = this.$paged.length
+    this.pages = Math.ceil(this.total / this.options.pageSize)
+    this.currentPage = 0
+
+    if (this.pages > 1) {
+      this.$ul = this.$element.find('ul')
+      this.$ul = this.$ul.length ? this.$ul : $('<ul></ul>').appendTo(this.$element)
+
+      var pageClick = function(i){
+        return function(){
+          this.page(i)
+
+          return false
+        }
+      }
+
+      for (var i = 1; i < (this.pages + 1); i++) {
+        var li = $('<li><a href="#">' + i + '</a></li>').appendTo(this.$ul).click($.proxy(pageClick(i-1), this))
+      }
+
+      if (this.options.showArrows) {
+        this.$prev = $('<li><a href="#">' + this.options.prevText + '</a></li>').prependTo(this.$ul).click($.proxy(this.prev, this))
+        this.$next = $('<li><a href="#">' + this.options.nextText + '</a></li>').appendTo(this.$ul).click($.proxy(this.next, this))
+      }
+
+      this.page(this.currentPage)
+    }
+  }
+
+  Pagination.prototype = {
+
+    constructor: Pagination
+
+  , page: function(page) {
+      this.$paged.hide()
+
+      this.$ul.find('li').removeClass('active')
+
+      var index = page + (this.options.showArrows ? 1 : 0)
+
+      this.$ul.find('li:eq(' + index + ')').addClass('active')
+
+      var filtered = this.$paged.filter(':lt(' + ((page + 1) * this.options.pageSize) + ')')
+
+      if (page > 0) filtered = filtered.filter(':gt(' + ((page * this.options.pageSize) -1 ) + ')')
+
+      filtered.show()
+
+      if (this.options.showArrows) {
+        if ((page + 1) < this.pages) {
+          this.$next.removeClass('active')
+        } else {
+          this.$next.addClass('active')
+        }
+
+        if (page > 0) {
+          this.$prev.removeClass('active')
+        } else {
+          this.$prev.addClass('active')
+        }
+      }
+
+      this.currentPage = page
+    }
+
+  , next: function() {
+      if (this.currentPage < (this.pages - 1)) {
+        this.page(++this.currentPage)
+      }
+
+      return false
+    }
+
+  , prev: function() {
+      if (this.currentPage > 0) {
+        this.page(--this.currentPage)
+      }
+
+      return false
+    }
+  }
+
+ /* PAGINATION PLUGIN DEFINITION
+  * ======================= */
+
+  $.fn.pagination = function (option) {
+    return this.each(function () {
+      var $this = $(this)
+        , data = $this.data('pagination')
+      if (!data) $this.data('pagination', (data = new Pagination(this, option)))
+      if (typeof option == 'string') data[option]()
+    })
+  }
+
+  $.fn.pagination.Constructor = Pagination
+
+  $.fn.pagination.defaults = $.extend({} , $.fn.tooltip.defaults, {
+    pageSize: 5
+  , showArrows : true
+  , prevText: '&laquo'
+  , nextText: '&raquo'
+  })
+
+ /* PAGINATION DATA-API
+  * ================== */
+
+  $(window).on('load', function () {
+    $('[data-paged]').each(function () {
+      var $paginator = $(this)
+      $paginator.pagination($paginator.data())
+    })
+  })
+
+}(window.jQuery);
\ No newline at end of file
diff --git a/docs/base-css.html b/docs/base-css.html
index 7504f24699..f8624d3843 100644
--- a/docs/base-css.html
+++ b/docs/base-css.html
@@ -25,6 +25,16 @@
     <link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
     <link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
 
+    <script type="text/javascript">
+      var _gaq = _gaq || [];
+      _gaq.push(['_setAccount', 'UA-146052-10']);
+      _gaq.push(['_trackPageview']);
+      (function() {
+        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+      })();
+    </script>
   </head>
 
   <body data-spy="scroll" data-target=".bs-docs-sidebar">
@@ -1972,9 +1982,25 @@ For example, &lt;code&gt;&lt;section&gt;&lt;/code&gt; should be wrapped as inlin
     <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/bootstrap-pagination.js"></script>
     <script src="assets/js/application.js"></script>
 
 
+    <!-- Analytics
+    ================================================== -->
+    <script>
+      var _gauges = _gauges || [];
+      (function() {
+        var t   = document.createElement('script');
+        t.type  = 'text/javascript';
+        t.async = true;
+        t.id    = 'gauges-tracker';
+        t.setAttribute('data-site-id', '4f0dc9fef5a1f55508000013');
+        t.src = '//secure.gaug.es/track.js';
+        var s = document.getElementsByTagName('script')[0];
+        s.parentNode.insertBefore(t, s);
+      })();
+    </script>
 
   </body>
 </html>
diff --git a/docs/components.html b/docs/components.html
index f47aecbf19..8bee430a7a 100644
--- a/docs/components.html
+++ b/docs/components.html
@@ -25,6 +25,16 @@
     <link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
     <link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
 
+    <script type="text/javascript">
+      var _gaq = _gaq || [];
+      _gaq.push(['_setAccount', 'UA-146052-10']);
+      _gaq.push(['_trackPageview']);
+      (function() {
+        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+      })();
+    </script>
   </head>
 
   <body data-spy="scroll" data-target=".bs-docs-sidebar">
@@ -2330,9 +2340,25 @@ class="clearfix"
     <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/bootstrap-pagination.js"></script>
     <script src="assets/js/application.js"></script>
 
 
+    <!-- Analytics
+    ================================================== -->
+    <script>
+      var _gauges = _gauges || [];
+      (function() {
+        var t   = document.createElement('script');
+        t.type  = 'text/javascript';
+        t.async = true;
+        t.id    = 'gauges-tracker';
+        t.setAttribute('data-site-id', '4f0dc9fef5a1f55508000013');
+        t.src = '//secure.gaug.es/track.js';
+        var s = document.getElementsByTagName('script')[0];
+        s.parentNode.insertBefore(t, s);
+      })();
+    </script>
 
   </body>
 </html>
diff --git a/docs/customize.html b/docs/customize.html
index 0a6c65da91..04c91a23b6 100644
--- a/docs/customize.html
+++ b/docs/customize.html
@@ -25,6 +25,16 @@
     <link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
     <link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
 
+    <script type="text/javascript">
+      var _gaq = _gaq || [];
+      _gaq.push(['_setAccount', 'UA-146052-10']);
+      _gaq.push(['_trackPageview']);
+      (function() {
+        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+      })();
+    </script>
   </head>
 
   <body data-spy="scroll" data-target=".bs-docs-sidebar">
@@ -419,7 +429,7 @@
               </h1>
             </div>
             <div class="download-btn">
-              <a class="btn btn-primary" href="#" >Customize and Download</a>
+              <a class="btn btn-primary" href="#" onclick="_gaq.push(['_trackEvent', 'Customize', 'Download', 'Customize and Download']);">Customize and Download</a>
               <h4>What's included?</h4>
               <p>Downloads include compiled CSS, compiled and minified CSS, and compiled jQuery plugins, all nicely packed up into a zipball for your convenience.</p>
             </div>
@@ -472,9 +482,25 @@
     <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/bootstrap-pagination.js"></script>
     <script src="assets/js/application.js"></script>
 
 
+    <!-- Analytics
+    ================================================== -->
+    <script>
+      var _gauges = _gauges || [];
+      (function() {
+        var t   = document.createElement('script');
+        t.type  = 'text/javascript';
+        t.async = true;
+        t.id    = 'gauges-tracker';
+        t.setAttribute('data-site-id', '4f0dc9fef5a1f55508000013');
+        t.src = '//secure.gaug.es/track.js';
+        var s = document.getElementsByTagName('script')[0];
+        s.parentNode.insertBefore(t, s);
+      })();
+    </script>
 
   </body>
 </html>
diff --git a/docs/extend.html b/docs/extend.html
index a81016e48d..308d07926b 100644
--- a/docs/extend.html
+++ b/docs/extend.html
@@ -25,6 +25,16 @@
     <link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
     <link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
 
+    <script type="text/javascript">
+      var _gaq = _gaq || [];
+      _gaq.push(['_setAccount', 'UA-146052-10']);
+      _gaq.push(['_trackPageview']);
+      (function() {
+        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+      })();
+    </script>
   </head>
 
   <body data-spy="scroll" data-target=".bs-docs-sidebar">
@@ -278,9 +288,25 @@
     <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/bootstrap-pagination.js"></script>
     <script src="assets/js/application.js"></script>
 
 
+    <!-- Analytics
+    ================================================== -->
+    <script>
+      var _gauges = _gauges || [];
+      (function() {
+        var t   = document.createElement('script');
+        t.type  = 'text/javascript';
+        t.async = true;
+        t.id    = 'gauges-tracker';
+        t.setAttribute('data-site-id', '4f0dc9fef5a1f55508000013');
+        t.src = '//secure.gaug.es/track.js';
+        var s = document.getElementsByTagName('script')[0];
+        s.parentNode.insertBefore(t, s);
+      })();
+    </script>
 
   </body>
 </html>
diff --git a/docs/getting-started.html b/docs/getting-started.html
index 5ef9026881..f95064bc59 100644
--- a/docs/getting-started.html
+++ b/docs/getting-started.html
@@ -25,6 +25,16 @@
     <link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
     <link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
 
+    <script type="text/javascript">
+      var _gaq = _gaq || [];
+      _gaq.push(['_setAccount', 'UA-146052-10']);
+      _gaq.push(['_trackPageview']);
+      (function() {
+        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+      })();
+    </script>
   </head>
 
   <body data-spy="scroll" data-target=".bs-docs-sidebar">
@@ -110,12 +120,12 @@
             <div class="span6">
               <h2>Download compiled</h2>
               <p><strong>Fastest way to get started:</strong> get the compiled and minified versions of our CSS, JS, and images. No docs or original source files.</p>
-              <p><a class="btn btn-large btn-primary" href="assets/bootstrap.zip" >Download Bootstrap</a></p>
+              <p><a class="btn btn-large btn-primary" href="assets/bootstrap.zip" onclick="_gaq.push(['_trackEvent', 'Getting started', 'Download', 'Download compiled']);">Download Bootstrap</a></p>
             </div>
             <div class="span6">
               <h2>Download source</h2>
               <p>Get the original files for all CSS and JavaScript, along with a local copy of the docs by downloading the latest version directly from GitHub.</p>
-              <p><a class="btn btn-large" href="https://github.com/twitter/bootstrap/zipball/master" >Download Bootstrap source</a></p>
+              <p><a class="btn btn-large" href="https://github.com/twitter/bootstrap/zipball/master" onclick="_gaq.push(['_trackEvent', 'Getting started', 'Download', 'Download source']);">Download Bootstrap source</a></p>
             </div>
           </div>
         </section>
@@ -276,8 +286,8 @@
             <h1>What next?</h1>
           </div>
           <p class="lead">Head to the docs for information, examples, and code snippets, or take the next leap and customize Bootstrap for any upcoming project.</p>
-          <a class="btn btn-large btn-primary" href="./scaffolding.html" >Visit the Bootstrap docs</a>
-          <a class="btn btn-large" href="./customize.html" style="margin-left: 5px;" >Customize Bootstrap</a>
+          <a class="btn btn-large btn-primary" href="./scaffolding.html" onclick="_gaq.push(['_trackEvent', 'Getting started', 'Next steps', 'Visit docs']);">Visit the Bootstrap docs</a>
+          <a class="btn btn-large" href="./customize.html" style="margin-left: 5px;" onclick="_gaq.push(['_trackEvent', 'Getting started', 'Next steps', 'Customize']);">Customize Bootstrap</a>
         </section>
 
 
@@ -327,9 +337,25 @@
     <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/bootstrap-pagination.js"></script>
     <script src="assets/js/application.js"></script>
 
 
+    <!-- Analytics
+    ================================================== -->
+    <script>
+      var _gauges = _gauges || [];
+      (function() {
+        var t   = document.createElement('script');
+        t.type  = 'text/javascript';
+        t.async = true;
+        t.id    = 'gauges-tracker';
+        t.setAttribute('data-site-id', '4f0dc9fef5a1f55508000013');
+        t.src = '//secure.gaug.es/track.js';
+        var s = document.getElementsByTagName('script')[0];
+        s.parentNode.insertBefore(t, s);
+      })();
+    </script>
 
   </body>
 </html>
diff --git a/docs/index.html b/docs/index.html
index c610399546..ead252cd6d 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -25,6 +25,16 @@
     <link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
     <link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
 
+    <script type="text/javascript">
+      var _gaq = _gaq || [];
+      _gaq.push(['_setAccount', 'UA-146052-10']);
+      _gaq.push(['_trackPageview']);
+      (function() {
+        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+      })();
+    </script>
   </head>
 
   <body data-spy="scroll" data-target=".bs-docs-sidebar">
@@ -73,10 +83,10 @@
   <div class="container">
     <h1>Bootstrap</h1>
     <p>Sleek, intuitive, and powerful front-end framework for faster and easier web development.</p>
-    <p><a href="assets/bootstrap.zip" class="btn btn-primary btn-large" >Download Bootstrap</a></p>
+    <p><a href="assets/bootstrap.zip" class="btn btn-primary btn-large" onclick="_gaq.push(['_trackEvent', 'Jumbotron actions', 'Download', 'Download 2.1.1']);">Download Bootstrap</a></p>
     <ul class="masthead-links">
-      <li><a href="http://github.com/twitter/bootstrap" >GitHub project</a></li>
-      <li><a href="./extend.html" >Extend</a></li>
+      <li><a href="http://github.com/twitter/bootstrap" onclick="_gaq.push(['_trackEvent', 'Jumbotron actions', 'Jumbotron links', 'GitHub project']);">GitHub project</a></li>
+      <li><a href="./extend.html" onclick="_gaq.push(['_trackEvent', 'Jumbotron actions', 'Jumbotron links', 'Extend']);">Extend</a></li>
       <li>Version 2.1.1</li>
     </ul>
   </div>
@@ -198,9 +208,25 @@
     <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/bootstrap-pagination.js"></script>
     <script src="assets/js/application.js"></script>
 
 
+    <!-- Analytics
+    ================================================== -->
+    <script>
+      var _gauges = _gauges || [];
+      (function() {
+        var t   = document.createElement('script');
+        t.type  = 'text/javascript';
+        t.async = true;
+        t.id    = 'gauges-tracker';
+        t.setAttribute('data-site-id', '4f0dc9fef5a1f55508000013');
+        t.src = '//secure.gaug.es/track.js';
+        var s = document.getElementsByTagName('script')[0];
+        s.parentNode.insertBefore(t, s);
+      })();
+    </script>
 
   </body>
 </html>
diff --git a/docs/javascript.html b/docs/javascript.html
index a530b21e0d..283f90ac77 100644
--- a/docs/javascript.html
+++ b/docs/javascript.html
@@ -25,6 +25,16 @@
     <link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
     <link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
 
+    <script type="text/javascript">
+      var _gaq = _gaq || [];
+      _gaq.push(['_setAccount', 'UA-146052-10']);
+      _gaq.push(['_trackPageview']);
+      (function() {
+        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+      })();
+    </script>
   </head>
 
   <body data-spy="scroll" data-target=".bs-docs-sidebar">
@@ -74,7 +84,7 @@
 <header class="jumbotron subhead">
   <div class="container">
     <h1>JavaScript for Bootstrap</h1>
-    <p class="lead">Bring Bootstrap's components to life&mdash;now with 13 custom jQuery plugins.
+    <p class="lead">Bring Bootstrap's components to life&mdash;now with 14 custom jQuery plugins.
   </div>
 </header>
 
@@ -99,6 +109,7 @@
           <li><a href="#carousel"><i class="icon-chevron-right"></i> Carousel</a></li>
           <li><a href="#typeahead"><i class="icon-chevron-right"></i> Typeahead</a></li>
           <li><a href="#affix"><i class="icon-chevron-right"></i> Affix</a></li>
+          <li><a href="#pagination"><i class="icon-chevron-right"></i> Pagination</a></li>
         </ul>
       </div>
       <div class="span9">
@@ -1677,6 +1688,113 @@ $('[data-spy="affix"]').each(function () {
           </table>
         </section>
 
+          <!-- Pagination
+          ================================================== -->
+          <section id="pagination">
+            <div class="page-header">
+              <h1>Pagination <small>bootstrap-pagination.js</small></h1>
+            </div>
+
+            <p>The pagination javascript component is a simple client-side feature that leverages existing bootstrap pagination components.</p>
+
+            <h2>Simple Example</h2>
+
+            <div class="bs-docs-example" style="background-color: #f5f5f5;">
+              <div class="pagination" id="pager" data-paged="#pagedContent" data-page-size="4"></div>
+
+              <ul id="pagedContent">
+                <li>Item 1</li>
+                <li>Item 2</li>
+                <li>Item 3</li>
+                <li>Item 4</li>
+                <li>Item 5</li>
+                <li>Item 6</li>
+                <li>Item 7</li>
+                <li>Item 8</li>
+                <li>Item 9</li>
+                <li>Item 10</li>
+                <li>Item 11</li>
+                <li>Item 12</li>
+              </ul>
+            </div>
+  <pre class="prettyprint linenums">
+&lt;div class=&quot;pagination&quot; id=&quot;pager&quot; data-paged=&quot;#pagedContent&quot; data-page-size=&quot;4&quot;&gt;&lt;/div&gt;
+
+&lt;ul id=&quot;pagedContent&quot;&gt;
+  &lt;li&gt;Item 1&lt;/li&gt;
+  &lt;li&gt;Item 2&lt;/li&gt;
+  &lt;li&gt;Item 3&lt;/li&gt;
+  &lt;li&gt;Item 4&lt;/li&gt;
+  &lt;li&gt;Item 5&lt;/li&gt;
+  &lt;li&gt;Item 6&lt;/li&gt;
+  &lt;li&gt;Item 7&lt;/li&gt;
+  &lt;li&gt;Item 8&lt;/li&gt;
+  &lt;li&gt;Item 9&lt;/li&gt;
+  &lt;li&gt;Item 10&lt;/li&gt;
+  &lt;li&gt;Item 11&lt;/li&gt;
+  &lt;li&gt;Item 12&lt;/li&gt;
+&lt;/ul&gt;
+  </pre>
+
+            <hr class="bs-docs-separator">
+
+            <h2>Usage</h2>
+
+            <h3>Via data attributes</h3>
+            <p>To enable client-side pagination on an existing pagination component, just add <code>data-paged=".cssSelector"</code> to target the container of child elements to page through.</p>
+
+            <pre class="prettyprint linenums">&lt;div class="pagination" data-paged="#pagedContent" data-page-size="4"&gt;&lt;/div&gt;</pre>
+
+            <h3>Via JavaScript</h3>
+            <p>Call the pagination plugin via JavaScript:</p>
+            <pre class="prettyprint linenums">$('#pager').pagination({paged: '#pagedContent'})</pre>
+
+            <h3>Methods</h3>
+            <h4>.pagination('next')</h4>
+            <p>Change the state of the pagination component to the next page (if available) as well as scroll the content forward.</p>
+
+            <h4>.pagination('prev')</h4>
+            <p>Change the state of the pagination component to the previous page (if available) as well as scroll the content backward.</p>
+
+          <h3>Options</h3>
+          <p>Options can be passed via data attributes or JavaScript. For data attributes, append the option name to <code>data-</code>, as in <code>data-page-size="4"</code>.</p>
+          <table class="table table-bordered table-striped">
+            <thead>
+             <tr>
+               <th style="width: 100px;">Name</th>
+               <th style="width: 100px;">type</th>
+               <th style="width: 50px;">default</th>
+               <th>description</th>
+             </tr>
+            </thead>
+            <tbody>
+             <tr>
+               <td>pageSize</td>
+               <td>number</td>
+               <td>5</td>
+               <td>The number of elements to display per page.</td>
+             </tr>
+             <tr>
+               <td>showArrows</td>
+               <td>boolean</td>
+               <td>true</td>
+               <td>When enabled, the next and previous arrows are displayed in the pagination component.</td>
+             </tr>
+             <tr>
+               <td>prevText</td>
+               <td>string</td>
+               <td>&laquo;</td>
+               <td>The text to show in the previous link when <b>showArrows</b> is enabled.</td>
+             </tr>
+             <tr>
+               <td>nextText</td>
+               <td>string</td>
+               <td>&raquo;</td>
+               <td>The text to show in the next link when <b>showArrows</b> is enabled.</td>
+             </tr>
+            </tbody>
+          </table>
+        </section>
 
 
       </div>
@@ -1723,9 +1841,25 @@ $('[data-spy="affix"]').each(function () {
     <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/bootstrap-pagination.js"></script>
     <script src="assets/js/application.js"></script>
 
 
+    <!-- Analytics
+    ================================================== -->
+    <script>
+      var _gauges = _gauges || [];
+      (function() {
+        var t   = document.createElement('script');
+        t.type  = 'text/javascript';
+        t.async = true;
+        t.id    = 'gauges-tracker';
+        t.setAttribute('data-site-id', '4f0dc9fef5a1f55508000013');
+        t.src = '//secure.gaug.es/track.js';
+        var s = document.getElementsByTagName('script')[0];
+        s.parentNode.insertBefore(t, s);
+      })();
+    </script>
 
   </body>
 </html>
diff --git a/docs/scaffolding.html b/docs/scaffolding.html
index 75cb761d53..22623ee565 100644
--- a/docs/scaffolding.html
+++ b/docs/scaffolding.html
@@ -25,6 +25,16 @@
     <link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
     <link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
 
+    <script type="text/javascript">
+      var _gaq = _gaq || [];
+      _gaq.push(['_setAccount', 'UA-146052-10']);
+      _gaq.push(['_trackPageview']);
+      (function() {
+        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+      })();
+    </script>
   </head>
 
   <body data-spy="scroll" data-target=".bs-docs-sidebar">
@@ -576,9 +586,25 @@
     <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/bootstrap-pagination.js"></script>
     <script src="assets/js/application.js"></script>
 
 
+    <!-- Analytics
+    ================================================== -->
+    <script>
+      var _gauges = _gauges || [];
+      (function() {
+        var t   = document.createElement('script');
+        t.type  = 'text/javascript';
+        t.async = true;
+        t.id    = 'gauges-tracker';
+        t.setAttribute('data-site-id', '4f0dc9fef5a1f55508000013');
+        t.src = '//secure.gaug.es/track.js';
+        var s = document.getElementsByTagName('script')[0];
+        s.parentNode.insertBefore(t, s);
+      })();
+    </script>
 
   </body>
 </html>
diff --git a/docs/templates/layout.mustache b/docs/templates/layout.mustache
index d463f441e8..acff56948c 100644
--- a/docs/templates/layout.mustache
+++ b/docs/templates/layout.mustache
@@ -122,6 +122,7 @@
     <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/bootstrap-pagination.js"></script>
     <script src="assets/js/application.js"></script>
 
 
diff --git a/docs/templates/pages/javascript.mustache b/docs/templates/pages/javascript.mustache
index 5f8883bdf7..8ad29b17c4 100644
--- a/docs/templates/pages/javascript.mustache
+++ b/docs/templates/pages/javascript.mustache
@@ -3,7 +3,7 @@
 <header class="jumbotron subhead">
   <div class="container">
     <h1>{{_i}}JavaScript for Bootstrap{{/i}}</h1>
-    <p class="lead">{{_i}}Bring Bootstrap's components to life&mdash;now with 13 custom jQuery plugins.{{/i}}
+    <p class="lead">{{_i}}Bring Bootstrap's components to life&mdash;now with 14 custom jQuery plugins.{{/i}}
   </div>
 </header>
 
@@ -28,6 +28,7 @@
           <li><a href="#carousel"><i class="icon-chevron-right"></i> {{_i}}Carousel{{/i}}</a></li>
           <li><a href="#typeahead"><i class="icon-chevron-right"></i> {{_i}}Typeahead{{/i}}</a></li>
           <li><a href="#affix"><i class="icon-chevron-right"></i> {{_i}}Affix{{/i}}</a></li>
+          <li><a href="#pagination"><i class="icon-chevron-right"></i> {{_i}}Pagination{{/i}}</a></li>
         </ul>
       </div>
       <div class="span9">
@@ -1607,6 +1608,113 @@ $('[data-spy="affix"]').each(function () {
           </table>
         </section>
 
+          <!-- Pagination
+          ================================================== -->
+          <section id="pagination">
+            <div class="page-header">
+              <h1>{{_i}}Pagination{{/i}} <small>bootstrap-pagination.js</small></h1>
+            </div>
+
+            <p>{{_i}}The pagination javascript component is a simple client-side feature that leverages existing bootstrap pagination components.{{/i}}</p>
+
+            <h2>{{_i}}Simple Example{{/i}}</h2>
+
+            <div class="bs-docs-example" style="background-color: #f5f5f5;">
+              <div class="pagination" id="pager" data-paged="#pagedContent" data-page-size="4"></div>
+
+              <ul id="pagedContent">
+                <li>Item 1</li>
+                <li>Item 2</li>
+                <li>Item 3</li>
+                <li>Item 4</li>
+                <li>Item 5</li>
+                <li>Item 6</li>
+                <li>Item 7</li>
+                <li>Item 8</li>
+                <li>Item 9</li>
+                <li>Item 10</li>
+                <li>Item 11</li>
+                <li>Item 12</li>
+              </ul>
+            </div>{{! /example }}
+  <pre class="prettyprint linenums">
+&lt;div class=&quot;pagination&quot; id=&quot;pager&quot; data-paged=&quot;#pagedContent&quot; data-page-size=&quot;4&quot;&gt;&lt;/div&gt;
+
+&lt;ul id=&quot;pagedContent&quot;&gt;
+  &lt;li&gt;Item 1&lt;/li&gt;
+  &lt;li&gt;Item 2&lt;/li&gt;
+  &lt;li&gt;Item 3&lt;/li&gt;
+  &lt;li&gt;Item 4&lt;/li&gt;
+  &lt;li&gt;Item 5&lt;/li&gt;
+  &lt;li&gt;Item 6&lt;/li&gt;
+  &lt;li&gt;Item 7&lt;/li&gt;
+  &lt;li&gt;Item 8&lt;/li&gt;
+  &lt;li&gt;Item 9&lt;/li&gt;
+  &lt;li&gt;Item 10&lt;/li&gt;
+  &lt;li&gt;Item 11&lt;/li&gt;
+  &lt;li&gt;Item 12&lt;/li&gt;
+&lt;/ul&gt;
+  </pre>
+
+            <hr class="bs-docs-separator">
+
+            <h2>{{_i}}Usage{{/i}}</h2>
+
+            <h3>{{_i}}Via data attributes{{/i}}</h3>
+            <p>{{_i}}To enable client-side pagination on an existing pagination component, just add <code>data-paged=".cssSelector"</code> to target the container of child elements to page through.{{/i}}</p>
+
+            <pre class="prettyprint linenums">&lt;div class="pagination" data-paged="#pagedContent" data-page-size="4"&gt;&lt;/div&gt;</pre>
+
+            <h3>{{_i}}Via JavaScript{{/i}}</h3>
+            <p>{{_i}}Call the pagination plugin via JavaScript:{{/i}}</p>
+            <pre class="prettyprint linenums">$('#pager').pagination({paged: '#pagedContent'})</pre>
+
+            <h3>{{_i}}Methods{{/i}}</h3>
+            <h4>.pagination('next')</h4>
+            <p>{{_i}}Change the state of the pagination component to the next page (if available) as well as scroll the content forward.{{/i}}</p>
+
+            <h4>.pagination('prev')</h4>
+            <p>{{_i}}Change the state of the pagination component to the previous page (if available) as well as scroll the content backward.{{/i}}</p>
+
+          <h3>{{_i}}Options{{/i}}</h3>
+          <p>{{_i}}Options can be passed via data attributes or JavaScript. For data attributes, append the option name to <code>data-</code>, as in <code>data-page-size="4"</code>.{{/i}}</p>
+          <table class="table table-bordered table-striped">
+            <thead>
+             <tr>
+               <th style="width: 100px;">{{_i}}Name{{/i}}</th>
+               <th style="width: 100px;">{{_i}}type{{/i}}</th>
+               <th style="width: 50px;">{{_i}}default{{/i}}</th>
+               <th>{{_i}}description{{/i}}</th>
+             </tr>
+            </thead>
+            <tbody>
+             <tr>
+               <td>{{_i}}pageSize{{/i}}</td>
+               <td>{{_i}}number{{/i}}</td>
+               <td>{{_i}}5{{/i}}</td>
+               <td>{{_i}}The number of elements to display per page.{{/i}}</td>
+             </tr>
+             <tr>
+               <td>{{_i}}showArrows{{/i}}</td>
+               <td>{{_i}}boolean{{/i}}</td>
+               <td>{{_i}}true{{/i}}</td>
+               <td>{{_i}}When enabled, the next and previous arrows are displayed in the pagination component.{{/i}}</td>
+             </tr>
+             <tr>
+               <td>{{_i}}prevText{{/i}}</td>
+               <td>{{_i}}string{{/i}}</td>
+               <td>{{_i}}&laquo;{{/i}}</td>
+               <td>{{_i}}The text to show in the previous link when <b>showArrows</b> is enabled.{{/i}}</td>
+             </tr>
+             <tr>
+               <td>{{_i}}nextText{{/i}}</td>
+               <td>{{_i}}string{{/i}}</td>
+               <td>{{_i}}&raquo;{{/i}}</td>
+               <td>{{_i}}The text to show in the next link when <b>showArrows</b> is enabled.{{/i}}</td>
+             </tr>
+            </tbody>
+          </table>
+        </section>
 
 
       </div>{{! /span9 }}
diff --git a/js/bootstrap-pagination.js b/js/bootstrap-pagination.js
new file mode 100644
index 0000000000..12e23a17ca
--- /dev/null
+++ b/js/bootstrap-pagination.js
@@ -0,0 +1,137 @@
+/* ===========================================================
+ * bootstrap-pagination.js v2.1.1
+ * http://twitter.github.com/bootstrap/javascript.html#pagintation
+ * ===========================================================
+ * 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 ;_;
+
+
+ /* PAGINATION PUBLIC CLASS DEFINITION
+  * =============================== */
+
+  var Pagination = function (element, options) {
+    this.$element = $(element)
+
+    this.options = $.extend({}, $.fn.pagination.defaults, options)
+    this.$paged  = $(this.options.paged).children()
+    this.total = this.$paged.length
+    this.pages = Math.ceil(this.total / this.options.pageSize)
+    this.currentPage = 0
+
+    if (this.pages > 1) {
+      this.$ul = this.$element.find('ul')
+      this.$ul = this.$ul.length ? this.$ul : $('<ul></ul>').appendTo(this.$element)
+
+      var pageClick = function(i){
+        return function(){
+          this.page(i)
+
+          return false
+        }
+      }
+
+      for (var i = 1; i < (this.pages + 1); i++) {
+        var li = $('<li><a href="#">' + i + '</a></li>').appendTo(this.$ul).click($.proxy(pageClick(i-1), this))
+      }
+
+      if (this.options.showArrows) {
+        this.$prev = $('<li><a href="#">' + this.options.prevText + '</a></li>').prependTo(this.$ul).click($.proxy(this.prev, this))
+        this.$next = $('<li><a href="#">' + this.options.nextText + '</a></li>').appendTo(this.$ul).click($.proxy(this.next, this))
+      }
+
+      this.page(this.currentPage)
+    }
+  }
+
+  Pagination.prototype = {
+
+    constructor: Pagination
+
+  , page: function(page) {
+      this.$paged.hide()
+
+      this.$ul.find('li').removeClass('active')
+
+      var index = page + (this.options.showArrows ? 1 : 0)
+
+      this.$ul.find('li:eq(' + index + ')').addClass('active')
+
+      var filtered = this.$paged.filter(':lt(' + ((page + 1) * this.options.pageSize) + ')')
+
+      if (page > 0) filtered = filtered.filter(':gt(' + ((page * this.options.pageSize) -1 ) + ')')
+
+      filtered.show()
+
+      if (this.options.showArrows) {
+        if ((page + 1) < this.pages) {
+          this.$next.removeClass('active')
+        } else {
+          this.$next.addClass('active')
+        }
+
+        if (page > 0) {
+          this.$prev.removeClass('active')
+        } else {
+          this.$prev.addClass('active')
+        }
+      }
+
+      this.currentPage = page
+    }
+
+  , next: function() {
+      if (this.currentPage < (this.pages - 1)) {
+        this.page(++this.currentPage)
+      }
+
+      return false
+    }
+
+  , prev: function() {
+      if (this.currentPage > 0) {
+        this.page(--this.currentPage)
+      }
+
+      return false
+    }
+  }
+
+ /* PAGINATION PLUGIN DEFINITION
+  * ======================= */
+
+  $.fn.pagination = function (option) {
+    return this.each(function () {
+      var $this = $(this)
+        , data = $this.data('pagination')
+      if (!data) $this.data('pagination', (data = new Pagination(this, option)))
+      if (typeof option == 'string') data[option]()
+    })
+  }
+
+  $.fn.pagination.Constructor = Pagination
+
+  $.fn.pagination.defaults = $.extend({} , $.fn.tooltip.defaults, {
+    pageSize: 3
+  , showArrows : true
+  , prevText: '&laquo'
+  , nextText: '&raquo'
+  })
+
+}(window.jQuery);
\ No newline at end of file
diff --git a/js/tests/index.html b/js/tests/index.html
index 976ca16872..290bead856 100644
--- a/js/tests/index.html
+++ b/js/tests/index.html
@@ -28,6 +28,7 @@
   <script src="../../js/bootstrap-popover.js"></script>
   <script src="../../js/bootstrap-typeahead.js"></script>
   <script src="../../js/bootstrap-affix.js"></script>
+  <script src="../../js/bootstrap-pagination.js"></script>
 
   <!-- unit tests -->
   <script src="unit/bootstrap-transition.js"></script>
@@ -43,6 +44,7 @@
   <script src="unit/bootstrap-popover.js"></script>
   <script src="unit/bootstrap-typeahead.js"></script>
   <script src="unit/bootstrap-affix.js"></script>
+  <script src="unit/bootstrap-pagination.js"></script>
 </head>
 <body>
   <div>
diff --git a/js/tests/unit/bootstrap-pagination.js b/js/tests/unit/bootstrap-pagination.js
new file mode 100644
index 0000000000..88642bbaff
--- /dev/null
+++ b/js/tests/unit/bootstrap-pagination.js
@@ -0,0 +1,212 @@
+$(function () {
+
+    module("bootstrap-pagination")
+
+      test("should be defined on jquery object", function () {
+        var div = $("<div class='pagination'></div>")
+        ok(div.pagination, 'pagination method is defined')
+      })
+
+      test("should return element", function () {
+        var div = $("<div class='pagination'></div>")
+        ok(div.pagination() == div, 'document.body returned')
+      })
+
+      test("should expose defaults var for settings", function () {
+        ok($.fn.pagination.defaults, 'default object exposed')
+      })
+
+      test("children is smaller than page size", function () {
+        var div = $("<div></div>")
+        for(var i = 0; i < 5; i++) {
+          div.append('<div></div>')
+        }
+
+        var pagination = $("<div class='pagination'></div>")
+
+        pagination.pagination({
+          paged: div,
+          pageSize: 10
+        })
+
+        var ul = pagination.find('ul')
+        ok(!ul.length, 'ul not created')
+      })
+
+      test("should build pages when children greater than page size", function () {
+        var div = $("<div></div>")
+        for(var i = 0; i < 5; i++) {
+          div.append('<div></div>')
+        }
+
+        var pagination = $("<div class='pagination'></div>")
+
+        pagination.pagination({
+          paged: div,
+          pageSize: 3
+        })
+
+        var ul = pagination.find('ul')
+        ok(ul.length, 'ul created')
+        equal(ul.find('li').length, 4, '2 pages created + arrows')
+      })
+
+      test("should build pages when children greater than page size without arrows", function () {
+        var div = $("<div></div>")
+        for(var i = 0; i < 5; i++) {
+          div.append('<div></div>')
+        }
+
+        var pagination = $("<div class='pagination'></div>")
+
+        pagination.pagination({
+          paged: div,
+          pageSize: 3,
+          showArrows: false
+        })
+
+        var ul = pagination.find('ul')
+        ok(ul.length, 'ul created')
+        equal(ul.find('li').length, 2, '2 pages created')
+      })
+
+      test("first page prev arrow disabled", function () {
+        var div = $("<div></div>")
+        for(var i = 0; i < 5; i++) {
+          div.append('<div></div>')
+        }
+
+        var pagination = $("<div class='pagination'></div>")
+
+        pagination.pagination({
+          paged: div,
+          pageSize: 3
+        })
+
+        ok(pagination.find('li').first().hasClass('active'), 'prev disabled')
+      })
+
+      test("second page prev arrow enabled", function () {
+        var div = $("<div></div>")
+        for(var i = 0; i < 5; i++) {
+          div.append('<div></div>')
+        }
+
+        var pagination = $("<div class='pagination'></div>")
+
+        pagination.pagination({
+          paged: div,
+          pageSize: 3
+        })
+
+        pagination.pagination('next')
+
+        ok(!pagination.find('li').first().hasClass('active'), 'prev enabled')
+      })
+
+      test("first page next arrow enable", function () {
+        var div = $("<div></div>")
+        for(var i = 0; i < 5; i++) {
+          div.append('<div></div>')
+        }
+
+        var pagination = $("<div class='pagination'></div>")
+
+        pagination.pagination({
+          paged: div,
+          pageSize: 3
+        })
+
+        ok(!pagination.find('li').last().hasClass('active'), 'next enabled')
+      })
+
+      test("last page next arrow enable", function () {
+        var div = $("<div></div>")
+        for(var i = 0; i < 5; i++) {
+          div.append('<div></div>')
+        }
+
+        var pagination = $("<div class='pagination'></div>")
+
+        pagination.pagination({
+          paged: div,
+          pageSize: 3
+        })
+
+        pagination.pagination('next')
+
+        ok(pagination.find('li').last().hasClass('active'), 'next disabled')
+      })
+
+      test("jump to first page prev arrow disabled", function () {
+        var div = $("<div></div>")
+        for(var i = 0; i < 5; i++) {
+          div.append('<div></div>')
+        }
+
+        var pagination = $("<div class='pagination'></div>")
+
+        pagination.pagination({
+          paged: div,
+          pageSize: 3
+        })
+
+        pagination.find('li:eq(1)').click()
+
+        ok(pagination.find('li').first().hasClass('active'), 'prev disabled')
+      })
+
+      test("jump to last page prev arrow enabled", function () {
+        var div = $("<div></div>")
+        for(var i = 0; i < 5; i++) {
+          div.append('<div></div>')
+        }
+
+        var pagination = $("<div class='pagination'></div>")
+
+        pagination.pagination({
+          paged: div,
+          pageSize: 3
+        })
+
+        pagination.find('li:eq(2)').click()
+
+        ok(!pagination.find('li').first().hasClass('active'), 'prev enabled')
+      })
+
+      test("jump to first page next arrow enabled", function () {
+        var div = $("<div></div>")
+        for(var i = 0; i < 5; i++) {
+          div.append('<div></div>')
+        }
+
+        var pagination = $("<div class='pagination'></div>")
+
+        pagination.pagination({
+          paged: div,
+          pageSize: 3
+        })
+
+        pagination.find('li:eq(1)').click()
+
+        ok(!pagination.find('li').last().hasClass('active'), 'next enable')
+      })
+
+      test("jump to last page next arrow disabled", function () {
+        var div = $("<div></div>")
+        for(var i = 0; i < 5; i++) {
+          div.append('<div></div>')
+        }
+
+        var pagination = $("<div class='pagination'></div>")
+
+        pagination.pagination({
+          paged: div,
+          pageSize: 3
+        })
+
+        pagination.find('li:eq(2)').click()
+
+        ok(pagination.find('li').last().hasClass('active'), 'next disabled')
+      })
+})
-- 
GitLab


From 71341369d5a18445814e24188f6f8f39989991b8 Mon Sep 17 00:00:00 2001
From: Paris Holley <mail@parisholley.com>
Date: Sat, 8 Sep 2012 10:56:20 -0500
Subject: [PATCH 2/7] ran another build

---
 docs/assets/js/bootstrap-pagination.js | 12 +---------
 docs/base-css.html                     | 25 -------------------
 docs/components.html                   | 25 -------------------
 docs/customize.html                    | 27 +--------------------
 docs/extend.html                       | 25 -------------------
 docs/getting-started.html              | 33 ++++----------------------
 docs/index.html                        | 31 +++---------------------
 docs/javascript.html                   | 25 -------------------
 docs/scaffolding.html                  | 25 -------------------
 9 files changed, 9 insertions(+), 219 deletions(-)

diff --git a/docs/assets/js/bootstrap-pagination.js b/docs/assets/js/bootstrap-pagination.js
index c961989c8f..12e23a17ca 100644
--- a/docs/assets/js/bootstrap-pagination.js
+++ b/docs/assets/js/bootstrap-pagination.js
@@ -128,20 +128,10 @@
   $.fn.pagination.Constructor = Pagination
 
   $.fn.pagination.defaults = $.extend({} , $.fn.tooltip.defaults, {
-    pageSize: 5
+    pageSize: 3
   , showArrows : true
   , prevText: '&laquo'
   , nextText: '&raquo'
   })
 
- /* PAGINATION DATA-API
-  * ================== */
-
-  $(window).on('load', function () {
-    $('[data-paged]').each(function () {
-      var $paginator = $(this)
-      $paginator.pagination($paginator.data())
-    })
-  })
-
 }(window.jQuery);
\ No newline at end of file
diff --git a/docs/base-css.html b/docs/base-css.html
index f8624d3843..1d0e76c509 100644
--- a/docs/base-css.html
+++ b/docs/base-css.html
@@ -25,16 +25,6 @@
     <link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
     <link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
 
-    <script type="text/javascript">
-      var _gaq = _gaq || [];
-      _gaq.push(['_setAccount', 'UA-146052-10']);
-      _gaq.push(['_trackPageview']);
-      (function() {
-        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
-        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
-        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
-      })();
-    </script>
   </head>
 
   <body data-spy="scroll" data-target=".bs-docs-sidebar">
@@ -1986,21 +1976,6 @@ For example, &lt;code&gt;&lt;section&gt;&lt;/code&gt; should be wrapped as inlin
     <script src="assets/js/application.js"></script>
 
 
-    <!-- Analytics
-    ================================================== -->
-    <script>
-      var _gauges = _gauges || [];
-      (function() {
-        var t   = document.createElement('script');
-        t.type  = 'text/javascript';
-        t.async = true;
-        t.id    = 'gauges-tracker';
-        t.setAttribute('data-site-id', '4f0dc9fef5a1f55508000013');
-        t.src = '//secure.gaug.es/track.js';
-        var s = document.getElementsByTagName('script')[0];
-        s.parentNode.insertBefore(t, s);
-      })();
-    </script>
 
   </body>
 </html>
diff --git a/docs/components.html b/docs/components.html
index 8bee430a7a..85c1a6138c 100644
--- a/docs/components.html
+++ b/docs/components.html
@@ -25,16 +25,6 @@
     <link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
     <link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
 
-    <script type="text/javascript">
-      var _gaq = _gaq || [];
-      _gaq.push(['_setAccount', 'UA-146052-10']);
-      _gaq.push(['_trackPageview']);
-      (function() {
-        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
-        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
-        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
-      })();
-    </script>
   </head>
 
   <body data-spy="scroll" data-target=".bs-docs-sidebar">
@@ -2344,21 +2334,6 @@ class="clearfix"
     <script src="assets/js/application.js"></script>
 
 
-    <!-- Analytics
-    ================================================== -->
-    <script>
-      var _gauges = _gauges || [];
-      (function() {
-        var t   = document.createElement('script');
-        t.type  = 'text/javascript';
-        t.async = true;
-        t.id    = 'gauges-tracker';
-        t.setAttribute('data-site-id', '4f0dc9fef5a1f55508000013');
-        t.src = '//secure.gaug.es/track.js';
-        var s = document.getElementsByTagName('script')[0];
-        s.parentNode.insertBefore(t, s);
-      })();
-    </script>
 
   </body>
 </html>
diff --git a/docs/customize.html b/docs/customize.html
index 04c91a23b6..440343f830 100644
--- a/docs/customize.html
+++ b/docs/customize.html
@@ -25,16 +25,6 @@
     <link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
     <link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
 
-    <script type="text/javascript">
-      var _gaq = _gaq || [];
-      _gaq.push(['_setAccount', 'UA-146052-10']);
-      _gaq.push(['_trackPageview']);
-      (function() {
-        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
-        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
-        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
-      })();
-    </script>
   </head>
 
   <body data-spy="scroll" data-target=".bs-docs-sidebar">
@@ -429,7 +419,7 @@
               </h1>
             </div>
             <div class="download-btn">
-              <a class="btn btn-primary" href="#" onclick="_gaq.push(['_trackEvent', 'Customize', 'Download', 'Customize and Download']);">Customize and Download</a>
+              <a class="btn btn-primary" href="#" >Customize and Download</a>
               <h4>What's included?</h4>
               <p>Downloads include compiled CSS, compiled and minified CSS, and compiled jQuery plugins, all nicely packed up into a zipball for your convenience.</p>
             </div>
@@ -486,21 +476,6 @@
     <script src="assets/js/application.js"></script>
 
 
-    <!-- Analytics
-    ================================================== -->
-    <script>
-      var _gauges = _gauges || [];
-      (function() {
-        var t   = document.createElement('script');
-        t.type  = 'text/javascript';
-        t.async = true;
-        t.id    = 'gauges-tracker';
-        t.setAttribute('data-site-id', '4f0dc9fef5a1f55508000013');
-        t.src = '//secure.gaug.es/track.js';
-        var s = document.getElementsByTagName('script')[0];
-        s.parentNode.insertBefore(t, s);
-      })();
-    </script>
 
   </body>
 </html>
diff --git a/docs/extend.html b/docs/extend.html
index 308d07926b..11e7ce1eb7 100644
--- a/docs/extend.html
+++ b/docs/extend.html
@@ -25,16 +25,6 @@
     <link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
     <link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
 
-    <script type="text/javascript">
-      var _gaq = _gaq || [];
-      _gaq.push(['_setAccount', 'UA-146052-10']);
-      _gaq.push(['_trackPageview']);
-      (function() {
-        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
-        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
-        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
-      })();
-    </script>
   </head>
 
   <body data-spy="scroll" data-target=".bs-docs-sidebar">
@@ -292,21 +282,6 @@
     <script src="assets/js/application.js"></script>
 
 
-    <!-- Analytics
-    ================================================== -->
-    <script>
-      var _gauges = _gauges || [];
-      (function() {
-        var t   = document.createElement('script');
-        t.type  = 'text/javascript';
-        t.async = true;
-        t.id    = 'gauges-tracker';
-        t.setAttribute('data-site-id', '4f0dc9fef5a1f55508000013');
-        t.src = '//secure.gaug.es/track.js';
-        var s = document.getElementsByTagName('script')[0];
-        s.parentNode.insertBefore(t, s);
-      })();
-    </script>
 
   </body>
 </html>
diff --git a/docs/getting-started.html b/docs/getting-started.html
index f95064bc59..74a422cdb5 100644
--- a/docs/getting-started.html
+++ b/docs/getting-started.html
@@ -25,16 +25,6 @@
     <link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
     <link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
 
-    <script type="text/javascript">
-      var _gaq = _gaq || [];
-      _gaq.push(['_setAccount', 'UA-146052-10']);
-      _gaq.push(['_trackPageview']);
-      (function() {
-        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
-        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
-        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
-      })();
-    </script>
   </head>
 
   <body data-spy="scroll" data-target=".bs-docs-sidebar">
@@ -120,12 +110,12 @@
             <div class="span6">
               <h2>Download compiled</h2>
               <p><strong>Fastest way to get started:</strong> get the compiled and minified versions of our CSS, JS, and images. No docs or original source files.</p>
-              <p><a class="btn btn-large btn-primary" href="assets/bootstrap.zip" onclick="_gaq.push(['_trackEvent', 'Getting started', 'Download', 'Download compiled']);">Download Bootstrap</a></p>
+              <p><a class="btn btn-large btn-primary" href="assets/bootstrap.zip" >Download Bootstrap</a></p>
             </div>
             <div class="span6">
               <h2>Download source</h2>
               <p>Get the original files for all CSS and JavaScript, along with a local copy of the docs by downloading the latest version directly from GitHub.</p>
-              <p><a class="btn btn-large" href="https://github.com/twitter/bootstrap/zipball/master" onclick="_gaq.push(['_trackEvent', 'Getting started', 'Download', 'Download source']);">Download Bootstrap source</a></p>
+              <p><a class="btn btn-large" href="https://github.com/twitter/bootstrap/zipball/master" >Download Bootstrap source</a></p>
             </div>
           </div>
         </section>
@@ -286,8 +276,8 @@
             <h1>What next?</h1>
           </div>
           <p class="lead">Head to the docs for information, examples, and code snippets, or take the next leap and customize Bootstrap for any upcoming project.</p>
-          <a class="btn btn-large btn-primary" href="./scaffolding.html" onclick="_gaq.push(['_trackEvent', 'Getting started', 'Next steps', 'Visit docs']);">Visit the Bootstrap docs</a>
-          <a class="btn btn-large" href="./customize.html" style="margin-left: 5px;" onclick="_gaq.push(['_trackEvent', 'Getting started', 'Next steps', 'Customize']);">Customize Bootstrap</a>
+          <a class="btn btn-large btn-primary" href="./scaffolding.html" >Visit the Bootstrap docs</a>
+          <a class="btn btn-large" href="./customize.html" style="margin-left: 5px;" >Customize Bootstrap</a>
         </section>
 
 
@@ -341,21 +331,6 @@
     <script src="assets/js/application.js"></script>
 
 
-    <!-- Analytics
-    ================================================== -->
-    <script>
-      var _gauges = _gauges || [];
-      (function() {
-        var t   = document.createElement('script');
-        t.type  = 'text/javascript';
-        t.async = true;
-        t.id    = 'gauges-tracker';
-        t.setAttribute('data-site-id', '4f0dc9fef5a1f55508000013');
-        t.src = '//secure.gaug.es/track.js';
-        var s = document.getElementsByTagName('script')[0];
-        s.parentNode.insertBefore(t, s);
-      })();
-    </script>
 
   </body>
 </html>
diff --git a/docs/index.html b/docs/index.html
index ead252cd6d..53709a4c80 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -25,16 +25,6 @@
     <link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
     <link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
 
-    <script type="text/javascript">
-      var _gaq = _gaq || [];
-      _gaq.push(['_setAccount', 'UA-146052-10']);
-      _gaq.push(['_trackPageview']);
-      (function() {
-        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
-        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
-        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
-      })();
-    </script>
   </head>
 
   <body data-spy="scroll" data-target=".bs-docs-sidebar">
@@ -83,10 +73,10 @@
   <div class="container">
     <h1>Bootstrap</h1>
     <p>Sleek, intuitive, and powerful front-end framework for faster and easier web development.</p>
-    <p><a href="assets/bootstrap.zip" class="btn btn-primary btn-large" onclick="_gaq.push(['_trackEvent', 'Jumbotron actions', 'Download', 'Download 2.1.1']);">Download Bootstrap</a></p>
+    <p><a href="assets/bootstrap.zip" class="btn btn-primary btn-large" >Download Bootstrap</a></p>
     <ul class="masthead-links">
-      <li><a href="http://github.com/twitter/bootstrap" onclick="_gaq.push(['_trackEvent', 'Jumbotron actions', 'Jumbotron links', 'GitHub project']);">GitHub project</a></li>
-      <li><a href="./extend.html" onclick="_gaq.push(['_trackEvent', 'Jumbotron actions', 'Jumbotron links', 'Extend']);">Extend</a></li>
+      <li><a href="http://github.com/twitter/bootstrap" >GitHub project</a></li>
+      <li><a href="./extend.html" >Extend</a></li>
       <li>Version 2.1.1</li>
     </ul>
   </div>
@@ -212,21 +202,6 @@
     <script src="assets/js/application.js"></script>
 
 
-    <!-- Analytics
-    ================================================== -->
-    <script>
-      var _gauges = _gauges || [];
-      (function() {
-        var t   = document.createElement('script');
-        t.type  = 'text/javascript';
-        t.async = true;
-        t.id    = 'gauges-tracker';
-        t.setAttribute('data-site-id', '4f0dc9fef5a1f55508000013');
-        t.src = '//secure.gaug.es/track.js';
-        var s = document.getElementsByTagName('script')[0];
-        s.parentNode.insertBefore(t, s);
-      })();
-    </script>
 
   </body>
 </html>
diff --git a/docs/javascript.html b/docs/javascript.html
index 283f90ac77..c3831a5b5c 100644
--- a/docs/javascript.html
+++ b/docs/javascript.html
@@ -25,16 +25,6 @@
     <link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
     <link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
 
-    <script type="text/javascript">
-      var _gaq = _gaq || [];
-      _gaq.push(['_setAccount', 'UA-146052-10']);
-      _gaq.push(['_trackPageview']);
-      (function() {
-        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
-        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
-        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
-      })();
-    </script>
   </head>
 
   <body data-spy="scroll" data-target=".bs-docs-sidebar">
@@ -1845,21 +1835,6 @@ $('[data-spy="affix"]').each(function () {
     <script src="assets/js/application.js"></script>
 
 
-    <!-- Analytics
-    ================================================== -->
-    <script>
-      var _gauges = _gauges || [];
-      (function() {
-        var t   = document.createElement('script');
-        t.type  = 'text/javascript';
-        t.async = true;
-        t.id    = 'gauges-tracker';
-        t.setAttribute('data-site-id', '4f0dc9fef5a1f55508000013');
-        t.src = '//secure.gaug.es/track.js';
-        var s = document.getElementsByTagName('script')[0];
-        s.parentNode.insertBefore(t, s);
-      })();
-    </script>
 
   </body>
 </html>
diff --git a/docs/scaffolding.html b/docs/scaffolding.html
index 22623ee565..0b76134c5e 100644
--- a/docs/scaffolding.html
+++ b/docs/scaffolding.html
@@ -25,16 +25,6 @@
     <link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
     <link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
 
-    <script type="text/javascript">
-      var _gaq = _gaq || [];
-      _gaq.push(['_setAccount', 'UA-146052-10']);
-      _gaq.push(['_trackPageview']);
-      (function() {
-        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
-        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
-        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
-      })();
-    </script>
   </head>
 
   <body data-spy="scroll" data-target=".bs-docs-sidebar">
@@ -590,21 +580,6 @@
     <script src="assets/js/application.js"></script>
 
 
-    <!-- Analytics
-    ================================================== -->
-    <script>
-      var _gauges = _gauges || [];
-      (function() {
-        var t   = document.createElement('script');
-        t.type  = 'text/javascript';
-        t.async = true;
-        t.id    = 'gauges-tracker';
-        t.setAttribute('data-site-id', '4f0dc9fef5a1f55508000013');
-        t.src = '//secure.gaug.es/track.js';
-        var s = document.getElementsByTagName('script')[0];
-        s.parentNode.insertBefore(t, s);
-      })();
-    </script>
 
   </body>
 </html>
-- 
GitLab


From a3a88f1819dc9e47e69659dbac24ec8bed3f7766 Mon Sep 17 00:00:00 2001
From: Paris Holley <mail@parisholley.com>
Date: Sat, 8 Sep 2012 11:24:33 -0500
Subject: [PATCH 3/7] hide/show pagination based on need, ability to refresh if
 dynamicly added content

---
 js/bootstrap-pagination.js            | 64 ++++++++++++++++-----------
 js/tests/unit/bootstrap-pagination.js | 56 +++++++++++++++++++++++
 2 files changed, 93 insertions(+), 27 deletions(-)

diff --git a/js/bootstrap-pagination.js b/js/bootstrap-pagination.js
index 12e23a17ca..8b02c651cc 100644
--- a/js/bootstrap-pagination.js
+++ b/js/bootstrap-pagination.js
@@ -30,34 +30,9 @@
     this.$element = $(element)
 
     this.options = $.extend({}, $.fn.pagination.defaults, options)
-    this.$paged  = $(this.options.paged).children()
-    this.total = this.$paged.length
-    this.pages = Math.ceil(this.total / this.options.pageSize)
     this.currentPage = 0
-
-    if (this.pages > 1) {
-      this.$ul = this.$element.find('ul')
-      this.$ul = this.$ul.length ? this.$ul : $('<ul></ul>').appendTo(this.$element)
-
-      var pageClick = function(i){
-        return function(){
-          this.page(i)
-
-          return false
-        }
-      }
-
-      for (var i = 1; i < (this.pages + 1); i++) {
-        var li = $('<li><a href="#">' + i + '</a></li>').appendTo(this.$ul).click($.proxy(pageClick(i-1), this))
-      }
-
-      if (this.options.showArrows) {
-        this.$prev = $('<li><a href="#">' + this.options.prevText + '</a></li>').prependTo(this.$ul).click($.proxy(this.prev, this))
-        this.$next = $('<li><a href="#">' + this.options.nextText + '</a></li>').appendTo(this.$ul).click($.proxy(this.next, this))
-      }
-
-      this.page(this.currentPage)
-    }
+    
+    this.refresh()
   }
 
   Pagination.prototype = {
@@ -111,6 +86,41 @@
 
       return false
     }
+
+  , refresh: function(){
+      this.$paged  = $(this.options.paged).children()
+      this.total = this.$paged.length
+      this.pages = Math.ceil(this.total / this.options.pageSize)
+
+      this.$ul = this.$element.find('ul').empty()
+
+      if (this.pages > 1) {
+        this.$ul = this.$ul.length ? this.$ul : $('<ul></ul>').appendTo(this.$element)
+
+        var pageClick = function(i){
+          return function(){
+            this.page(i)
+
+            return false
+          }
+        }
+
+        for (var i = 1; i < (this.pages + 1); i++) {
+          var li = $('<li><a href="#">' + i + '</a></li>').appendTo(this.$ul).click($.proxy(pageClick(i-1), this))
+        }
+
+        if (this.options.showArrows) {
+          this.$prev = $('<li><a href="#">' + this.options.prevText + '</a></li>').prependTo(this.$ul).click($.proxy(this.prev, this))
+          this.$next = $('<li><a href="#">' + this.options.nextText + '</a></li>').appendTo(this.$ul).click($.proxy(this.next, this))
+        }
+
+        this.page(this.currentPage)
+
+        this.$element.show()
+      }else{
+        this.$element.hide()
+      }
+    }
   }
 
  /* PAGINATION PLUGIN DEFINITION
diff --git a/js/tests/unit/bootstrap-pagination.js b/js/tests/unit/bootstrap-pagination.js
index 88642bbaff..38e37bc4c9 100644
--- a/js/tests/unit/bootstrap-pagination.js
+++ b/js/tests/unit/bootstrap-pagination.js
@@ -209,4 +209,60 @@ $(function () {
 
         ok(pagination.find('li').last().hasClass('active'), 'next disabled')
       })
+
+      test("refresh after adding to hit page size", function () {
+        var div = $("<div></div>")
+        for(var i = 0; i < 4; i++) {
+          div.append('<div></div>')
+        }
+
+        var pagination = $("<div class='pagination'></div>").appendTo($('body'))
+
+        pagination.pagination({
+          paged: div,
+          showArrows: false,
+          pageSize: 4
+        })
+
+        equal(pagination.find('li').length, 0)
+
+        ok(!pagination.is(':visible'))
+
+        div.append('<div></div>')
+
+        pagination.pagination('refresh')
+
+        ok(pagination.is(':visible'))
+
+        equal(pagination.find('li').length, 2)
+
+        pagination.remove()
+      })      
+
+      test("refresh after removing to hit page size", function () {
+        var div = $("<div></div>")
+        for(var i = 0; i < 5; i++) {
+          div.append('<div></div>')
+        }
+
+        var pagination = $("<div class='pagination'></div>").appendTo($('body'))
+
+        pagination.pagination({
+          paged: div,
+          showArrows: false,
+          pageSize: 4
+        })
+
+        ok(pagination.is(':visible'))
+        equal(pagination.find('li').length, 2)
+
+        div.children().last().remove()
+
+        pagination.pagination('refresh')
+
+        ok(!pagination.is(':visible'))
+        equal(pagination.find('li').length, 0)
+
+        pagination.remove()
+      })      
 })
-- 
GitLab


From 0cdad3b689ec66b450aa26313fc8f4441af44cda Mon Sep 17 00:00:00 2001
From: Paris Holley <mail@parisholley.com>
Date: Sat, 8 Sep 2012 11:49:36 -0500
Subject: [PATCH 4/7] ignore commands if pagination hasn't successfully ran yet

---
 docs/assets/js/bootstrap-pagination.js | 68 +++++++++++++++-----------
 js/bootstrap-pagination.js             |  4 +-
 js/tests/unit/bootstrap-pagination.js  | 27 +++++++++-
 3 files changed, 67 insertions(+), 32 deletions(-)

diff --git a/docs/assets/js/bootstrap-pagination.js b/docs/assets/js/bootstrap-pagination.js
index 12e23a17ca..52eff3f4ba 100644
--- a/docs/assets/js/bootstrap-pagination.js
+++ b/docs/assets/js/bootstrap-pagination.js
@@ -30,34 +30,9 @@
     this.$element = $(element)
 
     this.options = $.extend({}, $.fn.pagination.defaults, options)
-    this.$paged  = $(this.options.paged).children()
-    this.total = this.$paged.length
-    this.pages = Math.ceil(this.total / this.options.pageSize)
     this.currentPage = 0
-
-    if (this.pages > 1) {
-      this.$ul = this.$element.find('ul')
-      this.$ul = this.$ul.length ? this.$ul : $('<ul></ul>').appendTo(this.$element)
-
-      var pageClick = function(i){
-        return function(){
-          this.page(i)
-
-          return false
-        }
-      }
-
-      for (var i = 1; i < (this.pages + 1); i++) {
-        var li = $('<li><a href="#">' + i + '</a></li>').appendTo(this.$ul).click($.proxy(pageClick(i-1), this))
-      }
-
-      if (this.options.showArrows) {
-        this.$prev = $('<li><a href="#">' + this.options.prevText + '</a></li>').prependTo(this.$ul).click($.proxy(this.prev, this))
-        this.$next = $('<li><a href="#">' + this.options.nextText + '</a></li>').appendTo(this.$ul).click($.proxy(this.next, this))
-      }
-
-      this.page(this.currentPage)
-    }
+    
+    this.refresh()
   }
 
   Pagination.prototype = {
@@ -111,6 +86,41 @@
 
       return false
     }
+
+  , refresh: function(){
+      this.$paged  = $(this.options.paged).children()
+      this.total = this.$paged.length
+      this.pages = Math.ceil(this.total / this.options.pageSize)
+
+      this.$ul = this.$element.find('ul').empty()
+
+      if (this.pages > 1) {
+        this.$ul = this.$ul.length ? this.$ul : $('<ul></ul>').appendTo(this.$element)
+
+        var pageClick = function(i){
+          return function(){
+            this.page(i)
+
+            return false
+          }
+        }
+
+        for (var i = 1; i < (this.pages + 1); i++) {
+          var li = $('<li><a href="#">' + i + '</a></li>').appendTo(this.$ul).click($.proxy(pageClick(i-1), this))
+        }
+
+        if (this.options.showArrows) {
+          this.$prev = $('<li><a href="#">' + this.options.prevText + '</a></li>').prependTo(this.$ul).click($.proxy(this.prev, this))
+          this.$next = $('<li><a href="#">' + this.options.nextText + '</a></li>').appendTo(this.$ul).click($.proxy(this.next, this))
+        }
+
+        this.page(this.currentPage)
+
+        this.$element.show()
+      }else{
+        this.$element.hide()
+      }
+    }
   }
 
  /* PAGINATION PLUGIN DEFINITION
@@ -120,8 +130,8 @@
     return this.each(function () {
       var $this = $(this)
         , data = $this.data('pagination')
-      if (!data) $this.data('pagination', (data = new Pagination(this, option)))
-      if (typeof option == 'string') data[option]()
+      if (!data && option.paged) $this.data('pagination', (data = new Pagination(this, option)))
+      if (data && typeof option == 'string') data[option]()
     })
   }
 
diff --git a/js/bootstrap-pagination.js b/js/bootstrap-pagination.js
index 8b02c651cc..52eff3f4ba 100644
--- a/js/bootstrap-pagination.js
+++ b/js/bootstrap-pagination.js
@@ -130,8 +130,8 @@
     return this.each(function () {
       var $this = $(this)
         , data = $this.data('pagination')
-      if (!data) $this.data('pagination', (data = new Pagination(this, option)))
-      if (typeof option == 'string') data[option]()
+      if (!data && option.paged) $this.data('pagination', (data = new Pagination(this, option)))
+      if (data && typeof option == 'string') data[option]()
     })
   }
 
diff --git a/js/tests/unit/bootstrap-pagination.js b/js/tests/unit/bootstrap-pagination.js
index 38e37bc4c9..f1ff33f00b 100644
--- a/js/tests/unit/bootstrap-pagination.js
+++ b/js/tests/unit/bootstrap-pagination.js
@@ -9,7 +9,7 @@ $(function () {
 
       test("should return element", function () {
         var div = $("<div class='pagination'></div>")
-        ok(div.pagination() == div, 'document.body returned')
+        ok(div.pagination({paged: $('<div></div>')}) == div, 'document.body returned')
       })
 
       test("should expose defaults var for settings", function () {
@@ -239,6 +239,31 @@ $(function () {
         pagination.remove()
       })      
 
+      test("ignore commands until initialized", function () {
+        var div = $("<div></div>")
+        for(var i = 0; i < 3; i++) {
+          div.append('<div></div>')
+        }
+
+        var pagination = $("<div class='pagination'></div>").appendTo($('body'))
+
+        ok(pagination.is(':visible'))
+
+        pagination.pagination('refresh')
+
+        ok(pagination.is(':visible'))
+
+        pagination.pagination({
+          paged: div,
+          showArrows: false,
+          pageSize: 4
+        })
+
+        ok(!pagination.is(':visible'))
+
+        pagination.remove()
+      })  
+
       test("refresh after removing to hit page size", function () {
         var div = $("<div></div>")
         for(var i = 0; i < 5; i++) {
-- 
GitLab


From c2d77927fc65b29c0932db92dc8c2aa3d0bae453 Mon Sep 17 00:00:00 2001
From: Paris Holley <mail@parisholley.com>
Date: Sat, 8 Sep 2012 12:42:10 -0500
Subject: [PATCH 5/7] fixed paged content when navigation is hidden but not all
 of the paged content is revealed

---
 docs/assets/js/bootstrap-pagination.js | 1 +
 js/bootstrap-pagination.js             | 1 +
 js/tests/unit/bootstrap-pagination.js  | 7 +++++--
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/docs/assets/js/bootstrap-pagination.js b/docs/assets/js/bootstrap-pagination.js
index 52eff3f4ba..e0cfe112c8 100644
--- a/docs/assets/js/bootstrap-pagination.js
+++ b/docs/assets/js/bootstrap-pagination.js
@@ -119,6 +119,7 @@
         this.$element.show()
       }else{
         this.$element.hide()
+        this.$paged.show()
       }
     }
   }
diff --git a/js/bootstrap-pagination.js b/js/bootstrap-pagination.js
index 52eff3f4ba..e0cfe112c8 100644
--- a/js/bootstrap-pagination.js
+++ b/js/bootstrap-pagination.js
@@ -119,6 +119,7 @@
         this.$element.show()
       }else{
         this.$element.hide()
+        this.$paged.show()
       }
     }
   }
diff --git a/js/tests/unit/bootstrap-pagination.js b/js/tests/unit/bootstrap-pagination.js
index f1ff33f00b..de7d1b0626 100644
--- a/js/tests/unit/bootstrap-pagination.js
+++ b/js/tests/unit/bootstrap-pagination.js
@@ -265,7 +265,7 @@ $(function () {
       })  
 
       test("refresh after removing to hit page size", function () {
-        var div = $("<div></div>")
+        var div = $("<div></div>").appendTo($('body'))
         for(var i = 0; i < 5; i++) {
           div.append('<div></div>')
         }
@@ -280,14 +280,17 @@ $(function () {
 
         ok(pagination.is(':visible'))
         equal(pagination.find('li').length, 2)
+        equal(div.find(':visible').length, 4)
 
-        div.children().last().remove()
+        div.children().first().remove()
 
         pagination.pagination('refresh')
 
         ok(!pagination.is(':visible'))
         equal(pagination.find('li').length, 0)
+        equal(div.find(':visible').length, 4)
 
         pagination.remove()
+        div.remove()
       })      
 })
-- 
GitLab


From 7be70d8690bebb1390c48e4d3cc8e2cf6b4b4611 Mon Sep 17 00:00:00 2001
From: Paris Holley <mail@parisholley.com>
Date: Fri, 28 Sep 2012 09:37:07 -0500
Subject: [PATCH 6/7] added data based config

---
 docs/assets/js/bootstrap-pagination.js | 10 ++++++++++
 js/bootstrap-pagination.js             | 10 ++++++++++
 2 files changed, 20 insertions(+)

diff --git a/docs/assets/js/bootstrap-pagination.js b/docs/assets/js/bootstrap-pagination.js
index e0cfe112c8..b48dc8fcbc 100644
--- a/docs/assets/js/bootstrap-pagination.js
+++ b/docs/assets/js/bootstrap-pagination.js
@@ -145,4 +145,14 @@
   , nextText: '&raquo'
   })
 
+  /* PAGINATION DATA-API
+  * ==================== */
+
+  $(function () {
+    $('[data-paged]').each(function(){
+      var $pager = $(this);
+      $pager.pagination($pager.data());
+    });
+  })
+  
 }(window.jQuery);
\ No newline at end of file
diff --git a/js/bootstrap-pagination.js b/js/bootstrap-pagination.js
index e0cfe112c8..b48dc8fcbc 100644
--- a/js/bootstrap-pagination.js
+++ b/js/bootstrap-pagination.js
@@ -145,4 +145,14 @@
   , nextText: '&raquo'
   })
 
+  /* PAGINATION DATA-API
+  * ==================== */
+
+  $(function () {
+    $('[data-paged]').each(function(){
+      var $pager = $(this);
+      $pager.pagination($pager.data());
+    });
+  })
+  
 }(window.jQuery);
\ No newline at end of file
-- 
GitLab


From 586b13a574b1d5ef7b42798acbf9bec0793c1cdd Mon Sep 17 00:00:00 2001
From: Paris Holley <pholley@Pariss-MacBook-Pro.local>
Date: Thu, 18 Oct 2012 11:57:08 -0500
Subject: [PATCH 7/7] removed unwanted tooltip depend

---
 js/bootstrap-pagination.js | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/js/bootstrap-pagination.js b/js/bootstrap-pagination.js
index b48dc8fcbc..02555effaa 100644
--- a/js/bootstrap-pagination.js
+++ b/js/bootstrap-pagination.js
@@ -138,12 +138,12 @@
 
   $.fn.pagination.Constructor = Pagination
 
-  $.fn.pagination.defaults = $.extend({} , $.fn.tooltip.defaults, {
+  $.fn.pagination.defaults = {
     pageSize: 3
   , showArrows : true
   , prevText: '&laquo'
   , nextText: '&raquo'
-  })
+  }
 
   /* PAGINATION DATA-API
   * ==================== */
@@ -155,4 +155,4 @@
     });
   })
   
-}(window.jQuery);
\ No newline at end of file
+}(window.jQuery);
-- 
GitLab