Subversion-Projekte lars-tiefland.cienc

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
9 lars 1
<!DOCTYPE html>
2
<html lang="en">
3
<head>
4
	<title>Tooltipster - The jQuery Tooltip Plugin</title>
5
	<meta charset="UTF-8" />
6
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
7
	<meta name="description" content="Tooltipster is a powerful, flexible jQuery plugin enabling you to easily create clean, HTML5 validated tooltips." />
8
	<meta property="og:title" content="Tooltipster" />
9
	<meta property="og:type" content="website" />
10
	<meta property="og:url" content="index.html" />
11
	<meta property="og:image" content="images/social.jpg" />
12
	<meta property="og:site_name" content="Tooltipster - The jQuery Tooltip Plugin" />
13
	<meta property="og:description" content="Tooltipster is a powerful, flexible jQuery plugin enabling you to easily create clean, HTML5 validated tooltips." />
14
	<html itemscope itemtype="http://schema.org/CreativeWork">
15
	<meta itemprop="name" content="Tooltipster - The jQuery Tooltip Plugin">
16
	<meta itemprop="description" content="Tooltipster is a powerful, flexible jQuery plugin enabling you to easily create clean, HTML5 validated tooltips.">
17
	<meta itemprop="image" content="images/social.jpg">
18
	<link rel="icon" type="image/png" href="images/favicon.png" />
19
	<link rel="image_src" href="images/social.jpg" / >
20
 
21
	<link rel="stylesheet" type="text/css" href="doc/css/reset.css" />
22
	<link rel="stylesheet" type="text/css" href="doc/css/prettify.css" />
23
	<link rel="stylesheet" type="text/css" href="doc/css/style.css" />
24
	<link rel="stylesheet" type="text/css" href="css/tooltipster.css" />
25
	<link rel="stylesheet" type="text/css" href="css/themes/tooltipster-light.css" />
26
	<link rel="stylesheet" type="text/css" href="css/themes/tooltipster-noir.css" />
27
	<link rel="stylesheet" type="text/css" href="css/themes/tooltipster-punk.css" />
28
	<link rel="stylesheet" type="text/css" href="css/themes/tooltipster-shadow.css" />
29
 
30
	<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
31
	<script type="text/javascript" src="doc/js/jquery.jgfeed.js"></script>
32
	<script type="text/javascript" src="doc/js/prettify.js"></script>
33
	<script type="text/javascript" src="doc/js/lang-css.js"></script>
34
	<script type="text/javascript" src="doc/js/scripts.js"></script>
35
	<script type="text/javascript" src="js/jquery.tooltipster.js"></script>
36
 
37
	<!--[if lt IE 9]>
38
		<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
39
	<![endif]-->
40
</head>
41
<body>
42
	<div id="background">
43
		<img src="doc/images/large-background.jpg" />
44
	</div>
45
	<div id="wrapper">
46
		<header>
47
			<div id="social">
48
				<div id="github">
49
					<iframe src="http://ghbtns.com/github-btn.html?user=iamceege&repo=tooltipster&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="100" height="20"></iframe>
50
				</div>
51
				<div id="tweet">
52
					<a href="https://twitter.com/share" class="twitter-share-button" data-text="Tooltipster - A powerful &amp; degradable jQuery tooltip plugin" data-via="iamceege" data-related="iamceege">Tweet</a>
53
					<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
54
				</div>
55
				<div id="gplus">
56
					<g:plusone href="http://calebjacob.com/tooltipster"></g:plusone>
57
				</div>
58
			</div>
59
			<nav>
60
				<ul>
61
					<li><a href="https://github.com/iamceege/tooltipster/archive/master.zip">Download</a></li>
62
					<li><a href="#demos">Demos</a></li>
63
					<li><a href="#getting-started">Get Started</a></li>
64
					<li><a href="#options">Options</a></li>
65
					<li><a href="#advanced">Advanced</a></li>
66
					<li><a href="#themes">Themes</a></li>
67
					<li><a href="#talk">Talk</a></li>
68
				</ul>
69
			</nav>
70
			<select>
71
				<option selected="selected" disabled="disabled">Menu...</option>
72
				<option value="demos">Demos</option>
73
				<option value="getting-started">Get Started</option>
74
				<option value="options">Options</option>
75
				<option value="themes">Themes</option>
76
				<option value="talk">Talk</option>
77
			</select>
78
		</header>
79
		<section id="welcome">
80
			<img src="doc/images/tooltipster.svg" alt="Tooltipster" id="tooltipster" />
81
			<h1>A powerful, flexible jQuery plugin enabling you to easily create semantic, modern tooltips enhanced with the power of CSS.</h1>
82
			<ul id="browser-support">
83
				<li>
84
					<img src="doc/images/browser-chrome.png" alt="Chrome" class="tooltip" title="Chrome Support" />
85
				</li>
86
				<li>
