This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/components/mobile-nav.js.es6

39 lines
779 B
JavaScript

export default Ember.Component.extend({
_init: function(){
if (!this.get('site.mobileView')) {
var classes = this.get('desktopClass');
if (classes) {
classes = classes.split(' ');
this.set('classNames', classes);
}
}
}.on('init'),
tagName: 'ul',
classNames: ['mobile-nav'],
currentPathChanged: function(){
this.set('expanded', false);
Em.run.next(() => this._updateSelectedHtml());
}.observes('currentPath'),
_updateSelectedHtml(){
const active = this.$('.active');
if (active && active.html) {
this.set('selectedHtml', active.html());
}
},
didInsertElement(){
this._updateSelectedHtml();
},
actions: {
toggleExpanded(){
this.toggleProperty('expanded');
}
}
});