Plugin Directory

Changeset 3128010


Ignore:
Timestamp:
07/30/2024 09:41:19 AM (20 months ago)
Author:
hfdepost
Message:

Performance Improvement

Location:
hfd-epost-integration/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • hfd-epost-integration/trunk/class/Helper/Spot.php

    r3060497 r3128010  
    3939        $xml = simplexml_load_string( $response, 'SimpleXMLElement', LIBXML_NOCDATA );
    4040        $arrResponse = json_decode(wp_json_encode($xml), true);
    41 
     41       
    4242        $spots = array();
    4343        if( isset( $arrResponse['spots']['spot_detail'] ) && !empty( $arrResponse['spots']['spot_detail'] ) ){
  • hfd-epost-integration/trunk/css/style.css

    r3059826 r3128010  
    242242}
    243243
     244.autocomplete {
     245  /*the container must be positioned relative:*/
     246  position: relative;
     247  display: inline-block;
     248}
     249.autocomplete-items {
     250  position: absolute;
     251  border: 1px solid #d4d4d4;
     252  border-bottom: none;
     253  border-top: none;
     254  z-index: 99;
     255  /*position the autocomplete items to be the same width as the container:*/
     256  top: 100%;
     257  left: 0;
     258  right: 0;
     259}
     260.autocomplete-items div {
     261  padding: 10px;
     262  cursor: pointer;
     263  background-color: #fff;
     264  border-bottom: 1px solid #d4d4d4;
     265}
     266.autocomplete-items div:hover {
     267  /*when hovering an item:*/
     268  background-color: #e9e9e9;
     269}
     270.autocomplete-active {
     271  /*when navigating through the items using the arrow keys:*/
     272  background-color: DodgerBlue !important;
     273  color: #ffffff;
     274}
    244275@media only screen and (max-width: 767px){
    245276    #legend {
  • hfd-epost-integration/trunk/hfd-woocommerce-epost.php

    r3097702 r3128010  
    55Plugin URI:
    66Description: Add shipping method of ePost, allowing the user on the checkout, to select the pickup location point from a google map popup. Also allows to synch the order to HFD API after the order is created.
    7 Version: 2.3
     7Version: 2.5
    88Author: HFD
    99Author URI: https://www.hfd.co.il
  • hfd-epost-integration/trunk/js/map.js

    r3097702 r3128010  
    55    markers: {},
    66    current_spot: null,
    7 
    87    init: function () {
    98        var _this = this;
     
    1413        });
    1514
    16         var searchInput = $j('#pac-input');
    1715        $j(window).trigger('resize');
    1816         
     
    2119
    2220    drawMap: async function(){
    23         const { AdvancedMarkerElement } = await google.maps.importLibrary("marker");
    2421        const { AutocompleteService } = await google.maps.importLibrary("places");
    2522       
    26         //const placeAutocomplete = new google.maps.places.PlaceAutocompleteElement();
    27         //placeAutocomplete.id = "place-autocomplete-input";
    28        
    29         this.map = new google.maps.Map(document.getElementById('israelpost-map'), {
     23        this.map = new google.maps.Map(document.getElementById('israelpost-map'), {
    3024            center: {lat: 32.063940, lng: 34.837801},
    3125            zoom: 12,
    3226            mapId: 'hfd19integration'
    3327        });
    34         var map = this.map;
    35         var searchContainer = document.getElementById('israelpost-autocompelete');
    36         var input = (document.getElementById('pac-input'));
     28       
     29        window.gmap = this.map;
     30       
     31        var searchContainer = document.getElementById('israelpost-autocompelete');
    3732        var legend = (document.getElementById('legend'));
    3833       
     
    4035        this.map.controls[google.maps.ControlPosition.TOP_LEFT].push(legend);
    4136        this.map.controls[google.maps.ControlPosition.TOP_LEFT].push(searchContainer);
    42 
    43         //const searchBox = new google.maps.places.SearchBox(input);
    44         var options = {
    45             //componentRestrictions: {country: 'il'}
    46             bounds: map.getBounds(),
    47             strictBounds: true,
    48             types:  ['matched_substrings'],
    49         };
    50 
    51         var searchBox = new google.maps.places.Autocomplete(input, options);
    52         // Bias the SearchBox results towards current map's viewport.
    53         map.addListener("bounds_changed", () => {
    54             searchBox.setBounds(map.getBounds());
    55             console.log( "test" );
    56         });
    57        
    58         /* const pac = new google.maps.places.PlaceAutocompleteElement({
    59             locationRestriction: map.getBounds(),
    60         }); */
    61         searchBox.addListener("place_changed", () => {
    62             const place = searchBox.getPlace();
    63             if( !place.geometry ){
    64                 window.alert( "Autocomplete's returned place contains no geometry" );
    65                 return;
    66             }
    67             if (place.geometry.viewport) {
    68                 console.log( 'first' );
    69                 map.fitBounds(place.geometry.viewport);
    70             } else {
    71                 console.log( 'second' );
    72                 map.setCenter(place.geometry.location);
    73                 map.setZoom(17);  // Why 17? Because it looks good.
    74             }           
    75             /* places.forEach((place) => {
    76                 if( !place.geometry ){
    77                     window.alert( "Autocomplete's returned place contains no geometry" );
    78                     return;
    79                 }
    80 
    81                 if( place.geometry.viewport ){
    82                     map.fitBounds( place.geometry.viewport );
    83                 } else {
    84                     map.setCenter( place.geometry.location );
    85                     map.setZoom(17);  // Why 17? Because it looks good.
    86                 }
    87             }); */
    88         });
    8937    },
    9038    buildContent: function( spot ){
     
    10654        return content;
    10755    },
    108    
    10956    pinMarkers: async function (spots) {
    11057        const { AdvancedMarkerElement } = await google.maps.importLibrary("marker");
    11158        const { Map, InfoWindow } = await google.maps.importLibrary("maps");
    11259       
     60        var spotList = [];
    11361        spots = spots || {};
    11462        var _this = this,
     
    12674                var icon = IsraelPostCommon.getConfig('grnDotPath');
    12775            }
     76           
     77            spotList.push( spot );
    12878           
    12979            const hfdImg = document.createElement("img");
     
    152102                    anchor: marker,
    153103                });
    154             }); 
     104            });
    155105        }
    156 
     106       
    157107        google.maps.event.addListenerOnce(_this.map, 'idle', function () {
    158108            google.maps.event.trigger(_this.map, 'resize');
    159109        });
     110       
     111        var selectOpt = [];
     112        var searchInput = ( document.getElementById( 'pac-input' ) );
     113        spotList.forEach( spot => {         
     114            selectOpt.push( spot.name );
     115        });
     116       
     117        autocomplete( document.getElementById( "pac-input" ), selectOpt );
     118       
     119        window.spotsLists = spotList;
     120        window.map = this.map;
     121       
     122        jQuery( document ).on( 'click', '.hfd_autocomplete_spot', function(e){
     123            console.log( "clicked" );
     124            var dataVal = jQuery( this ).find( 'input' ).val();
     125            if( dataVal != "" ){
     126                var optionVal = jQuery( "#pac-input" ).find( "option[value='"+dataVal+"']" );
     127                window.spotsLists.forEach( spot => {
     128                    if( spot.name == dataVal ){
     129                        var icon = IsraelPostCommon.getConfig( 'redDotPath' );
     130                        if( spot.type == 'חנות' ){
     131                            var icon = IsraelPostCommon.getConfig( 'grnDotPath' );
     132                        }                       
     133                        const hfdImg = document.createElement( "img" );
     134                        hfdImg.src = icon;
     135                       
     136                        //google maps marker
     137                        const marker = new AdvancedMarkerElement({
     138                            position: new google.maps.LatLng(spot.latitude, spot.longitude),
     139                            map: window.map,
     140                            content: hfdImg,
     141                            zIndex: null,
     142                        });     
     143                        marker.spot = spot;
     144                        var info_window = new InfoWindow({
     145                            content: IsraelPostMap.buildContent( marker.spot ),
     146                        });
     147                        infow = info_window;
     148                        IsraelPostMap.current_spot = marker.spot;
     149                        info_window.open({
     150                            anchor: marker,
     151                        });
     152                    }
     153                });
     154            }
     155        });
    160156    },
    161157
  • hfd-epost-integration/trunk/js/pickup-post.js

    r3060497 r3128010  
    6262        this.pickerButton = $j('#israelpost-additional .spot-picker');
    6363        this.spotInfo = $j('#israelpost-additional .spot-detail');
    64         this.pickerButton.on({
    65             click: function (e) {
    66                 _this.showPickerPopup(e);
    67             }
    68         });
    6964    },
    7065
  • hfd-epost-integration/trunk/readme.txt

    r3097702 r3128010  
    44Donate link:
    55Requires at least: 4.0
    6 Tested up to: 6.5
    7 Stable tag: 2.3
     6Tested up to: 6.6
     7Stable tag: 2.5
    88Requires PHP: 5.4
    99License: GPLv2 or later
     
    9090* Added option to send order items
    9191
     92= 2.5 =
     93* Improved autocomplete in google map
     94
    9295== Frequently Asked Questions ==
    9396= Why Google Maps isnt loading =
  • hfd-epost-integration/trunk/templates/cart/footer.php

    r3097702 r3128010  
    1515if( $layout == 'map' ): ?>
    1616    <div id="israelpost-modal" style="display: none">
    17         <div id="israelpost-autocompelete">
    18             <input id="pac-input" class="controls" type="text" placeholder="<?php echo esc_html( __( 'Please enter an address', 'hfd-integration' ) ); ?>" />
     17        <div id="israelpost-autocompelete" class="autocomplete">
     18            <input type="text" id="pac-input" placeholder="<?php echo esc_html( __( 'Please enter an address', 'hfd-integration' ) ); ?>" />
    1919        </div>
    2020        <div id="legend" style="height: 45px;" class="pac-inner">
     
    3838    </script>
    3939    <?php
     40    wp_enqueue_script( 'hfd-autocomplete-js', $this->getSkinUrl( 'js/jquery-hfd-autocomplete.js' ) );
    4041    wp_enqueue_script( 'hfd-common-js', $this->getSkinUrl( 'js/common.js' ) );
    4142    wp_enqueue_script( 'hfd-gmap-js', $this->getSkinUrl( 'js/map.js' ), array(), time() );
Note: See TracChangeset for help on using the changeset viewer.