Fixed ContainerView code to build views correctly
This commit is contained in:
parent
8f32aed944
commit
ba5f2d23a1
|
@ -70,7 +70,6 @@ Discourse.HistoryController = Discourse.ObjectController.extend(Discourse.ModalF
|
||||||
Em.String.i18n("changed_by", { author: item.display_username });
|
Em.String.i18n("changed_by", { author: item.display_username });
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('wat');
|
|
||||||
historyController.setProperties({
|
historyController.setProperties({
|
||||||
loading: false,
|
loading: false,
|
||||||
versionLeft: result.first(),
|
versionLeft: result.first(),
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
/**
|
||||||
|
A button for clearing a pinned topic
|
||||||
|
|
||||||
|
@class ClearPinButton
|
||||||
|
@extends Discourse.ButtonView
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
|
Discourse.ClearPinButton = Discourse.ButtonView.extend({
|
||||||
|
textKey: 'topic.clear_pin.title',
|
||||||
|
helpKey: 'topic.clear_pin.help',
|
||||||
|
classNameBindings: ['unpinned'],
|
||||||
|
|
||||||
|
// Hide the button if it becomes unpinned
|
||||||
|
unpinned: function() {
|
||||||
|
// When not logged in don't show the button
|
||||||
|
if (!Discourse.User.current()) return 'hidden'
|
||||||
|
return this.get('controller.pinned') ? null : 'hidden';
|
||||||
|
}.property('controller.pinned'),
|
||||||
|
|
||||||
|
click: function(buffer) {
|
||||||
|
this.get('controller').clearPin();
|
||||||
|
},
|
||||||
|
|
||||||
|
renderIcon: function(buffer) {
|
||||||
|
buffer.push("<i class='icon icon-pushpin'></i>");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
This view handles rendering of a button in a drop down
|
This view handles rendering of a button with an associated drop down
|
||||||
|
|
||||||
@class DropdownButtonView
|
@class DropdownButtonView
|
||||||
@extends Discourse.View
|
@extends Discourse.View
|
||||||
|
@ -11,16 +11,19 @@ Discourse.DropdownButtonView = Discourse.View.extend({
|
||||||
attributeBindings: ['data-not-implemented'],
|
attributeBindings: ['data-not-implemented'],
|
||||||
|
|
||||||
didInsertElement: function(e) {
|
didInsertElement: function(e) {
|
||||||
var _this = this;
|
// If there's a click handler, call it
|
||||||
return this.$('ul li').on('click', function(e) {
|
if (this.clicked) {
|
||||||
|
var dropDownButtonView = this;
|
||||||
|
this.$('ul li').on('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
_this.clicked($(e.currentTarget).data('id'));
|
dropDownButtonView.clicked($(e.currentTarget).data('id'));
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
clicked: function(id) {
|
willDestroyElement: function(e) {
|
||||||
return null;
|
this.$('ul li').off('click');
|
||||||
},
|
},
|
||||||
|
|
||||||
textChanged: function() {
|
textChanged: function() {
|
||||||
|
@ -28,24 +31,27 @@ Discourse.DropdownButtonView = Discourse.View.extend({
|
||||||
}.observes('text', 'longDescription'),
|
}.observes('text', 'longDescription'),
|
||||||
|
|
||||||
render: function(buffer) {
|
render: function(buffer) {
|
||||||
var desc;
|
|
||||||
buffer.push("<h4 class='title'>" + this.get('title') + "</h4>");
|
buffer.push("<h4 class='title'>" + this.get('title') + "</h4>");
|
||||||
buffer.push("<button class='btn standard dropdown-toggle' data-toggle='dropdown'>");
|
buffer.push("<button class='btn standard dropdown-toggle' data-toggle='dropdown'>");
|
||||||
buffer.push(this.get('text'));
|
buffer.push(this.get('text'));
|
||||||
buffer.push("</button>");
|
buffer.push("</button>");
|
||||||
buffer.push("<ul class='dropdown-menu'>");
|
buffer.push("<ul class='dropdown-menu'>");
|
||||||
|
|
||||||
this.get('dropDownContent').each(function(row) {
|
this.get('dropDownContent').each(function(row) {
|
||||||
var id = row[0],
|
var id = row[0],
|
||||||
textKey = row[1],
|
textKey = row[1],
|
||||||
title = Em.String.i18n("" + textKey + ".title"),
|
title = Em.String.i18n(textKey + ".title"),
|
||||||
description = Em.String.i18n("" + textKey + ".description");
|
description = Em.String.i18n(textKey + ".description");
|
||||||
|
|
||||||
buffer.push("<li data-id=\"" + id + "\"><a href='#'>");
|
buffer.push("<li data-id=\"" + id + "\"><a href='#'>");
|
||||||
buffer.push("<span class='title'>" + title + "</span>");
|
buffer.push("<span class='title'>" + title + "</span>");
|
||||||
buffer.push("<span>" + description + "</span>");
|
buffer.push("<span>" + description + "</span>");
|
||||||
buffer.push("</a></li>");
|
buffer.push("</a></li>");
|
||||||
});
|
});
|
||||||
buffer.push("</ul>");
|
buffer.push("</ul>");
|
||||||
if (desc = this.get('longDescription')) {
|
|
||||||
|
var desc = this.get('longDescription');
|
||||||
|
if (desc) {
|
||||||
buffer.push("<p>");
|
buffer.push("<p>");
|
||||||
buffer.push(desc);
|
buffer.push(desc);
|
||||||
buffer.push("</p>");
|
buffer.push("</p>");
|
|
@ -0,0 +1,27 @@
|
||||||
|
/**
|
||||||
|
A button for favoriting a topic
|
||||||
|
|
||||||
|
@class FavoriteButton
|
||||||
|
@extends Discourse.ButtonView
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
|
Discourse.FavoriteButton = Discourse.ButtonView.extend({
|
||||||
|
textKey: 'favorite.title',
|
||||||
|
helpKeyBinding: 'controller.content.favoriteTooltipKey',
|
||||||
|
|
||||||
|
favoriteChanged: function() {
|
||||||
|
this.rerender();
|
||||||
|
}.observes('controller.content.starred'),
|
||||||
|
|
||||||
|
click: function() {
|
||||||
|
this.get('controller').toggleStar();
|
||||||
|
},
|
||||||
|
|
||||||
|
renderIcon: function(buffer) {
|
||||||
|
buffer.push("<i class='icon-star " +
|
||||||
|
(this.get('controller.content.starred') ? ' starred' : '') +
|
||||||
|
"'></i>");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
/**
|
||||||
|
A button for inviting users to reply to a topic
|
||||||
|
|
||||||
|
@class InviteReplyButton
|
||||||
|
@extends Discourse.ButtonView
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
|
Discourse.InviteReplyButton = Discourse.ButtonView.extend({
|
||||||
|
textKey: 'topic.invite_reply.title',
|
||||||
|
helpKey: 'topic.invite_reply.help',
|
||||||
|
attributeBindings: ['disabled'],
|
||||||
|
disabled: Em.computed.or('controller.content.archived', 'controller.content.closed'),
|
||||||
|
|
||||||
|
renderIcon: function(buffer) {
|
||||||
|
buffer.push("<i class='icon icon-group'></i>");
|
||||||
|
},
|
||||||
|
|
||||||
|
click: function() {
|
||||||
|
return this.get('controller').send('showInvite');
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,15 @@
|
||||||
|
/**
|
||||||
|
A button prompting users to login to reply to a topic
|
||||||
|
|
||||||
|
@class LoginReplyButton
|
||||||
|
@extends Discourse.ButtonView
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
|
Discourse.LoginReplyButton = Discourse.ButtonView.extend({
|
||||||
|
textKey: 'topic.login_reply',
|
||||||
|
classNames: ['btn', 'btn-primary', 'create'],
|
||||||
|
click: function() {
|
||||||
|
this.get('controller').send('showLogin');
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,46 @@
|
||||||
|
/**
|
||||||
|
A button for favoriting a topic
|
||||||
|
|
||||||
|
@class NotificationsButton
|
||||||
|
@extends Discourse.DropdownButtonView
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
|
Discourse.NotificationsButton = Discourse.DropdownButtonView.extend({
|
||||||
|
title: Em.String.i18n('topic.notifications.title'),
|
||||||
|
longDescriptionBinding: 'topic.notificationReasonText',
|
||||||
|
|
||||||
|
dropDownContent: [
|
||||||
|
[Discourse.Topic.NotificationLevel.WATCHING, 'topic.notifications.watching'],
|
||||||
|
[Discourse.Topic.NotificationLevel.TRACKING, 'topic.notifications.tracking'],
|
||||||
|
[Discourse.Topic.NotificationLevel.REGULAR, 'topic.notifications.regular'],
|
||||||
|
[Discourse.Topic.NotificationLevel.MUTE, 'topic.notifications.muted']
|
||||||
|
],
|
||||||
|
|
||||||
|
text: function() {
|
||||||
|
var key = (function() {
|
||||||
|
switch (this.get('topic.notification_level')) {
|
||||||
|
case Discourse.Topic.NotificationLevel.WATCHING: return 'watching';
|
||||||
|
case Discourse.Topic.NotificationLevel.TRACKING: return 'tracking';
|
||||||
|
case Discourse.Topic.NotificationLevel.REGULAR: return 'regular';
|
||||||
|
case Discourse.Topic.NotificationLevel.MUTE: return 'muted';
|
||||||
|
}
|
||||||
|
}).call(this);
|
||||||
|
|
||||||
|
var icon = (function() {
|
||||||
|
switch (key) {
|
||||||
|
case 'watching': return '<i class="icon-circle heatmap-high"></i> ';
|
||||||
|
case 'tracking': return '<i class="icon-circle heatmap-low"></i> ';
|
||||||
|
case 'regular': return '';
|
||||||
|
case 'muted': return '<i class="icon-remove-sign"></i> ';
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
return icon + (Ember.String.i18n("topic.notifications." + key + ".title")) + "<span class='caret'></span>";
|
||||||
|
}.property('topic.notification_level'),
|
||||||
|
|
||||||
|
clicked: function(id) {
|
||||||
|
return this.get('topic').updateNotifications(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
/**
|
||||||
|
A button for replying to a topic
|
||||||
|
|
||||||
|
@class ReplyButton
|
||||||
|
@extends Discourse.ButtonView
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
|
Discourse.ReplyButton = Discourse.ButtonView.extend({
|
||||||
|
classNames: ['btn', 'btn-primary', 'create'],
|
||||||
|
attributeBindings: ['disabled'],
|
||||||
|
helpKey: 'topic.reply.help',
|
||||||
|
disabled: Em.computed.not('controller.content.can_create_post'),
|
||||||
|
|
||||||
|
text: function() {
|
||||||
|
var archetypeCapitalized = this.get('controller.content.archetype').capitalize();
|
||||||
|
var customTitle = this.get("parentView.replyButtonText" + archetypeCapitalized);
|
||||||
|
if (customTitle) { return customTitle; }
|
||||||
|
|
||||||
|
return Em.String.i18n("topic.reply.title");
|
||||||
|
}.property(),
|
||||||
|
|
||||||
|
renderIcon: function(buffer) {
|
||||||
|
buffer.push("<i class='icon icon-plus'></i>");
|
||||||
|
},
|
||||||
|
|
||||||
|
click: function() {
|
||||||
|
this.get('controller').reply();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
/**
|
||||||
|
A button for sharing a link to a topic
|
||||||
|
|
||||||
|
@class ShareButton
|
||||||
|
@extends Discourse.ButtonView
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
|
Discourse.ShareButton = Discourse.ButtonView.extend({
|
||||||
|
textKey: 'topic.share.title',
|
||||||
|
helpKey: 'topic.share.help',
|
||||||
|
'data-share-url': Em.computed.alias('topic.shareUrl'),
|
||||||
|
|
||||||
|
renderIcon: function(buffer) {
|
||||||
|
buffer.push("<i class='icon icon-share'></i>");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
/**
|
||||||
|
Our own containerView with a helper method for attaching views
|
||||||
|
|
||||||
|
@class ContainerView
|
||||||
|
@extends Ember.ContainerView
|
||||||
|
@namespace Discourse
|
||||||
|
@uses Discourse.Presence
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
|
Discourse.ContainerView = Ember.ContainerView.extend(Discourse.Presence, {
|
||||||
|
|
||||||
|
/**
|
||||||
|
Attaches a view and wires up the container properly
|
||||||
|
|
||||||
|
@method attachViewWithArgs
|
||||||
|
@param {Object} viewArgs The arguments to pass when creating the view
|
||||||
|
@param {Class} klass The view class we want to create
|
||||||
|
@return {Ember.View} the view we created
|
||||||
|
**/
|
||||||
|
attachViewWithArgs: function(viewArgs, viewClass) {
|
||||||
|
if (!viewClass) { viewClass = Ember.View.extend() };
|
||||||
|
var view = this.createChildView(viewClass, viewArgs);
|
||||||
|
this.pushObject(view);
|
||||||
|
return view;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
Attaches a view with no arguments and wires up the container properly
|
||||||
|
|
||||||
|
@method attachViewClass
|
||||||
|
@param {Class} klass The view class we want to create
|
||||||
|
@return {Ember.View} the view we created
|
||||||
|
**/
|
||||||
|
attachViewClass: function(viewClass) {
|
||||||
|
this.attachViewWithArgs(null, viewClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
|
@ -2,26 +2,23 @@
|
||||||
This view handles the rendering of an archetype as an option
|
This view handles the rendering of an archetype as an option
|
||||||
|
|
||||||
@class ArchetypeOptionsView
|
@class ArchetypeOptionsView
|
||||||
@extends Discourse.View
|
@extends Discourse.ContainerView
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.ArchetypeOptionsView = Em.ContainerView.extend({
|
Discourse.ArchetypeOptionsView = Discourse.ContainerView.extend({
|
||||||
metaDataBinding: 'parentView.metaData',
|
metaDataBinding: 'parentView.metaData',
|
||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
var metaData,
|
|
||||||
_this = this;
|
|
||||||
this._super();
|
this._super();
|
||||||
metaData = this.get('metaData');
|
var metaData = this.get('metaData');
|
||||||
|
var archetypeOptionsView = this;
|
||||||
return this.get('archetype.options').forEach(function(a) {
|
return this.get('archetype.options').forEach(function(a) {
|
||||||
var checked;
|
|
||||||
|
|
||||||
if (a.option_type === 1) {
|
if (a.option_type === 1) {
|
||||||
checked = _this.pushObject(Discourse.OptionBooleanView.create({
|
archetypeOptionsView.attachViewWithArgs({
|
||||||
content: a,
|
content: a,
|
||||||
checked: metaData.get(a.key) === 'true'
|
checked: metaData.get(a.key) === 'true'
|
||||||
}));
|
}, Discourse.OptionBooleanView);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
This view shows an array of buttons for selection of a color from a predefined set.
|
This view shows an array of buttons for selection of a color from a predefined set.
|
||||||
|
|
||||||
@class ColorPickerView
|
@class ColorPickerView
|
||||||
@extends Ember.ContainerView
|
@extends Discourse.ContainerView
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.ColorPickerView = Ember.ContainerView.extend({
|
Discourse.ColorPickerView = Discourse.ContainerView.extend({
|
||||||
classNames: 'colors-container',
|
classNames: 'colors-container',
|
||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
|
@ -16,24 +16,26 @@ Discourse.ColorPickerView = Ember.ContainerView.extend({
|
||||||
|
|
||||||
createButtons: function() {
|
createButtons: function() {
|
||||||
var colors = this.get('colors');
|
var colors = this.get('colors');
|
||||||
var _this = this;
|
var colorPickerView = this;
|
||||||
var isUsed, usedColors = this.get('usedColors') || [];
|
var isUsed, usedColors = this.get('usedColors') || [];
|
||||||
|
|
||||||
if (!colors) return;
|
if (!colors) return;
|
||||||
|
|
||||||
colors.each(function(color) {
|
colors.forEach(function(color) {
|
||||||
isUsed = usedColors.indexOf(color.toUpperCase()) >= 0;
|
isUsed = usedColors.indexOf(color.toUpperCase()) >= 0;
|
||||||
_this.addObject(Discourse.View.create({
|
|
||||||
|
colorPickerView.attachViewWithArgs({
|
||||||
tagName: 'button',
|
tagName: 'button',
|
||||||
attributeBindings: ['style', 'title'],
|
attributeBindings: ['style', 'title'],
|
||||||
classNames: ['colorpicker'].concat( isUsed ? ['used-color'] : ['unused-color'] ),
|
classNames: ['colorpicker'].concat( isUsed ? ['used-color'] : ['unused-color'] ),
|
||||||
style: 'background-color: #' + color + ';',
|
style: 'background-color: #' + color + ';',
|
||||||
title: isUsed ? I18n.t("js.category.already_used") : null,
|
title: isUsed ? I18n.t("js.category.already_used") : null,
|
||||||
click: function() {
|
click: function() {
|
||||||
_this.set("value", color);
|
colorPickerView.set("value", color);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
A base class for helping us display modal content
|
A base class for helping us display modal content
|
||||||
|
|
||||||
@class ModalView
|
@class ModalView
|
||||||
@extends Ember.ContainerView
|
@extends Discourse.View
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
A control to support using PageDown as an Ember view.
|
A control to support using PageDown as an Ember view.
|
||||||
|
|
||||||
@class PagedownEditor
|
@class PagedownEditor
|
||||||
@extends Ember.ContainerView
|
@extends Discourse.ContainerView
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.PagedownEditor = Ember.ContainerView.extend({
|
Discourse.PagedownEditor = Discourse.ContainerView.extend({
|
||||||
elementId: 'pagedown-editor',
|
elementId: 'pagedown-editor',
|
||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
|
@ -20,28 +20,35 @@ Discourse.PagedownEditor = Ember.ContainerView.extend({
|
||||||
this.pushObject(Em.View.create({ elementId: 'wmd-button-bar' }));
|
this.pushObject(Em.View.create({ elementId: 'wmd-button-bar' }));
|
||||||
this.pushObject(Em.TextArea.create({ valueBinding: 'parentView.value', elementId: 'wmd-input' }));
|
this.pushObject(Em.TextArea.create({ valueBinding: 'parentView.value', elementId: 'wmd-input' }));
|
||||||
|
|
||||||
this.pushObject(Discourse.View.createWithMixins({
|
this.attachViewClass(Discourse.PagedownPreviewView);
|
||||||
elementId: 'wmd-preview',
|
|
||||||
classNameBindings: [':preview', 'hidden'],
|
|
||||||
hidden: (function() {
|
|
||||||
return this.blank('parentView.value');
|
|
||||||
}).property('parentView.value')
|
|
||||||
}));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
didInsertElement: function() {
|
didInsertElement: function() {
|
||||||
var $wmdInput = $('#wmd-input');
|
$('#wmd-input').data('init', true);
|
||||||
$wmdInput.data('init', true);
|
|
||||||
this.set('editor', Discourse.Markdown.createEditor());
|
this.set('editor', Discourse.Markdown.createEditor());
|
||||||
return this.get('editor').run();
|
return this.get('editor').run();
|
||||||
},
|
},
|
||||||
|
|
||||||
observeValue: (function() {
|
observeValue: function() {
|
||||||
var editor = this.get('editor');
|
var editor = this.get('editor');
|
||||||
if (!editor) return;
|
if (!editor) return;
|
||||||
Ember.run.next(null, function() { editor.refreshPreview(); });
|
Ember.run.next(null, function() { editor.refreshPreview(); });
|
||||||
}).observes('value')
|
}.observes('value')
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Discourse.View.registerHelper('pagedown', Discourse.PagedownEditor);
|
Discourse.View.registerHelper('pagedown', Discourse.PagedownEditor);
|
||||||
|
|
||||||
|
/**
|
||||||
|
A helper view to display a preview of the pagedown content
|
||||||
|
|
||||||
|
@class PagedownPreviewView
|
||||||
|
@extends Discourse.View
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
|
Discourse.PagedownPreviewView = Discourse.View.extend({
|
||||||
|
elementId: 'wmd-preview',
|
||||||
|
classNameBindings: [':preview', 'hidden'],
|
||||||
|
hidden: Em.computed.empty('parentView.value')
|
||||||
|
});
|
|
@ -4,7 +4,7 @@
|
||||||
A control to support embedding a post as a parent of the current post (in reply to)
|
A control to support embedding a post as a parent of the current post (in reply to)
|
||||||
|
|
||||||
@class ParentView
|
@class ParentView
|
||||||
@extends Ember.ContainerView
|
@extends Discourse.EmbeddedPostView
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
|
@ -13,9 +13,9 @@ Discourse.ParentView = Discourse.EmbeddedPostView.extend({
|
||||||
|
|
||||||
// Nice animation for when the replies appear
|
// Nice animation for when the replies appear
|
||||||
didInsertElement: function() {
|
didInsertElement: function() {
|
||||||
var $parentPost;
|
|
||||||
this._super();
|
this._super();
|
||||||
$parentPost = this.get('postView').$('section.parent-post');
|
|
||||||
|
var $parentPost = this.get('postView').$('section.parent-post');
|
||||||
|
|
||||||
// Animate unless we're on a touch device
|
// Animate unless we're on a touch device
|
||||||
if (Discourse.get('touch')) {
|
if (Discourse.get('touch')) {
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
This view allows us to prepend content to a post (for use in plugins)
|
This view allows us to prepend content to a post (for use in plugins)
|
||||||
|
|
||||||
@class PrependPostView
|
@class PrependPostView
|
||||||
@extends Discourse.View
|
@extends Discourse.ContainerView
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.PrependPostView = Em.ContainerView.extend({
|
Discourse.PrependPostView = Discourse.ContainerView.extend({
|
||||||
init: function() {
|
init: function() {
|
||||||
this._super();
|
this._super();
|
||||||
return this.trigger('prependPostContent');
|
return this.trigger('prependPostContent');
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
automatically close.
|
automatically close.
|
||||||
|
|
||||||
@class TopicClosingView
|
@class TopicClosingView
|
||||||
@extends Ember.ContainerView
|
@extends Discourse.View
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
|
|
|
@ -2,177 +2,42 @@
|
||||||
This view is used for rendering the buttons at the footer of the topic
|
This view is used for rendering the buttons at the footer of the topic
|
||||||
|
|
||||||
@class TopicFooterButtonsView
|
@class TopicFooterButtonsView
|
||||||
@extends Ember.ContainerView
|
@extends Discourse.ContainerView
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.TopicFooterButtonsView = Ember.ContainerView.extend({
|
Discourse.TopicFooterButtonsView = Discourse.ContainerView.extend({
|
||||||
elementId: 'topic-footer-buttons',
|
elementId: 'topic-footer-buttons',
|
||||||
topicBinding: 'controller.content',
|
topicBinding: 'controller.content',
|
||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
this._super();
|
this._super();
|
||||||
return this.createButtons();
|
this.createButtons();
|
||||||
},
|
},
|
||||||
|
|
||||||
// Add the buttons below a topic
|
// Add the buttons below a topic
|
||||||
createButtons: function() {
|
createButtons: function() {
|
||||||
var topic;
|
var topic = this.get('topic');
|
||||||
topic = this.get('topic');
|
|
||||||
if (Discourse.User.current()) {
|
if (Discourse.User.current()) {
|
||||||
if (!topic.get('isPrivateMessage')) {
|
if (!topic.get('isPrivateMessage')) {
|
||||||
|
|
||||||
// We hide some controls from private messages
|
// We hide some controls from private messages
|
||||||
if (this.get('topic.can_invite_to')) {
|
if (this.get('topic.can_invite_to')) {
|
||||||
this.addObject(Discourse.ButtonView.createWithMixins({
|
this.attachViewClass(Discourse.InviteReplyButton);
|
||||||
textKey: 'topic.invite_reply.title',
|
|
||||||
helpKey: 'topic.invite_reply.help',
|
|
||||||
attributeBindings: ['disabled'],
|
|
||||||
|
|
||||||
disabled: function(){
|
|
||||||
return this.get('controller.content.archived') || this.get('controller.content.closed');
|
|
||||||
}.property('controller.content.archived', 'controller.content.closed'),
|
|
||||||
|
|
||||||
renderIcon: function(buffer) {
|
|
||||||
buffer.push("<i class='icon icon-group'></i>");
|
|
||||||
},
|
|
||||||
|
|
||||||
click: function() {
|
|
||||||
return this.get('controller').send('showInvite');
|
|
||||||
}
|
}
|
||||||
}));
|
this.attachViewClass(Discourse.FavoriteButton);
|
||||||
|
this.attachViewWithArgs({topic: topic}, Discourse.ShareButton);
|
||||||
|
this.attachViewClass(Discourse.ClearPinButton);
|
||||||
}
|
}
|
||||||
|
this.attachViewClass(Discourse.ReplyButton);
|
||||||
this.addObject(Discourse.ButtonView.createWithMixins({
|
|
||||||
textKey: 'favorite.title',
|
|
||||||
helpKeyBinding: 'controller.content.favoriteTooltipKey',
|
|
||||||
|
|
||||||
favoriteChanged: (function() {
|
|
||||||
this.rerender();
|
|
||||||
}).observes('controller.content.starred'),
|
|
||||||
|
|
||||||
click: function() {
|
|
||||||
this.get('controller').toggleStar();
|
|
||||||
},
|
|
||||||
|
|
||||||
renderIcon: function(buffer) {
|
|
||||||
var extraClass;
|
|
||||||
if (this.get('controller.content.starred')) {
|
|
||||||
extraClass = 'starred';
|
|
||||||
}
|
|
||||||
return buffer.push("<i class='icon-star " + extraClass + "'></i>");
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
this.addObject(Discourse.ButtonView.create({
|
|
||||||
textKey: 'topic.share.title',
|
|
||||||
helpKey: 'topic.share.help',
|
|
||||||
'data-share-url': topic.get('shareUrl'),
|
|
||||||
|
|
||||||
renderIcon: function(buffer) {
|
|
||||||
buffer.push("<i class='icon icon-share'></i>");
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Add our clear pin button
|
|
||||||
this.addObject(Discourse.ButtonView.createWithMixins({
|
|
||||||
textKey: 'topic.clear_pin.title',
|
|
||||||
helpKey: 'topic.clear_pin.help',
|
|
||||||
classNameBindings: ['unpinned'],
|
|
||||||
|
|
||||||
// Hide the button if it becomes unpinned
|
|
||||||
unpinned: function() {
|
|
||||||
// When not logged in don't show the button
|
|
||||||
if (!Discourse.User.current()) return 'hidden'
|
|
||||||
|
|
||||||
return this.get('controller.pinned') ? null : 'hidden';
|
|
||||||
}.property('controller.pinned'),
|
|
||||||
|
|
||||||
click: function(buffer) {
|
|
||||||
this.get('controller').clearPin();
|
|
||||||
},
|
|
||||||
|
|
||||||
renderIcon: function(buffer) {
|
|
||||||
buffer.push("<i class='icon icon-pushpin'></i>");
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
this.addObject(Discourse.ButtonView.createWithMixins({
|
|
||||||
classNames: ['btn', 'btn-primary', 'create'],
|
|
||||||
attributeBindings: ['disabled'],
|
|
||||||
helpKey: 'topic.reply.help',
|
|
||||||
disabled: !this.get('controller.content.can_create_post'),
|
|
||||||
|
|
||||||
text: function() {
|
|
||||||
var archetype, customTitle;
|
|
||||||
archetype = this.get('controller.content.archetype');
|
|
||||||
if (customTitle = this.get("parentView.replyButtonText" + (archetype.capitalize()))) {
|
|
||||||
return customTitle;
|
|
||||||
}
|
|
||||||
return Em.String.i18n("topic.reply.title");
|
|
||||||
}.property(),
|
|
||||||
|
|
||||||
renderIcon: function(buffer) {
|
|
||||||
buffer.push("<i class='icon icon-plus'></i>");
|
|
||||||
},
|
|
||||||
|
|
||||||
click: function() {
|
|
||||||
this.get('controller').reply();
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
if (!topic.get('isPrivateMessage')) {
|
if (!topic.get('isPrivateMessage')) {
|
||||||
this.addObject(Discourse.DropdownButtonView.createWithMixins({
|
this.attachViewWithArgs({topic: topic}, Discourse.NotificationsButton);
|
||||||
topic: topic,
|
|
||||||
title: Em.String.i18n('topic.notifications.title'),
|
|
||||||
longDescriptionBinding: 'topic.notificationReasonText',
|
|
||||||
dropDownContent: [
|
|
||||||
[Discourse.Topic.NotificationLevel.WATCHING, 'topic.notifications.watching'],
|
|
||||||
[Discourse.Topic.NotificationLevel.TRACKING, 'topic.notifications.tracking'],
|
|
||||||
[Discourse.Topic.NotificationLevel.REGULAR, 'topic.notifications.regular'],
|
|
||||||
[Discourse.Topic.NotificationLevel.MUTE, 'topic.notifications.muted']
|
|
||||||
],
|
|
||||||
|
|
||||||
text: function() {
|
|
||||||
var key = (function() {
|
|
||||||
switch (this.get('topic.notification_level')) {
|
|
||||||
case Discourse.Topic.NotificationLevel.WATCHING: return 'watching';
|
|
||||||
case Discourse.Topic.NotificationLevel.TRACKING: return 'tracking';
|
|
||||||
case Discourse.Topic.NotificationLevel.REGULAR: return 'regular';
|
|
||||||
case Discourse.Topic.NotificationLevel.MUTE: return 'muted';
|
|
||||||
}
|
}
|
||||||
}).call(this);
|
this.trigger('additionalButtons', this);
|
||||||
|
|
||||||
var icon = (function() {
|
|
||||||
switch (key) {
|
|
||||||
case 'watching': return '<i class="icon-circle heatmap-high"></i> ';
|
|
||||||
case 'tracking': return '<i class="icon-circle heatmap-low"></i> ';
|
|
||||||
case 'regular': return '';
|
|
||||||
case 'muted': return '<i class="icon-remove-sign"></i> ';
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
return icon + (Ember.String.i18n("topic.notifications." + key + ".title")) + "<span class='caret'></span>";
|
|
||||||
}.property('topic.notification_level'),
|
|
||||||
|
|
||||||
clicked: function(id) {
|
|
||||||
return this.get('topic').updateNotifications(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
return this.trigger('additionalButtons', this);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// If not logged in give them a login control
|
// If not logged in give them a login control
|
||||||
return this.addObject(Discourse.ButtonView.create({
|
this.attachViewClass(Discourse.LoginReplyButton);
|
||||||
textKey: 'topic.login_reply',
|
|
||||||
classNames: ['btn', 'btn-primary', 'create'],
|
|
||||||
click: function() {
|
|
||||||
this.get('controller').send('showLogin');
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.TopicSummaryView = Ember.ContainerView.extend(Discourse.Presence, {
|
Discourse.TopicSummaryView = Discourse.ContainerView.extend({
|
||||||
topicBinding: 'controller.content',
|
topicBinding: 'controller.content',
|
||||||
classNameBindings: ['hidden', ':topic-summary'],
|
classNameBindings: ['hidden', ':topic-summary'],
|
||||||
LINKS_SHOWN: 5,
|
LINKS_SHOWN: 5,
|
||||||
|
@ -42,11 +42,12 @@ Discourse.TopicSummaryView = Ember.ContainerView.extend(Discourse.Presence, {
|
||||||
this._super();
|
this._super();
|
||||||
if (this.get('hidden')) return;
|
if (this.get('hidden')) return;
|
||||||
|
|
||||||
this.pushObject(Em.View.create({
|
this.attachViewWithArgs({
|
||||||
templateName: 'topic_summary/info',
|
templateName: 'topic_summary/info',
|
||||||
topic: this.get('topic'),
|
topic: this.get('topic'),
|
||||||
summaryView: this
|
summaryView: this
|
||||||
}));
|
})
|
||||||
|
|
||||||
this.trigger('appendSummaryInformation', this);
|
this.trigger('appendSummaryInformation', this);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -58,20 +59,20 @@ Discourse.TopicSummaryView = Ember.ContainerView.extend(Discourse.Presence, {
|
||||||
|
|
||||||
// If we have a best of view
|
// If we have a best of view
|
||||||
if (this.get('controller.has_best_of')) {
|
if (this.get('controller.has_best_of')) {
|
||||||
container.pushObject(Em.View.create({
|
container.attachViewWithArgs({
|
||||||
templateName: 'topic_summary/best_of_toggle',
|
templateName: 'topic_summary/best_of_toggle',
|
||||||
tagName: 'section',
|
tagName: 'section',
|
||||||
classNames: ['information']
|
classNames: ['information']
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have a private message
|
// If we have a private message
|
||||||
if (this.get('topic.isPrivateMessage')) {
|
if (this.get('topic.isPrivateMessage')) {
|
||||||
return container.pushObject(Em.View.create({
|
container.attachViewWithArgs({
|
||||||
templateName: 'topic_summary/private_message',
|
templateName: 'topic_summary/private_message',
|
||||||
tagName: 'section',
|
tagName: 'section',
|
||||||
classNames: ['information']
|
classNames: ['information']
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
**/
|
**/
|
||||||
Discourse.View = Ember.View.extend(Discourse.Presence, {});
|
Discourse.View = Ember.View.extend(Discourse.Presence, {});
|
||||||
|
|
||||||
|
|
||||||
Discourse.View.reopenClass({
|
Discourse.View.reopenClass({
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
//= require ./discourse/controllers/object_controller
|
//= require ./discourse/controllers/object_controller
|
||||||
//= require ./discourse/views/modal/modal_body_view
|
//= require ./discourse/views/modal/modal_body_view
|
||||||
//= require ./discourse/views/combobox_view
|
//= require ./discourse/views/combobox_view
|
||||||
|
//= require ./discourse/views/buttons/button_view
|
||||||
|
//= require ./discourse/views/buttons/dropdown_button_view
|
||||||
//= require ./discourse/models/model
|
//= require ./discourse/models/model
|
||||||
//= require ./discourse/routes/discourse_route
|
//= require ./discourse/routes/discourse_route
|
||||||
//= require ./discourse/routes/discourse_restricted_user_route
|
//= require ./discourse/routes/discourse_restricted_user_route
|
||||||
|
|
Loading…
Reference in New Issue