87
					<img src="doc/images/browser-safari.png" alt="Safari" class="tooltip" title="Safari Support" />
88
				</li>
89
				<li>
90
					<img src="doc/images/browser-opera.png" alt="Opera" class="tooltip" title="Opera Support" />
91
				</li>
92
				<li>
93
					<img src="doc/images/browser-firefox.png" alt="FireFox" class="tooltip" title="FireFox Support" />
94
				</li>
95
				<li>
96
					<img src="doc/images/browser-ie.png" alt="Internet Explorer" class="tooltip" title="IE10, IE9, &amp; IE8 Support + Graceful Degradation" />
97
				</li>
98
			</ul>
99
			<div id="download">
100
				<a href="https://github.com/iamceege/tooltipster/archive/master.zip" class="button alt">Download</a> <span style="padding-right: 0.5em;">&amp;</span> <a href="#demos" class="white">get started &rsaquo;</a>
101
			</div>
102
		</section>
103
 
104
		<section id="demos">
105
			<h2>Demos</h2>
106
			<ul>
107
				<li>
108
					<span id="demo-default" title="Hi! This is a tooltip.">Hover</span> Default settings
109
				</li>
110
				<li>
111
					<span id="demo-html">Hover</span> Fixed width, position, &amp; HTML
112
				</li>
113
				<li>
114
					<span id="demo-events" title="Press any key on your keyboard or click anywhere in the page to close this">Click</span> Custom show / hide triggers
115
				</li>
116
				<li>
117
					<span id="demo-touch" title="I would have never been born on a touch device :'(">Hover</span> Disable touch devices
118
				</li>
119
				<li>
120
					<span id="demo-theme" title="Build custom themes and CSS powered animations!">Hover</span> Custom themes &amp; animations
121
				</li>
122
				<li>
123
					<span id="demo-callback" title="This will be populated by AJAX.">Hover</span> Custom callbacks (AJAX <3)
124
				</li>
125
				<li>
126
					<span id="demo-interact" title="Try clicking &lt;a href='http://google.com/' target='_blank'&gt;this link&lt;/a&gt;">Hover</span> Interaction with tooltips
127
				</li>
128
				<li>
129
					<span id="demo-icon" title="Use separate icons to launch your tooltips on either desktops or touch devices - or both!"></span> Attach tooltips to icons
130
				</li>
131
				<li>
132
					<span id="demo-multiple">Hover</span> Multiple tooltips on a single element
133
				</li>
134
				<li>...&amp; more!</li>
135
			</ul>
136
		</section>
137
 
138
		<section id="getting-started">
139
			<h2>Getting Started</h2>
140
			<h3>1. Load jQuery and include Tooltipster's plugin files</h3>
141
			<p>After you <a href="https://github.com/iamceege/tooltipster/archive/master.zip">download Tooltipster</a>, move tooltipster.css and jquery.tooltipster.min.js to your root's CSS and JavaScript directories. Next, load jQuery and include Tooltipster's CSS and JavaScript files inside of your  tags:</p>
142
<pre class="prettyprint">
143
&lt;head&#62;
144
...
145
 
146
    &lt;link rel="stylesheet" type="text/css" href="css/tooltipster.css" /&#62;
147
 
148
    &lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.7.0.min.js"&#62;&lt;/script&#62;
149
    &lt;script type="text/javascript" src="js/jquery.tooltipster.min.js"&#62;&lt;/script&#62;
150
 
151
...
152
&lt;/head&#62;
153
</pre>
154
			<h3>2. Set up your HTML</h3>
