Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/files_texteditor.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Petry <PVince81@yahoo.fr>2015-09-23 11:35:51 +0300
committerVincent Petry <PVince81@yahoo.fr>2015-09-23 11:35:51 +0300
commit506ca9ff76abfb14300b45984d02b9d1c6ec6a67 (patch)
tree7c9686e260a485fa5d49e5bf77e77ca7b251f324 /appinfo
parentc56a944c04926884ba18afa2e1333abf11d3bf44 (diff)
Only load scripts when needed
This will only load the scripts and CSS whenever the files app is displayed
Diffstat (limited to 'appinfo')
-rw-r--r--appinfo/app.php21
1 files changed, 9 insertions, 12 deletions
diff --git a/appinfo/app.php b/appinfo/app.php
index 28cfd0b..dbcc368 100644
--- a/appinfo/app.php
+++ b/appinfo/app.php
@@ -2,16 +2,13 @@
// only load text editor if the user is logged in
if (\OCP\User::isLoggedIn()) {
- $request = \OC::$server->getRequest();
-
- if (isset($request->server['REQUEST_URI'])) {
- $url = $request->server['REQUEST_URI'];
- if (preg_match('%index.php/apps/files(/.*)?%', $url) || preg_match('%index.php/s/(/.*)?%', $url)) {
- OCP\Util::addStyle('files_texteditor', 'DroidSansMono/stylesheet');
- OCP\Util::addStyle('files_texteditor', 'style');
- OCP\Util::addStyle('files_texteditor', 'mobile');
- OCP\Util::addscript('files_texteditor', 'editor');
- OCP\Util::addscript('files_texteditor', 'vendor/ace/src-noconflict/ace');
- }
- }
+ $eventDispatcher = \OC::$server->getEventDispatcher();
+ $eventDispatcher->addListener('OCA\Files::loadAdditionalScripts', function() {
+ OCP\Util::addStyle('files_texteditor', 'DroidSansMono/stylesheet');
+ OCP\Util::addStyle('files_texteditor', 'style');
+ OCP\Util::addStyle('files_texteditor', 'mobile');
+ OCP\Util::addscript('files_texteditor', 'editor');
+ OCP\Util::addscript('files_texteditor', 'vendor/ace/src-noconflict/ace');
+ });
}
+