index.html 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <!doctype html>
  2. <head>
  3. <title>Starrr, for jQuery</title>
  4. <meta name="description" content="">
  5. <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
  6. <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.2.0/css/font-awesome.min.css">
  7. <link rel="stylesheet" href="dist/starrr.css">
  8. <style type='text/css'>
  9. img.ribbon {
  10. position: fixed;
  11. z-index: 1;
  12. top: 0;
  13. right: 0;
  14. border: 0;
  15. cursor: pointer; }
  16. .container {
  17. margin-top: 60px;
  18. text-align: center;
  19. max-width: 450px; }
  20. input {
  21. width: 30px;
  22. margin: 10px 0;
  23. }
  24. </style>
  25. </head>
  26. <body>
  27. <a href="https://github.com/dobtco/starrr">
  28. <img class="ribbon" src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub">
  29. </a>
  30. <div class="container">
  31. <h3>Starrr</h3>
  32. <h5>Click to rate:</h5>
  33. <div class='starrr' id='star1'></div>
  34. <div>&nbsp;
  35. <span class='your-choice-was' style='display: none;'>
  36. Your rating was <span class='choice'></span>.
  37. </span>
  38. </div>
  39. <h5>Advanced:</h5>
  40. <div class='starrr' id='star2'></div>
  41. <br />
  42. <input type='text' name='rating' value='3' id='star2_input' />
  43. <h5>Why?</h5>
  44. <p>There are other libraries out there, but none that approach the level clarity and conciseness that I wanted. Starrr is less than 75 lines of code -- you can understand the entirety of its source code in about a minute.</p>
  45. <h5>Dependencies</h5>
  46. <p>jQuery.</p>
  47. <p>I'm using Bootstrap + Font Awesome to render the stars, but you're more than welcome to use something else.</p>
  48. </div>
  49. <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.js"></script>
  50. <script src="dist/starrr.js"></script>
  51. <script>
  52. $('#star1').starrr({
  53. change: function(e, value){
  54. if (value) {
  55. $('.your-choice-was').show();
  56. $('.choice').text(value);
  57. } else {
  58. $('.your-choice-was').hide();
  59. }
  60. }
  61. });
  62. var $s2input = $('#star2_input');
  63. $('#star2').starrr({
  64. max: 10,
  65. rating: $s2input.val(),
  66. change: function(e, value){
  67. $s2input.val(value).trigger('input');
  68. }
  69. });
  70. </script>
  71. <script type="text/javascript">
  72. (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  73. (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  74. m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  75. })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  76. ga('create', 'UA-39205841-5', 'dobtco.github.io');
  77. ga('send', 'pageview');
  78. </script>
  79. </body>
  80. </html>