different versions of moo

7 views
Skip to first unread message

hellspawn

unread,
Sep 8, 2009, 6:15:17 PM9/8/09
to MooTools Users
Hi
I want to take advantage of the last moo version - the $ safe mode.
What is happening if the user has allready an older version of
mootools on it's site?
thanks

Fábio M. Costa

unread,
Sep 8, 2009, 6:30:43 PM9/8/09
to mootool...@googlegroups.com
If the developer uses 1.2.2 or smaller there will be no document.id function, you should use the $ function instead.
If you want to use 1.2.3, just replace the old one with with 1.2.3. :S
It looks like you didnt asked what you really want.

--
Fábio Miranda Costa
Solucione Sistemas
Front-End Engineer
http://meiocodigo.com

rborn

unread,
Sep 9, 2009, 4:02:44 AM9/9/09
to MooTools Users
I want to upgrade Kroppr ( http://kroppr.rborn.info) to mootools
1.2.3.
This will allow me to simplify a lot the code, to be able to work with
other frameworks.

My question is what is happening if the user already has a version of
mootools on it's page. How my script can break his, or in reverse


On Sep 9, 12:30 am, Fábio M. Costa <fabiomco...@gmail.com> wrote:
> If the developer uses 1.2.2 or smaller there will be no
> document.idfunction, you should use the $ function instead.
> If you want to use 1.2.3, just replace the old one with with 1.2.3. :S
> It looks like you didnt asked what you really want.
>
> --
> Fábio Miranda Costa
> Solucione Sistemas
> Front-End Engineerhttp://meiocodigo.com

Fábio M. Costa

unread,
Sep 9, 2009, 8:58:22 AM9/9/09
to mootool...@googlegroups.com
You mean how can your script work with both versions?

What i usually do is something like this:

(function(){
  var $ = document.id || $;
 
  // use $ here and it will work fine with 1.2.x

})();

At this example if the user has mootools 1.2.3 and jquery for example it will get the document.id from mootools.
If he puts 1.2.2 and jquery it will get the dollar function from the last framework he've put on the page, i think.

This kind of make sure you'll have the mootools dollar function inside the closure (if you use 1.2.3 or greater) while making it work fine with 1.2.2 or smaller (if the user doesn't put another framework on the site).



--
Fábio Miranda Costa
Solucione Sistemas
Front-End Engineer
http://meiocodigo.com


Aaron Newton

unread,
Sep 9, 2009, 11:35:50 AM9/9/09
to mootool...@googlegroups.com
First, Fabio, no one needs to name $ to document.id to upgrade UNLESS they have another script that's using $ (like jQuery). That's not the case here.

