mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 20:03:12 +03:00
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:
parent
f11a81067a
commit
b04dfd52c1
@ -4,18 +4,16 @@ 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.');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export default PostController;
|
||||
export default PostController;
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ var EditorControllerMixin = Ember.Mixin.create(MarkerManager, {
|
||||
// when returned from the server with ids.
|
||||
updateTags: function () {
|
||||
var tags = this.get('model.tags'),
|
||||
oldTags = tags.filterBy('id', null);
|
||||
oldTags = tags.filterBy('id', null);
|
||||
|
||||
tags.removeObjects(oldTags);
|
||||
oldTags.invoke('deleteRecord');
|
||||
|
@ -11,10 +11,10 @@ var MarkerManager = Ember.Mixin.create({
|
||||
// Add markers to the line if it needs one
|
||||
initMarkers: function (line) {
|
||||
var imageMarkdownRegex = this.get('imageMarkdownRegex'),
|
||||
markerRegex = this.get('markerRegex'),
|
||||
editor = this.get('codemirror'),
|
||||
isImage = line.text.match(imageMarkdownRegex),
|
||||
hasMarker = line.text.match(markerRegex);
|
||||
markerRegex = this.get('markerRegex'),
|
||||
editor = this.get('codemirror'),
|
||||
isImage = line.text.match(imageMarkdownRegex),
|
||||
hasMarker = line.text.match(markerRegex);
|
||||
|
||||
if (isImage && !hasMarker) {
|
||||
this.addMarker(line, editor.getLineNumber(line));
|
||||
@ -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(
|
||||
@ -189,7 +188,7 @@ var MarkerManager = Ember.Mixin.create({
|
||||
|
||||
editor.eachLine(function (line) {
|
||||
var markerText = self.markerRegexForId(id).exec(line.text),
|
||||
ln;
|
||||
ln;
|
||||
|
||||
if (markerText) {
|
||||
ln = editor.getLineNumber(line);
|
||||
|
@ -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.');
|
||||
|
@ -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>
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user