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