123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>Snippet - Bootsnipp.com</title>
- <link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet">
- <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
- <script type="text/javascript" src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
-
- <style>
- .table-responsive {height:500px;}
- </style>
-
- <script type="text/javascript">
- $.fn.pageMe = function(opts){
- var $this = this,
- defaults = {
- perPage: 7,
- showPrevNext: false,
- hidePageNumbers: false
- },
- settings = $.extend(defaults, opts);
-
- var listElement = $this;
- var perPage = settings.perPage;
- var children = listElement.children();
- var pager = $('.pager');
-
- if (typeof settings.childSelector!="undefined") {
- children = listElement.find(settings.childSelector);
- }
-
- if (typeof settings.pagerSelector!="undefined") {
- pager = $(settings.pagerSelector);
- }
-
- var numItems = children.size();
- var numPages = Math.ceil(numItems/perPage);
- pager.data("curr",0);
-
- if (settings.showPrevNext){
- $('<li><a href="#" class="prev_link">«</a></li>').appendTo(pager);
- }
-
- var curr = 0;
- while(numPages > curr && (settings.hidePageNumbers==false)){
- $('<li><a href="#" class="page_link">'+(curr+1)+'</a></li>').appendTo(pager);
- curr++;
- }
-
- if (settings.showPrevNext){
- $('<li><a href="#" class="next_link">»</a></li>').appendTo(pager);
- }
-
- pager.find('.page_link:first').addClass('active');
- pager.find('.prev_link').hide();
- if (numPages<=1) {
- pager.find('.next_link').hide();
- }
- pager.children().eq(1).addClass("active");
-
- children.hide();
- children.slice(0, perPage).show();
-
- pager.find('li .page_link').click(function(){
- var clickedPage = $(this).html().valueOf()-1;
- goTo(clickedPage,perPage);
- return false;
- });
- pager.find('li .prev_link').click(function(){
- previous();
- return false;
- });
- pager.find('li .next_link').click(function(){
- next();
- return false;
- });
-
- function previous(){
- var goToPage = parseInt(pager.data("curr")) - 1;
- goTo(goToPage);
- }
-
- function next(){
- goToPage = parseInt(pager.data("curr")) + 1;
- goTo(goToPage);
- }
-
- function goTo(page){
- var startAt = page * perPage,
- endOn = startAt + perPage;
-
- children.css('display','none').slice(startAt, endOn).show();
-
- if (page>=1) {
- pager.find('.prev_link').show();
- }
- else {
- pager.find('.prev_link').hide();
- }
-
- if (page<(numPages-1)) {
- pager.find('.next_link').show();
- }
- else {
- pager.find('.next_link').hide();
- }
-
- pager.data("curr",page);
- pager.children().removeClass("active");
- pager.children().eq(page+1).addClass("active");
-
- }
- };
- $(document).ready(function(){
- $('#myTable').pageMe({pagerSelector:'#myPager',showPrevNext:true,hidePageNumbers:false,perPage:7});
- });
- </script>
-
- </head>
- <body>
- <div class="container">
- <div class="row">
- <div class="table-responsive">
- <table class="table table-hover">
- <thead>
- <tr>
- <th>#</th>
- <th>Table heading</th>
- <th>Table heading</th>
- <th>Table heading</th>
- <th>Table heading</th>
- <th>Table heading</th>
- <th>Table heading</th>
- </tr>
- </thead>
- <tbody id="myTable">
- <tr style="display: none;">
- <td>1</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- </tr>
- <tr style="display: none;">
- <td>2</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- </tr>
- <tr style="display: none;">
- <td>3</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- </tr>
- <tr style="display: none;">
- <td>4</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- </tr>
- <tr style="display: none;">
- <td>5</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- </tr>
- <tr style="display: none;">
- <td>6</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- </tr>
- <tr style="display: none;">
- <td>7</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- </tr>
- <tr style="display: none;">
- <td>8</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- </tr>
- <tr style="display: none;">
- <td>9</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- </tr>
- <tr style="display: none;">
- <td>10</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- <td>Table cell</td>
- </tr>
- </tbody>
- </table>
- </div>
- <div class="col-md-12 text-center">
- <ul class="pagination pagination-lg pager" id="myPager">
- <!--
- <li>
- <a href="#" class="prev_link" style="display: none;">«</a>
- </li>
- <li class="active">
- <a href="#" class="page_link active">1</a>
- </li>
- <li>
- <a href="#" class="page_link">2</a>
- </li>
- <li>
- <a href="#" class="page_link">3</a>
- </li>
- <li>
- <a href="#" class="next_link">»</a>
- </li>
- -->
- </ul>
- </div>
- </div>
- </div>
- </body>
- </html>
|