Merge pull request #3836 from jaswilli/ember17-prep

Rework editor save button.
This commit is contained in:
Hannah Wolfe 2014-08-21 19:47:35 +01:00
commit fb0d1d0643
2 changed files with 12 additions and 12 deletions

View File

@ -1,14 +1,14 @@
<button type="button" {{action "save"}} {{bind-attr class=":btn :btn-sm view.isDangerous:btn-red:btn-blue :js-publish-button" }}>{{view.save-text}}</button>
<button type="button" {{action "save"}} {{bind-attr class=":btn :btn-sm view.isDangerous:btn-red:btn-blue :js-publish-button" }}>{{view.saveText}}</button>
{{#gh-popover-button popoverName="post-save-menu" classNameBindings=":btn :btn-sm view.isDangerous:btn-red:btn-blue btnopen:active :dropdown-toggle :up"}}
<i class="options"></i>
<span class="sr-only">Toggle Settings Menu</span>
{{/gh-popover-button}}
{{#gh-popover name="post-save-menu" closeOnClick="true" tagName="div" classNames="dropdown editor-options" publishTextBinding="view.publish-text" draftTextBinding="view.draft-text"}}
{{#gh-popover name="post-save-menu" closeOnClick="true" tagName="div" classNames="dropdown editor-options"}}
<ul class="dropdown-menu dropdown-triangle-bottom-right">
<li class="post-save-publish" {{bind-attr class="controller.willPublish:active" }}>
<li class="post-save-publish" {{bind-attr class="willPublish:active"}}>
<a {{action "setSaveType" "publish"}} href="#">{{view.publishText}}</a>
</li>
<li class="post-save-draft" {{bind-attr class="controller.willPublish::active" }}>
<li class="post-save-draft" {{bind-attr class="willPublish::active"}}>
<a {{action "setSaveType" "draft"}} href="#">{{view.draftText}}</a>
</li>
</ul>

View File

@ -1,24 +1,24 @@
var EditorSaveButtonView = Ember.View.extend({
templateName: 'editor-save-button',
tagName: 'section',
classNames: ['splitbtn js-publish-splitbutton'],
classNames: ['splitbtn', 'js-publish-splitbutton'],
//Tracks whether we're going to change the state of the post on save
isDangerous: Ember.computed('controller.isPublished', 'controller.willPublish', function () {
return this.get('controller.isPublished') !== this.get('controller.willPublish');
}),
'save-text': Ember.computed('controller.willPublish', function () {
return this.get('controller.willPublish') ? this.get('publish-text') : this.get('draft-text');
}),
'publish-text': Ember.computed('controller.isPublished', function () {
'publishText': Ember.computed('controller.isPublished', function () {
return this.get('controller.isPublished') ? 'Update Post' : 'Publish Now';
}),
'draft-text': Ember.computed('controller.isPublished', function () {
'draftText': Ember.computed('controller.isPublished', function () {
return this.get('controller.isPublished') ? 'Unpublish' : 'Save Draft';
})
}),
'saveText': Ember.computed('controller.willPublish', function () {
return this.get('controller.willPublish') ? this.get('publishText') : this.get('draftText');
}),
});
export default EditorSaveButtonView;