first commit
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Scroll To Top
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules
|
||||
*/
|
||||
|
||||
if ( class_exists( 'Powerkit_Module' ) ) {
|
||||
/**
|
||||
* Init module
|
||||
*/
|
||||
class Powerkit_Scroll_To_Top extends Powerkit_Module {
|
||||
|
||||
/**
|
||||
* Register module
|
||||
*/
|
||||
public function register() {
|
||||
$this->name = esc_html__( 'Scroll To Top Button', 'powerkit' );
|
||||
$this->desc = esc_html__( 'A simple and light-weight Scroll To Top button will appear automatically as soon as a user scrolls past the first screen.', 'powerkit' );
|
||||
$this->slug = 'scroll_to_top';
|
||||
$this->type = 'default';
|
||||
$this->category = 'basic';
|
||||
$this->priority = 180;
|
||||
$this->public = true;
|
||||
$this->enabled = true;
|
||||
$this->links = array(
|
||||
array(
|
||||
'name' => esc_html__( 'View documentation', 'powerkit' ),
|
||||
'url' => powerkit_get_setting( 'documentation' ) . '/utilities/scroll-to-top-button/',
|
||||
'target' => '_blank',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize module
|
||||
*/
|
||||
public function initialize() {
|
||||
|
||||
/* Load the required dependencies for this module */
|
||||
|
||||
// Admin and public area.
|
||||
require_once dirname( __FILE__ ) . '/public/class-powerkit-scroll-to-top-public.php';
|
||||
|
||||
new Powerkit_Scroll_To_Top_Public( $this->slug );
|
||||
}
|
||||
}
|
||||
|
||||
new Powerkit_Scroll_To_Top();
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* The public-facing functionality of the module.
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules/public
|
||||
*/
|
||||
|
||||
/**
|
||||
* The public-facing functionality of the module.
|
||||
*/
|
||||
class Powerkit_Scroll_To_Top_Public extends Powerkit_Module_Public {
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function initialize() {
|
||||
add_action( 'wp_footer', array( $this, 'wp_footer' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add html markup for the button.
|
||||
*/
|
||||
public function wp_footer() {
|
||||
ob_start();
|
||||
?>
|
||||
<a href="#top" class="pk-scroll-to-top">
|
||||
<i class="pk-icon pk-icon-up"></i>
|
||||
</a>
|
||||
<?php
|
||||
echo apply_filters( 'powerkit_scroll_to_top_template', ob_get_clean() ); // XSS.
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the stylesheets for the public-facing side of the site.
|
||||
*/
|
||||
public function wp_enqueue_scripts() {
|
||||
// Styles.
|
||||
wp_enqueue_style( 'powerkit-scroll-to-top', powerkit_style( plugin_dir_url( __FILE__ ) . 'css/public-powerkit-scroll-to-top.css' ), array(), powerkit_get_setting( 'version' ), 'all' );
|
||||
|
||||
// Scripts.
|
||||
wp_enqueue_script( 'powerkit-scroll-to-top', plugin_dir_url( __FILE__ ) . 'js/public-powerkit-scroll-to-top.js', array( 'jquery' ), powerkit_get_setting( 'version' ), true );
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* All of the CSS for your public-facing functionality should be
|
||||
* included in this file.
|
||||
*/
|
||||
/**
|
||||
* Environment for all styles (variables, additions, etc).
|
||||
*/
|
||||
/*--------------------------------------------------------------*/
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-scroll-to-top {
|
||||
--pk-scrolltop-background: #a0a0a0;
|
||||
--pk-scrolltop-icon-color: #FFFFFF;
|
||||
--pk-scrolltop-opacity: 1;
|
||||
--pk-scrolltop-opacity-hover: 0.7;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-scroll-to-top {
|
||||
background: var(--pk-scrolltop-background);
|
||||
display: none;
|
||||
position: fixed;
|
||||
right: -9999px;
|
||||
bottom: 2rem;
|
||||
opacity: 0;
|
||||
transition: opacity 0.25s;
|
||||
}
|
||||
|
||||
.pk-scroll-to-top.pk-active {
|
||||
opacity: var(--pk-scrolltop-opacity);
|
||||
right: auto;
|
||||
left: 2rem;
|
||||
}
|
||||
|
||||
.pk-scroll-to-top:hover {
|
||||
opacity: var(--pk-scrolltop-opacity-hover);
|
||||
}
|
||||
|
||||
.pk-scroll-to-top .pk-icon {
|
||||
display: block;
|
||||
padding: .6rem;
|
||||
color: var(--pk-scrolltop-icon-color);
|
||||
line-height: 1;
|
||||
transition: opacity .2s ease;
|
||||
}
|
||||
|
||||
@media (min-width: 760px) {
|
||||
.pk-scroll-to-top {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* All of the CSS for your public-facing functionality should be
|
||||
* included in this file.
|
||||
*/
|
||||
/**
|
||||
* Environment for all styles (variables, additions, etc).
|
||||
*/
|
||||
/*--------------------------------------------------------------*/
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-scroll-to-top {
|
||||
--pk-scrolltop-background: #a0a0a0;
|
||||
--pk-scrolltop-icon-color: #FFFFFF;
|
||||
--pk-scrolltop-opacity: 1;
|
||||
--pk-scrolltop-opacity-hover: 0.7;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-scroll-to-top {
|
||||
background: var(--pk-scrolltop-background);
|
||||
display: none;
|
||||
position: fixed;
|
||||
left: -9999px;
|
||||
bottom: 2rem;
|
||||
opacity: 0;
|
||||
transition: opacity 0.25s;
|
||||
}
|
||||
|
||||
.pk-scroll-to-top.pk-active {
|
||||
opacity: var(--pk-scrolltop-opacity);
|
||||
left: auto;
|
||||
right: 2rem;
|
||||
}
|
||||
|
||||
.pk-scroll-to-top:hover {
|
||||
opacity: var(--pk-scrolltop-opacity-hover);
|
||||
}
|
||||
|
||||
.pk-scroll-to-top .pk-icon {
|
||||
display: block;
|
||||
padding: .6rem;
|
||||
color: var(--pk-scrolltop-icon-color);
|
||||
line-height: 1;
|
||||
transition: opacity .2s ease;
|
||||
}
|
||||
|
||||
@media (min-width: 760px) {
|
||||
.pk-scroll-to-top {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Scroll To Top
|
||||
*/
|
||||
|
||||
( function( $ ) {
|
||||
|
||||
$( document ).ready( function() {
|
||||
|
||||
$( window ).scroll( function() {
|
||||
var offset = $( 'body' ).innerHeight() * 0.1;
|
||||
|
||||
if ( $( this ).scrollTop() > offset ) {
|
||||
$( '.pk-scroll-to-top' ).addClass( 'pk-active' );
|
||||
} else {
|
||||
$( '.pk-scroll-to-top' ).removeClass( 'pk-active' );
|
||||
}
|
||||
} );
|
||||
|
||||
$( '.pk-scroll-to-top' ).on( 'click', function() {
|
||||
|
||||
$( 'body, html' ).animate( {
|
||||
scrollTop: 0
|
||||
}, 400 );
|
||||
|
||||
return false;
|
||||
} );
|
||||
} );
|
||||
|
||||
} )( jQuery );
|
||||
Reference in New Issue
Block a user