cancel
Showing results for 
Search instead for 
Did you mean: 

Mootools javascript library and tomahawk components

dhalupa
Champ on-the-rise
Champ on-the-rise
Recently, I had a request to replace DatePicker control with some calendar control that would improve usability when it comes to handling date values. Since Alfresco is built on MyFaces implementation of JSF, logical choice was to use calendar component from tomahawk library . Unfortunately, it did not work due to the fact that page tag is creating a reference to Mootools, a javascript library which, from what I saw, is used for ajax enabled dashlets and document preview feature (anywhere else?). It is clearly stated on Mootools site that it simply does not work (neither it is their intention to make it work) with other javascript libraries namely prototype or dojo which are heavily used in tomahawk. This effectively prevents usage of tomahawk library of components.
After the above mentioned reference was removed, calendar component plugged into property sheet started to work nicely.

I am not a javascript expert, but I wonder how come that Mootools was chosen over scriptaculous web2.0 javascript library which would not prevent usage of tomahawk? is there a chance to revise this decision?

Kind regards,

Denis
14 REPLIES 14

ebo
Champ in-the-making
Champ in-the-making
Ok, so if we disable Mootools then "Web Forms" will no longer work. I am developing a custom web module (hence the use of Tomahawk) and I am trying to find out the implications of turning off MooTools. I have checked out http://wiki.alfresco.com/wiki/Forms_Developer_Guide but it does not reference this issue.

I only want to disable Mootools for a couple of pages that use some tomahawk components? So, can I remove Mootools for a single page?

dd090
Champ in-the-making
Champ in-the-making
I guess turning of mootools for a particular page would involve using a custom <rSmiley Tongueage> (on that page) which does not include the mootools javascript reference .

You'll want to avoid having this piece of code in the custom pageTag.

            // mootools
//            out.write("<script type=\"text/javascript\" src=\"");
//            out.write(reqPath);
//            out.write("/scripts/ajax/mootools.v1.11.js\"></script>");


I've just done the same and everything still seems to work.

But I am not sure which other parts of Alfresco I have now broken.
Can somebody from the development team eloborate on that ?

Question is : which alfresco functionalities will no longer work is we remove the above piece of code ?

dd090
Champ in-the-making
Champ in-the-making
After further testing I found some functionalities that no longer work after removing mootools (the preview of a document for one as dhalupa pointed out in the inital post)

MikeH : what do you mean when you say :
stub-out the mootools javascript file itself (in scripts/ajax)
Can you elaborate on that please ?

mikeh
Star Contributor
Star Contributor
That simply means replace the mootools.v1.11.js file with an empty file of the same name. Prevents a 404 error if you just delete the file.

Mike

pbrodka
Champ in-the-making
Champ in-the-making
Well, I made some nasty trick - I put my own version of mootools.js file. It looks like this:

var scripts= document.getElementsByTagName('script');
var calendarLoaded = false;
for (var i=0;i<scripts.length;i++){
   var script = scripts[i];
   var file = script.src;
   var search = file.lastIndexOf('calendar.js');
   if (search>0){
      
      calendarLoaded = true;
      
   }
}
if (calendarLoaded){
}
else{  /*there is old code*/ }

If on page is user richfaces calendar (which is one of first loaded scripts), then mootools is not loaded. I hope it will not destroy WC anywhere.