-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.html
337 lines (304 loc) · 13.9 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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,user-scalable=no">
<link rel="shortcut icon" href="site/img/isotip-favicon.png">
<link rel="stylesheet" href="site/css/isotip.css">
<title>Isotip.js | A small javascript tooltip library</title>
<style>
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
body {
padding: 10px;
font: normal normal 16px/1.4 'Helvetica Neue', Helvetica, Arial, Sans-serif;
color: #2C3E50;
background-color: #ECF0F1;
}
div + div {
margin-top: 20px;
}
.content {
width: 100%;
max-width: 600px;
padding: 0;
margin: 0 auto;
}
.h1 {
margin: 0 auto -15px auto;
color: #E67E22;
font-size: 60px;
font-size: 3.75rem;
text-align: center;
}
.h2 {
margin: 0 auto;
color: #E67E22;
font-size: 32px;
font-size: 2rem;
text-align: center;
}
blockquote {
margin: 0;
font-size: 22px;
font-size: 1.375rem;
line-height: 1.2;
text-align: center;
}
a {
color: #3498DB;
text-decoration: none;
}
img {
display: block;
margin: 20px auto -10px auto;
width: 80px;
}
body > p:last-of-type {
margin-bottom: 30px;
}
.button {
display: inline-block;
padding: 10px 15px;
max-width: 150px;
font-weight: bold;
font-size: 16px;
line-height: 1.4;
color: #E67E22;
border: 2px solid #E67E22;
cursor: pointer;
}
.badges {
margin-bottom: 40px;
text-align: center;
}
iframe {
display: inline-block;
}
.center-text {
text-align: center;
}
.default-tooltip {
margin-bottom: 40px;
}
.default-tooltip .button {
margin-bottom: 10px;
}
.tooltip-group {
margin: 40px 0;
}
.tooltip-group div {
clear: both;
}
.tooltip-group div:after {
content: '';
display: table;
clear: both;
}
.tooltip-position-left {
float: left;
}
.tooltip-position-right {
float: right;
}
.scroll-container {
position: relative;
z-index: 100;
overflow: scroll;
margin-bottom: 50px;
height: 300px;
background-color: white;
border: 2px solid #E67E22;
}
.scroll-container > .tooltip-container {
padding-top: 1px;
height: 600px;
}
.scroll-container > .tooltip {
z-index: 0;
margin-top: 0;
}
.scroll-container .tooltip-click {
display: block;
margin: 100px auto 0 auto;
max-width: 210px;
text-align: center;
}
code {
padding: 2px 5px;
color: #E67E22;
white-space: nowrap;
}
pre {
padding: 10px;
margin: 0;
overflow: scroll;
border: 1px solid #BDC3C7;
border-radius: 3.5px;
background-color: #FFF;
}
pre code {
white-space: pre;
}
dt {
margin: 20px 0 10px 0;
padding: 3px 5px;
border-left: 3px solid #E67E22;
}
dt pre {
border: none;
padding: 0;
background-color: transparent;
}
dd {
margin-bottom: 30px;
}
</style>
</head>
<body>
<div class="content">
<img src="site/img/isotip-icon.svg" alt="isotip logo">
<h1 class="h1">Isotip</h1>
<blockquote>
<p>The javascript tooltip plugin with no dependencies</p>
</blockquote>
<p>Isotip is a small (3kb minified and gzipped) and minimal node module to be included in your browserify (or similar) package for use in the browser. Its only dependencies are ES5 and a browser. View the source on <a href="https://github.com/datuhealth/isotip">Github</a>.</p>
<div class="badges">
<iframe src="https://ghbtns.com/github-btn.html?user=datuhealth&repo=isotip&type=star&count=true" frameborder="0" scrolling="0" width="120px" height="20px"></iframe>
<iframe src="https://ghbtns.com/github-btn.html?user=datuhealth&repo=isotip&type=fork&count=true" frameborder="0" scrolling="0" width="120px" height="20px"></iframe>
</div>
<div class="center-text default-tooltip">
<span class="tooltip-click button" data-tooltip-content="I'm the default tooltip">Click me</span>
<span class="tooltip-hover button" data-tooltip-content="I'm the default tooltip">Hover over me</span>
<input class="tooltip-focus button" data-tooltip-content="I'm the default tooltip" value="Focus on me">
</div>
<p>Positioning a tooltip is as simple as adding an attribute. You can position a tooltip to the top, right, bottom, or left of an element. By default, tooltips appear above an element.</p>
<p>Additionally, if a tooltip is so large that it would run off-screen, Isotip will re-position it to a better position. Scrolling with a tooltip open will also keep it in position, and re-adjust if scrolling would cause it to move off-screen.</p>
<div class="center-text tooltip-group">
<div>
<span class="tooltip-click button tooltip-position-top" data-tooltip-content="I'm on top" data-tooltip-placement="top">On top</span>
</div>
<div>
<span class="tooltip-click button tooltip-position-left" data-tooltip-content="I'm on the right" data-tooltip-placement="right">On the right</span>
<span class="tooltip-click button tooltip-position-right" data-tooltip-content="I'm on the left" data-tooltip-placement="left">On the left</span>
</div>
<div>
<span class="tooltip-click button tooltip-position-left" data-tooltip-content="I'm on the left" data-tooltip-placement="left">On the left</span>
<span class="tooltip-click button tooltip-position-right" data-tooltip-content="I'm on the right" data-tooltip-placement="right">On the right</span>
</div>
<div>
<span class="tooltip-click button tooltip-position-bottom" data-tooltip-content="I'm on bottom" data-tooltip-placement="bottom">On the bottom</span>
</div>
<div>
<span class="tooltip-click button tooltip-html" data-tooltip-content="<a href='http://google.com' target='_blank'>Google</a>" data-tooltip-html="true">Custom HTML content</span>
</div>
</div>
<div class="scroll-container">
<div class="tooltip-container">
<span class="tooltip-click button tooltip-scroll-container" data-tooltip-content="I'm In a scrolling container!" data-tooltip-placement="top" data-tooltip-container=".scroll-container" data-tooltip-scrollContainer=".scroll-container">In a scrolling container</span>
</div>
</div>
<h2 class="h2" id="api">API</h2>
<p>Isotip (purposefully) has a simple api. It provides a simple helper function to automatically bind certain events and open tooltips when they fire.</p>
<p>Configuring a specific tooltip is done via data attributes on an element.</p>
<dl>
<dt><pre><code>data-tooltip-classname</code></pre></dt>
<dd>
<p>If you'd like to add a classname to the root tooltip element, set it here.</p>
</dd>
<dt><pre><code>data-tooltip-content</code></pre></dt>
<dd>
<p>This sets the main body content of the tooltip into a <code><p></code> tag by default with a class of <code>tooltip-content</code>. Content is interpreted as plain text by default. To insert html, set the <code>data-tooltip-html</code> attribute to true.</p>
</dd>
<dt><pre><code>data-tooltip-title</code></pre></dt>
<dd>
<p>This sets the title of the tooltip into a <code><p></code> tag by default with a class of <code>tooltip-title</code>.</p>
</dd>
<dt><pre><code>data-tooltip-html</code></pre></dt>
<dd>
<p>Setting this to true will force Isotip to try and interpret the content as HTML. If it fails, it will interpret the content as plain text.</p>
</dd>
<dt><pre><code>data-tooltip-placement</code></pre></dt>
<dd>
<p>This sets the position of the tooltip. Options are <code>top</code>, <code>right</code>, <code>bottom</code>, and <code>left</code>. By default, <code>top</code> is used for all tooltips.</p>
</dd>
<dt><pre><code>data-tooltip-container</code></pre></dt>
<dd>
<p>This sets the element that the tooltip will be prepended to. By default, this is the <code><body></code> element.</p>
</dd>
<dt><pre><code>data-tooltip-scrollContainer</code></pre></dt>
<dd>
<p>This sets the element that will have a scroll event bound to it. If your tooltip is inside a scrolling element (<code>overflow:scroll</code>), you need to add this!.</p>
</dd>
<dt><pre><code>data-tooltip-autoclose</code></pre></dt>
<dd>
<p>If set to false, the tooltip won't close until you programmatically close it with <code>isotip.close()</code>. Note that normal tooltips will not open until the open tooltip has been closed!</p>
</dd>
</dl>
<p>Alternatively, programattic creation and destruction of tooltips is available.</p>
<dl>
<dt><pre><code>init( config )</code></pre></dt>
<dd>
<p>The init method provides automatic event binding for tooltips. It sets up delegated event listeners for <code>.tooltip-click</code>, <code>.tooltip-hover</code>, and <code>.tooltip-focus</code> for click, mouseover, and focus events respectively. You can pass in an optional config object to overwrite any of the default options.</p>
<pre><code>var options = {
html: false, // set to true to always interpret content as HTML
placement: 'top', // default placement of tooltips
container: 'body', // default containing element for the tooltip
scrollContainer: '.scroll-container', // default container for scroll watching
template: '<div class="tooltip" data-tooltip-target="tooltip"></div>', // default template for the tooltip shell
removalDelay: 200, // default number of ms before the tooltip is removed
tooltipOffset: 10, // default number of px the tooltip is offset from the trigger element
windowPadding: { // window bounds for tooltip repositioning
top: 10,
right: 10,
bottom: 10,
left: 10
}
};
isotip.init( config );</code></pre>
</dd>
<dt><pre><code>open( trigger, config )</code></pre></dt>
<dd>
<p>The open method will create the tooltip, insert it into the DOM, and position it in relation to it's trigger. The trigger can be an element or a CSS selector. The object to be passed in will serve as a replacement for the data attributes on the trigger.</p>
<pre><code>var config = {
className: 'specific-class', // set to add a class to the tooltip
html: false, // set to true to interpret content as HTML
placement: 'top', // where to place the tooltip in relation to the trigger
content: 'Tooltip content', // the content to go into the tooltip,
title: 'Tooltip title', // the text to go in the title, if any
container: document.querySelector('.container'), // the container to append the tooltip to
scrollContainer: document.querySelector('.scroll-container'), // the container to bind the scroll event to
autoClose: false // set to false if you only want to close the tooltip programmatically. Normal tooltips will not open until this is closed!
};
isotip.open( '.tooltip', config );</code></pre>
</dd>
<dt><pre><code>close( tooltip )</code></pre></dt>
<dd>
<p>The close method will remove a tooltip from the DOM. The tooltip to remove should be passed in and can be an element or a CSS selector.</p>
<pre><code>isotip.close( '.tooltip' );</code></pre>
</dd>
<dt><pre><code>positionTooltip( tooltip, trigger, placement )</code></pre></dt>
<dd>
<p>The positionTooltip method will re-evaluate the position of a tooltip in relation to it's trigger element. Only the tooltip and trigger need to be passed in, and placement will default to what's been configured by <code>init()</code>. Tooltip and trigger can be either an element or a CSS selector.</p>
<pre><code>isotip.positionTooltip( '.tooltip', '.tooltip-click', 'left' );</code></pre>
</dd>
</dl>
<p>Isotip is licensed under the <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache 2.0</a> license.</p>
<p>Copyright 2015 Datu Health, Inc.</p>
</div>
<script src="node_modules/es5-shim/es5-shim.min.js"></script>
<script src="dist/isotip.js"></script>
<script>isotip.init();</script>
</body>
</html>