2015-02-12 21:22:32 -07:00
|
|
|
import Ember from 'ember';
|
2014-09-15 22:55:37 -06:00
|
|
|
|
2015-10-28 11:36:45 +00:00
|
|
|
const {Route, addObserver, inject, removeObserver} = Ember;
|
|
|
|
|
2014-10-24 21:09:50 +00:00
|
|
|
// Routes that extend MobileIndexRoute need to implement
|
2014-09-15 22:55:37 -06:00
|
|
|
// desktopTransition, a function which is called when
|
|
|
|
// the user resizes to desktop levels.
|
2015-10-28 11:36:45 +00:00
|
|
|
export default Route.extend({
|
2014-09-15 22:55:37 -06:00
|
|
|
desktopTransition: Ember.K,
|
2015-11-20 12:26:34 -05:00
|
|
|
_callDesktopTransition: null,
|
2014-09-15 22:55:37 -06:00
|
|
|
|
2015-10-28 11:36:45 +00:00
|
|
|
mediaQueries: inject.service(),
|
2014-09-15 22:55:37 -06:00
|
|
|
|
2015-10-28 11:36:45 +00:00
|
|
|
activate() {
|
2015-11-15 11:06:49 +00:00
|
|
|
this._super(...arguments);
|
2015-11-20 12:26:34 -05:00
|
|
|
this._callDesktopTransition = () => {
|
|
|
|
if (!this.get('mediaQueries.isMobile')) {
|
|
|
|
this.desktopTransition();
|
|
|
|
}
|
|
|
|
};
|
2015-10-28 11:36:45 +00:00
|
|
|
addObserver(this, 'mediaQueries.isMobile', this._callDesktopTransition);
|
2014-09-15 22:55:37 -06:00
|
|
|
},
|
|
|
|
|
2015-10-28 11:36:45 +00:00
|
|
|
deactivate() {
|
2015-11-15 11:06:49 +00:00
|
|
|
this._super(...arguments);
|
2015-11-20 12:26:34 -05:00
|
|
|
if (this._callDesktopTransition) {
|
2015-10-28 11:36:45 +00:00
|
|
|
removeObserver(this, 'mediaQueries.isMobile', this._callDesktopTransition);
|
2015-11-20 12:26:34 -05:00
|
|
|
this._callDesktopTransition = null;
|
|
|
|
}
|
|
|
|
}
|
2014-09-15 22:55:37 -06:00
|
|
|
});
|