Floren
Well-known member
Hi all,
I'm trying to create an add-on for an alternate QUOTE BB Code and I'm stuck at extending the JavaScript code. I extracted from xenforo.js the code I'm interested in, but I need your help to properly finalize the functions (note the bbCodeAltQuote part):
Thank you for your help.
I'm trying to create an add-on for an alternate QUOTE BB Code and I'm stuck at extending the JavaScript code. I extracted from xenforo.js the code I'm interested in, but I need your help to properly finalize the functions (note the bbCodeAltQuote part):
Code:
/** @param {jQuery} $ jQuery Object */
!function($, window, document, _undefined)
{
$.extend(XenForo,
{
init: function()
{
$(window).on('resize', function() {
XenForo.checkAltQuoteSizing($(document));
});
$(document).on('click', '.bbCodeAltQuote .quoteContainer .quoteExpand', function(e) {
$(this).closest('.quoteContainer').toggleClass('expanded');
});
},
checkAltQuoteSizing: function($element)
{
$element.find('.bbCodeAltQuote .quoteContainer').each(function() {
var self = this,
delay = 0,
checkHeight = function() {
var $self = $(self),
quote = $self.find('.quote')[0];
if (!quote)
{
return;
}
if (quote.scrollHeight == 0 || quote.offsetHeight == 0)
{
if (delay < 2000)
{
setTimeout(checkHeight, delay);
delay += 100;
}
return;
}
// +1 resolves a chrome rounding issue
if (quote.scrollHeight > quote.offsetHeight + 1)
{
$self.find('.quoteExpand').addClass('quoteCut');
}
else
{
$self.find('.quoteExpand').removeClass('quoteCut');
}
};
checkHeight();
$(this).find('img').one('load', checkHeight);
});
}
});
}
(jQuery, this, document);
Thank you for your help.