Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2014
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 2.56 KB | None | 0 0
  1. <!doctype html>
  2. <html lang="en">
  3. <title>snote example</title>
  4. <meta charset="utf-8">
  5.  
  6. <!-- Placed in the public domain by Roger Hågensen. -->
  7. <style>
  8. .snote
  9. {
  10.     width: 1em;
  11.     height: 1em;
  12.     background-image: url('http://icons.iconarchive.com/icons/visualpharm/must-have/256/Information-icon.png');
  13.     background-size: auto 1em;
  14.     background-repeat: no-repeat;
  15.     display: none;
  16.     cursor: help
  17. }
  18.  
  19. .snote_tip
  20. {
  21.     display: block;
  22.     visibility: hidden;
  23.     position: absolute;
  24.     width: 16em;
  25.     height: 3em;
  26.     margin-left: -8em;
  27.     margin-top: -4em;
  28.     padding: 0.5em;
  29.     overflow: auto;
  30.     background: #cccccc;
  31.     color: #000000;
  32.     border: 0.15em solid #000000;
  33.     border-radius: 0.25em;  
  34.     box-shadow: 0.25em 0.25em 0.25em #7f7f7f;
  35. }
  36.  
  37. .snote_tip:hover
  38. {
  39.     cursor: default;
  40. }
  41. </style>
  42.  
  43. <script>
  44.     //call this function once the page has loaded
  45.     window.addEventListener('load', snote_init, false);
  46.  
  47.     //this function will add a span with snote_tip class where a span with the snote class is used, this reduces the html needed and makes writing notes so much simpler/cleaner.
  48.     function snote_init()
  49.     {
  50.         var snote_elements = document.getElementsByClassName('snote');
  51.         for (var i = 0; i < snote_elements.length; i += 1)
  52.         {
  53.             (function(i)
  54.             {
  55.                 var snote_element = snote_elements[i];
  56.  
  57.                 snote_element.innerHTML = '<span class="snote_tip" id="snote_' + i + '">' + snote_element.innerHTML + '</span>';
  58.                 snote_element.style.display = 'inline-block';
  59.                 snote_element.addEventListener ("mouseup", function () {snote_show(i)}, false);
  60.             })(i);
  61.         }
  62.     }
  63.  
  64.     function snote_show(arg)
  65.     {
  66.         var snote_tip = document.getElementById('snote_' + arg);
  67.         if (snote_tip.style.visibility == 'visible')
  68.         {
  69.             snote_tip.style.visibility = 'hidden';
  70.         }
  71.         else
  72.         {
  73.             snote_tip.style.visibility = 'visible';
  74.         }
  75.     };
  76. </script>
  77.  
  78. <body>
  79.  
  80. <br><br>
  81. <p>But the thing is this: I really, REALLY like annotations. I'm talking about the little numbers that pop up in a post <span class="snote">Like this one, for example.<br><br>And it is really long, but that is not really a problem.<br><br>This text could easily just go on and on.</span>. I ran into them on the <a href="http://what-if.xkcd.com/">XKCD What-If blog</a>.  They're great for expanding on a side-thought without cluttering up the main body of the article. They're handy when writing faux-technical articles that require lots of footnotes to save me from Death By Nitpick. They're great for jokes <span class="snote">Since you can hide the <a href="http://en.wikipedia.org/wiki/Punch_line">punchline</a>.</span>. </p>
  82.  
  83. </body>
  84. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement