Cleanup Misc Ember Code

No issue

Misc Places
- Removed expired, irrelevant, and fixed todos

FloatingHeaderPartial
- Fixed "Written" vs "Published" text logic

SettingsGeneralController
- Removed single quotes from property names

EditorBaseController, MarkerManagerMixin
- Aligned var declarations

PostItemView
- Commented out unfunctional code for feature request #2398
- Switched `isPage`, `isFeatured` to be computed properties in `Po
- use `toggleProperty` in `PostController.action.toggleFeatured`
This commit is contained in:
Matt Enlow 2014-06-17 14:20:54 -06:00
parent f11a81067a
commit b04dfd52c1
7 changed files with 21 additions and 33 deletions

View File

@ -4,14 +4,12 @@ var PostController = Ember.ObjectController.extend({
actions: {
toggleFeatured: function () {
var featured = !this.get('featured'),
var featured = this.toggleProperty('featured'),
self = this;
this.set('featured', featured);
this.get('model').save().then(function () {
self.notifications.showSuccess('Post successfully marked as ' + (featured ? 'featured' : 'not featured') + '.');
}, function () {
}).catch(function () {
self.notifications.showError('An error occured while saving the post.');
});
}

View File

@ -1,4 +1,3 @@
var elementLookup = {
title: '#blog-title',
description: '#blog-description',
@ -20,7 +19,7 @@ var SettingsGeneralController = Ember.ObjectController.extend({
}.property('permalinks'),
actions: {
'save': function () {
save: function () {
// Validate and save settings
var model = this.get('model'),
// @TODO: Don't know how to scope this to this controllers view because this.view is null
@ -46,11 +45,11 @@ var SettingsGeneralController = Ember.ObjectController.extend({
}
},
'uploadLogo': function () {
uploadLogo: function () {
// @TODO: Integrate with Modal component
},
'uploadCover': function () {
uploadCover: function () {
// @TODO: Integrate with Modal component
}
}

View File

@ -159,12 +159,11 @@ var MarkerManager = Ember.Mixin.create({
// Removes the marker on the given line if there is one
stripMarkerFromLine: function (line) {
var ln,
editor = this.get('codemirror'),
var editor = this.get('codemirror'),
ln = editor.getLineNumber(line),
markerRegex = /\{<([\w\W]*?)>\}/,
markerText = line.text.match(markerRegex);
ln = editor.getLineNumber(line);
if (markerText) {
editor.replaceRange(

View File

@ -16,7 +16,6 @@ var SignoutRoute = AuthenticatedRoute.extend(styleBody, {
}
}).then(function () {
self.notifications.showSuccess('You were successfully signed out.');
// @TODO: new CSRF token to enable logging back in w/o refreshing - see issue #2861 for details
self.transitionTo('signin');
}, function (resp) {
self.notifications.showAPIError(resp, 'There was a problem logging out, please try again.');

View File

@ -1,12 +1,10 @@
<header class="floatingheader">
<button class="button-back" href="#">Back</button>
{{!-- @TODO: add back title updates depending on featured state --}}
<a {{bind-attr class="featured:featured:unfeatured"}} href="#" title="Feature this post" {{action "toggleFeatured"}}>
<span class="hidden">Star</span>
</a>
<small>
{{!-- @TODO: the if published doesn't seem to work, needs to be fixed --}}
<span class="status">{{#if published}}Published{{else}}Written{{/if}}</span>
<span class="status">{{#if isPublished}}Published{{else}}Written{{/if}}</span>
<span class="normal">by</span>
<span class="author">{{#if author.name}}{{author.name}}{{else}}{{author.email}}{{/if}}</span>
</small>

View File

@ -1,23 +1,18 @@
import itemView from 'ghost/views/item-view';
var PostItemView = itemView.extend({
classNameBindings: ['isFeatured', 'isPage'],
classNameBindings: ['isFeatured:featured', 'isPage:page'],
isFeatured: function () {
if (this.get('controller.model.featured')) {
return 'featured';
}
}.property('controller.model.featured'),
isFeatured: Ember.computed.alias('controller.model.featured'),
isPage: function () {
if (this.get('controller.model.page')) {
return 'page';
}
}.property('controller.model.page'),
isPage: Ember.computed.alias('controller.model.page'),
// WIP for #2308
/*
openEditor: function () {
this.get('controller').send('openEditor', this.get('controller.model')); // send action to handle transition to editor route
}.on('doubleClick')
*/
});
export default PostItemView;