1- /** @documenter esdoc */
1+ /** @documenter yuidoc */
22
33// Why `autocomplete.js-cybertooth.io`? https://github.com/algolia/autocomplete.js/issues/282
44import autocomplete from 'autocomplete.js-cybertooth.io/dist/autocomplete' ;
@@ -13,22 +13,25 @@ import { isPresent } from '@ember/utils';
1313 * and Ember Data's `store` in fetching type ahead completion results that your
1414 * user can choose.
1515 *
16+ * @class Autocomplete
1617 * @extends {TextField }
18+ * @public
1719 */
1820export default class Autocomplete extends TextField {
19- /** Services
20- ------------------------------------------------------------------------------------------------------------------ */
21+ /* Services
22+ - ------------------------------------------------------------------------------------------------------------------ */
2123
2224 /**
2325 * The Ember Data `store` service that is used to query the data.
2426 *
2527 * @access private
28+ * @field store
2629 * @type {DS.Store }
2730 */
2831 @service store ;
2932
30- /** Arguments
31- ------------------------------------------------------------------------------------------------------------------ */
33+ /* Arguments
34+ - ------------------------------------------------------------------------------------------------------------------ */
3235
3336 /**
3437 * Optional.
@@ -40,7 +43,7 @@ export default class Autocomplete extends TextField {
4043 * <Autocomplete ... @additionalFilters={{hash by_active=true}} ... />
4144 * ```
4245 *
43- * @argument
46+ * @argument additionalFilters
4447 * @type {{} }
4548 */
4649 additionalFilters = { } ;
@@ -55,7 +58,7 @@ export default class Autocomplete extends TextField {
5558 * The number of milliseconds to wait between keystrokes in the autocomplete textbox
5659 * before firing of the search request.
5760 *
58- * @argument
61+ * @argument debounce
5962 * @type {number }
6063 */
6164 debounce = 250 ;
@@ -75,7 +78,7 @@ export default class Autocomplete extends TextField {
7578 * argument is not supplied, then the `displayKey` derived value will also be presented in
7679 * the suggestions list that appears beneath the autocomplete textbox.
7780 *
78- * @argument
81+ * @argument displayKey
7982 * @type {String|function }
8083 */
8184 displayKey = 'id' ;
@@ -89,7 +92,7 @@ export default class Autocomplete extends TextField {
8992 * <Autocomplete ... @filter="by_name_search" ... />
9093 * ```
9194 *
92- * @argument
95+ * @argument filter
9396 * @type {String }
9497 */
9598 filter = '' ;
@@ -142,7 +145,7 @@ export default class Autocomplete extends TextField {
142145 * ```handlebars
143146 * <Autocomplete ... @globalOptions={{hash clearOnSelected=true}} />
144147 * ```
145- * @argument
148+ * @argument globalOptions
146149 * @see https://github.com/algolia/autocomplete.js#global-options
147150 * @type {{} }
148151 */
@@ -191,7 +194,7 @@ export default class Autocomplete extends TextField {
191194 * <Autocomplete ... @include="roles" ... />
192195 * ```
193196 *
194- * @argument
197+ * @argument include
195198 * @type {String }
196199 */
197200 include = '' ;
@@ -205,7 +208,7 @@ export default class Autocomplete extends TextField {
205208 * <Autocomplete ... @modelName="user" ... />
206209 * ```
207210 *
208- * @argument
211+ * @argument modelName
209212 * @type {String }
210213 */
211214 modelName = '' ;
@@ -222,7 +225,7 @@ export default class Autocomplete extends TextField {
222225 * You can control how many records are being returned by your JSON:API
223226 * endpoint by passing the page size.
224227 *
225- * @argument
228+ * @argument page
226229 * @experimental
227230 * @type {{number: number, size: number} }
228231 */
@@ -241,7 +244,7 @@ export default class Autocomplete extends TextField {
241244 * <Autocomplete ... @sort="last-name,first-name,email" ... />
242245 * ```
243246 *
244- * @argument
247+ * @argument sort
245248 * @type {String }
246249 */
247250 sort = '' ;
@@ -270,34 +273,37 @@ export default class Autocomplete extends TextField {
270273 * <Autocomplete ... @suggestion={{suggestByFirstAndLastName}}/>
271274 * ```
272275 *
273- * @argument
276+ * @argument suggestion
274277 * @param {Object } model - the model instance the was retrieved by the search that you
275278 * can use to create the suggestion
276279 * @type {function }
277280 * @return {String } the suggestion value wrapped in a `<p>` element.
278281 */
279282 suggestion = undefined ;
280283
281- /** Computed
282- ------------------------------------------------------------------------------------------------------------------ */
284+ /* Computed
285+ ------------------------------------------------------------------------------------------------------------------- */
286+
283287 /**
284288 * DO NOT TOUCH.
285289 *
286290 * The Autocomplete instance that is created on `didInsertElement`.
287291 *
292+ * @field _autocompleteInstance
288293 * @private
289294 * @type {Autocomplete }
290295 */
291296 _autocompleteInstance = null ;
292297
293- /** Actions
294- ------------------------------------------------------------------------------------------------------------------ */
298+ /* Actions
299+ - ------------------------------------------------------------------------------------------------------------------ */
295300
296301 /**
297302 * The html `#id` selector of this component used to instantiate the `Autocomplete` instance.
298303 *
304+ * @property _selector
299305 * @private
300- * @return {string }
306+ * @return {String }
301307 */
302308 get _selector ( ) {
303309 return `#${ this . elementId } ` ;
@@ -308,10 +314,12 @@ export default class Autocomplete extends TextField {
308314 * The event handler will be invoked with 3 arguments: the jQuery event object, the suggestion
309315 * object, and the name of the dataset the suggestion belongs to.
310316 *
317+ * @method autocompleted
318+ * @public
311319 * @param {Event } event - the event object
312320 * @param {Object } chosenItem - the Ember Data instance that was selected
313- * @param {string } dataSetNameOrNumber - the name of the autocomplete.js dataset
314- * @emits {autocompleted}
321+ * @param {String } dataSetNameOrNumber - the name of the autocomplete.js dataset
322+ * @return {autocompleted }
315323 * @see https://github.com/algolia/autocomplete.js#events
316324 * @type {Action }
317325 */
@@ -322,7 +330,9 @@ export default class Autocomplete extends TextField {
322330 /**
323331 * Triggered when the dropdown menu of the autocomplete is closed.
324332 *
325- * @emits {closed}
333+ * @method closed
334+ * @public
335+ * @return {closed }
326336 * @see https://github.com/algolia/autocomplete.js#events
327337 * @type {Action }
328338 */
@@ -335,10 +345,12 @@ export default class Autocomplete extends TextField {
335345 * handler will be invoked with 3 arguments: the jQuery event object, the suggestion object, and
336346 * the name of the dataset the suggestion belongs to.
337347 *
348+ * @method cursorChanged
349+ * @public
338350 * @param {Event } event - the event object
339351 * @param {Object } chosenItem - the Ember Data instance that was selected
340- * @param {string } dataSetNameOrNumber - the name of the autocomplete.js dataset
341- * @emits {cursorChanged}
352+ * @param {String } dataSetNameOrNumber - the name of the autocomplete.js dataset
353+ * @return {cursorChanged }
342354 * @see https://github.com/algolia/autocomplete.js#events
343355 * @type {Action }
344356 */
@@ -349,7 +361,9 @@ export default class Autocomplete extends TextField {
349361 /**
350362 * Triggered when the cursor leaves the selections or its current index is lower than 0.
351363 *
352- * @emits {cursorRemoved}
364+ * @method cursorRemoved
365+ * @public
366+ * @return {cursorRemoved }
353367 * @see https://github.com/algolia/autocomplete.js#events
354368 * @type {Action }
355369 */
@@ -360,8 +374,10 @@ export default class Autocomplete extends TextField {
360374 /**
361375 * Triggered when all datasets are empty.
362376 *
377+ * @method empty
378+ * @public
363379 * @param {Event } event - the event object
364- * @emits {empty}
380+ * @return {empty }
365381 * @see https://github.com/algolia/autocomplete.js#events
366382 * @type {Action }
367383 */
@@ -372,8 +388,10 @@ export default class Autocomplete extends TextField {
372388 /**
373389 * Triggered when the dropdown menu of the autocomplete is opened.
374390 *
391+ * @method opened
392+ * @public
375393 * @param {Event } event - the event object
376- * @emits {opened}
394+ * @return {opened }
377395 * @see https://github.com/algolia/autocomplete.js#events
378396 * @type {Action }
379397 */
@@ -384,7 +402,9 @@ export default class Autocomplete extends TextField {
384402 /**
385403 * Triggered when appendTo is used and the wrapper is resized/repositionned.
386404 *
387- * @emits {redrawn}
405+ * @method redrawn
406+ * @public
407+ * @return {redrawn }
388408 * @see https://github.com/algolia/autocomplete.js#events
389409 * @type {Action }
390410 */
@@ -398,13 +418,14 @@ export default class Autocomplete extends TextField {
398418 * dataset the suggestion belongs to and a context object. The context contains a .selectionMethod
399419 * key that can be either click, enterKey, tabKey or blur, depending how the suggestion was selected.
400420 *
421+ * @method selected
401422 * @param {Event } event - the event object
402423 * @param {Object } chosenItem - the Ember Data instance that was selected
403- * @param {string } dataSetNameOrNumber - the name of the autocomplete.js dataset
424+ * @param {String } dataSetNameOrNumber - the name of the autocomplete.js dataset
404425 * @param {Object } context -
405- * @param {string } context.selectionMethod - the string describing how the selection
426+ * @param {String } context.selectionMethod - the string describing how the selection
406427 * was made (`click`, `enterKey`, etc.)
407- * @emits {selected} when a suggestion is selected
428+ * @return {selected } when a suggestion is selected
408429 * @see https://github.com/algolia/autocomplete.js#events
409430 * @type {Action }
410431 */
@@ -415,8 +436,9 @@ export default class Autocomplete extends TextField {
415436 /**
416437 * Triggered when the dropdown menu of the autocomplete is shown (opened and non-empty).
417438 *
439+ * @method shown
418440 * @param {Event } event - the event object
419- * @emits {shown} when the dropdown menu of the autocomplete is shown
441+ * @return {shown } when the dropdown menu of the autocomplete is shown
420442 * @see https://github.com/algolia/autocomplete.js#events
421443 * @type {Action }
422444 */
@@ -427,38 +449,47 @@ export default class Autocomplete extends TextField {
427449 /**
428450 * Triggered when a dataset is rendered.
429451 *
452+ * @method updated
430453 * @param {Event } event - the event object
431- * @emits {updated} when a dataset is rendered
454+ * @return {updated } when a dataset is rendered
432455 * @see https://github.com/algolia/autocomplete.js#events
433456 * @type {Action }
434457 */
435458 updated ( /*event*/ ) {
436459 // override accordingly
437460 }
438461
439- /** Methods
440- ------------------------------------------------------------------------------------------------------------------ */
462+ /* Methods
463+ - ------------------------------------------------------------------------------------------------------------------ */
441464
465+ /**
466+ * @method didInsertElement
467+ * @public
468+ */
442469 didInsertElement ( ) {
443470 super . didInsertElement ( ...arguments ) ;
444471 this . _fixAutofocus ( ) ;
445472 this . _initializeAutocomplete ( ) ;
446473 }
447474
448- /** Private
449- ------------------------------------------------------------------------------------------------------------------ */
450-
451475 /**
452476 * Destroy the #_autocompleteInstance instance that was created during #didInsertElement.
477+ *
478+ * @method willDestroy
479+ * @public
453480 */
454481 willDestroy ( ) {
455482 this . _autocompleteInstance . autocomplete . destroy ( ) ;
456483 super . willDestroy ( ...arguments ) ;
457484 }
458485
486+ /* Private
487+ ------------------------------------------------------------------------------------------------------------------- */
488+
459489 /**
460490 * Fixes Ember's weird bug where autofocus can't be re-triggered on subsequent transitions.
461491 *
492+ * @method _fixAutofocus
462493 * @private
463494 */
464495 _fixAutofocus ( ) {
@@ -473,6 +504,7 @@ export default class Autocomplete extends TextField {
473504 * Responsible for locating this component's `<input>` element and passing it
474505 * to Algolia's `autocomplete.js` library for initialisation.
475506 *
507+ * @method _initializeAutocomplete
476508 * @private
477509 */
478510 _initializeAutocomplete ( ) {
@@ -508,9 +540,9 @@ export default class Autocomplete extends TextField {
508540 }
509541
510542 /**
543+ * @method _queryOptions
511544 * @param {String } filterValue - the textbox value
512545 * @private
513- * @todo unit tests of this
514546 */
515547 _queryOptions ( filterValue ) {
516548 const queryOptions = { filter : { } } ;
0 commit comments