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 $( '.password-input' ).append( 108 '<span class="show-password-input"></span>' 109 ); 110 111 $( '.show-password-input' ).on( 'click', function () { 112 if ( $( this ).hasClass( 'display-password' ) ) { 113 $( this ).removeClass( 'display-password' ); 114 } else { 115 $( this ).addClass( 'display-password' ); 116 } 117 if ( $( this ).hasClass( 'display-password' ) ) { 118 $( this ) 119 .siblings( [ 'input[type="password"]' ] ) 120 .prop( 'type', 'text' ); 121 } else { 122 $( this ) 123 .siblings( 'input[type="text"]' ) 124 .prop( 'type', 'password' ); 125 } 126 } ); 127 128 $( 'a.coming-soon-footer-banner-dismiss' ).on( 'click', function ( e ) { 129 var target = $( e.target ); 130 $.ajax( { 131 type: 'post', 132 url: target.data( 'rest-url' ), 133 data: { 134 woocommerce_meta: { 135 coming_soon_banner_dismissed: 'yes', 136 }, 137 }, 138 beforeSend: function ( xhr ) { 139 xhr.setRequestHeader( 140 'X-WP-Nonce', 141 target.data( 'rest-nonce' ) 142 ); 143 }, 144 complete: function () { 145 $( '#coming-soon-footer-banner' ).hide(); 146 }, 147 } ); 148 } ); 149}); 150 151document.addEventListener( 'DOMContentLoaded' , function() { 152 var noticeClasses = [ 'woocommerce-message', 'woocommerce-error', 'wc-block-components-notice-banner' ]; 153 var noticeSelectors = noticeClasses.map( function( className ) { 154 return '.' + className + '[role="alert"]'; 155 } ).join( ', ' ); 156 var noticeElements = document.querySelectorAll( noticeSelectors ); 157 158 if ( noticeElements.length === 0 ) { 159 return; 160 } 161 162 var firstNotice = noticeElements[0]; 163 164 firstNotice.setAttribute( 'tabindex', '-1' ); 165 166 // Wait for the element to get the tabindex attribute so it can be focused. 167 var delayFocusNoticeId = setTimeout( function() { 168 firstNotice.focus(); 169 clearTimeout( delayFocusNoticeId ); 170 }, 500 ); 171} );
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.