Upgrade Ember to RC5. Disabled a deprecation warning that I believe is in error.

This commit is contained in:
Robin Ward 2013-06-05 11:01:20 -04:00
parent 67ba33dee5
commit a0bd51862e
23 changed files with 7205 additions and 4791 deletions

View file

@ -6,7 +6,7 @@
@namespace Discourse
@module Discourse
**/
Discourse.AdminSiteContentEditController = Discourse.ObjectController.extend({
Discourse.AdminSiteContentEditController = Discourse.Controller.extend({
saveDisabled: function() {
if (this.get('saving')) return true;

View file

@ -27,7 +27,11 @@ Discourse.AdminSiteContentEditRoute = Discourse.Route.extend({
setupController: function(controller, model) {
controller.set('loaded', false);
controller.setProperties({saving: false, saved: false});
controller.setProperties({
model: model,
saving: false,
saved: false
});
Discourse.SiteContent.find(Em.get(model, 'content_type')).then(function (sc) {
controller.set('content', sc);

View file

@ -12,7 +12,8 @@ Discourse.AdminSiteContentsRoute = Discourse.Route.extend({
return Discourse.SiteContentType.findAll();
},
renderTemplate: function() {
renderTemplate: function(controller, model) {
controller.set('model', model);
this.render('admin/templates/site_contents', {into: 'admin/templates/admin'});
this.render('admin/templates/site_contents_empty', {into: 'admin/templates/site_contents'});
}

View file

@ -1,20 +1,20 @@
{{#if loaded}}
<h3>{{title}}</h3>
<p class='description'>{{description}}</p>
<h3>{{model.title}}</h3>
<p class='description'>{{model.description}}</p>
{{#if markdown}}
{{#if model.markdown}}
{{pagedown value=model.content}}
{{/if}}
{{#if plainText}}
{{#if model.plainText}}
{{textarea value=model.content class="plain"}}
{{/if}}
{{#if html}}
{{#if model.html}}
{{aceEditor content=model.content mode="html"}}
{{/if}}
{{#if css}}
{{#if model.css}}
{{aceEditor content=model.content mode="css"}}
{{/if}}

View file

@ -12,7 +12,7 @@
// Externals we need to load first
//= require ./external/jquery-1.8.3.js
//= require ./external/jquery.ui.widget.js
//= require ./external/handlebars-1.0.rc.3.js
//= require ./external/handlebars-1.0.rc.4.js
<%
if Rails.env.development?
require_asset ("./external_development/ember.js")

View file

@ -72,7 +72,7 @@ Discourse.Development = {
});
};
Ember.View.prototype.renderToBuffer = window.probes.measure(Ember.View.prototype.renderToBuffer, "renderToBuffer");
//Ember.View.prototype.renderToBuffer = window.probes.measure(Ember.View.prototype.renderToBuffer, "renderToBuffer");
Discourse.URL.routeTo = topLevel(Discourse.URL.routeTo, "Discourse.URL.routeTo");
Ember.run.end = topLevel(Ember.run.end, "Ember.run.end");
},

View file

@ -18,7 +18,11 @@ Discourse.HeaderController = Discourse.Controller.extend({
categories: function() {
return Discourse.Category.list();
}.property()
}.property(),
showFavoriteButton: function() {
return Discourse.User.current() && !this.get('topic.isPrivateMessage');
}.property('topic.isPrivateMessage')
});

View file

@ -11,18 +11,15 @@ Discourse.ListCategoriesRoute = Discourse.Route.extend({
redirect: function() { Discourse.redirectIfLoginRequired(this); },
events: {
createCategory: function() {
Discourse.Route.showModal(this, 'editCategory', Discourse.Category.create({ color: 'AB9364', text_color: 'FFFFFF', hotness: 5 }));
this.controllerFor('editCategory').set('selectedTab', 'general');
}
},
model: function() {
var listTopicsController = this.controllerFor('listTopics');
if (listTopicsController) listTopicsController.set('content', null);
return this.controllerFor('list').load('categories');
},
@ -33,6 +30,7 @@ Discourse.ListCategoriesRoute = Discourse.Route.extend({
setupController: function(controller, categoryList) {
this.render('listCategories', { into: 'list', outlet: 'listView' });
controller.set('model', categoryList);
this.controllerFor('list').setProperties({
canCreateCategory: categoryList.get('can_create_category'),

View file

@ -98,6 +98,7 @@ Discourse.TopicRoute = Discourse.Route.extend({
},
setupController: function(controller, model) {
controller.set('model', model);
this.controllerFor('header').set('topic', model);
this.controllerFor('composer').set('topic', model);
}

View file

@ -18,6 +18,7 @@ Discourse.UserPrivateMessagesRoute = Discourse.RestrictedUserRoute.extend({
setupController: function(controller, stream) {
var composerController = this.controllerFor('composer');
controller.set('model', stream);
Discourse.Draft.get('new_private_message').then(function(data) {
if (data.draft) {
composerController.open({

View file

@ -13,11 +13,13 @@ Discourse.UserRoute = Discourse.Route.extend({
},
serialize: function(params) {
if (!params) return {};
return { username: Em.get(params, 'username').toLowerCase() };
},
setupController: function(controller, user) {
user.findDetails();
controller.set('model', user);
// Add a search context
this.controllerFor('search').set('searchContext', user.get('searchContext'));

View file

@ -2,7 +2,30 @@
<div class='contents clearfix'>
{{view.logoHTML}}
{{view Discourse.TopicExtraInfoView}}
{{#if showExtraInfo}}
<div class="extra-info-wrapper">
<div class="extra-info">
{{#if showFavoriteButton}}
<a {{bindAttr class=":star topic.starred:starred"}} {{action toggleStar}} href='#' {{bindAttr title="topic.favoriteTooltip"}}></a>
{{/if}}
<h1>
{{#if topic.fancy_title}}
{{topicStatus topic=topic}}
<a class='topic-link' href='{{unbound topic.url}}'>{{{topic.fancy_title}}}</a>
{{else}}
{{#if topic.errorLoading}}
{{topic.errorTitle}}
{{else}}
{{i18n topic.loading}}
{{/if}}
{{/if}}
{{categoryLink topic.category}}
</h1>
</div>
</div>
{{/if}}
<div class='panel clearfix'>
{{#unless showExtraInfo}}

View file

@ -1,19 +0,0 @@
{{#if view.showFavoriteButton}}
<a {{bindAttr class=":star view.topic.starred:starred"}} {{action toggleStar}} href='#' {{bindAttr title="view.topic.favoriteTooltip"}}></a>
{{/if}}
<h1>
{{#if view.topic.fancy_title}}
{{topicStatus topic=view.topic}}
<a class='topic-link' href='{{unbound view.topic.url}}'>{{{view.topic.fancy_title}}}</a>
{{else}}
{{#if view.topic.errorLoading}}
{{topic.errorTitle}}
{{else}}
{{i18n topic.loading}}
{{/if}}
{{/if}}
{{#if view.topic.category}}
{{categoryLink view.topic.category}}
{{/if}}
</h1>

View file

@ -1,12 +1,12 @@
<nav class='buttons'>
{{#if summaryCollapsed}}
<button class='btn collapsed' {{action toggleSummary}} title="{{i18n topic.toggle_information}}">
<i class='icon icon-chevron-down'></i>
</button>
{{else}}
<button class='btn' {{action toggleSummary}} title="{{i18n topic.toggle_information}}">
<i class='icon icon-chevron-up'></i>
</button>
<button class='btn collapsed' {{action toggleSummary}} title="{{i18n topic.toggle_information}}">
<i class='icon icon-chevron-down'></i>
</button>
{{else}}
<button class='btn' {{action toggleSummary}} title="{{i18n topic.toggle_information}}">
<i class='icon icon-chevron-up'></i>
</button>
{{/if}}
</nav>
@ -17,32 +17,32 @@
<li>
<a {{bindAttr href="url"}}>
<h4>{{i18n created}}</h4>
{{avatar view.topic.created_by imageSize="tiny"}}
{{date view.topic.created_at}}
{{avatar created_by imageSize="tiny"}}
{{date created_at}}
</a>
</li>
<li>
<a {{bindAttr href="lastPostUrl"}}>
<h4>{{i18n last_post}}</h4>
{{avatar view.topic.last_poster imageSize="tiny"}}
{{date view.topic.last_posted_at}}
{{avatar last_poster imageSize="tiny"}}
{{date last_posted_at}}
</a>
</li>
<li>
<h4>{{i18n posts}}</h4>
{{number view.topic.posts_count}}
{{number posts_count}}
</li>
<li>
<h4>{{i18n views}}</h4>
{{number view.topic.views}}
{{number views}}
</li>
<li>
<h4>{{i18n links}}</h4>
{{number view.topic.links.length}}
{{number links.length}}
</li>
{{#if view.topic.fewParticipants}}
{{#if fewParticipants}}
<li class='avatars'>
{{#each view.topic.fewParticipants}}{{participant participant=this}}{{/each}}
{{#each fewParticipants}}{{participant participant=this}}{{/each}}
</li>
{{/if}}
</ul>
@ -53,28 +53,28 @@
<ul class="clearfix">
<li>
<h4>{{i18n created}}</h4>
{{avatar view.topic.created_by imageSize="tiny"}}
<a {{bindAttr href="view.topic.url"}}>{{date view.topic.created_at}}</a>
{{avatar created_by imageSize="tiny"}}
<a {{bindAttr href="url"}}>{{date created_at}}</a>
</li>
<li>
<h4>{{i18n last_post}}</h4>
{{avatar view.topic.last_poster imageSize="tiny"}}
<a {{bindAttr href="view.topic.lastPostUrl"}}>{{date view.topic.last_posted_at}}</a>
{{avatar last_poster imageSize="tiny"}}
<a {{bindAttr href="lastPostUrl"}}>{{date last_posted_at}}</a>
</li>
<li>
<h4>{{i18n posts}}</h4>
{{number view.topic.posts_count}}
{{number posts_count}}
</li>
<li>
<h4>{{i18n views}}</h4>
{{number view.topic.views}}
{{number views}}
</li>
</ul>
</section>
{{#if view.topic.participants}}
{{#if participants}}
<section class='avatars clearfix'>
{{#each view.topic.participants}}{{participant participant=this}}{{/each}}
{{#each participants}}{{participant participant=this}}{{/each}}
</section>
{{/if}}
@ -92,7 +92,7 @@
{{#if view.parentView.showAllLinksControls}}
<div class='link-summary'>
<a href='#' {{action showAllLinks target="view.parentView"}}>{{i18n topic_summary.links_shown totalLinks="view.topic.links.length"}}</a>
<a href='#' {{action showAllLinks target="view.parentView"}}>{{i18n topic_summary.links_shown totalLinks="links.length"}}</a>
</div>
{{/if}}

View file

@ -1,24 +0,0 @@
/**
This view is used for rendering the extra information on a topic in the header
@class TopicExtraInfoView
@extends Discourse.View
@namespace Discourse
@module Discourse
**/
Discourse.TopicExtraInfoView = Ember.ContainerView.extend({
classNameBindings: [':extra-info-wrapper', 'controller.showExtraInfo'],
childViews: ['extraInfo'],
extraInfo: Em.View.createWithMixins({
templateName: 'topic_extra_info',
classNames: ['extra-info'],
topicBinding: 'controller.topic',
showFavoriteButton: function() {
return Discourse.User.current() && !this.get('topic.isPrivateMessage');
}.property('topic.isPrivateMessage')
})
});

View file

@ -12,35 +12,36 @@ Discourse.TopicSummaryView = Ember.ContainerView.extend(Discourse.Presence, {
LINKS_SHOWN: 5,
allLinksShown: false,
showAllLinksControls: (function() {
showAllLinksControls: function() {
if (this.blank('topic.links')) return false;
if (this.get('allLinksShown')) return false;
if (this.get('topic.links.length') <= this.LINKS_SHOWN) return false;
return true;
}).property('allLinksShown', 'topic.links'),
}.property('allLinksShown', 'topic.links'),
infoLinks: (function() {
infoLinks: function() {
if (this.blank('topic.links')) return [];
var allLinks = this.get('topic.links');
if (this.get('allLinksShown')) return allLinks;
return allLinks.slice(0, this.LINKS_SHOWN);
}).property('topic.links', 'allLinksShown'),
}.property('topic.links', 'allLinksShown'),
newPostCreated: (function() {
newPostCreated: function() {
this.rerender();
}).observes('topic.posts_count'),
}.observes('topic.posts_count'),
hidden: (function() {
hidden: function() {
if (this.get('post.post_number') !== 1) return true;
if (this.get('controller.content.archetype') === 'private_message') return false;
if (this.get('controller.content.archetype') !== 'regular') return true;
return this.get('controller.content.posts_count') < 2;
}).property(),
}.property(),
init: function() {
this._super();
if (this.get('hidden')) return;
this.pushObject(Em.View.create({
templateName: 'topic_summary/info',
topic: this.get('topic'),

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -102,12 +102,8 @@
// App header
.extra-info-wrapper {
display: none;
float: left;
margin-left: 10px;
&.show-extra-info {
display: block;
}
}
#multi-select-options {

View file

@ -112,7 +112,7 @@ module Discourse
# ember stuff only used for asset precompliation, production variant plays up
config.ember.variant = :development
config.ember.ember_location = "#{Rails.root}/app/assets/javascripts/external_production/ember.js"
config.ember.handlebars_location = "#{Rails.root}/app/assets/javascripts/external/handlebars-1.0.rc.3.js"
config.ember.handlebars_location = "#{Rails.root}/app/assets/javascripts/external/handlebars-1.0.rc.4.js"
# So open id logs somewhere sane
config.after_initialize do

View file

@ -9,7 +9,7 @@
//= require ../../app/assets/javascripts/external/jquery-1.8.3.js
//= require ../../app/assets/javascripts/external/jquery.ui.widget.js
//= require ../../app/assets/javascripts/external/handlebars-1.0.rc.3.js
//= require ../../app/assets/javascripts/external/handlebars-1.0.rc.4.js
//= require ../../app/assets/javascripts/external_production/ember.js
//= require ../../app/assets/javascripts/external_production/sugar-1.3.5.js
//= require ../../app/assets/javascripts/external_production/group-helper.js