Last active
June 13, 2018 16:27
-
-
Save camskene/6c155779335246a1322c6a804dc1ded0 to your computer and use it in GitHub Desktop.
cs-accordion
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', | |
accordion: Ember.inject.service(), | |
actions: { | |
expandAll() { | |
let accordion = this.get('accordion'); | |
console.log('accordion', accordion); | |
console.log('expand all'); | |
accordion.expandAll('my-accordion') | |
}, | |
}, | |
}); |
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
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
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
accordion: Ember.inject.service(), | |
actions: { | |
toggleBody() { | |
let panelConfig = this.get('panelConfig'); | |
console.log('panelConfig', panelConfig); | |
this.toggleProperty('panelConfig.isExpanded'); | |
console.log('accordions', this.get('accordion.accordions')); | |
}, | |
}, | |
panelConfig: Ember.computed('accordion', function() { | |
let accordions = this.get('accordion.accordions'); | |
let group = this.get('group'); | |
return accordions[group].panels.findBy('name', this.get('elementId')); | |
}), | |
didInsertElement() { | |
this._super(...arguments); | |
let accordions = this.get('accordion.accordions'); | |
let group = this.get('group'); | |
if (!accordions[`${group}`]) { | |
accordions[`${group}`] = {}; | |
} | |
if (!accordions[`${group}`].panels) { | |
accordions[`${group}`].panels = []; | |
} | |
let panelConfig = { | |
name: this.get('elementId'), | |
isExpanded: false, | |
}; | |
accordions[`${group}`].panels.push(panelConfig); | |
}, | |
}); |
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
import Ember from 'ember'; | |
export default Ember.Service.extend({ | |
expandAll(name) { | |
let accordions = this.get('accordions'); | |
console.log('accordions', accordions); | |
}, | |
accordions: {}, | |
}); | |
/* | |
let accordions = { | |
'my-accordion': { | |
panels: [ | |
{ | |
name: 'panel-xyz', | |
isExpanded: false, | |
}, | |
{ | |
name: 'panel-ijk', | |
isExpanded: false, | |
}, | |
], | |
}, | |
'my-other-accordion': { | |
... | |
}, | |
} | |
*/ |
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.14.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": true, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "2.18.2", | |
"ember-template-compiler": "2.18.2", | |
"ember-testing": "2.18.2" | |
}, | |
"addons": { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment