mirror of
https://github.com/flarum/framework.git
synced 2024-12-03 07:33:36 +08:00
c28307903b
HTMLBars goodness! Since there was some breakage and a lot of fiddling around to get some things working, I took this opportunity to do a big cleanup of the whole Ember app. I accidentally worked on some new features too :3 Note that the app is still broken right now, pending on https://github.com/emberjs/ember.js/issues/10401 Cleanup: - Restructuring of components - Consolidation of some stuff into mixins, cleanup of some APIs that will be public - Change all instances of .property() / .observes() / .on() to Ember.computed() / Ember.observer() / Ember.on() respectively (I think it is more readable) - More comments - Start conforming to a code style (2 spaces for indentation) New features: - Post hiding/restoring - Mark individual discussions as read by clicking - Clicking on a read discussion jumps to the end - Mark all discussions as read - Progressively mark the discussion as read as the page is scrolled - Unordered list post formatting - Post permalink popup Demo once that Ember regression is fixed!
68 lines
2.3 KiB
JavaScript
68 lines
2.3 KiB
JavaScript
import Ember from 'ember';
|
|
|
|
import HasItemLists from 'flarum/mixins/has-item-lists';
|
|
import DropdownSplit from 'flarum/components/ui/dropdown-split';
|
|
import StreamScrubber from 'flarum/components/discussion/stream-scrubber';
|
|
|
|
var $ = Ember.$;
|
|
|
|
export default Ember.View.extend(HasItemLists, {
|
|
itemLists: ['sidebar'],
|
|
|
|
didInsertElement: function() {
|
|
this.get('controller').on('loaded', this, this.loaded);
|
|
this.get('controller').on('startWasChanged', this, this.startWasChanged);
|
|
},
|
|
|
|
willDestroyElement: function() {
|
|
this.get('controller').off('loaded', this, this.loaded);
|
|
this.get('controller').off('startWasChanged', this, this.startWasChanged);
|
|
},
|
|
|
|
// When the controller has finished loading, we want to scroll down to the
|
|
// appropriate post instantly (without animation).
|
|
loaded: function() {
|
|
this.get('streamContent').send('goToNumber', this.get('controller.start'), true);
|
|
},
|
|
|
|
// When the start position of the discussion changes, we want to scroll
|
|
// down to the appropriate post.
|
|
startWasChanged: function(start) {
|
|
this.get('streamContent').send('goToNumber', start);
|
|
},
|
|
|
|
// ------------------------------------------------------------------------
|
|
// OBSERVERS
|
|
// ------------------------------------------------------------------------
|
|
|
|
// Whenever the model's title changes, we want to update that document's
|
|
// title the reflect the new title.
|
|
updateTitle: Ember.observer('controller.model.title', function() {
|
|
this.set('controller.controllers.application.pageTitle', this.get('controller.model.title'));
|
|
}),
|
|
|
|
// ------------------------------------------------------------------------
|
|
// LISTENERS
|
|
// ------------------------------------------------------------------------
|
|
|
|
populateSidebar: function(items) {
|
|
items.pushObjectWithTag(DropdownSplit.create({
|
|
items: this.populateItemList('controls'),
|
|
icon: 'reply',
|
|
buttonClass: 'btn-primary'
|
|
}), 'controls');
|
|
|
|
items.pushObjectWithTag(StreamScrubber.create({
|
|
streamContent: this.get('streamContent')
|
|
}), 'scrubber');
|
|
},
|
|
|
|
populateControls: function(items) {
|
|
var view = this;
|
|
this.addActionItem(items, 'reply', 'Reply').set('action', function() {
|
|
view.get('streamContent').send('goToLast');
|
|
view.get('controller').send('reply');
|
|
});
|
|
}
|
|
});
|