diff options
author | Olivier Paroz <oparoz@users.noreply.github.com> | 2017-01-05 22:37:26 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-05 22:37:26 +0300 |
commit | 65acb05fccdd9c2e8b6fd6fc7b76e8b8d946c011 (patch) | |
tree | 4f6a4523e06a3bba8fedb65d4c2842189e6eb854 /appinfo | |
parent | 363bf0a5e960a4225920dc8315df1d5fc4627564 (diff) | |
parent | a722fac08d821894c560f1acd925b6fd634af1c2 (diff) |
Merge pull request #181 from nextcloud/only-load-scripts-on-files-and-sharing
Only load scripts on the files and sharing pages
Diffstat (limited to 'appinfo')
-rw-r--r-- | appinfo/app.php | 51 |
1 files changed, 23 insertions, 28 deletions
diff --git a/appinfo/app.php b/appinfo/app.php index e75c81ac..27e8116b 100644 --- a/appinfo/app.php +++ b/appinfo/app.php @@ -56,33 +56,28 @@ $c->query('OCP\INavigationManager') * * The string has to match the app's folder name */ -Util::addTranslations('gallery'); +Util::addTranslations($appName); -// Hack which only loads the scripts in the Files app -$request = $c->query('Request'); -if (isset($request->server['REQUEST_URI'])) { - $url = $request->server['REQUEST_URI']; - if (preg_match('/apps\/files(_sharing)?$/', $url) - || preg_match('%apps/files(_sharing)?[/?]%', $url) - || preg_match('%^((?!/apps/).)*/s/\b(.*)\b(?<!/authenticate)$%', $url) - ) { - // @codeCoverageIgnoreStart - /** - * Scripts for the Files app - */ - Util::addScript($appName, 'vendor/bigshot/bigshot-compressed'); - Util::addScript($appName, 'vendor/dompurify/src/purify'); - Util::addScript($appName, 'galleryutility'); - Util::addScript($appName, 'galleryfileaction'); - Util::addScript($appName, 'slideshow'); - Util::addScript($appName, 'slideshowcontrols'); - Util::addScript($appName, 'slideshowzoomablepreview'); - Util::addScript($appName, 'gallerybutton'); +$loadScripts = function() use ($appName) { + // @codeCoverageIgnoreStart + /** + * Scripts for the Files app + */ + Util::addScript($appName, 'vendor/bigshot/bigshot-compressed'); + Util::addScript($appName, 'vendor/dompurify/src/purify'); + Util::addScript($appName, 'galleryutility'); + Util::addScript($appName, 'galleryfileaction'); + Util::addScript($appName, 'slideshow'); + Util::addScript($appName, 'slideshowcontrols'); + Util::addScript($appName, 'slideshowzoomablepreview'); + Util::addScript($appName, 'gallerybutton'); - /** - * Styles for the Files app - */ - Util::addStyle($appName, 'slideshow'); - Util::addStyle($appName, 'gallerybutton'); - } -}// @codeCoverageIgnoreEnd + /** + * Styles for the Files app + */ + Util::addStyle($appName, 'slideshow'); + Util::addStyle($appName, 'gallerybutton'); +};// @codeCoverageIgnoreEnd + +\OC::$server->getEventDispatcher()->addListener('OCA\Files::loadAdditionalScripts', $loadScripts); +\OC::$server->getEventDispatcher()->addListener('OCA\Files_Sharing::loadAdditionalScripts', $loadScripts); |