Skip to content

Instantly share code, notes, and snippets.

@varblob
varblob / application.controller.js
Last active October 20, 2015 22:04 — forked from HenryVonfire/README_01.md
Expandable list
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Expandable list',
buttonName: 'expand all',
families: [{title:'parent a',
children: [
{ title:'a son' },{ title:'a daughter' }
]
},
@varblob
varblob / application.controller.js
Last active October 21, 2015 07:39
Example of view model wrapping normal model
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Expandable list',
buttonName: 'expand all',
families: [{title:'parent a',
children: [
{ title:'a son' },{ title:'a daughter' }
]
},
translateTarget(target, dx, dy){
// dragged position in the data-x/data-y attributes
function attr(name, defaultVal) {
return (parseFloat(target.getAttribute('data-' + name)) || defaultVal);
}
function setAttrs(target, attrs){
Object.keys(attrs).forEach((k)=> {
target.setAttribute('data-' + k, attrs[k]);
});
}