mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-03-26 10:45:04 -04:00
* Add GBIF cient * Add lookup * Add autocomplete for GBIF lookup * Add extra detail to scientific names * Autocomplete * Add routes * Rmeove mapping * Add autocomplete * Update GBIF data on save * db/schema * Style * Extract service * Add concern * Add concern * Save photos * Initial coverage * Coverage * Add coverage * Shut up, codeclimate * Shut up, codeclimate * Unused * Shut up, codeclimate * Apply suggestions from code review * Remove localhost * Fix rubocop * Fix rubocop * Add UI links * Add rake * Indent * Update Gemfile.lock * Update lib/tasks/gbif.rake * Update app/views/crops/_scientific_names.html.haml * Rubocop * Expand edit photo form * Fix error * Add model validations * Skip photos without backlinks * Fix tests * Add photo words * Allow blank * Rubocop and handle invalid legacy data * Apply suggestions from code review * Update lib/tasks/gbif.rake
32 lines
1.0 KiB
CoffeeScript
32 lines
1.0 KiB
CoffeeScript
# TODO: This assumes one autocomplete per page.
|
|
# Needs to be a function so that when we append one of these, it gets uniquely associated with the hidden controls.
|
|
jQuery ->
|
|
|
|
if el = $( '.scientific-name-auto-suggest' )
|
|
|
|
id = $( '.scientific-name-auto-suggest-id' )
|
|
|
|
el.autocomplete
|
|
minLength: 3,
|
|
source: el.attr( 'data-source-url' ),
|
|
focus: ( event, ui ) ->
|
|
el.val( ui.item.canonicalName )
|
|
id.val( ui.item.nameKey )
|
|
false
|
|
select: ( event, ui ) ->
|
|
el.val( ui.item.canonicalName )
|
|
id.val( ui.item.nameKey )
|
|
false
|
|
response: ( event, ui ) ->
|
|
id.val( "" )
|
|
for item in ui.content
|
|
if item.name == el.val()
|
|
id.val( item.nameKey )
|
|
|
|
if el.data( 'uiAutocomplete' )
|
|
el.data( 'uiAutocomplete' )._renderItem = ( ul, item ) ->
|
|
$( '<li class="list-group-item"></li>' )
|
|
.data( 'item.autocomplete', item )
|
|
.append( "<a>#{item.canonicalName} (#{item.scientificName}) - #{item.rank}</a>" )
|
|
.appendTo( ul )
|