Page 1 of 2

Run time changing

PostPosted: 25 Apr 2014 15:16
by etwoss
Hi


I ask again because the other link in a thread about this is not working

I have made a 'branding' form where the user may select a theme.

The first thing in notice is that this form does NOT show up in the already selected theme (Sunny).

So i thought i have to set the IWCGJQThemeSwitcher.JQThemeSwitcherOptions.LoadTheme property.

Code: Select all
  IWCGJQThemeSwitcher.JQThemeSwitcherOptions.LoadTheme := IWServerController.ReadSetting('WebTheme', 'INFOmatch-Yellow');


Yes this sets the right theme for the form, however the IWCGJQThemeSwitcher stil shows the wrong theme.

So i thought to use SetTheme to set the theme:

Code: Select all
  IWCGJQThemeSwitcher.SetTheme(IWServerController.ReadSetting('WebTheme', 'INFOmatch-Yellow'));



Yes this set the right value but the forms does not change

So i do both

Code: Select all
  IWCGJQThemeSwitcher.SetTheme(IWServerController.ReadSetting('WebTheme', 'INFOmatch-Yellow'));
  IWCGJQThemeSwitcher.JQThemeSwitcherOptions.LoadTheme := IWServerController.ReadSetting('WebTheme', 'INFOmatch-Yellow');


So far so good

Now i have to react on the Select event of the IWCGJQThemeSwitcher
To be sure this event is not called with my first two statements i hook them in after them:

I have added some codesite code to show the AParams property of the IWCGJQThemeSwitcherJQThemeSwitcherOptionsSelect event
Code: Select all
  IWCGJQThemeSwitcher.SetTheme(IWServerController.ReadSetting('WebTheme', 'INFOmatch-Yellow'));
  IWCGJQThemeSwitcher.JQThemeSwitcherOptions.LoadTheme := IWServerController.ReadSetting('WebTheme', 'INFOmatch-Yellow');

  IWCGJQThemeSwitcher.JQThemeSwitcherOptions.OnSelect.Ajax := True;
  IWCGJQThemeSwitcher.JQThemeSwitcherOptions.OnSelect.OnEvent := IWCGJQThemeSwitcherJQThemeSwitcherOptionsSelect;


When i run i see two time's Aparams in codesite, once with jWin8 and once with Sunny as being the value for IWCGJQTHEMESWITCHER_THEME

I did not expect this because i hooked in the event after setting the Theme!

So now i set a Boolean FStarting := True; in the FormCreate and FStarting := False in the IWAppFormAfterRender and in the select event:

Code: Select all

procedure TIWFormSettingsBranding.IWCGJQThemeSwitcherJQThemeSwitcherOptionsSelect(
  Sender: TObject; AParams: TStringList);
begin
  if not FStarting then
    Codesite.Send('Aparams' ,  AParams);


lets see what happens?

Still two times the codesite message

What am i missing here?

And what to do if i really do select another Theme?

>I want the current form to show the newly selected theme

Do i need to free al forms in memory or will the take the newly selected automatic, tried this but no, so better free?

Busy for more than 3 hours now on this, simply looking, subject :-(

Any help is appreciated

Eric

Re: Run time changing

PostPosted: 25 Apr 2014 15:31
by Jorge Sousa
Hi Eric

Themeswitcher works with cookies, and you must use the onselect even at the first time to know what is saved in themeswitcher cookie.

This happens now because it wasnt the user who selected the theme he wanted, it was you.

So for replicate the site use, you must clear cookies first, have a initial theme the you also set in options.LoadTheme

then when you open that page where the user can chagne the theme, you use onselect to save it for future use.

And yes, all the pages in memory won't get the theme, since the pages in memory don't use themeswitcher, you must warn you users that only next time they will see the next theme.

Re: Run time changing

PostPosted: 28 Apr 2014 14:00
by etwoss
Hi

I have it working now, but i noticed the following:

Chrome: when i open my setting form the themeswitcher show the correct theme from the cookie

IE11 : when i open my setting form the themeswitcher always shows Start

Eric

Re: Run time changing

PostPosted: 29 Apr 2014 11:27
by etwoss
Hi

I understand that each browser has its own cookies so IE does not read the one created when running Chrome, right?

Eruc

Re: Run time changing

PostPosted: 29 Apr 2014 11:29
by Alexander Bulei

Re: Run time changing

PostPosted: 29 Apr 2014 11:35
by etwoss
Hi

The property 'LoadTheme' can not be one of the 'AdditionalThemes', they are not in the list.
Can this be made possible?

Eric

Re: Run time changing

PostPosted: 29 Apr 2014 11:42
by Jorge Sousa
Hi Eric

Can you please detail / explain this?

The property 'LoadTheme' can not be one of the 'AdditionalThemes', they are not in the list.


t.i.a.

Re: Run time changing

PostPosted: 29 Apr 2014 11:46
by etwoss
Hi

The ThemeSwitcher has a property called "LoadTheme", by default its value is "Start"
if i clean all cookies i see the swither coming with this theme as being the default
We have our own themes which we added to the property "AdditionalThemes"
So i hoped that if we can set our own theme in the property LoadTheme it wil use ours as the default to show if there is no cookie
However if you open the property list, the ones from the "AdditionalThemes" are not in the list


Added:

I changed the value for the property not from the property inspector but in the DFM, this hack works but is not so nice


Eric

Re: Run time changing

PostPosted: 29 Apr 2014 11:47
by etwoss
Hi

I named the cookie "INFOmatchCookie" and set CookiePath to the path the exe is in
However i can't find the file, searched whole HD, also set ShowHidden files to true

Eric

Re: Run time changing

PostPosted: 29 Apr 2014 11:52
by Jorge Sousa
Eric

In this case, a Cookie is temp file, you must clear the cookies in browser developer tools (F12).

And you don't have to set CookiePath.