framework/ember/app/components/discussions/post-wrapper.js

63 lines
1.6 KiB
JavaScript
Raw Normal View History

2015-01-03 19:21:47 +08:00
import Ember from 'ember';
import TaggedArray from '../../utils/tagged-array';
import ActionButton from '../ui/controls/action-button';
export default Ember.Component.extend({
tagName: 'article',
layoutName: 'components/discussions/post-wrapper',
2015-01-03 19:21:47 +08:00
// controls: null,
post: Ember.computed.alias('content'),
2015-01-03 19:21:47 +08:00
contentComponent: function() {
2015-01-07 14:52:34 +08:00
return 'discussions/post-content-'+this.get('post.type');
2015-01-03 19:21:47 +08:00
}.property('post.type'),
classNames: ['post'],
classNameBindings: ['post.deleted', 'post.edited'],
// construct: function() {
// // this.set('controls', Menu.create());
2015-01-03 19:21:47 +08:00
// // var post = this.get('post');
2015-01-03 19:21:47 +08:00
// // if (post.get('deleted')) {
// // this.addControl('restore', 'Restore', 'reply', 'canEdit');
// // this.addControl('delete', 'Delete', 'times', 'canDelete');
// // } else {
// // if (post.get('type') == 'comment') {
// // this.addControl('edit', 'Edit', 'pencil', 'canEdit');
// // this.addControl('hide', 'Delete', 'times', 'canEdit');
// // } else {
// // this.addControl('delete', 'Delete', 'times', 'canDelete');
// // }
// // }
// }.on('init'),
2015-01-03 19:21:47 +08:00
didInsertElement: function() {
var $this = this.$();
$this.css({opacity: 0});
setTimeout(function() {
$this.animate({opacity: 1}, 'fast');
}, 100);
2015-01-03 19:21:47 +08:00
},
addControl: function(tag, title, icon, permissionAttribute) {
if (permissionAttribute && ! this.get('post').get(permissionAttribute)) {
return;
}
var self = this;
var action = function(post) {
self.get('controller').send(actionName, post);
};
var item = MenuItem.extend({title: title, icon: icon, action: action});
this.get('controls').addItem(tag, item);
}
});