//<![CDATA[
$(function() {
new WCF.Effect.SmoothScroll();
- new WCF.Sitemap();
{if $__wcf->getStyleHandler()->countStyles() > 1}new WCF.Style.Chooser();{/if}
WCF.System.PageNavigation.init('.pageNavigation');
WCF.Date.Picker.init();
}
});
-/**
- * Provides a generic sitemap.
- */
-WCF.Sitemap = Class.extend({
- /**
- * sitemap name cache
- * @var array
- */
- _cache: [ ],
-
- /**
- * dialog overlay
- * @var jQuery
- */
- _dialog: null,
-
- /**
- * initialization state
- * @var boolean
- */
- _didInit: false,
-
- /**
- * action proxy
- * @var WCF.Action.Proxy
- */
- _proxy: null,
-
- /**
- * Initializes the generic sitemap.
- */
- init: function() {
- $('#sitemap').click($.proxy(this._click, this));
-
- this._cache = [ ];
- this._dialog = null;
- this._didInit = false;
- this._proxy = new WCF.Action.Proxy({
- success: $.proxy(this._success, this)
- });
- },
-
- /**
- * Handles clicks on the sitemap icon.
- */
- _click: function(event) {
- event.preventDefault();
-
- if (this._dialog === null) {
- this._dialog = $('<div id="sitemapDialog" />').appendTo(document.body);
-
- this._proxy.setOption('data', {
- actionName: 'getSitemap',
- className: 'wcf\\data\\sitemap\\SitemapAction'
- });
- this._proxy.sendRequest();
- }
- else {
- this._dialog.wcfDialog('open');
-
- $(document).trigger('resize');
- }
- },
-
- /**
- * Handles successful AJAX responses.
- *
- * @param object data
- * @param string textStatus
- * @param jQuery jqXHR
- */
- _success: function(data, textStatus, jqXHR) {
- if (this._didInit) {
- this._cache.push(data.returnValues.sitemapName);
-
- this._dialog.find('#sitemap_' + data.returnValues.sitemapName).html(data.returnValues.template);
-
- // redraw dialog
- this._dialog.wcfDialog('render');
- }
- else {
- // mark sitemap name as loaded
- this._cache.push(data.returnValues.sitemapName);
-
- // insert sitemap template
- this._dialog.html(data.returnValues.template);
-
- // bind event listener
- this._dialog.find('.sitemapNavigation').click($.proxy(this._navigate, this));
-
- // select active item
- this._dialog.find('.tabMenuContainer').wcfTabs('select', 'sitemap_' + data.returnValues.sitemapName);
-
- // show dialog
- this._dialog.wcfDialog({
- title: WCF.Language.get('wcf.page.sitemap')
- });
-
- this._didInit = true;
- }
-
- $(document).trigger('resize');
- },
-
- /**
- * Navigates between different sitemaps.
- *
- * @param object event
- */
- _navigate: function(event) {
- var $sitemapName = $(event.currentTarget).data('sitemapName');
- if (WCF.inArray($sitemapName, this._cache)) {
- this._dialog.find('.tabMenuContainer').wcfTabs('select', 'sitemap_' + $sitemapName);
-
- // redraw dialog
- this._dialog.wcfDialog('render');
- }
- else {
- this._proxy.setOption('data', {
- actionName: 'getSitemap',
- className: 'wcf\\data\\sitemap\\SitemapAction',
- parameters: {
- sitemapName: $sitemapName
- }
- });
- this._proxy.sendRequest();
- }
- }
-});
-
/**
* Provides a language chooser.
*
* @module WoltLab/WCF/Bootstrap
*/
define(
- [ 'jquery', 'favico', 'enquire', 'WoltLab/WCF/Date/Time/Relative', 'UI/SimpleDropdown', 'WoltLab/WCF/UI/Mobile', 'WoltLab/WCF/UI/TabMenu', 'WoltLab/WCF/UI/FlexibleMenu', 'UI/Dialog', 'WoltLab/WCF/UI/Tooltip'],
- function($, favico, enquire, relativeTime, simpleDropdown, UIMobile, UITabMenu, UIFlexibleMenu, UIDialog, UITooltip)
+ [
+ 'jquery', 'favico', 'enquire', 'WoltLab/WCF/Date/Time/Relative',
+ 'UI/SimpleDropdown', 'WoltLab/WCF/UI/Mobile', 'WoltLab/WCF/UI/TabMenu', 'WoltLab/WCF/UI/FlexibleMenu',
+ 'UI/Dialog', 'WoltLab/WCF/UI/Tooltip', 'WoltLab/WCF/Controller/Sitemap'
+ ],
+ function(
+ $, favico, enquire, relativeTime,
+ simpleDropdown, UIMobile, UITabMenu, UIFlexibleMenu,
+ UIDialog, UITooltip, ControllerSitemap
+ )
{
"use strict";
UIDialog.setup();
UITooltip.setup();
+ ControllerSitemap.setup();
+
$.holdReady(false);
}
};
--- /dev/null
+/**
+ * Provides the sitemap dialog.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2015 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module WoltLab/WCF/Controller/Sitemap
+ */
+define(['EventHandler', 'DOM/Util', 'UI/Dialog', 'UI/TabMenu'], function(EventHandler, DOMUtil, UIDialog, UITabMenu) {
+ "use strict";
+
+ var _cache = [];
+ var _dialog = null;
+
+ /**
+ * @constructor
+ */
+ function ControllerSitemap() {};
+ ControllerSitemap.prototype = {
+ /**
+ * Binds click handler.
+ */
+ setup: function() {
+ document.getElementById('sitemap').addEventListener('click', this._click.bind(this));
+ },
+
+ /**
+ * Handles clicks on the sitemap button.
+ *
+ * @param {object} event event object
+ */
+ _click: function(event) {
+ event.preventDefault();
+
+ if (UIDialog.getDialog('sitemapDialog') === null) {
+ new WCF.Action.Proxy({
+ autoSend: true,
+ data: {
+ actionName: 'getSitemap',
+ className: 'wcf\\data\\sitemap\\SitemapAction'
+ },
+ success: (function(data) {
+ _cache.push(data.returnValues.sitemapName);
+
+ _dialog = UIDialog.open('sitemapDialog', data.returnValues.template, {
+ disableContentPadding: true,
+ title: WCF.Language.get('wcf.page.sitemap')
+ });
+
+ var tabMenuContainer = _dialog.content.querySelector('.tabMenuContainer');
+ var menuId = DOMUtil.identify(tabMenuContainer);
+
+ UITabMenu.getTabMenu(menuId).select('sitemap_' + data.returnValues.sitemapName);
+
+ EventHandler.add('com.woltlab.wcf.simpleTabMenu_' + menuId, 'select', this.showTab.bind(this));
+ }).bind(this)
+ });
+ }
+ else {
+ UIDialog.open('sitemapDialog');
+ }
+ },
+
+ /**
+ * Callback for tab links, lazy loads content.
+ *
+ * @param {object<string, Element>} tabData tab data
+ */
+ showTab: function(tabData) {
+ var name = tabData.active.getAttribute('data-name').replace(/^sitemap_/, '');
+
+ if (_cache.indexOf(name) === -1) {
+ new WCF.Action.Proxy({
+ autoSend: true,
+ data: {
+ actionName: 'getSitemap',
+ className: 'wcf\\data\\sitemap\\SitemapAction',
+ parameters: {
+ sitemapName: name
+ }
+ },
+ success: function(data) {
+ _cache.push(data.returnValues.sitemapName);
+
+ document.getElementById('sitemap_' + data.returnValues.sitemapName).innerHTML = data.returnValues.template;
+ }
+ });
+ }
+ }
+ };
+
+ return new ControllerSitemap();
+});
var actions = _listeners.get(identifier);
if (actions === null) {
- actions = dictionary.create();
+ actions = new Dictionary();
_listeners.set(identifier, actions);
}
var callbacks = actions.get(action);
if (callbacks === null) {
- callbacks = dictionary.create();
+ callbacks = new Dictionary();
actions.set(action, callbacks);
}
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @module WoltLab/WCF/UI/Dialog
*/
-define(['jquery', 'Core', 'Dictionary', 'DOM/Util'], function($, Core, Dictionary, DOMUtil) {
+define(['jquery', 'enquire', 'Core', 'Dictionary', 'DOM/Util'], function($, enquire, Core, Dictionary, DOMUtil) {
"use strict";
var _activeDialog = null;
var _container = null;
var _dialogs = null;
+ var _dialogFullHeight = false;
var _keyupListener = null;
/**
return true;
}).bind(this);
+
+ enquire.register('screen and (max-width: 800px)', {
+ match: function() { _dialogFullHeight = true; },
+ unmatch: function() { _dialogFullHeight = false; },
+ setup: function() { _dialogFullHeight = true; },
+ deferSetup: true
+ });
},
/**
* @param {string} id element id, if exists the html parameter is ignored in favor of the existing element
* @param {?string} html content html
* @param {object<string, *>} options list of options, is completely ignored if the dialog already exists
+ * @return {object<string, *>} dialog data
*/
open: function(id, html, options) {
if (_dialogs.has(id)) {
this._createDialog(id, html, options);
}
+
+ return _dialogs.get(id);
},
/**
content = element;
}
- contentContainer.appendChild(element);
+ contentContainer.appendChild(content);
+
+ if (content.style.getPropertyValue('display') === 'none') {
+ content.style.removeProperty('display');
+ }
_dialogs.set(id, {
backdropCloseOnClick: options.backdropCloseOnClick,
return;
}
- // fix for a calculation bug in Chrome causing the scrollbar to overlap the border
- if ($.browser.chrome) {
- if (data.content.scrollHeight > data.content.clientHeight) {
- data.content.style.setProperty('margin-right', '-1px');
- }
- }
-
var contentContainer = data.content.parentNode;
var formSubmit = data.content.querySelector('.formSubmit');
unavailableHeight += DOMUtil.outerHeight(data.header);
- var maximumHeight = (window.innerHeight * 0.8) - unavailableHeight;
+ var maximumHeight = (window.innerHeight * (_dialogFullHeight ? 1 : 0.8)) - unavailableHeight;
contentContainer.style.setProperty('max-height', ~~maximumHeight + 'px');
+
+ // fix for a calculation bug in Chrome causing the scrollbar to overlap the border
+ if ($.browser.chrome) {
+ if (data.content.scrollHeight > maximumHeight) {
+ data.content.style.setProperty('margin-right', '-1px');
+ }
+ else {
+ data.content.style.removeProperty('margin-right');
+ }
+ }
},
/**
this._init();
// TODO: use WCF.DOMNodeInsertedHandler
+ WCF.DOMNodeInsertedHandler.addCallback('WoltLab/WCF/UI/TabMenu', this._init.bind(this));
},
/**
* @param {boolean=} disableEvent suppress event handling
*/
select: function(name, tab, disableEvent) {
- tab = tab || this._tabs.get(name);
+ tab = tab || this._tabs.get(name) || null;
if (tab === null) {
// check if name is an integer
}
if (tab === null) {
- throw new Error("Expected a valid tab name (tab menu id: '" + this._containerId + "').");
+ throw new Error("Expected a valid tab name, '" + name + "' given (tab menu id: '" + this._containerId + "').");
}
}
'EventHandler': 'WoltLab/WCF/Event/Handler',
'UI/Alignment': 'WoltLab/WCF/UI/Alignment',
'UI/Dialog': 'WoltLab/WCF/UI/Dialog',
- 'UI/SimpleDropdown': 'WoltLab/WCF/UI/Dropdown/Simple'
+ 'UI/SimpleDropdown': 'WoltLab/WCF/UI/Dropdown/Simple',
+ 'UI/TabMenu': 'WoltLab/WCF/UI/TabMenu'
}
}
});