1/* 2 * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development"). 3 * This devtool is neither made for production nor for readable output files. 4 * It uses "eval()" calls to create a separate source file in the browser devtools. 5 * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/) 6 * or disable the default devtool with "devtool: false". 7 * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/). 8 */ 9/******/ (() => { // webpackBootstrap 10/******/ var __webpack_modules__ = ({ 11 12/***/ "./src/js/wcwl_frontend.js" 13/*!*********************************!*\ 14 !*** ./src/js/wcwl_frontend.js ***! 15 \*********************************/ 16() { 17 18eval("{// JS required for the front end\njQuery( document ).ready( function ( $ ) {\n var waitlist_display_class = 'block';\n wcwl_apply_event_on_page_update();\n wcwl_hook_up_variation_events();\n // Quickview\n $( 'body' ).on( 'quick-view-displayed', function () {\n wcwl_hook_up_variation_events();\n } );\n} );\n/* AJAX */\n// Stop the form submitting as normal if we can use JS and submit via AJAX\n// .bound class ensures the event is bound only once\nfunction wcwl_apply_event_on_page_update() {\n // Waitlist join/leave requests\n // Setup elements for single/shop page\n var waitlist_elements = '.wcwl_elements';\n if ( jQuery( '.wcwl_frontend_wrap' ).length ) {\n waitlist_elements = '.wcwl_frontend_wrap';\n }\n jQuery( '.wcwl_nojs' ).toggleClass( 'wcwl_nojs', false );\n jQuery( waitlist_elements + ':not(.bound)' ).addClass( 'bound' ).on( 'click', 'a.wcwl_control', function ( event ) {\n event.preventDefault();\n wcwl_reset_waitlist_elements( jQuery( this ) );\n wcwl_process_waitlist_request( jQuery( this ) );\n } );\n // Quickview\n jQuery( '.woocommerce.quick-view.single-product .wcwl_elements:not(.bound)' ).addClass( 'bound' ).on( 'click', 'a.wcwl_control', function ( event ) {\n event.preventDefault();\n jQuery( '.wcwl_notice' ).hide();\n wcwl_process_waitlist_request( jQuery( this ) );\n } );\n // Archive page toggle buttons\n jQuery( '.wcwl_toggle' ).on( 'click', 'button', function () {\n var current_wrap = jQuery( this ).closest( '.wcwl_frontend_wrap' );\n wcwl_toggle_archive_fields( current_wrap );\n current_wrap.find( '.wcwl_intro, .wcwl_optin, .wcwl_email_elements' ).show();\n } );\n // Notice dismiss buttons\n jQuery( '.wcwl_notice' ).on( 'click', '.wcwl_notice_dismiss', function () {\n jQuery( this ).closest( '.wcwl_notice' ).hide();\n if ( jQuery( '.wcwl_frontend_wrap' ).length ) {\n var current_wrap = jQuery( this ).closest( '.wcwl_frontend_wrap' );\n wcwl_toggle_archive_fields( current_wrap );\n current_wrap.find( '.spinner' ).hide();\n current_wrap.find( '.wcwl_toggle' ).show();\n current_wrap.find( '.wcwl_elements' ).hide();\n } else {\n var current_wrap = jQuery( this ).closest( '.wcwl_elements' );\n current_wrap.find( '.spinner' ).hide();\n current_wrap.find( '.wcwl_intro, .wcwl_optin, .wcwl_email_elements, .wcwl_control, .wcwl_control button' ).show();\n }\n } );\n wcwl_hide_waitlist_notice_if_empty();\n // Make buttons trigger when enter button pressed\n wcwl_add_keyboard_button_events();\n // Set display class to re-apply after AJAX\n if ( jQuery( waitlist_elements ).css( 'display' ) != undefined ) {\n waitlist_display_class = jQuery( waitlist_elements ).css( 'display' ) != undefined;\n }\n}\n\n/**\n * Hide/show required fields when on archive pages\n *\n * @param current_wrap\n */\nfunction wcwl_toggle_archive_fields( current_wrap ) {\n jQuery( '.wcwl_elements, .wcwl_notice' ).hide();\n jQuery( '.wcwl_toggle, .woocommerce_waitlist, .wcwl_frontend_wrap > .wcwl_control' ).show();\n current_wrap.find( '.wcwl_toggle' ).hide();\n current_wrap.find( '.wcwl_elements, .wcwl_email_elements, .wcwl_control, .wcwl_optin' ).show();\n}\n\nfunction wcwl_reset_waitlist_elements( button ) {\n if ( jQuery( '.wcwl_frontend_wrap' ).length ) {\n wcwl_toggle_archive_fields( button.closest( '.wcwl_frontend_wrap' ) );\n } else {\n jQuery( '.wcwl_elements, .wcwl_email_elements, .wcwl_control, .wcwl_optin, .wcwl_intro' ).show();\n jQuery( '.wcwl_notice' ).hide();\n button.closest( '.wcwl_elements' ).find( '.wcwl_intro' ).hide();\n }\n jQuery( '.wcwl_email, .wcwl_optin' ).removeClass( 'wcwl_error_highlight' );\n}\n\n/**\n * Process the AJAX request to reload waitlist HTML\n *\n * @param link\n */\nfunction wcwl_process_waitlist_request( link ) {\n var wrap = link.closest( '.wcwl_frontend_wrap' );\n if ( !wrap.length ) {\n wrap = link.closest( '.wcwl_elements' );\n }\n var errors = [];\n var email = wrap.find( 'input[name=\"wcwl_email\"]' );\n if ( !wcwl_check_email_field( email ) ) {\n errors.push( 'email' );\n }\n var checkbox = wrap.find( '.wcwl_optin input' );\n if ( !wcwl_check_optin_field( checkbox ) ) {\n errors.push( 'optin' );\n }\n if ( jQuery( 'div.product-type-grouped' ).length && wcwl_data.user_id == 0 ) {\n if ( ! jQuery( 'input.wcwl_checkbox:checked' ).length ) {\n errors.push( 'grouped_no_checked' );\n }\n }\n if ( errors.length == 0 ) {\n link.find( 'button' ).hide();\n wrap.find( '.wcwl_email_elements, .wcwl_optin' ).hide();\n link.find( '.spinner' ).show();\n wcwl_add_screenreader_message( wrap.find( '.wcwl_control' ), wcwl_data.loading_message );\n wcwl_process_ajax_request( wrap, link, email.val() );\n } else {\n wrap.find( '.wcwl_notice' ).hide();\n wrap.find( '.wcwl_intro, .wcwl_optin' ).show();\n if ( 'email' === errors[ 0 ] ) {\n email.focus();\n } else if ( 'optin' === errors[ 0 ] ) {\n checkbox.focus();\n } else if ( 'grouped_no_checked' === errors[ 0 ] ) {\n wrap.find( '.wcwl_notice p' ).text( wcwl_data.no_checkboxes_message );\n wrap.find( '.wcwl_notice' ).show();\n }\n }\n}\n// Process the AJAX request for user to join/leave waitlist\nfunction wcwl_process_ajax_request( wrap, link, email ) {\n var context = link.data( 'context' );\n var products = wcwl_get_grouped_products();\n var product_id = link.data( 'product-id' );\n var language = link.data( 'wpml-lang' );\n var data = {\n action: 'wcwl_process_user_waitlist_request',\n nonce: link.data( 'nonce' ),\n product_id: product_id,\n language: language,\n products: products,\n email: email,\n context: context,\n archive: wrap.hasClass( 'wcwl_frontend_wrap' ) ? 'true' : 'false'\n };\n jQuery( document.body ).trigger( 'wcwl_before_waitlist_request', data );\n jQuery.post( wcwl_data.ajax_url, data )\n .done( function ( response ) {\n if ( response?.data?.redirectUrl !== undefined) {\n let redirect_url = (response.data.redirectUrl !== \"\") ? response.data.redirectUrl : document.location;\n document.location = redirect_url;\n return;\n }\n var html = wrap;\n if ( response.success ) {\n html = response.data.html.replace( '<!-- wcwl_elements -->', '' );\n html = html.replace( '<!-- wcwl_frontend_wrap -->', '' );\n wrap.replaceWith( html );\n }\n if ( wrap.hasClass( 'wcwl_frontend_wrap' ) ) {\n // Archive page\n wcwl_process_dom_changes_on_archive_page( product_id, context, response );\n } else {\n // Single product\n if ( jQuery( '.single_variation_wrap' ).length ) {\n wcwl_update_availability_html_on_variation_form( html, product_id );\n }\n var new_wrap = jQuery( '.wcwl_control[data-product-id=\"' + product_id + '\"]' ).closest( '.wcwl_elements' );\n if ( new_wrap.length ) {\n new_wrap.find( '.wcwl_intro' ).hide();\n if ( ! response.success ) {\n new_wrap.find( '.wcwl_notice p' ).text( response.data );\n }\n new_wrap.find( '.wcwl_notice' ).show();\n new_wrap.css( 'display', waitlist_display_class );\n if ( 'none' === waitlist_display_class || undefined === waitlist_display_class ) {\n new_wrap.show();\n }\n }\n }\n // Avoid duplicate notices with Quickview\n if ( jQuery( '.woocommerce.quick-view.single-product .product-type-simple' ).length ) {\n jQuery( '.wcwl_frontend_wrap .wcwl_notice' ).hide();\n }\n wcwl_apply_event_on_page_update();\n jQuery( document.body ).trigger( 'wcwl_after_waitlist_request', [response, data] );\n } );\n}\n\n/**\n * Update the HTML for variations on waitlist update.\n *\n * @param html\n * @param product_id\n */\nfunction wcwl_update_availability_html_on_variation_form( html, product_id ) {\n var variations = jQuery( 'form.variations_form' ).data( 'product_variations' );\n jQuery.each( variations, function ( key, variation ) {\n if ( variation.variation_id === product_id ) {\n html = html.replace( '</div><!-- wcwl_elements -->', '' );\n var to_replace = variation.availability_html.substring( variation.availability_html.lastIndexOf( '<div class=\"wcwl_elements' ), variation.availability_html.lastIndexOf( '</div><!-- wcwl_elements -->' ) );\n variation.availability_html = variation.availability_html.replace( to_replace, html );\n variations[ key ] = variation;\n }\n } );\n jQuery( 'form.variations_form' ).data( 'product_variations', variations );\n}\n\n/**\n * Update the DOM when a waitlist request has completed on an archive page\n *\n * @param product_id\n * @param context\n * @param response\n */\nfunction wcwl_process_dom_changes_on_archive_page( product_id, context, response ) {\n var new_wrap = jQuery( 'a[data-product-id=\"' + product_id + '\"]' ).closest( '.wcwl_frontend_wrap' );\n new_wrap.find( '.wcwl_elements' ).css( 'display', waitlist_display_class );\n if ( ! response.success ) {\n new_wrap.find( '.wcwl_notice p' ).text( response.data );\n }\n new_wrap.find( '.wcwl_elements, .wcwl_notice' ).show();\n new_wrap.find( '.wcwl_notice' ).next( 'a button' ).hide();\n new_wrap.find( '.wcwl_intro, .wcwl_optin, .wcwl_email_elements, .wcwl_control' ).hide();\n if ( 'leave' === context ) {\n new_wrap.find( '.woocommerce_waitlist' ).text( new_wrap.find( 'input[name=\"wcwl_join_button_text\"]' ).val() );\n } else {\n // If we're logged in show the leave button immediately\n if ( wcwl_data.user_id != 0 ) {\n new_wrap.find( 'a.wcwl_control' ).show();\n }\n }\n // Move toggle button to below the notice\n new_wrap.find( '.wcwl_toggle' ).insertAfter( new_wrap.find( '.wcwl_elements' ) );\n}\n\n/* VARIABLE PRODUCTS */\n// This ensures all event triggers are hooked as required for variations\nfunction wcwl_hook_up_variation_events() {\n jQuery( 'form.variations_form' ).on( 'show_variation', function () {\n wcwl_apply_event_on_page_update();\n } );\n}\n\n/* BUNDLES */\nif ( typeof wcwl_bundle_data !== 'undefined' && jQuery( '.bundle_availability' ).length ) {\n jQuery( '.bundle_form .bundle_data' ).on( 'woocommerce-product-bundle-initialized, woocommerce-product-bundle-updated', function () {\n setTimeout( function () {\n wcwl_maybe_show_for_bundle();\n }, 300 );\n } );\n function wcwl_maybe_show_for_bundle() {\n jQuery( '.bundle_wrap .wcwl_elements' ).remove();\n if ( jQuery( '.bundle_availability' ).is( ':visible' ) && jQuery( '.bundle_availability .stock.out-of-stock' ).length ) {\n jQuery( wcwl_bundle_data.waitlist_html ).insertAfter( '.bundle_availability' );\n } else if ( wcwl_bundle_data.backorder_allowed && jQuery( '.bundle_availability' ).is( ':visible' ) && jQuery( '.bundle_availability .stock.available-on-backorder' ).length ) {\n jQuery( wcwl_bundle_data.waitlist_html ).insertAfter( '.bundle_availability' );\n }\n wcwl_apply_event_on_page_update();\n }\n}\n\n\n/* EVENTS */\n// There are no hooks available to insert our waitlist HTML for tickets so we add it to the page with JS\n// Works for older versions of Event tickets (4.11 and earlier)\nif ( typeof wcwl_event_data !== 'undefined' && jQuery( '#tribe-events' ).length ) {\n var wcwl_tickets = jQuery( '.woocommerce.tribe-tickets-form-row' );\n if ( wcwl_tickets.length > 0 ) {\n var requires_waitlist = false;\n jQuery.each( wcwl_tickets, function ( key, ticket ) {\n var product_id = jQuery( ticket ).data( 'product-id' );\n var checkbox_html = wcwl_event_data[ 'tickets' ][ product_id ];\n if ( checkbox_html ) {\n requires_waitlist = true;\n jQuery( checkbox_html ).insertAfter( jQuery( ticket ).find( '.tickets_nostock' ) );\n }\n } );\n if ( requires_waitlist ) {\n jQuery( wcwl_event_data[ 'button' ] ).insertAfter( jQuery( '.tribe-events-tickets' ) );\n wcwl_apply_event_on_page_update();\n }\n } else {\n var wcwl_tickets = jQuery( 'input[value=\"Tribe__Tickets_Plus__Commerce__WooCommerce__Main\"' ).nextAll( 'div.product.type-product' );\n if ( wcwl_tickets.length > 0 ) {\n var requires_waitlist = false;\n jQuery.each( wcwl_tickets, function ( key, ticket ) {\n var product_id = jQuery( ticket ).data( 'ticket-id' );\n var checkbox_html = wcwl_event_data[ 'tickets' ][ product_id ];\n if ( checkbox_html ) {\n requires_waitlist = true;\n jQuery( checkbox_html ).insertAfter( jQuery( ticket ) );\n }\n } );\n if ( requires_waitlist ) {\n jQuery( wcwl_event_data[ 'button' ] ).insertAfter( jQuery( 'form#tribe-tickets' ) );\n wcwl_apply_event_on_page_update();\n }\n }\n }\n} else {\n // Required for 4.12 and on\n var wcwl_ticket_form = jQuery( 'form[data-provider-id=\"woo\"]' );\n if ( typeof wcwl_event_data !== 'undefined' && jQuery( wcwl_ticket_form ).length ) {\n var wcwl_tickets = wcwl_ticket_form.find( '.tribe-tickets__item' );\n if ( wcwl_tickets.length == 0 ) {\n wcwl_tickets = wcwl_ticket_form.find( '.tribe-tickets__tickets-item' );\n }\n if ( wcwl_tickets.length > 0 ) {\n var requires_waitlist = false;\n jQuery.each( wcwl_tickets, function ( key, ticket ) {\n var product_id = jQuery( ticket ).data( 'ticket-id' );\n var checkbox_html = wcwl_event_data[ 'tickets' ][ product_id ];\n if ( checkbox_html ) {\n requires_waitlist = true;\n jQuery( '<div class=\"wcwl_event_checkbox\">' + checkbox_html + '</div>' ).insertAfter( jQuery( ticket ) );\n }\n } );\n if ( requires_waitlist ) {\n jQuery( wcwl_event_data[ 'button' ] ).insertAfter( wcwl_ticket_form );\n wcwl_apply_event_on_page_update();\n }\n }\n }\n}\n\n/* GROUPED */\n// Create an array of checked products to process waitlist request\nfunction wcwl_get_grouped_products() {\n var products = {};\n if ( !jQuery( '.wcwl_checkbox' ).length ) {\n return products;\n }\n jQuery( '.wcwl_checkbox' ).each( function () {\n var product_id = jQuery( this ).data( 'product-id' );\n var lang = jQuery( this ).data( 'wpml-lang' );\n products[ product_id ] = { 'checked': this.checked, 'lang': lang };\n } );\n return products;\n}\n\n/* QUICKVIEW */\njQuery( 'body' ).on( 'quick-v
18iew-displayed', function () {\n wcwl_apply_event_on_page_update();\n} );\n\n/* PRODUCT FILTERS FOR WOOCOMMERCE */\njQuery( window ).on( 'wcpf_after_ajax_filtering', function () {\n wcwl_apply_event_on_page_update();\n} );\n\n/* WOOCOMMERCE PRODUCT SEARCH */\njQuery( document ).on( 'ixProductFilterRequestProcessed', function () {\n wcwl_apply_event_on_page_update();\n} );\n\n/* FUNCTIONS */\n// Enable return to trigger waitlist buttons\nfunction wcwl_add_keyboard_button_events() {\n jQuery( '.wcwl_email_elements' ).on( 'keyup keypress', 'input.wcwl_email', function ( e ) {\n var keyCode = e.keyCode || e.which;\n if ( keyCode === 13 ) {\n if ( jQuery( this ).closest( '.wcwl_frontend_wrap' ).length ) {\n jQuery( this ).closest( '.wcwl_frontend_wrap' ).find( '.woocommerce_waitlist' ).trigger( 'click' );\n } else {\n jQuery( this ).closest( '.wcwl_elements' ).find( '.woocommerce_waitlist' ).trigger( 'click' );\n }\n }\n } );\n}\n// Ensure user has checked optin box\nfunction wcwl_check_optin_field( checkbox ) {\n if ( checkbox.length && !checkbox.is( ':checked' ) ) {\n checkbox.closest( '.wcwl_optin' ).addClass( 'wcwl_error_highlight' );\n return false;\n } else {\n checkbox.closest( '.wcwl_optin' ).removeClass( 'wcwl_error_highlight' );\n }\n return true;\n}\n// Ensure users entered email address is valid\nfunction wcwl_check_email_field( email ) {\n if ( email.length && ( !email.val() || !wcwl_validate_email( email.val() ) ) ) {\n email.addClass( 'wcwl_error_highlight' );\n return false;\n } else {\n email.removeClass( 'wcwl_error_highlight' );\n }\n return true;\n}\n// Validate given email address\nfunction wcwl_validate_email( email ) {\n var valid = /^(([^<>()\\[\\]\\\\.,;:\\s@\"]+(\\.[^<>()\\[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n return valid.test( email );\n}\n// Add message for screenreaders\nfunction wcwl_add_screenreader_message( wrap, message ) {\n var message_wrap = wrap.find( 'div[aria-live=\"polite\"]' );\n message_wrap.empty();\n message_wrap.append( '<p>' + message + '</p>' );\n}\n// Avoids displaying empty notices when using plugins such as quick view\nfunction wcwl_hide_waitlist_notice_if_empty() {\n jQuery( '.wcwl_notice:empty' ).hide();\n}\n\n\n//# sourceURL=webpack://woocommerce-waitlist/./src/js/wcwl_frontend.js?\n}"); 19 20/***/ } 21 22/******/ }); 23/************************************************************************/ 24/******/ 25/******/ // startup 26/******/ // Load entry module and return exports 27/******/ // This entry module can't be inlined because the eval devtool is used. 28/******/ let __webpack_exports__ = {}; 29/******/ __webpack_modules__["./src/js/wcwl_frontend.js"](); 30/******/ 31/******/ })() 32;
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.