1/* global Cookies */ 2jQuery( function( $ ) { 3 // Orderby 4 $( '.woocommerce-ordering' ).on( 'change', 'select.orderby', function() { 5 $( this ).closest( 'form' ).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( 'notice-id' ) || '', 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' ).click( function( event ) { 29 Cookies.set( cookieName, 'hidden', { path: '/' } ); 30 $( '.woocommerce-store-notice' ).hide(); 31 event.preventDefault(); 32 }); 33 34 // Make form field descriptions toggle on focus. 35 if ( $( '.woocommerce-input-wrapper span.description' ).length ) { 36 $( document.body ).on( 'click', function() { 37 $( '.woocommerce-input-wrapper span.description:visible' ).prop( 'aria-hidden', true ).slideUp( 250 ); 38 } ); 39 } 40 41 $( '.woocommerce-input-wrapper' ).on( 'click', function( event ) { 42 event.stopPropagation(); 43 } ); 44 45 $( '.woocommerce-input-wrapper :input' ) 46 .on( 'keydown', function( event ) { 47 var input = $( this ), 48 parent = input.parent(), 49 description = parent.find( 'span.description' ); 50 51 if ( 27 === event.which && description.length && description.is( ':visible' ) ) { 52 description.prop( 'aria-hidden', true ).slideUp( 250 ); 53 event.preventDefault(); 54 return false; 55 } 56 } ) 57 .on( 'click focus', function() { 58 var input = $( this ), 59 parent = input.parent(), 60 description = parent.find( 'span.description' ); 61 62 parent.addClass( 'currentTarget' ); 63 64 $( '.woocommerce-input-wrapper:not(.currentTarget) span.description:visible' ).prop( 'aria-hidden', true ).slideUp( 250 ); 65 66 if ( description.length && description.is( ':hidden' ) ) { 67 description.prop( 'aria-hidden', false ).slideDown( 250 ); 68 } 69 70 parent.removeClass( 'currentTarget' ); 71 } ); 72 73 // Common scroll to element code. 74 $.scroll_to_notices = function( scrollElement ) { 75 if ( scrollElement.length ) { 76 $( 'html, body' ).animate( { 77 scrollTop: ( scrollElement.offset().top - 100 ) 78 }, 1000 ); 79 } 80 }; 81 82 // Show password visiblity hover icon on woocommerce forms 83 $( '.woocommerce form .woocommerce-Input[type="password"]' ).wrap( '<span class="password-input"></span>' ); 84 // Add 'password-input' class to the password wrapper in checkout page. 85 $( '.woocommerce form input' ).filter(':password').parent('span').addClass('password-input'); 86 $( '.password-input' ).append( '<span class="show-password-input"></span>' ); 87 88 $( '.show-password-input' ).click( 89 function() { 90 $( this ).toggleClass( 'display-password' ); 91 if ( $( this ).hasClass( 'display-password' ) ) { 92 $( this ).siblings( ['input[type="password"]'] ).prop( 'type', 'text' ); 93 } else { 94 $( this ).siblings( 'input[type="text"]' ).prop( 'type', 'password' ); 95 } 96 } 97 ); 98});
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.