Shape 5

Joomla Free Extensions => Image and Content Fader - Free => : brandokx70 July 25, 2016, 03:36:28 PM



: [SOLVED] overriding a Mootools function (periodical())
: brandokx70 July 25, 2016, 03:36:28 PM
Image and Content Fader v3
Hello, I have been told by another forum that this module overriding a Mootools function (periodical()).  

This is stopping a form module of mine with Mootools to not process properly.  Can the code be modified to not override that function prototype, or call the original when they've finished doing whatever it is it needs to do?

Thanks in advance.
J3.6

P.S. I just realized my extension wasn't up to date so I updated to v4.  Still having the same problem. Is there a setting or a way to change this?
https://www.ridersurance.com/
Image and content fader module is at the top, and the other module that isn't processing is at the bottom "Pick A Plan"


: Re: overriding a Mootools function (periodical())
: mikek July 26, 2016, 06:29:38 AM
Hello,

This module does not use mootools, it is jquery only. Other Joomla modules really shouldn't be using Mootools anymore either, the switch to Jquery has been in effect for over three years at this point.

periodical is not a function that we declare, that is a default function of the javascript library itself, so it's not something we can change. I also checked your site and didn't see any javascript errors on the page.


: Re: overriding a Mootools function (periodical())
: brandokx70 July 26, 2016, 07:31:19 AM
Thanks, I am assuming v3 was mootools and v4 switched to jquery.

Thanks for the response.


: Re: overriding a Mootools function (periodical())
: brandokx70 July 26, 2016, 11:30:07 AM
Hi Mike, thanks again for your help I have a little more info.

What about this line of code?

Function.prototype.periodical=function (c,b,a){return setInterval(this.passx((a==null?[]:a),b),c);};

... in jd.gallery.jquery.js, overrides the Mootools periodical() function.

When any other Mootools code calls periodical(), it is calling your function, instead of Mootools'.

Is it possible to use some other function name, perhaps jdPeriodical.

Thanks again in advance.



: Re: overriding a Mootools function (periodical())
: mikek July 26, 2016, 01:34:19 PM
Hello,

We can try doing a find a replace for periodical to something else in the js file, but we are not going to re-write our script because another script is using the same name. You would have to replace all calls of periodical with a new function, it's not tested though, so no guarantees that it will work.


: Re: overriding a Mootools function (periodical())
: brandokx70 July 26, 2016, 02:30:23 PM
I am a little confused. It's not "another script", it part of the Mootools framework:

http://mootools.net/core/docs/1.5.2/Types/Function#Function:periodical

Mootools may have fallen out of favor and is being deprecated in J! in favor of jQuery, but it is still a major JS framework library, and is still shipped with J!.

Overriding global function prototypes is NOT something which should be done lightly, and DEFINITELY should not tread on things like jQuery or Mootools.

I have a coder that states:
"There's absolutely no reason they need to do that, they could do it in native jquery, or put those functions in a "closure" so they don't pollute the global Javascript name space."

Can you pass this along to Shape5's coder?  If not I will just have to find another image and content type of module....

Thanks in advance.


: Re: overriding a Mootools function (periodical())
: mikek July 27, 2016, 05:31:05 AM
Hello,

It appears those calls are remnants of when the module was converted from mootools too jquery. I have commented out each line that calls periodicial and tested the script and it is working fine without them. We now are not calling this anywhere in our script. You can download the latest version of the module or use the attached js file.


"Mootools may have fallen out of favor and is being deprecated in J! in favor of jQuery, but it is still a major JS framework library, and is still shipped with J!."

-----I am only stating that as a precaution. Joomla has made it very clear that it will be deprecated from their CMS soon. If the developer hasn't updated by now you may very well be stuck with a script that no longer works soon.


: [SOLVED] Re: overriding a Mootools function (periodical())
: brandokx70 July 27, 2016, 12:54:43 PM
Thank you for the fix. Works now.

Cheers!