//<![CDATA[
$(function() {
WCF.TabMenu.init();
+ new WCF.Search.User('#username');
});
//]]>
</script>
<dt><label for="username">{lang}wcf.user.username{/lang}</label></dt>
<dd>
<input type="text" id="username" name="username" value="{$username}" class="medium" />
- <script type="text/javascript">
- //<![CDATA[
- var suggestion = new Suggestion('username');
- suggestion.enableMultiple(false);
- //]]>
- </script>
</dd>
</dl>
* @param boolean commaSeperated
*/
init: function(searchInput, callback, excludedSearchValues, commaSeperated) {
- if ((callback === null && !commaSeperated) && !$.isFunction(callback)) {
+ if (callback !== null && callback !== undefined && !$.isFunction(callback)) {
console.debug("[WCF.Search.Base] The given callback is invalid, aborting.");
return;
}
-
- this._callback = callback;
+
+ this._callback = (callback) ? callback : null;
this._excludedSearchValues = [];
if (excludedSearchValues) {
this._excludedSearchValues = excludedSearchValues;
this._proxy = new WCF.Action.Proxy({
success: $.proxy(this._success, this)
});
+
+ if (this._searchInput.getTagName() === 'input') {
+ this._searchInput.attr('autocomplete', 'off');
+ }
},
/**
* @param object event
*/
_executeCallback: function(event) {
+ var $clearSearchInput = false;
var $listItem = $(event.currentTarget);
// notify callback
if (this._commaSeperated) {
}
}
else {
- var $clearSearchInput = this._callback($listItem.data());
+ if (this._callback === null) {
+ this._searchInput.val($listItem.data('label'));
+ }
+ else {
+ $clearSearchInput = (this._callback($listItem.data()) === true) ? true : false;
+ }
}
// close list and revert input