theme.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 = document.getElementsByTagName('code');
  13. for (var i = codeFix.length - 1; i >= 0; i--)
  14. {
  15. if (is_webkit && codeFix[i].offsetHeight < 20)
  16. codeFix[i].style.height = (codeFix[i].offsetHeight + 20) + 'px';
  17. else if (is_ff && (codeFix[i].scrollWidth > codeFix[i].clientWidth || codeFix[i].clientWidth == 0))
  18. codeFix[i].style.overflow = 'scroll';
  19. else if ('currentStyle' in codeFix[i] && codeFix[i].currentStyle.overflow == 'auto' && (codeFix[i].currentStyle.height == '' || codeFix[i].currentStyle.height == 'auto') && (codeFix[i].scrollWidth > codeFix[i].clientWidth || codeFix[i].clientWidth == 0) && (codeFix[i].offsetHeight != 0))
  20. codeFix[i].style.height = (codeFix[i].offsetHeight + 24) + 'px';
  21. }
  22. }
  23. // Add a fix for code stuff?
  24. if (is_ie || is_webkit || is_ff)
  25. addLoadEvent(smf_codeBoxFix);
  26. // Toggles the element height and width styles of an image.
  27. function smc_toggleImageDimensions()
  28. {
  29. var oImages = document.getElementsByTagName('IMG');
  30. for (oImage in oImages)
  31. {
  32. // Not a resized image? Skip it.
  33. if (oImages[oImage].className == undefined || oImages[oImage].className.indexOf('bbc_img resized') == -1)
  34. continue;
  35. oImages[oImage].style.cursor = 'pointer';
  36. oImages[oImage].onclick = function() {
  37. this.style.width = this.style.height = this.style.width == 'auto' ? null : 'auto';
  38. };
  39. }
  40. }
  41. // Add a load event for the function above.
  42. addLoadEvent(smc_toggleImageDimensions);
  43. // Adds a button to a certain button strip.
  44. function smf_addButton(sButtonStripId, bUseImage, oOptions)
  45. {
  46. var oButtonStrip = document.getElementById(sButtonStripId);
  47. var aItems = oButtonStrip.getElementsByTagName('span');
  48. // Remove the 'last' class from the last item.
  49. if (aItems.length > 0)
  50. {
  51. var oLastSpan = aItems[aItems.length - 1];
  52. oLastSpan.className = oLastSpan.className.replace(/\s*last/, 'position_holder');
  53. }
  54. // Add the button.
  55. var oButtonStripList = oButtonStrip.getElementsByTagName('ul')[0];
  56. var oNewButton = document.createElement('li');
  57. if ('sId' in oOptions)
  58. oNewButton.id = oOptions.sId
  59. setInnerHTML(oNewButton, '<a href="' + oOptions.sUrl + '" ' + ('sCustom' in oOptions ? oOptions.sCustom : '') + '><span class="last"' + ('sId' in oOptions ? ' id="' + oOptions.sId + '_text"': '') + '>' + oOptions.sText + '</span></a>');
  60. oButtonStripList.appendChild(oNewButton);
  61. }