7,118 changes: 0 additions & 7,118 deletions css/bootstrap.css

This file was deleted.

33 changes: 7 additions & 26 deletions index.html
Expand Up @@ -7,14 +7,14 @@

<link href="http://fonts.googleapis.com/css?family=Open+Sans&subset=latin,cyrillic" rel="stylesheet"
type="text/css">
<link href="css/bootstrap.css" rel="stylesheet" type="text/css">
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
<link href='https://fonts.googleapis.com/css?family=Architects+Daughter' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="css/stylesheet.css" media="screen"/>
<link rel="stylesheet" type="text/css" href="css/pygment_trac.css" media="screen"/>
<link rel="stylesheet" type="text/css" href="css/print.css" media="print"/>

<script src="http://code.jquery.com/jquery-2.0.3.min.js" type="text/javascript"></script>
<script src="js/bootstrap.js" type="text/javascript"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<script src="js/jquery.twbsPagination.js" type="text/javascript"></script>
<script src="js/main.js" type="text/javascript"></script>

Expand Down Expand Up @@ -65,12 +65,10 @@ <h3>
<a id="demo" class="anchor" href="#demo"><span
class="octicon octicon-link"></span></a>Demo</h3>

<p>
<div id="page-content" class="well"></div>
<div class="text-center">
<ul id="pagination-demo" class="pagination-sm"></ul>
</div>
</p>
<div id="page-content" class="well"></div>
<div class="text-center">
<ul id="pagination-demo" class="pagination-sm"></ul>
</div>

<p>Here is corresponding piece of code:</p>
<pre><code class="highlight"> $(<span class="s">'#pagination-demo'</span>).twbsPagination({
Expand Down Expand Up @@ -127,23 +125,6 @@ <h3>
<a id="examples" class="anchor" href="#examples"><span
class="octicon octicon-link"></span></a>Examples</h3>

<h4>Versions</h4>

<p>Choose behaviour of method <code>getPages</code>. Try to following demos:</p>

<div class="text-center">
<ul id="pagination-demo-v1_0" class="pagination-sm"></ul>
</div>

<div class="text-center">VS</div>

<div class="text-center">
<ul id="pagination-demo-v1_1" class="pagination-sm"></ul>
</div>

<p>Download <a href="https://github.com/esimakin/twbs-pagination/releases/tag/v1.0">first</a> or
<a href="https://github.com/esimakin/twbs-pagination/releases/tag/v1.1">second</a>.</p>

<h4>URL page link</h4>

<p>You can specify url using <code>href</code> option:</p>
Expand Down Expand Up @@ -200,7 +181,7 @@ <h3>
</section>

<aside id="sidebar">
<div id="navigation">
<div id="navigation" data-spy="affix" data-offset-top="200">
<ul class="nav nav-pills nav-stacked">
<li class="active"><a href="#intro">Intro</a></li>
<li><a href="#demo">Demo</a>
Expand Down
2,006 changes: 0 additions & 2,006 deletions js/bootstrap.js

This file was deleted.

74 changes: 22 additions & 52 deletions js/jquery.twbsPagination.js
Expand Up @@ -28,18 +28,6 @@
init: function (options) {
this.options = $.extend({}, this.options, options);

switch (this.options.version) {
case '1.0':
this.currentPages = this.getPages_v_1_0(this.options.startPage);
break;
case '1.1':
this.currentPages = this.getPages_v_1_1(this.options.startPage);
break;
default:
this.currentPages = this.getPages_v_1_1(this.options.startPage);
break;
}

if (this.options.startPage < 1 || this.options.startPage > this.options.totalPages) {
throw new Error('Start page option is incorrect');
}
Expand All @@ -48,10 +36,12 @@
throw new Error('Total pages option cannot be less 1 (one)!');
}

if (!$.isNumeric(this.options.visiblePages) && !this.options.visiblePages) {
if (this.options.totalPages < this.options.visiblePages) {
this.options.visiblePages = this.options.totalPages;
}

this.currentPages = this.getPages(this.options.startPage);

if (this.options.onPageClick instanceof Function) {
this.$element.bind('page', this.options.onPageClick);
}
Expand All @@ -73,29 +63,29 @@
this.$element.append(this.$listContainer);
}

this.show(this.options.startPage);
this.render(this.currentPages);
this.setupEvents();

this.$element.trigger('page', this.options.startPage);

return this;
},

destroy: function () {
this.$element.empty();
return this;
},

show: function (page) {
if (page < 1 || page > this.options.totalPages) {
throw new Error('Page is incorrect.');
}

switch (this.options.version) {
case '1.0':
this.render(this.getPages_v_1_0(page));
break;
case '1.1':
this.render(this.getPages_v_1_1(page));
break;
default:
this.render(this.getPages_v_1_1(page));
break;
}

this.render(this.getPages(page));
this.setupEvents();

this.$element.trigger('page', page);
return this;
},

buildListItems: function (pages) {
Expand Down Expand Up @@ -156,26 +146,7 @@
return itemContainer;
},

getPages_v_1_0: function (currentPage) {
var pages = [];

var startPage;
var section = parseInt(currentPage / this.options.visiblePages, 10);
if (currentPage % this.options.visiblePages === 0) {
startPage = (section - 1) * this.options.visiblePages + 1;
} else {
startPage = section * this.options.visiblePages + 1;
}

var endPage = Math.min(this.options.totalPages, (startPage + this.options.visiblePages) - 1);
for (var i = startPage; i <= endPage; i++) {
pages.push(i);
}

return {"currentPage": currentPage, "numeric": pages};
},

getPages_v_1_1: function (currentPage) {
getPages: function (currentPage) {
var pages = [];

var half = Math.floor(this.options.visiblePages / 2);
Expand Down Expand Up @@ -240,10 +211,10 @@
});
},

equals: function (oldArray, newArray) {
equals: function (arr1, arr2) {
var i = 0;
while ((i < oldArray.length) || (i < newArray.length)) {
if (oldArray[i] !== newArray[i]) {
while ((i < arr1.length) || (i < arr2.length)) {
if (arr1[i] !== arr2[i]) {
return false;
}
i++;
Expand Down Expand Up @@ -284,8 +255,7 @@
next: 'Next',
last: 'Last',
paginationClass: 'pagination',
onPageClick: null,
version: '1.1'
onPageClick: null
};

$.fn.twbsPagination.Constructor = TwbsPagination;
Expand All @@ -295,4 +265,4 @@
return this;
};

})(jQuery, window, document);
})(jQuery, window, document);
20 changes: 1 addition & 19 deletions js/main.js
Expand Up @@ -7,27 +7,9 @@ $(document).ready(function () {
}
});

$('#navigation').affix({
offset: {
top: 200
}
});

$('#pagination-demo-v1_0').twbsPagination({
totalPages: 15,
version: '1.0',
startPage: 5
});

$('#pagination-demo-v1_1').twbsPagination({
totalPages: 15,
startPage: 5
});

$('#visible-pages-example').twbsPagination({
totalPages: 35,
visiblePages: 10,
version: '1.1'
visiblePages: 10
});

$('.sync-pagination').twbsPagination({
Expand Down