From 58ec7cbd7c49e0333499626db29b3668c04864be Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 24 Mar 2016 18:17:57 +0100 Subject: [PATCH] Sitemap now functional (but seriously ugly) --- com.woltlab.wcf/templates/sitemap.tpl | 2 +- .../files/js/WoltLab/WCF/BootstrapFrontend.js | 8 ++--- .../js/WoltLab/WCF/Controller/Sitemap.js | 14 +++----- .../install/files/js/WoltLab/WCF/Ui/Dialog.js | 34 ++++++++++++------- wcfsetup/install/files/style/ui/sitemap.scss | 34 +++++++++++++++++++ 5 files changed, 64 insertions(+), 28 deletions(-) create mode 100644 wcfsetup/install/files/style/ui/sitemap.scss diff --git a/com.woltlab.wcf/templates/sitemap.tpl b/com.woltlab.wcf/templates/sitemap.tpl index d233f38a00..e21b443933 100644 --- a/com.woltlab.wcf/templates/sitemap.tpl +++ b/com.woltlab.wcf/templates/sitemap.tpl @@ -13,7 +13,7 @@ {foreach from=$tree item=sitemapName} {/foreach} diff --git a/wcfsetup/install/files/js/WoltLab/WCF/BootstrapFrontend.js b/wcfsetup/install/files/js/WoltLab/WCF/BootstrapFrontend.js index 93f5169de0..2e82eca3c9 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/BootstrapFrontend.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/BootstrapFrontend.js @@ -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 * @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; }); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Sitemap.js b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Sitemap.js index 9e447f8482..4bc22cb555 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Sitemap.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Sitemap.js @@ -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; }); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Dialog.js b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Dialog.js index 92999c9ad7..4ae4a9e6d3 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Dialog.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Dialog.js @@ -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 index 0000000000..ad2f2f374f --- /dev/null +++ b/wcfsetup/install/files/style/ui/sitemap.scss @@ -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; + } + } + } +} -- 2.20.1