Plugin Directory

Changeset 3383704


Ignore:
Timestamp:
10/24/2025 03:10:12 AM (5 months ago)
Author:
evcode
Message:

Update to version 1.2.2 from GitHub

Location:
myd-delivery
Files:
20 edited
1 copied

Legend:

Unmodified
Added
Removed
  • myd-delivery/tags/1.2.2/README.txt

    r3383604 r3383704  
    55Requires at least: 5.5
    66Tested up to: 6.8
    7 Stable tag: 1.2.1
     7Stable tag: 1.2.2
    88Requires PHP: 7.4
    99License: GPL-3.0+
     
    7676== Changelog ==
    7777
     78= 1.2.2 =
     79* Changed: code improvements.
     80* Fix: product extra repeater dont working as expected in some conditions.
     81
    7882= 1.2.1 =
    7983* Changed: code improvements.
    80 * Fix: Custom message selector in settings.
     84* Fix: custom message selector in settings.
    8185
    8286= 1.2 =
  • myd-delivery/tags/1.2.2/assets/js/admin/custom-fields/repeater.min.js

    r3379132 r3383704  
    1 (()=>{const e=document.querySelectorAll(".myd-repeater-summary__action--remove");e.length>0&&e.forEach(e=>{e.addEventListener("click",l)});const t=document.querySelectorAll(".myd-repeater-container__remove");t.length>0&&t.forEach(e=>{e.addEventListener("click",a)});const r=document.querySelectorAll(".myd-repeater-add-option");r.length>0&&r.forEach(e=>{e.addEventListener("click",t=>{t.preventDefault(),o(e)})});const n=document.querySelectorAll(".myd-repeater-add-extra");function a(){if(this.parentNode.previousElementSibling||!this.parentNode.previousElementSibling&&!this.parentNode.nextElementSibling.matches("button"))this.parentNode.remove();else{const e=this.parentNode;if(e){let t=e.querySelector(".myd-repeater-summary__title");t&&(t.innerText="")}const t=e.querySelectorAll(".myd-repeater-input");t.length>0&&t.forEach(e=>{"checkbox"!==e.type&&"hidden"!==e.type?e.value="":e.checked=!1})}}function l(){if(this.parentNode.parentNode.previousElementSibling.matches("details")||!this.parentNode.parentNode.previousElementSibling.matches("details")&&this.parentNode.parentNode.nextElementSibling.matches("details"))this.parentNode.parentNode.remove();else{const e=this.parentNode.parentNode;if(e){let t=e.querySelector(".myd-repeater-summary__title");t&&(t.innerText="")}const t=e.querySelectorAll(".myd-repeater-input");t.length>0&&t.forEach(e=>{"checkbox"!==e.type&&"hidden"!==e.type?e.value="":e.checked=!1})}}function o(e){const t=e.parentNode.querySelector("details:last-of-type").cloneNode(!0);let r=t.querySelector(".myd-repeater-summary__title");r&&(r.innerText="");const n=t.querySelectorAll(".myd-repeater-input");n.length>0&&n.forEach(e=>{let t=e.dataset.mainIndex,r=e.dataset.name,n=e.dataset.internalIndex||"";if(t&&r){let a=Number(n)+1;r=r.replace(/{{main-index}}/,t),r=r.replace(/{{internal-index}}/,a),e.name=r,e.dataset.internalIndex=a,"checkbox"!==e.type&&"hidden"!==e.type?e.value="":e.checked=!1}});const a=t.querySelector(".myd-repeater-summary__action--remove");a&&a.addEventListener("click",l),e.parentNode.insertBefore(t,e)}n.length>0&&n.forEach(e=>{e.addEventListener("click",t=>{t.preventDefault(),function(e){const t=e.parentNode.querySelector(".myd-repeater-container--top-level:last-of-type").cloneNode(!0);let r=t.querySelectorAll("details.myd-repeater-container:not(:first-of-type)");r.length>0&&r.forEach(e=>{e.remove()});let n=t.querySelector(".myd-repeater-summary__title");n&&(n.innerText="");const l=t.querySelectorAll(".myd-repeater-input");l.length>0&&l.forEach(e=>{let t=e.dataset.mainIndex,r=e.dataset.name,n=e.dataset.internalIndex||"";if(t&&r){let a=Number(t)+1;r=r.replace(/{{main-index}}/,a),r=r.replace(/{{internal-index}}/,n),e.name=r,e.dataset.mainIndex=a,"checkbox"!==e.type&&"hidden"!==e.type?e.value="":e.checked=!1}});const d=t.querySelector(".myd-repeater-container__remove");d&&d.addEventListener("click",a);const c=t.querySelector(".myd-repeater-add-option");c&&c.addEventListener("click",e=>{e.preventDefault(),o(c)}),e.parentNode.insertBefore(t,e)}(e)})})})();
     1(()=>{const e=document.querySelectorAll(".myd-repeater-summary__action--remove");e.length>0&&e.forEach(e=>{e.addEventListener("click",o)});const t=document.querySelectorAll(".myd-repeater-container__remove");t.length>0&&t.forEach(e=>{e.addEventListener("click",a)});const n=document.querySelectorAll(".myd-repeater-add-option");n.length>0&&n.forEach(e=>{e.addEventListener("click",t=>{t.preventDefault(),l(e)})});const r=document.querySelectorAll(".myd-repeater-add-extra");function a(){if(this.parentNode.previousElementSibling||!this.parentNode.previousElementSibling&&!this.parentNode.nextElementSibling.matches("button"))this.parentNode.remove();else{const e=this.parentNode;if(e){let t=e.querySelector(".myd-repeater-summary__title");t&&(t.innerText="")}const t=e.querySelectorAll(".myd-repeater-input");t.length>0&&t.forEach(e=>{"checkbox"!==e.type&&"hidden"!==e.type?e.value="":e.checked=!1})}}function o(){if(this.parentNode.parentNode.previousElementSibling.matches("details")||!this.parentNode.parentNode.previousElementSibling.matches("details")&&this.parentNode.parentNode.nextElementSibling.matches("details"))this.parentNode.parentNode.remove();else{const e=this.parentNode.parentNode;if(e){const t=e.querySelector(".myd-repeater-summary__title");t&&(t.innerText="")}const t=e.querySelectorAll(".myd-repeater-input");t.length>0&&t.forEach(e=>{"checkbox"!==e.type&&"hidden"!==e.type?e.value="":e.checked=!1})}}function l(e){const t=e.parentNode.querySelector("details:last-of-type").cloneNode(!0),n=t.querySelector(".myd-repeater-summary__title");n&&(n.innerText="");const r=t.querySelectorAll(".myd-repeater-input");r.length>0&&r.forEach(e=>{let t=e.dataset.name;const n=e.dataset.mainIndex,r=e.dataset.internalIndex||"";if(n&&t){const a=Number(r)+1;t=t.replace(/{{main-index}}/,n),t=t.replace(/{{internal-index}}/,a),e.name=t,e.dataset.internalIndex=a,"checkbox"!==e.type&&"hidden"!==e.type?e.value="":e.checked=!1}});const a=t.querySelector(".myd-repeater-summary__action--remove");a&&a.addEventListener("click",o),e.parentNode.insertBefore(t,e)}r.length>0&&r.forEach(e=>{e.addEventListener("click",t=>{t.preventDefault(),function(e){const t=e.parentNode.querySelector(".myd-repeater-container--top-level:last-of-type").cloneNode(!0),n=t.querySelectorAll("details.myd-repeater-container:not(:first-of-type)");n.length>0&&n.forEach(e=>{e.remove()});const r=t.querySelector(".myd-repeater-summary__title");r&&(r.innerText="");const o=t.querySelectorAll(".myd-repeater-input");o.length>0&&o.forEach(e=>{let t=e.dataset.mainIndex,n=e.dataset.name,r=e.dataset.internalIndex||"";if(t&&n){let a=Number(t)+1;n=n.replace(/{{main-index}}/,a),n=n.replace(/{{internal-index}}/,r),e.name=n,e.dataset.mainIndex=a,"checkbox"!==e.type&&"hidden"!==e.type?e.value="":e.checked=!1}});const c=t.querySelector(".myd-repeater-container__remove");c&&c.addEventListener("click",a);const d=t.querySelector(".myd-repeater-add-option");d&&d.addEventListener("click",e=>{e.preventDefault(),l(d)}),e.parentNode.insertBefore(t,e)}(e)})})})();
  • myd-delivery/tags/1.2.2/includes/custom-fields/class-custom-fields.php

    r3379132 r3383704  
    180180        }
    181181
    182         return implode( $output_data_attr );
     182        return implode( ' ', $output_data_attr );
    183183    }
    184184
     
    244244            isset( $args['required'] ) && $args['required'] === true ? 'required' : '',
    245245            isset( $args['data'] ) ? $this->build_data_attr( $args['data'] ) : '',
    246             esc_attr( $value )
     246            esc_textarea( $value )
    247247        );
    248248    }
  • myd-delivery/tags/1.2.2/myd-delivery.php

    r3383604 r3383704  
    66 * Author: EduardoVillao.me
    77 * Author URI: https://eduardovillao.me/
    8  * Version: 1.2.1
     8 * Version: 1.2.2
    99 * Requires PHP: 7.4
    1010 * Requires at least: 5.5
     
    2626define( 'MYDDELIVERY_BASENAME', plugin_basename( __FILE__ ) );
    2727define( 'MYDDELIVERY_DIRNAME', plugin_basename( __DIR__ ) );
    28 define( 'MYDDELIVERY_VERSION', '1.2.1' );
     28define( 'MYDDELIVERY_VERSION', '1.2.2' );
    2929define( 'MYDDELIVERY_MIN_PHP_VERSION', '7.4' );
    3030define( 'MYDDELIVERY_MIN_WP_VERSION', '5.5' );
  • myd-delivery/tags/1.2.2/src/js/admin/custom-fields/repeater.js

    r3379132 r3383704  
    22 * Remove extra option
    33 */
    4 const removeOption = document.querySelectorAll('.myd-repeater-summary__action--remove');
     4const removeOption = document.querySelectorAll(
     5    '.myd-repeater-summary__action--remove'
     6);
    57if (removeOption.length > 0) {
    68    removeOption.forEach((item) => {
     
    1214 * Remove product extra
    1315 */
    14 const removeProductExtraButtons = document.querySelectorAll('.myd-repeater-container__remove');
     16const removeProductExtraButtons = document.querySelectorAll(
     17    '.myd-repeater-container__remove'
     18);
    1519if (removeProductExtraButtons.length > 0) {
    1620    removeProductExtraButtons.forEach((item) => {
     
    1822    });
    1923}
    20 
    2124
    2225/**
     
    5053 */
    5154function removeProductExtra() {
    52     if(
     55    if (
    5356        this.parentNode.previousElementSibling ||
    54         !this.parentNode.previousElementSibling &&
    55         !this.parentNode.nextElementSibling.matches('button')
    56         ) {
     57        (!this.parentNode.previousElementSibling &&
     58            !this.parentNode.nextElementSibling.matches('button'))
     59    ) {
    5760        this.parentNode.remove();
    5861    } else {
    5962        const extraOptionItem = this.parentNode;
    60         if(extraOptionItem) {
    61             let summaryTitle = extraOptionItem.querySelector('.myd-repeater-summary__title');
    62             if(summaryTitle) {
     63        if (extraOptionItem) {
     64            let summaryTitle = extraOptionItem.querySelector(
     65                '.myd-repeater-summary__title'
     66            );
     67            if (summaryTitle) {
    6368                summaryTitle.innerText = '';
    6469            }
     
    6671
    6772        const inputs = extraOptionItem.querySelectorAll('.myd-repeater-input');
    68         if(inputs.length > 0) {
     73        if (inputs.length > 0) {
    6974            inputs.forEach((item) => {
    70                 if(item.type !== 'checkbox' && item.type !== 'hidden') {
     75                if (item.type !== 'checkbox' && item.type !== 'hidden') {
    7176                    item.value = '';
    7277                } else {
     
    8287 */
    8388function removeExtraOption() {
    84     if(
     89    if (
    8590        this.parentNode.parentNode.previousElementSibling.matches('details') ||
    86         !this.parentNode.parentNode.previousElementSibling.matches('details') &&
    87         this.parentNode.parentNode.nextElementSibling.matches('details')
    88         ) {
     91        (!this.parentNode.parentNode.previousElementSibling.matches(
     92            'details'
     93        ) &&
     94            this.parentNode.parentNode.nextElementSibling.matches('details'))
     95    ) {
    8996        this.parentNode.parentNode.remove();
    9097    } else {
    9198        const extraOptionItem = this.parentNode.parentNode;
    92         if(extraOptionItem) {
    93             let summaryTitle = extraOptionItem.querySelector('.myd-repeater-summary__title');
    94             if(summaryTitle) {
     99        if (extraOptionItem) {
     100            const summaryTitle = extraOptionItem.querySelector(
     101                '.myd-repeater-summary__title'
     102            );
     103            if (summaryTitle) {
    95104                summaryTitle.innerText = '';
    96105            }
     
    98107
    99108        const inputs = extraOptionItem.querySelectorAll('.myd-repeater-input');
    100         if(inputs.length > 0) {
     109        if (inputs.length > 0) {
    101110            inputs.forEach((item) => {
    102                 if(item.type !== 'checkbox' && item.type !== 'hidden') {
     111                if (item.type !== 'checkbox' && item.type !== 'hidden') {
    103112                    item.value = '';
    104113                } else {
     
    110119}
    111120
    112 
    113121/**
    114122 * Add new option
    115123 */
    116124function addNewOption(element) {
    117     const lastElement = element.parentNode.querySelector('details:last-of-type'),
    118     newElement = lastElement.cloneNode(true);
    119 
    120     let summaryTitle = newElement.querySelector('.myd-repeater-summary__title');
    121     if(summaryTitle) {
     125    const lastElement = element.parentNode.querySelector(
     126            'details:last-of-type'
     127        ),
     128        newElement = lastElement.cloneNode(true);
     129
     130    const summaryTitle = newElement.querySelector(
     131        '.myd-repeater-summary__title'
     132    );
     133    if (summaryTitle) {
    122134        summaryTitle.innerText = '';
    123135    }
    124136
    125137    const inputs = newElement.querySelectorAll('.myd-repeater-input');
    126     if(inputs.length > 0) {
     138    if (inputs.length > 0) {
    127139        inputs.forEach((item) => {
    128             let mainIndex = item.dataset.mainIndex,
    129             loopName = item.dataset.name,
    130             internalIndex = item.dataset.internalIndex || '';
    131 
    132             if(mainIndex && loopName) {
    133                 let newInternalKey = Number(internalIndex) + 1;
     140            let loopName = item.dataset.name;
     141            const mainIndex = item.dataset.mainIndex,
     142                internalIndex = item.dataset.internalIndex || '';
     143
     144            if (mainIndex && loopName) {
     145                const newInternalKey = Number(internalIndex) + 1;
    134146
    135147                loopName = loopName.replace(/{{main-index}}/, mainIndex);
    136                 loopName = loopName.replace(/{{internal-index}}/, newInternalKey);
     148                loopName = loopName.replace(
     149                    /{{internal-index}}/,
     150                    newInternalKey
     151                );
    137152                item.name = loopName;
    138153                item.dataset.internalIndex = newInternalKey;
    139                 if(item.type !== 'checkbox' && item.type !== 'hidden') {
    140                     item.value = '';
    141                 } else {
    142                     item.checked = false;
    143                 }
    144             }
    145         });
    146     }
    147 
    148     const removeExtraButton = newElement.querySelector('.myd-repeater-summary__action--remove');
    149     if(removeExtraButton) {
     154                if (item.type !== 'checkbox' && item.type !== 'hidden') {
     155                    item.value = '';
     156                } else {
     157                    item.checked = false;
     158                }
     159            }
     160        });
     161    }
     162
     163    const removeExtraButton = newElement.querySelector(
     164        '.myd-repeater-summary__action--remove'
     165    );
     166    if (removeExtraButton) {
    150167        removeExtraButton.addEventListener('click', removeExtraOption);
    151168    }
     
    159176 */
    160177function addNewExtra(element) {
    161     const extraContainer = element.parentNode.querySelector('.myd-repeater-container--top-level:last-of-type'),
    162     newExtra = extraContainer.cloneNode(true);
     178    const extraContainer = element.parentNode.querySelector(
     179            '.myd-repeater-container--top-level:last-of-type'
     180        ),
     181        newExtra = extraContainer.cloneNode(true);
    163182
    164183    /**
    165184     * Clean extra items
    166185     */
    167     let details = newExtra.querySelectorAll('details.myd-repeater-container:not(:first-of-type)');
    168     if(details.length > 0) {
     186    const details = newExtra.querySelectorAll(
     187        'details.myd-repeater-container:not(:first-of-type)'
     188    );
     189    if (details.length > 0) {
    169190        details.forEach((item) => {
    170191            item.remove();
     
    172193    }
    173194
    174     let summaryTitle = newExtra.querySelector('.myd-repeater-summary__title');
    175     if(summaryTitle) {
     195    const summaryTitle = newExtra.querySelector('.myd-repeater-summary__title');
     196    if (summaryTitle) {
    176197        summaryTitle.innerText = '';
    177198    }
    178199
    179200    const inputs = newExtra.querySelectorAll('.myd-repeater-input');
    180     if(inputs.length > 0) {
     201    if (inputs.length > 0) {
    181202        inputs.forEach((item) => {
    182203            let mainIndex = item.dataset.mainIndex,
    183             loopName = item.dataset.name,
    184             internalIndex = item.dataset.internalIndex || '';
    185 
    186             if(mainIndex && loopName) {
     204                loopName = item.dataset.name,
     205                internalIndex = item.dataset.internalIndex || '';
     206
     207            if (mainIndex && loopName) {
    187208                let newMainKey = Number(mainIndex) + 1;
    188209
    189210                loopName = loopName.replace(/{{main-index}}/, newMainKey);
    190                 loopName = loopName.replace(/{{internal-index}}/, internalIndex);
     211                loopName = loopName.replace(
     212                    /{{internal-index}}/,
     213                    internalIndex
     214                );
    191215                item.name = loopName;
    192216                item.dataset.mainIndex = newMainKey;
    193                 if(item.type !== 'checkbox' && item.type !== 'hidden') {
    194                     item.value = '';
    195                 } else {
    196                     item.checked = false;
    197                 }
    198             }
    199         });
    200     }
    201 
    202     const removeExtraButton = newExtra.querySelector('.myd-repeater-container__remove');
    203     if(removeExtraButton) {
     217                if (item.type !== 'checkbox' && item.type !== 'hidden') {
     218                    item.value = '';
     219                } else {
     220                    item.checked = false;
     221                }
     222            }
     223        });
     224    }
     225
     226    const removeExtraButton = newExtra.querySelector(
     227        '.myd-repeater-container__remove'
     228    );
     229    if (removeExtraButton) {
    204230        removeExtraButton.addEventListener('click', removeProductExtra);
    205231    }
    206232
    207233    const addOptionButton = newExtra.querySelector('.myd-repeater-add-option');
    208     if(addOptionButton) {
     234    if (addOptionButton) {
    209235        addOptionButton.addEventListener('click', (event) => {
    210236            event.preventDefault();
  • myd-delivery/tags/1.2.2/src/js/modules/input-mask.js

    r3379132 r3383704  
    3030    handleBackspace(event) {
    3131        const input = event.target;
    32         if (event.key === 'Backspace' && input.selectionStart === input.selectionEnd) {
     32        if (
     33            event.key === 'Backspace' &&
     34            input.selectionStart === input.selectionEnd
     35        ) {
    3336            const pos = input.selectionStart;
    3437            if (pos > 0) {
  • myd-delivery/tags/1.2.2/src/js/order/controller.js

    r3379132 r3383704  
    7777
    7878    // TODO: move to inside a shipping class
    79     if (window.MydOrder.shipping.validateZipcodeShipping(window.MydOrder.type) === false) {
     79    if (
     80        window.MydOrder.shipping.validateZipcodeShipping(
     81            window.MydOrder.type
     82        ) === false
     83    ) {
    8084        window.Myd.notificationBar(
    8185            'error',
  • myd-delivery/tags/1.2.2/src/js/order/modules/autocomplete-address.js

    r3379132 r3383704  
    2222                        if (!('erro' in dados)) {
    2323                            if (dados.logradouro !== '') {
    24                                 document.getElementById('input-delivery-street-name').value = dados.logradouro;
    25                                 document.getElementById('input-delivery-street-name').style.background = '#efefef';
    26                                 document.getElementById('input-delivery-address-number').focus();
     24                                document.getElementById(
     25                                    'input-delivery-street-name'
     26                                ).value = dados.logradouro;
     27                                document.getElementById(
     28                                    'input-delivery-street-name'
     29                                ).style.background = '#efefef';
     30                                document
     31                                    .getElementById(
     32                                        'input-delivery-address-number'
     33                                    )
     34                                    .focus();
    2735                            } else {
    28                                 document.getElementById('input-delivery-street-name').value = '';
     36                                document.getElementById(
     37                                    'input-delivery-street-name'
     38                                ).value = '';
    2939                            }
    3040
    3141                            if (dados.logradouro !== '') {
    32                                 document.getElementById('input-delivery-neighborhood').value = dados.bairro;
     42                                document.getElementById(
     43                                    'input-delivery-neighborhood'
     44                                ).value = dados.bairro;
    3345                            }
    3446                        }
  • myd-delivery/tags/1.2.2/src/js/order/modules/checkout.js

    r3379132 r3383704  
    3737            couponCode: document.getElementById('input-coupon'),
    3838            street: document.getElementById('input-delivery-street-name'),
    39             streetNumber: document.getElementById('input-delivery-address-number'),
     39            streetNumber: document.getElementById(
     40                'input-delivery-address-number'
     41            ),
    4042            addressComplement: document.getElementById('input-delivery-comp'),
    41             neighborhood: document.getElementById('input-delivery-neighborhood'),
     43            neighborhood: document.getElementById(
     44                'input-delivery-neighborhood'
     45            ),
    4246            zipcode: document.getElementById('input-delivery-zipcode'),
    4347            table: document.getElementById('input-in-store-table'),
  • myd-delivery/tags/1.2.2/src/js/order/modules/shipping.js

    r3379132 r3383704  
    2828
    2929    SetGoogleMapsApi() {
    30         const input = document.getElementById('input-delivery-autocomplete-address');
     30        const input = document.getElementById(
     31            'input-delivery-autocomplete-address'
     32        );
    3133        const options = {
    3234            fields: ['formatted_address', 'geometry', 'address_components'],
     
    3941        }
    4042
    41         const autocomplete = new google.maps.places.Autocomplete(input, options);
     43        const autocomplete = new google.maps.places.Autocomplete(
     44            input,
     45            options
     46        );
    4247        autocomplete.addListener('place_changed', () => {
    4348            const place = autocomplete.getPlace();
    44             if (!place.geometry || !place.geometry.location || !place.address_components) {
    45                 window.alert("No details available for input: '" + place.name + "'");
     49            if (
     50                !place.geometry ||
     51                !place.geometry.location ||
     52                !place.address_components
     53            ) {
     54                window.alert(
     55                    "No details available for input: '" + place.name + "'"
     56                );
    4657                return;
    4758            }
    4859
    49             const inputFormatedAddress = document.getElementsByName('input-delivery-formated-address');
    50             const inputLatitude = document.getElementsByName('input-delivery-latitude');
    51             const inputLongitude = document.getElementsByName('input-delivery-longitude');
     60            const inputFormatedAddress = document.getElementsByName(
     61                'input-delivery-formated-address'
     62            );
     63            const inputLatitude = document.getElementsByName(
     64                'input-delivery-latitude'
     65            );
     66            const inputLongitude = document.getElementsByName(
     67                'input-delivery-longitude'
     68            );
    5269            if (inputLatitude && inputLongitude && inputFormatedAddress) {
    5370                inputFormatedAddress[0].value = place.formatted_address;
     
    5774
    5875            if (place.address_components.length > 0) {
    59                 const streetNumber = place.address_components.filter((address_data) => {
    60                     return address_data.types.includes('street_number');
    61                 });
    62 
    63                 const zipcode = place.address_components.filter((address_data) => {
    64                     return address_data.types.includes('postal_code');
    65                 });
    66 
    67                 const streetName = place.address_components.filter((address_data) => {
    68                     return address_data.types.includes('route');
    69                 });
    70 
    71                 const neighborhood = place.address_components.filter((address_data) => {
    72                     return address_data.types.includes('sublocality_level_1');
    73                 });
    74 
    75                 const streetNumberInput = document.getElementById('input-delivery-address-number');
     76                const streetNumber = place.address_components.filter(
     77                    (address_data) => {
     78                        return address_data.types.includes('street_number');
     79                    }
     80                );
     81
     82                const zipcode = place.address_components.filter(
     83                    (address_data) => {
     84                        return address_data.types.includes('postal_code');
     85                    }
     86                );
     87
     88                const streetName = place.address_components.filter(
     89                    (address_data) => {
     90                        return address_data.types.includes('route');
     91                    }
     92                );
     93
     94                const neighborhood = place.address_components.filter(
     95                    (address_data) => {
     96                        return address_data.types.includes(
     97                            'sublocality_level_1'
     98                        );
     99                    }
     100                );
     101
     102                const streetNumberInput = document.getElementById(
     103                    'input-delivery-address-number'
     104                );
    76105                if (streetNumberInput) {
    77                     streetNumberInput.value = streetNumber.length > 0 ? streetNumber[0].long_name : '';
    78                 }
    79 
    80                 const zipcodeInput = document.getElementById('input-delivery-zipcode');
     106                    streetNumberInput.value =
     107                        streetNumber.length > 0
     108                            ? streetNumber[0].long_name
     109                            : '';
     110                }
     111
     112                const zipcodeInput = document.getElementById(
     113                    'input-delivery-zipcode'
     114                );
    81115                if (zipcodeInput) {
    82                     zipcodeInput.value = zipcode.length > 0 ? zipcode[0].long_name : '00000000';
    83                 }
    84 
    85                 const streetNameInput = document.getElementById('input-delivery-street-name');
     116                    zipcodeInput.value =
     117                        zipcode.length > 0 ? zipcode[0].long_name : '00000000';
     118                }
     119
     120                const streetNameInput = document.getElementById(
     121                    'input-delivery-street-name'
     122                );
    86123                if (streetNameInput) {
    87                     streetNameInput.value = streetName.length > 0 ? streetName[0].long_name : '';
    88                 }
    89 
    90                 const neighborhoodInput = document.getElementById('input-delivery-neighborhood');
     124                    streetNameInput.value =
     125                        streetName.length > 0 ? streetName[0].long_name : '';
     126                }
     127
     128                const neighborhoodInput = document.getElementById(
     129                    'input-delivery-neighborhood'
     130                );
    91131                if (neighborhoodInput) {
    92                     neighborhoodInput.value = neighborhood.length > 0 ? neighborhood[0].long_name : '';
     132                    neighborhoodInput.value =
     133                        neighborhood.length > 0
     134                            ? neighborhood[0].long_name
     135                            : '';
    93136                }
    94137            }
     
    98141    async getPriceByDistance() {
    99142        const options = mydStoreInfo.deliveryShipping.options;
    100         const inputLatitude = document.getElementsByName('input-delivery-latitude');
    101         const inputLongitude = document.getElementsByName('input-delivery-longitude');
     143        const inputLatitude = document.getElementsByName(
     144            'input-delivery-latitude'
     145        );
     146        const inputLongitude = document.getElementsByName(
     147            'input-delivery-longitude'
     148        );
    102149        if (!inputLatitude || !inputLongitude) {
    103150            console.error('Missed latitude and longitude to destination');
     
    149196    getPriceByNeighborhood() {
    150197        const neighborhoodList = mydStoreInfo.deliveryShipping.options,
    151             neighborhoodInputValue = document.getElementById('input-delivery-neighborhood').value,
     198            neighborhoodInputValue = document.getElementById(
     199                'input-delivery-neighborhood'
     200            ).value,
    152201            val = [];
    153202
    154203        Object.keys(neighborhoodList.options).forEach((item) => {
    155             if(neighborhoodList.options[item].from === neighborhoodInputValue) {
     204            if (
     205                neighborhoodList.options[item].from === neighborhoodInputValue
     206            ) {
    156207                val.push(neighborhoodList.options[item].price);
    157208            }
     
    167218            ),
    168219            val = [];
    169         Object.keys(zipcodeList.options).forEach( item => {
     220        Object.keys(zipcodeList.options).forEach((item) => {
    170221            if (
    171222                zipcodeInputValue >= zipcodeList.options[item].from &&
     
    193244        ) {
    194245            let zipcodeList = mydStoreInfo.deliveryShipping.options,
    195             zipcodeInputValue = parseInt(document.getElementById('input-delivery-zipcode').value),
    196             val = [];
    197 
    198             Object.keys(zipcodeList.options).forEach( item => {
    199                 if (zipcodeInputValue >= zipcodeList.options[item].from && zipcodeInputValue <= zipcodeList.options[item].to) {
     246                zipcodeInputValue = parseInt(
     247                    document.getElementById('input-delivery-zipcode').value
     248                ),
     249                val = [];
     250
     251            Object.keys(zipcodeList.options).forEach((item) => {
     252                if (
     253                    zipcodeInputValue >= zipcodeList.options[item].from &&
     254                    zipcodeInputValue <= zipcodeList.options[item].to
     255                ) {
    200256                    val.push(true);
    201257                }
  • myd-delivery/trunk/README.txt

    r3383604 r3383704  
    55Requires at least: 5.5
    66Tested up to: 6.8
    7 Stable tag: 1.2.1
     7Stable tag: 1.2.2
    88Requires PHP: 7.4
    99License: GPL-3.0+
     
    7676== Changelog ==
    7777
     78= 1.2.2 =
     79* Changed: code improvements.
     80* Fix: product extra repeater dont working as expected in some conditions.
     81
    7882= 1.2.1 =
    7983* Changed: code improvements.
    80 * Fix: Custom message selector in settings.
     84* Fix: custom message selector in settings.
    8185
    8286= 1.2 =
  • myd-delivery/trunk/assets/js/admin/custom-fields/repeater.min.js

    r3379132 r3383704  
    1 (()=>{const e=document.querySelectorAll(".myd-repeater-summary__action--remove");e.length>0&&e.forEach(e=>{e.addEventListener("click",l)});const t=document.querySelectorAll(".myd-repeater-container__remove");t.length>0&&t.forEach(e=>{e.addEventListener("click",a)});const r=document.querySelectorAll(".myd-repeater-add-option");r.length>0&&r.forEach(e=>{e.addEventListener("click",t=>{t.preventDefault(),o(e)})});const n=document.querySelectorAll(".myd-repeater-add-extra");function a(){if(this.parentNode.previousElementSibling||!this.parentNode.previousElementSibling&&!this.parentNode.nextElementSibling.matches("button"))this.parentNode.remove();else{const e=this.parentNode;if(e){let t=e.querySelector(".myd-repeater-summary__title");t&&(t.innerText="")}const t=e.querySelectorAll(".myd-repeater-input");t.length>0&&t.forEach(e=>{"checkbox"!==e.type&&"hidden"!==e.type?e.value="":e.checked=!1})}}function l(){if(this.parentNode.parentNode.previousElementSibling.matches("details")||!this.parentNode.parentNode.previousElementSibling.matches("details")&&this.parentNode.parentNode.nextElementSibling.matches("details"))this.parentNode.parentNode.remove();else{const e=this.parentNode.parentNode;if(e){let t=e.querySelector(".myd-repeater-summary__title");t&&(t.innerText="")}const t=e.querySelectorAll(".myd-repeater-input");t.length>0&&t.forEach(e=>{"checkbox"!==e.type&&"hidden"!==e.type?e.value="":e.checked=!1})}}function o(e){const t=e.parentNode.querySelector("details:last-of-type").cloneNode(!0);let r=t.querySelector(".myd-repeater-summary__title");r&&(r.innerText="");const n=t.querySelectorAll(".myd-repeater-input");n.length>0&&n.forEach(e=>{let t=e.dataset.mainIndex,r=e.dataset.name,n=e.dataset.internalIndex||"";if(t&&r){let a=Number(n)+1;r=r.replace(/{{main-index}}/,t),r=r.replace(/{{internal-index}}/,a),e.name=r,e.dataset.internalIndex=a,"checkbox"!==e.type&&"hidden"!==e.type?e.value="":e.checked=!1}});const a=t.querySelector(".myd-repeater-summary__action--remove");a&&a.addEventListener("click",l),e.parentNode.insertBefore(t,e)}n.length>0&&n.forEach(e=>{e.addEventListener("click",t=>{t.preventDefault(),function(e){const t=e.parentNode.querySelector(".myd-repeater-container--top-level:last-of-type").cloneNode(!0);let r=t.querySelectorAll("details.myd-repeater-container:not(:first-of-type)");r.length>0&&r.forEach(e=>{e.remove()});let n=t.querySelector(".myd-repeater-summary__title");n&&(n.innerText="");const l=t.querySelectorAll(".myd-repeater-input");l.length>0&&l.forEach(e=>{let t=e.dataset.mainIndex,r=e.dataset.name,n=e.dataset.internalIndex||"";if(t&&r){let a=Number(t)+1;r=r.replace(/{{main-index}}/,a),r=r.replace(/{{internal-index}}/,n),e.name=r,e.dataset.mainIndex=a,"checkbox"!==e.type&&"hidden"!==e.type?e.value="":e.checked=!1}});const d=t.querySelector(".myd-repeater-container__remove");d&&d.addEventListener("click",a);const c=t.querySelector(".myd-repeater-add-option");c&&c.addEventListener("click",e=>{e.preventDefault(),o(c)}),e.parentNode.insertBefore(t,e)}(e)})})})();
     1(()=>{const e=document.querySelectorAll(".myd-repeater-summary__action--remove");e.length>0&&e.forEach(e=>{e.addEventListener("click",o)});const t=document.querySelectorAll(".myd-repeater-container__remove");t.length>0&&t.forEach(e=>{e.addEventListener("click",a)});const n=document.querySelectorAll(".myd-repeater-add-option");n.length>0&&n.forEach(e=>{e.addEventListener("click",t=>{t.preventDefault(),l(e)})});const r=document.querySelectorAll(".myd-repeater-add-extra");function a(){if(this.parentNode.previousElementSibling||!this.parentNode.previousElementSibling&&!this.parentNode.nextElementSibling.matches("button"))this.parentNode.remove();else{const e=this.parentNode;if(e){let t=e.querySelector(".myd-repeater-summary__title");t&&(t.innerText="")}const t=e.querySelectorAll(".myd-repeater-input");t.length>0&&t.forEach(e=>{"checkbox"!==e.type&&"hidden"!==e.type?e.value="":e.checked=!1})}}function o(){if(this.parentNode.parentNode.previousElementSibling.matches("details")||!this.parentNode.parentNode.previousElementSibling.matches("details")&&this.parentNode.parentNode.nextElementSibling.matches("details"))this.parentNode.parentNode.remove();else{const e=this.parentNode.parentNode;if(e){const t=e.querySelector(".myd-repeater-summary__title");t&&(t.innerText="")}const t=e.querySelectorAll(".myd-repeater-input");t.length>0&&t.forEach(e=>{"checkbox"!==e.type&&"hidden"!==e.type?e.value="":e.checked=!1})}}function l(e){const t=e.parentNode.querySelector("details:last-of-type").cloneNode(!0),n=t.querySelector(".myd-repeater-summary__title");n&&(n.innerText="");const r=t.querySelectorAll(".myd-repeater-input");r.length>0&&r.forEach(e=>{let t=e.dataset.name;const n=e.dataset.mainIndex,r=e.dataset.internalIndex||"";if(n&&t){const a=Number(r)+1;t=t.replace(/{{main-index}}/,n),t=t.replace(/{{internal-index}}/,a),e.name=t,e.dataset.internalIndex=a,"checkbox"!==e.type&&"hidden"!==e.type?e.value="":e.checked=!1}});const a=t.querySelector(".myd-repeater-summary__action--remove");a&&a.addEventListener("click",o),e.parentNode.insertBefore(t,e)}r.length>0&&r.forEach(e=>{e.addEventListener("click",t=>{t.preventDefault(),function(e){const t=e.parentNode.querySelector(".myd-repeater-container--top-level:last-of-type").cloneNode(!0),n=t.querySelectorAll("details.myd-repeater-container:not(:first-of-type)");n.length>0&&n.forEach(e=>{e.remove()});const r=t.querySelector(".myd-repeater-summary__title");r&&(r.innerText="");const o=t.querySelectorAll(".myd-repeater-input");o.length>0&&o.forEach(e=>{let t=e.dataset.mainIndex,n=e.dataset.name,r=e.dataset.internalIndex||"";if(t&&n){let a=Number(t)+1;n=n.replace(/{{main-index}}/,a),n=n.replace(/{{internal-index}}/,r),e.name=n,e.dataset.mainIndex=a,"checkbox"!==e.type&&"hidden"!==e.type?e.value="":e.checked=!1}});const c=t.querySelector(".myd-repeater-container__remove");c&&c.addEventListener("click",a);const d=t.querySelector(".myd-repeater-add-option");d&&d.addEventListener("click",e=>{e.preventDefault(),l(d)}),e.parentNode.insertBefore(t,e)}(e)})})})();
  • myd-delivery/trunk/includes/custom-fields/class-custom-fields.php

    r3379132 r3383704  
    180180        }
    181181
    182         return implode( $output_data_attr );
     182        return implode( ' ', $output_data_attr );
    183183    }
    184184
     
    244244            isset( $args['required'] ) && $args['required'] === true ? 'required' : '',
    245245            isset( $args['data'] ) ? $this->build_data_attr( $args['data'] ) : '',
    246             esc_attr( $value )
     246            esc_textarea( $value )
    247247        );
    248248    }
  • myd-delivery/trunk/myd-delivery.php

    r3383604 r3383704  
    66 * Author: EduardoVillao.me
    77 * Author URI: https://eduardovillao.me/
    8  * Version: 1.2.1
     8 * Version: 1.2.2
    99 * Requires PHP: 7.4
    1010 * Requires at least: 5.5
     
    2626define( 'MYDDELIVERY_BASENAME', plugin_basename( __FILE__ ) );
    2727define( 'MYDDELIVERY_DIRNAME', plugin_basename( __DIR__ ) );
    28 define( 'MYDDELIVERY_VERSION', '1.2.1' );
     28define( 'MYDDELIVERY_VERSION', '1.2.2' );
    2929define( 'MYDDELIVERY_MIN_PHP_VERSION', '7.4' );
    3030define( 'MYDDELIVERY_MIN_WP_VERSION', '5.5' );
  • myd-delivery/trunk/src/js/admin/custom-fields/repeater.js

    r3379132 r3383704  
    22 * Remove extra option
    33 */
    4 const removeOption = document.querySelectorAll('.myd-repeater-summary__action--remove');
     4const removeOption = document.querySelectorAll(
     5    '.myd-repeater-summary__action--remove'
     6);
    57if (removeOption.length > 0) {
    68    removeOption.forEach((item) => {
     
    1214 * Remove product extra
    1315 */
    14 const removeProductExtraButtons = document.querySelectorAll('.myd-repeater-container__remove');
     16const removeProductExtraButtons = document.querySelectorAll(
     17    '.myd-repeater-container__remove'
     18);
    1519if (removeProductExtraButtons.length > 0) {
    1620    removeProductExtraButtons.forEach((item) => {
     
    1822    });
    1923}
    20 
    2124
    2225/**
     
    5053 */
    5154function removeProductExtra() {
    52     if(
     55    if (
    5356        this.parentNode.previousElementSibling ||
    54         !this.parentNode.previousElementSibling &&
    55         !this.parentNode.nextElementSibling.matches('button')
    56         ) {
     57        (!this.parentNode.previousElementSibling &&
     58            !this.parentNode.nextElementSibling.matches('button'))
     59    ) {
    5760        this.parentNode.remove();
    5861    } else {
    5962        const extraOptionItem = this.parentNode;
    60         if(extraOptionItem) {
    61             let summaryTitle = extraOptionItem.querySelector('.myd-repeater-summary__title');
    62             if(summaryTitle) {
     63        if (extraOptionItem) {
     64            let summaryTitle = extraOptionItem.querySelector(
     65                '.myd-repeater-summary__title'
     66            );
     67            if (summaryTitle) {
    6368                summaryTitle.innerText = '';
    6469            }
     
    6671
    6772        const inputs = extraOptionItem.querySelectorAll('.myd-repeater-input');
    68         if(inputs.length > 0) {
     73        if (inputs.length > 0) {
    6974            inputs.forEach((item) => {
    70                 if(item.type !== 'checkbox' && item.type !== 'hidden') {
     75                if (item.type !== 'checkbox' && item.type !== 'hidden') {
    7176                    item.value = '';
    7277                } else {
     
    8287 */
    8388function removeExtraOption() {
    84     if(
     89    if (
    8590        this.parentNode.parentNode.previousElementSibling.matches('details') ||
    86         !this.parentNode.parentNode.previousElementSibling.matches('details') &&
    87         this.parentNode.parentNode.nextElementSibling.matches('details')
    88         ) {
     91        (!this.parentNode.parentNode.previousElementSibling.matches(
     92            'details'
     93        ) &&
     94            this.parentNode.parentNode.nextElementSibling.matches('details'))
     95    ) {
    8996        this.parentNode.parentNode.remove();
    9097    } else {
    9198        const extraOptionItem = this.parentNode.parentNode;
    92         if(extraOptionItem) {
    93             let summaryTitle = extraOptionItem.querySelector('.myd-repeater-summary__title');
    94             if(summaryTitle) {
     99        if (extraOptionItem) {
     100            const summaryTitle = extraOptionItem.querySelector(
     101                '.myd-repeater-summary__title'
     102            );
     103            if (summaryTitle) {
    95104                summaryTitle.innerText = '';
    96105            }
     
    98107
    99108        const inputs = extraOptionItem.querySelectorAll('.myd-repeater-input');
    100         if(inputs.length > 0) {
     109        if (inputs.length > 0) {
    101110            inputs.forEach((item) => {
    102                 if(item.type !== 'checkbox' && item.type !== 'hidden') {
     111                if (item.type !== 'checkbox' && item.type !== 'hidden') {
    103112                    item.value = '';
    104113                } else {
     
    110119}
    111120
    112 
    113121/**
    114122 * Add new option
    115123 */
    116124function addNewOption(element) {
    117     const lastElement = element.parentNode.querySelector('details:last-of-type'),
    118     newElement = lastElement.cloneNode(true);
    119 
    120     let summaryTitle = newElement.querySelector('.myd-repeater-summary__title');
    121     if(summaryTitle) {
     125    const lastElement = element.parentNode.querySelector(
     126            'details:last-of-type'
     127        ),
     128        newElement = lastElement.cloneNode(true);
     129
     130    const summaryTitle = newElement.querySelector(
     131        '.myd-repeater-summary__title'
     132    );
     133    if (summaryTitle) {
    122134        summaryTitle.innerText = '';
    123135    }
    124136
    125137    const inputs = newElement.querySelectorAll('.myd-repeater-input');
    126     if(inputs.length > 0) {
     138    if (inputs.length > 0) {
    127139        inputs.forEach((item) => {
    128             let mainIndex = item.dataset.mainIndex,
    129             loopName = item.dataset.name,
    130             internalIndex = item.dataset.internalIndex || '';
    131 
    132             if(mainIndex && loopName) {
    133                 let newInternalKey = Number(internalIndex) + 1;
     140            let loopName = item.dataset.name;
     141            const mainIndex = item.dataset.mainIndex,
     142                internalIndex = item.dataset.internalIndex || '';
     143
     144            if (mainIndex && loopName) {
     145                const newInternalKey = Number(internalIndex) + 1;
    134146
    135147                loopName = loopName.replace(/{{main-index}}/, mainIndex);
    136                 loopName = loopName.replace(/{{internal-index}}/, newInternalKey);
     148                loopName = loopName.replace(
     149                    /{{internal-index}}/,
     150                    newInternalKey
     151                );
    137152                item.name = loopName;
    138153                item.dataset.internalIndex = newInternalKey;
    139                 if(item.type !== 'checkbox' && item.type !== 'hidden') {
    140                     item.value = '';
    141                 } else {
    142                     item.checked = false;
    143                 }
    144             }
    145         });
    146     }
    147 
    148     const removeExtraButton = newElement.querySelector('.myd-repeater-summary__action--remove');
    149     if(removeExtraButton) {
     154                if (item.type !== 'checkbox' && item.type !== 'hidden') {
     155                    item.value = '';
     156                } else {
     157                    item.checked = false;
     158                }
     159            }
     160        });
     161    }
     162
     163    const removeExtraButton = newElement.querySelector(
     164        '.myd-repeater-summary__action--remove'
     165    );
     166    if (removeExtraButton) {
    150167        removeExtraButton.addEventListener('click', removeExtraOption);
    151168    }
     
    159176 */
    160177function addNewExtra(element) {
    161     const extraContainer = element.parentNode.querySelector('.myd-repeater-container--top-level:last-of-type'),
    162     newExtra = extraContainer.cloneNode(true);
     178    const extraContainer = element.parentNode.querySelector(
     179            '.myd-repeater-container--top-level:last-of-type'
     180        ),
     181        newExtra = extraContainer.cloneNode(true);
    163182
    164183    /**
    165184     * Clean extra items
    166185     */
    167     let details = newExtra.querySelectorAll('details.myd-repeater-container:not(:first-of-type)');
    168     if(details.length > 0) {
     186    const details = newExtra.querySelectorAll(
     187        'details.myd-repeater-container:not(:first-of-type)'
     188    );
     189    if (details.length > 0) {
    169190        details.forEach((item) => {
    170191            item.remove();
     
    172193    }
    173194
    174     let summaryTitle = newExtra.querySelector('.myd-repeater-summary__title');
    175     if(summaryTitle) {
     195    const summaryTitle = newExtra.querySelector('.myd-repeater-summary__title');
     196    if (summaryTitle) {
    176197        summaryTitle.innerText = '';
    177198    }
    178199
    179200    const inputs = newExtra.querySelectorAll('.myd-repeater-input');
    180     if(inputs.length > 0) {
     201    if (inputs.length > 0) {
    181202        inputs.forEach((item) => {
    182203            let mainIndex = item.dataset.mainIndex,
    183             loopName = item.dataset.name,
    184             internalIndex = item.dataset.internalIndex || '';
    185 
    186             if(mainIndex && loopName) {
     204                loopName = item.dataset.name,
     205                internalIndex = item.dataset.internalIndex || '';
     206
     207            if (mainIndex && loopName) {
    187208                let newMainKey = Number(mainIndex) + 1;
    188209
    189210                loopName = loopName.replace(/{{main-index}}/, newMainKey);
    190                 loopName = loopName.replace(/{{internal-index}}/, internalIndex);
     211                loopName = loopName.replace(
     212                    /{{internal-index}}/,
     213                    internalIndex
     214                );
    191215                item.name = loopName;
    192216                item.dataset.mainIndex = newMainKey;
    193                 if(item.type !== 'checkbox' && item.type !== 'hidden') {
    194                     item.value = '';
    195                 } else {
    196                     item.checked = false;
    197                 }
    198             }
    199         });
    200     }
    201 
    202     const removeExtraButton = newExtra.querySelector('.myd-repeater-container__remove');
    203     if(removeExtraButton) {
     217                if (item.type !== 'checkbox' && item.type !== 'hidden') {
     218                    item.value = '';
     219                } else {
     220                    item.checked = false;
     221                }
     222            }
     223        });
     224    }
     225
     226    const removeExtraButton = newExtra.querySelector(
     227        '.myd-repeater-container__remove'
     228    );
     229    if (removeExtraButton) {
    204230        removeExtraButton.addEventListener('click', removeProductExtra);
    205231    }
    206232
    207233    const addOptionButton = newExtra.querySelector('.myd-repeater-add-option');
    208     if(addOptionButton) {
     234    if (addOptionButton) {
    209235        addOptionButton.addEventListener('click', (event) => {
    210236            event.preventDefault();
  • myd-delivery/trunk/src/js/modules/input-mask.js

    r3379132 r3383704  
    3030    handleBackspace(event) {
    3131        const input = event.target;
    32         if (event.key === 'Backspace' && input.selectionStart === input.selectionEnd) {
     32        if (
     33            event.key === 'Backspace' &&
     34            input.selectionStart === input.selectionEnd
     35        ) {
    3336            const pos = input.selectionStart;
    3437            if (pos > 0) {
  • myd-delivery/trunk/src/js/order/controller.js

    r3379132 r3383704  
    7777
    7878    // TODO: move to inside a shipping class
    79     if (window.MydOrder.shipping.validateZipcodeShipping(window.MydOrder.type) === false) {
     79    if (
     80        window.MydOrder.shipping.validateZipcodeShipping(
     81            window.MydOrder.type
     82        ) === false
     83    ) {
    8084        window.Myd.notificationBar(
    8185            'error',
  • myd-delivery/trunk/src/js/order/modules/autocomplete-address.js

    r3379132 r3383704  
    2222                        if (!('erro' in dados)) {
    2323                            if (dados.logradouro !== '') {
    24                                 document.getElementById('input-delivery-street-name').value = dados.logradouro;
    25                                 document.getElementById('input-delivery-street-name').style.background = '#efefef';
    26                                 document.getElementById('input-delivery-address-number').focus();
     24                                document.getElementById(
     25                                    'input-delivery-street-name'
     26                                ).value = dados.logradouro;
     27                                document.getElementById(
     28                                    'input-delivery-street-name'
     29                                ).style.background = '#efefef';
     30                                document
     31                                    .getElementById(
     32                                        'input-delivery-address-number'
     33                                    )
     34                                    .focus();
    2735                            } else {
    28                                 document.getElementById('input-delivery-street-name').value = '';
     36                                document.getElementById(
     37                                    'input-delivery-street-name'
     38                                ).value = '';
    2939                            }
    3040
    3141                            if (dados.logradouro !== '') {
    32                                 document.getElementById('input-delivery-neighborhood').value = dados.bairro;
     42                                document.getElementById(
     43                                    'input-delivery-neighborhood'
     44                                ).value = dados.bairro;
    3345                            }
    3446                        }
  • myd-delivery/trunk/src/js/order/modules/checkout.js

    r3379132 r3383704  
    3737            couponCode: document.getElementById('input-coupon'),
    3838            street: document.getElementById('input-delivery-street-name'),
    39             streetNumber: document.getElementById('input-delivery-address-number'),
     39            streetNumber: document.getElementById(
     40                'input-delivery-address-number'
     41            ),
    4042            addressComplement: document.getElementById('input-delivery-comp'),
    41             neighborhood: document.getElementById('input-delivery-neighborhood'),
     43            neighborhood: document.getElementById(
     44                'input-delivery-neighborhood'
     45            ),
    4246            zipcode: document.getElementById('input-delivery-zipcode'),
    4347            table: document.getElementById('input-in-store-table'),
  • myd-delivery/trunk/src/js/order/modules/shipping.js

    r3379132 r3383704  
    2828
    2929    SetGoogleMapsApi() {
    30         const input = document.getElementById('input-delivery-autocomplete-address');
     30        const input = document.getElementById(
     31            'input-delivery-autocomplete-address'
     32        );
    3133        const options = {
    3234            fields: ['formatted_address', 'geometry', 'address_components'],
     
    3941        }
    4042
    41         const autocomplete = new google.maps.places.Autocomplete(input, options);
     43        const autocomplete = new google.maps.places.Autocomplete(
     44            input,
     45            options
     46        );
    4247        autocomplete.addListener('place_changed', () => {
    4348            const place = autocomplete.getPlace();
    44             if (!place.geometry || !place.geometry.location || !place.address_components) {
    45                 window.alert("No details available for input: '" + place.name + "'");
     49            if (
     50                !place.geometry ||
     51                !place.geometry.location ||
     52                !place.address_components
     53            ) {
     54                window.alert(
     55                    "No details available for input: '" + place.name + "'"
     56                );
    4657                return;
    4758            }
    4859
    49             const inputFormatedAddress = document.getElementsByName('input-delivery-formated-address');
    50             const inputLatitude = document.getElementsByName('input-delivery-latitude');
    51             const inputLongitude = document.getElementsByName('input-delivery-longitude');
     60            const inputFormatedAddress = document.getElementsByName(
     61                'input-delivery-formated-address'
     62            );
     63            const inputLatitude = document.getElementsByName(
     64                'input-delivery-latitude'
     65            );
     66            const inputLongitude = document.getElementsByName(
     67                'input-delivery-longitude'
     68            );
    5269            if (inputLatitude && inputLongitude && inputFormatedAddress) {
    5370                inputFormatedAddress[0].value = place.formatted_address;
     
    5774
    5875            if (place.address_components.length > 0) {
    59                 const streetNumber = place.address_components.filter((address_data) => {
    60                     return address_data.types.includes('street_number');
    61                 });
    62 
    63                 const zipcode = place.address_components.filter((address_data) => {
    64                     return address_data.types.includes('postal_code');
    65                 });
    66 
    67                 const streetName = place.address_components.filter((address_data) => {
    68                     return address_data.types.includes('route');
    69                 });
    70 
    71                 const neighborhood = place.address_components.filter((address_data) => {
    72                     return address_data.types.includes('sublocality_level_1');
    73                 });
    74 
    75                 const streetNumberInput = document.getElementById('input-delivery-address-number');
     76                const streetNumber = place.address_components.filter(
     77                    (address_data) => {
     78                        return address_data.types.includes('street_number');
     79                    }
     80                );
     81
     82                const zipcode = place.address_components.filter(
     83                    (address_data) => {
     84                        return address_data.types.includes('postal_code');
     85                    }
     86                );
     87
     88                const streetName = place.address_components.filter(
     89                    (address_data) => {
     90                        return address_data.types.includes('route');
     91                    }
     92                );
     93
     94                const neighborhood = place.address_components.filter(
     95                    (address_data) => {
     96                        return address_data.types.includes(
     97                            'sublocality_level_1'
     98                        );
     99                    }
     100                );
     101
     102                const streetNumberInput = document.getElementById(
     103                    'input-delivery-address-number'
     104                );
    76105                if (streetNumberInput) {
    77                     streetNumberInput.value = streetNumber.length > 0 ? streetNumber[0].long_name : '';
    78                 }
    79 
    80                 const zipcodeInput = document.getElementById('input-delivery-zipcode');
     106                    streetNumberInput.value =
     107                        streetNumber.length > 0
     108                            ? streetNumber[0].long_name
     109                            : '';
     110                }
     111
     112                const zipcodeInput = document.getElementById(
     113                    'input-delivery-zipcode'
     114                );
    81115                if (zipcodeInput) {
    82                     zipcodeInput.value = zipcode.length > 0 ? zipcode[0].long_name : '00000000';
    83                 }
    84 
    85                 const streetNameInput = document.getElementById('input-delivery-street-name');
     116                    zipcodeInput.value =
     117                        zipcode.length > 0 ? zipcode[0].long_name : '00000000';
     118                }
     119
     120                const streetNameInput = document.getElementById(
     121                    'input-delivery-street-name'
     122                );
    86123                if (streetNameInput) {
    87                     streetNameInput.value = streetName.length > 0 ? streetName[0].long_name : '';
    88                 }
    89 
    90                 const neighborhoodInput = document.getElementById('input-delivery-neighborhood');
     124                    streetNameInput.value =
     125                        streetName.length > 0 ? streetName[0].long_name : '';
     126                }
     127
     128                const neighborhoodInput = document.getElementById(
     129                    'input-delivery-neighborhood'
     130                );
    91131                if (neighborhoodInput) {
    92                     neighborhoodInput.value = neighborhood.length > 0 ? neighborhood[0].long_name : '';
     132                    neighborhoodInput.value =
     133                        neighborhood.length > 0
     134                            ? neighborhood[0].long_name
     135                            : '';
    93136                }
    94137            }
     
    98141    async getPriceByDistance() {
    99142        const options = mydStoreInfo.deliveryShipping.options;
    100         const inputLatitude = document.getElementsByName('input-delivery-latitude');
    101         const inputLongitude = document.getElementsByName('input-delivery-longitude');
     143        const inputLatitude = document.getElementsByName(
     144            'input-delivery-latitude'
     145        );
     146        const inputLongitude = document.getElementsByName(
     147            'input-delivery-longitude'
     148        );
    102149        if (!inputLatitude || !inputLongitude) {
    103150            console.error('Missed latitude and longitude to destination');
     
    149196    getPriceByNeighborhood() {
    150197        const neighborhoodList = mydStoreInfo.deliveryShipping.options,
    151             neighborhoodInputValue = document.getElementById('input-delivery-neighborhood').value,
     198            neighborhoodInputValue = document.getElementById(
     199                'input-delivery-neighborhood'
     200            ).value,
    152201            val = [];
    153202
    154203        Object.keys(neighborhoodList.options).forEach((item) => {
    155             if(neighborhoodList.options[item].from === neighborhoodInputValue) {
     204            if (
     205                neighborhoodList.options[item].from === neighborhoodInputValue
     206            ) {
    156207                val.push(neighborhoodList.options[item].price);
    157208            }
     
    167218            ),
    168219            val = [];
    169         Object.keys(zipcodeList.options).forEach( item => {
     220        Object.keys(zipcodeList.options).forEach((item) => {
    170221            if (
    171222                zipcodeInputValue >= zipcodeList.options[item].from &&
     
    193244        ) {
    194245            let zipcodeList = mydStoreInfo.deliveryShipping.options,
    195             zipcodeInputValue = parseInt(document.getElementById('input-delivery-zipcode').value),
    196             val = [];
    197 
    198             Object.keys(zipcodeList.options).forEach( item => {
    199                 if (zipcodeInputValue >= zipcodeList.options[item].from && zipcodeInputValue <= zipcodeList.options[item].to) {
     246                zipcodeInputValue = parseInt(
     247                    document.getElementById('input-delivery-zipcode').value
     248                ),
     249                val = [];
     250
     251            Object.keys(zipcodeList.options).forEach((item) => {
     252                if (
     253                    zipcodeInputValue >= zipcodeList.options[item].from &&
     254                    zipcodeInputValue <= zipcodeList.options[item].to
     255                ) {
    200256                    val.push(true);
    201257                }
Note: See TracChangeset for help on using the changeset viewer.