mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-07 01:58:09 +01:00
Reorganize javascript at end of page.
This commit is contained in:
@@ -6304,112 +6304,101 @@ function printCommonFooter($zone='private')
|
||||
if ($zone == 'private') print "\n".'<!-- Common footer for private page -->'."\n";
|
||||
else print "\n".'<!-- Common footer for public page -->'."\n";
|
||||
|
||||
if (! empty($conf->global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER."\n";
|
||||
|
||||
print "\n";
|
||||
if (! empty($conf->use_javascript_ajax))
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('printCommonFooter',$parameters); // Note that $action and $object may have been modified by some hooks
|
||||
if (empty($reshook))
|
||||
{
|
||||
print '<!-- Reposition management (does not work if a redirect is done after action of submission) -->'."\n";
|
||||
print '<script type="text/javascript" language="javascript">jQuery(document).ready(function() {'."\n";
|
||||
|
||||
print '<!-- If page_y set, we set scollbar with it -->'."\n";
|
||||
print "page_y=getParameterByName('page_y', 0);";
|
||||
print "if (page_y > 0) $('html, body').scrollTop(page_y);\n";
|
||||
|
||||
print '<!-- Set handler to add page_y param on some a href links -->'."\n";
|
||||
print 'jQuery(".reposition").click(function() {
|
||||
var page_y = $(document).scrollTop();
|
||||
/*alert(page_y);*/
|
||||
this.href=this.href+\'&page_y=\'+page_y;
|
||||
});'."\n";
|
||||
print '});'."\n";
|
||||
|
||||
if (empty($conf->dol_use_jmobile))
|
||||
if (! empty($conf->global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER."\n";
|
||||
|
||||
print "\n";
|
||||
if (! empty($conf->use_javascript_ajax))
|
||||
{
|
||||
print '<!-- Set handler to switch left menu page (menuhider) -->'."\n";
|
||||
print 'jQuery(".menuhider").click(function() {';
|
||||
print ' console.log("We click on .menuhider");'."\n";
|
||||
//print " $('.side-nav').animate({width:'toggle'},200);\n"; // OK with eldy theme but not with md
|
||||
print " $('.side-nav').toggle()\n";
|
||||
print " $('.login_block').toggle()\n";
|
||||
print '});'."\n";
|
||||
}
|
||||
print '<script type="text/javascript" language="javascript">'."\n";
|
||||
|
||||
print '</script>'."\n";
|
||||
}
|
||||
|
||||
// Google Analytics (need Google module)
|
||||
if (! empty($conf->google->enabled) && ! empty($conf->global->MAIN_GOOGLE_AN_ID))
|
||||
{
|
||||
if (($conf->dol_use_jmobile != 4))
|
||||
{
|
||||
print "\n";
|
||||
print '<script type="text/javascript">'."\n";
|
||||
print ' var _gaq = _gaq || [];'."\n";
|
||||
print ' _gaq.push([\'_setAccount\', \''.$conf->global->MAIN_GOOGLE_AN_ID.'\']);'."\n";
|
||||
print ' _gaq.push([\'_trackPageview\']);'."\n";
|
||||
print ''."\n";
|
||||
print ' (function() {'."\n";
|
||||
print ' var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;'."\n";
|
||||
print ' ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';'."\n";
|
||||
print ' var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);'."\n";
|
||||
print ' })();'."\n";
|
||||
print '</script>'."\n";
|
||||
if (empty($conf->dol_use_jmobile))
|
||||
{
|
||||
print "\n";
|
||||
print '/* Set handler to switch left menu page (menuhider) */'."\n";
|
||||
print 'jQuery(".menuhider").click(function() {';
|
||||
print ' console.log("We click on .menuhider");'."\n";
|
||||
//print " $('.side-nav').animate({width:'toggle'},200);\n"; // OK with eldy theme but not with md
|
||||
print " $('.side-nav').toggle()\n";
|
||||
print " $('.login_block').toggle()\n";
|
||||
print '});'."\n";
|
||||
}
|
||||
|
||||
// Google Analytics (need Google module)
|
||||
if (! empty($conf->google->enabled) && ! empty($conf->global->MAIN_GOOGLE_AN_ID))
|
||||
{
|
||||
if (($conf->dol_use_jmobile != 4))
|
||||
{
|
||||
print "\n";
|
||||
print "/* Set google analtics tag */\n";
|
||||
print ' var _gaq = _gaq || [];'."\n";
|
||||
print ' _gaq.push([\'_setAccount\', \''.$conf->global->MAIN_GOOGLE_AN_ID.'\']);'."\n";
|
||||
print ' _gaq.push([\'_trackPageview\']);'."\n";
|
||||
print ''."\n";
|
||||
print ' (function() {'."\n";
|
||||
print ' var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;'."\n";
|
||||
print ' ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';'."\n";
|
||||
print ' var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);'."\n";
|
||||
print ' })();'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
// End of tuning
|
||||
if (! empty($_SERVER['MAIN_SHOW_TUNING_INFO']) || ! empty($conf->global->MAIN_SHOW_TUNING_INFO))
|
||||
{
|
||||
print "\n";
|
||||
print "/* Add memory info */\n";
|
||||
print 'window.console && console.log("';
|
||||
if (! empty($conf->global->MEMCACHED_SERVER)) print 'MEMCACHED_SERVER='.$conf->global->MEMCACHED_SERVER.' - ';
|
||||
print 'MAIN_OPTIMIZE_SPEED='.(isset($conf->global->MAIN_OPTIMIZE_SPEED)?$conf->global->MAIN_OPTIMIZE_SPEED:'off');
|
||||
if (! empty($micro_start_time)) // Works only if MAIN_SHOW_TUNING_INFO is defined at $_SERVER level. Not in global variable.
|
||||
{
|
||||
$micro_end_time = microtime(true);
|
||||
print ' - Build time: '.ceil(1000*($micro_end_time-$micro_start_time)).' ms';
|
||||
}
|
||||
if (function_exists("memory_get_usage"))
|
||||
{
|
||||
print ' - Mem: '.memory_get_usage();
|
||||
}
|
||||
if (function_exists("xdebug_memory_usage"))
|
||||
{
|
||||
print ' - XDebug time: '.ceil(1000*xdebug_time_index()).' ms';
|
||||
print ' - XDebug mem: '.xdebug_memory_usage();
|
||||
print ' - XDebug mem peak: '.xdebug_peak_memory_usage();
|
||||
}
|
||||
if (function_exists("zend_loader_file_encoded"))
|
||||
{
|
||||
print ' - Zend encoded file: '.(zend_loader_file_encoded()?'yes':'no');
|
||||
}
|
||||
print '");'."\n";
|
||||
}
|
||||
|
||||
print "\n".'</script>'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
// End of tuning
|
||||
if (! empty($_SERVER['MAIN_SHOW_TUNING_INFO']) || ! empty($conf->global->MAIN_SHOW_TUNING_INFO))
|
||||
{
|
||||
print "\n".'<script type="text/javascript">'."\n";
|
||||
print 'window.console && console.log("';
|
||||
if (! empty($conf->global->MEMCACHED_SERVER)) print 'MEMCACHED_SERVER='.$conf->global->MEMCACHED_SERVER.' - ';
|
||||
print 'MAIN_OPTIMIZE_SPEED='.(isset($conf->global->MAIN_OPTIMIZE_SPEED)?$conf->global->MAIN_OPTIMIZE_SPEED:'off');
|
||||
if (! empty($micro_start_time)) // Works only if MAIN_SHOW_TUNING_INFO is defined at $_SERVER level. Not in global variable.
|
||||
{
|
||||
$micro_end_time = microtime(true);
|
||||
print ' - Build time: '.ceil(1000*($micro_end_time-$micro_start_time)).' ms';
|
||||
}
|
||||
if (function_exists("memory_get_usage"))
|
||||
{
|
||||
print ' - Mem: '.memory_get_usage();
|
||||
}
|
||||
if (function_exists("xdebug_memory_usage"))
|
||||
{
|
||||
print ' - XDebug time: '.ceil(1000*xdebug_time_index()).' ms';
|
||||
print ' - XDebug mem: '.xdebug_memory_usage();
|
||||
print ' - XDebug mem peak: '.xdebug_peak_memory_usage();
|
||||
}
|
||||
if (function_exists("zend_loader_file_encoded"))
|
||||
{
|
||||
print ' - Zend encoded file: '.(zend_loader_file_encoded()?'yes':'no');
|
||||
}
|
||||
print '");'."\n";
|
||||
print '</script>'."\n";
|
||||
|
||||
// Add Xdebug coverage of code
|
||||
if (defined('XDEBUGCOVERAGE'))
|
||||
{
|
||||
print_r(xdebug_get_code_coverage());
|
||||
}
|
||||
}
|
||||
|
||||
// If there is some logs in buffer to show
|
||||
if (count($conf->logbuffer))
|
||||
{
|
||||
print "\n";
|
||||
print "<!-- Start of log output\n";
|
||||
//print '<div class="hidden">'."\n";
|
||||
foreach($conf->logbuffer as $logline)
|
||||
|
||||
// If there is some logs in buffer to show
|
||||
if (count($conf->logbuffer))
|
||||
{
|
||||
print $logline."<br>\n";
|
||||
print "\n";
|
||||
print "<!-- Start of log output\n";
|
||||
//print '<div class="hidden">'."\n";
|
||||
foreach($conf->logbuffer as $logline)
|
||||
{
|
||||
print $logline."<br>\n";
|
||||
}
|
||||
//print '</div>'."\n";
|
||||
print "End of log output -->\n";
|
||||
}
|
||||
//print '</div>'."\n";
|
||||
print "End of log output -->\n";
|
||||
}
|
||||
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('printCommonFooter',$parameters); // Note that $action and $object may have been modified by some hooks
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user