it would be done like this...
var MT = (function(){
// all of MooTools
// return some object containing MooTools functionality
})();
This is basically what Yahoo does everywhere, and the whole premise
behind jQuery, a single object in the global namespace. Again though,
that "all of MooTools" line wont exactly work, because we use our
global collections and native prototypes throughout. Anywhere you see
a MooTools method on an Array, String, Number, etc would have to be
changed to use generic functions instead, so this kind of defeats the
purpose of an Object-oriented coding style...
On Oct 14, 2008, at 2:35 AM, nutron wrote:
My 2 cents here:
1) Everything Tom said and everything Nate said, I agree with. You
shouldn't run two frameworks. MooTools isn't trying to be
compatible. Yada yada. Prototype frameworks can't play nice no
matter what, etc.
2) That said, academically I think there's an easy way to do this:
closure.
(function(){
//ALL OF MOOTOOLS
//ALL YOUR CODE
})();
It's not the same thing as having a version of MooTools that plays
nice, but it would work.
You could allow methods to "escape" the closure, but this would be
more tricky:
var MT = {};
(function(){
//ALL OF MOOTOOLS
MT.$ = $;
MT.$type = $type;
MT.Drag = Drag;
etc.
})();
MT.$('foo');
Yes, methods like $ need $type, but those are available to $ via
closure. This would work, no?
On Mon, Oct 13, 2008 at 9:36 PM, nwhite <ml-user
[EMAIL PROTECTED]> wrote:
Tom,
I realize anything using the prototype chain is doomed to this fate.
While it would be next to impossible to create a compatibility mode
between Mootools & Prototype it would however be theoretically
possible to do so with a namespaced framework.
I guess I need to clarify my goals and expectations. I apologize for
the title of the post, its has an element of sensationalism ;-) I
never expected nor thought it was worth pursuing a compatibility
level that would recreate another frameworks API with mootools. Nor
was it my goal or focus to even worry or deal with other prototype
based frameworks. My goal was to try and make Mootools peacefully
coexist with other namespaced frameworks, particularly JQuery.
I use Mootools on a daily basis and I am aware of all the
complexities you pointed out. At the same time I have been required
to be familiar with JQuery. I believe it was Jan that said earlier
"that it is not an optimal solution to have two frameworks
coexisting". The extra overhead, the duplication etc all take away
the advantages. I do my absolute best to avoid even finding myself
in a situation where this might happen. I also feel that if such a
solution existed it should not be supported by Mootools as the
levels of technical issues multiply. It is best to have someone
leave and focus on a single framework. Rather then getting tied up
in knots with two frameworks and javascript. So far I hope were on
the same page ;-)
I brought this up because I have had experience making JQuery and
Mootools code running in the same page. Its not pretty but it is
possible. I apologize for bring this into open discussion as it will
only result in headaches. With the "holiday" I had too much time to
ponder the post about Wordpress plugins using Mootools while facing
the Jquery dependency. I love Mootools, I hate touching anything
else and I thank you and the rest of the team daily as you make my
day of coding that much easier and enjoyable.
I will try and refrain from such radical hypothesis testing in the
future.
Nathan
On Mon, Oct 13, 2008 at 11:42 PM, Iván N Paz <[EMAIL PROTECTED]> wrote:
1 "?" wouldn't convey my concern/intrigue on this :-P
> ps: @Iván, one question mark (?) is enough!
The MooTools Tutorial: www.mootorial.com CNET Clientside:
clientside.cnet.com
View this message in context: Re: Mootools compatibility mode
Sent from the MooTools Users mailing list archive at Nabble.com.