Jump to content

localized CSS and JavaScript for subclassed controls


KH0RKHE

Recommended Posts

Is there a way to add custom CSS and JavaScript, aside from the properties "CustomCSS" and "customFiles"?

This approach, for large projects, would bring back the days of jQuery hell into the Delphi world, making unmaintainable spaghetti out of the sources.

I'd like to add CSS, and JavaScript code with limited scope, in my descendant of a unigui control, for a modular, object oriented programming.

This approach is typically used in modern web front end frameworks, such as ReactJS or Angular, to enforce isolation between our building blocks.

How could this be achieved with unigui? And is this the right place to post, or should I put it in feature request?

Thanks for your time

Link to comment
Share on other sites

9 hours ago, KH0RKHE said:

Is there a way to add custom CSS and JavaScript, aside from the properties "CustomCSS" and "customFiles"?


 

procedure TUniMainModule.UniGUIMainModuleBeforeLogin(Sender: TObject; var Handled: Boolean);
begin
  LoadScriptCSS;

...

...

end;

procedure TUniMainModule.LoadScriptCSS;
begin
  if ExtLocale = 'ukr' then
  begin
    if UniMainModule.IsMobilePlatform then
      UniSession.AddJS('Ext.Loader.loadScript("/files/' + cCSSDir + 'custommob_ukr.css")')
    else
      UniSession.AddJS('Ext.Loader.loadScript("/files/' + cCSSDir + 'custom_ukr.css")');
  end
  else
  begin
    if UniMainModule.IsMobilePlatform then
      UniSession.AddJS('Ext.Loader.loadScript("/files/' + cCSSDir + 'custommob.css")')
    else
      UniSession.AddJS('Ext.Loader.loadScript("/files/' + cCSSDir + 'custom.css")');
  end;

end;

 

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...