155
			<p>In order for Tooltipster to work, we first need to add the <strong>.tooltip</strong> class (or whatever class / means of selection you'd like to use) to whatever element we wish to have a tooltip. Next, we'll set the <strong>title attribute</strong> to whatever we'd like our tooltip to say. Here are a few examples:</p>
156
			<h4>Adding a tooltip to an image:</h4>
157
			<pre class="prettyprint">
158
&lt;img src="my-image.png" class="tooltip" title="This is my image's tooltip message!" /&#62;</pre>
159
			<h4>Adding a tooltip to a link that already has a class:</h4>
160
			<pre class="prettyprint">
161
&lt;a href="http://calebjacob.com" class="ketchup tooltip" title="This is my link's tooltip message!"&#62;Link&lt;/a&#62;</pre>
162
			<h4>Adding a tooltip to a div:</h4>
163
			<pre class="prettyprint">
164
&lt;div class="tooltip" title="This is my div's tooltip message!"&#62;
165
    This div has a tooltip when you hover over it!
166
&lt;/div&#62;</pre>
167
 
168
			<h3>3. Activate Tooltipster</h3>
169
			<p>The last thing we have to do is activate the plugin. To do this, add the following script right before your closing &lt;/head&#62; tag (using whatever selector you'd like - in this case we're using the <strong>.tooltip</strong> class):</p>
170
			<pre class="prettyprint">
171
&lt;head&#62;
172
 
173
    ...
174
 
175
    &lt;script&#62;
176
        $(document).ready(function() {
177
            $('.tooltip').tooltipster();
178
        });
179
    &lt;/script&#62;
180
&lt;/head&#62;</pre>
181
 
182
			<h3><a name="further">4. Taking It a Step Further</a></h3>
183
			<h4>Using HTML tags inside your tooltips</h4>
184
			<p>Tooltipster allows you to use any HTML markup you can think of inside your tooltips. This means you can insert things like images and text formatting tags. To achieve this, the recommended method is a little different : provide your content as a jQuery object in the script rather than in the title attribute :</p>
185
			<pre class="prettyprint">
186
&lt;head&#62;
187
 
188
    ...
189
 
190
    &lt;script&#62;
191
        $(document).ready(function() {
192
            $('#my-tooltip').tooltipster({
193
                content: $('&lt;span&gt;&lt;img src="my-image.png" /&gt; &lt;strong&gt;This text is in bold case !&lt;/strong&gt;&lt;/span&gt;')
194
            });
195
        });
196
    &lt;/script&#62;
197
&lt;/head&#62;
198
&lt;body&#62;
199
 
200
    &lt;div id="my-tooltip"&#62;
201
        This div has a tooltip with HTML when you hover over it!
202
    &lt;/div&#62;
203
 
204
&lt;/body&#62;</pre>
205
 
206
			<p>Another (less recommended) way of achieving this is to put encoded HTML markup directly in your title attribute and set the 'contentAsHTML' option to 'true'. In all cases, make sure you have tight control over the content you wish to display in the tooltip, as unwanted &lt;script&gt; or &lt;iframe&gt; tags for example would be a serious security issue for your website.</p>
207
 
208
			<pre class="prettyprint">
209
&lt;head&#62;
210
 
211
    ...
212
 
213
    &lt;script&#62;
214
        $(document).ready(function() {
215
            $('.tooltip').tooltipster({
216
                contentAsHTML: true
217
            });
218
        });
219
    &lt;/script&#62;
220
&lt;/head&#62;
221
&lt;body&#62;
222
 
223
    &lt;div class="tooltip" title="&amp;lt;img src=&amp;quot;my-image.png&amp;quot; /&amp;gt; &amp;lt;strong&amp;gt; This text is in bold case !&amp;lt;/strong&amp;gt;"&gt;
224
        This div has a tooltip with HTML when you hover over it!
225
    &lt;/div&#62;
226
 
227
&lt;/body&#62;</pre>
228
 
229
			<h4>Customizing Your Tooltipster's Style</h4>
230
			<p>The style of your Tooltipsters can be easily changed by editing/overriding the default Tooltipster theme, located in the <strong>css/tooltipster.css</strong> file.</p>
231
			<p>Tooltipster is also packaged with 4 alternative themes to choose from. They are demonstrated at the bottom of this page. To use a theme, just include its css file (located in the css/themes folder) in your page and specify its name in Tooltipster's settings :</p>
232
			<pre class="prettyprint">
233
$('.tooltip').tooltipster({
234
    theme: 'tooltipster-noir'
235
});</pre>
236
			<p>And of course, you also have the option to create a brand new theme to suit your needs. To do this, start with the example below and add your flair. When you are done, include and specify your theme just like you would for one of Tooltipster's existing themes.</p>
237
			<pre class="prettyprint lang-css">
238
/* This is how you would create a theme called "my-custom-theme": */
239
 
240
.my-custom-theme {
241
	border-radius: 5px;
242
	border: 2px solid #000;
243
	background: #4c4c4c;
244
	color: #fff;
245
}
246
/* Use this next selector to style things like font-size and line-height: */
247
.my-custom-theme .tooltipster-content {
248
	font-family: Arial, sans-serif;
249
	font-size: 14px;
250
	line-height: 16px;
251
	padding: 8px 10px;
252
}</pre>
253
 
254
			<h4>Customizing Tooltipster's Functionality</h4>
255
			<p>Tooltipster's options gives you a wide range of variables to tweak your tooltip to your heart's content. To learn more about all of the options, <a href="#options">read the Options section</a>. Here's just a few of the things you can play with:</p>
256
			<pre class="prettyprint">
257
$('.tooltip').tooltipster({
258
   animation: 'fade',
259
   delay: 200,
260
   theme: 'tooltipster-default',
261
   touchDevices: false,
262
   trigger: 'hover'
263
});</pre>
264
		</section>
265
 
266
		<section id="options">
267
			<h2>Options</h2>
268
			<table border="0" cellpadding="0" cellspacing="0">
269
				<tr>
270
					<td><h4>animation</h4></td>
271
					<td>fade, grow, swing, slide, fall</td>
272
					<td>Determines how the tooltip will animate in and out. Feel free to modify or create custom transitions in the tooltipster.css file. In IE9 and 8, all animations default to a JavaScript generated, fade animation. <strong>Default: 'fade'</strong></td>
273
				</tr>
274
				<tr>
275
					<td><h4>arrow</h4></td>
276
					<td>boolean</td>
277
					<td>Adds the "speech bubble arrow" to the tooltip. <strong>Default: true</strong></td>
278
				</tr>
279
				<tr>
280
					<td><h4>arrowColor</h4></td>
281
					<td>hex code / rgb</td>
282
					<td>Select a specific color for the "speech bubble arrow". <strong>Default: will inherit the tooltip's background color</strong></td>
283
				</tr>
284
				<tr>
285
					<td><h4>autoClose</h4></td>
286
					<td>boolean</td>
287
					<td>If autoClose is set to false, the tooltip will never close unless you call the 'hide' method yourself. <strong>Default: true</strong></td>
288
				</tr>
289
				<tr>
290
					<td><h4>content</h4></td>
291
					<td>string, jQuery object</td>
292
					<td>If set, this will override the content of the tooltip. <strong>Default: null</strong></td>
293
				</tr>
294
				<tr>
295
					<td><h4>contentAsHTML</h4></td>
296
					<td>boolean</td>
297
					<td>If the content of the tooltip is provided as a string, it is displayed as plain text by default. If this content should actually be interpreted as HTML, set this option to true. <strong>Default: false</strong></td>
298
				</tr>
299
				<tr>
300
					<td><h4>contentCloning</h4></td>
301
					<td>boolean</td>
302
					<td>If you provide a jQuery object to the 'content' option, this sets if it is a clone of this object that should actually be used. <strong>Default: true</strong></td>
303
				</tr>
304
				<tr>
305
					<td><h4>debug</h4></td>
306
					<td>boolean</td>
307
					<td>Tooltipster logs notices into the console when you're doing something you ideally shouldn't be doing. Set to false to disable logging. <strong>Default: true</strong></td>
308
				</tr>
309
				<tr>
310
					<td><h4>delay</h4></td>
311
					<td>integer</td>
312
					<td>Delay how long it takes (in milliseconds) for the tooltip to start animating in. <strong>Default: 200</strong></td>
313
				</tr>
314
				<tr>
315
					<td><h4>minWidth</h4></td>
316
					<td>integer</td>
317
					<td>Set a minimum width for the tooltip. <strong>Default: 0 (auto width)</strong></td>
318
				</tr>
319
				<tr>
320
					<td><h4>maxWidth</h4></td>
321
					<td>integer</td>
322
					<td>Set a maximum width for the tooltip. <strong>Default: null (no max width)</strong></td>
323
				</tr>
324
				<tr>
325
					<td><h4>functionInit</h4></td>
326
					<td>function</td>
327
					<td>Create a custom function to be fired only once at instantiation. If the function returns a value, this value will become the content of the tooltip. See the <a href="#advanced">advanced section</a> to learn more. <strong>Default: function(origin, content) {}</strong></td>
328
				</tr>
329
				<tr>
330
					<td><h4>functionBefore</h4></td>
331
					<td>function</td>
332
					<td>Create a custom function to be fired before the tooltip opens. This function may prevent or hold off the opening. See the <a href="#advanced">advanced section</a> to learn more. <strong>Default: function(origin, continueTooltip) { continueTooltip(); }</strong></td>
333
				</tr>
334
				<tr>
335
					<td><h4>functionReady</h4></td>
336
					<td>function</td>
337
					<td>Create a custom function to be fired when the tooltip and its contents have been added to the DOM. <strong>Default: function(origin, tooltip) {}</strong></td>
338
				</tr>
339
				<tr>
340
					<td><h4>functionAfter</h4></td>
341
					<td>function</td>
342
					<td>Create a custom function to be fired once the tooltip has been closed and removed from the DOM. <strong>Default: function(origin) {}</strong></td>
343
				</tr>
344
				<tr>
345
					<td><h4>hideOnClick</h4></td>
346
					<td>boolean</td>
347
					<td>If true, the tooltip will close if its origin is clicked. This option only applies when 'trigger' is 'hover' and 'autoClose' is false. <strong>Default: false</strong></td>
348
				</tr>
349
				<tr>
350
					<td><h4>icon</h4></td>
351
					<td>string, jQuery object</td>
352
					<td>If using the iconDesktop or iconTouch options, this sets the content for your icon. <strong>Default: '(?)'</strong></td>
353
				</tr>
354
				<tr>
355
					<td><h4>iconCloning</h4></td>
356
					<td>boolean</td>
357
					<td>If you provide a jQuery object to the 'icon' option, this sets if it is a clone of this object that should actually be used. <strong>Default: true</strong></td>
358
				</tr>
359
				<tr>
360
					<td><h4>iconDesktop</h4></td>
361
					<td>boolean</td>
362
					<td>Generate an icon next to your content that is responsible for activating the tooltip on non-touch devices. <strong>Default: false</strong></td>
363
				</tr>
364
				<tr>
365
					<td><h4>iconTheme</h4></td>
366
					<td>CSS class</td>
367
					<td>If using the iconDesktop or iconTouch options, this sets the class on the icon (used to style the icon). <strong>Default: 'tooltipster-icon'</strong></td>
368
				</tr>
369
				<tr>
370
					<td><h4>iconTouch</h4></td>
371
					<td>boolean</td>
372
					<td>Generate an icon next to your content that is responsible for activating the tooltip on touch devices (tablets, phones, etc). <strong>Default: false</strong></td>
373
				</tr>
374
				<tr>
375
					<td><h4>interactive</h4></td>
376
					<td>boolean</td>
377
					<td>Give users the possibility to interact with the tooltip. Unless autoClose is set to false, the tooltip will still close if the user moves away from or clicks out of the tooltip. <strong>Default: false</strong></td>
378
				</tr>
379
				<tr>
380
					<td><h4>interactiveTolerance</h4></td>
381
					<td>integer</td>
382
					<td>If the tooltip is interactive and activated by a hover event, set the amount of time (milliseconds) allowed for a user to hover off of the tooltip activator (origin) on to the tooltip itself - keeping the tooltip from closing. <strong>Default: 350</strong></td>
383
				</tr>
384
				<tr>
385
					<td><h4>multiple</h4></td>
386
					<td>boolean</td>
387
					<td>Allows you to put multiple tooltips on a single element. Read further instructions down this page. <strong>Default: false</strong></td>
388
				</tr>
389
				<tr>
390
					<td><h4>offsetX</h4></td>
391
					<td>integer</td>
392
					<td>Offsets the tooltip (in pixels) farther left/right from the origin. <strong>Default: 0</strong></td>
393
				</tr>
394
				<tr>
395
					<td><h4>offsetY</h4></td>
396
					<td>integer</td>
397
					<td>Offsets the tooltip (in pixels) farther up/down from the origin. <strong>Default: 0</strong></td>
398
				</tr>
399
				<tr>
400
					<td><h4>onlyOne</h4></td>
401
					<td>boolean</td>
402
					<td>If true, only one tooltip will be allowed to be active at a time. Non-autoclosing tooltips will not be closed though. <strong>Default: false</strong></td>
403
				</tr>
404
				<tr>
405
					<td><h4>position</h4></td>
406
					<td>right, left, top, top-right, top-left, bottom, bottom-right, bottom-left</td>
407
					<td>Set the position of the tooltip. <strong>Default: 'top'</strong></td>
408
				</tr>
409
				<tr>
410
					<td><h4>positionTracker</h4></td>
411
					<td>boolean</td>
412
					<td>Will reposition the tooltip if the origin moves. As this option may have an impact on performance, we suggest you enable it only if you need to. <strong>Default: false</strong></td>
413
				</tr>
414
				<tr>
415
					<td><h4>positionTrackerCallback</h4></td>
416
					<td>function</td>
417
					<td>Called after the tooltip has been repositioned by the position tracker (if enabled). <strong>Default:</strong> A function that will close the tooltip if the trigger is 'hover' and autoClose is false.</td>
418
				</tr>
419
				<tr>
420
					<td><h4>restoration</h4></td>
421
					<td>'none', 'previous' or 'current'</td>
422
					<td>Specify if a TITLE attribute should be restored on the HTML element after a call to the 'destroy' method. This attribute may be omitted, or be restored with the value that existed before Tooltipster was initialized, or be restored with the stringified value of the current content. Note: in case of multiple tooltips on a single element, only the last destroyed tooltip may trigger a restoration. <strong>Default: 'current'</strong></td>
423
				</tr>
424
				<tr>
425
					<td><h4>speed</h4></td>
426
					<td>integer</td>
427
					<td>Set the speed of the animation. <strong>Default: 350</strong></td>
428
				</tr>
429
				<tr>
430
					<td><h4>timer</h4></td>
431
					<td>integer</td>
432
					<td>How long the tooltip should be allowed to live before closing. <strong>Default: 0 (disabled)</strong></td>
433
				</tr>
434
				<tr>
435
					<td><h4>theme</h4></td>
436
					<td>CSS class</td>
437
					<td>Set the theme used for your tooltip. <strong>Default: 'tooltipster-default'</strong></td>
438
				</tr>
439
				<tr>
440
					<td><h4>touchDevices</h4></td>
441
					<td>boolean</td>
442
					<td>If set to false, tooltips will not show on pure-touch devices, unless you open them yourself with the 'show' method. Touch gestures on devices which also have a mouse will still open the tooltips though. <strong>Default: true</strong></td>
443
				</tr>
444
				<tr>
445
					<td><h4>trigger</h4></td>
446
					<td>hover, click, custom</td>
447
					<td>Set how tooltips should be activated and closed. See the <a href="#advanced">advanced section</a> to learn how to build custom triggers. <strong>Default: 'hover'</strong></td>
448
				</tr>
449
				<tr>
450
					<td><h4>updateAnimation</h4></td>
451
					<td>boolean</td>
452
					<td>If a tooltip is open while its content is updated, play a subtle animation when the content changes. <strong>Default: true</strong></td>
453
				</tr>
454
			</table>
455
		</section>
456
 
457
		<section id="advanced">
458
			<h2>Advanced</h2>
459
 
460
			<a name="api"></a>
461
			<h3>The awesomesauce Tooltipster API</h3>
462
			<p>The Tooltipster API was created to be as flexible and easy to use as possible (thanks to <a href="https://github.com/glebtv">glebtv</a> for the inspiration). The API allows you to create custom triggers, update tooltip content on the fly (whether the tooltip is currently open or not), destroy Tooltipster functionality if needed, and reposition tooltips for unique use cases.</p>
463
			<p>Here is a quick look at all of the API methods:</p>
464
			<pre class="prettyprint">
465
// set default options for all future tooltip instantiations
466
$.fn.tooltipster('setDefaults', {
467
  position: 'bottom'
468
});
469
 
470
// show a tooltip (the 'callback' argument is optional)
471
$(...).tooltipster('show', callback);
472
 
473
// hide a tooltip (the 'callback' argument is optional)
474
$(...).tooltipster('hide', callback);
475
 
476
// temporarily disable a tooltip from being able to open
477
$(...).tooltipster('disable');
478
 
479
// if a tooltip was disabled from opening, reenable its previous functionality
480
$(...).tooltipster('enable');
481
 
482
// hide and destroy tooltip functionality
483
$(...).tooltipster('destroy');
484
 
485
// return a tooltip's current content (if selector contains multiple origins, only the value of the first will be returned)
486
$(...).tooltipster('content');
487
 
488
// update tooltip content
489
$(...).tooltipster('content', myNewContent);
490
 
491
// get the value of an option
492
$(...).tooltipster('option', optionName);
493
 
494
// set the value of an option (use at your own risk, we do not provide support for issues you may encounter when using this method)
495
$(...).tooltipster('option', optionName, optionValue);
496
 
497
// reposition and resize the tooltip
498
$(...).tooltipster('reposition');
499
 
500
// return the HTML root element of the tooltip
501
$(...).tooltipster('elementTooltip');
502
 
503
// return the HTML root element of the icon if there is one, 'undefined' otherwise
504
$(...).tooltipster('elementIcon');</pre>
505
 
506
			<a name="ajax"></a>
507
			<h3>Using AJAX to generate your tooltip content</h3>
508
			<p>Tooltipster gives you the ability to fire a custom synchronous or asynchronous function everytime before the tooltip launches (<a href="#functionBeforeExample">functionBefore</a>) or just once upon instantiation (<a href="#functionInitExample">functionInit</a>). One great use for this is to grab dynamic content for your tooltips via AJAX.</p>
509
			<p id="functionBeforeExample">Here is an example of using functionBefore() asynchronously to replace a loading notification with our AJAX call. Once the content has been retrieved and updated, we'll take advantage of setting $.data() to keep our content cached for the next time the tooltip is opened:</p>
510
			<pre class="prettyprint">
511
$('.tooltip').tooltipster({
512
    content: 'Loading...',
513
    functionBefore: function(origin, continueTooltip) {
514
 
515
        // we'll make this function asynchronous and allow the tooltip to go ahead and show the loading notification while fetching our data
516
        continueTooltip();
517
 
518
        // next, we want to check if our data has already been cached
519
        if (origin.data('ajax') !== 'cached') {
520
            $.ajax({
521
                type: 'POST',
522
                url: 'example.php',
523
                success: function(data) {
524
                    // update our tooltip content with our returned data and cache it
525
                    origin.tooltipster('content', data).data('ajax', 'cached');
526
                }
527
            });
528
        }
529
    }
530
});</pre>
531
			<p id="functionInitExample">However, maybe you just need to make one call and only need it to fire once instead of everytime the tooltip opens. This is where you could use functionInit(). This function will fire only once - right at the beginning of the instantiation process. You'll have the ability to do things like check the current content and set new content. Since the fancy API methods for returning and setting the value aren't instantiated yet, the way we go about this is a little different than functionBefore():
532
			<pre class="prettyprint">
533
$('.tooltip').tooltipster({
534
    functionInit: function(origin, content) {
535
 
536
        if (content === 'This is bad content') {
537
 
538
            // when the request has finished loading, we will change the tooltip's content
539
            $.ajax({
540
                type: 'POST',
541
                url: 'example.php',
542
                success: function(data) {
543
                    origin.tooltipster('content', 'New content has been loaded : ' + data);
544
                }
545
            });
546
 
547
            // this returned string will overwrite the content of the tooltip for the time being
548
            return 'Wait while we load new content...';
549
        }
550
        else {
551
            // return nothing : the initialization continues normally with its content unchanged.
552
        }
553
    }
554
});</pre>
555
 
556
			<a name="apishow"></a>
557
			<h3>Manually show and hide a tooltip</h3>
558
			<p>By default and according to the 'trigger' option, Tooltipster automatically shows tooltips upon users' mouse clicks or mouse hovering (or their touch-gesture equivalents). In addition to this, you may also manually open or close a tooltip at anytime with a simple javascript command.</p>
559
			<p>To achieve this, Tooltipster has the 'show' and 'hide' methods. Both of them may receive an optional 'callback' parameter, which represents a function you'd like to call when the tooltip is done animating.</p>
560
			<p>Here's an example of how you could launch a specific tooltip on page load and close it when any key on your keyboard is pressed. This will still preserve the default hover trigger.</p>
561
			<pre class="prettyprint">
562
&lt;span class="tooltip" id="example" title="My tooltip content"&#62;Example&lt;/span&#62;
563
</pre>
564
			<pre class="prettyprint">
565
$(document).ready(function() {
566
 
567
   // first on page load, initiate the Tooltipster plugin
568
   $('.tooltip').tooltipster();
569
 
570
   // then immediately show the tooltip
571
   $('#example').tooltipster('show');
572
 
573
   // as soon as a key is pressed on the keyboard, hide the tooltip.
574
   $(window).keypress(function() {
575
      $('#example').tooltipster('hide');
576
   });
577
});
578
</pre>
579
			<p>You may also provide a function as the callback parameter of the show/hide methods. The callback functions are called in the context of the tooltipstered element. If the tooltip is already in the state you are asking for (open/closed), the callback is executed immediately. Please note that if the show/hide action is somehow cancelled before it has completed its animation, the callback function will never be called.</p>
580
			<pre class="prettyprint">
581
$(document).ready(function() {
582
 
583
   $('.tooltip').tooltipster();
584
 
585
   $('#example').tooltipster('show', function() {
586
       alert('The tooltip is now fully open. The content is: ' + this.tooltipster('content'));
587
   });
588
 
589
   $(window).keypress(function() {
590
      $('#example').tooltipster('hide', function() {
591
         alert('The tooltip is now fully closed');
592
      });
593
   });
594
});
595
</pre>
596
 
597
			<a name="apicontent"></a>
598
			<h3>Updating a tooltip's content</h3>
599
			<p>It's easy as pie to update a tooltip's content - whether it's open or closed. Depending on your selector, you can update multiple tooltips at once or just one:</p>
600
			<pre class="prettyprint">
601
$('#my-special-element').tooltipster('content', 'My new content');</pre>
602
			<p>By default, Tooltipster will play a subtle animation when the content changes. To tweak the animation, check out the '.tooltipster-content-changing' class in your tooltipster.css file. It's important to note that only CSS transforms will be animated. To disable this animation, set updateAnimation to false.</p>
603
 
604
			<a name="multiple"></a>
605
			<h3>Using several tooltips on a single element</h3>
606
			<p>Several independant tooltips can be set on a single element, each one having its own triggers and options. Just set the 'multiple' option to true when you initialize your tooltip. This will only change two things that you might want to be aware of.</p>
607
			<p>Firstly, the instantiation call will now return an array of Tooltipster objects generated by the call, instead of the tooltipped jQuery-wrapped elements.</p>
608
			<p>Secondly, you will have to use the Tooltipster object of a tooltip to make any API method calls on it. All methods documented on this page remain available, only the way to call them changes.</p>
609
 
610
			<pre class="prettyprint">
611
// create a first tooltip as usual. The multiple option is actually optional for the first tooltip
612
$('#my-element').tooltipster({
613
	content: 'My first tooltip',
614
	position: 'top'
615
});
616
 
617
// instantiate a second tooltip and keep the returned Tooltipster objects array for later use of the API
618
var tooltipsterObjects = $('#my-element').tooltipster({
619
	// don't forget to provide content here as the 1st tooltip will have deleted the original title attribute of the element
620
	content: 'My second tooltip',
621
	multiple: true,
622
	position: 'bottom'
623
});
624
 
625
// since the jQuery selector matches only one element, the array will contain only one Tooltipster object.
626
// Otherwise the array would contain one object for each matched element, in the same order as them
627
var tooltip2 = tooltipsterObjects[0];
628
 
629
// use this Tooltipster object to make any API method call on the tooltip
630
tooltip2.content('New content for my second tooltip').show();
631
// all documented methods can be called that way
632
var element = tooltip2.elementTooltip();
633
 
634
// calling the API methods in the usual way only affects the first tooltip that was created on the element
635
$('#my-element').tooltipster('content', 'New content for my first tooltip')
636
</pre>
637
 
638
<pre class="prettyprint">
639
// You may use the 'multiple' option on the first tooltip as well, it will return an array of objects too
640
var tooltipsterObjects = $('#my-element').tooltipster({
641
	content: 'My first tooltip',
642
	multiple: true
643
});
644
 
645
// this is also a way to call API methods on the first tooltip
646
var tooltip1 = tooltipsterObjects[0];
647
tooltip1.content('New content for my first tooltip').show();</pre>
648
 
649
<p>Note : if you have multiple tooltips and destroy them, only the last destroyed tooltip will transfer its content back to the title attribute of the tooltipped element.</p>
650
 
651
			<a name="accessibility"></a>
652
			<h3>Make tooltips accessible to persons with disabilities</h3>
653
			<p>The W3C issued a recommendation to make websites more accessible to persons with disabilities. This recommendation is known as WAI-ARIA (or simply ARIA), which stands for Web Accessibility Initiative - Accessible Rich Internet Applications.</p>
654
			<p>Accessible tooltips can be powered by Tooltipster. To do this, one solution is to actually manipulate in parallel two tooltips which will share the same content :<br />
655
				- the ARIA tooltip, which is invisible on the screen but readable by ARIA-compatible software<br />
656
				- the Tooltipster tooltip, which is visible on the screen but does not appear as an ARIA-compatible element
657
			</p>
658
			<p>A basic example : imagine that we want to put a tooltip on a text input field. As for the HTML part, you would write :</p>
659
			<pre class="prettyprint">
660
&lt;input id="myfield" type="text" aria-describedby="myfield_description" /&gt;
661
&lt;span id="myfield_description" role="tooltip"&gt;Please insert your name here&lt;/span&gt;
662
</pre>
663
			<p>As for the CSS part, write this :</p>
664
			<pre class="prettyprint">
665
#myfield_description {
666
	display: none;
667
}
668
</pre>
669
			<p>And finally, you could initiate Tooltipster like this :</p>
