Using {js} template plugin in ACP (broken commit, have fun)
authorAlexander Ebert <ebert@woltlab.com>
Fri, 26 Jun 2015 15:20:29 +0000 (17:20 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 26 Jun 2015 15:20:29 +0000 (17:20 +0200)
wcfsetup/install/files/acp/templates/header.tpl
wcfsetup/install/files/lib/system/template/plugin/JsFunctionTemplatePlugin.class.php

index 6409684309cfda3757a5f5f91d934109a353640f..cf908d1528895548cb1943e638ebd5111d449240 100644 (file)
        {@$__wcf->getStyleHandler()->getStylesheet(true)}
        {event name='stylesheets'}
        
+       <!-- Icons -->
+       <link rel="shortcut icon" href="{@$__wcf->getPath()}images/favicon.ico" />
+       <link rel="apple-touch-icon" href="{@$__wcf->getPath()}images/apple-touch-icon.png" />
+       
        <script>
                var SID_ARG_2ND = '{@SID_ARG_2ND_NOT_ENCODED}';
                var WCF_PATH = '{@$__wcf->getPath()}';
                var TIME_NOW = {@TIME_NOW};
                var URL_LEGACY_MODE = {if URL_LEGACY_MODE}true{else}false{/if};
        </script>
-       <script src="{@$__wcf->getPath()}js/3rdParty/jquery.min.js?v={@LAST_UPDATE_TIME}"></script>
-       <script src="{@$__wcf->getPath()}js/3rdParty/jquery-ui.min.js?v={@LAST_UPDATE_TIME}"></script>
-       <script src="{@$__wcf->getPath()}js/3rdParty/jquery-ui/touchPunch.min.js?v={@LAST_UPDATE_TIME}"></script>
-       <script src="{@$__wcf->getPath()}js/3rdParty/jquery-ui/nestedSortable.min.js?v={@LAST_UPDATE_TIME}"></script>
-       <script src="{@$__wcf->getPath()}js/WCF.Assets.js?v={@LAST_UPDATE_TIME}"></script>
-       <script src="{@$__wcf->getPath()}js/WCF.js?v={@LAST_UPDATE_TIME}"></script>
-       <script src="{@$__wcf->getPath()}acp/js/WCF.ACP.js?v={@LAST_UPDATE_TIME}"></script>
-       <script src="{@$__wcf->getPath()}js/require.js?v={@LAST_UPDATE_TIME}"></script>
-       <script src="{@$__wcf->getPath()}js/require.config.js?v={@LAST_UPDATE_TIME}"></script>
-       <script>
-               WCF.User.init({$__wcf->user->userID}, '{@$__wcf->user->username|encodeJS}');
-       </script>
-       {event name='javascriptInclude'}
-       
-       <!-- Icons -->
-       <link rel="shortcut icon" href="{@$__wcf->getPath()}images/favicon.ico" />
-       <link rel="apple-touch-icon" href="{@$__wcf->getPath()}images/apple-touch-icon.png" />
        
+       {js application='wcf' file='require' bundle='WCF.Core' core='true'}
+       {js application='wcf' file='require.config' bundle='WCF.Core' core='true'}
        <script>
                requirejs.config({
                        baseUrl: '{@$__wcf->getPath()}js'
                });
-               
-               $.holdReady(true);
        </script>
-       
        <script>
+               document.addEventListener('DOMContentLoaded', function() {
                require(['Language', 'WoltLab/WCF/ACP/Bootstrap'], function(Language, ACPBootstrap) {
                        Language.addObject({
                                '__days': [ '{lang}wcf.date.day.sunday{/lang}', '{lang}wcf.date.day.monday{/lang}', '{lang}wcf.date.day.tuesday{/lang}', '{lang}wcf.date.day.wednesday{/lang}', '{lang}wcf.date.day.thursday{/lang}', '{lang}wcf.date.day.friday{/lang}', '{lang}wcf.date.day.saturday{/lang}' ],
                        
                        ACPBootstrap.setup();
                });
-               
+               });
+       </script>
+       {js application='wcf' lib='jquery'}
+       {js application='wcf' lib='jquery-ui'}
+       {js application='wcf' lib='jquery-ui' file='touchPunch' bundle='WCF.Combined'}
+       {js application='wcf' lib='jquery-ui' file='nestedSortable' bundle='WCF.Combined'}
+       {js application='wcf' file='WCF.Assets' bundle='WCF.Combined'}
+       {js application='wcf' file='WCF' bundle='WCF.Combined'}
+       {js application='wcf' acp='true' file='WCF.ACP'}
+       <script>
+               $.holdReady(true);
+               WCF.User.init({$__wcf->user->userID}, '{@$__wcf->user->username|encodeJS}');
+       </script>
+       <script>
                $(function() {
                        {* work-around for unknown core-object during WCFSetup *}
                        {if PACKAGE_ID}
                        $('form[method=get]').attr('method', 'post');
                });
        </script>
+       {event name='javascriptInclude'}
 </head>
 
 <body id="tpl{$templateName|ucfirst}" data-template="{$templateName}" data-application="{$templateNameApplication}" class="wcfAcp">
index a318370a21d8eb5772e55b55593fd62a88b42db5..6091ac5cb25c224fd5bef0b0b43bee0fc74562fc 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 namespace wcf\system\template\plugin;
 use wcf\system\exception\SystemException;
+use wcf\system\request\RequestHandler;
 use wcf\system\template\TemplateEngine;
 use wcf\system\WCF;
 use wcf\util\StringUtil;
@@ -53,7 +54,7 @@ class JsFunctionTemplatePlugin implements IFunctionTemplatePlugin {
                        $isJqueryUi = true;
                }
                
-               $src = WCF::getPath($tagArgs['application']) . 'js/';
+               $src = WCF::getPath($tagArgs['application']) . (isset($tagArgs['acp']) && $tagArgs['acp'] === 'true' ? 'acp/' : '') . 'js/';
                if (!empty($tagArgs['bundle']) && !ENABLE_DEBUG_MODE) {
                        $src .= $tagArgs['bundle'];
                }
@@ -79,7 +80,8 @@ class JsFunctionTemplatePlugin implements IFunctionTemplatePlugin {
                $this->includedFiles[] = $src;
                $src .= (!ENABLE_DEBUG_MODE ? '.min' : '') . '.js?v=' . LAST_UPDATE_TIME;
                
-               $html = '<script' . (!isset($tagArgs['core']) || $tagArgs['core'] !== 'true' ? ' data-relocate="true"' : '') . ' src="' . $src . '"></script>'."\n";
+               $relocate = !RequestHandler::getInstance()->isACPRequest() && (!isset($tagArgs['core']) || $tagArgs['core'] !== 'true');
+               $html = '<script' . ($relocate ? ' data-relocate="true"' : '') . ' src="' . $src . '"></script>'."\n";
                
                if (isset($tagArgs['encodeJs']) && $tagArgs['encodeJs'] === 'true') {
                        $html = StringUtil::encodeJS($html);