D&D Forums - MyBB Plugins & Themes
EMERALD (extended): JS Uncaught TypeError & Expand/Collaped boxes - Printable Version

+- D&D Forums - MyBB Plugins & Themes (https://developement.design/forum)
+-- Forum: MyBB Ressources (https://developement.design/forum/forumdisplay.php?fid=5)
+--- Forum: Premium MyBB Themes (https://developement.design/forum/forumdisplay.php?fid=9)
+---- Forum: Support (https://developement.design/forum/forumdisplay.php?fid=18)
+---- Thread: EMERALD (extended): JS Uncaught TypeError & Expand/Collaped boxes (/showthread.php?tid=27981)



EMERALD (extended): JS Uncaught TypeError & Expand/Collaped boxes - Vitor Costa (APDCA IT) - 11-28-2022

Hi guys :-)

I found that on EXTENDED VERSION OF EMERALD every time I click to expand or collapse the tabs on the user CP it generates a JS error. I tested also here to validade if it was me only or so, but seems that the same error occurs here in this forum ...

Don't know also if that could be related with the fact that when we revisit the user CP the browser don't "remember" the last expanded/collapsed state. Maybe not supposed to... don't know.
[Image: attachment.php?aid=102]
Code:
general.js?ver=1804:690 Uncaught TypeError: Cannot read properties of undefined (reading 'replace')
    at Object.expandCollapse (general.js?ver=1804:690:89)
    at HTMLElement.<anonymous> (general.js?ver=1804:666:18)
    at HTMLElement.dispatch (jquery.js?ver=1804:2:43090)
    at v.handle (jquery.js?ver=1804:2:41074)



EDIT: 
A bit replying to myself Smile ...

I tracked the funcion a bit in the general.js file.
 
I think It can be something to do with the fact that the theme is not using images to represent the maximized and minimized, and its using font awesome icons to make those representation so the tag "img" a his "src" are null.

Also then, as it fails, it doesn't run the saveCollapsed function etc etc... 
[Image: attachment.php?aid=103]
Code:
        if(expandedItem.length)
        {
            var expState = + !expandedItem.is(":hidden"),
                expcolImg = element.attr("src"),            
                expText = [lang.expcol_collapse, lang.expcol_expand];

            expandedItem.toggle("fast", this.expCallback(controls, expState));
            
            element.attr({
                "alt": expText[expState],
                "title": expText[expState],
                "src": expState ? expcolImg.replace('collapse.', 'collapse_collapsed.') : expcolImg.replace('collapse_collapsed.', 'collapse.')
            })
            .parents(':eq(1)').toggleClass(element.parents(':eq(1)').hasClass('thead') ? 'thead_collapsed' : 'tcat_collapse_collapsed');
            this.saveCollapsed(controls, expState);
        }
        return true;


EDIT again... last time. 
By now I edited the file general.js, and in the "expandCollapse: function(element)" I made a check typeof to test if it is undefined  before procede.
All work now without erros and the state of the boxes keeps "remembered"  Big Grin  as it is saved in the cookie.

[Image: attachment.php?aid=104]


RE: EMERALD (extended): JS Uncaught TypeError & Expand/Collaped boxes - AmazOuz - 11-30-2022

Thanks for your investigation and solution for this ^^
These are of course harmless JS errors but it's always better to clean them