7.17.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. $(document).ready(function() {
  2. var $books = $('#books').cycle({
  3. timeout: 2000,
  4. speed: 200,
  5. pause: true
  6. });
  7. if ( $.cookie('cyclePaused') ) {
  8. $books.cycle('pause');
  9. }
  10. var $controls = $('<div id="books-controls"></div>').insertAfter($books);
  11. $('<button>Pause</button>').click(function(event) {
  12. event.preventDefault();
  13. $books.cycle('pause');
  14. $.cookie('cyclePaused', 'y');
  15. }).button({
  16. icons: {primary: 'ui-icon-pause'}
  17. }).appendTo($controls);
  18. $('<button>Resume</button>').click(function(event) {
  19. event.preventDefault();
  20. var $paused = $('ul:paused');
  21. if ($paused.length) {
  22. $paused.cycle('resume');
  23. $.cookie('cyclePaused', null);
  24. }
  25. else {
  26. $(this).effect('shake', {
  27. distance: 10
  28. });
  29. }
  30. }).button({
  31. icons: {primary: 'ui-icon-play'}
  32. }).appendTo($controls);
  33. $('<div id="slider"></div>').slider({
  34. min: 0,
  35. max: $('#books li').length - 1,
  36. slide: function(event, ui) {
  37. $books.cycle(ui.value);
  38. }
  39. }).appendTo($controls);
  40. $books.hover(function() {
  41. $books.find('.title').animate({
  42. backgroundColor: '#eee',
  43. color: '#000'
  44. }, 1000);
  45. }, function() {
  46. $books.find('.title').animate({
  47. backgroundColor: '#000',
  48. color: '#fff'
  49. }, 1000);
  50. });
  51. $('h1').click(function() {
  52. $(this).toggleClass('highlighted', 'slow', 'easeInExpo');
  53. });
  54. $books.find('.title').resizable({
  55. handles: 's'
  56. });
  57. });