Fixed box position handling
authorAlexander Ebert <ebert@woltlab.com>
Mon, 20 Nov 2017 15:34:11 +0000 (16:34 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 20 Nov 2017 15:34:11 +0000 (16:34 +0100)
Fixes be3a8e90cb326f1805d94a8ec802535c2cb87a21

wcfsetup/install/files/acp/templates/boxAdd.tpl
wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Box/Handler.js

index 6c2903639c01d91eb5d0d58ef001d6d7c2af515e..673c52cef62108fe79925cffd373e2529753ef34 100644 (file)
@@ -7,33 +7,33 @@
                require(['WoltLabSuite/Core/Acp/Ui/Box/Controller/Handler'], function(AcpUiBoxControllerHandler) {
                        AcpUiBoxControllerHandler.init({if $boxController}{@$boxController->objectTypeID}{/if});
                });
-       {else}
-               require(['Dictionary', 'Language', 'WoltLabSuite/Core/Acp/Ui/Box/Handler'], function(Dictionary, Language, AcpUiBoxHandler) {
-                       Language.addObject({
-                               'wcf.page.pageObjectID': '{lang}wcf.page.pageObjectID{/lang}',
-                               {foreach from=$pageNodeList item=pageNode}
-                                       {capture assign='pageObjectIDLanguageItem'}{lang __optional=true}wcf.page.pageObjectID.{@$pageNode->identifier}{/lang}{/capture}
-                                       {if $pageObjectIDLanguageItem}
-                                               'wcf.page.pageObjectID.{@$pageNode->identifier}': '{@$pageObjectIDLanguageItem}',
-                                       {/if}
-                                       {capture assign='pageObjectIDLanguageItem'}{lang __optional=true}wcf.page.pageObjectID.search.{@$pageNode->identifier}{/lang}{/capture}
-                                       {if $pageObjectIDLanguageItem}
-                                               'wcf.page.pageObjectID.search.{@$pageNode->identifier}': '{@$pageObjectIDLanguageItem}',
-                                       {/if}
-                               {/foreach}
-                               'wcf.page.pageObjectID.search.noResults': '{lang}wcf.page.pageObjectID.search.noResults{/lang}',
-                               'wcf.page.pageObjectID.search.results': '{lang}wcf.page.pageObjectID.search.results{/lang}',
-                               'wcf.page.pageObjectID.search.terms': '{lang}wcf.page.pageObjectID.search.terms{/lang}'
-                       });
-                       
-                       var handlers = new Dictionary();
-                       {foreach from=$pageHandlers key=handlerPageID item=requireObjectID}
-                               handlers.set({@$handlerPageID}, {if $requireObjectID}true{else}false{/if});
+       {/if}
+       
+       require(['Dictionary', 'Language', 'WoltLabSuite/Core/Acp/Ui/Box/Handler'], function(Dictionary, Language, AcpUiBoxHandler) {
+               Language.addObject({
+                       'wcf.page.pageObjectID': '{lang}wcf.page.pageObjectID{/lang}',
+                       {foreach from=$pageNodeList item=pageNode}
+                               {capture assign='pageObjectIDLanguageItem'}{lang __optional=true}wcf.page.pageObjectID.{@$pageNode->identifier}{/lang}{/capture}
+                               {if $pageObjectIDLanguageItem}
+                                       'wcf.page.pageObjectID.{@$pageNode->identifier}': '{@$pageObjectIDLanguageItem}',
+                               {/if}
+                               {capture assign='pageObjectIDLanguageItem'}{lang __optional=true}wcf.page.pageObjectID.search.{@$pageNode->identifier}{/lang}{/capture}
+                               {if $pageObjectIDLanguageItem}
+                                       'wcf.page.pageObjectID.search.{@$pageNode->identifier}': '{@$pageObjectIDLanguageItem}',
+                               {/if}
                        {/foreach}
-                       
-                       AcpUiBoxHandler.init(handlers);
+                       'wcf.page.pageObjectID.search.noResults': '{lang}wcf.page.pageObjectID.search.noResults{/lang}',
+                       'wcf.page.pageObjectID.search.results': '{lang}wcf.page.pageObjectID.search.results{/lang}',
+                       'wcf.page.pageObjectID.search.terms': '{lang}wcf.page.pageObjectID.search.terms{/lang}'
                });
-       {/if}
+               
+               var handlers = new Dictionary();
+               {foreach from=$pageHandlers key=handlerPageID item=requireObjectID}
+                       handlers.set({@$handlerPageID}, {if $requireObjectID}true{else}false{/if});
+               {/foreach}
+               
+               AcpUiBoxHandler.init(handlers, '{$boxType}');
+       });
        
        {if $__wcf->session->getPermission('admin.content.cms.canUseMedia')}
                require(['WoltLabSuite/Core/Media/Manager/Select'], function(MediaManagerSelect) {
index 75466dd02df33852d3e995bd11c30f79019f9477..b8dc2432ad8942b393156c6dafb98277f9682d49 100644 (file)
@@ -28,44 +28,47 @@ define(['Dictionary', 'Language', 'WoltLabSuite/Core/Ui/Page/Search/Handler'], f
                 * Initializes the interface logic.
                 * 
                 * @param       {Dictionary}    handlers        list of handlers by page id supporting page object ids
+                * @param       {string}        boxType         box type
                 */
-               init: function(handlers) {
+               init: function(handlers, boxType) {
                        _handlers = handlers;
                        
                        _boxController = elById('boxControllerID');
                        
-                       _containerPageID = elById('linkPageIDContainer');
-                       _containerExternalLink = elById('externalURLContainer');
-                       _containerPageObjectId = elById('linkPageObjectIDContainer');
-                       
-                       if (_handlers.size) {
-                               _pageId = elById('linkPageID');
-                               _pageId.addEventListener('change', this._togglePageId.bind(this));
-                               
-                               _pageObjectId = elById('linkPageObjectID');
+                       if (boxType !== 'system') {
+                               _containerPageID = elById('linkPageIDContainer');
+                               _containerExternalLink = elById('externalURLContainer');
+                               _containerPageObjectId = elById('linkPageObjectIDContainer');
                                
-                               _cache = new Dictionary();
-                               _activePageId = ~~_pageId.value;
-                               if (_activePageId && _handlers.has(_activePageId)) {
-                                       _cache.set(_activePageId, ~~_pageObjectId.value);
+                               if (_handlers.size) {
+                                       _pageId = elById('linkPageID');
+                                       _pageId.addEventListener('change', this._togglePageId.bind(this));
+                                       
+                                       _pageObjectId = elById('linkPageObjectID');
+                                       
+                                       _cache = new Dictionary();
+                                       _activePageId = ~~_pageId.value;
+                                       if (_activePageId && _handlers.has(_activePageId)) {
+                                               _cache.set(_activePageId, ~~_pageObjectId.value);
+                                       }
+                                       
+                                       elById('searchLinkPageObjectID').addEventListener(WCF_CLICK_EVENT, this._openSearch.bind(this));
+                                       
+                                       // toggle page object id container on init
+                                       if (_handlers.has(~~_pageId.value)) {
+                                               elShow(_containerPageObjectId);
+                                       }
                                }
                                
-                               elById('searchLinkPageObjectID').addEventListener(WCF_CLICK_EVENT, this._openSearch.bind(this));
-                               
-                               // toggle page object id container on init
-                               if (_handlers.has(~~_pageId.value)) {
-                                       elShow(_containerPageObjectId);
-                               }
+                               elBySelAll('input[name="linkType"]', null, (function (input) {
+                                       input.addEventListener('change', this._toggleLinkType.bind(this, input.value));
+                                       
+                                       if (input.checked) {
+                                               this._toggleLinkType(input.value);
+                                       }
+                               }).bind(this));
                        }
                        
-                       elBySelAll('input[name="linkType"]', null, (function(input) {
-                               input.addEventListener('change', this._toggleLinkType.bind(this, input.value));
-                               
-                               if (input.checked) {
-                                       this._toggleLinkType(input.value);
-                               }
-                       }).bind(this));
-                       
                        if (_boxController !== null) {
                                _position = elById('position');
                                _boxController.addEventListener('change', this._setAvailableBoxPositions.bind(this));
@@ -82,20 +85,24 @@ define(['Dictionary', 'Language', 'WoltLabSuite/Core/Ui/Page/Search/Handler'], f
                 * @protected
                 */
                _toggleLinkType: function(value) {
-                       if (value == 'none') {
-                               elHide(_containerPageID);
-                               elHide(_containerPageObjectId);
-                               elHide(_containerExternalLink);
-                       }
-                       if (value == 'internal') {
-                               elShow(_containerPageID);
-                               elHide(_containerExternalLink);
-                               if (_handlers.size) this._togglePageId();
-                       }
-                       if (value == 'external') {
-                               elHide(_containerPageID);
-                               elHide(_containerPageObjectId);
-                               elShow(_containerExternalLink);
+                       switch (value) {
+                               case 'none':
+                                       elHide(_containerPageID);
+                                       elHide(_containerPageObjectId);
+                                       elHide(_containerExternalLink);
+                                       break;
+                                       
+                               case 'internal':
+                                       elShow(_containerPageID);
+                                       elHide(_containerExternalLink);
+                                       if (_handlers.size) this._togglePageId();
+                                       break;
+                                       
+                               case 'external':
+                                       elHide(_containerPageID);
+                                       elHide(_containerPageObjectId);
+                                       elShow(_containerExternalLink);
+                                       break;
                        }
                },