2
0

theme.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. var strip = $('#' + stripId);
  54. var anchorItems = $('#' + stripId + '.span');
  55. // Kill the class name "last" in the last item.
  56. if (anchorItems.length > 0)
  57. {
  58. var lastSpan = anchorItems[anchorItems.length - 1];
  59. var lastSpanClass = $(lastSpan).attr('class');
  60. $(lastSpan).attr('class') = lastSpanClass.replace(/\s*last/, 'position_holder');
  61. }
  62. // Add in the new button!
  63. var buttonStrip = strip.children('ul');
  64. buttonStrip.append(
  65. '<li' + ('sId' in options ? ' id="' + options.sId + '"' : '') + '>' +
  66. '<a href="' + options.sUrl + '"' + ('sCustom' in options ? options.sCustom : '') + '>' +
  67. '<span class="last"' + ('sId' in options ? ' id="' + options.sId + '_text"' : '') + '>' + options.sText + '</span>' +
  68. '</a>' +
  69. '</li>'
  70. );
  71. }