Skip to content

Commit

Permalink
Merge branch 'issue/787'
Browse files Browse the repository at this point in the history
  • Loading branch information
Dima committed Oct 4, 2017
2 parents 11c0fa8 + eccf5a6 commit 2811c7a
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 5 deletions.
29 changes: 28 additions & 1 deletion includes/header-footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,19 @@ function dslc_hf_init() {
),
),
),
array(
'label' => __( '', 'live-composer-page-builder' ),
'std' => '',
'descr' => __( 'Add extra bottom padding on the top of the page under the header.' ),
'id' => 'dslc_extra_padding',
'type' => 'checkbox',
'choices' => array(
array(
'label' => 'Bottom padding',
'value' => 'bottom_padding',
),
),
),
),
);

Expand Down Expand Up @@ -557,6 +570,20 @@ function dslc_hf_get_headerfooter( $post_id = false, $hf_type = 'header' ) {
$position = 'relative';
}

$header_padding = get_post_meta( $hf_id, 'dslc_extra_padding', true );

if ( ! empty( $header_padding ) ) {
$header_padding = 'dslc-header-extra-padding';
} else {
$header_padding = '';
}

// If the "position" option value exists
if ( ! $position ) {
// Set the "position" option value to default "relative"
$position = 'relative';
}

// Code to insert before.
$code_before = apply_filters( 'dslc_' . $hf_type . '_before', '' );

Expand Down Expand Up @@ -631,7 +658,7 @@ function dslc_hf_get_headerfooter( $post_id = false, $hf_type = 'header' ) {

// if ( ! empty( $rendered_code ) && ! dslc_is_editor_active() ) {
if ( ! empty( $rendered_code ) ) {
$rendered_code = '<div id="dslc-' . $hf_type . '" class="dslc-' . $hf_type . '-pos-' . $position . '" data-hf ' . $editing_parametters . '>' . $rendered_code . $append . '</div>';
$rendered_code = '<div id="dslc-' . $hf_type . '" class="dslc-' . $hf_type . '-pos-' . $position . ' ' . $header_padding .'" data-hf ' . $editing_parametters . '>' . $rendered_code . $append . '</div>';
}

$rendered_code = $code_before . $wrapper_start . $rendered_code . $wrapper_end . $code_after;
Expand Down
48 changes: 48 additions & 0 deletions includes/post-options-framework/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,52 @@ jQuery(document).ready(function(){
jQuery('#post-option-dslc_template_base').hide();
}

/**
* Header - Show/Hide extra padding
*/

var headerFor = jQuery("select#dslc_hf_for").val();

if ( headerFor == 'footer' ) {
jQuery("#post-option-dslc_extra_padding").hide();
jQuery('#post-option-dslc_extra_padding input[type="checkbox"]').val('');
}

jQuery(document).on('change', 'select#dslc_hf_for', function(e) {

var option = jQuery(this).val();

if ( option == 'footer' ) {
jQuery("#post-option-dslc_extra_padding").hide();
jQuery('#post-option-dslc_extra_padding input[type="checkbox"]').val('');
} else {
jQuery('#post-option-dslc_hf_position input[type="radio"]#dslc_hf_position0').prop('checked', true);
jQuery('#post-option-dslc_extra_padding input[type="checkbox"]').val('');
jQuery('#post-option-dslc_extra_padding input[type="checkbox"]').prop('checked', false);
}

headerFor = jQuery("select#dslc_hf_for").val();
});

jQuery(document).on('change', '#post-option-dslc_hf_position input[type="radio"]', function(e) {

if ( headerFor == 'header' ) {

var inputValue = jQuery(this).val();

if ( inputValue == 'relative' ) {
jQuery("#post-option-dslc_extra_padding").hide();
jQuery('#post-option-dslc_extra_padding input[type="checkbox"]').val('');
jQuery('#post-option-dslc_extra_padding input[type="checkbox"]').prop('checked', false);
} else {
jQuery("#post-option-dslc_extra_padding").show();
}

}
});

if ( jQuery('#post-option-dslc_hf_position input[type="radio"]#dslc_hf_position0').is(':checked') ) {
jQuery('#post-option-dslc_extra_padding').hide();
}

}); // jQuery(document).ready
2 changes: 1 addition & 1 deletion includes/post-options-framework/js/main.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions includes/post-options-framework/post-options-framework.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ function dslc_editorinterface_post_options( $object, $metabox ) {

if ( 'list-heading' === $choice['value'] && 'dslca_single_post_templates' === $choice['id'] ) {
$dslca_post_option_id = 'id="' . $choice['id'] . '"';
} else {
$dslca_post_option_id = '';
}
}

Expand Down
6 changes: 3 additions & 3 deletions js/frontend.all.min.js

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions js/frontend/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,16 @@ jQuery(document).ready(function($){
}
});

/**
* Header Fixed/Absolute - https://github.com/live-composer/live-composer-page-builder/issues/787
*/

if ( jQuery( "#dslc-header" ).hasClass( "dslc-header-extra-padding" ) && !jQuery( "body" ).hasClass( "dslca-enabled" ) ) {

var headerHeight = jQuery( "#dslc-header" ).height();
jQuery( "#dslc-main .dslc-modules-section:first-child" ).css({ paddingTop : headerHeight });
}


/**
* Navigation Module
Expand Down

0 comments on commit 2811c7a

Please sign in to comment.