|
|
@@ -218,128 +218,7 @@ $(() => {
|
|
|
$(this).select();
|
|
|
});
|
|
|
|
|
|
- // rename
|
|
|
- $('#renamePage').on('shown.bs.modal', (e) => {
|
|
|
- $('#renamePage #newPageName').focus();
|
|
|
- $('#renamePage .msg').hide();
|
|
|
- });
|
|
|
- $('#renamePageForm').submit(function(e) {
|
|
|
- // create name-value map
|
|
|
- const nameValueMap = {};
|
|
|
- $(this).serializeArray().forEach((obj) => {
|
|
|
- nameValueMap[obj.name] = obj.value; // nameValueMap.new_path is renamed page path
|
|
|
- });
|
|
|
- nameValueMap.socketClientId = websocketContainer.getSocketClientId();
|
|
|
-
|
|
|
- $.ajax({
|
|
|
- type: 'POST',
|
|
|
- url: '/_api/pages.rename',
|
|
|
- data: nameValueMap,
|
|
|
- dataType: 'json',
|
|
|
- })
|
|
|
- .done((res) => {
|
|
|
- // error
|
|
|
- if (!res.ok) {
|
|
|
- const linkPath = pathUtils.normalizePath(nameValueMap.new_path);
|
|
|
- $('#renamePage .msg').hide();
|
|
|
- $(`#renamePage .msg-${res.code}`).show();
|
|
|
- $('#renamePage #linkToNewPage').html(`
|
|
|
- <a href="${linkPath}">${linkPath} <i class="icon-login"></i></a>
|
|
|
- `);
|
|
|
- }
|
|
|
- else {
|
|
|
- const page = res.page;
|
|
|
- window.location.href = `${page.path}?renamed=${pagePath}`;
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- return false;
|
|
|
- });
|
|
|
-
|
|
|
- // empty trash
|
|
|
- $('#emptyTrash').on('shown.bs.modal', (e) => {
|
|
|
- $('#emptyTrash .msg').hide();
|
|
|
- });
|
|
|
- $('#empty-trash-form').submit((e) => {
|
|
|
- // create name-value map
|
|
|
- const nameValueMap = {};
|
|
|
- $('#empty-trash-form').serializeArray().forEach((obj) => {
|
|
|
- nameValueMap[obj.name] = obj.value;
|
|
|
- });
|
|
|
- $.ajax({
|
|
|
- type: 'DELETE',
|
|
|
- url: '/_api/v3/pages/empty-trash',
|
|
|
- data: nameValueMap,
|
|
|
- dataType: 'json',
|
|
|
- }).done((res) => {
|
|
|
- window.location.href = '/trash';
|
|
|
- }).fail((jqXHR, textStatus, errorThrown) => {
|
|
|
- $('#emptyTrash .msg').hide();
|
|
|
- $('#emptyTrash .msg-unknown').show();
|
|
|
- });
|
|
|
-
|
|
|
- return false;
|
|
|
- });
|
|
|
-
|
|
|
- // Put Back
|
|
|
- $('#putBackPage').on('shown.bs.modal', (e) => {
|
|
|
- $('#putBackPage .msg').hide();
|
|
|
- });
|
|
|
- $('#revert-delete-page-form').submit((e) => {
|
|
|
- $.ajax({
|
|
|
- type: 'POST',
|
|
|
- url: '/_api/pages.revertRemove',
|
|
|
- data: $('#revert-delete-page-form').serialize(),
|
|
|
- dataType: 'json',
|
|
|
- }).done((res) => {
|
|
|
- // error
|
|
|
- if (!res.ok) {
|
|
|
- $('#putBackPage .msg').hide();
|
|
|
- $(`#putBackPage .msg-${res.code}`).show();
|
|
|
- }
|
|
|
- else {
|
|
|
- const page = res.page;
|
|
|
- window.location.href = page.path;
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- return false;
|
|
|
- });
|
|
|
-
|
|
|
- $('#create-portal-button').on('click', (e) => {
|
|
|
- $('a[data-toggle="tab"][href="#edit"]').tab('show');
|
|
|
-
|
|
|
- $('body').addClass('on-edit');
|
|
|
- $('body').addClass('builtin-editor');
|
|
|
-
|
|
|
- const path = $('.content-main').data('path');
|
|
|
- if (path !== '/' && $('.content-main').data('page-id') === '') {
|
|
|
- const upperPage = path.substr(0, path.length - 1);
|
|
|
- $.get('/_api/pages.get', { path: upperPage }, (res) => {
|
|
|
- if (res.ok && res.page) {
|
|
|
- $('#portal-warning-modal').modal('show');
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- $('#portal-form-close').on('click', (e) => {
|
|
|
- $('#edit').removeClass('active');
|
|
|
- $('body').removeClass('on-edit');
|
|
|
- $('body').removeClass('builtin-editor');
|
|
|
- window.location.hash = '#';
|
|
|
- });
|
|
|
-
|
|
|
if (pageId) {
|
|
|
- // for Crowi Template LangProcessor
|
|
|
- $('.template-create-button', $('#revision-body')).on('click', function() {
|
|
|
- const path = $(this).data('path');
|
|
|
- const templateId = $(this).data('template');
|
|
|
- const template = $(`#${templateId}`).html();
|
|
|
-
|
|
|
- const editorContainer = appContainer.getContainer('EditorContainer');
|
|
|
- editorContainer.saveDraft(path, template);
|
|
|
- window.location.href = `${path}#edit`;
|
|
|
- });
|
|
|
|
|
|
if (!isSeen) {
|
|
|
$.post('/_api/pages.seen', { page_id: pageId }, (res) => {
|