theme.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. $(document).ready(function() {
  2. // menu drop downs
  3. $('ul.dropmenu, ul.quickbuttons').superfish({delay : 600, speed: 200, sensitivity : 8, interval : 50, timeout : 1});
  4. // tooltips
  5. $('.preview').SMFtooltip();
  6. // find all nested linked images and turn off the border
  7. $('a.bbc_link img.bbc_img').parent().css('border', '0');
  8. });
  9. // The purpose of this code is to fix the height of overflow: auto blocks, because some browsers can't figure it out for themselves.
  10. function smf_codeBoxFix()
  11. {
  12. var codeFix = $('code');
  13. $.each(codeFix, function(index, tag)
  14. {
  15. if (is_webkit && $(tag).height() < 20)
  16. $(tag).css({height: ($(tag).height + 20) + 'px'});
  17. else if (is_ff && ($(tag)[0].scrollWidth > $(tag).innerWidth() || $(tag).innerWidth() == 0))
  18. $(tag).css({overflow: 'scroll'});
  19. // Holy conditional, Batman!
  20. else if (
  21. 'currentStyle' in $(tag) && $(tag)[0].currentStyle.overflow == 'auto'
  22. && ($(tag).innerHeight() == '' || $(tag).innerHeight() == 'auto')
  23. && ($(tag)[0].scrollWidth > $(tag).innerWidth() || $(tag).innerWidth == 0)
  24. && ($(tag).outerHeight() != 0)
  25. )
  26. $(tag).css({height: ($(tag).height + 24) + 'px'});
  27. });
  28. }
  29. // Add a fix for code stuff?
  30. if (is_ie || is_webkit || is_ff)
  31. addLoadEvent(smf_codeBoxFix);
  32. // Toggles the element height and width styles of an image.
  33. function smc_toggleImageDimensions()
  34. {
  35. var images = $('img.bbc_img');
  36. $.each(images, function(key, img)
  37. {
  38. if ($(img).hasClass('resized'))
  39. {
  40. $(img).css({cursor: 'pointer'});
  41. $(img).on('click', function()
  42. {
  43. var size = $(this)[0].style.width == 'auto' ? '' : 'auto';
  44. $(this).css({width: size, height: size});
  45. });
  46. }
  47. });
  48. }
  49. // Add a load event for the function above.
  50. addLoadEvent(smc_toggleImageDimensions);
  51. function smf_addButton(stripId, image, options)
  52. {
  53. $('#' + stripId + ' ul').append(
  54. '<li' + ('sId' in options ? ' id="' + options.sId + '"' : '') + '>' +
  55. '<a href="' + options.sUrl + '"' + ('sCustom' in options ? options.sCustom : '') + '>' +
  56. '<span class="last"' + ('sId' in options ? ' id="' + options.sId + '_text"' : '') + '>' + options.sText + '</span>' +
  57. '</a>' +
  58. '</li>'
  59. );
  60. }