]> BookStack Code Mirror - bookstack/blob - resources/views/pages/show.blade.php
9767791203f5e79ed4286cb7784fb2a0427e5f6f
[bookstack] / resources / views / pages / show.blade.php
1 @extends('base')
2
3 @section('sidebar')
4     <div class="book-tree">
5         <h4><a href="{{$book->getUrl()}}"><i class="fa fa-book"></i>{{$book->name}}</a></h4>
6         @include('pages/sidebar-tree-list', ['book' => $book])
7     </div>
8 @stop
9
10 @section('content')
11
12     <div class="row faded-small">
13         <div class="col-md-6 faded">
14             <div class="breadcrumbs padded-horizontal">
15                 <a href="{{$book->getUrl()}}"><i class="fa fa-book"></i>{{ $book->name }}</a>
16                 @if($breadCrumbs)
17                     @foreach($breadCrumbs as $parentPage)
18                         <span class="sep">&gt;</span>
19                         <a href="{{$parentPage->getUrl()}}">{{ $parentPage->name }}</a>
20                     @endforeach
21                 @endif
22             </div>
23         </div>
24         <div class="col-md-6 faded">
25             <div class="action-buttons">
26                 <a href="{{$page->getUrl() . '/edit'}}" ><i class="fa fa-pencil"></i>Edit</a>
27                 <a href="{{$page->getUrl() . '/delete'}}"><i class="fa fa-trash"></i>Delete</a>
28             </div>
29         </div>
30     </div>
31
32     <div class="side-nav faded">
33         <h4>Page Navigation</h4>
34         <ul class="page-nav-list">
35         </ul>
36     </div>
37
38
39     <div class="page-content">
40         <h1>{{$page->name}}</h1>
41         @if(count($page->children) > 0)
42             <h4 class="text-muted">Sub-pages</h4>
43             <div class="page-list">
44                 @foreach($page->children as $childPage)
45                     <a href="{{ $childPage->getUrl() }}">{{ $childPage->name }}</a>
46                 @endforeach
47             </div>
48         @endif
49         {!! $page->html !!}
50     </div>
51
52
53     <script>
54         $(document).ready(function() {
55
56             // Set up document navigation
57             var pageNav = $('.page-nav-list');
58             var pageContent = $('.page-content');
59             var headers = pageContent.find('h1, h2, h3, h4, h5, h6');
60             headers.each(function() {
61                 var header = $(this);
62                 var tag = header.prop('tagName');
63                 var listElem = $('<li></li>').addClass('nav-'+tag);
64                 var link = $('<a></a>').text(header.text().trim()).attr('href', '#');
65                 listElem.append(link);
66                 pageNav.append(listElem);
67                 link.click(function(e) {
68                     e.preventDefault();
69                     header.smoothScrollTo();
70                 })
71             });
72
73             // Set up link hooks
74             var pageId = {{$page->id}};
75             headers.each(function() {
76                 var text = $(this).text().trim();
77                 var link = '/link/' + pageId + '#' + encodeURIComponent(text);
78                 var linkHook = $('<a class="link-hook"><i class="fa fa-link"></i></a>')
79                         .attr({"data-content": link, href: link, target: '_blank'});
80                 linkHook.click(function(e) {
81                     e.preventDefault();
82                     goToText(text);
83                 });
84                 $(this).append(linkHook);
85             });
86
87             function goToText(text) {
88                 $('.page-content').find(':contains("'+text+'")').smoothScrollTo();
89             }
90
91             if(window.location.hash) {
92                 var text = window.location.hash.replace(/\%20/g, ' ').substr(1);
93                 goToText(text);
94             }
95
96             //$('[data-toggle="popover"]').popover()
97         });
98     </script>
99 @stop