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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...