7.18.js 1.5 KB

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