diff --git a/ghost/admin/components/gh-focus-input.js b/ghost/admin/components/gh-focus-input.js deleted file mode 100644 index 2a3528705e..0000000000 --- a/ghost/admin/components/gh-focus-input.js +++ /dev/null @@ -1,7 +0,0 @@ -var FocusInput = Ember.TextField.extend({ - becomeFocused: function () { - this.$().val(this.$().val()).focus(); - }.on('didInsertElement') -}); - -export default FocusInput; diff --git a/ghost/admin/components/gh-trim-focus-input.js b/ghost/admin/components/gh-trim-focus-input.js new file mode 100644 index 0000000000..c99b19ca4a --- /dev/null +++ b/ghost/admin/components/gh-trim-focus-input.js @@ -0,0 +1,13 @@ +var TrimFocusInput = Ember.TextField.extend({ + setFocus: function () { + this.$().val(this.$().val()).focus(); + }.on('didInsertElement'), + + focusOut: function () { + var text = this.$().val(); + + this.$().val(text.trim()); + } +}); + +export default TrimFocusInput; diff --git a/ghost/admin/models/post.js b/ghost/admin/models/post.js index 36eacb8077..0de58e780a 100644 --- a/ghost/admin/models/post.js +++ b/ghost/admin/models/post.js @@ -4,7 +4,7 @@ var Post = DS.Model.extend(ValidationEngine, { validationType: 'post', uuid: DS.attr('string'), - title: DS.attr('string'), + title: DS.attr('string', {defaultValue: ''}), slug: DS.attr('string'), markdown: DS.attr('string', {defaultValue: ''}), html: DS.attr('string'), diff --git a/ghost/admin/templates/editor/edit.hbs b/ghost/admin/templates/editor/edit.hbs index a06d788053..c7d92b5340 100644 --- a/ghost/admin/templates/editor/edit.hbs +++ b/ghost/admin/templates/editor/edit.hbs @@ -1,6 +1,6 @@
- {{gh-focus-input type="text" id="entry-title" placeholder="Your Post Title" value=title tabindex="1"}} + {{gh-trim-focus-input type="text" id="entry-title" placeholder="Your Post Title" value=title tabindex="1"}}