[12]Upgrade to mootools 1.2

User avatar
Dionisiy
Joomla! Intern
Joomla! Intern
Posts: 98
Joined: Thu Mar 16, 2006 11:00 am
Location: Minsk, Belarus
Contact:

[12]Upgrade to mootools 1.2

Postby Dionisiy » Tue Mar 11, 2008 8:40 am

mootools 1.2 is already in beta and will be released soon.
It is a great improovement of mootools.

User avatar
pointri
Joomla! Explorer
Joomla! Explorer
Posts: 283
Joined: Wed Aug 24, 2005 2:02 pm
Location: Rhode Island, USA

Re: Upgrade to mootools 1.2

Postby pointri » Wed Mar 12, 2008 2:55 pm

I concur (Swiff!), but we should whitepaperify these kinds of requests made for upgrading external libraries: new Mootools behaviors implemented in the core, etc.

User avatar
Dionisiy
Joomla! Intern
Joomla! Intern
Posts: 98
Joined: Thu Mar 16, 2006 11:00 am
Location: Minsk, Belarus
Contact:

Re: Upgrade to mootools 1.2

Postby Dionisiy » Wed Mar 12, 2008 4:02 pm

Joomla uses digitarald.be stuff mostly and it has support for 1.2 I think

guilleva
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 122
Joined: Thu Nov 17, 2005 12:31 am
Contact:

Re: Upgrade to mootools 1.2

Postby guilleva » Tue Mar 18, 2008 9:59 pm

I replaced the mootools.js file of joomla with the version 1.2 and some things of joomla didn't work, not even with backwards compatibility enabled on mootools 1.2

Thats to bad because I'd like to use some of to new features of mootools 1.2!

I'd like to know what the developers of Joomla think about mootools 1.2, its important to let know to all the 3rd party developers what is going to be te future of mootools on joomla. Should they start testing and upgrading their extensions against mootools 1.2?

Stian
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 247
Joined: Sat May 20, 2006 7:58 am
Location: Norway
Contact:

Re: Upgrade to mootools 1.2

Postby Stian » Thu Mar 20, 2008 2:39 pm

The roadmap at http://dev.joomla.org/content/view/23/61/ states that a "New javascript framework" will be incorporated into "Future versions" of Joomla!. Are we talking about a MooTools upgrade or a completely new one? If so, why have one decided to move away from MooTools? Or is "framework" different from "library"?

Stian

guilleva
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 122
Joined: Thu Nov 17, 2005 12:31 am
Contact:

Re: Upgrade to mootools 1.2

Postby guilleva » Thu Mar 20, 2008 2:49 pm

It looks like that document is outdated (Last Updated ( Wednesday, 19 December 2007 ) )

Maybe that new javascript framework is the now present Mootools and others javascript libraries

User avatar
Hackwar
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3748
Joined: Fri Sep 16, 2005 8:41 pm
Location: NRW - Germany
Contact:

Re: Upgrade to mootools 1.2

Postby Hackwar » Thu Mar 20, 2008 3:18 pm

that list is pretty outdated. We will stay with mootools. The question is just how to move to 1.2 without breaking backwards compatibility.
god doesn't play dice with the universe. not after that drunken night with the devil where he lost classical mechanics in a game of craps.

Since the creation of the Internet, the Earth's rotation has been fueled, primarily, by the collective spinning of English teachers in their graves.

User avatar
dkarlovi
Joomla! Intern
Joomla! Intern
Posts: 95
Joined: Wed Sep 26, 2007 10:59 am
Contact:

Re: Upgrade to mootools 1.2

Postby dkarlovi » Fri Mar 21, 2008 1:02 pm

Hackwar wrote:that list is pretty outdated. We will stay with mootools. The question is just how to move to 1.2 without breaking backwards compatibility.


Mootools 1.2 has a 1.1 compatibility layer.

User avatar
Hackwar
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3748
Joined: Fri Sep 16, 2005 8:41 pm
Location: NRW - Germany
Contact:

