2015-06-09 19:25:45 +03:00
|
|
|
/*
|
|
|
|
This cute little component has two jobs.
|
|
|
|
|
|
|
|
On desktop, it toggles autoNav behaviour. It tracks
|
|
|
|
that state via the maximise property, and uses the
|
|
|
|
state to render the appropriate icon.
|
|
|
|
|
|
|
|
On mobile, it renders a closing icon, and clicking it
|
|
|
|
closes the mobile menu
|
|
|
|
*/
|
|
|
|
|
|
|
|
import Ember from 'ember';
|
|
|
|
|
|
|
|
export default Ember.Component.extend({
|
|
|
|
classNames: ['gh-menu-toggle'],
|
|
|
|
|
2015-11-20 20:26:34 +03:00
|
|
|
mediaQueries: Ember.inject.service(),
|
|
|
|
isMobile: Ember.computed.reads('mediaQueries.isMobile'),
|
2015-06-09 19:25:45 +03:00
|
|
|
maximise: false,
|
|
|
|
|
|
|
|
iconClass: Ember.computed('maximise', 'isMobile', function () {
|
|
|
|
if (this.get('maximise') && !this.get('isMobile')) {
|
|
|
|
return 'icon-maximise';
|
|
|
|
} else {
|
|
|
|
return 'icon-minimise';
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
|
|
|
click: function () {
|
|
|
|
if (this.get('isMobile')) {
|
|
|
|
this.sendAction('mobileAction');
|
|
|
|
} else {
|
|
|
|
this.toggleProperty('maximise');
|
|
|
|
this.sendAction('desktopAction');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|