Dan (I think that's your name, forgive me if not), your site is running on a *very* old version of MooTools. You'll need to upgrade. Upgrading is not a painless process as the API for the framework has changed. I *think* you're running a 1.0 version of MooTools; I can't tell, because back then we didn't put the version number in the download. You'll need to download MooTools 1.2 and replace your copy of MooTools with it. You'll then need to go through your code and rewrite the portions of it that need to change.

To help with this, you can use this compatibility layer:


If you include this after mootools 1.2 but before your code, it will post console warnings to you in firebug in all the places you're using deprecated methods. You should NOT leave this script in place in production. It's only there to help you upgrade.

Good luck.

2009/9/9 Fábio M. Costa <fabio...@gmail.com>

Fábio M. Costa

unread,
Sep 9, 2009, 11:54:41 AM9/9/09
to mootool...@googlegroups.com
Hi Aaron,

First, Fabio, no one needs to name $ to document.id to upgrade UNLESS they have another script that's using $ (like jQuery). That's not the case here.

Thats exactly what i said. Sorry if i wrote in a wrong way. English is not my native language and sometimes my points get a little confusing :S


rborn

unread,
Sep 9, 2009, 12:30:31 PM9/9/09
to MooTools Users
Hi Fabio, Aaron

Thanks a lot for your answers.
Aaron, yes, my name is Dan
I think I did not made myself very clear

I'll try to explain again

As you see Kroppr is a commercial application. The way is built now
allows me to use Mootools ( v1.11 ) with any other library, using
iframes. This makes the script slow, as iframes are costly, and the
code is a pain to maintain, not talking about the new features v1.2.3
has.

Now i want to use Mootools v1.2.3 to get the $safe mode - so I can
use this with any other library that uses $ - jquery, user made, etc

In the case the client uses jquery, will be no problems, I tested it,
with another script.

My concern is what is happening if the user already has mootools in
his site - any other version - of course 1.2.3 will not create
problems.
Will my script break his code ?

Can I avoid this?

Thanks a lot for your time.



On Sep 9, 5:35 pm, Aaron Newton <aa...@iminta.com> wrote:
> First, Fabio, no one needs to name $ to document.id to upgrade UNLESS they
> have another script that's using $ (like jQuery). That's not the case here.
> Dan (I think that's your name, forgive me if not), your site is running on a
> *very* old version of MooTools. You'll need to upgrade. Upgrading is not a
> painless process as the API for the framework has changed. I *think* you're
> running a 1.0 version of MooTools; I can't tell, because back then we didn't
> put the version number in the download. You'll need to download MooTools 1.2
> and replace your copy of MooTools with it. You'll then need to go through
> your code and rewrite the portions of it that need to change.
>
> To help with this, you can use this compatibility layer:
>
> http://gist.github.com/128335
>
> If you include this after mootools
> 1.2 but before your code, it will post console warnings to you in
> firebug in all the places you're using deprecated methods. You should
> NOT leave this script in place in production. It's only there to help
> you upgrade.
>
> Good luck.
>
> 2009/9/9 Fábio M. Costa <fabiomco...@gmail.com>
>
>
>
> > You mean how can your script work with both versions?
>
> > What i usually do is something like this:
>
> > (function(){
> >   var $ = document.id || $;
>
> >   // use $ here and it will work fine with 1.2.x
>
> > })();
>
> > At this example if the user has mootools 1.2.3 and jquery for example it
> > will get the document.id from mootools.
> > If he puts 1.2.2 and jquery it will get the dollar function from the last
> > framework he've put on the page, i think.
>
> > This kind of make sure you'll have the mootools dollar function inside the
> > closure (if you use 1.2.3 or greater) while making it work fine with 1.2.2
> > or smaller (if the user doesn't put another framework on the site).
>
> > --
> > Fábio Miranda Costa
> > Solucione Sistemas
> > Front-End Engineer
> >http://meiocodigo.com
>
> > On Wed, Sep 9, 2009 at 5:02 AM, rborn <dan.ta...@gmail.com> wrote:
>
> >> I want to upgrade Kroppr (http://kroppr.rborn.info) to mootools

rborn

unread,
Sep 9, 2009, 12:37:37 PM9/9/09
to MooTools Users
Me again
Fabio, can I isolate somehow the mootools lib and my code using a
closure?

If yes, can you give me some lines to follow ?

Thanks

On Sep 9, 2:58 pm, Fábio M. Costa <fabiomco...@gmail.com> wrote:
> You mean how can your script work with both versions?
>
> What i usually do is something like this:
>
> (function(){
>   var $ = document.id || $;
>
>   // use $ here and it will work fine with 1.2.x
>
> })();
>
> At this example if the user has mootools 1.2.3 and jquery for example it
> will get the document.id from mootools.
> If he puts 1.2.2 and jquery it will get the dollar function from the last
> framework he've put on the page, i think.
>
> This kind of make sure you'll have the mootools dollar function inside the
> closure (if you use 1.2.3 or greater) while making it work fine with 1.2.2
> or smaller (if the user doesn't put another framework on the site).
>
> --
> Fábio Miranda Costa
> Solucione Sistemas
> Front-End Engineerhttp://meiocodigo.com
>
>
>
> On Wed, Sep 9, 2009 at 5:02 AM, rborn <dan.ta...@gmail.com> wrote:
>
> > I want to upgrade Kroppr (http://kroppr.rborn.info) to mootools

Aaron Newton

unread,
Sep 9, 2009, 1:06:37 PM9/9/09
to mootool...@googlegroups.com
No, this is not possible. MooTools is not self contained as jQuery or YUI are. It enhances prototypes of things and uses the global namespace. Even if you could put it in a closure, you would still not be able to use two versions of it in the same page as both define native properties on arrays, functions, etc.

rborn

unread,
Sep 9, 2009, 1:20:18 PM9/9/09
to MooTools Users
Ok, then how I avoid that my script breaks the user's script ?
I'm thinking on this:

moo v1.11 $('el').setText('blah');
moo v1.2.x $('el').set('text','blah');

I belive that my script, if loaded last, will load mootools v1.2.3
that will overwrite his version, and will break the above line
Any way to avoid this, or I should stick with iframea ?

Aaron Newton

unread,
Sep 9, 2009, 1:35:59 PM9/9/09
to mootool...@googlegroups.com
actually, in that example, it wouldn't break, but it would break in dozens of other places.

I think you have to stick with iframes.

rborn

unread,
Sep 9, 2009, 1:47:42 PM9/9/09
to MooTools Users
Ok, thanks a lot for your help
Reply all
Reply to author
Forward
0 new messages