Wrapping an external javascript how to

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

Wrapping an external javascript how to

garduino
Hi:

I'm starting to learn about Amber and a thing I would like to know is
how to wrap (some starting points) an external javascript library, for
example the Google GData or any other.

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Wrapping an external javascript how to

gokr
Hi!

On the subway right now but basically you will not need to "wrap" it. You just use it. But yes, we should explain this with examples in the docs or the wiki in more detail.

The idea btw is for all of us to use the wiki as a ... note book, and then we will pull stuff from it into the proper doc system step by step and typically make the wiki pages eventually just point into the docs.

Sound like a good idea? The new doc system by Nicolas is sweet indeed so the docs is basically just an Amber app dynamically built from reflecting on class comments (now in markdown syntax!). And oh, it uses a js lib for rendering markdown - no wrapping needed. :)

regards, Göran



-- Sent from my Palm Pre 2, wohoo!


On Jan 17, 2012 22:07, Germán Arduino <[hidden email]> wrote:

Hi:

I'm starting to learn about Amber and a thing I would like to know is
how to wrap (some starting points) an external javascript library, for
example the Google GData or any other.

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Wrapping an external javascript how to

garduino
Hi Göran:

On 18 ene, 05:44, "Göran Krampe" <[hidden email]> wrote:
> Hi!
> On the subway right now but basically you will not need to "wrap" it. You just use it. But yes, we should explain this with examples in the docs or the wiki in more detail.

Yes, some example please. I understand that I can invoke a javascript
from inside Amber, but, how to use it "a la Smalltalk"? I mean how to
use methods and messages? Or I must to generate html and embbed the
original external javascript?

Cheers.
Reply | Threaded
Open this post in threaded view
|

Re: Wrapping an external javascript how to

laurent laffont
On Wed, Jan 18, 2012 at 10:25 PM, Germán Arduino <[hidden email]> wrote:
Hi Göran:

On 18 ene, 05:44, "Göran Krampe" <[hidden email]> wrote:
> Hi!
> On the subway right now but basically you will not need to "wrap" it. You just use it. But yes, we should explain this with examples in the docs or the wiki in more detail.

Yes, some example please. I understand that I can invoke a javascript
from inside Amber, but, how to use it "a la Smalltalk"? I mean how to
use methods and messages? Or I must to generate html and embbed the
original external javascript?


It uses several js libs, in a Widget I have:

BookWidget>>renderScriptsOn: html

      #( 'booklet/jquery.easing.1.3.js'
  'booklet/jquery.booklet.1.2.0.min.js' 
          'iviewer/jquery.iviewer.min.js'
          'iviewer/jquery.mousewheel.min.js'
          ) do: [:anUrl| 
                           html script
                            type: 'text/javascript';
                                src: anUrl]


Then for jQuery plugins it's easy:

'div#mydiv' asJQuery booklet: (HashedCollection new 
                                                              at: 'pageSelector' put:false; 
                                                              at: 'chapterSelector' put:true ).

in js that would be:

$('div#mydiv') booklet( { pageSelector: false, chapterSelector: true  } );

For js libs that have methods with underscore may be less easy:

anElement onClick: [<aViewer.zoom_by(1)>].

in js:

anElement.onClick(function() {aViewer.zoom_by(1)});


Laurent



 

Cheers.

Reply | Threaded
Open this post in threaded view
|

Re: Wrapping an external javascript how to

garduino
Thanks Laurent!

Very useful example.

Cheers.
Germán.

On 18 ene, 18:50, laurent laffont <[hidden email]> wrote:

> On Wed, Jan 18, 2012 at 10:25 PM, Germán Arduino <[hidden email]> wrote:
> > Hi Göran:
>
> > On 18 ene, 05:44, "Göran Krampe" <[hidden email]> wrote:
> > > Hi!
> > > On the subway right now but basically you will not need to "wrap" it.
> > You just use it. But yes, we should explain this with examples in the docs
> > or the wiki in more detail.
>
> > Yes, some example please. I understand that I can invoke a javascript
> > from inside Amber, but, how to use it "a la Smalltalk"? I mean how to
> > use methods and messages? Or I must to generate html and embbed the
> > original external javascript?
>
> Some example code used onhttp://mediatheques.agglo-moulins.fr/bible-souvigny/index.html
>
> It uses several js libs, in a Widget I have:
>
> BookWidget>>renderScriptsOn: html
>
>       #( 'booklet/jquery.easing.1.3.js'
>    'booklet/jquery.booklet.1.2.0.min.js'
>           'iviewer/jquery.iviewer.min.js'
>           'iviewer/jquery.mousewheel.min.js'
>           ) do: [:anUrl|
>                            html script
>                             type: 'text/javascript';
>                                 src: anUrl]
>
> Then for jQuery plugins it's easy:
>
> 'div#mydiv' asJQuery booklet: (HashedCollection new
>                                                               at:
> 'pageSelector' put:false;
>                                                               at:
> 'chapterSelector' put:true ).
>
> in js that would be:
>
> $('div#mydiv') booklet( { pageSelector: false, chapterSelector: true  } );
>
> For js libs that have methods with underscore may be less easy:
>
> anElement onClick: [<aViewer.zoom_by(1)>].
>
> in js:
>
> anElement.onClick(function() {aViewer.zoom_by(1)});
>
> Laurent
>
>
>
>
>
>
>
>
>
> > Cheers.