04.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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({
  39. position: 'relative'
  40. }).animate({left: paraWidth - switcherWidth}, 'slow')
  41. .animate({height: '+=20px'}, 'slow')
  42. .animate({borderWidth: '5px'}, 'slow');
  43. });
  44. });