1
0
mirror of https://github.com/flarum/core.git synced 2025-07-25 18:51:40 +02:00
Files
php-flarum/ember/app/components/application/back-button.js
Toby Zerner 976d97877b Improve global back button. Goes back to previous interface.
It’s not quite like the browser’s back button because it doesn’t
necessarily go back to the last URL; rather, it goes back to the last
interface. So if you go into a discussion, then go to a different
discussion via the side pane, the back button will still take you back
to the index (not the previous discussion).
2015-03-20 10:40:42 +10:30

44 lines
905 B
JavaScript
Executable File

import Ember from 'ember';
/**
The back/pin button group in the top-left corner of Flarum's interface.
*/
export default Ember.Component.extend({
classNames: ['back-button'],
classNameBindings: ['active', 'className'],
active: Ember.computed.or('target.paneIsShowing', 'target.paneIsPinned'),
mouseEnter: function() {
var target = this.get('target');
if (target) {
target.send('showPane');
}
},
mouseLeave: function() {
var target = this.get('target');
if (target) {
target.send('hidePane');
}
},
actions: {
// WE HAVE TO GO BACK. WAAAAAALLLLLLTTTTT
back: function() {
this.sendAction('goBack');
},
togglePinned: function() {
var target = this.get('target');
if (target) {
target.send('togglePinned');
}
},
toggleDrawer: function() {
this.sendAction('toggleDrawer');
}
}
});