670
			<pre class="prettyprint">
671
$('#myfield').tooltipster({
672
    functionInit: function(){
673
        return $('#myfield_description').html();
674
    },
675
    functionReady: function(){
676
        $('#myfield_description').attr('aria-hidden', false);
677
    },
678
    functionAfter: function(){
679
        $('#myfield_description').attr('aria-hidden', true);
680
    }
681
});
682
 
683
// if in addition you want the tooltip to be displayed when the field gets focus, add these custom triggers :
684
$('#myfield')
685
    .focus(function(){
686
        $(this).tooltipster('show');
687
    })
688
    .blur(function(){
689
        $(this).tooltipster('hide');
690
    });
691
</pre>
692
 
693
			<h3>Community submitted use cases</h3>
694
			<p><a href="http://stackoverflow.com/questions/14741688/how-to-display-messages-from-jquery-validate-plugin-inside-of-tooltipster-toolti">Using Tooltipster alongside jQuery Validate</a> by <a href="https://github.com/sparky672">sparky672</a></p>
695
			<p>Did you do something awesome with Tooltipster? <a href="#talk">Tell me</a> and I'll post it up here!</p>
696
		</section>
697
 
698
		<section id="themes">
699
			<h2>Themes</h2>
700
			<p>Tired of the same old? Four other rocking themes are available for your tooltips, and you can always create yours ! Share them with us on GitHub !</p>
