Created
August 27, 2015 23:16
-
-
Save styfle/769f1e9ba5ce4f6468a7 to your computer and use it in GitHub Desktop.
First attempt at type definitions for atwho
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface JQueryAtWhoOptions<T> { | |
// key char for observing such as `@` | |
at?: string; | |
/* | |
alias name of `at` | |
it would be an id attribute of the popup view. | |
*/ | |
alias?: string; | |
/* | |
should be a plain object *Array* or a *URL* | |
would save *Array* directly. | |
would load and save remote JSON data by *URL* | |
*/ | |
data?: T[]; | |
/* | |
would eval it and assign value of the key contained in `${}` | |
key-value ( {'name'?: "one"} ) is an item in `data` Array. | |
Alternatively, this can be a function accepting one data item as a parameter. | |
*/ | |
displayTpl?: string | ((T)=> string); | |
/* | |
It will be evaluated and inserted in the inputor. | |
`atwho-at` is the `at` for runtime by default. | |
You change it into anything you want. | |
*/ | |
insertTpl?: string; | |
/* | |
There are several data processors that can be overriden here such as `filter`. | |
we will cover it later. | |
*/ | |
callbacks?: any, | |
/* | |
would matching item by test against the value of this `search_key` with query string. | |
*/ | |
searchKey?: string; | |
/* | |
limit number of items to show in popup list. | |
*/ | |
limit?: number; | |
/* | |
setting the max length of the string after `at` that would be matched | |
It will stop matching if the query string is longer than `max_len`. | |
*/ | |
maxLen?: number; | |
/* | |
if `yes`, At.js will match the query with a spaaace before the `at`. | |
*/ | |
startWithSpace?: boolean, | |
displayTimeout?: number; | |
// highlight_first suggestion in popup menu | |
highlightFirst?: boolean, | |
// delay time trigger At.js while typing. For example?: delay?: 400 | |
delay?: number, | |
// suffix for inserting string. | |
suffix?: string; | |
// don't show dropdown view without `suffix` | |
hideWithoutSuffix?: boolean; | |
} | |
interface JQueryAtWhoStatic { | |
} | |
interface JQueryStatic { | |
atwho: JQueryAtWhoStatic; | |
} | |
interface JQuery { | |
atwho(method: "hide"): JQuery; | |
atwho(method: "destroy"): JQuery; | |
atwho(method: "run"): JQuery; | |
atwho(method: string): JQuery; | |
atwho<T>(options?: JQueryAtWhoOptions<T>): JQuery; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment