1
0
mirror of https://github.com/flarum/core.git synced 2025-08-10 18:35:56 +02:00

Upgrade to Ember 1.11-beta.1

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!
This commit is contained in:
Toby Zerner
2015-02-10 18:05:40 +10:30
parent cf88fda8c8
commit c28307903b
164 changed files with 4623 additions and 4587 deletions

View File

@@ -0,0 +1,40 @@
import Ember from 'ember';
import HasItemLists from 'flarum/mixins/has-item-lists';
/**
This component is a base class for a composer body. It provides a template
with a list of controls, a text editor, and some default behaviour.
*/
export default Ember.Component.extend(HasItemLists, {
layoutName: 'components/composer/composer-body',
itemLists: ['controls'],
submitLabel: '',
placeholder: '',
content: '',
originalContent: '',
user: null,
submit: null,
loading: false,
confirmExit: '',
disabled: Ember.computed.alias('composer.minimized'),
actions: {
submit: function(content) {
this.get('submit')({
content: content
});
},
willExit: function(abort) {
// If the user has typed something, prompt them before exiting
// this composer state.
if (this.get('content') !== this.get('originalContent') && !confirm(this.get('confirmExit'))) {
abort();
}
}
}
});

View File

@@ -0,0 +1,41 @@
import Ember from 'ember';
import ComposerBody from 'flarum/components/composer/composer-body';
var precompileTemplate = Ember.Handlebars.compile;
/**
The composer body for starting a new discussion. Adds a text field as a
control so the user can enter the title of their discussion. Also overrides
the `submit` and `willExit` actions to account for the title.
*/
export default ComposerBody.extend({
submitLabel: 'Post Discussion',
confirmExit: 'You have not posted your discussion. Do you wish to discard it?',
titlePlaceholder: 'Discussion Title',
title: '',
populateControls: function(items) {
var title = Ember.Component.create({
tagName: 'h3',
layout: precompileTemplate('{{ui/text-input value=component.title class="form-control" placeholder=component.titlePlaceholder disabled=component.disabled autoGrow=true}}'),
component: this
});
items.pushObjectWithTag(title, 'title');
},
actions: {
submit: function(content) {
this.get('submit')({
title: this.get('title'),
content: content
});
},
willExit: function(abort) {
if ((this.get('title') || this.get('content')) && !confirm(this.get('confirmExit'))) {
abort();
}
}
}
});

View File

@@ -0,0 +1,26 @@
import Ember from 'ember';
import ComposerBody from 'flarum/components/composer/composer-body';
var precompileTemplate = Ember.Handlebars.compile;
/**
The composer body for editing a post. Sets the initial content to the
content of the post that is being edited, and adds a title control to
indicate which post is being edited.
*/
export default ComposerBody.extend({
submitLabel: 'Save Changes',
content: Ember.computed.oneWay('post.content'),
originalContent: Ember.computed.oneWay('post.content'),
populateControls: function(controls) {
var title = Ember.Component.create({
tagName: 'h3',
layout: precompileTemplate('Editing Post #{{component.post.number}} in <em>{{discussion.title}}</em>'),
discussion: this.get('post.discussion'),
component: this
});
controls.pushObjectWithTag(title, 'title');
}
});

View File

@@ -0,0 +1,22 @@
import Ember from 'ember';
import ComposerBody from 'flarum/components/composer/composer-body';
var precompileTemplate = Ember.Handlebars.compile;
/**
The composer body for posting a reply. Adds a title control to indicate
which discussion is being replied to.
*/
export default ComposerBody.extend({
submitLabel: 'Post Reply',
populateControls: function(items) {
var title = Ember.Component.create({
tagName: 'h3',
layout: precompileTemplate('Replying to <em>{{component.discussion.title}}</em>'),
component: this
});
items.pushObjectWithTag(title, 'title');
}
});