-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpagination-example.html
93 lines (74 loc) · 4.97 KB
/
pagination-example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
/* reset */
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{border:0;font-size:100%;font:inherit;vertical-align:baseline;margin:0;padding:0}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:none}table{border-collapse:collapse;border-spacing:0}
</style>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script>
$(document).ready(function() {
var maxPage = 1;
$('section[data-article-page]').each(function() {
var pageNumber = parseInt($(this).attr('data-article-page'));
if (pageNumber > maxPage) {
maxPage = pageNumber;
}
});
$('[data-article-max-page]').text(maxPage);
$('[data-article-page-link]').on('click', function(e) {
e.preventDefault();
var page = $(this).attr('data-article-page-link');
$('[data-article-page-number]').text(page);
$("section[data-article-page!='" + page + "']").hide();
$("section[data-article-page='" + page + "']").show();
if (page == 1) {
$('[data-article-page-link-previous]').hide();
} else {
$('[data-article-page-link-previous]').show();
}
if (page == parseInt($('[data-article-max-page]').text())) {
$('[data-article-page-link-next]').hide();
} else {
$('[data-article-page-link-next]').show();
}
});
$('[data-article-page-link-previous]').on('click', function(e) {
e.preventDefault();
var nextPage = parseInt($('[data-article-page-number]').text()) - 1;
$("[data-article-page-link='" + nextPage + "']").click();
});
$('[data-article-page-link-next]').on('click', function(e) {
e.preventDefault();
var nextPage = parseInt($('[data-article-page-number]').text()) + 1;
$("[data-article-page-link='" + nextPage + "']").click();
});
$("section[data-article-page!='1']").hide();
$("[data-article-page-link='1']").click();
});
</script>
</head>
<body>
<article>
<section data-article-page="1">
The article element represents a component of a page that consists of a self-contained composition in a document, page, application, or site and that is intended to be independently distributable or reusable, e.g. in syndication. This could be a forum post, a magazine or newspaper article, a blog entry, a user-submitted comment, an interactive widget or gadget, or any other independent item of content.
</section>
<section data-article-page="2">
An independent piece of content, one suitable for putting in an <article> element, is content that makes sense on its own. This yardstick is up to your interpretation, but an easy smell test is would this make sense in an RSS feed? Of course weblog articles and static pages would make sense in a feed reader, and some sites have weblog comment feeds. On the other hand, a feed with each paragraph of this article as a separate post wouldn't be very useful. The key point here is that the content has to make sense independent of its context, i.e. when all the surrounding content is stripped away.
</section>
<section data-article-page="3">
But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure.
</section>
</article>
<div>
<a href="#" data-article-page-link-previous>Previous</a> Page <span data-article-page-number>0</span> of <span data-article-max-page>0</span>. <a href="#" data-article-page-link-next>Next</a>
</div>
<nav>
<a href="#" data-article-page-link="1">Page 1</a> |
<a href="#" data-article-page-link="2">Page 2</a> |
<a href="#" data-article-page-link="3">Page 3</a>
</nav>
</body>
</html>