Last active
April 5, 2016 22:08
-
-
Save nightire/8749ee21c350a97d9d87 to your computer and use it in GitHub Desktop.
auto-complete component with editable content
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
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName:'Ember Twiddle', | |
selections: Ember.A([ | |
Ember.Object.create({ name: '张三', phone: '13987654321' }), | |
Ember.Object.create({ name: '李四', phone: '13987654321' }), | |
Ember.Object.create({ name: '王五', phone: '13987654321' }), | |
Ember.Object.create({ name: '赵六', phone: '13987654321' }), | |
]), | |
actions: { | |
select(item) { | |
this.set('selected', item) | |
}, | |
} | |
}); |
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
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
classNames: ['auto-complete-datalist'], | |
classNameBindings: ['active'], | |
actions: { | |
select(item) { | |
this.attrs.select(item) | |
this.attrs.active.update(false) | |
} | |
} | |
}); |
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
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
classNames: ['auto-complete-input'], | |
classNameBindings: ['active'], | |
attributeBindings: ['contenteditable'], | |
click() { | |
return false | |
}, | |
focusIn() { | |
this.attrs.active.update(true) | |
} | |
}); |
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
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
}); |
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
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
.auto-complete-input { | |
padding: .5em 1em; | |
border: 1px solid #ccc; | |
} | |
.auto-complete-datalist ul { | |
margin: 0; | |
padding: 0; | |
opacity: 0; | |
transform: scaleY(0); | |
transform-origin: 50% 0; | |
transition: all .2s; | |
} | |
.auto-complete-datalist.active ul { | |
opacity: 1; | |
transform: scaleY(1); | |
} | |
.auto-complete-datalist ul li { | |
padding: .5em 1em; | |
list-style: none; | |
} | |
.auto-complete-datalist ul li:hover { | |
background: #eee; | |
cursor: pointer; | |
} |
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
{ | |
"version": "0.4.16", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.1.0", | |
"ember-data": "2.1.0", | |
"ember-template-compiler": "2.1.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment