mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-05 09:34:37 +08:00
@ -4,6 +4,7 @@ module.exports = function (ngApp, events) {
|
||||
|
||||
ngApp.controller('ImageManagerController', ['$scope', '$attrs', '$http', '$timeout', 'imageManagerService',
|
||||
function ($scope, $attrs, $http, $timeout, imageManagerService) {
|
||||
|
||||
$scope.images = [];
|
||||
$scope.imageType = $attrs.imageType;
|
||||
$scope.selectedImage = false;
|
||||
@ -12,6 +13,7 @@ module.exports = function (ngApp, events) {
|
||||
$scope.hasMore = false;
|
||||
$scope.imageUpdateSuccess = false;
|
||||
$scope.imageDeleteSuccess = false;
|
||||
|
||||
var page = 0;
|
||||
var previousClickTime = 0;
|
||||
var dataLoaded = false;
|
||||
@ -221,8 +223,13 @@ module.exports = function (ngApp, events) {
|
||||
var pageId = Number($attrs.pageId);
|
||||
var isEdit = pageId !== 0;
|
||||
var autosaveFrequency = 30; // AutoSave interval in seconds.
|
||||
$scope.isDraft = Number($attrs.pageDraft) === 1;
|
||||
if ($scope.isDraft) $scope.draftText = 'Editing Draft';
|
||||
$scope.isUpdateDraft = Number($attrs.pageUpdateDraft) === 1;
|
||||
$scope.isNewPageDraft = Number($attrs.pageNewDraft) === 1;
|
||||
if ($scope.isUpdateDraft || $scope.isNewPageDraft) {
|
||||
$scope.draftText = 'Editing Draft'
|
||||
} else {
|
||||
$scope.draftText = 'Editing Page'
|
||||
};
|
||||
|
||||
var autoSave = false;
|
||||
|
||||
@ -254,7 +261,7 @@ module.exports = function (ngApp, events) {
|
||||
if (newTitle !== currentContent.title || newHtml !== currentContent.html) {
|
||||
currentContent.html = newHtml;
|
||||
currentContent.title = newTitle;
|
||||
saveDraftUpdate(newTitle, newHtml);
|
||||
saveDraft(newTitle, newHtml);
|
||||
}
|
||||
}, 1000 * autosaveFrequency);
|
||||
}
|
||||
@ -264,16 +271,22 @@ module.exports = function (ngApp, events) {
|
||||
* @param title
|
||||
* @param html
|
||||
*/
|
||||
function saveDraftUpdate(title, html) {
|
||||
function saveDraft(title, html) {
|
||||
$http.put('/ajax/page/' + pageId + '/save-draft', {
|
||||
name: title,
|
||||
html: html
|
||||
}).then((responseData) => {
|
||||
$scope.draftText = responseData.data.message;
|
||||
$scope.isDraft = true;
|
||||
if (!$scope.isNewPageDraft) $scope.isUpdateDraft = true;
|
||||
});
|
||||
}
|
||||
|
||||
$scope.forceDraftSave = function() {
|
||||
var newTitle = $('#name').val();
|
||||
var newHtml = $scope.editorHtml;
|
||||
saveDraft(newTitle, newHtml);
|
||||
};
|
||||
|
||||
/**
|
||||
* Discard the current draft and grab the current page
|
||||
* content from the system via an AJAX request.
|
||||
@ -281,10 +294,10 @@ module.exports = function (ngApp, events) {
|
||||
$scope.discardDraft = function () {
|
||||
$http.get('/ajax/page/' + pageId).then((responseData) => {
|
||||
if (autoSave) $interval.cancel(autoSave);
|
||||
$scope.draftText = '';
|
||||
$scope.isDraft = false;
|
||||
$scope.draftText = 'Editing Page';
|
||||
$scope.isUpdateDraft = false;
|
||||
$scope.$broadcast('html-update', responseData.data.html);
|
||||
$('#name').val(currentContent.title);
|
||||
$('#name').val(responseData.data.name);
|
||||
$timeout(() => {
|
||||
startAutoSave();
|
||||
}, 1000);
|
||||
|
@ -164,7 +164,6 @@ form.search-box {
|
||||
.faded span.faded-text {
|
||||
display: inline-block;
|
||||
padding: $-s;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.faded-small {
|
||||
|
@ -26,6 +26,12 @@
|
||||
.page {
|
||||
border-left: 5px solid $color-page;
|
||||
}
|
||||
.page.draft {
|
||||
border-left: 5px solid $color-page-draft;
|
||||
.text-page {
|
||||
color: $color-page-draft;
|
||||
}
|
||||
}
|
||||
.chapter {
|
||||
border-left: 5px solid $color-chapter;
|
||||
}
|
||||
@ -182,6 +188,12 @@
|
||||
background-color: rgba($color-page, 0.1);
|
||||
}
|
||||
}
|
||||
.list-item-page.draft {
|
||||
border-left: 5px solid $color-page-draft;
|
||||
}
|
||||
.page.draft .page, .list-item-page.draft a.page {
|
||||
color: $color-page-draft !important;
|
||||
}
|
||||
.sub-menu {
|
||||
display: none;
|
||||
padding-left: 0;
|
||||
@ -234,7 +246,6 @@
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
|
||||
.activity-list-item {
|
||||
padding: $-s 0;
|
||||
color: #888;
|
||||
@ -304,6 +315,9 @@ ul.pagination {
|
||||
font-size: 0.75em;
|
||||
margin-top: $-xs;
|
||||
}
|
||||
.page.draft .text-page {
|
||||
color: $color-page-draft;
|
||||
}
|
||||
}
|
||||
.entity-list.compact {
|
||||
font-size: 0.6em;
|
||||
|
@ -45,6 +45,7 @@ $primary-faded: rgba(21, 101, 192, 0.15);
|
||||
$color-book: #009688;
|
||||
$color-chapter: #ef7c3c;
|
||||
$color-page: $primary;
|
||||
$color-page-draft: #9A60DA;
|
||||
|
||||
// Text colours
|
||||
$text-dark: #444;
|
||||
|
@ -7,7 +7,7 @@
|
||||
<div class="row">
|
||||
<div class="col-md-4 faded">
|
||||
<div class="breadcrumbs">
|
||||
<a href="{{$book->getUrl()}}" class="text-book text-button"><i class="zmdi zmdi-book"></i>{{ $book->name }}</a>
|
||||
<a href="{{$book->getUrl()}}" class="text-book text-button"><i class="zmdi zmdi-book"></i>{{ $book->getShortName() }}</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-8 faded">
|
||||
|
@ -23,6 +23,12 @@
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm-4">
|
||||
<div id="recent-drafts">
|
||||
@if(count($draftPages) > 0)
|
||||
<h3>My Recent Drafts</h3>
|
||||
@include('partials/entity-list', ['entities' => $draftPages, 'style' => 'compact'])
|
||||
@endif
|
||||
</div>
|
||||
@if($signedIn)
|
||||
<h3>My Recently Viewed</h3>
|
||||
@else
|
||||
|
@ -1,7 +1,7 @@
|
||||
@extends('base')
|
||||
|
||||
@section('head')
|
||||
<script src="/libs/tinymce/tinymce.min.js?ver=4.3.2"></script>
|
||||
<script src="/libs/tinymce/tinymce.min.js?ver=4.3.7"></script>
|
||||
@stop
|
||||
|
||||
@section('body-class', 'flexbox')
|
||||
@ -9,11 +9,8 @@
|
||||
@section('content')
|
||||
|
||||
<div class="flex-fill flex">
|
||||
<form action="{{$book->getUrl() . '/page'}}" method="POST" class="flex flex-fill">
|
||||
@include('pages/form')
|
||||
@if($chapter)
|
||||
<input type="hidden" name="chapter" value="{{$chapter->id}}">
|
||||
@endif
|
||||
<form action="{{$book->getUrl() . '/page/' . $draft->id}}" method="POST" class="flex flex-fill">
|
||||
@include('pages/form', ['model' => $draft])
|
||||
</form>
|
||||
</div>
|
||||
@include('partials/image-manager', ['imageType' => 'gallery'])
|
||||
|
@ -3,8 +3,8 @@
|
||||
@section('content')
|
||||
|
||||
<div class="container small" ng-non-bindable>
|
||||
<h1>Delete Page</h1>
|
||||
<p class="text-neg">Are you sure you want to delete this page?</p>
|
||||
<h1>Delete {{ $page->draft ? 'Draft' : '' }} Page</h1>
|
||||
<p class="text-neg">Are you sure you want to delete this {{ $page->draft ? 'draft' : '' }} page?</p>
|
||||
|
||||
<form action="{{$page->getUrl()}}" method="POST">
|
||||
{!! csrf_field() !!}
|
||||
|
@ -1,7 +1,7 @@
|
||||
@extends('base')
|
||||
|
||||
@section('head')
|
||||
<script src="/libs/tinymce/tinymce.min.js?ver=4.3.2"></script>
|
||||
<script src="/libs/tinymce/tinymce.min.js?ver=4.3.7"></script>
|
||||
@stop
|
||||
|
||||
@section('body-class', 'flexbox')
|
||||
|
@ -1,7 +1,5 @@
|
||||
|
||||
|
||||
|
||||
<div class="page-editor flex-fill flex" ng-controller="PageEditController" page-id="{{ $model->id or 0 }}" page-draft="{{ $page->isDraft or 0 }}">
|
||||
<div class="page-editor flex-fill flex" ng-controller="PageEditController" page-id="{{ $model->id or 0 }}" page-new-draft="{{ $model->draft or 0 }}" page-update-draft="{{ $model->isDraft or 0 }}">
|
||||
|
||||
{{ csrf_field() }}
|
||||
<div class="faded-small toolbar">
|
||||
@ -14,11 +12,23 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-4 faded text-center">
|
||||
<span class="faded-text" ng-bind="draftText"></span>
|
||||
|
||||
<div dropdown class="dropdown-container">
|
||||
<a dropdown-toggle class="text-primary text-button"><span class="faded-text" ng-bind="draftText"></span> <i class="zmdi zmdi-more-vert"></i></a>
|
||||
<ul>
|
||||
<li>
|
||||
<a ng-click="forceDraftSave()" class="text-pos"><i class="zmdi zmdi-save"></i>Save Draft</a>
|
||||
</li>
|
||||
<li ng-if="isNewPageDraft">
|
||||
<a href="{{$model->getUrl()}}/delete" class="text-neg"><i class="zmdi zmdi-delete"></i>Delete Draft</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-4 faded">
|
||||
<div class="action-buttons" ng-cloak>
|
||||
<button type="button" ng-if="isDraft" ng-click="discardDraft()" class="text-button text-neg"><i class="zmdi zmdi-close-circle"></i>Discard Draft</button>
|
||||
|
||||
<button type="button" ng-if="isUpdateDraft" ng-click="discardDraft()" class="text-button text-neg"><i class="zmdi zmdi-close-circle"></i>Discard Draft</button>
|
||||
<button type="submit" id="save-button" class="text-button text-pos"><i class="zmdi zmdi-floppy"></i>Save Page</button>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<div class="page">
|
||||
<div class="page {{$page->draft ? 'draft' : ''}}">
|
||||
<h3>
|
||||
<a href="{{ $page->getUrl() }}" class="text-page"><i class="zmdi zmdi-file-text"></i>{{ $page->name }}</a>
|
||||
</h3>
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
|
||||
@foreach($sidebarTree as $bookChild)
|
||||
<li class="list-item-{{ $bookChild->getClassName() }} {{ $bookChild->getClassName() }}">
|
||||
<li class="list-item-{{ $bookChild->getClassName() }} {{ $bookChild->getClassName() }} {{ $bookChild->isA('page') && $bookChild->draft ? 'draft' : '' }}">
|
||||
<a href="{{$bookChild->getUrl()}}" class="{{ $bookChild->getClassName() }} {{ $current->matches($bookChild)? 'selected' : '' }}">
|
||||
@if($bookChild->isA('chapter'))<i class="zmdi zmdi-collection-bookmark"></i>@else <i class="zmdi zmdi-file-text"></i>@endif{{ $bookChild->name }}
|
||||
</a>
|
||||
@ -17,7 +17,7 @@
|
||||
</p>
|
||||
<ul class="menu sub-menu inset-list @if($bookChild->matchesOrContains($current)) open @endif">
|
||||
@foreach($bookChild->pages as $childPage)
|
||||
<li class="list-item-page">
|
||||
<li class="list-item-page {{ $childPage->isA('page') && $childPage->draft ? 'draft' : '' }}">
|
||||
<a href="{{$childPage->getUrl()}}" class="page {{ $current->matches($childPage)? 'selected' : '' }}">
|
||||
<i class="zmdi zmdi-file-text"></i> {{ $childPage->name }}
|
||||
</a>
|
||||
|
Reference in New Issue
Block a user