XF 2.2 Extend JS Base Helpers from core.js?

Newsman

Member
Hey there,

well, the title says it all - I know the process of extending an element or whatever, but how do you do the same with base helpers from the core.js file? Obviously I do not want to tinker around with the core.js file at all, but I need to slightly alter the updateAvatars function..

Cheers, and thanks for any help!
 
See this post:


Search for XF.BlueText on that page.
 
Right, that is how to extend an element - I'm asking about the core.js base helper functions themselves, for example shouldCountBeShown

PHP:
        shouldCountBeShown: function(newCount)
        {
            var newCountNormalized = parseInt(newCount.replace(/[,. ]/g, ''));
            return newCountNormalized > 0;
        },
 
Right, that is how to extend an element - I'm asking about the core.js base helper functions themselves, for example shouldCountBeShown

PHP:
        shouldCountBeShown: function(newCount)
        {
            var newCountNormalized = parseInt(newCount.replace(/[,. ]/g, ''));
            return newCountNormalized > 0;
        },
Well you didn't mention that one specifically, but it's the same as if you wanted to extend the updateAvatars function.

Off the top of my head, why couldn't you do this?

JavaScript:
XF.shouldCountBeShownOriginal = XF.shouldCountBeShown;
XF.shouldCountBeShown = function(newCount)
{
    let newCountNormalized = this.shouldCountBeShownOriginal(newCount);
    // Do your stuff
    return newCountNormalized;
}
 
Top Bottom