use same method (prefer .min.js over .js) for app.js include in Etemplate and Framework

fixes double include of /mail/js/app.js and /mail/js/app.min.js
This commit is contained in:
Ralf Becker 2021-07-08 16:57:47 +02:00
parent 2be47ffce2
commit d57fe03326
2 changed files with 9 additions and 8 deletions

View File

@ -234,13 +234,10 @@ class Etemplate extends Etemplate\Widget\Template
{ {
// check if application of template has a app.js file --> load it, preferring local min file if there // check if application of template has a app.js file --> load it, preferring local min file if there
list($app) = explode('.',$this->name); list($app) = explode('.',$this->name);
if (file_exists(EGW_SERVER_ROOT.'/'.$app.'/js/app.min.js')) if (file_exists(EGW_SERVER_ROOT.($path = '/'.$app.'/js/app.min.js')) ||
file_exists(EGW_SERVER_ROOT.($path = '/'.$app.'/js/app.js')))
{ {
Framework::includeJS('.','app.min',$app,true); Framework::includeJS($path);
}
else if (file_exists(EGW_SERVER_ROOT.'/'.$app.'/js/app.js'))
{
Framework::includeJS('.','app',$app,true);
} }
// Category styles // Category styles
Categories::css($app); Categories::css($app);

View File

@ -1490,7 +1490,7 @@ abstract class Framework extends Framework\Extra
* @param string $app ='phpgwapi' application directory to search - default = phpgwapi * @param string $app ='phpgwapi' application directory to search - default = phpgwapi
* @param boolean $append =true should the file be added * @param boolean $append =true should the file be added
*/ */
static function includeJS($package, $file=null, $app='phpgwapi', $append=true) static function includeJS($package, $file=null, $app='api', $append=true)
{ {
self::$js_include_mgr->include_js_file($package, $file, $app, $append); self::$js_include_mgr->include_js_file($package, $file, $app, $append);
} }
@ -1584,7 +1584,11 @@ abstract class Framework extends Framework\Extra
} }
// try to add app specific js file // try to add app specific js file
self::includeJS('.', 'app', $app); if (file_exists(EGW_SERVER_ROOT.($path = '/'.$app.'/js/app.min.js')) ||
file_exists(EGW_SERVER_ROOT.($path = '/'.$app.'/js/app.js')))
{
self::includeJS($path);
}
// add all js files from Framework::includeJS() // add all js files from Framework::includeJS()
$files = Framework\Bundle::js_includes(self::$js_include_mgr->get_included_files()); $files = Framework\Bundle::js_includes(self::$js_include_mgr->get_included_files());