1 | <!doctype html> |
---|
2 | <html lang="en"> |
---|
3 | <head> |
---|
4 | <meta charset="utf-8"> |
---|
5 | <title>jQuery UI Tooltip - Custom content</title> |
---|
6 | <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> |
---|
7 | <script src="../../jquery-1.8.2.js"></script> |
---|
8 | <script src="../../ui/jquery.ui.core.js"></script> |
---|
9 | <script src="../../ui/jquery.ui.widget.js"></script> |
---|
10 | <script src="../../ui/jquery.ui.position.js"></script> |
---|
11 | <script src="../../ui/jquery.ui.tooltip.js"></script> |
---|
12 | <link rel="stylesheet" href="../demos.css"> |
---|
13 | <style> |
---|
14 | .photo { |
---|
15 | width: 300px; |
---|
16 | text-align: center; |
---|
17 | } |
---|
18 | .photo .ui-widget-header { |
---|
19 | margin: 1em 0; |
---|
20 | } |
---|
21 | .map { |
---|
22 | width: 350px; |
---|
23 | height: 350px; |
---|
24 | } |
---|
25 | </style> |
---|
26 | <script> |
---|
27 | $(function() { |
---|
28 | $( document ).tooltip({ |
---|
29 | items: "img, [data-geo], [title]", |
---|
30 | content: function() { |
---|
31 | var element = $( this ); |
---|
32 | if ( element.is( "[data-geo]" ) ) { |
---|
33 | var text = element.text(); |
---|
34 | return "<img class='map' alt='" + text + |
---|
35 | "' src='http://maps.google.com/maps/api/staticmap?" + |
---|
36 | "zoom=11&size=350x350&maptype=terrain&sensor=false¢er=" + |
---|
37 | text + "'>"; |
---|
38 | } |
---|
39 | if ( element.is( "[title]" ) ) { |
---|
40 | return element.attr( "title" ); |
---|
41 | } |
---|
42 | if ( element.is( "img" ) ) { |
---|
43 | return element.attr( "alt" ); |
---|
44 | } |
---|
45 | } |
---|
46 | }); |
---|
47 | }); |
---|
48 | </script> |
---|
49 | </head> |
---|
50 | <body> |
---|
51 | |
---|
52 | <div class="ui-widget photo"> |
---|
53 | <div class="ui-widget-header ui-corner-all"> |
---|
54 | <h2>St. Stephen's Cathedral</h2> |
---|
55 | <h3><a href="http://maps.google.com/maps?q=vienna,+austria&z=11" data-geo>Vienna, Austria</a></h3> |
---|
56 | </div> |
---|
57 | <a href="http://en.wikipedia.org/wiki/File:Wien_Stefansdom_DSC02656.JPG"> |
---|
58 | <img src="images/st-stephens.jpg" alt="St. Stephen's Cathedral" class="ui-corner-all"> |
---|
59 | </a> |
---|
60 | </div> |
---|
61 | |
---|
62 | <div class="ui-widget photo"> |
---|
63 | <div class="ui-widget-header ui-corner-all"> |
---|
64 | <h2>Tower Bridge</h2> |
---|
65 | <h3><a href="http://maps.google.com/maps?q=london,+england&z=11" data-geo>London, England</a></h3> |
---|
66 | </div> |
---|
67 | <a href="http://en.wikipedia.org/wiki/File:Tower_bridge_London_Twilight_-_November_2006.jpg"> |
---|
68 | <img src="images/tower-bridge.jpg" alt="Tower Bridge" class="ui-corner-all"> |
---|
69 | </a> |
---|
70 | </div> |
---|
71 | |
---|
72 | <p>All images are part of <a href="http://commons.wikimedia.org/wiki/Main_Page">Wikimedia Commons</a> |
---|
73 | and are licensed under <a href="http://creativecommons.org/licenses/by-sa/3.0/deed.en" title="Creative Commons Attribution-ShareAlike 3.0">CC BY-SA 3.0</a> by the copyright holder.</p> |
---|
74 | |
---|
75 | <div class="demo-description"> |
---|
76 | <p>Shows how to combine different event delegated tooltips into a single instance, by customizing the items and content options.</p> |
---|
77 | <p>We realize you may want to interact with the map tooltips. This is a planned feature for a future version.</p> |
---|
78 | </div> |
---|
79 | </body> |
---|
80 | </html> |
---|