Skip to content

Commit 2e9918f

Browse files
committed
reading progress bar feature
1 parent 1f32ccb commit 2e9918f

File tree

6 files changed

+76
-4
lines changed

6 files changed

+76
-4
lines changed

src/BlogEtcServiceProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ public function boot()
4343
__DIR__ . '/Views/blogetc' => base_path('resources/views/vendor/blogetc'),
4444
__DIR__ . '/Config/blogetc.php' => config_path('blogetc.php'),
4545
__DIR__ . '/css/blogetc_admin_css.css' => public_path('blogetc_admin_css.css'),
46+
__DIR__ . '/css/hessam-blog.css' => public_path('hessam-blog.css'),
47+
__DIR__ . '/js/hessam-blog.js' => public_path('hessam-blog.js'),
4648
]);
4749

4850

src/Config/blogetc.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44

55
return [
66

7-
//you custom User model
7+
//your custom User model
88
'user_model'=>\App\User::class,
99

10+
// reading progress bar is the bar which shows on top of your post when you are scrolling down the page. You can disable this feature if you want
11+
'reading_progress_bar' => true,
12+
1013
'include_default_routes' => true, // set to false to not include routes.php for BlogEtcReaderController and admin related routes. Default: true. If you disable this, you will have to manually copy over the data from routes.php and add it to your web.php.
1114

1215
'blog_prefix' => "blog", // used in routes.php. If you want to your http://yoursite.com/latest-news (or anything else), then enter that here. Default: blog
@@ -171,10 +174,8 @@
171174
],
172175
],
173176

174-
175177
'search' => [
176-
'search_enabled' => false, // is search enabled? By default this is disabled, but you can easily turn it on.
178+
'search_enabled' => true, //you can easily turn off search functionality
177179
],
178180

179-
180181
];

src/Views/blogetc/index.blade.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
@extends("layouts.app",['title'=>$title])
2+
3+
@section('blog-custom-css')
4+
<link type="text/css" href="{{ asset('hessam-blog.css') }}" rel="stylesheet">
5+
@endsection
6+
27
@section("content")
38

49
<div class='row'>

src/Views/blogetc/single_post.blade.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
@extends("layouts.app",['title'=>$post->gen_seo_title()])
2+
3+
@section('blog-custom-css')
4+
<link type="text/css" href="{{ asset('hessam-blog.css') }}" rel="stylesheet">
5+
@endsection
6+
27
@section("content")
38

9+
@if(config("blogetc.reading_progress_bar"))
10+
<div id="scrollbar">
11+
<div id="scrollbar-bg"></div>
12+
</div>
13+
@endif
414

515
{{--https://webdevetc.com/laravel/packages/blogetc-blog-system-for-your-laravel-app/help-documentation/laravel-blog-package-blogetc#guide_to_views--}}
616

@@ -26,4 +36,8 @@
2636
</div>
2737
</div>
2838

39+
@endsection
40+
41+
@section('blog-custom-js')
42+
<script src="{{asset('hessam-blog.js')}}"></script>
2943
@endsection

src/css/hessam-blog.css

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.cat2{
2+
padding-left: 20px !important;
3+
}
4+
5+
.cat3{
6+
padding-left: 40px !important;
7+
}
8+
9+
#scrollbar {
10+
position: fixed;
11+
top: 0;
12+
left: 0;
13+
overflow: hidden;
14+
width: 0%;
15+
height: 5px;
16+
z-index: 9999;
17+
}
18+
19+
#scrollbar-bg {
20+
position: absolute;
21+
top: 0;
22+
left: 0;
23+
width: 100%;
24+
height: 100%;
25+
background-color: #E16036;
26+
}

src/js/hessam-blog.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
var bar_bg = document.getElementById("scrollbar-bg"),
2+
body = document.body,
3+
html = document.documentElement;
4+
5+
bar_bg.style.minWidth = document.width + "px";
6+
7+
document.getElementsByTagName("body")[0].onresize = function() {
8+
// Update the gradient width
9+
bar_bg.style.minWidth = document.width + "px";
10+
};
11+
12+
window.onscroll = function() {
13+
// Change the width of the progress bar
14+
var bar = document.getElementById("scrollbar"),
15+
dw = document.documentElement.clientWidth,
16+
dh = Math.max( body.scrollHeight, body.offsetHeight,
17+
html.clientHeight, html.scrollHeight, html.offsetHeight ),
18+
wh = window.innerHeight,
19+
pos = pageYOffset || (document.documentElement.clientHeight ?
20+
document.documentElement.scrollTop : document.body.scrollTop),
21+
bw = ((pos / (dh - wh)) * 100);
22+
23+
bar.style.width = bw + "%";
24+
};

0 commit comments

Comments
 (0)