* list container element.
* 'onShow' - (function) Called when the list is shown. Passed the
* list container element.
+ * 'domParent' - (Element) Specifies the parent element. Defaults to
+ * document.body
+ * 'keydownObserver - (Element) The element to register the keydown handler
+ * on. Defaults to document.
* });
*
* [base = (Element) The element to use for display positioning purposes]
onChoose: Prototype.emptyFunction,
onHide: Prototype.emptyFunction,
onShow: Prototype.emptyFunction,
- domParent: null
+ domParent: null,
+ keydownObserver: document
}, opts || {});
this.div = new Element('DIV', { className: 'KeyNavList' }).hide().insert(new Element('UL'));
document.observe('click', this.onClickFunc);
this.onKeyDownFunc = this.onKeyDown.bindAsEventListener(this);
- document.observe('keydown', this.onKeyDownFunc);
+ $(this.opts.keydownObserver).observe('keydown', this.onKeyDownFunc);
this.resizeFunc = this.hide.bind(this);
Event.observe(window, 'resize', this.resizeFunc);
onShow: Prototype.K,
onType: Prototype.K,
paramName: elt.readAttribute('name'),
- tokens: []
+ tokens: [],
+ keydownObserver: this.elt
}, (this._setOptions ? this._setOptions(opts) : (opts || {})));
// Force carriage returns as token delimiters anyway
if (!this.knl) {
this.knl = new KeyNavList(this.elt, { onChoose: this.onSelect.bind(this),
onShow: this.opts.onShow.bind(this),
- domParent: this.opts.domParent });
+ domParent: this.opts.domParent,
+ keydownObserver: this.opts.keydownObserver});
}
this.knl.show(c);