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 @namespace Discourse
@module Discourse @module Discourse
**/ **/
Discourse.AdminSiteContentEditController = Discourse.ObjectController.extend({ Discourse.AdminSiteContentEditController = Discourse.Controller.extend({
saveDisabled: function() { saveDisabled: function() {
if (this.get('saving')) return true; if (this.get('saving')) return true;

View File

@ -27,7 +27,11 @@ Discourse.AdminSiteContentEditRoute = Discourse.Route.extend({
setupController: function(controller, model) { setupController: function(controller, model) {
controller.set('loaded', false); 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) { Discourse.SiteContent.find(Em.get(model, 'content_type')).then(function (sc) {
controller.set('content', sc); controller.set('content', sc);

View File

@ -12,7 +12,8 @@ Discourse.AdminSiteContentsRoute = Discourse.Route.extend({
return Discourse.SiteContentType.findAll(); 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', {into: 'admin/templates/admin'});
this.render('admin/templates/site_contents_empty', {into: 'admin/templates/site_contents'}); this.render('admin/templates/site_contents_empty', {into: 'admin/templates/site_contents'});
} }

View File

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

View File

@ -12,7 +12,7 @@
// Externals we need to load first // Externals we need to load first
//= require ./external/jquery-1.8.3.js //= require ./external/jquery-1.8.3.js
//= require ./external/jquery.ui.widget.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? if Rails.env.development?
require_asset ("./external_development/ember.js") 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"); Discourse.URL.routeTo = topLevel(Discourse.URL.routeTo, "Discourse.URL.routeTo");
Ember.run.end = topLevel(Ember.run.end, "Ember.run.end"); Ember.run.end = topLevel(Ember.run.end, "Ember.run.end");
}, },

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,30 @@
<div class='contents clearfix'> <div class='contents clearfix'>
{{view.logoHTML}} {{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'> <div class='panel clearfix'>
{{#unless showExtraInfo}} {{#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

@ -17,32 +17,32 @@
<li> <li>
<a {{bindAttr href="url"}}> <a {{bindAttr href="url"}}>
<h4>{{i18n created}}</h4> <h4>{{i18n created}}</h4>
{{avatar view.topic.created_by imageSize="tiny"}} {{avatar created_by imageSize="tiny"}}
{{date view.topic.created_at}} {{date created_at}}
</a> </a>
</li> </li>
<li> <li>
<a {{bindAttr href="lastPostUrl"}}> <a {{bindAttr href="lastPostUrl"}}>
<h4>{{i18n last_post}}</h4> <h4>{{i18n last_post}}</h4>
{{avatar view.topic.last_poster imageSize="tiny"}} {{avatar last_poster imageSize="tiny"}}
{{date view.topic.last_posted_at}} {{date last_posted_at}}
</a> </a>
</li> </li>
<li> <li>
<h4>{{i18n posts}}</h4> <h4>{{i18n posts}}</h4>
{{number view.topic.posts_count}} {{number posts_count}}
</li> </li>
<li> <li>
<h4>{{i18n views}}</h4> <h4>{{i18n views}}</h4>
{{number view.topic.views}} {{number views}}
</li> </li>
<li> <li>
<h4>{{i18n links}}</h4> <h4>{{i18n links}}</h4>
{{number view.topic.links.length}} {{number links.length}}
</li> </li>
{{#if view.topic.fewParticipants}} {{#if fewParticipants}}
<li class='avatars'> <li class='avatars'>
{{#each view.topic.fewParticipants}}{{participant participant=this}}{{/each}} {{#each fewParticipants}}{{participant participant=this}}{{/each}}
</li> </li>
{{/if}} {{/if}}
</ul> </ul>
@ -53,28 +53,28 @@
<ul class="clearfix"> <ul class="clearfix">
<li> <li>
<h4>{{i18n created}}</h4> <h4>{{i18n created}}</h4>
{{avatar view.topic.created_by imageSize="tiny"}} {{avatar created_by imageSize="tiny"}}
<a {{bindAttr href="view.topic.url"}}>{{date view.topic.created_at}}</a> <a {{bindAttr href="url"}}>{{date created_at}}</a>
</li> </li>
<li> <li>
<h4>{{i18n last_post}}</h4> <h4>{{i18n last_post}}</h4>
{{avatar view.topic.last_poster imageSize="tiny"}} {{avatar last_poster imageSize="tiny"}}
<a {{bindAttr href="view.topic.lastPostUrl"}}>{{date view.topic.last_posted_at}}</a> <a {{bindAttr href="lastPostUrl"}}>{{date last_posted_at}}</a>
</li> </li>
<li> <li>
<h4>{{i18n posts}}</h4> <h4>{{i18n posts}}</h4>
{{number view.topic.posts_count}} {{number posts_count}}
</li> </li>
<li> <li>
<h4>{{i18n views}}</h4> <h4>{{i18n views}}</h4>
{{number view.topic.views}} {{number views}}
</li> </li>
</ul> </ul>
</section> </section>
{{#if view.topic.participants}} {{#if participants}}
<section class='avatars clearfix'> <section class='avatars clearfix'>
{{#each view.topic.participants}}{{participant participant=this}}{{/each}} {{#each participants}}{{participant participant=this}}{{/each}}
</section> </section>
{{/if}} {{/if}}
@ -92,7 +92,7 @@
{{#if view.parentView.showAllLinksControls}} {{#if view.parentView.showAllLinksControls}}
<div class='link-summary'> <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> </div>
{{/if}} {{/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, LINKS_SHOWN: 5,
allLinksShown: false, allLinksShown: false,
showAllLinksControls: (function() { showAllLinksControls: function() {
if (this.blank('topic.links')) return false; if (this.blank('topic.links')) return false;
if (this.get('allLinksShown')) return false; if (this.get('allLinksShown')) return false;
if (this.get('topic.links.length') <= this.LINKS_SHOWN) return false; if (this.get('topic.links.length') <= this.LINKS_SHOWN) return false;
return true; return true;
}).property('allLinksShown', 'topic.links'), }.property('allLinksShown', 'topic.links'),
infoLinks: (function() { infoLinks: function() {
if (this.blank('topic.links')) return []; if (this.blank('topic.links')) return [];
var allLinks = this.get('topic.links'); var allLinks = this.get('topic.links');
if (this.get('allLinksShown')) return allLinks; if (this.get('allLinksShown')) return allLinks;
return allLinks.slice(0, this.LINKS_SHOWN); return allLinks.slice(0, this.LINKS_SHOWN);
}).property('topic.links', 'allLinksShown'), }.property('topic.links', 'allLinksShown'),
newPostCreated: (function() { newPostCreated: function() {
this.rerender(); 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('post.post_number') !== 1) return true;
if (this.get('controller.content.archetype') === 'private_message') return false; if (this.get('controller.content.archetype') === 'private_message') return false;
if (this.get('controller.content.archetype') !== 'regular') return true; if (this.get('controller.content.archetype') !== 'regular') return true;
return this.get('controller.content.posts_count') < 2; return this.get('controller.content.posts_count') < 2;
}).property(), }.property(),
init: function() { init: function() {
this._super(); this._super();
if (this.get('hidden')) return; if (this.get('hidden')) return;
this.pushObject(Em.View.create({ this.pushObject(Em.View.create({
templateName: 'topic_summary/info', templateName: 'topic_summary/info',
topic: this.get('topic'), 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 // App header
.extra-info-wrapper { .extra-info-wrapper {
display: none;
float: left; float: left;
margin-left: 10px; margin-left: 10px;
&.show-extra-info {
display: block;
}
} }
#multi-select-options { #multi-select-options {

View File

@ -112,7 +112,7 @@ module Discourse
# ember stuff only used for asset precompliation, production variant plays up # ember stuff only used for asset precompliation, production variant plays up
config.ember.variant = :development config.ember.variant = :development
config.ember.ember_location = "#{Rails.root}/app/assets/javascripts/external_production/ember.js" 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 # So open id logs somewhere sane
config.after_initialize do 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-1.8.3.js
//= require ../../app/assets/javascripts/external/jquery.ui.widget.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/ember.js
//= require ../../app/assets/javascripts/external_production/sugar-1.3.5.js //= require ../../app/assets/javascripts/external_production/sugar-1.3.5.js
//= require ../../app/assets/javascripts/external_production/group-helper.js //= require ../../app/assets/javascripts/external_production/group-helper.js