getting the browser's screen resolution?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

getting the browser's screen resolution?

Joseph Blatter
I know there's a discussion some time ago, but I haven't found a clear solution to get the browser's screen resolution. Is there a way to do this with Seaside?



__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
Regístrate ya - http://correo.espanol.yahoo.com/
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: getting the browser's screen resolution?

Lukas Renggli
> I know there's a discussion some time ago, but I haven't found a clear
> solution to get the browser's screen resolution. Is there a way to do this
> with Seaside?

There is no difference to PHP, JSP, RoR, ... whatever. You can
basically take any solution from there and take it over to Seaside.

If you use Scriptaculous something like that might work for you:

html script: (html request
        callback: [ :value | width := value ] value: (SUStream on:
'window.innerWidth || document.documentElement.clientWidth ||
document.body.clientWidth || 0');
        callback: [ :value | height := value ] value: (SUStream on:
'window.innerHeight || document.documentElement.clientHeight ||
document.body.clientHeight || 0'))

This generates a new request posting the current values into your
web-applications.  Maybe nicer would be to override #initialRequest:
and do a redirect posting the size, but that wouldn't be that simple
anymore.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: getting the browser's screen resolution?

Joseph Blatter
In reply to this post by Joseph Blatter
Hi Lukas. Since most methods in Seaside are undocumented, and it seems difficult to deduce what should I do from what you wrote, can you show me how to get those current values (how to trigger the callback to set weight and height)?
thanks!

----- Mensaje original ----
De: Lukas Renggli <[hidden email]>
Para: Seaside - general discussion <[hidden email]>
Enviado: domingo, 25 de marzo, 2007 5:26:22
Asunto: Re: [Seaside] getting the browser's screen resolution?

> I know there's a discussion some time ago, but I haven't found a clear
> solution to get the browser's screen resolution. Is there a way to do this
> with Seaside?

There is no difference to PHP, JSP, RoR, ... whatever. You can
basically take any solution from there and take it over to Seaside.

If you use Scriptaculous something like that might work for you:

html script: (html request
    callback: [ :value | width := value ] value: (SUStream on:
'window.innerWidth || document.documentElement.clientWidth ||
document.body.clientWidth || 0');
    callback: [ :value | height := value ] value: (SUStream on:
'window.innerHeight || document.documentElement.clientHeight ||
document.body.clientHeight || 0'))

This generates a new request posting the current values into your
web-applications.  Maybe nicer would be to override #initialRequest:
and do a redirect posting the size, but that wouldn't be that simple
anymore.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
Regístrate ya - http://correo.espanol.yahoo.com/
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: getting the browser's screen resolution?

Lukas Renggli
> Hi Lukas. Since most methods in Seaside are undocumented, and it seems
> difficult to deduce what should I do from what you wrote, can you show me
> how to get those current values (how to trigger the callback to set weight
> and height)?

I asked Google for you and transformed everything to Seaside. The only
thing remaining for you to do is to copy the code into a rendering
method and to create the instance-variables width and height.

> html script: (html request
>     callback: [ :value | width := value ] value: (SUStream on:
> 'window.innerWidth || document.documentElement.clientWidth
> ||
> document.body.clientWidth || 0');
>     callback: [ :value | height := value ] value: (SUStream on:
> 'window.innerHeight ||
> document.documentElement.clientHeight ||
> document.body.clientHeight || 0'))

The object returned by #request -- the class SURequest -- has a nice
class comment. The key method here -- #callback:value: -- is well
documented.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: getting the browser's screen resolution?

Joseph Blatter
In reply to this post by Joseph Blatter
Lukas, thanks for your reply. I've copied your code into a #renderContentOn: with a "self halt" to inspect the values of width and height and they are nil everytime, so that's why I've asked to you again.

>the class SURequest -- has a nice class comment

I don't know if I missing some package or something else, but you're saying this class comment in SURequest is enough for understanding how to use the class?
"Initiates and processes an AJAX request."
(sorry, as I'm not an AJAX programmer, I didn't expected to learn first Ajax to then get back to Smalltalk)

The method comment in #callback:value you're saying it's ok for understanding what does the method, and maybe as a developer concerned with the internals of the framework is even perfect and enough, but it's difficult to me (and I guess all first-time Scriptaculous users) to see the general context for its use. I've browsed 8 senders, most of them starts with #triggerSomething. 2 of them are documented but no senders, so I can't get a general view for it's use. Going to a sender of one of the #triggers...

renderContentOn: html
    html paragraph
        script: (html inPlaceEditor
            cancelLink: false;
            triggerInPlaceEditor: [ :value | text := value ];
            callback: [ :r | r render: text ]);
        with: text

it's unclear (at least for me) what the script's argument does, and when the trigger is made.

Sorry for asking this, but I think with more and good code comments the seaside community will be benefitted a lot and no-one will complaint for helping newbies (or unexperienced AJAX programmers) to use the framework easier.
thanks

----- Mensaje original ----
De: Lukas Renggli <[hidden email]>
Para: Seaside - general discussion <[hidden email]>
Enviado: lunes, 26 de marzo, 2007 3:49:02
Asunto: Re: [Seaside] getting the browser's screen resolution?

> Hi Lukas. Since most methods in Seaside are undocumented, and it seems
> difficult to deduce what should I do from what you wrote, can you show me
> how to get those current values (how to trigger the callback to set weight
> and height)?

I asked Google for you and transformed everything to Seaside. The only
thing remaining for you to do is to copy the code into a rendering
method and to create the instance-variables width and height.

> html script: (html request
>     callback: [ :value | width := value ] value: (SUStream on:
> 'window.innerWidth || document.documentElement.clientWidth
> ||
> document.body.clientWidth || 0');
>     callback: [ :value | height := value ] value: (SUStream on:
> 'window.innerHeight ||
> document.documentElement.clientHeight ||
> document.body.clientHeight || 0'))

The object returned by #request -- the class SURequest -- has a nice
class comment. The key method here -- #callback:value: -- is well
documented.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
Regístrate ya - http://correo.espanol.yahoo.com/
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: getting the browser's screen resolution?

Lukas Renggli
> Lukas, thanks for your reply. I've copied your code into a #renderContentOn:
> with a "self halt" to inspect the values of width and height and they are
> nil everytime, so that's why I've asked to you again.

Did you add SULibrary to the list of libraries of your application?

Another possibility is that your browse doesn't work with
Scriptaculous, but that is less likely.

> I don't know if I missing some package or something else, but you're saying
> this class comment in SURequest is enough for understanding how to use the
> class?
> "Initiates and processes an AJAX request."
> (sorry, as I'm not an AJAX programmer, I didn't expected to learn first Ajax
> to then get back to Smalltalk)

Well, you asked how to get the browser size. Unfortunately there is no
easy way to get to this information. No matter what framework you use
you need some dirty Javascript tricks (as far as I know). You don't
necessarily need AJAX tough.

If you are not into JavaScript and HTTP hacking you should maybe
rethink if you really need this information and start with something
simple? Later on it will be certainly easier to find a solution that
works well for you.

> The method comment in #callback:value you're saying it's ok for
> understanding what does the method, and maybe as a developer concerned with
> the internals of the framework is even perfect and enough, but it's
> difficult to me (and I guess all first-time Scriptaculous users) to see the
> general context for its use. I've browsed 8 senders, most of them starts
> with #triggerSomething. 2 of them are documented but no senders, so I can't
> get a general view for it's use. Going to a sender of one of the
> #triggers...

These triggers are just convenience methods for #callback:value: to
convert the result to objects, etc.

> Sorry for asking this, but I think with more and good code comments the
> seaside community will be benefitted a lot and no-one will complaint for
> helping newbies (or unexperienced AJAX programmers) to use the framework
> easier.

We are constantly adding comments. Moreover there are many threads in
the mailing-list about the use of specific features of Seaside, such
as the Scriptaculous integration. One thing that is crucial in this
context (and any other context involving Javascript) is that you use
FireFox with FireBug (http://www.getfirebug.com/) loaded. Using this
tool you will be able to tell exactly why the code doesn't work for
your.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside