Ghost/core/client/app/routes/mobile-index-route.js
2015-03-11 12:37:41 -06:00

31 lines
891 B
JavaScript

import Ember from 'ember';
import mobileQuery from 'ghost/utils/mobile';
// Routes that extend MobileIndexRoute need to implement
// desktopTransition, a function which is called when
// the user resizes to desktop levels.
var MobileIndexRoute = Ember.Route.extend({
desktopTransition: Ember.K,
activate: function attachDesktopTransition() {
this._super();
mobileQuery.addListener(this.desktopTransitionMQ);
},
deactivate: function removeDesktopTransition() {
this._super();
mobileQuery.removeListener(this.desktopTransitionMQ);
},
setDesktopTransitionMQ: function () {
var self = this;
this.set('desktopTransitionMQ', function desktopTransitionMQ() {
if (!mobileQuery.matches) {
self.desktopTransition();
}
});
}.on('init')
});
export default MobileIndexRoute;