smf-theme/scripts/theme.js

60 lines
1.8 KiB
JavaScript
Raw Normal View History

$(function() {
$('ul.dropmenu, ul.quickbuttons').superfish({delay : 250, speed: 100, sensitivity : 8, interval : 50, timeout : 1});
// tooltips
$('.preview').SMFtooltip();
// find all nested linked images and turn off the border
$('a.bbc_link img').parent().css('border', '0');
});
// The purpose of this code is to fix the height of overflow: auto blocks, because some browsers can't figure it out for themselves.
function smf_codeBoxFix()
{
var codeFix = $('code');
$.each(codeFix, function(index, tag)
{
if (is_webkit && $(tag).height() < 20)
$(tag).css({height: ($(tag).height() + 20) + 'px'});
else if (is_ff && ($(tag)[0].scrollWidth > $(tag).innerWidth() || $(tag).innerWidth() == 0))
$(tag).css({overflow: 'scroll'});
// Holy conditional, Batman!
else if (
'currentStyle' in $(tag) && $(tag)[0].currentStyle.overflow == 'auto'
&& ($(tag).innerHeight() == '' || $(tag).innerHeight() == 'auto')
&& ($(tag)[0].scrollWidth > $(tag).innerWidth() || $(tag).innerWidth == 0)
&& ($(tag).outerHeight() != 0)
)
$(tag).css({height: ($(tag).height + 24) + 'px'});
});
}
// Add a fix for code stuff?
if (is_ie || is_webkit || is_ff)
addLoadEvent(smf_codeBoxFix);
// Toggles the element height and width styles of an image.
function smc_toggleImageDimensions()
{
$('.postarea .bbc_img.resized').each(function(index, item)
{
$(item).click(function(e)
{
$(item).toggleClass('original_size');
});
});
}
// Add a load event for the function above.
addLoadEvent(smc_toggleImageDimensions);
function smf_addButton(stripId, image, options)
{
$('#' + stripId).append(
'<a href="' + options.sUrl + '" class="button last" ' + ('sCustom' in options ? options.sCustom : '') + ' ' + ('sId' in options ? ' id="' + options.sId + '_text"' : '') + '>'
+ options.sText +
'</a>'
);
}