diff --git a/gui/app/components/document/document-index.js b/gui/app/components/document/document-index.js index cac16b9a..0a536c99 100644 --- a/gui/app/components/document/document-index.js +++ b/gui/app/components/document/document-index.js @@ -10,13 +10,11 @@ // https://documize.com import { computed } from '@ember/object'; - import Component from '@ember/component'; import tocUtil from '../../utils/toc'; import NotifierMixin from '../../mixins/notifier'; -import TooltipMixin from '../../mixins/tooltip'; -export default Component.extend(NotifierMixin, TooltipMixin, { +export default Component.extend(NotifierMixin, { document: {}, folder: {}, pages: [], @@ -42,17 +40,6 @@ export default Component.extend(NotifierMixin, TooltipMixin, { } }, - didRender() { - this._super(...arguments); - - if (this.session.authenticated) { - this.addTooltip(document.getElementById("toc-up-button")); - this.addTooltip(document.getElementById("toc-down-button")); - this.addTooltip(document.getElementById("toc-outdent-button")); - this.addTooltip(document.getElementById("toc-indent-button")); - } - }, - didInsertElement() { this._super(...arguments); @@ -63,7 +50,6 @@ export default Component.extend(NotifierMixin, TooltipMixin, { this._super(...arguments); this.eventBus.unsubscribe('documentPageAdded'); - this.destroyTooltips(); }, onDocumentPageAdded(pageId) { diff --git a/gui/app/components/document/document-sidebar.js b/gui/app/components/document/document-sidebar.js index a3869902..d3d9af71 100644 --- a/gui/app/components/document/document-sidebar.js +++ b/gui/app/components/document/document-sidebar.js @@ -10,26 +10,10 @@ // https://documize.com import Component from '@ember/component'; -import NotifierMixin from '../../mixins/notifier'; -import TooltipMixin from '../../mixins/tooltip'; -export default Component.extend(NotifierMixin, TooltipMixin, { +export default Component.extend({ tab: 'index', - didRender() { - this._super(...arguments); - - if (this.get('permissions.documentEdit')) { - this.addTooltip(document.getElementById("document-index-button")); - this.addTooltip(document.getElementById("document-activity-button")); - } - }, - - willDestroyElement() { - this._super(...arguments); - this.destroyTooltips(); - }, - actions: { onTabSwitch(tab) { this.set('tab', tab); diff --git a/gui/app/components/document/document-tab.js b/gui/app/components/document/document-tab.js deleted file mode 100644 index 8c92ca62..00000000 --- a/gui/app/components/document/document-tab.js +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2016 Documize Inc. . All rights reserved. -// -// This software (Documize Community Edition) is licensed under -// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html -// -// You can operate outside the AGPL restrictions by purchasing -// Documize Enterprise Edition and obtaining a commercial license -// by contacting . -// -// https://documize.com - -import { inject as service } from '@ember/service'; - -import Component from '@ember/component'; -import NotifierMixin from '../../mixins/notifier'; -import TooltipMixin from '../../mixins/tooltip'; - -export default Component.extend(NotifierMixin, TooltipMixin, { - sectionService: service('section'), - viewMode: true, - editMode: false, - - didInsertElement() { - this.get('sectionService').refresh(this.get('document.id')).then((changes) => { - if (this.get('isDestroyed') || this.get('isDestroying')) { - return; - } - - let oldPage = this.get('page'); - - if (is.undefined(changes) || is.undefined(oldPage)) { - return; - } - - changes.forEach((newPage) => { - if (oldPage.get('id') === newPage.get('id')) { - oldPage.set('body', newPage.get('body')); - oldPage.set('revised', newPage.get('revised')); - this.showNotification(`Refreshed ${oldPage.get('title')}`); - } - }); - }); - }, - - actions: { - onExpand() { - this.set('pageId', this.get('page.id')); - this.set('expanded', !this.get('expanded')); - }, - - onSavePageAsBlock(block) { - this.attrs.onSavePageAsBlock(block); - }, - - onCopyPage(documentId) { - this.attrs.onCopyPage(this.get('page.id'), documentId); - }, - - onMovePage(documentId) { - this.attrs.onMovePage(this.get('page.id'), documentId); - }, - - onDeletePage(deleteChildren) { - let page = this.get('page'); - - if (is.undefined(page)) { - return; - } - - let params = { - id: page.get('id'), - title: page.get('title'), - children: deleteChildren - }; - - this.attrs.onDeletePage(params); - } - } -}); diff --git a/gui/app/components/document/document-view.js b/gui/app/components/document/document-view.js index 3deb430d..4ba7aa96 100644 --- a/gui/app/components/document/document-view.js +++ b/gui/app/components/document/document-view.js @@ -49,17 +49,14 @@ export default Component.extend(NotifierMixin, TooltipMixin, { this._super(...arguments); this.setupAddWizard(); - let self = this; - $(".tooltipped").each(function(i, el) { - self.addTooltip(el); - }); + this.renderTooltips(); }, willDestroyElement() { this._super(...arguments); $('.start-section:not(.start-section-empty-state)').off('.hoverIntent'); - this.destroyTooltips(); + this.removeTooltips(); }, contentLinkHandler() { diff --git a/gui/app/components/document/tab-heading.js b/gui/app/components/document/tab-heading.js deleted file mode 100644 index b544d2fa..00000000 --- a/gui/app/components/document/tab-heading.js +++ /dev/null @@ -1,205 +0,0 @@ -// Copyright 2016 Documize Inc. . All rights reserved. -// -// This software (Documize Community Edition) is licensed under -// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html -// -// You can operate outside the AGPL restrictions by purchasing -// Documize Enterprise Edition and obtaining a commercial license -// by contacting . -// -// https://documize.com - -import Component from '@ember/component'; - -import { computed } from '@ember/object'; -import { inject as service } from '@ember/service'; -import TooltipMixin from '../../mixins/tooltip'; - -export default Component.extend(TooltipMixin, { - documentService: service('document'), - expanded: false, - deleteChildren: false, - menuOpen: false, - blockTitle: "", - blockExcerpt: "", - documentList: [], //includes the current document - documentListOthers: [], //excludes the current document - selectedDocument: null, - - checkId: computed('page', function () { - let id = this.get('page.id'); - return `delete-check-button-${id}`; - }), - menuTarget: computed('page', function () { - let id = this.get('page.id'); - return `page-menu-${id}`; - }), - deleteButtonId: computed('page', function () { - let id = this.get('page.id'); - return `delete-page-button-${id}`; - }), - publishButtonId: computed('page', function () { - let id = this.get('page.id'); - return `publish-button-${id}`; - }), - publishDialogId: computed('page', function () { - let id = this.get('page.id'); - return `publish-dialog-${id}`; - }), - blockTitleId: computed('page', function () { - let id = this.get('page.id'); - return `block-title-${id}`; - }), - blockExcerptId: computed('page', function () { - let id = this.get('page.id'); - return `block-excerpt-${id}`; - }), - copyButtonId: computed('page', function () { - let id = this.get('page.id'); - return `copy-page-button-${id}`; - }), - copyDialogId: computed('page', function () { - let id = this.get('page.id'); - return `copy-dialog-${id}`; - }), - moveButtonId: computed('page', function () { - let id = this.get('page.id'); - return `move-page-button-${id}`; - }), - moveDialogId: computed('page', function () { - let id = this.get('page.id'); - return `move-dialog-${id}`; - }), - - hasMenuPermissions: computed('permissions', function() { - let permissions = this.get('permissions'); - - return permissions.get('documentDelete') || permissions.get('documentCopy') || - permissions.get('documentMove') || permissions.get('documentTemplate'); - }), - - didRender() { - $("#" + this.get('blockTitleId')).removeClass('error'); - $("#" + this.get('blockExcerptId')).removeClass('error'); - }, - - actions: { - toggleExpand() { - this.set('expanded', !this.get('expanded')); - this.get('onExpand')(); - }, - - onMenuOpen() { - if ($('#' + this.get('publishDialogId')).is( ":visible" )) { - return; - } - if ($('#' + this.get('copyDialogId')).is( ":visible" )) { - return; - } - if ($('#' + this.get('moveDialogId')).is( ":visible" )) { - return; - } - - this.set('menuOpen', !this.get('menuOpen')); - }, - - onEdit() { - this.attrs.onEdit(); - }, - - deletePage() { - this.attrs.onDeletePage(this.get('deleteChildren')); - }, - - onSavePageAsBlock() { - let page = this.get('page'); - let titleElem = '#' + this.get('blockTitleId'); - let blockTitle = this.get('blockTitle'); - if (is.empty(blockTitle)) { - $(titleElem).addClass('error'); - return; - } - - let excerptElem = '#' + this.get('blockExcerptId'); - let blockExcerpt = this.get('blockExcerpt'); - blockExcerpt = blockExcerpt.replace(/\n/g, ""); - if (is.empty(blockExcerpt)) { - $(excerptElem).addClass('error'); - return; - } - - this.get('documentService').getPageMeta(this.get('document.id'), page.get('id')).then((pm) => { - let block = { - folderId: this.get('folder.id'), - contentType: page.get('contentType'), - pageType: page.get('pageType'), - title: blockTitle, - body: page.get('body'), - excerpt: blockExcerpt, - rawBody: pm.get('rawBody'), - config: pm.get('config'), - externalSource: pm.get('externalSource') - }; - - this.attrs.onSavePageAsBlock(block); - - this.set('menuOpen', false); - this.set('blockTitle', ''); - this.set('blockExcerpt', ''); - $(titleElem).removeClass('error'); - $(excerptElem).removeClass('error'); - - return true; - }); - }, - - // Copy/move actions - onCopyDialogOpen() { - // Fetch document targets once. - if (this.get('documentList').length > 0) { - return; - } - - this.get('documentService').getPageMoveCopyTargets().then((d) => { - let me = this.get('document'); - this.set('documentList', d); - this.set('documentListOthers', d.filter((item) => item.get('id') !== me.get('id'))); - }); - }, - - onTargetChange(d) { - this.set('selectedDocument', d); - }, - - onCopyPage() { - // can't proceed if no data - if (this.get('documentList.length') === 0) { - return; - } - - let targetDocumentId = this.get('document.id'); - if (is.not.null(this.get('selectedDocument'))) { - targetDocumentId = this.get('selectedDocument.id'); - } - - this.attrs.onCopyPage(targetDocumentId); - return true; - }, - - onMovePage() { - // can't proceed if no data - if (this.get('documentListOthers.length') === 0) { - return; - } - - if (is.null(this.get('selectedDocument'))) { - this.set('selectedDocument', this.get('documentListOthers')[0]); - } - - let targetDocumentId = this.get('selectedDocument.id'); - - this.attrs.onMovePage(targetDocumentId); - return true; - } - } -}); diff --git a/gui/app/components/section/gemini/type-editor.js b/gui/app/components/section/gemini/type-editor.js index 3d0b93ca..bb347634 100644 --- a/gui/app/components/section/gemini/type-editor.js +++ b/gui/app/components/section/gemini/type-editor.js @@ -14,8 +14,9 @@ import { schedule } from '@ember/runloop'; import { inject as service } from '@ember/service'; import Component from '@ember/component'; import SectionMixin from '../../../mixins/section'; +import TooltipMixin from '../../../mixins/tooltip'; -export default Component.extend(SectionMixin, { +export default Component.extend(SectionMixin, TooltipMixin, { sectionService: service('section'), isDirty: false, waiting: false, @@ -84,12 +85,9 @@ export default Component.extend(SectionMixin, { self.set('workspaces', response); self.selectWorkspace(workspaceId); - schedule('afterRender', function () { + schedule('afterRender', () => { window.scrollTo(0, document.body.scrollHeight); - - response.forEach(function (workspace) { - self.addTooltip(document.getElementById("gemini-workspace-" + workspace.Id)); - }); + self.renderTooltips(); }); self.set('waiting', false); }, function (reason) { // eslint-disable-line no-unused-vars diff --git a/gui/app/components/section/markdown/type-editor.js b/gui/app/components/section/markdown/type-editor.js index 999cd129..e2c7fcb2 100644 --- a/gui/app/components/section/markdown/type-editor.js +++ b/gui/app/components/section/markdown/type-editor.js @@ -10,13 +10,11 @@ // https://documize.com import { schedule } from '@ember/runloop'; - import { computed } from '@ember/object'; import Component from '@ember/component'; import { inject as service } from '@ember/service'; -import TooltipMixin from '../../../mixins/tooltip'; -export default Component.extend(TooltipMixin, { +export default Component.extend({ link: service(), pageBody: "", pagePreview: "", @@ -39,7 +37,6 @@ export default Component.extend(TooltipMixin, { didInsertElement() { this.attachEditor(); - this.addTooltip(document.getElementById(this.get('tooltipId'))); }, willDestroyElement() { @@ -51,7 +48,6 @@ export default Component.extend(TooltipMixin, { } this.set('codeEditor', null); - this.destroyTooltips(); }, getBody() { diff --git a/gui/app/components/ui/ui-avatar.js b/gui/app/components/ui/ui-avatar.js index 74aa0c60..a1d61d78 100644 --- a/gui/app/components/ui/ui-avatar.js +++ b/gui/app/components/ui/ui-avatar.js @@ -14,7 +14,6 @@ import TooltipMixin from '../../mixins/tooltip'; export default Component.extend(TooltipMixin, { didRender() { - let refId = this.get('refId'); - this.addTooltip(document.getElementById(`avatar-${refId}`)); + this.renderTooltips(); }, }); diff --git a/gui/app/mixins/tooltip.js b/gui/app/mixins/tooltip.js index 6aca2d78..a9453f13 100644 --- a/gui/app/mixins/tooltip.js +++ b/gui/app/mixins/tooltip.js @@ -24,40 +24,5 @@ export default Mixin.create({ removeTooltips() { $('[data-toggle="tooltip"]').tooltip('dispose'); - }, - - addTooltip(elem) { - if (elem == null) { - return; - } - - let t = new Tooltip({ - target: elem - }); - - let tt = this.get('tooltips'); - tt.push(t); - - return t; - }, - - destroyTooltip(t) { - t.destroy(); - }, - - destroyTooltips() { - if (this.get('isDestroyed') || this.get('isDestroying')) { - return; - } - - let tt = this.get('tooltips'); - - tt.forEach(t => { - t.destroy(); - }); - - tt.length = 0; - - this.set('tooltips', tt); - } + } }); diff --git a/gui/app/routes/application.js b/gui/app/routes/application.js index 8a1f65e8..65a2bd33 100644 --- a/gui/app/routes/application.js +++ b/gui/app/routes/application.js @@ -56,7 +56,7 @@ export default Route.extend(ApplicationRouteMixin, TooltipMixin, { actions: { willTransition: function( /*transition*/ ) { Mousetrap.reset(); - this.destroyTooltips(); + this.removeTooltips(); }, error(error, transition) { diff --git a/gui/app/styles/view/document/all.scss b/gui/app/styles/view/document/all.scss index f67dd6d3..e4e5a075 100644 --- a/gui/app/styles/view/document/all.scss +++ b/gui/app/styles/view/document/all.scss @@ -2,5 +2,4 @@ @import "activity.scss"; @import "attachments.scss"; @import "toc.scss"; -@import "view.scss"; @import "new-section.scss"; diff --git a/gui/app/styles/view/document/view.scss b/gui/app/styles/view/document/view.scss deleted file mode 100644 index d60e2542..00000000 --- a/gui/app/styles/view/document/view.scss +++ /dev/null @@ -1,123 +0,0 @@ -.document-view { - margin: 0 0 0 0; - - .is-a-page { - @include ease-in(); - overflow-x: auto; - - &:hover { - .page-title { - > .page-toolbar { - opacity: 1; - } - } - } - - .page-title { - > .page-toolbar { - opacity: 0; - } - } - } - - .is-a-tab { - @include content-container(); - @include ease-in(); - - .icon { - text-align: center; - display: inline-block; - width: 40px; - vertical-align: bottom; - margin-right: 5px; - - > .img { - text-align: center; - display: inline-block; - height: 30px; - width: 30px; - } - } - - > .title { - font-size: 1.3rem; - font-weight: normal; - color: $color-off-black; - letter-spacing: 0.5px; - margin-top: 8px; - } - - &:hover { - .page-title { - > .page-toolbar { - opacity: 1; - } - } - } - - .page-title { - > .page-toolbar { - opacity: 0; - } - } - } - - .tab-min { - padding: 0px 50px; - height: 65px; - overflow: hidden; - cursor: default; - - .page-title { - > .page-toolbar { - opacity: 1; - } - } - } - - .tab-max { - padding: 25px 50px; - height: auto; - overflow: auto; - cursor: normal; - } - - .section-divider { - height: 60px; - background-color: transparent; - } -} - -// .document-view-unified { -// margin: 0 0 50px 0; -// @include content-container(); -// @include ease-in(); -// @extend .transition-all; - -// .is-a-page, .is-a-tab { -// padding: 0 !important; -// box-shadow: none !important; -// background-color: transparent !important; -// @include border-radius(0px); -// } - -// .tab-min, .tab-max { -// padding: 0 !important; -// } - -// .start-section { -// height: 50px !important; -// } -// } - -// .document-toolbar { -// > .round-button-mono { -// background-color: $color-white; -// border: 1px solid $color-gray; - -// > .material-icons { -// @include ease-in(); -// color: $color-gray; -// } -// } -// } diff --git a/gui/app/templates/components/document/document-tab.hbs b/gui/app/templates/components/document/document-tab.hbs deleted file mode 100644 index dd2a3052..00000000 --- a/gui/app/templates/components/document/document-tab.hbs +++ /dev/null @@ -1,7 +0,0 @@ -
- {{document/tab-heading tagName=page.tagName document=document folder=folder page=page permissions=permissions - onExpand=(action 'onExpand') onSavePageAsBlock=(action 'onSavePageAsBlock') onCopyPage=(action 'onCopyPage') onMovePage=(action 'onMovePage') onDeletePage=(action 'onDeletePage')}} - {{#if expanded}} - {{section/base-renderer page=page}} - {{/if}} -
diff --git a/gui/app/templates/components/document/document-view.hbs b/gui/app/templates/components/document/document-view.hbs index 4dd6ed10..f5849e09 100644 --- a/gui/app/templates/components/document/document-view.hbs +++ b/gui/app/templates/components/document/document-view.hbs @@ -13,19 +13,10 @@
{{/if}} - {{#if (is-equal page.pageType 'section')}} - {{#document/document-page document=document folder=folder page=page permissions=permissions toEdit=toEdit pageId=pageId - onSavePage=(action 'onSavePage') onSavePageAsBlock=(action 'onSavePageAsBlock') - onCopyPage=(action 'onCopyPage') onMovePage=(action 'onMovePage') onDeletePage=(action 'onDeletePage')}} - {{/document/document-page}} - {{/if}} - - {{#if (is-equal page.pageType 'tab')}} - {{#document/document-tab document=document folder=folder page=page permissions=permissions pageId=pageId - onSavePage=(action 'onSavePage') onSavePageAsBlock=(action 'onSavePageAsBlock') - onCopyPage=(action 'onCopyPage') onMovePage=(action 'onMovePage') onDeletePage=(action 'onDeletePage')}} - {{/document/document-tab}} - {{/if}} + {{#document/document-page document=document folder=folder page=page permissions=permissions toEdit=toEdit pageId=pageId + onSavePage=(action 'onSavePage') onSavePageAsBlock=(action 'onSavePageAsBlock') + onCopyPage=(action 'onCopyPage') onMovePage=(action 'onMovePage') onDeletePage=(action 'onDeletePage')}} + {{/document/document-page}} {{/each}} {{#if permissions.documentEdit}} @@ -79,7 +70,7 @@
Reusable content
    {{#each blocks as |block|}} -
  • +
  • {{#link-to 'document.block' folder.id folder.slug document.id document.slug block.id}} mode_edit diff --git a/gui/app/templates/components/document/page-heading.hbs b/gui/app/templates/components/document/page-heading.hbs index cb44fa2a..dc152581 100644 --- a/gui/app/templates/components/document/page-heading.hbs +++ b/gui/app/templates/components/document/page-heading.hbs @@ -14,9 +14,17 @@
    {{#if permissions.documentEdit}}
    -
    - mode_edit -
    + {{#if (is-equal page.pageType 'tab')}} + {{#link-to 'document.section' page.id}} +
    + mode_edit +
    + {{/link-to}} + {{else}} +
    + mode_edit +
    + {{/if}} {{#if hasMenuPermissions}}