Skip to content

Commit eaa41b8

Browse files
author
Gabriel Birke
committed
Better comments and simpler code for simple demo
1 parent 97dfc45 commit eaa41b8

File tree

1 file changed

+41
-39
lines changed

1 file changed

+41
-39
lines changed

demo/demo.htm

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
22
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
33
<head>
4-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5-
<link rel="stylesheet" href="../lib/jquery_pagination/pagination.css" />
4+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5+
<title>Pagination Demo I - Simple pagination</title>
6+
<link rel="stylesheet" href="../lib/jquery_pagination/pagination.css" />
67
<script type="text/javascript" src="../lib/jquery/jquery.min.js"></script>
78
<script type="text/javascript" src="../lib/jquery_pagination/jquery.pagination.js">
89
</script>
910
<script type="text/javascript">
1011

1112
// This is a very simple demo that shows how a range of elements can
1213
// be paginated.
14+
// The elements that will be displayed are in a hidden DIV and are
15+
// cloned for display. The elements are static, there are no Ajax
16+
// calls involved.
1317

1418
/**
1519
* Callback function that displays the content.
@@ -19,28 +23,26 @@
1923
* @param {int}page_index New Page index
2024
* @param {jQuery} jq the container with the pagination links as a jQuery object
2125
*/
22-
function pageselectCallback(page_index, jq){
26+
function pageselectCallback(page_index, jq){
2327
var new_content = $('#hiddenresult div.result:eq('+page_index+')').clone();
2428
$('#Searchresult').empty().append(new_content);
2529
return false;
2630
}
2731

2832
/**
29-
* Callback function for the AJAX content loader.
33+
* Initialisation function for pagination
3034
*/
3135
function initPagination() {
36+
// count entries inside the hidden content
3237
var num_entries = $('#hiddenresult div.result').length;
33-
// Create pagination element
38+
// Create content inside pagination element
3439
$("#Pagination").pagination(num_entries, {
35-
num_edge_entries: 2,
36-
num_display_entries: 8,
3740
callback: pageselectCallback,
38-
items_per_page:1
41+
items_per_page:1 // Show only one item per page
3942
});
4043
}
41-
42-
// Load HTML snippet with AJAX and insert it into the Hiddenresult element
43-
// When the HTML has loaded, call initPagination to paginate the elements
44+
45+
// When document is ready, initialize pagination
4446
$(document).ready(function(){
4547
initPagination();
4648
});
@@ -61,42 +63,42 @@
6163
height: 100%;
6264
font-family: Arial, Helvetica, sans-serif;
6365
}
64-
65-
h1 {
66-
margin-bottom:10px;
67-
font-size:1.5em;
68-
}
6966

70-
#Searchresult {
71-
margin-top:15px;
72-
margin-bottom:15px;
73-
border:solid 1px #eef;
74-
padding:5px;
75-
background:#eef;
67+
h1 {
68+
margin-bottom:10px;
69+
font-size:1.5em;
70+
}
71+
72+
#Searchresult {
73+
margin-top:15px;
74+
margin-bottom:15px;
75+
border:solid 1px #eef;
76+
padding:5px;
77+
background:#eef;
7678
width:40%;
77-
}
79+
}
7880

7981
#Searchresult p { margin-bottom:1.4em;}
80-
81-
#footer {
82-
margin-top:20px;
83-
font-size:60%;
84-
color:#15B;
85-
}
86-
82+
83+
#footer {
84+
margin-top:20px;
85+
font-size:60%;
86+
color:#15B;
87+
}
88+
8789
-->
8890
</style>
89-
91+
9092
<title>Pagination</title>
9193
</head>
9294
<body>
93-
<h1>jQuery Pagination Plugin Demo</h1>
95+
<h1>jQuery Pagination Plugin Demo</h1>
9496
<div id="Pagination" class="pagination">
9597
</div>
96-
<br style="clear:both;" />
97-
<div id="Searchresult">
98-
This content will be replaced when pagination inits.
99-
</div>
98+
<br style="clear:both;" />
99+
<div id="Searchresult">
100+
This content will be replaced when pagination inits.
101+
</div>
100102

101103
<!-- Container element for all the Elements that are to be paginated -->
102104
<div id="hiddenresult" style="display:none;">
@@ -130,8 +132,8 @@ <h1>jQuery Pagination Plugin Demo</h1>
130132
</div>
131133
</div>
132134

133-
<div id="footer">
134-
Copyright &copy; 2008 by <a href="http://www.d-scribe.de/">describe europe Ltd.</a>.
135-
</div>
135+
<div id="footer">
136+
Copyright &copy; 2010 by <a href="http://www.d-scribe.de/">describe europe Ltd.</a>.
137+
</div>
136138
</body>
137139
</html>

0 commit comments

Comments
 (0)