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