Update: Use MooTools v1.2.x in Joomla! 1.5

Homepage > Diary > Coding > Update: Use MooTools v1.2.x in Joomla! 1.5

Sun 06/07/2009

in Coding, Internet, JavaScript, PHP

Since i’ve fixed some bugs and issues on the files to switch core MooTools v1.11 to v1.2.x and following the release of version 1.2.2 1.2.3 of MooTools Core and More, i’m posting here an updated version of this workaround to which you could refer for details on how this code works.

Changes in this new version are:

  1. Updated MooTools Core to 1.2.2 1.2.3 and MooTools More to 1.2.2.2 1.2.3.1
  2. Added .getValue() to the compatibility file
  3. Added .getSelected() to the compatibility file to fix some issues under IE
  4. Added Json support to the compatibility file
  5. Added window.onDomReady shortcut for DOM ready event
  6. Changed MY_Behavior::mootoolsFix(); to handle new MooTools files 
  7. Changed MY_Behavior::mootoolsFix(); to correctly render old tooltips format title::text for items with hasTip class (anyway, remember that classes to style the tooltip have changed!)
  8. Added a validate.js replacement to fix an issue with changed namespaces. ( this replacement is no more needed)

The source code is released in the form of patch: unzip it and upload files in your Joomla root, eventually overwriting files. MooTools library is uncompressed to allow for a quicker debug. Anyway you may minify it with your tool of choice.

Here is the code: Mootools 1.11 to 1.2.2 (71.68 KB)

Update (again): Sometimes i can’t get if MooTools team is too vital or library milestones are not well defined… anyway here is an update to use latest MooTools 1.2.3. No major changes have been made to the fix library, anyway keep reporting compatibility issues. Here is the zipped  file: Mootools 1.11 to 1.2.3 for Joomla 1.5 (72.06 KB)

