Jump to content

Changing Custom CSS on theme change


tappatappa

Recommended Posts

I have defined a few div classes in ServerModule::CustomCSS. When I change (at run time!) the Theme of my application (this can be done in MainModule) I'd wish to switch my Custom CSS, and here is the problem: the CSS is in ServerModule, is global.

 

How do you achieve that?

 

 

Link to comment
Share on other sites

Thanks zilav for the input, but this would work if I had a css custom file, I guess. Right now I need a way to paste a css string at run time. For now my workaround seems to work, by the way.

UnicodeString custom_css;
if(UniMainModule()->Theme == UnicodeString(L"neptune"))
    custom_css = L"neptune_css";
else
    custom_css = L"default_css";

//removing carriage returns...
TReplaceFlags flags = TReplaceFlags() << rfReplaceAll;
custom_css = StringReplace(custom_css, L"\r\n", L" ", flags);

UniSession->AddJS(UnicodeString("var my_customstyle = Ext.util.CSS.createStyleSheet('")+custom_css+L"','my_customstyle');");
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...