mirror of
https://github.com/documize/community.git
synced 2025-07-21 22:29:41 +02:00
gui/editors: toggle Preview/Edit button
When hitting "Preview" on a previewable section (e.g. one with markdown), the tooltip and icon of the preview-button still show "Preview". With this change, both the text and the button will be switched accordingly.
This commit is contained in:
parent
73e8c7a278
commit
9ed8f79315
3 changed files with 9 additions and 2 deletions
|
@ -27,6 +27,10 @@ export default Component.extend(Modals, Notifier, {
|
||||||
return `page-editor-${page.id}`;
|
return `page-editor-${page.id}`;
|
||||||
}),
|
}),
|
||||||
previewText: 'Preview',
|
previewText: 'Preview',
|
||||||
|
previewIcon: computed('previewIcon', function () {
|
||||||
|
let constants = this.get('constants');
|
||||||
|
return constants.Icon.Preview;
|
||||||
|
}),
|
||||||
pageTitle: '',
|
pageTitle: '',
|
||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
|
@ -102,8 +106,10 @@ export default Component.extend(Modals, Notifier, {
|
||||||
},
|
},
|
||||||
|
|
||||||
onPreview() {
|
onPreview() {
|
||||||
|
let constants = this.get('constants');
|
||||||
let pt = this.get('previewText');
|
let pt = this.get('previewText');
|
||||||
this.set('previewText', pt === 'Preview' ? 'Edit Mode' : 'Preview');
|
this.set('previewText', pt === 'Preview' ? 'Edit Mode' : 'Preview');
|
||||||
|
this.set('previewIcon', pt === 'Preview' ? constants.Icon.Edit : constants.Icon.Preview);
|
||||||
return this.get('onPreview')();
|
return this.get('onPreview')();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ export default Component.extend({
|
||||||
click(e) {
|
click(e) {
|
||||||
if (!_.isUndefined(this.onClick)) {
|
if (!_.isUndefined(this.onClick)) {
|
||||||
this.onClick(e);
|
this.onClick(e);
|
||||||
|
this.notifyPropertyChange('calcClass');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,8 @@
|
||||||
tooltip="Insert Link" onClick=(action "onShowLinkModal")}}
|
tooltip="Insert Link" onClick=(action "onShowLinkModal")}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if previewButton}}
|
{{#if previewButton}}
|
||||||
{{ui/ui-toolbar-icon icon=constants.Icon.Preview color=constants.Color.Gray
|
{{ui/ui-toolbar-icon icon=previewIcon color=constants.Color.Gray
|
||||||
tooltip="Preview changes" onClick=(action "onPreview")}}
|
tooltip=previewText onClick=(action "onPreview")}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{ui/ui-toolbar-icon icon=constants.Icon.Tick color=constants.Color.Green tooltip="Save changes" onClick=(action "onAction")}}
|
{{ui/ui-toolbar-icon icon=constants.Icon.Tick color=constants.Color.Green tooltip="Save changes" onClick=(action "onAction")}}
|
||||||
{{ui/ui-toolbar-icon icon=constants.Icon.Cross color=constants.Color.Red tooltip="Cancel editing" onClick=(action "onCancel")}}
|
{{ui/ui-toolbar-icon icon=constants.Icon.Cross color=constants.Color.Red tooltip="Cancel editing" onClick=(action "onCancel")}}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue