Advertisement:
Anonymous Login
12-05-2016 07:50 PM

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0004990SMF 2.0Javascriptpublic2013-12-14 14:23
ReporterAkyhne 
PrioritynormalSeveritymajorReproducibilityalways
StatusresolvedResolutionfixed 
Summary0004990: Backgrounds for BBC buttons not showing when theme's name contains a space
DescriptionWhen creating/editing a topic where there's a space in the name of the theme, you will get some Javascript errors saying that bbc_bg.gif could not be created.

In the GenericControls.template.php, this one will fail (#218):
sButtonBackgroundImage: ', JavaScriptEscape($settings['images_url'] . '/bbc/bbc_bg.gif'), '
Steps To ReproduceCreate a duplicate of the Default theme, naming it with a space in the name:
"My Theme".
Create a new topic and the bbc_bg.gif & bbc_hoverbg.gif will not turn up.
Additional InformationI can't find any other reason why the bbc_bg.gif & bbc_hoverbg.gif will not show up.
In my theme, I eventually renamed my theme to use an underscore, then the problem dissapeared.
So I resume it's because of the space in my custom theme.

Javascript isn't my strongest side!
TagsNo tags attached.
Attached Files

-Relationships
+Relationships

-Notes

bugnote:0014772

akabugeyes (SMF Friend)

I imagine this is happening because CSS probably doesn't take kindly to having spaces inside the urls.

I was able to fix this by replacing an empty space here with '%20':

This in editor.js:

    if (oButtonImg.bHover && oButtonImg.bIsActive && 'sActiveButtonBackgroundImageHover' in this.opt)
        sNewURL = 'url(' + this.opt.sActiveButtonBackgroundImageHover + ')';
    else if (!oButtonImg.bHover && oButtonImg.bIsActive && 'sActiveButtonBackgroundImage' in this.opt)
        sNewURL = 'url(' + this.opt.sActiveButtonBackgroundImage + ')';
    else if (oButtonImg.bHover && 'sButtonBackgroundImageHover' in this.opt)
        sNewURL = 'url(' + this.opt.sButtonBackgroundImageHover + ')';
    else if ('sButtonBackgroundImage' in this.opt)
        sNewURL = 'url(' + this.opt.sButtonBackgroundImage + ')';

Becomes:

    if (oButtonImg.bHover && oButtonImg.bIsActive && 'sActiveButtonBackgroundImageHover' in this.opt)
        sNewURL = 'url(' + this.opt.sActiveButtonBackgroundImageHover.replace(' ', '%20') + ')';
    else if (!oButtonImg.bHover && oButtonImg.bIsActive && 'sActiveButtonBackgroundImage' in this.opt)
        sNewURL = 'url(' + this.opt.sActiveButtonBackgroundImage.replace(' ', '%20') + ')';
    else if (oButtonImg.bHover && 'sButtonBackgroundImageHover' in this.opt)
        sNewURL = 'url(' + this.opt.sButtonBackgroundImageHover.replace(' ', '%20') + ')';
    else if ('sButtonBackgroundImage' in this.opt)
        sNewURL = 'url(' + this.opt.sButtonBackgroundImage.replace(' ', '%20') + ')';

Note there are much nicer ways this code be done but this is a rough idea of what fixes the problem.

bugnote:0014888

arrowtotheknee (SMF Friend)

This shouldn't affect 2.1 because of the different editor, and I've added a slightly different fix to the patch I've got in preparation for if a 2.0.7 becomes necessary.
+Notes
MantisBT (Modified for SMF Intergration)[^] Copyright © 2000 - 2010 Mantis Group