04.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. $(document).ready(function () {
  2. "use strict";
  3. var $speech = $('div.speech');
  4. var defaultSize = $speech.css('fontSize');
  5. $('#switcher button').click(function () {
  6. var num = parseFloat($speech.css('fontSize'));
  7. switch (this.id) {
  8. case 'switcher-large':
  9. num *= 1.4;
  10. break;
  11. case 'switcher-small':
  12. num /= 1.4;
  13. break;
  14. default:
  15. num = parseFloat(defaultSize);
  16. }
  17. $speech.animate({fontSize: num + 'px'}, 'slow');
  18. });
  19. var $firstPara = $('p').eq(1);
  20. $firstPara.hide();
  21. $('a.more').click(function (event) {
  22. event.preventDefault();
  23. $firstPara.animate({
  24. opacity: 'toggle',
  25. height: 'toggle'
  26. }, 'slow');
  27. var $link = $(this);
  28. if ($link.text() == 'read more') {
  29. $link.text('read less');
  30. } else {
  31. $link.text('read more');
  32. }
  33. });
  34. $('div.label').click(function () {
  35. var paraWidth = $('div.speech p').outerWidth();
  36. var $switcher = $(this).parent();
  37. var switcherWidth = $switcher.outerWidth();
  38. $switcher.css({ position: 'relative' })
  39. .fadeTo('fast', 0.2)
  40. .animate({left: paraWidth - switcherWidth}, 'slow')
  41. .fadeTo('slow', 1.0)
  42. .slideUp('slow')
  43. .slideDown('slow')
  44. ;
  45. });
  46. });