0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Merge pull request #492 from gotdibbs/Issue352

Fixed editor actions menu
This commit is contained in:
Hannah Wolfe 2013-08-22 11:48:37 -07:00
commit 2b94364842
2 changed files with 50 additions and 33 deletions

View file

@ -420,7 +420,13 @@ body.zen {
@include icon($i-chevron-down) { @include icon($i-chevron-down) {
margin-top: -5px; margin-top: -5px;
@include transform(rotate(540deg)); @include transform(rotate(540deg));
@include transition(transform 0.6s ease); /* Transition properties are split out due to a defect in
the vendor prefixing of transform transitions.
See: http://github.com/thoughtbot/bourbon/pull/86
*/
@include transition-property(transform);
@include transition-duration(0.6s);
@include transition-timing-function(ease);
}; };
} }
} }

View file

@ -64,9 +64,11 @@
}, },
statusMap: { statusMap: {
'draft' : 'Save Draft', 'draft': 'Save Draft',
'published': 'Update Post', 'published': 'Publish Now',
'scheduled' : 'Save Schedued Post' 'scheduled': 'Save Schedued Post',
'queue': 'Add to Queue',
'publish-on': 'Publish on...'
}, },
initialize: function () { initialize: function () {
@ -119,54 +121,59 @@
}); });
}, },
setActiveStatus: function setActiveStatus(status, displayText) {
// Set the publish button's action
$('.js-post-button')
.attr('data-status', status)
.text(displayText);
// Set the active action in the popup
$('.splitbutton-save .editor-options li')
.removeClass('active')
.filter(['li[data-set-status="', status, '"]'].join(''))
.addClass('active');
},
handleStatus: function (e) { handleStatus: function (e) {
e.preventDefault(); if (e) { e.preventDefault(); }
var view = this, var view = this,
status = $(e.currentTarget).attr('data-set-status'), status = $(e.currentTarget).attr('data-set-status');
prevStatus = this.model.get('status'),
model = this.model; view.setActiveStatus(status, this.statusMap[status]);
// Dismiss the popup menu
$('body').find('.overlay:visible').fadeOut();
},
updatePost: function (e) {
if (e) { e.preventDefault(); }
var view = this,
model = view.model,
$currentTarget = $(e.currentTarget),
status = $currentTarget.attr('data-status'),
prevStatus = model.get('status');
if (status === 'publish-on') { if (status === 'publish-on') {
Ghost.notifications.addItem({ return Ghost.notifications.addItem({
type: 'alert', type: 'alert',
message: 'Scheduled publishing not supported yet.', message: 'Scheduled publishing not supported yet.',
status: 'passive' status: 'passive'
}); });
} }
if (status === 'queue') { if (status === 'queue') {
Ghost.notifications.addItem({ return Ghost.notifications.addItem({
type: 'alert', type: 'alert',
message: 'Scheduled publishing not supported yet.', message: 'Scheduled publishing not supported yet.',
status: 'passive' status: 'passive'
}); });
} }
this.savePost({ view.savePost({
status: status status: status
}).then(function () { }).then(function () {
Ghost.notifications.addItem({ Ghost.notifications.addItem({
type: 'success', type: 'success',
message: 'Your post: ' + model.get('title') + ' has been ' + status, message: ['Your post "', model.get('title'), '" has been ', status, '.'].join(''),
status: 'passive'
});
}, function (response) {
// Show a notification about the error
view.reportSaveError(response, model, status);
// Set the button text back to previous
model.set({ status: prevStatus });
});
},
updatePost: function (e) {
if (e) {
e.preventDefault();
}
var view = this,
model = this.model;
this.savePost().then(function () {
Ghost.notifications.addItem({
type: 'success',
message: 'Your post was saved as ' + model.get('status'),
status: 'passive' status: 'passive'
}); });
}, function (request) { }, function (request) {
@ -177,6 +184,8 @@
message: message, message: message,
status: 'passive' status: 'passive'
}); });
model.set({ status: prevStatus });
}); });
}, },
@ -219,7 +228,9 @@
}, },
render: function () { render: function () {
this.$('.js-post-button').text(this.statusMap[this.model.get('status')]); var status = this.model.get('status');
this.setActiveStatus(status, this.statusMap[status]);
} }
}); });