Forked from DingoEatingFuzz/components.checkbox-input.js
Last active
October 8, 2016 04:04
-
-
Save runspired/9cd0677596ed554f6bb7bb1395065e87 to your computer and use it in GitHub Desktop.
ember-1.13-over-rendering
This file contains 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({ | |
tagName: 'input', | |
type: 'checkbox', | |
onChange: null, | |
attributeBindings: [ 'type', 'name', 'checked:checked' ], | |
change: function() { | |
this.sendAction('onChange', this.$().is(':checked')); | |
}, | |
}); |
This file contains 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'; | |
const { | |
A, | |
set, | |
PromiseProxyMixin, | |
ArrayProxy, | |
computed | |
} = Ember; | |
const animals = 'https://raw.githubusercontent.com/boennemann/animals/master/words.json' | |
const PromiseArray = ArrayProxy.extend(PromiseProxyMixin); | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
term: '', | |
selection: computed(function() { return new A(); }), | |
items: computed(function() { | |
return PromiseArray.create({ | |
promise: fetch(animals).then(res => res.json()) | |
}); | |
}), | |
selectableItems: computed('items.[]', function() { | |
const selection = this.get('selection'); | |
return this.get('items').map(item => ({ | |
item, | |
isSelected: selection.includes(item), | |
})); | |
}), | |
filteredItems: computed('selectableItems', 'term', function() { | |
const term = this.get('term'); | |
const items = this.get('selectableItems'); | |
if (!term) { return items; } | |
return items.filter(item => item.item.indexOf(term) !== -1); | |
}), | |
actions: { | |
updateSelection(item, isSelected) { | |
const selection = this.get('selection'); | |
set(item, 'isSelected', isSelected); | |
isSelected ? selection.addObject(item.item) | |
: selection.removeObject(item.item); | |
}, | |
clearSelection() { | |
this.get('selection').clear(); | |
} | |
} | |
}); |
This file contains 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; | |
} | |
p { | |
background:papayawhip; | |
padding:15px; | |
height:30px; | |
} | |
ol { | |
list-style:none; | |
padding:0; | |
} | |
li { | |
border-left:2px solid rebeccapurple; | |
transition:0.5s border-left-width ease-in-out; | |
} | |
li:hover { | |
border-left-width:10px; | |
} |
This file contains 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.10.5", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.8.0", | |
"ember-data": "2.8.0", | |
"ember-template-compiler": "2.8.0", | |
"ember-testing": "2.8.0" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment