complete.js 1.7 KB

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