Update (09/20/09): New version available. Corrected some bugs in the compatibility file and added a loop check to replace MooTools 1.11 when called from a component as custom script. Now the validation core script doesn’t need to be replaced. Get source here (carries the original validate.js as in Joomla 1.5.14:  MooTools 1.11 to 1.2.x (72.88 KB)

Share this:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • BlinkList
  • blogmarks
  • DZone
  • LinkedIn
  • MySpace
  • NewsVine
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • Ping.fm
  • Yahoo! Buzz

Tags: , ,

58 Responses to this post:

  • [...] Update: A new version of files presented in this post is available here! [...]

  • andersen says:

    great fix! i have set to false for now since lord knows when you’ll ((if you’ll check 8-))

    it prevents the error in IE 7.

    BUT, will not load subsequent MODS ((on interior site pages)

    they pretend they are loading 8-)!

    any suggestion appreciated.

    thanks for the excellent workaround

  • Dan says:

    The hack works great with my Highslide and AllVideos Reloaded plgs but I’m having a problem with my mod_jaslideshow on the frontpage. IE throws me an error on the page:

    Webpage error details

    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
    Timestamp: Thu, 2 Jul 2009 16:37:38 UTC

    Object doesn’t support this property or method, Line: 187, Char: 3, media/system/js/mootools-compat-111-121.js

  • Dan says:

    I only use the mod_jaslideshow on the frontpage. Can I exclude mod_jaslideshow from the hack? how do i do that?

    OR

    Can I switch library right on my template’s index.php module call:

    PLEASE HELP!!! :) :)

    • Dwight Jack says:

      Hi,
      you may exclude the hack from the fronpage by placing the hack code inside this if code:

      $menu = &JSite::getMenu();
      if ($menu->getActive() != $menu->getDefault()) {
      JLoader::import( 'my_libs.behavior' );
      MY_Behavior::mootoolsFix();
      }

      This way when the active menu will be the default one (so you are in the homepage) the hack won’t be loaded.

      Anyway it’ll be nice if you can provide me with a link to the page so that i can try to fix the error :)

  • Dan says:

    Sure! It’s currently under developemnt: http://www.kiinga.com

  • Dan says:

    Can I put some code under:

    isContentEdit() && $this->countModules(‘ja-slideshow’)){ ?>

    • Dwight Jack says:

      Well, i think that if you wanna prevent it to load with ja-slideshow you’ll have to put it in this code:

      if (! $this->countModules('ja-slideshow')) {
      // here the hack
      }

      Anyway, i’ve looked at the problem, but im unsure where the issue is. I’ll try to analyze it deeper in the next days.
      Bye

      PS: nice project ;)

  • Dan says:

    You are a genius! I added the hack as a separate argument right before calling the module and it worked!

    Thanks a lot for your extremely quick response and thank you for your compliments on the site. Here’s the code I implemented:

    // countModules(‘ja-slideshow’)) {
    // JLoader::import( ‘my_libs.behavior’ );
    // MY_Behavior::mootoolsFix();
    // } ?>

    • pcrew says:

      Dan,

      I am using jaslideshow as well. I kinda understand that these hacks you are having are on index.php but I am confused how does it work?

      doesn’t this mootools hacks by dwight jack upgrade our Joomla 1.5 mootool?

      seems like just inserting

      //Jloader:: import(‘my_libs.behavior’);
      //MY_Behavior:mootoolsFix();

      from the looks of it.

      Please advise and thanks!

      • pcrew says:

        *seems like just inserting the codes would work from the looks of it.

      • Dwight Jack says:

        Hi,
        actually the hack works like this: Joomla stores all components and core JS needed in an array and plans to output it in the head template tag (< jdoc::include type=”head” />) . The hack just cycles the array before is rendered as HTML tags and substitutes every occurrence of the mootools files with the new version one.
        Of the two lines of code you quoted, the 1st loads a library which contains the substitution routines, the other just launches them.

        • pcrew says:

          ah i see.

          thanks dwight jack! i have applied your hack but have not make any changes regarding this ja-slideshow but it still works!

          weird maybe i am missing something but good thing is, it works now :)

          ps: see the result of it on my site :)

  • Dan says:

    Sorry, tags don’t work with your posting system. Your should try to implement some bbCode for people to paste code [code][/code]

  • jamland says:

    Thanx, that’s exactly what I need. I also did changes in /libraries/joomla/html/html/behavior.php to prevent default mootools1.1 loading. Don’t know why but it’s doesn’t want load mootools1.2 without it.

  • jamland says:

    Sorry forgot to ask my question… How I can change it to Moo 1.2.3?

    • Dwight Jack says:

      Thanx for the feedback.
      To answer (with another question) to your previous comment: is your installation in a subfolder?

      To answer to your Mootools version question: if you take a look to the mootoolsFix class method, you’ll see that it points to Mootools JS files. Just download new Mootools library files and change the PHP code to point to the right file names.
      If no major changes are made to the framework, i wouldn’t have any problem.
      Anyway im planning to release an updated version of the class.

      bye!

      • jamland says:

        Sorry I was not correct.
        I find my problem with trying stop loading Mootools1.1. I am very-very new with PHP so your code for me is hard. I will try with it more but for now I did some changes with mootools function in /Joomla/libraries/joomla/html/html/behavior.php:
        global $mainframe;
        if ($debug || $konkcheck) {

        JHTML::script(‘mootools-uncompressed.js’, ‘media/system/js/’, false);

        }
        elseif ($mainframe->isSite()) {

        JHTML::script(‘mootools-1.2.2-core.js’, ‘media/system/js/’, false);
        JHTML::script(‘mootools-1.2.2.2-more.js’, ‘media/system/js/’, false);
        JHTML::script(‘mootools-compat-111-121.js’, ‘media/system/js/’, false);
        JHTML::script(’switcher.js’, ‘media/system/js/’, false);
        JHTML::script(‘validate.js’, ‘media/system/js/’, false);

        //Otherwise, use the stable 1.11
        }else{
        JHTML::script(‘mootools.js’, ‘media/system/js/’, false);

        }
        $loaded = true;
        return;

        That’s what I found by googling. I know it’s not best manner but…
        Thanks for your feedback I’ll try with mootools1.2.3.

  • James says:

    Thanks for this patch. I`m going to test it and i post again. But still thank you.

  • Barry Roggeveen says:

    I just did the fix on my site, but now I get an error on the frontpage syaing:

    JHTMLBehavior::caption not found in file.
    JHTMLBehavior::mootools not found in file.

    and on the backend I get:

    JHTMLBehavior::mootools not found in file.
    JHTMLBehavior::mootools not found in file.
    JHTMLBehavior::tooltip not found in file.

    Did I miss something? Please help and thanks in advance.

    Barry

    • Dwight Jack says:

      Hi,
      seems like your are having some problems with a missing Joomla core library. It’s located in /libraries/joomla/html/html/behavior.php
      check if the file exists and it’s not empty

  • notbanksy says:

    I’m using this method as defined for moo 1.2.1 as this is the version I’ve been working with for my menu script.
    I’m checking the page in firebug, and apparently, all the js is loading. Moo 1.11 and moo 1.2.1 – is this right? Needless to say, my menu doesn’t work, but the joomla backend does.
    Any advice much appreciated :)

  • notbanksy says:

    Ok – I’ve figured it out. If anyone else can’t get it to work, try this:
    Remove this bit of code from your template’s index.php file

    then manually add the mootools.js and any css for your page.
    The back end will still work because it doesn’t use your template, so it will load moo 1.11. Easy!

  • notbanksy says:

    meh
    the code to remove is
    < jdoc::include type=”head” />

    • Dwight Jack says:

      Well no,
      if you’are removing the head tag from Joomla, you’re loosing also all the meta tags and external CSS. You’d better investigate why you script is not working (you can send me a link, if u want, so i can help you).
      bye!

  • pcrew says:

    hi all,

    my site works fine with existing js except for this specific component SIMgallery:

    so inside index.php above

    make it half workings and there is still some errors which I couldn't solve by my own.

    the dev claims the typical issue raised bcoz of SIMgallery is using Mootools 1.2. Using this hack I managed to get it works on some parts, while others part remain problematic.

    thanks for the concern and please advise.

    http://forum.joomla.org/viewtopic.php?f=471&t=427770&p=1805759#p1805759

  • Bill says:

    This is just what I needed. I will detail any issues I come across if any.

    Thanks.

    • Bill says:

      I get..
      Window.onDomReady(function(){
      126 document.formvalidator.setHandler(‘passverify’, function (value) { return ($(‘password’).value == value); } );
      127 });

      This occurs when I load my home page while not logged in. It seems to be getting thrown from com_user registration which is currently my default front page. The site is not live. Registration seems to be working fine though.

  • jakobe says:

    I have applied this to my joomla 1.5.14 and RT template affinity 1.5.5

    the purpose was to get SimGallery to work..and although SimGallery does now work ..anything form the template that used mootools does not.

    and shadwobox is not loading either

    and also in IE I now get a error overflow stack at line 77

    and these errors

    Message: ‘getSize().size.x’ is null or not an object
    Line: 150
    Char: 48
    Code: 0
    URI: http://www.stripperhq.com/media/system/js/mootools-1.2.3-core.js

    Message: Object doesn’t support this property or method
    Line: 2908
    Char: 3
    Code: 0
    URI: http://www.stripperhq.com/media/system/js/mootools-1.2.3-core.js

    Ideally I just need the SimGallery to load the newest version or at least 1.2 version of mootools, I need the rest of the site to rely on 1.11 or 1.14 or what it was orgianly using…..is this possible?

    the developer at SimGallery doesnt really seem to have any answers for me, and neither does RT

    suggestions?

    • Dwight Jack says:

      Hi. Many methods with same name have changed a lot from 1.11 to 1.2x .getSize() now returns an object with ‘x’ and ‘y’ keys only while in 1.11 was different. I should see a live example to digg the problem though.

  • Clone says:

    Not working for me at all… getting the error:

    this.setOptions is not a function
    in modal.js

    • Dwight Jack says:

      That’s because the script should load an updated version of modal.js which is included in my package. Try downloading the latest version and see if it works.

  • oppo GOP says:

    It lunacy developers JOOMLA —
    make forced users to download large mootools!!
    There is a much better script Jquery – easier and more convenient

    • Dwight Jack says:

      Honestly im a jQuery fan 2, but since Joomla’s core JS Framework is MooTools and right now u need it ’cause is largely used from templates, modules and components. I think that loading jQuery 2 would result in a performance issue :)

  • Bill says:

    There are some new features in Mootools 1.2.4 that I would like to use. I am going to load the latest version and report any issues with Joomla 1.5.14.

  • EDark says:

    Hi all! There are errors in the Chronoforms.

  • EDark says:

    error in com_contact in ie 5.5 =) this.ownerDocument.window is null (core)

  • mootools says:

    This is what I needed.Thanks.

  • Jim Mooney says:

    I tried this but the top menus in the back end no longer work. Am I missing something?

  • Jim Mooney says:

    I didn’t use it for the backend on purpose. I must be doing something wrong. Anyway, I decided to use Dojo until Joomla 1.6 comes out. Dojo seems to do everything with no conflicts and works well in all IE browsers. I tried some other frameworks and had problems with some things not working in IE 7, or conflicts with the resident MooTools.

  • Piotr_cz says:

    There’s a problem with loading TinyMCE configuration script in the frontend (it’s being stripped). To add an exclusion, change behaviur.php @Line 18 to

    if ((preg_match('/src="([^"]*)"/',$script,$matches)) && (preg_match('tinyMCE.init',$script,$matches))) {

    thanks Dwight Jack for your work!

    btw Joomla 1.5.16 is supposed to have an option in admin to load MooTools 1.1.x or 1.2.x

    • Piotr_cz says:

      well, the code works but actuall it’s supposed to be:


      if ((preg_match('/src="([^"]*)"/',$script,$matches)) && !(strpos($script,'tinyMCE.init' ))) {

  • Slashmaster says:

    Nice Work. Helped me a lot with MooScroll :)

  • koyan says:

    I had to change the line 29 in the beheaviour.php to the following:


    if ((strpos($script,'mootools.js') !== false ) || (strpos($script,'mootools-uncompressed.js') !== false )) {

  • Suli3 says:

    hi

    Is there a upgrade with mootools 1.2.4 planed?

  • Danila says:

    Hi! First of all thank you very much for this nice hack. It helped me much with allvideos reloaded.

    By the way I would like to ask you if I have to load all these three javascript files (if not, which one will do the best work and which can I remove?)

  • Danila says:

    - media/system/js/mootools-1.2.3-core.js
    - media/system/js/mootools-1.2.3.1-more.js
    - media/system/js/mootools-compat-111-12.js

Leave a Reply ()

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

* required.