• Resolved jiggaman

    (@jiggaman)


    Everytime you select a start time for business hours it hides the end time.

    admin/scripts/admin.js
    Your bug is in this function, please review

    var $form   = $('#business-hours');
                    jQuery(document).on("click", ".bup_select_start", function(e) {
                    //$('.bup_select_start').on('change', function () {
    
                            var $row = $(this).parent(),
                                    $end_select = $('.bup_select_end', $row),
                                    $start_select = $(this);
    
                            if ($start_select.val()) {
                                    $end_select.show();
                                    $('span', $row).show();
    
                                    var start_time = $start_select.val();
    
                                    $('span > option', $end_select).each(function () {
                                            $(this).unwrap();
                                    });
    
                                    // Hides end time options with value less than in the start time
                                    $('option', $end_select).each(function () {
                                            if ($(this).val() <= start_time) {
                                                    $(this).wrap("<span>").parent().hide();
                                            }
                                    });
    
                                    if (start_time >= $end_select.val()) {
                                            $('option:visible:first', $end_select).attr('selected', true);
                                    }
                            } else { // OFF
    
                                    $end_select.hide();
                                    $('span', $row).hide();
                            }
                    }).each(function () {
                            var $row = $(this).parent(),
                                    $end_select = $('.bup_select_end', $row);
    
                            $(this).data('default_value', $(this).val());
                            $end_select.data('default_value', $end_select.val());
    
                            // Hides end select for "OFF" days
                            if (!$(this).val()) {
                                    $end_select.hide();
                                    $('span', $row).hide();
                            }
                    }).trigger('change');

    https://wordpress.org/plugins/booking-ultra-pro/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter jiggaman

    (@jiggaman)

    My quick changes for the fix:

    jQuery(document).on("change", ".bup_select_start", function(e) { // ben
                    //jQuery(document).on("click", ".bup_select_start", function(e) { // ben
                    //$('.bup_select_start').on('change', function () {
    
                            var $row = $(this).parent(),
                                    $end_select = $('.bup_select_end', $row),
                                    $start_select = $(this);
    
                            if ($start_select.val()) {
                                    $end_select.show();
                                    $('span', $row).show();
    
                                    var start_time = $start_select.val();
    
                                    $('span > option', $end_select).each(function () {
                                            $(this).unwrap();
                                    });
    
                                    // Hides end time options with value less than in the start time
                                    $('option', $end_select).each(function () {
                                            if ($(this).val() <= start_time) {
                                                    $(this).wrap("<span>").parent().hide();
                                            }
                                    });
    
                                    if (start_time >= $end_select.val()) {
                                            $('option:visible:first', $end_select).attr('selected', true);
                                    }
                            } /*else { // OFF // ben
    
                                    $end_select.hide();
                                    $('span', $row).hide();
                            }*/ // ben
                    }).each(function () {
                            var $row = $(this).parent(),
                                    $end_select = $('.bup_select_end', $row);
    
                            $(this).data('default_value', $(this).val());
                            $end_select.data('default_value', $end_select.val());
    
                            // Hides end select for "OFF" days
                            if (!$(this).val()) {
                                    $end_select.hide();
                                    $('span', $row).hide();
                            }
                    }).trigger('change');

    @jiggaman,

    Thank you for your post.

    Why you posted it as bug? Actually when you select “OFF” the closing time is hidden, that’s the login we’ve implemented.

    Could you please explain what’s the bug your mentioning so we can check it?

    We have checked the drop&downs on a clean WP installation and everything works the way it should.

    For example if you select 8PM the closing time will be from 8PM not before.

    Please let us know
    Cheers

    Thread Starter jiggaman

    (@jiggaman)

    You actions are take place on the “click”, so before anything is selected (or not even selected) the end time drop down disappears. That’s a bug. And when sometihng is selected, the end time doesn’t reappear.

    Those are the results on Mac running Chrome.

    Please test. My changes seem to fix this issue.

    Ohh, i see, there was a problem on Mac, you were right.

    Thank you for your help to improve the plugin.

    Cheers

    This has been resolved.

    Cheers

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘BUG: Choosing Business Hours Bad javascript’ is closed to new replies.