lift support for YUI and potentially other JS frameworks ...

9 views
Skip to first unread message

Marius

unread,
Aug 10, 2008, 5:26:09 AM8/10/08
to liftweb
Hi all,

I finished up the abstraction of JavaScript artifacts within lift core
code. Please see wip-marius-jslib branch. As I said in a previous
thread I tested it with YUI:

1. Comet
2. Ajax (ajax forms, notice etc)
3. JSon (json handler)
4. Etc.

So ... what did I do ...

1. Made a trait net.liftweb.http.js.JsArtifacts - basically this
abstract the JS operations that lift core code used but were dependent
on JQuery
2. Added LiftRules.jsArtifacts variablewhich by default points to the
JQuery implementation of JSArtifacts
(net.liftweb.http.js.jquery.JQueryArtifacts). It can be changed in
Boot to point to net.liftweb.http.js.yui.YUIArtifacts
3. In lift core classes I used LiftRules.jsArtifacts where JQuery was
used directly
4. Stuff from JsCommands.scala (JSExp's, JsCmd's etc) that were
specific to JQuery are now in
net.liftweb.http.js.jquery.JQueryCommands.scala. So because of this
your current application will fail tocompile if you're using such
JSExp's,JsCmd's etc. To fix this just add the appropriate imports
(import JqJE._, import JqJsCmds._ etc).
5. I moved the autocomplete stuff from SHtml to
net.liftweb.http.jquery.JqSHtml as this heavily depends on JQuery. I'm
not sure if everyone agrees with this it is just a proposal. I'm
opened to better ideas though.
6. Added liftYUI.js .. this is necessary when using YUI. The
motivation is that YUI doesn;t have some cool features that JQuery has
(at least I could not find them). For instance lift Ajax and Comet
typically uses JavaScript mime type as response. JQuery is smart
enough to know this and execute the JS payload. YUI connection-manager
just passes the content to the callback function. So liftYUI.js
contains the eval function which is inspired from JQuery
implementation which is inspired from
http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
. There are of course other things that I could not find in YUI as
simple artifacts like toggle. etc.

7. To use lift with yui the YUI scripts dependency is:
yahoo.js, event.js, dom.js, connection.js, json.js (YAHOO's script),
liftYUI.js

8. I added YUI scripts to be accepted by ResourceServer

I'll post soon a lift example that uses YUI on wiki.

Thoughts are always welcomed !

P.S.
This is not in the master branch until reviews are done and agreed.

Br's,
Marius

TylerWeir

unread,
Aug 10, 2008, 9:33:52 AM8/10/08
to liftweb
Excellent work, Marius!
> implementation which is inspired fromhttp://webreflection.blogspot.com/2007/08/global-scope-evaluation-and...

David Pollak

unread,
Aug 11, 2008, 12:35:30 AM8/11/08
to lif...@googlegroups.com
Marius,

This is awesome stuff.  Looking forward to playing with it next week.  This week, I'm on semi-vacation.

Thanks,

David
--
lift, the simply functional web framework http://liftweb.net
Collaborative Task Management http://much4.us
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp

Marius

unread,
Aug 11, 2008, 3:14:53 AM8/11/08
to liftweb
No worries David ... have a nice relaxing semi-vacation !

I'm looking forward for feedback from everywhere. In the meantime I'll
do more testing, wiki article etc.

Br's,
Marius

On Aug 11, 7:35 am, "David Pollak" <feeder.of.the.be...@gmail.com>
wrote:
> >http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and...
> > . There are of course other things that I could not find in YUI as
> > simple artifacts like toggle. etc.
>
> > 7. To use lift with yui the YUI scripts dependency is:
> > yahoo.js, event.js, dom.js, connection.js, json.js (YAHOO's script),
> > liftYUI.js
>
> > 8. I added YUI scripts to be accepted by ResourceServer
>
> > I'll post soon a lift example that uses YUI on wiki.
>
> > Thoughts are always welcomed !
>
> > P.S.
> > This is not in the master branch until reviews are done and agreed.
>
> > Br's,
> > Marius
>
> --
> lift, the simply functional web frameworkhttp://liftweb.net
> Collaborative Task Managementhttp://much4.us

philip

unread,
Aug 19, 2008, 9:18:23 AM8/19/08
to liftweb
Hi Marius,

Do you see any problem with mixing JQuery with YUI, why not keep the
JQuery for comet yet use YUI for different things such as UI
components/form components?
Have you seen the new YUI ? http://developer.yahoo.com/yui/3/
I would like to write some components as Scala classes for YUI, like
accordian, it would help me learning Liftweb better and contribute
towards an idea I have for a CMS.

Philip
> motivation is thatYUIdoesn;t have some cool features that JQuery has
> (at least I could not find them). For instance lift Ajax and Comet
> typically uses JavaScript mime type as response. JQuery is smart
> enough to know this and execute the JS payload.YUIconnection-manager
> just passes the content to the callback function. So liftYUI.js
> contains the eval function which is inspired from JQuery
> implementation which is inspired fromhttp://webreflection.blogspot.com/2007/08/global-scope-evaluation-and...
> . There are of course other things that I could not find inYUIas
> simple artifacts like toggle. etc.
>
> 7. To use lift withyuitheYUIscripts dependency is:
> yahoo.js, event.js, dom.js, connection.js, json.js (YAHOO's script),
> liftYUI.js
>
> 8. I addedYUIscripts to be accepted by ResourceServer
>
> I'll post soon a lift example that usesYUIon wiki.

Marius

unread,
Aug 19, 2008, 2:32:05 PM8/19/08
to liftweb
Hi,

Good questions.

1. Mixing JQuery and YUI is something that I would avoid as I don't
have yet seen any compatibility and coexistence tests. For instance $
function is overloaded in both AFAIK
2. The proposal here is more about abstracting JS library from lift
core and YUI implementation is for POC reasons.
3. If you want to mix JQuery and YUI you can now do that by
implementing by yourself JSArtifacts trait or simply use them in your
app.
4. Personally I don't see any reason why keep JQuery for Comet only
and the rest with some other library.

I haven't see YUI 3 yet but if you could integrate YUI 3 in lift
through these abstraction we'll probably owe you many beers ;) ... I
would welcome you to do it.


Please note that this is not yet in the master branch, hopefully David
(and other people) would have some time soon to review it so I can put
it into master.

Br's,
Marius

On Aug 19, 4:18 pm, philip <philip14...@gmail.com> wrote:
> Hi Marius,
>
> Do you see any problem with mixing JQuery with YUI, why not keep the
> JQuery for comet yet use YUI for different things such as UI
> components/form components?
> Have you seen the new YUI ?http://developer.yahoo.com/yui/3/

philip

unread,
Aug 19, 2008, 8:35:06 PM8/19/08
to liftweb
Hi Marius,

1. I didn't know YUI uses $ ? can you point me to an article/doc? They
have a Y. - Y.all('#demo li').on('click', onClick);
2. Yes thats your proposal
3. Thanks! I will use it
4. Since YUI doesn't help with comet (as far as we know), but I want
to use YUI's components such as calendar, tree, accordian to make a
CMS. I don't want to use JQuerys components as they are implemented by
different people and may have more bugs, eg, the tree may not be as
fully featured as YUI's.
So I want to use YUI for components, but I don't mind JQuery being
around for other things like AJAX and Comet or JSON transfer - if they
interoperate/co-exist peacefully.

Philip

Marius

unread,
Aug 20, 2008, 2:38:05 AM8/20/08
to liftweb
I could swear that I saw $ function in YUI somewhere but if I'm
wrong ... I'm wrong :)
Reply all
Reply to author
Forward
0 new messages