Plugin Directory

Changeset 2998159


Ignore:
Timestamp:
11/18/2023 09:11:14 PM (2 years ago)
Author:
udidol
Message:

Updates to the dragging mechanism
Put the dragging mechanism behind a flag, changed the dragging handle from being the entire whatsapp button to a separate handle element.

Location:
add-whatsapp-button/trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • add-whatsapp-button/trunk/add-whatsapp-button.php

    r2997916 r2998159  
    66Text Domain: add-whatsapp-button
    77Domain Path: /languages
    8 Version: 2.1.1
     8Version: 2.1.2
    99Author URI: http://udidollberg.com/
    1010*/
  • add-whatsapp-button/trunk/admin/settings.php

    r2672423 r2998159  
    264264                            </tr>
    265265                            <tr>
     266                                <th scope="row"><label for="awb_settings[enable_dragging]"><?php echo esc_html__( 'Allow dragging button on Y axis', 'add-whatsapp-button' ); ?></label></th>
     267                                <td>
     268                                    <input name="awb_settings[enable_dragging]" type="checkbox" id="awb_settings[enable_dragging]" value="1" <?php isset($settings['enable_dragging'] ) ? checked('1', $settings['enable_dragging'] ) : ''; ?>>
     269                                    <p class="description"><?php echo esc_html__( 'Check this box in order to add a small "dragging" handle on the top of the WhatsApp button, which will allow users to drag the button up and down. This won\'t work for the bottom-fixed button type.', 'add-whatsapp-button'); ?></p>
     270                                </td>
     271                            </tr>
     272                            <tr>
    266273                                <th scope="row"><label for="awb_settings[breakpoint]"><?php echo esc_html__( 'Breakpoint', 'add-whatsapp-button' ); ?></label></th>
    267274                                <td>
  • add-whatsapp-button/trunk/includes/scripts-manager.php

    r2997890 r2998159  
    4949        $button_location = ( isset( $options['button_location'] ) ) ? $options['button_location'] : 'left';
    5050        $buttonType = isset( $options['button_type'] ) ? $options['button_type'] : 'wab-side-rectangle';
     51        $dragEnabled = ! empty ( $options['enable_dragging'] ) ? $options['enable_dragging'] : 0;
    5152
    5253        // Create an array of the data we want to pass to the JS script
     
    5859            'button_location' => $button_location,
    5960            'button_type'     => $buttonType,
     61            'dragEnabled'     => $dragEnabled,
    6062            'plugins_url'     => plugins_url()
    6163        );
     
    7274     */
    7375    private function enqueue_jquery_ui_draggable() {
     76        $options = Plugin::$instance->get_plugin_options();
     77
     78        if ( ! empty ( $options['enable_dragging'] ) ? $options['enable_dragging'] : 0 ) {
     79            return;
     80        }
     81
    7482        wp_enqueue_script( 'jquery_draggable', plugins_url( '../js/lib/jquery-ui.drag.min.js', __FILE__ ), array( 'jquery' ) );
    7583        wp_enqueue_script( 'jquery_touch_punch', plugins_url( '../js/lib/jquery.ui.touch-punch.min.js', __FILE__ ), array( 'jquery' ) );
  • add-whatsapp-button/trunk/includes/style-templates/frontend-css.php

    r2575242 r2998159  
    325325                display: none;
    326326            }
     327
     328            /* Draggable */
     329            #wab_drag {
     330                position: absolute;
     331                z-index: 99998;
     332                background-color: #20B038;
     333                display: flex;
     334                align-items: center;
     335                justify-content: center;
     336                cursor: grab;
     337            }
     338
     339            .wab-side-rectangle #wab_drag {
     340                top: 38px;
     341                padding: 5px;
     342            }
     343
     344            .wab-icon-plain #wab_drag {
     345                top: 68px;
     346                right: -7px;
     347                padding: 9px 5px;
     348                border: 3px solid white;
     349                border-radius: 50%;
     350            }
     351
     352            .wab-side-rectangle #wab_drag img {
     353                height: 6px;
     354            }
     355
     356            .wab-icon-plain #wab_drag img {
     357                height: 4px;
     358            }
    327359        </style>
    328360
  • add-whatsapp-button/trunk/js/wab.js

    r2997914 r2998159  
    1 class WhatsAppButtonHandler{constructor(t){this.settings=wabSettings,this.$=t,this.getElements(),this.init()}getElements(){this.$buttonContainer=this.$("#wab_cont"),this.$whatsAppButton=this.$("#whatsAppButton"),this.$chevron=this.$("#wab_close img.wab-chevron"),this.$closeButton=this.$("#wab_close")}setButtonToggleWidth(){const t=this.$buttonContainer.outerWidth();let s="";"wab-side-rectangle"===this.settings.button_type?s=t-12+"px":"wab-icon-plain"===this.settings.button_type&&(s=t-14+"px"),this.$buttonContainer.css(this.settings.button_location,"-"+s)}toggleHideBottomRectangle(){this.$chevron.toggleClass("wab-down wab-up");const t=this.$whatsAppButton.outerHeight()-12+"px";this.$chevron.hasClass("wab-down")?(this.$chevron.attr("src",this.settings.plugins_url+"/add-whatsapp-button/img/chevron-down.svg"),this.$buttonContainer.css("bottom",0)):this.$chevron.hasClass("wab-up")&&(this.$chevron.attr("src",this.settings.plugins_url+"/add-whatsapp-button/img/chevron-up.svg"),this.$buttonContainer.css("bottom","-"+t))}toggleHideSideButton(){this.$chevron.toggleClass("wab-left wab-right"),this.$buttonContainer.hasClass("wab-hidden")?("left"===this.settings.button_location?this.$chevron.attr("src",this.settings.plugins_url+"/add-whatsapp-button/img/chevron-right.svg"):this.$chevron.attr("src",this.settings.plugins_url+"/add-whatsapp-button/img/chevron-left.svg"),this.setButtonToggleWidth()):(this.$chevron.attr("src",this.settings.plugins_url+"/add-whatsapp-button/img/chevron-"+this.settings.button_location+".svg"),this.$buttonContainer.css(this.settings.button_location,0))}toggleHideCloseButton(){this.$buttonContainer.toggleClass("wab-hidden"),"wab-bottom-rectangle"===this.settings.button_type?this.toggleHideBottomRectangle():this.toggleHideSideButton()}onCloseButtonClick(){"full"===this.settings.hideButtonType&&this.$buttonContainer.hide(),"hide"===this.settings.hideButtonType&&this.toggleHideCloseButton()}handleButtonDisplayHours(){const t={startHour:this.settings.startHour,endHour:this.settings.endHour},s=(new Date).getHours();(s<parseInt(t.startHour)||s>parseInt(t.endHour))&&this.$buttonContainer.css("display","none")}init(){this.$buttonContainer.draggable({axis:"y"}),this.$closeButton.on("click",(()=>this.onCloseButtonClick())),"1"===this.settings.limitHours&&this.handleButtonDisplayHours()}}jQuery(document).ready((t=>{new WhatsAppButtonHandler(t)}));
     1class WhatsAppButtonHandler{constructor(t){this.settings=wabSettings,this.$=t,this.getElements(),this.init()}getElements(){this.$buttonContainer=this.$("#wab_cont"),this.$whatsAppButton=this.$("#whatsAppButton"),this.$chevron=this.$("#wab_close img.wab-chevron"),this.$closeButton=this.$("#wab_close")}setButtonToggleWidth(){const t=this.$buttonContainer.outerWidth();let s="";"wab-side-rectangle"===this.settings.button_type?s=t-12+"px":"wab-icon-plain"===this.settings.button_type&&(s=t-14+"px"),this.$buttonContainer.css(this.settings.button_location,"-"+s)}toggleHideBottomRectangle(){this.$chevron.toggleClass("wab-down wab-up");const t=this.$whatsAppButton.outerHeight()-12+"px";this.$chevron.hasClass("wab-down")?(this.$chevron.attr("src",this.settings.plugins_url+"/add-whatsapp-button/img/chevron-down.svg"),this.$buttonContainer.css("bottom",0)):this.$chevron.hasClass("wab-up")&&(this.$chevron.attr("src",this.settings.plugins_url+"/add-whatsapp-button/img/chevron-up.svg"),this.$buttonContainer.css("bottom","-"+t))}toggleHideSideButton(){this.$chevron.toggleClass("wab-left wab-right"),this.$buttonContainer.hasClass("wab-hidden")?("left"===this.settings.button_location?this.$chevron.attr("src",this.settings.plugins_url+"/add-whatsapp-button/img/chevron-right.svg"):this.$chevron.attr("src",this.settings.plugins_url+"/add-whatsapp-button/img/chevron-left.svg"),this.setButtonToggleWidth()):(this.$chevron.attr("src",this.settings.plugins_url+"/add-whatsapp-button/img/chevron-"+this.settings.button_location+".svg"),this.$buttonContainer.css(this.settings.button_location,0))}toggleHideCloseButton(){this.$buttonContainer.toggleClass("wab-hidden"),"wab-bottom-rectangle"===this.settings.button_type?this.toggleHideBottomRectangle():this.toggleHideSideButton()}onCloseButtonClick(){"full"===this.settings.hideButtonType&&this.$buttonContainer.hide(),"hide"===this.settings.hideButtonType&&this.toggleHideCloseButton()}handleButtonDisplayHours(){const t={startHour:this.settings.startHour,endHour:this.settings.endHour},s=(new Date).getHours();(s<parseInt(t.startHour)||s>parseInt(t.endHour))&&this.$buttonContainer.css("display","none")}init(){"1"===this.settings.dragEnabled&&this.$buttonContainer.draggable({axis:"y",scroll:!1,handle:"#wab_drag"}),this.$closeButton.on("click",(()=>this.onCloseButtonClick())),"1"===this.settings.limitHours&&this.handleButtonDisplayHours()}}jQuery(document).ready((t=>{new WhatsAppButtonHandler(t)}));
  • add-whatsapp-button/trunk/plugin.php

    r2575274 r2998159  
    186186            <div id="wab_cont"  class="wab-cont ui-draggable <?php echo $button_style; ?> <?php echo $button_location; ?>">
    187187                <a id="whatsAppButton" href="https://wa.me/<?php echo esc_html( $settings['phone_number'] ); ?><?php echo ( !empty($settings['default_message']) && $settings['enable_message'] == '1' ) ? '/?text='. rawurlencode($settings['default_message']) : ''; ?>" target="_blank"><span class="<?php echo $displayNoneIfIcon; ?>"><?php echo $button_text; ?></span></a>
    188                 <?php if ( isset( $settings['enable_hide_button'] ) && ( isset( $settings['hide_button'] ) ) ) : ?>
     188                <?php if ( isset( $settings['enable_dragging'] ) ) : ?>
     189                    <div id="wab_drag"><img src="<?php echo plugins_url( '/img/drag-horizontal.svg', __FILE__ ) ?>"></div>
     190                <?php endif; ?>
     191                <?php if ( isset( $settings['enable_hide_button'] ) && isset( $settings['hide_button'] ) ) : ?>
    189192                    <div id="wab_close"><?php echo $close_button_icon; ?></div>
    190193                <?php endif; ?>
  • add-whatsapp-button/trunk/readme.txt

    r2997916 r2998159  
    44Requires at least: 4.6
    55Tested up to: 6.4.1
    6 Stable tag: 2.1.1
     6Stable tag: 2.1.2
    77Requires PHP: 5.4
    88License: GPLv2 or later
     
    5353
    5454== Changelog ==
     55
     56= 2.1.2 =
     57* Moved the button dragging functionality under a flag (admin setting)
     58* The dragging is now done by a small dragging handle instead of the entire button being draggable
    5559
    5660= 2.1.1 =
Note: See TracChangeset for help on using the changeset viewer.