-{capture assign='__searchFormLink'}{link controller='Search'}{/link}{/capture}
+{capture assign='__searchLink'}{link controller='Search'}{/link}{/capture}
{event name='settings'}
<div id="pageHeaderSearch" class="pageHeaderSearch">
- <form method="post" action="{@$__searchFormLink}">
+ <form method="post" action="{@$__searchLink}">
<div id="pageHeaderSearchInputContainer" class="pageHeaderSearchInputContainer">
<div class="pageHeaderSearchType dropdown">
- <a href="#" class="button dropdownToggle">{lang}wcf.search.type.{if !$searchObjectTypeName|empty}{@$searchObjectTypeName}{else}everywhere{/if}{/lang}</a>
+ <a href="#" class="button dropdownToggle">{lang}wcf.search.type.{if !$__searchObjectTypeName|empty}{@$__searchObjectTypeName}{else}everywhere{/if}{/lang}</a>
<ul class="dropdownMenu">
- <li><a href="#" data-object-type="">{lang}wcf.search.type.everywhere{/lang}</a></li>
+ <li><a href="#" data-object-type="everywhere">{lang}wcf.search.type.everywhere{/lang}</a></li>
<li class="dropdownDivider"></li>
{hascontent}
{content}
- {event name='searchTypesScoped'}
+ {if !$__searchTypesScoped|empty}{@$__searchTypesScoped}{/if}
{/content}
<li class="dropdownDivider"></li>
{/foreach}
<li class="dropdownDivider"></li>
- <li><a href="{@$__searchFormLink}">{lang}wcf.search.extended{/lang}</a></li>
+ <li><a href="{@$__searchLink}">{lang}wcf.search.extended{/lang}</a></li>
</ul>
</div>
<span class="icon icon16 fa-search pointer" title="{lang}wcf.global.search{/lang}"></span>
</button>
- {if !$searchObjectTypeName|empty}<input type="hidden" name="types[]" value="{$searchObjectTypeName}">{/if}
+ <div id="pageHeaderSearchParameters"></div>
{@SECURITY_TOKEN_INPUT_TAG}
</div>
<label for="pageHeaderSearchInput" class="pageHeaderSearchLabel"></label>
-
- {if !$searchObjectTypeName|empty}<input type="hidden" name="types[]" value="{$searchObjectTypeName}">{/if}
-
- {@SECURITY_TOKEN_INPUT_TAG}
</form>
</div>
{if !OFFLINE || $__wcf->session->getPermission('admin.general.canViewPageDuringOfflineMode')}
<script data-relocate="true">
require(['WoltLab/WCF/Ui/Search/Page'], function(UiSearchPage) {
- UiSearchPage.init();
+ UiSearchPage.init('{if !$__searchObjectTypeName|empty}{@$__searchObjectTypeName}{else}everywhere{/if}');
});
</script>
{/if}
\ No newline at end of file
-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, {
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;
}
};
});