string convention
parent
d9774f5f50
commit
ada04366be
|
@ -19,12 +19,12 @@ module.exports = React.createClass
|
|||
value : React.PropTypes.any
|
||||
|
||||
getDefaultProps: ->
|
||||
className : ""
|
||||
className : ''
|
||||
colors : {}
|
||||
dataSource : {}
|
||||
exact : true
|
||||
multiple : true
|
||||
type : "text"
|
||||
type : 'text'
|
||||
|
||||
getInitialState: ->
|
||||
focus : false
|
||||
|
@ -57,12 +57,12 @@ module.exports = React.createClass
|
|||
|
||||
if @state.focus
|
||||
children = @refs.suggestions.getDOMNode().children
|
||||
for child, index in children when child.classList.contains "active"
|
||||
child.classList.remove "active"
|
||||
query = child.getAttribute "id"
|
||||
for child, index in children when child.classList.contains 'active'
|
||||
child.classList.remove 'active'
|
||||
query = child.getAttribute 'id'
|
||||
break
|
||||
|
||||
if key_ascii is 13 and query isnt ""
|
||||
if key_ascii is 13 and query isnt ''
|
||||
for key, label of @state.suggestions when query.toLowerCase() is label.toLowerCase()
|
||||
suggestion = {"#{key}": label}
|
||||
break
|
||||
|
@ -76,23 +76,23 @@ module.exports = React.createClass
|
|||
index = if index >= children.length - 1 then 0 else index + 1
|
||||
else
|
||||
index = if index is 0 then children.length - 1 else index - 1
|
||||
children[index].classList.add "active"
|
||||
children[index].classList.add 'active'
|
||||
|
||||
onBlur: (event) ->
|
||||
setTimeout (=> @setState focus: false, suggestions: {}), 300
|
||||
|
||||
onSelect: (event) ->
|
||||
key = event.target.getAttribute "id"
|
||||
key = event.target.getAttribute 'id'
|
||||
@_addValue {"#{key}": @state.suggestions[key]}
|
||||
|
||||
onRefreshSelection: (event) ->
|
||||
children = @refs.suggestions.getDOMNode().children
|
||||
for child, index in children when child.classList.contains "active"
|
||||
child.classList.remove "active"
|
||||
for child, index in children when child.classList.contains 'active'
|
||||
child.classList.remove 'active'
|
||||
break
|
||||
|
||||
onDelete: (event) ->
|
||||
delete @state.values[event.target.getAttribute "id"]
|
||||
delete @state.values[event.target.getAttribute 'id']
|
||||
@setState focus: false, values: @state.values
|
||||
@props.onChange? @
|
||||
|
||||
|
@ -100,12 +100,12 @@ module.exports = React.createClass
|
|||
render: ->
|
||||
className = "#{localCSS.root} #{@props.className}"
|
||||
className += " #{@props.type}" if @props.type
|
||||
className += " focus" if @state.focus
|
||||
className += ' focus' if @state.focus
|
||||
<div data-react-toolbox='autocomplete' className={className}>
|
||||
{ <label>{@props.label}</label> if @props.label }
|
||||
{
|
||||
if @props.multiple
|
||||
<ul className={localCSS.values} data-flex="horizontal wrap"
|
||||
<ul className={localCSS.values} data-flex='horizontal wrap'
|
||||
onClick={@onDelete}>
|
||||
{
|
||||
for key, label of @state.values
|
||||
|
@ -113,13 +113,13 @@ module.exports = React.createClass
|
|||
}
|
||||
</ul>
|
||||
}
|
||||
<Input {...@props} ref="input" value="" label=""
|
||||
<Input {...@props} ref='input' value='' label=''
|
||||
onBlur={@onBlur}
|
||||
onChange={@onChange}
|
||||
onFocus={@onFocus}
|
||||
onKeyDown={@onKeyPress}
|
||||
/>
|
||||
<ul ref="suggestions" className={localCSS.suggestions}
|
||||
<ul ref='suggestions' className={localCSS.suggestions}
|
||||
onClick={@onSelect} onMouseEnter={@onRefreshSelection}>
|
||||
{<li key={key} id={key}>{label}</li> for key, label of @state.suggestions}
|
||||
</ul>
|
||||
|
@ -154,7 +154,7 @@ module.exports = React.createClass
|
|||
values = value
|
||||
setTimeout (=> @props.onChange? @), 10
|
||||
@setState focus: false, values: values
|
||||
@refs.input.setValue if @props.multiple then "" else value[key]
|
||||
@refs.input.setValue if @props.multiple then '' else value[key]
|
||||
|
||||
_getSuggestions: (query) ->
|
||||
suggestions = {}
|
||||
|
|
Loading…
Reference in New Issue