_initSearchBar: function() {
var searchContainer = elById('pageHeaderSearch');
searchContainer.addEventListener(WCF_CLICK_EVENT, function(event) {
- event.preventDefault();
event.stopPropagation();
});
* @protected
*/
_keydown: function(event) {
- if (this._activeItem !== null || this._options.preventSubmit) {
+ if ((this._activeItem !== null && UiSimpleDropdown.isOpen(this._dropdownContainerId)) || this._options.preventSubmit) {
if (EventKey.Enter(event)) {
event.preventDefault();
}
}
- if (EventKey.ArrowUp(event) || EventKey.ArrowDown(event)) {
+ if (EventKey.ArrowUp(event) || EventKey.ArrowDown(event) || EventKey.Escape(event)) {
event.preventDefault();
}
},
_keyup: function(event) {
// handle dropdown keyboard navigation
if (this._activeItem !== null) {
+ if (!UiSimpleDropdown.isOpen(this._dropdownContainerId)) {
+ return;
+ }
+
if (EventKey.ArrowUp(event)) {
event.preventDefault();
}
}
+ // close list on escape
+ if (EventKey.Escape(event)) {
+ UiSimpleDropdown.close(this._dropdownContainerId);
+
+ return;
+ }
+
var value = this._element.value.trim();
if (this._lastValue === value) {
// value did not change, e.g. previously it was "Test" and now it is "Test ",
if (isset($_REQUEST['types']) && is_array($_REQUEST['types'])) {
$this->selectedObjectTypes = $_REQUEST['types'];
- // validate given values
- foreach ($this->selectedObjectTypes as $objectTypeName) {
- if (SearchEngine::getInstance()->getObjectType($objectTypeName) === null) {
- throw new IllegalLinkException();
+ // handle special selection to search in all areas
+ if (isset($this->selectedObjectTypes[0]) && $this->selectedObjectTypes[0] === 'everywhere') {
+ $this->selectedObjectTypes = [];
+ foreach (SearchEngine::getInstance()->getAvailableObjectTypes() as $typeName => $typeObject) {
+ $this->selectedObjectTypes[] = $typeName;
+ }
+ }
+ else {
+ // validate given values
+ foreach ($this->selectedObjectTypes as $objectTypeName) {
+ if (SearchEngine::getInstance()->getObjectType($objectTypeName) === null) {
+ throw new IllegalLinkException();
+ }
}
}
}
case 'subject':
case 'time':
case 'username': break;
+
+ /** @noinspection PhpMissingBreakStatementInspection */
case 'relevance': if (!$this->submit || !empty($this->query)) break;
+
default:
if (!$this->submit || !empty($this->query)) $this->sortField = 'relevance';
else $this->sortField = 'time';