-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.php
66 lines (52 loc) · 1.73 KB
/
plugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
class kokenback2top extends KokenPlugin {
function __construct()
{
$this->require_setup = true;
$this->register_hook('before_closing_head', 'customcss');
$this->register_hook('before_closing_head', 'back2top');
}
function customcss()
{
if( $this->data->custom_css !== ""){
?><style> .back2top_button{ <?php
echo $this->data->custom_css;
?>}</style> <?php
}
else{
?>
<link rel="stylesheet" type="text/css" href="/storage/plugins/koken-plugin-back2top/css/back2top.css">
<?php
}
}
function back2top()
{
?>
<script>
$(document).ready(function(){
/* create the button and bind it to the end of body*/
var back_to_top_button = ['<a href="#top" class="back2top_button"></a>'].join("");
$("body").append(back_to_top_button)
/*hide the button*/
$(".back2top_button").hide();
/* function for scroll */
$(function () {
$(window).scroll(function () {
if ($(this).scrollTop() > 200) { /* if 200 pixel scrolled down, fade in button */
$('.back2top_button').fadeIn();
} else {
$('.back2top_button').fadeOut();
}
});
$('.back2top_button').click(function () { /* click the button */
$('body,html').animate({
scrollTop: 0
}, 800);
return false;
});
});
});
</script>
<?php
}
}