https://www.mooviment.com/wp-content/plugins/woocommerce/assets/js/frontend/woocommerce.js?ver=9.8.7
1/* global Cookies */ 2jQuery( function ( $ ) { 3 // Orderby 4 $( '.woocommerce-ordering' ).on( 'change', 'select.orderby', function () { 5 $( this ).closest( 'form' ).trigger( 'submit' ); 6 } ); 7 8 // Target quantity inputs on product pages 9 $( 'input.qty:not(.product-quantity input.qty)' ).each( function () { 10 var min = parseFloat( $( this ).attr( 'min' ) ); 11 12 if ( min >= 0 && parseFloat( $( this ).val() ) < min ) { 13 $( this ).val( min ); 14 } 15 } ); 16 17 var noticeID = $( '.woocommerce-store-notice' ).data( 'noticeId' ) || '', 18 cookieName = 'store_notice' + noticeID; 19 20 // Check the value of that cookie and show/hide the notice accordingly 21 if ( 'hidden' === Cookies.get( cookieName ) ) { 22 $( '.woocommerce-store-notice' ).hide(); 23 } else { 24 $( '.woocommerce-store-notice' ).show(); 25 } 26 27 // Set a cookie and hide the store notice when the dismiss button is clicked 28 $( '.woocommerce-store-notice__dismiss-link' ).on( 29 'click', 30 function ( event ) { 31 Cookies.set( cookieName, 'hidden', { path: '/' } ); 32 $( '.woocommerce-store-notice' ).hide(); 33 event.preventDefault(); 34 } 35 ); 36 37 // Make form field descriptions toggle on focus. 38 if ( $( '.woocommerce-input-wrapper span.description' ).length ) { 39 $( document.body ).on( 'click', function () { 40 $( '.woocommerce-input-wrapper span.description:visible' ) 41 .prop( 'aria-hidden', true ) 42 .slideUp( 250 ); 43 } ); 44 } 45 46 $( '.woocommerce-input-wrapper' ).on( 'click', function ( event ) { 47 event.stopPropagation(); 48 } ); 49 50 $( '.woocommerce-input-wrapper :input' ) 51 .on( 'keydown', function ( event ) { 52 var input = $( this ), 53 parent = input.parent(), 54 description = parent.find( 'span.description' ); 55 56 if ( 57 27 === event.which && 58 description.length && 59 description.is( ':visible' ) 60 ) { 61 description.prop( 'aria-hidden', true ).slideUp( 250 ); 62 event.preventDefault(); 63 return false; 64 } 65 } ) 66 .on( 'click focus', function () { 67 var input = $( this ), 68 parent = input.parent(), 69 description = parent.find( 'span.description' ); 70 71 parent.addClass( 'currentTarget' ); 72 73 $( 74 '.woocommerce-input-wrapper:not(.currentTarget) span.description:visible' 75 ) 76 .prop( 'aria-hidden', true ) 77 .slideUp( 250 ); 78 79 if ( description.length && description.is( ':hidden' ) ) { 80 description.prop( 'aria-hidden', false ).slideDown( 250 ); 81 } 82 83 parent.removeClass( 'currentTarget' ); 84 } ); 85 86 // Common scroll to element code. 87 $.scroll_to_notices = function ( scrollElement ) { 88 if ( scrollElement.length ) { 89 $( 'html, body' ).animate( 90 { 91 scrollTop: scrollElement.offset().top - 100, 92 }, 93 1000 94 ); 95 } 96 }; 97 98 // Show password visibility hover icon on woocommerce forms 99 $( '.woocommerce form .woocommerce-Input[type="password"]' ).wrap( 100 '<span class="password-input"></span>' 101 ); 102 // Add 'password-input' class to the password wrapper in checkout page. 103 $( '.woocommerce form input' ) 104 .filter( ':password' ) 105 .parent( 'span' ) 106 .addClass( 'password-input' ); 107 108 $( '.password-input' ).each( function () { 109 const describedBy = $( this ).find( 'input' ).attr( 'id' ); 110 $( this ).append( 111 '<button class="show-password-input" aria-label="' + 112 woocommerce_params.i18n_password_show + 113 '" aria-describedBy="' + 114 describedBy + 115 '"></button>' 116 ); 117 118 $( this ).on( 'keydown', function ( event ) { 119 if ( 'Enter' === event.key ) { 120 event.preventDefault(); 121 } 122 } ); 123 } ); 124 125 $( '.show-password-input' ).on( 'click', function ( event ) { 126 event.preventDefault(); 127 128 if ( $( this ).hasClass( 'display-password' ) ) { 129 $( this ).removeClass( 'display-password' ); 130 $( this ).attr( 131 'aria-label', 132 woocommerce_params.i18n_password_show 133 ); 134 } else { 135 $( this ).addClass( 'display-password' ); 136 $( this ).attr( 137 'aria-label', 138 woocommerce_params.i18n_password_hide 139 ); 140 } 141 if ( $( this ).hasClass( 'display-password' ) ) { 142 $( this ) 143 .siblings( [ 'input[type="password"]' ] ) 144 .prop( 'type', 'text' ); 145 } else { 146 $( this ) 147 .siblings( 'input[type="text"]' ) 148 .prop( 'type', 'password' ); 149 } 150 151 $( this ).siblings( 'input' ).focus(); 152 } ); 153 154 $( '#customer_login .password-input' ).on( 'keydown', function ( event ) { 155 if ( 'Enter' === event.key ) { 156 $( this ) 157 .closest( 'form' ) 158 .find( '[type=submit]' ) 159 .click(); 160 } 161 } ); 162 163 $( 'a.coming-soon-footer-banner-dismiss' ).on( 'click', function ( e ) { 164 var target = $( e.target ); 165 $.ajax( { 166 type: 'post', 167 url: target.data( 'rest-url' ), 168 data: { 169 woocommerce_meta: { 170 coming_soon_banner_dismissed: 'yes', 171 }, 172 }, 173 beforeSend: function ( xhr ) { 174 xhr.setRequestHeader( 175 'X-WP-Nonce', 176 target.data( 'rest-nonce' ) 177 ); 178 },
179 complete: function () { 180 $( '#coming-soon-footer-banner' ).hide(); 181 }, 182 } ); 183 } ); 184 185 $( document.body ).on( 'item_removed_from_classic_cart', focus_populate_live_region ); 186} ); 187 188/** 189 * Focus on the first notice element on the page. 190 * 191 * Populated live regions don't always are announced by screen readers. 192 * This function focus on the first notice message with the role="alert" 193 * attribute to make sure it's announced. 194 */ 195function focus_populate_live_region() { 196 var noticeClasses = [ 197 'woocommerce-message', 198 'woocommerce-error', 199 'wc-block-components-notice-banner', 200 ]; 201 var noticeSelectors = noticeClasses 202 .map( function ( className ) { 203 return '.' + className + '[role="alert"]'; 204 } ) 205 .join( ', ' ); 206 var noticeElements = document.querySelectorAll( noticeSelectors ); 207 208 if ( noticeElements.length === 0 ) { 209 return; 210 } 211 212 var firstNotice = noticeElements[ 0 ]; 213 214 firstNotice.setAttribute( 'tabindex', '-1' ); 215 216 // Wait for the element to get the tabindex attribute so it can be focused. 217 var delayFocusNoticeId = setTimeout( function () { 218 firstNotice.focus(); 219 clearTimeout( delayFocusNoticeId ); 220 }, 500 ); 221} 222 223/** 224 * Refresh the sorted by live region. 225 */ 226function refresh_sorted_by_live_region() { 227 var sorted_by_live_region = document.querySelector( 228 '.woocommerce-result-count[data-is-sorted-by="true"]' 229 ); 230 231 if ( sorted_by_live_region ) { 232 var text = sorted_by_live_region.innerHTML; 233 234 var sorted_by_live_region_id = setTimeout( function () { 235 sorted_by_live_region.innerHTML = ''; 236 sorted_by_live_region.innerHTML = text; 237 clearTimeout( sorted_by_live_region_id ); 238 }, 1000 ); 239 } 240} 241 242function on_document_ready() { 243 focus_populate_live_region(); 244 refresh_sorted_by_live_region(); 245} 246 247document.addEventListener( 'DOMContentLoaded', on_document_ready );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.