|
1 | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
2 | 2 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> |
3 | 3 | <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" /> |
6 | 7 | <script type="text/javascript" src="../lib/jquery/jquery.min.js"></script> |
7 | 8 | <script type="text/javascript" src="../lib/jquery_pagination/jquery.pagination.js"> |
8 | 9 | </script> |
9 | 10 | <script type="text/javascript"> |
10 | 11 |
|
11 | 12 | // This is a very simple demo that shows how a range of elements can |
12 | 13 | // 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. |
13 | 17 |
|
14 | 18 | /** |
15 | 19 | * Callback function that displays the content. |
|
19 | 23 | * @param {int}page_index New Page index |
20 | 24 | * @param {jQuery} jq the container with the pagination links as a jQuery object |
21 | 25 | */ |
22 | | - function pageselectCallback(page_index, jq){ |
| 26 | + function pageselectCallback(page_index, jq){ |
23 | 27 | var new_content = $('#hiddenresult div.result:eq('+page_index+')').clone(); |
24 | 28 | $('#Searchresult').empty().append(new_content); |
25 | 29 | return false; |
26 | 30 | } |
27 | 31 |
|
28 | 32 | /** |
29 | | - * Callback function for the AJAX content loader. |
| 33 | + * Initialisation function for pagination |
30 | 34 | */ |
31 | 35 | function initPagination() { |
| 36 | + // count entries inside the hidden content |
32 | 37 | var num_entries = $('#hiddenresult div.result').length; |
33 | | - // Create pagination element |
| 38 | + // Create content inside pagination element |
34 | 39 | $("#Pagination").pagination(num_entries, { |
35 | | - num_edge_entries: 2, |
36 | | - num_display_entries: 8, |
37 | 40 | callback: pageselectCallback, |
38 | | - items_per_page:1 |
| 41 | + items_per_page:1 // Show only one item per page |
39 | 42 | }); |
40 | 43 | } |
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 |
44 | 46 | $(document).ready(function(){ |
45 | 47 | initPagination(); |
46 | 48 | }); |
|
61 | 63 | height: 100%; |
62 | 64 | font-family: Arial, Helvetica, sans-serif; |
63 | 65 | } |
64 | | - |
65 | | - h1 { |
66 | | - margin-bottom:10px; |
67 | | - font-size:1.5em; |
68 | | - } |
69 | 66 |
|
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; |
76 | 78 | width:40%; |
77 | | - } |
| 79 | + } |
78 | 80 |
|
79 | 81 | #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 | + |
87 | 89 | --> |
88 | 90 | </style> |
89 | | - |
| 91 | + |
90 | 92 | <title>Pagination</title> |
91 | 93 | </head> |
92 | 94 | <body> |
93 | | - <h1>jQuery Pagination Plugin Demo</h1> |
| 95 | + <h1>jQuery Pagination Plugin Demo</h1> |
94 | 96 | <div id="Pagination" class="pagination"> |
95 | 97 | </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> |
100 | 102 |
|
101 | 103 | <!-- Container element for all the Elements that are to be paginated --> |
102 | 104 | <div id="hiddenresult" style="display:none;"> |
@@ -130,8 +132,8 @@ <h1>jQuery Pagination Plugin Demo</h1> |
130 | 132 | </div> |
131 | 133 | </div> |
132 | 134 |
|
133 | | - <div id="footer"> |
134 | | - Copyright © 2008 by <a href="http://www.d-scribe.de/">describe europe Ltd.</a>. |
135 | | - </div> |
| 135 | + <div id="footer"> |
| 136 | + Copyright © 2010 by <a href="http://www.d-scribe.de/">describe europe Ltd.</a>. |
| 137 | + </div> |
136 | 138 | </body> |
137 | 139 | </html> |
0 commit comments