2015-01-30 09:52:19 +08:00
|
|
|
import Ember from 'ember';
|
|
|
|
|
2015-02-02 14:27:59 +08:00
|
|
|
export default Ember.Controller.extend(Ember.Evented, {
|
2015-01-30 09:52:19 +08:00
|
|
|
|
|
|
|
needs: ['index', 'application'],
|
|
|
|
|
2015-02-02 14:27:59 +08:00
|
|
|
content: null,
|
2015-01-30 09:52:19 +08:00
|
|
|
|
2015-02-02 14:27:59 +08:00
|
|
|
showing: false,
|
2015-01-30 09:52:19 +08:00
|
|
|
minimized: false,
|
2015-02-02 14:27:59 +08:00
|
|
|
fullScreen: false,
|
|
|
|
|
|
|
|
switchContent: function(newContent) {
|
|
|
|
var composer = this;
|
|
|
|
this.confirmExit().then(function() {
|
|
|
|
composer.set('content', null);
|
|
|
|
Ember.run.next(function() {
|
|
|
|
composer.set('content', newContent);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
2015-01-30 09:52:19 +08:00
|
|
|
|
2015-02-02 14:27:59 +08:00
|
|
|
confirmExit: function() {
|
|
|
|
var composer = this;
|
|
|
|
var promise = new Ember.RSVP.Promise(function(resolve, reject) {
|
|
|
|
var content = composer.get('content');
|
|
|
|
if (content) {
|
|
|
|
content.send('willExit', reject);
|
|
|
|
}
|
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
return promise;
|
|
|
|
},
|
2015-01-30 09:52:19 +08:00
|
|
|
|
|
|
|
actions: {
|
|
|
|
close: function() {
|
2015-02-02 14:27:59 +08:00
|
|
|
var composer = this;
|
|
|
|
this.confirmExit().then(function() {
|
|
|
|
composer.send('hide');
|
|
|
|
});
|
|
|
|
},
|
|
|
|
hide: function() {
|
2015-01-30 09:52:19 +08:00
|
|
|
this.set('showing', false);
|
2015-02-02 14:27:59 +08:00
|
|
|
this.set('fullScreen', false);
|
|
|
|
var content = this.get('content');
|
|
|
|
if (content) {
|
|
|
|
content.send('reset');
|
|
|
|
}
|
2015-01-30 09:52:19 +08:00
|
|
|
},
|
|
|
|
minimize: function() {
|
2015-02-02 14:27:59 +08:00
|
|
|
this.set('minimized', true);
|
|
|
|
this.set('fullScreen', false);
|
2015-01-30 09:52:19 +08:00
|
|
|
},
|
|
|
|
show: function() {
|
2015-02-02 14:27:59 +08:00
|
|
|
var composer = this;
|
|
|
|
Ember.run.next(function() {
|
|
|
|
composer.set('showing', true);
|
|
|
|
composer.set('minimized', false);
|
|
|
|
composer.trigger('focus');
|
|
|
|
});
|
|
|
|
},
|
|
|
|
fullScreen: function() {
|
|
|
|
this.set('fullScreen', true);
|
|
|
|
this.set('minimized', false);
|
|
|
|
this.trigger('focus');
|
2015-01-30 09:52:19 +08:00
|
|
|
},
|
2015-02-02 14:27:59 +08:00
|
|
|
exitFullScreen: function() {
|
|
|
|
this.set('fullScreen', false);
|
|
|
|
this.trigger('focus');
|
2015-01-30 09:52:19 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|