From: Alexander Ebert Date: Fri, 20 May 2016 13:20:16 +0000 (+0200) Subject: Properly implemented new search X-Git-Tag: 3.0.0_Beta_1~1703 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c5a5ca6ca45d56ebf4f17db46a29ed534aece168;p=GitHub%2FWoltLab%2FWCF.git Properly implemented new search --- diff --git a/com.woltlab.wcf/templates/pageHeaderSearch.tpl b/com.woltlab.wcf/templates/pageHeaderSearch.tpl index 07403e5e07..1dfe96def0 100644 --- a/com.woltlab.wcf/templates/pageHeaderSearch.tpl +++ b/com.woltlab.wcf/templates/pageHeaderSearch.tpl @@ -1,19 +1,19 @@ -{capture assign='__searchFormLink'}{link controller='Search'}{/link}{/capture} +{capture assign='__searchLink'}{link controller='Search'}{/link}{/capture} {event name='settings'}
-
+
@@ -36,23 +36,19 @@ - {if !$searchObjectTypeName|empty}{/if} +
{@SECURITY_TOKEN_INPUT_TAG}
- - {if !$searchObjectTypeName|empty}{/if} - - {@SECURITY_TOKEN_INPUT_TAG}
{if !OFFLINE || $__wcf->session->getPermission('admin.general.canViewPageDuringOfflineMode')} {/if} \ No newline at end of file diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Search/Page.js b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Search/Page.js index 11e846efc0..522352a289 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Search/Page.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Search/Page.js @@ -1,10 +1,8 @@ -define(['Dom/Util', './Input'], function(DomUtil, UiSearchInput) { +define(['Core', 'Dom/Util', 'Ui/SimpleDropdown', './Input'], function(Core, DomUtil, UiSimpleDropdown, UiSearchInput) { "use strict"; - var _dropdownMenu = null; - return { - init: function () { + init: function (objectType) { var searchInput = elById('pageHeaderSearchInput'); new UiSearchInput(searchInput, { @@ -26,6 +24,49 @@ define(['Dom/Util', './Input'], function(DomUtil, UiSearchInput) { dropdownMenu.style.setProperty('transform', 'translateX(-' + Math.ceil(offsetRight) + 'px) translateY(-' + offsetTop + 'px)', ''); } }); + + var dropdownMenu = UiSimpleDropdown.getDropdownMenu(DomUtil.identify(elBySel('.pageHeaderSearchType'))); + var callback = this._click.bind(this); + elBySelAll('a[data-object-type]', dropdownMenu, function(link) { + link.addEventListener(WCF_CLICK_EVENT, callback); + }); + + // trigger click on init + var link = elBySel('a[data-object-type="' + objectType + '"]', dropdownMenu); + Core.triggerEvent(link, WCF_CLICK_EVENT); + }, + + _click: function(event) { + event.preventDefault(); + + var objectType = elData(event.currentTarget, 'object-type'); + + var container = elById('pageHeaderSearchParameters'); + container.innerHTML = ''; + + var parameters = elData(event.currentTarget, 'parameters'); + if (parameters) { + parameters = JSON.parse(parameters); + } + else { + parameters = {}; + } + + if (objectType) parameters['types[]'] = objectType; + + for (var key in parameters) { + if (parameters.hasOwnProperty(key)) { + var input = elCreate('input'); + input.type = 'hidden'; + input.name = key; + input.value = parameters[key]; + container.appendChild(input); + } + } + + // update label + var button = elBySel('.pageHeaderSearchType > .button', elById('pageHeaderSearchInputContainer')); + button.textContent = event.currentTarget.textContent; } }; });