Fixed editor actions menu

Closes #352
- Updated editor.scss to break out transition shorthand into its
constituent properties so that bourbon appends the correct vendor
prefixes.
- Added full set of publish options to the statusMap.
- Added setActiveStatus function to handle toggling the active action
for the publish menu.
- Cleaned up handleStatus and updatePost functions to match desired
functionality of menu items toggling the selected action and the actual
button on the split button invoking said action.
This commit is contained in:
William Dibbern 2013-08-21 21:31:59 -05:00
parent 2b0c544e3e
commit 31dc45768a
2 changed files with 50 additions and 33 deletions

View File

@ -416,7 +416,13 @@ body.zen {
@include icon($i-chevron-down) {
margin-top:-5px;
@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: {
'draft' : 'Save Draft',
'published': 'Update Post',
'scheduled' : 'Save Schedued Post'
'draft': 'Save Draft',
'published': 'Publish Now',
'scheduled': 'Save Schedued Post',
'queue': 'Add to Queue',
'publish-on': 'Publish on...'
},
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) {
e.preventDefault();
if (e) { e.preventDefault(); }
var view = this,
status = $(e.currentTarget).attr('data-set-status'),
prevStatus = this.model.get('status'),
model = this.model;
status = $(e.currentTarget).attr('data-set-status');
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') {
Ghost.notifications.addItem({
return Ghost.notifications.addItem({
type: 'alert',
message: 'Scheduled publishing not supported yet.',
status: 'passive'
});
}
if (status === 'queue') {
Ghost.notifications.addItem({
return Ghost.notifications.addItem({
type: 'alert',
message: 'Scheduled publishing not supported yet.',
status: 'passive'
});
}
this.savePost({
view.savePost({
status: status
}).then(function () {
Ghost.notifications.addItem({
type: 'success',
message: 'Your post: ' + model.get('title') + ' has been ' + status,
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'),
message: ['Your post "', model.get('title'), '" has been ', status, '.'].join(''),
status: 'passive'
});
}, function (request) {
@ -177,6 +184,8 @@
message: message,
status: 'passive'
});
model.set({ status: prevStatus });
});
},
@ -219,7 +228,9 @@
},
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]);
}
});