1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-08-07 23:03:00 +03:00

Updated page pointer to sit near mouse location and extracted page js into browserify bundle

This commit is contained in:
Dan Brown
2015-12-30 20:48:57 +00:00
parent cca3533d35
commit a592eaeb91
5 changed files with 90 additions and 65 deletions

View File

@@ -80,5 +80,6 @@
@yield('bottom')
<script src="{{ versioned_asset('js/common.js') }}"></script>
@yield('scripts')
</body>
</html>

View File

@@ -33,7 +33,7 @@
</div>
<div class="container">
<div class="container" id="page-show">
<div class="row">
<div class="col-md-9 print-full-width">
<div class="page-content anim fadeIn">
@@ -66,62 +66,11 @@
</div>
</div>
<script>
$(document).ready(function() {
// Set up pointer
var $pointer = $('#pointer').detach();
var pageId = {{$page->id}};
var isSelection = false;
$pointer.find('input').click(function(e){$(this).select();e.stopPropagation();});
new ZeroClipboard( $pointer.find('button').first()[0] );
$(document.body).find('*').on('click focus', function(e) {
if(!isSelection) {
$pointer.detach();
}
});
$('.page-content [id^="bkmrk"]').on('mouseup keyup', function(e) {
var selection = window.getSelection();
if(selection.toString().length === 0) return;
// Show pointer and set link
var $elem = $(this);
var link = window.location.protocol + "//" + window.location.host + '/link/' + pageId + '#' + $elem.attr('id');
$pointer.find('input').val(link);
$pointer.find('button').first().attr('data-clipboard-text', link);
$elem.before($pointer);
$pointer.show();
e.stopPropagation();
isSelection = true;
setTimeout(function() {
isSelection = false;
}, 100);
});
function goToText(text) {
var idElem = $('.page-content').find('#' + text).first();
if(idElem.length !== 0) {
idElem.smoothScrollTo();
} else {
$('.page-content').find(':contains("'+text+'")').smoothScrollTo();
}
}
if(window.location.hash) {
var text = window.location.hash.replace(/\%20/g, ' ').substr(1);
goToText(text);
}
});
</script>
@include('partials/highlight')
@stop
@section('scripts')
<script>
setupPageShow({{$page->id}});
</script>
@stop