Page 1 of 1

Mootools 1.2 for Site interface, and 1.11 for Administration

Posted: Sat Apr 19, 2008 5:06 am
by jiggliemon
I know all of the joomla developers hate it when we screw with the core code. But I need to use Mootools 1.2b on the site interface, and maintain the mootools 1.11 for the administrator section. So i did a little hacking to the Core "behavior" script for mootols and added an if/then...

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 {
                        // 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;
	}
I just thought i would let people know.

Re: Mootools 1.2 for Site interface, and 1.11 for Administration

Posted: Sun Apr 20, 2008 7:00 am
by Geoff
mod note: moved to Suggested Tips & Tricks

Just so you know, a white paper has been done for this feature and it has been accepted.
[12]Upgrade to mootools 1.2: http://forum.joomla.org/viewtopic.php?f=501&t=273960

Re: Mootools 1.2 for Site interface, and 1.11 for Administration

Posted: Sat Apr 26, 2008 6:26 pm
by ghazal
Hi,
thanks for this useful tip.
But could you tell which file you modified exactly.
Until now, to implement Moo1.2, I just hacked my template file.

Re: Mootools 1.2 for Site interface, and 1.11 for Administration

Posted: Sat Apr 26, 2008 7:10 pm
by jiggliemon
libraries > joomla > html > behavior.php > function mootools()

Re: Mootools 1.2 for Site interface, and 1.11 for Administration

Posted: Sun Apr 27, 2008 8:14 am
by ghazal
libraries > joomla > html > behavior.php > function mootools()
TKS

Re: Mootools 1.2 for Site interface, and 1.11 for Administration

Posted: Mon Apr 28, 2008 2:07 pm
by Bodom78
Thanks for the tip.

I don't like editing the core either but I had to use this method to include mootools1.12 into one of my admin components. I simply checked the $option and $task and called it when necessary.

Re: Mootools 1.2 for Site interface, and 1.11 for Administration

Posted: Thu Jun 12, 2008 8:56 am
by ghazal
Mootools 1.2 is out since yesterday.
Enjoy the 'new shiny version" !

Re: Mootools 1.2 for Site interface, and 1.11 for Administration

Posted: Mon Jun 30, 2008 6:52 am
by jiggliemon
I've updated the hack a little bit since the Joomla team did a little work on the class structure as well. I made a separate method for the "more" js file. Obviously, these are the full versions of both "Core" and "More". If you wanted to get even more gangster on it, you could download or dissect both "core" and "more" and put the respective pieces into their own methods (minding the dependencies of course). But that's not something im looking forward to doing, So the full files are fine for me.

The Mootools method is fount in the JHTMLBehavior class:
libraries > joomla > html > html > behavior.php

The modified mootools method:

Code: Select all

	function mootools($debug = null)
	{
		global $mainframe;
		static $loaded;
	
		// 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
		if ($debug || $konkcheck) {
				JHTML::script('mootools-uncompressed.js');
		} else {
			//////////////////////////THIS IS THE MOOTOOLS SWITCHER////////////////////////////////
			if($mainframe->isSite())
			{
				// Interface is for the front end show 1.2b
				JHTML::script('mootools-1.2-core.js');
			}else{
				//Otherwise, use the stable 1.11
				JHTML::script('mootools.js');
			}
		}
		$loaded = true;
		return;
	}
The bonus "More" Method:

Code: Select all

	function mootoolsMore() {
		JHTML::script('mootools-1.2-more.js');
	}

Re: Mootools 1.2 for Site interface, and 1.11 for Administration

Posted: Thu Jul 17, 2008 8:04 pm
by agel
Original code cause my webserver crash for some reason %)
So I've written a little improving:

Code: Select all

	function mootools($debug = null)
	{
		global $mainframe;
		static $loaded;
	
		// Only load once
		if ($loaded) {
			return;
		}
		
		if ($debug === null) {
			$config = &JFactory::getConfig();
			$debug = $config->getValue('config.debug');
		}
		
		if ($debug || $konkcheck) {

				JHTML::script('mootools-uncompressed.js');

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

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

		}else{

				JHTML::script('mootools.js', 'media/system/js/', false);

		}
		$loaded = true;
		return;
	}
Thanks jiggliemon for idea!