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

Merge pull request #6697 from jeffjewiss/save-draft-title-on-blur

Saves post title on focus blur if status is draft
This commit is contained in:
Austin Burdine 2016-04-12 13:55:09 -05:00
commit 5cba0810fc
2 changed files with 20 additions and 1 deletions

View file

@ -398,6 +398,25 @@ export default Mixin.create({
return transition.retry();
},
updateTitle() {
let currentTitle = this.model.get('title');
let newTitle = this.model.get('titleScratch').trim();
if (currentTitle === newTitle) {
return;
}
if (this.get('model.isDraft') && !this.get('model.isNew')) {
// this is preferrable to setting hasDirtyAttributes to false manually
this.model.set('title', newTitle);
this.send('save', {
silent: true,
backgroundSave: true
});
}
},
toggleReAuthenticateModal() {
this.toggleProperty('showReAuthenticateModal');
}

View file

@ -1,7 +1,7 @@
<section class="gh-view">
<header class="view-header">
{{#gh-view-title classNames="gh-editor-title" openMobileMenu="openMobileMenu"}}
{{gh-trim-focus-input type="text" id="entry-title" placeholder="Your Post Title" value=model.titleScratch tabindex="1" focus=shouldFocusTitle}}
{{gh-trim-focus-input type="text" id="entry-title" placeholder="Your Post Title" value=model.titleScratch tabindex="1" focus=shouldFocusTitle focus-out="updateTitle" }}
{{/gh-view-title}}
<section class="view-actions">
<button type="button" class="post-settings" title="Post Settings" {{action "openSettingsMenu"}}>