Skip to content

Commit

Permalink
Remove js log and add function comments #312
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimp2t committed Sep 8, 2018
1 parent 128d660 commit 7351a61
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
5 changes: 2 additions & 3 deletions assets/js/jquery.bully.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
if ($( '#masthead' ).hasClass( 'is-sticky' ) ) {
top = $( '#masthead' ).outerHeight();
}
console.log( '----------------', lastItemId );

$.each( elements, function( i, element ) {
if ( lastScrollY >= element.offset.top - top - windowHeight / 2 ) {
count = count + 1;
inverse = lastScrollY < element.offset.top - top + element.height - windowHeight / 2;
lastItemId = element.element.id;
console.log( 'lastItemId', lastItemId );

}

} );
Expand All @@ -51,7 +51,6 @@

// New insverse
if ( lastItemId && typeof Onepress_Bully.sections[ lastItemId ] !== "undefined" ) {
console.log( '==: ' + lastItemId, Onepress_Bully.sections[ lastItemId ].inverse );
if ( Onepress_Bully.sections[ lastItemId ].inverse ) {
$bully.addClass( 'c-bully--inversed' );
} else {
Expand Down
45 changes: 44 additions & 1 deletion inc/class-sections-navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,23 @@ class Onepress_Dots_Navigation {
static $_instance = null;
private $key = 'onepress_sections_nav_';

/**
* Get instance
*
* @return null|Onepress_Dots_Navigation
*/
static function get_instance(){
if ( is_null( self::$_instance ) ){
self::$_instance = new self();
}
return self::$_instance;
}

/**
* Get sections
*
* @return array
*/
function get_sections(){

$sorted_sections = apply_filters( 'onepress_frontpage_sections_order', array(
Expand Down Expand Up @@ -91,15 +101,28 @@ function get_sections(){
$new[ $id ] = $sections_config[ $id ];
}
}

// Filter to add more custom sections here
return apply_filters( 'onepress_sections_navigation_get_sections', $new );

}

/**
* Get setting name
*
* @param $id
*
* @return string
*/
function get_name( $id ) {
return $this->key.$id;
}

/**
* Add customize config
*
* @param $wp_customize
* @param $section_id
*/
function add_customize( $wp_customize, $section_id ){

$wp_customize->add_setting( $this->get_name( '__enable' ),
Expand Down Expand Up @@ -227,6 +250,12 @@ function add_customize( $wp_customize, $section_id ){

}

/**
*
* Get sections settings
*
* @return array
*/
function get_settings(){

$data = apply_filters( 'onepress_dots_navigation_get_settings', false );
Expand Down Expand Up @@ -266,6 +295,10 @@ function get_settings(){
return $data;
}

/**
* Add scripts
* load only enabled
*/
function scripts(){
if ( get_theme_mod( $this->get_name( '__enable' ), false ) ) {
if ( is_front_page() ) {
Expand All @@ -278,6 +311,13 @@ function scripts(){
}
}

/**
* Add custom style
* load only enabled
* @param $code
*
* @return string
*/
function custom_style( $code ){
if ( get_theme_mod( $this->get_name( '__enable' ), false ) ) {
$color = sanitize_hex_color_no_hash( get_theme_mod( $this->get_name( '__color' ) ) );
Expand All @@ -293,6 +333,9 @@ function custom_style( $code ){
return $code;
}

/**
* Inits
*/
function init(){
add_action( 'wp_enqueue_scripts', array( $this, 'scripts' ) );
add_action( 'onepress_custom_css', array( $this, 'custom_style' ) );
Expand Down

0 comments on commit 7351a61

Please sign in to comment.