Mootools upgrade system plugin issue

108 views
Skip to first unread message

pollen8

unread,
Jul 29, 2010, 6:08:51 AM7/29/10
to Joomla! General Development
Hi All

I'm trying to update fabrik to use the new 1.5.20 mootools 1.2.4
system plugin, whilst at the same time providing support for mootools
1.1.

I've come across a pretty important issue (well for my code at least),
take a look at this sample code:

Animal = new Class({
test:function(){
alert('animal');
}
});

Man = Animal.extend({
test:function(){
alert('man');
}
});

var rob = new Man().test();

within Joomla 1.5.20 with the mootools upgrade plugin enabled:

* in firefox you get an alert 'man'
* in IE8 you get an alert 'animal'

I have 30 or so classes that rely on .extend, and I can't update them
to use .implement() as that will break them for mootools 1.1

My only current 'fix' for this is to convert all my .js files to .php
files and load them as:

$method = useExtendOrImplement();
JHTML::script('script.php?method='.$method, 'path/to/script');

with the start of script.php looking like:

<?php header('Content-type: text/javascript'); ?>
var FabRadiusSearch = FbTablePlugin.<?php echo $_GET['method']?>({
});

This isn't really a clean solution and I was wondering if the bug was
a known issue and if anything can be done about it?

Looking at
http://github.com/mootools/mootools-upgrade-helper
It says the native objects' extend() method has been altered, but I'm
presuming that doesn't apply to the Class object()?

In fact later on it says:
'All of these items below are addressed in the upgrade helper /
compatibility script.........
Class.extend in 1.1 is accomplished by using the Extends mutator in
1.2.'

HELP! :D

-Rob Clayburn

dukeofgaming

unread,
Jul 29, 2010, 10:43:32 AM7/29/10
to joomla-de...@googlegroups.com
http://mootools.net/docs/more/Class/Class.Refactor
http://mootools.net/docs/core/Class/Class#Class:implement

=)


--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.


anutron

unread,
Jul 29, 2010, 12:58:33 PM7/29/10
to Joomla! General Development
Hi Rob,

We (the MooTools team) will see if we can get this working right in
the next day or three.

Aaron
> Looking athttp://github.com/mootools/mootools-upgrade-helper

fakedarren

unread,
Jul 29, 2010, 4:14:38 PM7/29/10
to Joomla! General Development
Hi Rob,

Unfortunately when we made the upgrade script, one of the things we
couldn't make work 100% was this.

Instead of writing (from your example) Animal.extend, you have to do:

var Man = new Class({

Extends: Animal,

test:function(){
alert('man');
}

});

We tried as hard as possible to make the upgrade helper (or compat
layer :D) 100% but unfortunately this was one of the things we
couldn't automate. If we'd made this class extension syntax work we'd
have broken something else and we had to choose one or the other.

Sorry! You can almost always find me on our IRC channel (#mootools on
freenode.net) if you have any questions.

Regards
Darren

Louis Landry

unread,
Jul 29, 2010, 4:31:21 PM7/29/10
to joomla-de...@googlegroups.com
Thanks Aaron and Darren.  It's much appreciated!

- Louis

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.




--
Development Coordinator
Joomla! ... because open source matters.
http://www.joomla.org

Oli Griffiths

unread,
Jul 30, 2010, 4:04:23 AM7/30/10
to joomla-de...@googlegroups.com
Hey Guys,

If I can throw in my 2 cents:

Try this:

Class.prototype.extend = function(properties){
   var proto = new this(null);
   proto = $extend(proto, properties)   
    return new Class(proto);
};


To replace the existing extend method in the compatibility layer. Seems to work for me :)

Oli


On 29/07/2010 21:31, "Louis Landry" <louis....@joomla.org> wrote:

Thanks Aaron and Darren.  It's much appreciated!

- Louis

On Thu, Jul 29, 2010 at 3:14 PM, fakedarren <darren....@gmail.com> wrote:
Hi Rob,

Unfortunately when we made the upgrade script, one of the things we
couldn't make work 100% was this.

Instead of writing (from your example) Animal.extend, you have to do:

var Man = new Class({

  Extends: Animal,

  test:function(){
    alert('man');
  }

});

We tried as hard as possible to make the upgrade helper (or compat
layer :D) 100% but unfortunately this was one of the things we
couldn't automate. If we'd made this class extension syntax work we'd
have broken something else and we had to choose one or the other.

Sorry! You can almost always find me on our IRC channel (#mootools on
freenode.net <http://freenode.net> ) if you have any questions.
> > It says the native objects' extend() method has been altered, but I'm
> > presuming that doesn't apply to the Class object()?
>
> > In fact later on it says:
> > 'All of these items below are addressed in the upgrade helper /
> > compatibility script.........
> > Class.extend in 1.1 is accomplished by using the Extends mutator in
> > 1.2.'
>
> > HELP! :D
>
> > -Rob Clayburn

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To post to this group, send an email to joomla-de...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.




 
Oli Griffiths
Development Director
Organic Development Ltd.




Contact Organic Development:
Telephone: 0845 869 7654
Web: http://www.organic-development.com
Email: in...@organic-development.com
Twitter: http://twitter.com/growwithorganic


This email and any attachments to it may be confidential and are intended solely for the use of the individual to whom it is addressed. Any views or opinions expressed are solely those of the author and do not necessarily represent those of Organic Development Ltd.
If you are not the intended recipient of this email, you must neither take any action based upon its contents, nor copy or show it to anyone.
Please contact the sender if you believe you have received this email in error.

pollen8

unread,
Jul 30, 2010, 7:40:56 AM7/30/10
to Joomla! General Development
wow thanks Guys for all the answers :)

@Darren & dukeofgaming - the issue with updating the code to mootools
1.2 only, is that it wont work if the user has the mootools upgrade
plugin disabled or they are using an earlier version of Joomla?

@Oli - many many many thanks for that it seems to work for me yeah!
Aaron could you take a look at that code snippet and see if it works
for you and perhaps add it the compat lib?

Cheers
Rob

pollen8

unread,
Jul 30, 2010, 9:46:51 AM7/30/10
to Joomla! General Development
A quick follow up on Oli's script. Its working great, the only caveat
that i've found is that if you have

Animal = new Class({

initialize:function(){
$('button').addEvent('click', function(){alert('hi');});
}

});

Man = Animal.extend({
initialize:function(){

}

});

window.addEvent('load', function(){
var rob = new Man();
});

Animal.initialize() seems to get called when the Man class is
included, not when its instatiated, producing a js error as 'button'
isnt yet in the dom.

Not a biggy as I can work round that but just thought I'd share :)

=Rob
Reply all
Reply to author
Forward
0 new messages