Welcome, Guest
Username Password: Remember me

mootools.js and MobileJomla
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: mootools.js and MobileJomla

mootools.js and MobileJomla 4 years, 8 months ago #21591

  • Elimelech
  • OFFLINE
  • Junior Boarder
  • Posts: 24
  • Karma: 0
Can this code mootools.js be removed from the mobile site template?
https://meirbruk.net/media/system/js/mootools.js

I mean, so that it does not load when the mobile version of the site loads or is it needed?
Last Edit: 4 years, 8 months ago by Elimelech.

Re: mootools.js and MobileJomla 4 years, 8 months ago #21594

  • dryabov
  • OFFLINE
  • Administrator
  • Denis Ryabov, Lead Developer
  • Posts: 4867
  • Karma: 105
As far as I remember, MooTools in Joomla 1.5 is usually loaded for two purposes:
1) generate tooltips for labels,
2) insert captions for images with class="caption" attribute.

In the preinstalled Mobile_Basic template (and additional premium templates) we use modified com_content layouts that don't load MooTools by default (until it is explicitly loaded by a plugin or component).

Re: mootools.js and MobileJomla 4 years, 8 months ago #21595

  • Elimelech
  • OFFLINE
  • Junior Boarder
  • Posts: 24
  • Karma: 0
So can MooTools Joomla 1.5 be disabled in the template? It is not needed for the normal operation of the mobile version of the site? I have a free version mobilejoomle
Last Edit: 4 years, 8 months ago by Elimelech.

Re: mootools.js and MobileJomla 4 years, 8 months ago #21598

  • dryabov
  • OFFLINE
  • Administrator
  • Denis Ryabov, Lead Developer
  • Posts: 4867
  • Karma: 105
It's possible, but it's not so easy in 1.5. Joomla's com_content component loads MooTools via call to
JHTML::_('behavior.caption');
and Mobile extension overrides JHTMLBehavior class to do nothing for behavior.caption command. As a result, MooTools is loaded only if a plugin or a component explicitly executes behaviour.mootools command. So, if you have MooTools loaded in mobile version of your website, most likely it means it is directly requested by a 3rdparty plugin.

Re: mootools.js and MobileJomla 4 years, 8 months ago #21602

  • Elimelech
  • OFFLINE
  • Junior Boarder
  • Posts: 24
  • Karma: 0
$user = JFactory::getUser();
if ($user->get('guest') == 1 or $user->usertype == 'Registered') {
$headerstuff = $this->getHeadData();
$tmp = array();
foreach ($headerstuff['scripts'] as $path=>$type) {
if ( !preg_match('#media/system/js#i', $path, $ar) ) $tmp[$path] = $type;
}
$headerstuff['scripts'] = $tmp;
$this->setHeadData($headerstuff);
}
But what if I insert this code into the mobile website template?

or such:
<?php
$user =& JFactory::getUser();
if ($user->get('guest') == 1) {
$headerstuff = $this->getHeadData();
$key1 = JURI::base(true). '/media/system/js/mootools.js';
$key2 = JURI::base(true). '/media/system/js/caption.js';
unset($headerstuff['scripts'][$key1], $headerstuff['scripts'][$key2]);
$this->setHeadData($headerstuff);
}
?>
I want
so that mootools.js from Joomla does not load on the mobile version of the site
Last Edit: 4 years, 8 months ago by Elimelech.

Re: mootools.js and MobileJomla 4 years, 8 months ago #21604

  • dryabov
  • OFFLINE
  • Administrator
  • Denis Ryabov, Lead Developer
  • Posts: 4867
  • Karma: 105
Just try. The latter code should be a little bit faster. If you use 3rdparty template, it should work. In the case of our Mobile_Basic and other premium templates, there is an option in its setting to do it automatically (but as far as I.can see, your desktop template is currently used in mobile version of your website).

Re: mootools.js and MobileJomla 4 years, 8 months ago #21605

  • Elimelech
  • OFFLINE
  • Junior Boarder
  • Posts: 24
  • Karma: 0
And what is the 3rdparty template?


Please look, have I inserted the code in the correct place in the template?

 <?php
/**
* Mobile Joomla! extension
* https://www.mobilejoomla.com
*
* @version 2.1.44
* @license GNU/GPL v2 - http://www.gnu.org/licenses/gpl-2.0.html
* @copyright (C) 2008-2019 Kuneri Ltd. / Denis Ryabov
* @date December 2019
*/

defined('_JEXEC') or die('Restricted access');
$user =& JFactory::getUser();
if ($user->get('guest') == 1 or $user->usertype == 'Registered') {
$headerstuff = $this->getHeadData();
$key1 = JURI::base(true). '/media/system/js/mootools.js';
$key2 = JURI::base(true). '/media/system/js/caption.js';
unset($headerstuff['scripts'][$key1], $headerstuff['scripts'][$key2]);
$this->setHeadData($headerstuff);
}
Last Edit: 4 years, 8 months ago by Elimelech.

Re: mootools.js and MobileJomla 4 years, 8 months ago #21611

  • dryabov
  • OFFLINE
  • Administrator
  • Denis Ryabov, Lead Developer
  • Posts: 4867
  • Karma: 105
No, in the case of our mobile templates it's sufficient to just disable MooTools loading in the template's settings (see "Troubleshootings" section).

PS. Your code should work with any template, but note that files of Mobile_Basic template are overwritten every time you install an update to Mobile Joomla! extension, and so your changes in the template's index.php will be lost.
  • Page:
  • 1
Time to create page: 0.28 seconds

By continuing to use this site you consent to the use of cookies on your device as described in our cookie policy unless you have disabled them. This site will not function correctly without cookies.

I accept cookies from this site.