forked from jonkirkman/rptr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
182 lines (155 loc) · 4.36 KB
/
index.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>rptr.js helps repeat things</title>
<script src="rptr.js" type="text/javascript"></script>
<script src="libs/Nonsense.js" type="text/javascript"></script>
<style type="text/css">
@font-face {
font-family: 'RaphaelIcons';
src: url('libs/raphaelicons/raphaelicons-webfont.eot');
src: local('☺'),
url('libs/raphaelicons/raphaelicons-webfont.woff') format('woff'),
url('libs/raphaelicons/raphaelicons-webfont.ttf') format('truetype'),
url('libs/raphaelicons/raphaelicons-webfont.svgwebfontKOf9F4sx') format('svg');
font-weight: normal;
font-style: normal;
}
body {
font: 12px/18px Helvetica, Arial, sans-serif;
color: #555;
}
h1,
h2,
h3 {
margin: 1.5em 0 1em;
}
h1 {
font-size: 36px;
color: #ff8200;
}
h2,
h3 {
font-weight: 200;
}
.wrapper {
max-width: 720px;
margin: 0 auto;
}
#viewport {
position: relative;
height: 400px;
border: 4px solid #ff8200;
}
.placeholder {
position: absolute;
width: 100%;
height: 100%;
padding-top: 140px;
font-size: 3em;
line-height: 2;
text-align: center;
color: #ff8200;
cursor: pointer;
}
.placeholder small {
font-size: .5em;
font-weight: 200;
color: #555;
}
.single-thing {
position: relative;
height: 38px;
line-height: 38px;
border-bottom: 2px solid #f0f0f0;
overflow: hidden;
}
.single-thing::before {
content: attr(data-icon);
display: inline-block;
width: 50px;
font-size: 32px;
font-weight: normal;
font-style: normal;
font-family: 'RaphaelIcons';
text-transform: none;
text-align: center;
vertical-align: middle;;
color: #ccc;
-webkit-font-smoothing: antialiased;
-webkit-transform: rotate( -15deg );
/*-webkit-transition: all .1s ease-in;*/
}
.single-thing small {
position: absolute;
right: 10px;
color: #ccc;
}
strong {
text-transform: capitalize;
}
/*
* Styles for rptr
*/
.rptr-canvas { position: relative; }
.rptr-single { position: absolute; width: 100%; }
</style>
</head>
<body>
<div class="wrapper">
<h1>rptr.js</h1>
<h2>A logic-only repeatable list component aimed at efficiency.</h2>
<!-- This will contain our list -->
<div id="viewport">
<div class="placeholder">Try it <br> <small>[with 5,000 random non-ideas]</small></div>
</div>
<h3>Three parameters you need:</h3>
<ol>
<li><strong>Container</strong> A DOM element to hold your soon to be rendered items.</li>
<li><strong>Data</strong> An array of items you would like rendered. </li>
<li><strong>Renderer</strong> A function that will know what to do when we pass it any single item from your array.</li>
</ol>
<code><pre>
</pre></code>
</div>
<!-- Let's kickstart this -->
<script type="text/javascript">
// Building an array of junk. Feel free to ignore this and use real data.
var blah = new Nonsense();
var icons = [
'!','"','#','$','%','&','(',')','*','+',',','-','.','/','0',
'1','2','3','4','5','6','7','8','9',':',';','<','=','>','?','@','\'','\\',
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','[',']','^','_','`',
'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
'À','Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö','×','Ø','Ù','Ú','Û','Ü'
];
var my_items = (function(count){
var things = [];
for (var i = count - 1; i >= 0; i--)
things[i] = {
id: i,
icon: icons[ Math.floor(Math.random() * icons.length) ],
phrase: blah.buzzPhrase()
};
return things;
})(5000);
// Get our container
var my_container = document.getElementById('viewport');
// We need a renderer for our items
var my_renderer = function(item) {
return '<div class="single-thing" data-icon="'+item.icon+'"> <strong>'+item.phrase+'</strong>   <small>#'+item.id+'</small> </div>';
}
// Build'n our demo
var demo;
// Start'n our demo
function try_btn_click() {
my_container.removeChild(try_btn);
demo = rptr(my_container, my_items, my_renderer);
// demo.init();
}
var try_btn = document.querySelector('.placeholder');
try_btn.addEventListener('click', try_btn_click, false);
</script>
</body>
</html>