Re: Upgrade to mootools 1.2

Postby Hackwar » Fri Mar 21, 2008 1:18 pm

dkarlovi wrote:
Hackwar wrote:that list is pretty outdated. We will stay with mootools. The question is just how to move to 1.2 without breaking backwards compatibility.


Mootools 1.2 has a 1.1 compatibility layer.

Which does not work for about 50% of the scripts. :(
god doesn't play dice with the universe. not after that drunken night with the devil where he lost classical mechanics in a game of craps.

Since the creation of the Internet, the Earth's rotation has been fueled, primarily, by the collective spinning of English teachers in their graves.

User avatar
dkarlovi
Joomla! Intern
Joomla! Intern
Posts: 95
Joined: Wed Sep 26, 2007 10:59 am
Contact:

Re: Upgrade to mootools 1.2

Postby dkarlovi » Fri Mar 21, 2008 2:07 pm

Hackwar wrote:
dkarlovi wrote:
Hackwar wrote:that list is pretty outdated. We will stay with mootools. The question is just how to move to 1.2 without breaking backwards compatibility.


Mootools 1.2 has a 1.1 compatibility layer.

Which does not work for about 50% of the scripts. :(


Do what you'd expect Joomla users to do, use it, find bugs, report them to MT guys. ;) I'm porting my MT stuff over to 1.2 anyway so don't mind either way, but you shouldn't hold on to 1.1 just because some scripts don't work, 1.2 is really way better to work with and I'm sure, with exposure Joomla brought to MT, those guys would be glad to fix stuff.

User avatar
jiggliemon
Joomla! Intern
Joomla! Intern
Posts: 81
Joined: Wed Nov 22, 2006 6:18 am
Contact:

Re: [12]Upgrade to mootools 1.2

Postby jiggliemon » Sun Apr 20, 2008 9:00 pm

A Quick hack but it's worked so far.

JFactory HTML Behaviors or something. I forget exactly where the Mootols behavior is located, but it's easy to find.

Code: Select all

    function mootools($debug = null)
       {
          global $mainframe;
          static $loaded;
          $administrator = JFactory::getApplication('administrator');
          // Only load once
          if ($loaded) {
             return;
          }

          // If no debugging value is set, use the configuration setting
          if ($debug === null) {
             $config = &JFactory::getConfig();
             $debug = $config->getValue('config.debug');
          }

          // TODO NOTE: Here we are checking for Konqueror - If they fix thier issue with compressed, we will need to update this
          $konkcheck = strpos (strtolower($_SERVER['HTTP_USER_AGENT']), "konqueror");

          if ($debug || $konkcheck) {
             JHTML::script('mootools-uncompressed.js', 'media/system/js/', false);
          } else {
             //////////////////////////THIS IS THE MOOTOOLS SWITCHER////////////////////////////////
             // interface is for the front end show 1.2b
             if($mainframe->isSite())
             {
                JHTML::script('mootools2.js', 'media/system/js/', false);
                            //Otherwise, use the stable 1.11
             }else{
                JHTML::script('mootools.js', 'media/system/js/', false);
             }
          }
          $loaded = true;
          return;
       }


ghazal
Joomla! Explorer
Joomla! Explorer
Posts: 272
Joined: Fri Aug 19, 2005 12:12 pm
Location: Out of my mind ...sometimes

Re: [12]Upgrade to mootools 1.2

Postby ghazal » Wed Jun 18, 2008 4:23 pm

Hi,
with this hack + a little plug here:
http://extensions.joomla.org/component/ ... /cat_id,0/
which sends js/css files to head

one can test easily the new demos displayed on the new Mootools site for 1.2 stable
http://demos.mootools.net/

Stasys
Joomla! Ace
Joomla! Ace
Posts: 1318
Joined: Wed Aug 17, 2005 11:06 pm
Location: Lithuania
Contact:

Re: [12]Upgrade to mootools 1.2

Postby Stasys » Thu Jun 19, 2008 6:46 pm

1.2 is a lot more stable, we should upgrade
Lithuanian Joomla! Community http://www.lithuanianjoomla.com
lietuviškas Joomla! puslapis, naujienos, straipsniai, forumas, vertimai
always be open source, and be free as freedom

ghazal
Joomla! Explorer
Joomla! Explorer
Posts: 272
Joined: Fri Aug 19, 2005 12:12 pm
Location: Out of my mind ...sometimes

Re: [12]Upgrade to mootools 1.2

Postby ghazal » Thu Jun 19, 2008 10:01 pm

Yep.
But there will be a lot of re-coding to port mootools1.11 based apps to the update.
One of mootools developers provides a "compatibility layer" :
http://digitarald.de/journal/38150523/m ... ity-layer/
Haven't tested it.

Here is the aforementionned code corrected with the 2 new libraries dowloadable from mootools.net, mootools-1.2-core.js and mootools-1.2-more.js. Files to be added in media/system/js folder.

Code: Select all

        function mootools($debug = null)
           {
              global $mainframe;
              static $loaded;
              $administrator = JFactory::getApplication('administrator');
              // Only load once
              if ($loaded) {
                 return;
              }

              // If no debugging value is set, use the configuration setting
              if ($debug === null) {
                 $config = &JFactory::getConfig();
                 $debug = $config->getValue('config.debug');
              }

              // TODO NOTE: Here we are checking for Konqueror - If they fix thier issue with compressed, we will need to update this
              $konkcheck = strpos (strtolower($_SERVER['HTTP_USER_AGENT']), "konqueror");

              if ($debug || $konkcheck) {
                 JHTML::script('mootools-uncompressed.js', 'media/system/js/', false);
              } else {
                 //////////////////////////THIS IS THE MOOTOOLS SWITCHER////////////////////////////////
                 // interface is for the front end show 1.2b
                 if($mainframe->isSite())
                 {
                JHTML::script('mootools-1.2-core.js', 'media/system/js/', false);
                JHTML::script('mootools-1.2-more.js', 'media/system/js/', false);
                                //Otherwise, use the stable 1.11
                 }else{
                    JHTML::script('mootools.js', 'media/system/js/', false);
                 }
              }
              $loaded = true;
              return;
           }

User avatar
pollen8
Joomla! Explorer
Joomla! Explorer
Posts: 350
Joined: Wed Aug 17, 2005 10:32 pm
Location: la Rochelle - France
Contact:

Re: [12]Upgrade to mootools 1.2

Postby pollen8 » Tue Jul 29, 2008 7:41 am

here's a mootools 1.2 and Joomla 1.5 compatible version of the Tips code:

Code: Select all

var Tips = new Class({

   Implements: [Events, Options],

   options: {
      onShow: function(tip){
         tip.setStyle('visibility', 'visible');
      },
      onHide: function(tip){
         tip.setStyle('visibility', 'hidden');
      },
      showDelay: 100,
      hideDelay: 100,
      className: 'tool',
      offsets: {x: 16, y: 16},
      fixed: false
   },

   initialize: function(){
      var params = Array.link(arguments, {options: Object.type, elements: $defined});
      this.setOptions(params.options || null);
      this.tip = new Element('div',{'class': this.options.className + '-tip'}).inject(document.body);
      if (this.options.className) this.tip.addClass(this.options.className);
      var top = new Element('div', {'class': 'tip-top'}).inject(this.tip);
      this.container = new Element('div', {'class': 'tip'}).inject(this.tip);
      var bottom = new Element('div', {'class': 'tip-bottom'}).inject(this.tip);
      this.tip.setStyles({position: 'absolute', top: 0, left: 0, visibility: 'hidden'});
      if (params.elements) this.attach(params.elements);
   },
   
   attach: function(elements){
      $$(elements).each(function(element){
         var title = element.retrieve('tip:title', element.get('title'));
         var dual = title   .split('::');
         var text = element.retrieve('tip:text', element.get('rel') || element.get('href'));
         if (dual.length > 1){
            var text = dual[1].trim();
            var title = dual[0].trim();
         }else{
            var text = dual[0].trim();
            var title = '';
         }
         element.store('tip:title', title);
         element.store('tip:text', text);
         var enter = element.retrieve('tip:enter', this.elementEnter.bindWithEvent(this, element));
         var leave = element.retrieve('tip:leave', this.elementLeave.bindWithEvent(this, element));
         element.addEvents({mouseenter: enter, mouseleave: leave});
         if (!this.options.fixed){
            var move = element.retrieve('tip:move', this.elementMove.bindWithEvent(this, element));
            element.addEvent('mousemove', move);
         }
         element.store('tip:native', element.get('title'));
         element.erase('title');
      }, this);
      return this;
   },
   
   detach: function(elements){
      $$(elements).each(function(element){
         element.removeEvent('mouseenter', element.retrieve('tip:enter') || $empty);
         element.removeEvent('mouseleave', element.retrieve('tip:leave') || $empty);
         element.removeEvent('mousemove', element.retrieve('tip:move') || $empty);
         element.eliminate('tip:enter').eliminate('tip:leave').eliminate('tip:move');
         var original = element.retrieve('tip:native');
         if (original) element.set('title', original);
      });
      return this;
   },
   
   elementEnter: function(event, element){
      $A(this.container.childNodes).each(Element.dispose);
      var title = element.retrieve('tip:title');
      if (title){
         this.titleElement = new Element('div', {'class': this.options.className + '-title'}).inject(this.container);
         this.fill(this.titleElement, title);
      }
      
      var text = element.retrieve('tip:text');
      if (text){
         this.textElement = new Element('div', {'class': this.options.className + '-text'}).inject(this.container);
         this.fill(this.textElement, text);
      }
      this.timer = $clear(this.timer);
      this.timer = this.show.delay(this.options.showDelay, this);

      this.position((!this.options.fixed) ? event : {page: element.getPosition()});
   },
   
   elementLeave: function(event){
      $clear(this.timer);
      this.timer = this.hide.delay(this.options.hideDelay, this);
   },
   
   elementMove: function(event){
      this.position(event);
   },
   
   position: function(event){
      var size = window.getSize(), scroll = window.getScroll();
      var tip = {x: this.tip.offsetWidth, y: this.tip.offsetHeight};
      var props = {x: 'left', y: 'top'};
      for (var z in props){
         var pos = event.page[z] + this.options.offsets[z];
         if ((pos + tip[z] - scroll[z]) > size[z]) pos = event.page[z] - this.options.offsets[z] - tip[z];
         this.tip.setStyle(props[z], pos);
      }
   },
   
   fill: function(element, contents){
      (typeof contents == 'string') ? element.set('html', contents) : element.adopt(contents);
   },

   show: function(){
      this.fireEvent('show', this.tip);
   },

   hide: function(){
      this.fireEvent('hide', this.tip);
   }

});


Basically I'm porting Fabrik's mootools code to mootools 1.2 so would be willing to submit code if so desired?
aka

User avatar
pollen8
Joomla! Explorer
Joomla! Explorer
Posts: 350
Joined: Wed Aug 17, 2005 10:32 pm
Location: la Rochelle - France
Contact:

Re: [12]Upgrade to mootools 1.2

Postby pollen8 » Tue Jul 29, 2008 9:15 am

also found this script which addresses more compat issues between 1.1. and 1.2

http://www.siafoo.net/snippet/137#description
aka

User avatar
mihu
Joomla! Guru
Joomla! Guru
Posts: 741
Joined: Mon Mar 20, 2006 8:17 am

Re: [12]Upgrade to mootools 1.2

Postby mihu » Fri Aug 01, 2008 10:39 pm

I load those 4 mootools scripts

Code: Select all

JHTML::script('mootools-1.2-core.js', 'media/system/js/', false);
JHTML::script('mootools-1.2-compat-core.js', 'media/system/js/', false);
JHTML::script('mootools-1.2-more.js', 'media/system/js/', false);
JHTML::script('mootools-1.2-compat-more.js', 'media/system/js/', false);


You can find Compatibility files from here too
http://blog.mootools.net/2008/6/12/moot ... s-official

You need to modify behavior.php mootools function as mentioned above and also upload those files.

It seems to me calendar and tooltops are broken. I think we can report all joomla scripts which broken here.

For those who wanna help Joomla to fix those broken script for mootools 1.2, please either report the issue you found or provides a patch to speed up the process. (I as speak as individual instead of DEV WG)

I found this link, and I hope this would help.
http://github.com/mootools/mootools-cor ... -11-to-1-2
bento2go.com - We DO NOT sell bento !!

User avatar
hotnuts21
Joomla! Explorer
Joomla! Explorer
Posts: 315
Joined: Wed Aug 17, 2005 11:11 pm

Re: [12]Upgrade to mootools 1.2

Postby hotnuts21 » Tue Aug 05, 2008 2:10 pm

Just a thought, I may be well of base here but could we not link this up with another suggestion to enable people to disable mootools altogether and then give the user the choice?

For example, load mootools 1.2 in the admin by default no choice.
But for the front end, the user can have one of the following options, (in config?)
Load mootools 1.2
load mootools 1.1 (backward compatibility for all those modules and custom hacks using 1.1)
Disable Mootools
provide link (so people can provide a link to another lib such as the google ajax API's)

In the front end very little actually really requires mootools, except for the caption if I am not mistaken, and that could probably be written to use 1.1 or 1.2 so those people who dont want the load overhead are happy.

It also addresses another whitepaper issue that was raised about disabling mootools altogether.

User avatar
pollen8
Joomla! Explorer
Joomla! Explorer
Posts: 350
Joined: Wed Aug 17, 2005 10:32 pm
Location: la Rochelle - France
Contact:

Re: [12]Upgrade to mootools 1.2

Postby pollen8 » Wed Aug 06, 2008 6:56 am

on another thought - it would also make sense to get the mootools file from one central server. Meaning that users would only ever need to download the file once for all the Joomla sites they encounter.
I *think * this type of option is available for dojo and is hosted with Google.
aka

User avatar
mihu
Joomla! Guru
Joomla! Guru
Posts: 741
Joined: Mon Mar 20, 2006 8:17 am

Re: [12]Upgrade to mootools 1.2

Postby mihu » Wed Aug 06, 2008 2:42 pm

regard to hold at a central place, there are some debates. Not everyone like to host their scripts at other place.
bento2go.com - We DO NOT sell bento !!

Stasys
Joomla! Ace
Joomla! Ace
Posts: 1318
Joined: Wed Aug 17, 2005 11:06 pm
Location: Lithuania
Contact:

Re: [12]Upgrade to mootools 1.2

Postby Stasys » Wed Aug 06, 2008 7:03 pm

please do not host scripts at other place
Lithuanian Joomla! Community http://www.lithuanianjoomla.com
lietuviškas Joomla! puslapis, naujienos, straipsniai, forumas, vertimai
always be open source, and be free as freedom

User avatar
pollen8
Joomla! Explorer
Joomla! Explorer
Posts: 350
Joined: Wed Aug 17, 2005 10:32 pm
Location: la Rochelle - France
Contact:

Re: [12]Upgrade to mootools 1.2

Postby pollen8 » Wed Aug 06, 2008 9:01 pm

Remote hosted javascript files are a very common use case these days, we don't all run google maps, adwords, [youtube], daily motion applications on our own servers do we? No these services are supplied via various remote techniques be they javascript embeds or iframes.

I can understand the feeling of loosing control over your files, but I'd trust Google to have more uptime than any server I can run. By hosting in one location you alleviate the concern over repetitive downloads as it's a one time only download for every Joomla site you will ever use

Looking at it Google already host mootools:
http://code.google.com/apis/ajaxlibs/

More and more components will be using mootools in the front end simply because they will want to make the most of the functionality provided by mootools, and as component become native to 1.5 they will, I imagine, be replacing the other js libraires (prototype, dojo, etc) with mootools compatible code.

To me giving at least the option to link to a hosted mootools script makes so much more sense than building in a mechanism for not loading mootools into the front end at all.

Looking forward to hearing why this isn't a good idea :D

Rob
aka

User avatar
hotnuts21
Joomla! Explorer
Joomla! Explorer
Posts: 315
Joined: Wed Aug 17, 2005 11:11 pm

Re: [12]Upgrade to mootools 1.2

Postby hotnuts21 » Wed Aug 06, 2008 10:06 pm

pollen8 wrote:Looking forward to hearing why this isn't a good idea :D
Rob


Its not that its not a good idea, or a bad idea, but different people have different needs. Hence why I suggested the option to allow people to choose, not everyone has the same needs. Also its worth noting that Amazons cloud went down recently (which is similar to the cloud google uses to host is ajaxapis) and google also had some downtime on some of its servers. A lot of people rely and trust the amazon cloud to host their sites, this downtime was not good. Technically my little server has better uptime than that this year, what would you do if your files were hosted here, you would be stuck without ajax!! Going back to the 'choice switch' if this was an option then if your google or other hosted site went down, you could at least switch to a local version as a backup.

Hope that makes sense :)

User avatar
pollen8
Joomla! Explorer
Joomla! Explorer
Posts: 350
Joined: Wed Aug 17, 2005 10:32 pm
Location: la Rochelle - France
Contact:

Re: [12]Upgrade to mootools 1.2

Postby pollen8 » Wed Aug 06, 2008 11:09 pm

what would you do if your files were hosted here, you would be stuck without ajax


Not sure, but wouldn't it used the cached version (presuming that you had it cached, which if it was hosted in one place would be by several magnitudes more likely)?

Think we are debating from similar points :
option to:
use remote mootools
OR
use local mootools
OR
turn off mootools

would cover most people .

But really all this is less important to me that getting 1.2 support in Joomla.
aka

Stasys
Joomla! Ace
Joomla! Ace
Posts: 1318
Joined: Wed Aug 17, 2005 11:06 pm
Location: Lithuania
Contact:

Re: [12]Upgrade to mootools 1.2

Postby Stasys » Wed Aug 06, 2008 11:19 pm

I am strongly against such idea, cause I simply don't want to have my cms partly hosted by someone else
Its very simple ;)
Lithuanian Joomla! Community http://www.lithuanianjoomla.com
lietuviškas Joomla! puslapis, naujienos, straipsniai, forumas, vertimai
always be open source, and be free as freedom

Stasys
Joomla! Ace
Joomla! Ace
Posts: 1318
Joined: Wed Aug 17, 2005 11:06 pm
Location: Lithuania
Contact:

Re: [12]Upgrade to mootools 1.2

Postby Stasys » Wed Aug 06, 2008 11:21 pm

and yes, better just get local 1.2 mootools
Lithuanian Joomla! Community http://www.lithuanianjoomla.com
lietuviškas Joomla! puslapis, naujienos, straipsniai, forumas, vertimai
always be open source, and be free as freedom

ghazal
Joomla! Explorer
Joomla! Explorer
Posts: 272
Joined: Fri Aug 19, 2005 12:12 pm
Location: Out of my mind ...sometimes

Re: [12]Upgrade to mootools 1.2

Postby ghazal » Tue Aug 26, 2008 10:35 am

In case anyone needs a caption.js file updated to Mootools 1.2, here it is :
(modified with the help of ppl at the unofficial mootools forum, mooforum.net, the official one being on googlegroups, http://groups.google.com/group/mootools-users)

Code: Select all

   
   var myCaption = new Class({
      
      initialize: function(selector)
      {
         this.selector = selector;
         $each($$(selector), function(item){
            this.createCaption(item);
         }, this);
      },
      
      createCaption: function(zielement)
      {
          var caption   = document.createTextNode(zielement.title);
          var container = document.createElement('div');
          var text      = document.createElement('p');
          var width     = zielement.getAttribute('width');
          var align     = zielement.getAttribute('align');
      
          if(!width) {
         width = zielement.width;
          }
      
          text.appendChild(caption);
          container.inject(zielement, 'before');
          container.appendChild(zielement);
          if(zielement.title != '') {
         container.appendChild(text);
          }
      
          container.className   = this.selector.replace('.', '_');
          container.className   = container.className + '' + align;
          container.setAttribute('style','float:'+align);
          container.style.width = width + 'px';
      }   
   });
   
   document.caption = null;
   
   window.addEvent('load', function() {
      var caption = new myCaption('img.caption')
      document.caption = caption
   });

Stasys
Joomla! Ace
Joomla! Ace
Posts: 1318
Joined: Wed Aug 17, 2005 11:06 pm
Location: Lithuania
Contact:

Re: [12]Upgrade to mootools 1.2

Postby Stasys » Tue Aug 26, 2008 10:54 am

by the way - we'll soon have 1.2.1 Mootools Bug Fix release, don't miss it ;)
Lithuanian Joomla! Community http://www.lithuanianjoomla.com
lietuviškas Joomla! puslapis, naujienos, straipsniai, forumas, vertimai
always be open source, and be free as freedom

stbenz
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Tue Aug 26, 2008 12:32 pm

Re: [12]Upgrade to mootools 1.2

Postby stbenz » Tue Aug 26, 2008 5:25 pm

Hi,

I wanted to know when the new version of mootools will be part of Joomla. Will it be in one of the next 1.5.x releses or not until version 1.6?

I also edited some js files in Joomla to be compatible with mootools 1.2 but hadn't the time to test them jet...

switcher.js

Code: Select all

var JSwitcher = new Class({

   Implements: Options,

   toggler : null, //holds the active toggler
   page    : null, //holds the active page

   options : {
      cookieName: 'switcher'
   },

   initialize: function(toggler, element, options)
   {
      this.setOptions(options);

      var self = this;

      togglers = toggler.getElements('a');
      for (i=0; i < togglers.length; i++) {
         togglers[i].addEvent( 'click', function() { self.switchTo(this); } );
      }

      //hide all
      elements = element.getElements('div[id^=page-]');
      for (i=0; i < elements.length; i++) {
         this.hide(elements[i])
      }

      this.toggler = toggler.getElement('a.active');
      this.page    = $('page-'+ this.toggler.id);

      this.show(this.page);
      if (this.options.cookieName)
      {
         if((page = Cookie.read(this.options.cookieName))) {
            this.switchTo($(page));
         }
      }
   },

   switchTo: function(toggler)
   {
      page = $chk(toggler) ? $('page-'+toggler.id) : null;
      if(page && page != this.page)
      {
         //hide old element
         if(this.page) {
            this.hide(this.page);
         }

         //show new element
         this.show(page);

         toggler.addClass('active');
         if (this.toggler) {
            this.toggler.removeClass('active');
         }
         this.page    = page;
         this.toggler = toggler;
         Cookie.write(this.options.cookieName, toggler.id);
      }
   },

   hide: function(element) {
      element.setStyle('display', 'none');
   },

   show: function (element) {
      element.setStyle('display', 'block');
   }
});

document.switcher = null;
window.addEvent('domready', function(){
    toggler = $('submenu')
     element = $('config-document')
     if(element) {
        document.switcher = new JSwitcher(toggler, element, {cookieName: toggler.getAttribute('class')});
     }
});


validate.js

Code: Select all

var JFormValidator = new Class({
   initialize: function()
   {
      // Initialize variables
      this.handlers   = Object();
      this.custom      = Object();

      // Default handlers
      this.setHandler('username',
         function (value) {
            regex = new RegExp("[\<|\>|\"|\'|\%|\;|\(|\)|\&]", "i");
            return !regex.test(value);
         }
      );

      this.setHandler('password',
         function (value) {
            regex=/^\S[\S ]{2,98}\S$/;
            return regex.test(value);
         }
      );

      this.setHandler('numeric',
         function (value) {
            regex=/^(\d|-)?(\d|,)*\.?\d*$/;
            return regex.test(value);
         }
      );

      this.setHandler('email',
         function (value) {
            regex=/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
            return regex.test(value);
         }
      );

      // Attach to forms with class 'form-validate'
      var forms = $$('form.form-validate');
      forms.each(function(form){ this.attachToForm(form); }, this);
   },

   setHandler: function(name, fn, en)
   {
      en = (en == '') ? true : en;
      this.handlers[name] = { enabled: en, exec: fn };
   },

   attachToForm: function(form)
   {
      // Iterate through the form object and attach the validate method to all input fields.
      $A(form.elements).each(function(el){
         el = $(el);
         if ((el.get('tag') == 'input' || el.get('tag') == 'button') && el.getProperty('type') == 'submit') {
            if (el.hasClass('validate')) {
               el.onclick = function(){return document.formvalidator.isValid(this.form);};
            }
         } else {
            el.addEvent('blur', function(){return document.formvalidator.validate(this);});
         }
      });
   },

   validate: function(el)
   {
      // If the field is required make sure it has a value
      if ($(el).hasClass('required')) {
         if (!($(el).get('value'))) {
            this.handleResponse(false, el);
            return false;
         }
      }

      // Only validate the field if the validate class is set
      var handler = (el.className && el.className.search(/validate-([a-zA-Z0-9\_\-]+)/) != -1) ? el.className.match(/validate-([a-zA-Z0-9\_\-]+)/)[1] : "";
      if (handler == '') {
         this.handleResponse(true, el);
         return true;
      }

      // Check the additional validation types
      if ((handler) && (handler != 'none') && (this.handlers[handler]) && $(el).get('value')) {
         // Execute the validation handler and return result
         if (this.handlers[handler].exec($(el).get('value')) != true) {
            this.handleResponse(false, el);
            return false;
         }
      }

      // Return validation state
      this.handleResponse(true, el);
      return true;
   },

   isValid: function(form)
   {
      var valid = true;

      // Validate form fields
      for (var i=0;i < form.elements.length; i++) {
         if (this.validate(form.elements[i]) == false) {
            valid = false;
         }
      }

      // Run custom form validators if present
      $A(this.custom).each(function(validator){
         if (validator.exec() != true) {
            valid = false;
         }
      });

      return valid;
   },

   handleResponse: function(state, el)
   {
      // Find the label object for the given field if it exists
      if (!(el.labelref)) {
         var labels = $$('label');
         labels.each(function(label){
            if (label.getProperty('for') == el.getProperty('id')) {
               el.labelref = label;
            }
         });
      }

      // Set the element and its label (if exists) invalid state
      if (state == false) {
         el.addClass('invalid');
         if (el.labelref) {
            $(el.labelref).addClass('invalid');
         }
      } else {
         el.removeClass('invalid');
         if (el.labelref) {
            $(el.labelref).removeClass('invalid');
         }
      }
   }
});

document.formvalidator = null;
Window.onDomReady(function(){
   document.formvalidator = new JFormValidator();
});


There are also some updated external scripts which work with mootools 1.2:
- SqueezeBox (modal.js): http://digitarald.de/project/squeezebox/
- FancyUpload (swf.js and uploader.js): http://digitarald.de/project/fancyupload/
These maybe will also break some code (like mootools 1.2 does), but i haven't tested it jet.

User avatar
Tonie
Joomla! Master
Joomla! Master
Posts: 16584
Joined: Thu Aug 18, 2005 7:13 am

Re: [12]Upgrade to mootools 1.2

Postby Tonie » Tue Aug 26, 2008 7:37 pm

The idea is that it will be for 1.6.


Return to “Accepted - Archived”

Who is online

Users browsing this forum: No registered users and 1 guest