Sitemap now functional (but seriously ugly)
authorAlexander Ebert <ebert@woltlab.com>
Thu, 24 Mar 2016 17:17:57 +0000 (18:17 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 24 Mar 2016 17:17:57 +0000 (18:17 +0100)
com.woltlab.wcf/templates/sitemap.tpl
wcfsetup/install/files/js/WoltLab/WCF/BootstrapFrontend.js
wcfsetup/install/files/js/WoltLab/WCF/Controller/Sitemap.js
wcfsetup/install/files/js/WoltLab/WCF/Ui/Dialog.js
wcfsetup/install/files/style/ui/sitemap.scss [new file with mode: 0644]

index d233f38a000574ae9cc250b0d0b48ec2492a3eb2..e21b4439339f8c18e9d02d7f383ff74819fd20f9 100644 (file)
@@ -13,7 +13,7 @@
                        
                        {foreach from=$tree item=sitemapName}
                                <div id="sitemap_{$sitemapName}" class="tabMenuContent hidden">
-                                       {if $sitemapName == $defaultSitemapName}{@$sitemap}{/if}
+                                       <div class="section">{if $sitemapName == $defaultSitemapName}{@$sitemap}{/if}</div>
                                </div>
                        {/foreach}
                </div>
index 93f5169de034346ed87696777228a0a8deb7c04c..2e82eca3c90069a5be293b0a1f936ed87530f9c4 100644 (file)
@@ -2,7 +2,7 @@
  * Bootstraps WCF's JavaScript with additions for the frontend usage.
  * 
  * @author     Alexander Ebert
- * @copyright  2001-2015 WoltLab GmbH
+ * @copyright  2001-2016 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @module     WoltLab/WCF/BootstrapFrontend
  */
@@ -23,7 +23,7 @@ define(
        /**
         * @exports     WoltLab/WCF/BootstrapFrontend
         */
-       var BootstrapFrontend = {
+       return {
                /**
                 * Bootstraps general modules and frontend exclusive ones.
                 * 
@@ -32,7 +32,7 @@ define(
                setup: function(options) {
                        Bootstrap.setup();
                        
-                       //ControllerSitemap.setup();
+                       ControllerSitemap.setup();
                        
                        if (options.styleChanger) {
                                //ControllerStyleChanger.setup();
@@ -91,6 +91,4 @@ define(
                        }
                }
        };
-       
-       return BootstrapFrontend;
 });
index 9e447f8482a518ae79eafea7256f1c1b11fdbfff..4bc22cb5553cc34c1db427e977279247671de05b 100644 (file)
@@ -10,25 +10,24 @@ define(['Ajax', 'EventHandler', 'Language', 'Dom/Util', 'Ui/Dialog', 'Ui/TabMenu
        "use strict";
        
        var _cache = [];
-       var _dialog = null;
        
        /**
         * @exports     WoltLab/WCF/Controller/Sitemap
         */
-       var ControllerSitemap = {
+       return {
                /**
                 * Binds click handler.
                 */
                setup: function() {
-                       elById('sitemap').addEventListener('click', this._click.bind(this));
+                       elBySel('#sitemap > a').addEventListener(WCF_CLICK_EVENT, this.open.bind(this));
                },
                
                /**
                 * Handles clicks on the sitemap button.
                 * 
-                * @param       {object}        event   event object
+                * @param       {Event}         event   event object
                 */
-               _click: function(event) {
+               open: function(event) {
                        event.preventDefault();
                        
                        UiDialog.open(this);
@@ -46,14 +45,13 @@ define(['Ajax', 'EventHandler', 'Language', 'Dom/Util', 'Ui/Dialog', 'Ui/TabMenu
                _ajaxSuccess: function(data) {
                        _cache.push(data.returnValues.sitemapName);
                        
-                       elById('sitemap_' + data.returnValues.sitemapName).innerHTML = data.returnValues.template;
+                       elById('sitemap_' + data.returnValues.sitemapName).children[0].innerHTML = data.returnValues.template;
                },
                
                _dialogSetup: function() {
                        return {
                                id: 'sitemapDialog',
                                options: {
-                                       disableContentPadding: true,
                                        title: Language.get('wcf.page.sitemap')
                                },
                                source: {
@@ -92,6 +90,4 @@ define(['Ajax', 'EventHandler', 'Language', 'Dom/Util', 'Ui/Dialog', 'Ui/TabMenu
                        }
                } 
        };
-       
-       return ControllerSitemap;
 });
index 92999c9ad707c56f5a8ef9a7dc9b6fb18a1f2232..4ae4a9e6d3a77dea5b722eca0743a4c10a82a7c2 100644 (file)
@@ -131,15 +131,23 @@ define(
                                setupData.source();
                        }
                        else if (Core.isPlainObject(setupData.source)) {
-                               Ajax.api(this, setupData.source.data, (function(data) {
-                                       if (data.returnValues && typeof data.returnValues.template === 'string') {
-                                               this.open(callbackObject, data.returnValues.template);
-                                               
-                                               if (typeof setupData.source.after === 'function') {
-                                                       setupData.source.after(_dialogs.get(setupData.id).content, data);
+                               if (typeof html === 'string' && html.trim() !== '') {
+                                       setupData.source = html;
+                               }
+                               else {
+                                       Ajax.api(this, setupData.source.data, (function (data) {
+                                               if (data.returnValues && typeof data.returnValues.template === 'string') {
+                                                       this.open(callbackObject, data.returnValues.template);
+                                                       
+                                                       if (typeof setupData.source.after === 'function') {
+                                                               setupData.source.after(_dialogs.get(setupData.id).content, data);
+                                                       }
                                                }
-                                       }
-                               }).bind(this));
+                                       }).bind(this));
+                                       
+                                       // deferred initialization
+                                       return {};
+                               }
                        }
                        else {
                                if (typeof setupData.source === 'string') {
@@ -291,21 +299,21 @@ define(
                        
                        var content;
                        if (element === null) {
-                               content = elCreate('div');
-                               
                                if (typeof html === 'string') {
+                                       content = elCreate('div');
+                                       content.id = id;
                                        content.innerHTML = html;
                                }
                                else if (html instanceof DocumentFragment) {
                                        if (html.children[0].nodeName !== 'div' || html.childElementCount > 1) {
+                                               content = elCreate('div');
+                                               content.id = id;
                                                content.appendChild(html);
                                        }
                                        else {
-                                               content = html.children[0];
+                                               content = html;
                                        }
                                }
-                               
-                               content.id = id;
                        }
                        else {
                                content = element;
diff --git a/wcfsetup/install/files/style/ui/sitemap.scss b/wcfsetup/install/files/style/ui/sitemap.scss
new file mode 100644 (file)
index 0000000..ad2f2f3
--- /dev/null
@@ -0,0 +1,34 @@
+.sitemapList {
+       h3 {
+               padding-bottom: 5px;
+               
+               @include wcfFontHeadline;
+       }
+       
+       a {
+               display: block;
+               padding: 2px 10px;
+               
+               &:hover {
+                       background-color: $wcfTabularBoxBackgroundActive;
+               }
+       }
+       
+       > li {
+               & + li {
+                       border-top: 1px solid $wcfContentBorderInner;
+                       margin-top: 5px;
+                       padding-top: 5px;
+               }
+               
+               > ul > li {
+                       > a {
+                               padding-left: 20px;
+                       }
+                       
+                       > ul > li > a {
+                               padding-left: 40px;
+                       }
+               }
+       }
+}