*/
_triggerElement: null,
+ /**
+ * @var Element
+ */
+ _button: null,
+
+ /**
+ * @var Function
+ */
+ _callbackFocus: null,
+
+ /**
+ * @var boolean
+ */
+ _wasInsideDropdown: false,
+
/**
* Initializes the WCF.User.Panel.Abstract class.
*
this._identifier = identifier;
this._triggerElement = triggerElement;
this._options = options;
+ this._callbackFocus = null;
this._proxy = new WCF.Action.Proxy({
showLoadingOverlay: false,
});
this._triggerElement.click($.proxy(this.toggle, this));
+ this._button = elBySel('a', this._triggerElement[0]);
+ if (this._button) {
+ elAttr(this._button, 'role', 'button');
+ elAttr(this._button, 'tabindex', '0');
+ elAttr(this._button, 'aria-haspopup', true);
+ elAttr(this._button, 'aria-expanded', false);
+ }
if (this._options.showAllLink) {
this._triggerElement.dblclick($.proxy(this._dblClick, this));
this._loadData = false;
this._load();
}
+
+ elAttr(this._button, 'aria-expanded', true);
+ if (this._callbackFocus === null) {
+ this._callbackFocus = this._maintainFocus.bind(this);
+ }
+ document.body.addEventListener('focus', this._callbackFocus, { capture: true });
+ }
+ else {
+ elAttr(this._button, 'aria-expanded', false);
+ document.body.removeEventListener('focus', this._callbackFocus);
}
return false;
this._dropdown.resetItems();
this._loadData = true;
}
+ },
+
+ /**
+ * @param {Event} event
+ */
+ _maintainFocus: function(event) {
+ var dropdown = this._dropdown.getContainer()[0];
+
+ if (!dropdown.contains(event.target)) {
+ if (this._wasInsideDropdown) {
+ this._button.focus();
+ this._wasInsideDropdown = false;
+ }
+ else {
+ elBySel('a', dropdown).focus();
+ }
+ }
+ else {
+ this._wasInsideDropdown = true;
+ }
}
});