1/* global rac_guest_params */ 2 3jQuery( document ).ready( function () { 4 'use strict' ; 5 6 var force_guest_email = rac_guest_params.force_guest == 'yes' ? true : false ; 7 var check = force_guest_email ? true : rac_guest_params.popup_already_displayed != 'yes' ; 8 var already_cookie_occured = ( rac_guest_params.is_cookie_already_set == 1 ) ? true : false ; 9 var popup_cookie_delay_time = ( rac_guest_params.popup_cookie_delay_time == 'yes' ) ? true : false ; 10 11 if ( ( !already_cookie_occured ) && ( rac_guest_params.enable_popup == 'yes' ) ) { 12 if ( check && popup_cookie_delay_time ) { 13 common_function_get_guest_email_address_in_cookie( false ) ; 14 } 15 } 16 17 if ( rac_guest_params.is_checkout ) { 18 jQuery( "#billing_email" ).val( rac_guest_params.fp_rac_popup_email ) ; 19 jQuery( "#billing_first_name" ).val( rac_guest_params.fp_rac_first_name ) ; 20 jQuery( "#billing_last_name" ).val( rac_guest_params.fp_rac_last_name ) ; 21 jQuery( "#billing_phone" ).val( rac_guest_params.fp_rac_phone_no ) ; 22 var request = null ; 23 jQuery( "#billing_email" ).on( "focusout" , function () { 24 fp_rac_common_function_for_checkout_fields() ; 25 } ) ; 26 jQuery( "#billing_first_name" ).on( "change" , function () { 27 fp_rac_common_function_for_checkout_fields() ; 28 } ) ; 29 jQuery( "#billing_last_name" ).on( "change" , function () { 30 fp_rac_common_function_for_checkout_fields() ; 31 } ) ; 32 jQuery( "#billing_phone" ).on( "change" , function () { 33 fp_rac_common_function_for_checkout_fields() ; 34 } ) ; 35 window.onbeforeunload = function () { 36 fp_rac_common_function_for_checkout_fields() ; 37 } ; 38 function fp_rac_common_function_for_checkout_fields() { 39 var fp_rac_mail = jQuery( "#billing_email" ).val() ; 40 var atpos = fp_rac_mail.indexOf( "@" ) ; 41 var dotpos = fp_rac_mail.lastIndexOf( "." ) ; 42 if ( atpos < 1 || dotpos < atpos + 2 || dotpos + 2 >= fp_rac_mail.length ) { 43 console.log( rac_guest_params.console_error ) ; 44 } else { 45 console.log( fp_rac_mail ) ; 46 var fp_rac_first_name = jQuery( "#billing_first_name" ).val() ; 47 var fp_rac_last_name = jQuery( "#billing_last_name" ).val() ; 48 var fp_rac_phone = jQuery( "#billing_phone" ).val() ; 49 var data = { 50 action : "rac_preadd_guest" , 51 rac_email : fp_rac_mail , 52 rac_first_name : fp_rac_first_name , 53 rac_last_name : fp_rac_last_name , 54 rac_phone : fp_rac_phone , 55 rac_security : rac_guest_params.guest_entry , 56 rac_lang : rac_guest_params.current_lang_code 57 } 58 if ( request == null ) { 59 request = jQuery.post( rac_guest_params.ajax_url , data , 60 function ( response ) { 61 request = null ; 62 console.log( response ) ; 63 } ) ; 64 } 65 } 66 } 67 } 68 var proceed_add_to_cart = false ; 69 var force_guest_email = rac_guest_params.force_guest == 'yes' ? true : false ; 70 var check = force_guest_email ? true : rac_guest_params.popup_already_displayed != 'yes' ; 71 if ( 'yes' == rac_guest_params.enable_popup ) { 72 jQuery( ".product_type_simple" ).on( "click" , function ( event ) { 73 event.preventDefault() ; 74 var object_clicked = jQuery( this ) ; 75 jQuery( '.product_type_simple' ).removeClass( 'fp_rac_currently_clicked_atc' ) ; 76 jQuery( '.single_add_to_cart_button' ).removeClass( 'fp_rac_currently_clicked_atc' ) ; 77 jQuery( this ).addClass( 'fp_rac_currently_clicked_atc' ) ; 78 if ( jQuery( this ).hasClass( 'ajax_add_to_cart' ) && !proceed_add_to_cart && ( !already_cookie_occured ) && ( rac_guest_params.enable_popup == 'yes' ) ) { 79 if ( ( !jQuery( this ).hasClass( 'rac_hide_guest_poup' ) ) && check ) { 80 if ( rac_guest_params.popup_disp_method == 1 ) { 81 common_function_get_guest_email_address_in_cookie( object_clicked ) 82 return false ; 83 } else { 84 var data = { 85 action : 'rac_popup_timedelay' , 86 rac_security : rac_guest_params.rac_popup_delay_nonce , 87 } ; 88 jQuery.post( rac_guest_params.ajax_url , data , function ( response ) { 89 console.log( response ) ; 90 proceed_add_to_cart = true ; 91 92 if ( rac_guest_params.is_shop && rac_guest_params.ajax_add_to_cart != 'yes' ) { 93 var href = object_clicked.attr( 'href' ) ; 94 window.location = href ; 95 } else { 96 jQuery( '.fp_rac_currently_clicked_atc' ).trigger( 'click' ) ; 97 } 98 } ) ; 99 return false ; 100 } 101 } 102 } 103 } ) ; 104 } 105 106 jQuery( ".single_add_to_cart_button" ).on( "click" , function () { 107 var object_clicked = jQuery( this ) ; 108 jQuery( '.product_type_simple' ).removeClass( 'fp_rac_currently_clicked_atc' ) ; 109 jQuery( '.single_add_to_cart_button' ).removeClass( 'fp_rac_currently_clicked_atc' ) ; 110 jQuery( this ).addClass( 'fp_rac_currently_clicked_atc' ) ; 111 if ( !jQuery( this ).hasClass( 'wc-variation-selection-needed' ) && !proceed_add_to_cart && !jQuery( this ).hasClass( 'disabled' ) && ( !already_cookie_occured ) && ( rac_guest_params.enable_popup == 'yes' ) ) { 112 if ( ( !jQuery( this ).hasClass( 'rac_hide_guest_poup' ) ) && check ) { 113 if ( rac_guest_params.popup_disp_method == 1 ) { 114 common_function_get_guest_email_address_in_cookie( object_clicked ) ; 115 return false ; 116 } else {
117 var time_delay = new Date().getTime() ; 118 var data = { 119 action : 'rac_popup_timedelay' , 120 timedelay : time_delay , 121 rac_security : rac_guest_params.rac_popup_delay_nonce , 122 } ; 123 jQuery.post( rac_guest_params.ajax_url , data , function ( response ) { 124 console.log( response ) ; 125 proceed_add_to_cart = true ; 126 127 if ( rac_guest_params.is_shop && rac_guest_params.ajax_add_to_cart != 'yes' ) { 128 var href = object_clicked.attr( 'href' ) ; 129 window.location = href ; 130 } else { 131 jQuery( '.fp_rac_currently_clicked_atc' ).trigger( 'click' ) ; 132 } 133 } ) ; 134 return false ; 135 } 136 } 137 } 138 } ) ; 139 140 function common_function_get_guest_email_address_in_cookie( object_clicked , error , default_email , defaultfname , default_lname , default_phoneno ) { 141 var force_guest = rac_guest_params.force_guest == 'yes' ? false : true ; 142 143 if ( typeof error === "undefined" || error === null ) { 144 error = "" ; 145 } 146 147 if ( typeof default_email === "undefined" || default_email === null ) { 148 default_email = "" ; 149 } 150 if ( typeof defaultfname === "undefined" || defaultfname === null ) { 151 defaultfname = "" ; 152 } 153 if ( typeof default_lname === "undefined" || default_lname === null ) { 154 default_lname = "" ; 155 } 156 if ( typeof default_phoneno === "undefined" || default_phoneno === null ) { 157 default_phoneno = "" ; 158 } 159 160 if ( force_guest ) { 161 jQuery( '.single_add_to_cart_button' ).addClass( 'rac_hide_guest_poup' ) ; 162 jQuery( '.product_type_simple' ).addClass( 'rac_hide_guest_poup' ) ; 163 } 164 165 var html = '' ; 166 if ( rac_guest_params.fp_rac_disp_notice_check ) { 167 html += '<div class="woocommerce-info" name="fp_rac_guest_notice" id="fp_rac_guest_notice">' + rac_guest_params.fp_rac_disp_notice + '</div>' ; 168 } 169 html += '<input type="text" name="fp_rac_guest_email_in_cookie" id="fp_rac_guest_email_in_cookie" value="' + default_email + '" placeholder="' + custom_css_btn_color.email_placeholder + '"><br><br>' ; 170 171 if ( rac_guest_params.show_guest_name ) { 172 html += '<input type="text" name="fp_rac_guest_fname_in_cookie" id="fp_rac_guest_fname_in_cookie" value="' + defaultfname + '" placeholder="' + custom_css_btn_color.fname_placeholder + '"><br><br>' + '<input type="text" name="fp_rac_guest_lname_in_cookie" id="fp_rac_guest_lname_in_cookie" value="' + default_lname + '" placeholder="' + custom_css_btn_color.lname_placeholder + '"><br><br>' ; 173 } 174 if ( rac_guest_params.show_guest_contactno ) { 175 html += '<input type="tel" name="fp_rac_guest_phoneno_in_cookie" id="fp_rac_guest_phoneno_in_cookie" value="' + default_phoneno + '" placeholder="' + custom_css_btn_color.phone_placeholder + '">' ; 176 } 177 178 var data = { 179 action : 'fp_rac_already_popup_displayed' , 180 already_displayed : 'yes' , 181 rac_security : rac_guest_params.guest_entry 182 } ; 183 var show_error = error != '' ? '<div style="color:red">' + error + '</div><br>' : '' ; 184 var error_msg = "" ; 185 jQuery.post( rac_guest_params.ajax_url , data , function () {} ) ; 186 swal( { 187 title : '<span class="rac_swal_popup_title">' + rac_guest_params.form_label + '</span>' , 188 html : '<span class="rac_swal_popup_sub_title">' + rac_guest_params.popup_sub_header + '</span>' + show_error + html , 189 showCloseButton : true , 190 showCancelButton : true , 191 confirmButtonText : '<i class="fa fa-thumbs-up"></i>' + rac_guest_params.add_to_cart_label , 192 cancelButtonText : '<i class="fa fa-thumbs-down"></i>' + rac_guest_params.cancel_label , 193 background : '#' + custom_css_btn_color.popupcolor , 194 confirmButtonColor : '#' + custom_css_btn_color.confirmbtncolor , 195 cancelButtonColor : '#' + custom_css_btn_color.cancelbtncolor , 196 } ).then( function ( isConfirm ) { 197 if ( isConfirm ) { 198 var email_id = jQuery( '#fp_rac_guest_email_in_cookie' ).val() ; 199 var first_name = jQuery( '#fp_rac_guest_fname_in_cookie' ).val() ; 200 var last_name = jQuery( '#fp_rac_guest_lname_in_cookie' ).val() ; 201 var phone_no = jQuery( '#fp_rac_guest_phoneno_in_cookie' ).val() ; 202 var filter = /^[0-9-+]+$/ ; 203 204 try { 205 if ( email_id == "" ) { 206 if ( !force_guest ) { 207 error_msg += rac_guest_params.enter_email_address + '<br>' ; 208 } 209 } else { 210 var atpos = email_id.indexOf( "@" ) ; 211 var dotpos = email_id.lastIndexOf( "." ) ; 212 if ( atpos < 1 || dotpos < atpos + 2 || dotpos + 2 >= email_id.length ) { 213 if ( !force_guest ) { 214 error_msg += rac_guest_params.email_address_not_valid + '<br>' ; 215 } 216 } 217 } 218 if ( ( first_name == "" ) ) { 219 if ( rac_guest_params.force_guest_name ) { 220 error_msg += rac_guest_params.enter_first_name + '<br>' ; 221 } 222 } 223 if ( ( last_name == "" ) ) { 224 if ( rac_guest_params.force_guest_name ) { 225 error_msg += rac_guest_params.enter_last_name + '<br>' ; 226 } 227 } 228 if ( ( phone_no == "" ) ) { 229 if ( rac_guest_params.force_guest_contactno ) { 230 error_msg += rac_guest_params.enter_phone_no + '<br>' ; 231 } 232 } else { 233 if ( ( !filter.test( phone_no ) ) ) { 234 if ( rac_guest_params.force_guest_contactno ) { 235 error_msg += rac_guest_params.enter_valid_phone_no + '<br>' ; 236 } 237 } 238 } 239 if ( error_msg ) { 240 common_function_get_guest_email_address_in_cookie( object_clicked , error_msg , email_id , first_name , last_name , phone_no ) ; 241 return false ; 242 } 243 var data = { 244 action : 'fp_rac_set_guest_email_in_cookie' , 245 cookie_guest_email : email_id , 246 cookie_guest_fname : first_name , 247 cookie_guest_lname : last_name , 248 cookie_guest_phone_no : phone_no , 249 rac_security : rac_guest_params.guest_entry 250 } ; 251 252 jQuery.post( rac_guest_params.ajax_url , data , function ( response ) { 253 console.log( response ) ; 254 if ( response == 'success' && rac_guest_params.popup_disp_method != 2 ) { 255 proceed_add_to_cart = true ; 256 if ( rac_guest_params.is_shop && rac_guest_params.ajax_add_to_cart != 'yes' ) { 257 var href = object_clicked.attr( 'href' ) ; 258 window.location = href ; 259 } else { 260 jQuery( '.fp_rac_currently_clicked_atc' ).trigger( 'click' ) ; 261 } 262 } 263 if ( rac_guest_params.popup_disp_method != 1 ) { 264 window.location.reload() ; 265 } 266 } ) ; 267 } catch ( err ) { 268 swal( { 269 title : err , 270 type : "error" 271 } ) ; 272 } 273 } else { 274 if ( !force_guest_email ) { 275 jQuery( '.fp_rac_currently_clicked_atc' ).trigger( 'click' ) ; 276 } 277 } 278 } ) 279 return false ; 280 } 281} ) ;
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.