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