mirror of
https://github.com/documize/community.git
synced 2025-07-24 07:39:43 +02:00
jump to page
This commit is contained in:
parent
8d2dcf376f
commit
f0590139b1
6 changed files with 20 additions and 112 deletions
|
@ -62,6 +62,16 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
|||
// out
|
||||
$(this).find('.start-button').velocity("transition.slideUpOut", {duration: 300});
|
||||
} });
|
||||
|
||||
let jumpTo = this.get('pageId');
|
||||
if (is.not.empty(jumpTo)) {
|
||||
let self = this;
|
||||
$("#page-" + jumpTo).velocity("scroll", { duration: 250, offset: -100, complete:
|
||||
function() {
|
||||
self.set('pageId', '');
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
|
@ -125,6 +135,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
|||
model.page.sequence = sequence;
|
||||
|
||||
this.send('onHideSectionWizard');
|
||||
this.set('pageId', '');
|
||||
|
||||
const promise = this.get('onInsertSection')(model);
|
||||
promise.then((id) => {
|
||||
|
|
|
@ -16,36 +16,10 @@ export default Ember.Controller.extend(NotifierMixin, {
|
|||
documentService: Ember.inject.service('document'),
|
||||
templateService: Ember.inject.service('template'),
|
||||
sectionService: Ember.inject.service('section'),
|
||||
page: null,
|
||||
folder: {},
|
||||
pages: [],
|
||||
toggled: false,
|
||||
|
||||
// to test
|
||||
// to test
|
||||
// Jump to the right part of the document.
|
||||
scrollToPage(pageId) {
|
||||
Ember.run.schedule('afterRender', function () {
|
||||
let dest;
|
||||
let target = "#page-title-" + pageId;
|
||||
let targetOffset = $(target).offset();
|
||||
|
||||
if (is.undefined(targetOffset)) {
|
||||
return;
|
||||
}
|
||||
|
||||
dest = targetOffset.top > $(document).height() - $(window).height() ? $(document).height() - $(window).height() : targetOffset.top;
|
||||
// small correction to ensure we also show page title
|
||||
dest = dest > 50 ? dest - 74 : dest;
|
||||
|
||||
$("html,body").animate({
|
||||
scrollTop: dest
|
||||
}, 500, "linear");
|
||||
$(".toc-index-item").removeClass("selected");
|
||||
$("#index-" + pageId).addClass("selected");
|
||||
});
|
||||
},
|
||||
|
||||
actions: {
|
||||
toggleSidebar() {
|
||||
this.set('toggled', !this.get('toggled'));
|
||||
|
@ -218,15 +192,6 @@ export default Ember.Controller.extend(NotifierMixin, {
|
|||
});
|
||||
},
|
||||
|
||||
// to test
|
||||
gotoPage(pageId) {
|
||||
if (is.null(pageId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.scrollToPage(pageId);
|
||||
},
|
||||
|
||||
// to test
|
||||
onSavePageAsBlock(block) {
|
||||
this.get('sectionService').addBlock(block).then(() => {
|
||||
|
@ -237,71 +202,6 @@ export default Ember.Controller.extend(NotifierMixin, {
|
|||
});
|
||||
|
||||
/*
|
||||
gotoPage(pageId) {
|
||||
if (is.null(pageId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.scrollToPage(pageId);
|
||||
},
|
||||
|
||||
|
||||
onSaveTemplate(name, desc) {
|
||||
this.get('templateService').saveAsTemplate(this.get('model.document.id'), name, desc).then(function () {});
|
||||
},
|
||||
|
||||
onSaveMeta(doc) {
|
||||
this.get('documentService').save(doc).then(() => {
|
||||
this.transitionToRoute('document.index');
|
||||
});
|
||||
},
|
||||
|
||||
onInsertBlock(block) {
|
||||
this.audit.record("added-content-block-" + block.get('contentType'));
|
||||
|
||||
let page = {
|
||||
documentId: this.get('model.document.id'),
|
||||
title: `${block.get('title')}`,
|
||||
level: 1,
|
||||
sequence: 0,
|
||||
body: block.get('body'),
|
||||
contentType: block.get('contentType'),
|
||||
pageType: block.get('pageType'),
|
||||
blockId: block.get('id')
|
||||
};
|
||||
|
||||
let meta = {
|
||||
documentId: this.get('model.document.id'),
|
||||
rawBody: block.get('rawBody'),
|
||||
config: block.get('config'),
|
||||
externalSource: block.get('externalSource')
|
||||
};
|
||||
|
||||
let model = {
|
||||
page: page,
|
||||
meta: meta
|
||||
};
|
||||
|
||||
this.get('documentService').addPage(this.get('model.document.id'), model).then((newPage) => {
|
||||
let data = this.get('store').normalize('page', newPage);
|
||||
this.get('store').push(data);
|
||||
|
||||
this.get('documentService').getPages(this.get('model.document.id')).then((pages) => {
|
||||
this.set('model.pages', pages.filterBy('pageType', 'section'));
|
||||
this.set('model.tabs', pages.filterBy('pageType', 'tab'));
|
||||
|
||||
this.get('documentService').getPageMeta(this.get('model.document.id'), newPage.id).then(() => {
|
||||
this.transitionToRoute('document.edit',
|
||||
this.get('model.folder.id'),
|
||||
this.get('model.folder.slug'),
|
||||
this.get('model.document.id'),
|
||||
this.get('model.document.slug'),
|
||||
newPage.id);
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
onDeleteBlock(blockId) {
|
||||
this.get('sectionService').deleteBlock(blockId).then(() => {
|
||||
this.audit.record("deleted-block");
|
||||
|
@ -317,5 +217,4 @@ onDocumentDelete() {
|
|||
this.transitionToRoute('folder', this.get('model.folder.id'), this.get('model.folder.slug'));
|
||||
});
|
||||
}
|
||||
|
||||
*/
|
||||
|
|
|
@ -18,13 +18,13 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
|||
folderService: Ember.inject.service('folder'),
|
||||
userService: Ember.inject.service('user'),
|
||||
queryParams: {
|
||||
page: {
|
||||
pageId: {
|
||||
refreshModel: false
|
||||
}
|
||||
},
|
||||
|
||||
beforeModel(transition) {
|
||||
this.set('pageId', is.not.undefined(transition.queryParams.page) ? transition.queryParams.page : "");
|
||||
this.set('pageId', is.not.undefined(transition.queryParams.pageId) ? transition.queryParams.pageId : '');
|
||||
},
|
||||
|
||||
model() {
|
||||
|
@ -36,7 +36,7 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
|||
folders: this.modelFor('document').folders,
|
||||
folder: this.modelFor('document').folder,
|
||||
document: this.modelFor('document').document,
|
||||
page: this.get('pageId'),
|
||||
pageId: this.get('pageId'),
|
||||
isEditor: this.get('folderService').get('canEditCurrentFolder'),
|
||||
pages: this.modelFor('document').pages,
|
||||
links: this.modelFor('document').links,
|
||||
|
|
|
@ -64,7 +64,10 @@
|
|||
</div>
|
||||
{{document/document-heading document=model.document isEditor=model.isEditor onSaveDocument=(action 'onSaveDocument')}}
|
||||
{{document/document-view document=model.document links=model.links pages=model.pages
|
||||
folder=model.folder folders=model.folders sections=model.sections isEditor=model.isEditor onSavePage=(action 'onSavePage') gotoPage=(action 'gotoPage') onInsertSection=(action 'onInsertSection') onSavePageAsBlock=(action 'onSavePageAsBlock') onCopyPage=(action 'onCopyPage') onMovePage=(action 'onMovePage') onDeletePage=(action 'onPageDeleted') onEditSection=(action 'onEditSection')}}
|
||||
folder=model.folder folders=model.folders sections=model.sections isEditor=model.isEditor pageId=pageId
|
||||
onSavePage=(action 'onSavePage') onInsertSection=(action 'onInsertSection')
|
||||
onSavePageAsBlock=(action 'onSavePageAsBlock') onCopyPage=(action 'onCopyPage') onMovePage=(action 'onMovePage')
|
||||
onDeletePage=(action 'onPageDeleted') onEditSection=(action 'onEditSection')}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -43,7 +43,8 @@ export default Ember.Controller.extend(NotifierMixin, {
|
|||
this.get('model.folder.id'),
|
||||
this.get('model.folder.slug'),
|
||||
this.get('model.document.id'),
|
||||
this.get('model.document.slug'));
|
||||
this.get('model.document.slug'),
|
||||
{ queryParams: { pageId: page.id }});
|
||||
});
|
||||
},
|
||||
}
|
||||
|
|
|
@ -41,12 +41,6 @@ export default Router.map(function () {
|
|||
this.route('section', {
|
||||
path: 'section/:page_id'
|
||||
});
|
||||
// this.route('edit', {
|
||||
// path: 'edit/:page_id'
|
||||
// });
|
||||
// this.route('wizard', {
|
||||
// path: 'add'
|
||||
// });
|
||||
this.route('history', {
|
||||
path: 'history'
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue