index.html 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Gritter demo for jQuery - boedesign.com</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <link rel="stylesheet" type="text/css" href="css/jquery.gritter.css" />
  7. <script type="text/javascript" src="http://www.google.com/jsapi"></script>
  8. <script type="text/javascript">google.load('jquery', '1.7.1');</script>
  9. <script type="text/javascript" src="js/jquery.gritter.js"></script>
  10. <style type="text/css">
  11. body {
  12. background:#222 url(images/trees.jpg);
  13. color:#fff;
  14. }
  15. a {
  16. color:#00ff00;
  17. }
  18. #container {
  19. width:600px;
  20. background:#333;
  21. padding:10px;
  22. }
  23. </style>
  24. </head>
  25. <body>
  26. <div id="container">
  27. <h1>Gritter Demo</h1>
  28. <p>
  29. The super awesome background is just to show you that all notifications are transparent!
  30. <em>Tested in: FF 3+, Opera 9, IE7, IE8, Safari 4+</em>
  31. </p>
  32. <ul>
  33. <li>
  34. <a href="#" id="add-regular">Add regular notification</a>: Fades out after a certain amount of time, can be set for each notification.
  35. </li>
  36. <li>
  37. <a href="#" id="add-sticky">Add sticky notification</a>: Doesn't run on a fade timer. Just sits there until the user manually removes it by clicking on the (X).
  38. </li>
  39. <li>
  40. <a href="#" id="add-without-image">Add notification without image</a>
  41. </li>
  42. <li>
  43. <a href="#" id="add-gritter-light">Add a white notification</a>: has a 'gritter-light' class_name applied to it.
  44. </li>
  45. <li>
  46. <a href="#" id="add-with-callbacks">Add notification (with callbacks)</a>
  47. </li>
  48. <li>
  49. <a href="#" id="add-sticky-with-callbacks">Add a sticky notification (with callbacks)</a>
  50. </li>
  51. <li>
  52. <a href="#" id="add-max">Add notification with max of 3</a>: If there are 3 messages already on screen, it won't show another one.
  53. </li>
  54. <li>
  55. <a href="#" id="remove-all">Remove all notifications</a>
  56. </li>
  57. <li>
  58. <a href="#" id="remove-all-with-callbacks">Remove all notifications (with callbacks)</a>
  59. </li>
  60. </ul>
  61. </div>
  62. <script type="text/javascript">
  63. $(function(){
  64. // global setting override
  65. /*
  66. $.extend($.gritter.options, {
  67. class_name: 'gritter-light', // for light notifications (can be added directly to $.gritter.add too)
  68. position: 'bottom-left', // possibilities: bottom-left, bottom-right, top-left, top-right
  69. fade_in_speed: 100, // how fast notifications fade in (string or int)
  70. fade_out_speed: 100, // how fast the notices fade out
  71. time: 3000 // hang on the screen for...
  72. });
  73. */
  74. $('#add-sticky').click(function(){
  75. var unique_id = $.gritter.add({
  76. // (string | mandatory) the heading of the notification
  77. title: 'This is a sticky notice!',
  78. // (string | mandatory) the text inside the notification
  79. text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus eget tincidunt velit. Cum sociis natoque penatibus et <a href="#" style="color:#ccc">magnis dis parturient</a> montes, nascetur ridiculus mus.',
  80. // (string | optional) the image to display on the left
  81. image: 'http://s3.amazonaws.com/twitter_production/profile_images/132499022/myface_bigger.jpg',
  82. // (bool | optional) if you want it to fade out on its own or just sit there
  83. sticky: true,
  84. // (int | optional) the time you want it to be alive for before fading out
  85. time: '',
  86. // (string | optional) the class name you want to apply to that specific message
  87. class_name: 'my-sticky-class'
  88. });
  89. // You can have it return a unique id, this can be used to manually remove it later using
  90. /*
  91. setTimeout(function(){
  92. $.gritter.remove(unique_id, {
  93. fade: true,
  94. speed: 'slow'
  95. });
  96. }, 6000)
  97. */
  98. return false;
  99. });
  100. $('#add-regular').click(function(){
  101. $.gritter.add({
  102. // (string | mandatory) the heading of the notification
  103. title: 'This is a regular notice!',
  104. // (string | mandatory) the text inside the notification
  105. text: 'This will fade out after a certain amount of time. Vivamus eget tincidunt velit. Cum sociis natoque penatibus et <a href="#" style="color:#ccc">magnis dis parturient</a> montes, nascetur ridiculus mus.',
  106. // (string | optional) the image to display on the left
  107. image: 'http://a0.twimg.com/profile_images/59268975/jquery_avatar_bigger.png',
  108. // (bool | optional) if you want it to fade out on its own or just sit there
  109. sticky: false,
  110. // (int | optional) the time you want it to be alive for before fading out
  111. time: ''
  112. });
  113. return false;
  114. });
  115. $('#add-max').click(function(){
  116. $.gritter.add({
  117. // (string | mandatory) the heading of the notification
  118. title: 'This is a notice with a max of 3 on screen at one time!',
  119. // (string | mandatory) the text inside the notification
  120. text: 'This will fade out after a certain amount of time. Vivamus eget tincidunt velit. Cum sociis natoque penatibus et <a href="#" style="color:#ccc">magnis dis parturient</a> montes, nascetur ridiculus mus.',
  121. // (string | optional) the image to display on the left
  122. image: 'http://a0.twimg.com/profile_images/59268975/jquery_avatar_bigger.png',
  123. // (bool | optional) if you want it to fade out on its own or just sit there
  124. sticky: false,
  125. // (function) before the gritter notice is opened
  126. before_open: function(){
  127. if($('.gritter-item-wrapper').length == 3)
  128. {
  129. // Returning false prevents a new gritter from opening
  130. return false;
  131. }
  132. }
  133. });
  134. return false;
  135. });
  136. $('#add-without-image').click(function(){
  137. $.gritter.add({
  138. // (string | mandatory) the heading of the notification
  139. title: 'This is a notice without an image!',
  140. // (string | mandatory) the text inside the notification
  141. text: 'This will fade out after a certain amount of time. Vivamus eget tincidunt velit. Cum sociis natoque penatibus et <a href="#" style="color:#ccc">magnis dis parturient</a> montes, nascetur ridiculus mus.'
  142. });
  143. return false;
  144. });
  145. $('#add-gritter-light').click(function(){
  146. $.gritter.add({
  147. // (string | mandatory) the heading of the notification
  148. title: 'This is a light notification',
  149. // (string | mandatory) the text inside the notification
  150. text: 'Just add a "gritter-light" class_name to your $.gritter.add or globally to $.gritter.options.class_name',
  151. class_name: 'gritter-light'
  152. });
  153. return false;
  154. });
  155. $('#add-with-callbacks').click(function(){
  156. $.gritter.add({
  157. // (string | mandatory) the heading of the notification
  158. title: 'This is a notice with callbacks!',
  159. // (string | mandatory) the text inside the notification
  160. text: 'The callback is...',
  161. // (function | optional) function called before it opens
  162. before_open: function(){
  163. alert('I am called before it opens');
  164. },
  165. // (function | optional) function called after it opens
  166. after_open: function(e){
  167. alert("I am called after it opens: \nI am passed the jQuery object for the created Gritter element...\n" + e);
  168. },
  169. // (function | optional) function called before it closes
  170. before_close: function(e, manual_close){
  171. var manually = (manual_close) ? 'The "X" was clicked to close me!' : '';
  172. alert("I am called before it closes: I am passed the jQuery object for the Gritter element... \n" + manually);
  173. },
  174. // (function | optional) function called after it closes
  175. after_close: function(e, manual_close){
  176. var manually = (manual_close) ? 'The "X" was clicked to close me!' : '';
  177. alert('I am called after it closes. ' + manually);
  178. }
  179. });
  180. return false;
  181. });
  182. $('#add-sticky-with-callbacks').click(function(){
  183. $.gritter.add({
  184. // (string | mandatory) the heading of the notification
  185. title: 'This is a sticky notice with callbacks!',
  186. // (string | mandatory) the text inside the notification
  187. text: 'Sticky sticky notice.. sticky sticky notice...',
  188. // Stickeh!
  189. sticky: true,
  190. // (function | optional) function called before it opens
  191. before_open: function(){
  192. alert('I am a sticky called before it opens');
  193. },
  194. // (function | optional) function called after it opens
  195. after_open: function(e){
  196. alert("I am a sticky called after it opens: \nI am passed the jQuery object for the created Gritter element...\n" + e);
  197. },
  198. // (function | optional) function called before it closes
  199. before_close: function(e){
  200. alert("I am a sticky called before it closes: I am passed the jQuery object for the Gritter element... \n" + e);
  201. },
  202. // (function | optional) function called after it closes
  203. after_close: function(){
  204. alert('I am a sticky called after it closes');
  205. }
  206. });
  207. return false;
  208. });
  209. $("#remove-all").click(function(){
  210. $.gritter.removeAll();
  211. return false;
  212. });
  213. $("#remove-all-with-callbacks").click(function(){
  214. $.gritter.removeAll({
  215. before_close: function(e){
  216. alert("I am called before all notifications are closed. I am passed the jQuery object containing all of Gritter notifications.\n" + e);
  217. },
  218. after_close: function(){
  219. alert('I am called after everything has been closed.');
  220. }
  221. });
  222. return false;
  223. });
  224. });
  225. </script>
  226. </body>
  227. </html>