Skip to content

Commit 3cf3d8b

Browse files
add documentation
1 parent 9e74830 commit 3cf3d8b

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

src/autocomplete.ts

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ interface ResponseItem {
7272
Value: string;
7373
}
7474

75-
// Core
75+
/**
76+
* Core
77+
*
78+
* @class
79+
* @author Baptiste Donaux <baptiste.donaux@gmail.com> @baptistedonaux
80+
*/
7681
class AutoComplete {
7782
static merge: any = function(): any {
7883
var merge: any = {},
@@ -185,6 +190,9 @@ class AutoComplete {
185190
Input: null,
186191
Select: null,
187192

193+
/**
194+
* Return the message when no result returns
195+
*/
188196
_EmptyMessage: function(): string {
189197
console.log("EmptyMessage", this);
190198

@@ -194,6 +202,10 @@ class AutoComplete {
194202

195203
return this.EmptyMessage;
196204
},
205+
206+
/**
207+
* Returns the maximum number of results
208+
*/
197209
_Limit: function(): number {
198210
console.log("Limit", this);
199211

@@ -205,6 +217,10 @@ class AutoComplete {
205217

206218
return parseInt(limit);
207219
},
220+
221+
/**
222+
* Returns the HHTP method to use
223+
*/
208224
_HttpMethod: function(): string {
209225
console.log("_HttpMethod", this);
210226

@@ -214,6 +230,10 @@ class AutoComplete {
214230

215231
return this.HttpMethod;
216232
},
233+
234+
/**
235+
* Returns the query param to use
236+
*/
217237
_QueryArg: function(): string {
218238
console.log("QueryArg", this);
219239

@@ -223,6 +243,10 @@ class AutoComplete {
223243

224244
return this.QueryArg;
225245
},
246+
247+
/**
248+
* Returns the URL to use for AJAX request
249+
*/
226250
_Url: function(): string {
227251
console.log("Url", this);
228252

@@ -232,6 +256,10 @@ class AutoComplete {
232256

233257
return this.Url;
234258
},
259+
260+
/**
261+
* Manage the close
262+
*/
235263
_Blur: function(now: boolean = false): void {
236264
console.log("Blur", "Close results div", this);
237265

@@ -244,6 +272,10 @@ class AutoComplete {
244272
}, 150);
245273
}
246274
},
275+
276+
/**
277+
* Manage the open
278+
*/
247279
_Focus: function(): void {
248280
console.log("Focus", "Open results div", this);
249281

@@ -255,6 +287,10 @@ class AutoComplete {
255287
this.DOMResults.setAttribute("class", "autocomplete open");
256288
}
257289
},
290+
291+
/**
292+
* Bind all results item if one result is opened
293+
*/
258294
_Open: function(): void {
259295
console.log("Open", this);
260296

@@ -265,12 +301,20 @@ class AutoComplete {
265301
};
266302
});
267303
},
304+
305+
/**
306+
* Position the results HTML element
307+
*/
268308
_Position:function(): void {
269309
console.log("Build results position", this);
270310

271311
this.DOMResults.setAttribute("class", "autocomplete");
272312
this.DOMResults.setAttribute("style", "top:" + (this.Input.offsetTop + this.Input.offsetHeight) + "px;left:" + this.Input.offsetLeft + "px;width:" + this.Input.clientWidth + "px;");
273313
},
314+
315+
/**
316+
* Execute the render of results DOM element
317+
*/
274318
_Render: function(response: ResponseItem[]|string): void {
275319
console.log("_Render", this, "Response", response);
276320

@@ -305,6 +349,10 @@ class AutoComplete {
305349

306350
this.DOMResults.appendChild(ul);
307351
},
352+
353+
/**
354+
* Deal with request response
355+
*/
308356
_Post: function(response: string): ResponseItem[]|string {
309357
console.log("Post", this);
310358

@@ -344,11 +392,19 @@ class AutoComplete {
344392
return response;
345393
}
346394
},
395+
396+
/**
397+
* Return the autocomplete value to send (before request)
398+
*/
347399
_Pre: function(): string {
348400
console.log("Pre", this);
349401

350402
return this.Input.value;
351403
},
404+
405+
/**
406+
* Choice one result item
407+
*/
352408
_Select: function(item: HTMLElement): void {
353409
console.log("Select", this);
354410

0 commit comments

Comments
 (0)