-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.html
320 lines (283 loc) · 8.37 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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<title>A minimal jQuery tooltip plugin</title>
</head>
<style type="text/css">
html {
height: 100%;
}
body {
color: #fff;
height: 100%;
font-family: "Trebuchet MS", sans-serif;
background-color: #269;
background-image: -moz-radial-gradient(50% 50%, circle, #226699 0%, #024679 100%);
background-image: -webkit-radial-gradient(50% 50%, circle cover, #226699 0%, #024679 100%);
}
h1 {
width: 650px;
border-bottom: 1px solid #d2d2d2;
line-height: 26px;
margin: 0 auto;
text-align: center;
font-size: 28px;
margin: 0px 0px 15px 0px;
text-shadow: 0px 1px 0px #fff;
}
h4 {
margin: 0px;
}
p {
margin: 5px 0px;
}
#tl {
position: absolute;
top: 10px;
left: 10px;
}
#tr {
position: absolute;
top: 10px;
right: 10px;
}
#bl {
position: absolute;
bottom: 10px;
left: 10px;
}
#br {
position: absolute;
bottom: 10px;
right: 10px;
}
#tc {
text-align: center;
position: absolute;
width: 200px;
top: -60px;
left: 50%;
margin-left: -100px;
color: #fff;
}
#bc {
text-align: center;
position: absolute;
width: 200px;
bottom: -60px;
left: 50%;
margin-left: -100px;
color: #fff;
}
#main {
position: absolute;
width: 650px;
height: 420px;
top: 50%;
left: 50%;
margin: -230px 0px 0px -345px;
background: #efefef;
padding: 20px;
border-radius: 6px;
color: #444;
}
label,input {
cursor: pointer;
}
#controls {
overflow: hidden;
}
.control {
float: left;
width: 150px;
}
.control h4 {
margin-bottom: 15px;
}
.control h5 {
margin: 0px;
font-size: 12px;
font-weight: normal;
color: #888;
}
.content.control {
width: 180px;
}
.control input[type=text] {
text-align: center;
width: 35px;
font-size: 15px;
}
a {
color: #16c;
}
#target {
color: #888;
font-size: 14px;
}
[data-test-title] {
background: rgba(0,0,0,0.3);
padding: 5px 10px;
border-radius: 3px;
cursor: pointer;
}
#source h4 {
margin-bottom: 5px;
}
#source p {
margin: 0px 0px 5px 0px;
border-left: 10px solid #692;
padding-left: 10px;
margin-bottom: 10px;
}
#source pre {
white-space: normal;
font-size: 15px;
color: #333;
padding: 2px 10px;
margin: 0px;
border-left: 10px solid #692;
margin-bottom: 10px;
}
.parameter {
color: #060;
font-weight: bold;
}
.attribute {
}
#get {
display: block;
text-align: right;
text-decoration: none;
font-size: 17px;
font-family: Tahoma;
margin-top: 30px;
}
#get a {
font-size: 20px;
margin-left: 5px;
}
</style>
<link rel="stylesheet" href="stylesheets/tooltip.css" type="text/css" />
<body>
<div id="tl" data-test-title="Hi... I'm the top left title attribute!" data-tooltip-slide="0">Top Left</div>
<div id="tr" data-test-title="Hi... I'm the top right title attribute!">Top Right</div>
<div id="bl" data-test-title="Hi... I'm the bottom left title attribute!">Bottom Left</div>
<div id="br" data-test-title="Hi... I'm the bottom right title attribute!">Bottom Right</div>
<div id="main">
<h1>A minimal jQuery tooltip plugin</h1>
<div id="tc" data-test-title="Hi... I'm the top center title attribute!">Top Center</div>
<div id="bc" data-test-title="Hi... I'm the bottom center title attribute!">Bottom Center</div>
<div id="controls">
<div class="control">
<h4 data-tooltip-direction="left">Direction:</h4>
<p>
<label for="direction_top">Top</label>
<input type="radio" id="direction_top" value="top" name="direction" checked="checked" />
</p>
<p>
<label for="direction_right">Right</label>
<input type="radio" id="direction_right" name="direction" value="right" />
</p>
<p>
<label for="direction_bottom">Bottom</label>
<input type="radio" id="direction_bottom" name="direction" value="bottom" />
</p>
<p>
<label for="direction_left">Left</label>
<input type="radio" id="direction_left" name="direction" value="left" />
</p>
</div>
<div class="control">
<h4 data-tooltip-direction="left">Color:</h4>
<p>
<label for="color_white" >White</label>
<input type="radio" id="color_white" name="color" value="white" />
</p>
<p>
<label for="color_black" >Black</label>
<input type="radio" id="color_black" name="color" value="black" />
</p>
</div>
<div class="control">
<h4 data-tooltip-direction="left">Margin:</h4>
<p>
<input type="text" id="margin" name="margin" />
<label for="margin" >px</label>
</p>
</div>
<div class="content control">
<h4>Content:</h4>
<p>
<label for="content_title" >Use title attribute</label>
<input type="radio" id="content_title" name="content" value="title" />
</p>
<p>
<label for="content_selector" >Use selector</label>
<input type="radio" id="content_selector" name="content" value="selector" />
</p>
<p id="target">Hello I'm some content. I can have html such as <em>em</em> tags.</p>
</div>
</div>
<div id="source">
<h4>HTML:</h4>
<pre><code id="output"></code></pre>
<h4>Javascript:</h4>
<p>None!</p>
<h4>Installation:</h4>
<p>Just unzip into your web directory and link to the js/css files.</p>
<div id="get">get the code: <a href="http://github.com/andrewplummer/tooltip">github</a><a href="https://nodeload.github.com/andrewplummer/tooltip/zipball/master">zip</a>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="javascripts/tooltip.js"></script>
<script>
var tipped = $('[data-test-title]');
var output = $('#output');
var source = '<div title="" data-tooltip-direction="" data-tooltip-color="" data-tooltip-margin=""></div>';
var direction = 'top';
var color = 'white';
var title = 'some text';
var margin = 10;
var setSource = function() {
var code = source;
code = code.replace(/</g, '<').replace(/>/g, '>');
code = code.replace(/title=".*?"/, '<span class="parameter">title</span>="<span class="attribute">'+ title +'</span>"');
code = code.replace(/data-tooltip-direction=".*?"/, '<span class="parameter">data-tooltip-direction</span>="<span class="attribute">'+ direction +'</span>"');
code = code.replace(/data-tooltip-color=".*?"/, '<span class="parameter">data-tooltip-color</span>="<span class="attribute">'+ color +'</span>"');
code = code.replace(/data-tooltip-margin=".*?"/, '<span class="parameter">data-tooltip-margin</span>="<span class="attribute">'+ margin +'</span>"');
output.html(code);
}
tipped.each(function(){
$(this).attr('title', $(this).data('test-title'));
});
$(document).ready(function(){
$('[name="direction"]').val([direction]).change(function(){
direction = $(this).val();
tipped.data('tooltip-direction', direction);
setSource();
});
$('[name="color"]').val([color]).change(function(){
color = $(this).val();
tipped.data('tooltip-color', color);
setSource();
});
$('[name="margin"]').val(margin).change(function(){
margin = $(this).val();
tipped.data('tooltip-margin', margin);
setSource();
});
$('[name="content"]').val(['title']).change(function(){
var selector = $(this).val() == 'selector';
tipped.each(function(){
var el = $(this);
el.attr('title', selector ? '#target' : el.data('test-title'));
});
title = selector ? '#target' : 'some text';
setSource();
});
setSource();
});
</script>
</body>
</html>