-
Notifications
You must be signed in to change notification settings - Fork 338
/
index.html
260 lines (211 loc) · 5.89 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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="author" content="www.frebsite.nl" />
<title>dotdotdot, javascript plugin for multiple line content ellipsis.</title>
<style type="text/css" media="all">
html,
body {
padding: 0;
margin: 0;
}
body {
background-color: #eed;
font-family: Arial, Helvetica, Verdana;
line-height: 20px;
color: #222538;
padding: 50px;
-webkit-text-size-adjust: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale
}
:first-child {
margin-top: 0;
}
:last-child {
margin-bottom: 0;
}
p {
margin: 10px 0;
}
a {
color: inherit;
text-decoration: underline;
}
.wrapper {
box-sizing: border-box;
width: 80%;
max-width: 600px;
min-width: 220px;
margin: 0 auto;
}
.example {
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
background: #222538;
background: -webkit-linear-gradient(bottom left,#222538,#46454d);
background: linear-gradient(to top right,#222538,#46454d);
color: #eed;
font-size: 20px;
line-height: 30px;
padding: 50px;
margin: 50px -50px;
overflow: hidden;
}
.example > div {
max-height: 250px;
}
/* readable pathnames */
.example ul,
.example ol,
.example li {
display: block;
list-style: none;
padding: 0;
margin: 0;
}
.example li {
height: 35px;
padding: 7px 0;
}
.example li + li {
border-top: 1px solid rgba( 255, 255, 255, 0.2 );
}
/* toggle full story */
.example > .full-story {
max-height: initial;
}
.example .toggle:before {
content: 'Show more';
}
.example > .full-story .toggle:before {
content: 'Show less';
}
.oldbrowser {
display: none;
}
@media screen and (min-width:0\0) {
.oldbrowser {
background: red;
color: white;
font-weight: bold;
font-size: 20px;
line-height: 1.5;
display: block;
padding: 50px;
margin: 50px -50px;
}
}
</style>
</head>
<body>
<br />
<br />
<div class="wrapper">
<div class="oldbrowser">
<big>Oh no!</big><br />
You're using an old browser.
Although the Dotdotdot plugin will work in older browsers (although you might need some polyfills),
these examples use modern JS your browser probably doesn't understand.
</div>
<div>
<h1>dotdotdot</h1>
<p>Javascript plugin for truncating multiple line content on a webpage.<br />
Resize your browser to see the examples below in action.</p>
<p>Documentation: <a href="http://dotdotdot.frebsite.nl" target="_blank">dotdotdot.frebsite.nl</a></p>
</div>
<div class="example">
<div id="xmpl-1">
<h3>Truncate multiple line content</h3>
<p><em>Lorem Ipsum</em> is simply <strong>dummy text</strong> of the printing and typesetting industry.
It has been the industry's standard dummy text ever <strong>since the 1500s</strong>, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
<em>Lorem Ipsum</em> has survived not only <strong>five centuries</strong>, but also the leap into <strong>electronic typesetting</strong>, remaining essentially unchanged.
<a href="#/" class="read-more">Read more »</a></p>
</div>
</div>
<div class="example">
<div id="xmpl-2">
<h3>Truncate to readable pathnames</h3>
<ol>
<li>file:///users/your-name/desktop/project/website/htdocs/index.html</li>
<li>file:///users/your-name/desktop/project/website/htdocs/css/style.css</li>
<li>file:///users/your-name/desktop/project/website/htdocs/css/layout.css</li>
</ol>
</div>
</div>
<div class="example">
<div id="xmpl-3">
<h3>Toggle full story</h3>
<p><em>Lorem Ipsum</em> is simply <strong>dummy text</strong> of the printing and typesetting industry.
It has been the industry's standard dummy text ever <strong>since the 1500s</strong>, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
<em>Lorem Ipsum</em> has survived not only <strong>five centuries</strong>, but also the leap into <strong>electronic typesetting</strong>, remaining essentially unchanged.</p>
<a class="toggle" href="#"></a>
</div>
</div>
</div>
<script src="dist/dotdotdot.js"></script>
<script>
/*
Basic example
*/
new Dotdotdot( document.querySelector( '#xmpl-1' ), {
// Prevents the <a class="read-more" /> from being removed
keep: '.read-more'
});
/*
Truncate to readable pathnames example
*/
document.querySelector( '#xmpl-2' )
.querySelectorAll( 'li' )
.forEach(( listitem ) => {
listitem.innerHTML = '<span>' + listitem.innerHTML.split( '/' ).join( '</span><span>/' ) + '</span>';
listitem.children.item( listitem.children.length - 1 ).classList.add( 'file' );
new Dotdotdot( listitem, {
// Add a slash before the ellipsis
ellipsis: '/\u2026',
// Adjustment for the top- and bottom padding.
tolerance: 20,
// Prevents the <span class="file" /> from being removed
keep: '.file'
});
});
/*
Toggle full story example
*/
var xmpl = document.querySelector( '#xmpl-3' );
var dot = new Dotdotdot( xmpl, {
// Prevents the <a class="toggle" /> from being removed
keep: '.toggle'
})
// Get the dotdotdot API
var api = dot.API;
xmpl.addEventListener( 'click', ( evnt ) => {
if ( evnt.target.closest( '.toggle' ) ) {
evnt.preventDefault();
// When truncated, restore
if ( xmpl.matches( '.ddd-truncated' ) )
{
api.restore();
xmpl.classList.add( 'full-story' );
}
// Not truncated, truncate
else
{
xmpl.classList.remove( 'full-story' );
api.truncate();
api.watch();
}
}
});
/*
For the demos
*/
document.body.addEventListener( 'click', ( evnt ) => {
if ( evnt.target.closest( 'a[href^="#/"]' ) ) {
evnt.preventDefault();
alert( 'Thank you for clicking, but that\'s a demo link.' );
}
});
</script>
</body>
</html>