701
			<div class="themes">
702
				<span class="tooltipster-default-preview tooltip" title="The default theme" target="_blank">Default</span>
703
				<span class="tooltipster-light-preview" title="Light and frisky!" target="_blank">Light</span>
704
				<span class="tooltipster-punk-preview" title="I will not conform to your old fart ways!" target="_blank">Punk</span>
705
				<span class="tooltipster-noir-preview" title="Hipsterific!" target="_blank">Noir</span>
706
				<span class="tooltipster-shadow-preview" title="Check out my shadow" target="_blank">Shadow</span>
707
			</div>
708
		</section>
709
 
710
		<section id="talk">
711
			<h2>Talk</h2>
712
			<h3>Share thoughts, questions, &amp; bugs!</h3>
713
			<p>Head on over to Tooltipster's issue tracker on GitHub: <a href="https://github.com/iamceege/tooltipster/issues">https://github.com/iamceege/tooltipster/issues</a></p>
714
			<p>Before opening a new issue, please be sure to search through the backlog to see if your question or bug has been / is being resolved. Thank you! :)</p>
715
		</section>
716
 
717
		<footer>
718
			Developed and maintained by <a href="https://plus.google.com/116532683962309427991?rel=author" class="white">Caleb Jacob</a> and <a href="https://github.com/louisameline" class="white">Louis Ameline</a> under the <a href="http://opensource.org/licenses/MIT" class="white">MIT license</a>
719
		</footer>
720
	</div>
721
 
722
	<div id="fb-root"></div>
723
	<script type="text/javascript">
724
	  (function() {
725
	    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
726
	    po.src = '//apis.google.com/js/plusone.js';
727
	    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
728
	  })();
729
  	</script>
730
</body>
731
</html>