1(function($){ 2 $(document).ready(function() { 3 var $locked_containers = []; 4 $( '.inf_infusionsoft_custom_html_form input[type="radio"], .inf_infusionsoft_custom_html_form input[type="checkbox"]' ).uniform(); 5 6 var $body = $('body'); 7 8 $body.on( 'click', 'span.inf_infusionsoft_close_button', function(){ 9 var container = $( this ).parent().parent(); 10 11 container.addClass( 'inf_infusionsoft_exit_animation' ); 12 13 if(container.hasClass('inf_infusionsoft_click_trigger')){ 14 setTimeout( function() { 15 container.removeClass('inf_infusionsoft_visible'); 16 container.removeClass('inf_infusionsoft_animated'); 17 container.removeClass('inf_infusionsoft_exit_animation'); 18 }, 400 ); 19 }else{ 20 setTimeout( function() { 21 container.remove(); 22 }, 400 ); 23 } 24 25 $( 'body' ).removeClass( 'inf_infusionsoft_popup_active' ); 26 27 return false; 28 }); 29 30 function update_stats_table( $type, $this_button ) { 31 var $optin_id = $this_button.data( 'optin_id' ), 32 $page_id = $this_button.data( 'page_id' ), 33 $list_id = $this_button.data( 'list_id' ); 34 35 var $stats_data = JSON.stringify({ 36 'type': $type, 37 'optin_id': $optin_id, 38 'page_id': $page_id, 39 'list_id': $list_id 40 }); 41 $.ajax({ 42 type: 'POST', 43 url: infusionsoftSettings.ajaxurl, 44 data: { 45 action : 'infusionsoft_handle_stats_adding', 46 stats_data_array : $stats_data, 47 update_stats_nonce : infusionsoftSettings.stats_nonce 48 } 49 }); 50 } 51 52 function setCookieExpire( days ) { 53 var ms = days*24*60*60*1000; 54 55 var date = new Date(); 56 date.setTime( date.getTime() + ms ); 57 58 return "; expires=" + date.toUTCString(); 59 } 60 61 function checkCookieValue( cookieName, value ) { 62 return parseCookies()[cookieName] == value; 63 } 64 65 function parseCookies() { 66 var cookies = document.cookie.split( '; ' ); 67 68 var ret = {}; 69 for ( var i = cookies.length - 1; i >= 0; i-- ) { 70 var el = cookies[i].split( '=' ); 71 ret[el[0]] = el[1]; 72 } 73 return ret; 74 } 75 76 function set_cookie( $expire, $cookie_content ) { 77 $cookie_content = '' == $cookie_content ? 'etInfusionsoftCookie=true' : $cookie_content; 78 cookieExpire = setCookieExpire( $expire ); 79 document.cookie = $cookie_content + cookieExpire + "; path=/"; 80 } 81 82 function get_url_parameter( param_name ) { 83 var page_url = window.location.search.substring(1); 84 var url_variables = page_url.split('&'); 85 for ( var i = 0; i < url_variables.length; i++ ) { 86 var curr_param_name = url_variables[i].split( '=' ); 87 if ( curr_param_name[0] == param_name ) { 88 return curr_param_name[1]; 89 } 90 } 91 } 92 93 //separate function for the setTimeout to make it work properly within the loop. 94 function make_popup_visible( $popup, $delay, $cookie_exp, $cookie_content ){ 95 if ( ! $popup.hasClass( 'inf_infusionsoft_visible' ) ) { 96 $('.accept_consent').removeAttr('checked'); 97 setTimeout( function() { 98 $popup.addClass( 'inf_infusionsoft_visible inf_infusionsoft_animated' ); 99 $stats_data_container = 0 != $popup.find( '.inf_infusionsoft_custom_html_form' ).length ? $popup.find( '.inf_infusionsoft_custom_html_form' ) : $popup.find( '.inf_infusionsoft_submit_subscription' ); 100 update_stats_table( 'imp', $stats_data_container ); 101 102 if ( '' != $cookie_exp ) { 103 set_cookie( $cookie_exp, $cookie_content ); 104 } 105 106 if ( $( '.inf_infusionsoft_resize' ).length ) { 107 $( '.inf_infusionsoft_resize.inf_infusionsoft_visible' ).each( function() { 108 define_popup_position( $( this ), true, 0 ); 109 }); 110 } 111 112 display_image( $popup ); 113 114 }, $delay ); 115 } 116 } 117 118 function display_image( $popup ) { 119 setTimeout( function() { 120 $popup.find( '.inf_infusionsoft_image' ).addClass( 'inf_infusionsoft_visible_image' ); 121 }, 500 ); 122 } 123 124 function auto_popup( $current_popup_auto, $delay ) { 125 var page_id = $current_popup_auto.find( '.inf_infusionsoft_submit_subscription' ).data( 'page_id' ), 126 optin_id = $current_popup_auto.find( '.inf_infusionsoft_submit_subscription' ).data( 'optin_id' ), 127 list_id = $current_popup_auto.find( '.inf_infusionsoft_submit_subscription' ).data( 'list_id' ); 128 129 if ( ! $current_popup_auto.hasClass( 'inf_infusionsoft_animated' ) ) { 130 var $cookies_expire_auto = $current_popup_auto.data( 'cookie_duration' ) ? $current_popup_auto.data( 'cookie_duration' ) : false, 131 $already_subscribed = checkCookieValue( 'inf_infusionsoft_subscribed_to_' + optin_id + list_id, 'true' ); 132 133 if ( ( ( false !== $cookies_expire_auto && ! checkCookieValue( 'etInfusionsoftCookie_' + optin_id, 'true' ) ) || false == $cookies_expire_auto ) && ! $already_subscribed ) { 134 if ( false !== $cookies_expire_auto ) {
135 make_popup_visible ( $current_popup_auto, $delay, $cookies_expire_auto, 'etInfusionsoftCookie_' + optin_id + '=true' ); 136 } else { 137 make_popup_visible ( $current_popup_auto, $delay, '', '' ); 138 } 139 } 140 } 141 } 142 143 144 $('.inf_infusionsoft_click_trigger_element').on('click', function(e){ 145 var optin_id = $(this).data('optin_id') 146 $( '.inf_infusionsoft_click_trigger:not(.inf_infusionsoft_visible)' ).each( function() { 147 var $this_el = $( this ); 148 current_optin_id = $(this).find( '.inf_infusionsoft_submit_subscription' ).data( 'optin_id' ); 149 e.preventDefault();//prevent links from disrupting popup 150 if(current_optin_id == optin_id){ 151 make_popup_visible ( $this_el, 0, '', '' ); 152 } 153 }); 154 155 }); 156 157 function exit_trigger($current_popup_exit){ 158 159 var page_id = $current_popup_exit.find( '.inf_infusionsoft_submit_subscription' ).data( 'page_id' ), 160 optin_id = $current_popup_exit.find( '.inf_infusionsoft_submit_subscription' ).data( 'optin_id' ), 161 list_id = $current_popup_exit.find( '.inf_infusionsoft_submit_subscription' ).data( 'list_id' ); 162 163 if ( ! $current_popup_exit.hasClass( 'inf_infusionsoft_animated' ) ) { 164 var $cookies_expire_auto = $current_popup_exit.data( 'cookie_duration' ) ? $current_popup_exit.data( 'cookie_duration' ) : false, 165 $already_subscribed = checkCookieValue( 'inf_infusionsoft_subscribed_to_' + optin_id + list_id, 'true' ); 166 167 $( document ).mouseleave(function() { 168 if (( ( false !== $cookies_expire_auto && !checkCookieValue('etInfusionsoftCookie_' + optin_id, 'true') ) || false == $cookies_expire_auto ) && !$already_subscribed) { 169 if (false !== $cookies_expire_auto) { 170 171 return make_popup_visible($current_popup_exit, 0, $cookies_expire_auto, 'etInfusionsoftCookie_' + optin_id + '=true'); 172 173 } else { 174 175 return make_popup_visible($current_popup_exit, 0, '', ''); 176 } 177 } 178 }); 179 } 180 } 181 182 183 function scroll_trigger( current_popup_bottom, is_bottom_trigger ) { 184 var triggered = 0, 185 page_id = current_popup_bottom.find( '.inf_infusionsoft_submit_subscription' ).data( 'page_id' ), 186 optin_id = current_popup_bottom.find( '.inf_infusionsoft_submit_subscription' ).data( 'optin_id' ); 187 list_id = current_popup_bottom.find( '.inf_infusionsoft_submit_subscription' ).data( 'list_id' ); 188 189 if ( ! current_popup_bottom.hasClass( 'inf_infusionsoft_animated' ) ) { 190 var cookies_expire_bottom = current_popup_bottom.data( 'cookie_duration' ) ? current_popup_bottom.data( 'cookie_duration' ) : false, 191 $already_subscribed = checkCookieValue( 'inf_infusionsoft_subscribed_to_' + optin_id + list_id, 'true' ); 192 193 var scroll_trigger = undefined; 194 if ( true == is_bottom_trigger ) { 195 var $radInfusionsoftBottomTrigger = $('.inf_infusionsoft_bottom_trigger'); 196 scroll_trigger = $radInfusionsoftBottomTrigger.length ? $radInfusionsoftBottomTrigger.offset().top : $( document ).height() - 500; 197 } else { 198 var scroll_pos = current_popup_bottom.data( 'scroll_pos' ) > 100 ? 100 : current_popup_bottom.data( 'scroll_pos' ); 199 scroll_trigger = 100 == scroll_pos ? $( document ).height() - 50 : $( document ).height() * scroll_pos / 100; 200 } 201 //check document height vs window height( if its the same or less assume mobile and show slidein after 5 seconds) 202 if ($(document).height() <= $(window).height()){ 203 setTimeout( 204 function(){ 205 make_popup_visible ( current_popup_bottom, 0, '', '' ); 206 }, 5000 207 ); 208 } 209 $( window ).scroll( function(){ 210 if ( ( ( false !== cookies_expire_bottom && ! checkCookieValue( 'etInfusionsoftCookie_' + optin_id, 'true' ) ) || false == cookies_expire_bottom ) && ! $already_subscribed ) { 211 if( $( window ).scrollTop() + $( window ).height() > scroll_trigger ) { 212 if ( 0 == triggered ) { 213 if ( false !== cookies_expire_bottom ) { 214 make_popup_visible ( current_popup_bottom, 0, cookies_expire_bottom, 'etInfusionsoftCookie_' + optin_id + '=true' ); 215 } else { 216 make_popup_visible ( current_popup_bottom, 0, '', '' ); 217 } 218 219 triggered++; 220 } 221 } 222 } 223 }); 224 } 225 } 226 227 if( $( '.inf_infusionsoft_auto_popup' ).length ) { 228 $( '.inf_infusionsoft_auto_popup:not(.inf_infusionsoft_visible)' ).each( function() { 229 var this_el = $( this ),
230 delay = '' !== this_el.data( 'delay' ) ? this_el.data( 'delay' ) * 1000 : 0; 231 auto_popup( this_el, delay ); 232 }); 233 } 234 235 if( $( '.inf_infusionsoft_infusionbar.inf_infusionsoft_infusionbar_trigger_auto' ).length ) { 236 $( '.inf_infusionsoft_infusionbar.inf_infusionsoft_infusionbar_trigger_auto:not(.inf_infusionsoft_visible)' ).each( function() { 237 var this_el = $( this ), 238 delay = '' !== this_el.data( 'delay' ) ? this_el.data( 'delay' ) * 1000 : 0; 239 auto_popup( this_el, delay ); 240 }); 241 } 242 243 if( $( '.inf_infusionsoft_trigger_bottom' ).length ) { 244 245 $( '.inf_infusionsoft_trigger_bottom:not(.inf_infusionsoft_visible)' ).each( function(){ 246 scroll_trigger( $( this ), true ); 247 }); 248 249 } 250 251 if( $( '.inf_infusionsoft_before_exit' ).length ) { 252 253 $( '.inf_infusionsoft_before_exit:not(.inf_infusionsoft_visible)' ).each( function(){ 254 exit_trigger( $( this ), false ); 255 }); 256 257 } 258 259 if( $( '.inf_infusionsoft_scroll' ).length ) { 260 261 $( '.inf_infusionsoft_scroll:not(.inf_infusionsoft_visible)' ).each( function(){ 262 scroll_trigger( $( this ), false ); 263 }); 264 } 265 266 if( $( '.inf_infusionsoft_trigger_idle' ).length ) { 267 $( '.inf_infusionsoft_trigger_idle:not(.inf_infusionsoft_visible)' ).each( function() { 268 var this_el = $( this ), 269 page_id = this_el.find( '.inf_infusionsoft_submit_subscription' ).data( 'page_id' ), 270 optin_id = this_el.find( '.inf_infusionsoft_submit_subscription' ).data( 'optin_id' ), 271 list_id = this_el.find( '.inf_infusionsoft_submit_subscription' ).data( 'list_id' ); 272 273 if ( ! this_el.hasClass( 'inf_infusionsoft_animated' ) ) { 274 var $cookies_expire_idle = this_el.data( 'cookie_duration' ) ? this_el.data( 'cookie_duration' ) : false, 275 $already_subscribed = checkCookieValue( 'inf_infusionsoft_subscribed_to_' + optin_id + list_id, 'true' ); 276 var $idle_timeout = '' !== this_el.data( 'idle_timeout' ) ? this_el.data( 'idle_timeout' ) * 1000 : 30000, 277 $delay = 0; 278 279 if ( ( ( false !== $cookies_expire_idle && ! checkCookieValue( 'etInfusionsoftCookie_' + optin_id, 'true' ) ) || false == $cookies_expire_idle ) && ! $already_subscribed ) { 280 $( document ).idleTimer( $idle_timeout ); 281 282 $( document ).on( 'idle.idleTimer', function() { 283 if ( false !== $cookies_expire_idle ) { 284 make_popup_visible ( this_el, $delay, $cookies_expire_idle, 'etInfusionsoftCookie_' + optin_id + '=true' ); 285 } else { 286 make_popup_visible ( this_el, $delay, '', '' ); 287 } 288 }); 289 } 290 } 291 }); 292 } 293 294 if ( 'true' == get_url_parameter( 'inf_infusionsoft_popup' ) ) { 295 $( '.inf_infusionsoft_after_comment' ).each( function() { 296 auto_popup( $( this ), 0 ); 297 }); 298 } 299 300 if ( $( '.inf_infusionsoft_after_order' ).length ) { 301 $( '.inf_infusionsoft_after_purchase' ).each( function() { 302 auto_popup( $( this ), 0 ); 303 }); 304 } 305 306 var $radInfusionsoftLockedContainer = $('.inf_infusionsoft_locked_container'); 307 if( $radInfusionsoftLockedContainer.length ) { 308 var $i = 0; 309 310 $radInfusionsoftLockedContainer.each( function() { 311 var $this_el = $( this ), 312 content = $this_el.find( '.inf_infusionsoft_locked_content' ), 313 form = $this_el.find( '.inf_infusionsoft_locked_form' ), 314 page_id = $this_el.data( 'page_id' ), 315 optin_id = $this_el.data( 'optin_id' ); 316 317 $this_el.data( 'container_id', $i ); 318 $locked_containers.push( content ); 319 320 if ( checkCookieValue( 'inf_infusionsoft_unlocked' + optin_id + page_id, 'true' ) ) { 321 content.css( {'display' : 'block'} ); 322 form.remove(); 323 } else { 324 content.remove(); 325 update_stats_table( 'imp', $this_el ); 326 } 327 328 $i++; 329 }); 330 } 331 332 $body.on( 'click', '.inf_infusionsoft_locked_container .inf_infusionsoft_submit_subscription', function(){ 333 var current_container = $( this ).closest( '.inf_infusionsoft_locked_container' ), 334 container_id = current_container.data( 'container_id' ), 335 page_id = current_container.data( 'page_id' ), 336 optin_id = current_container.data( 'optin_id' ); 337 338 perform_subscription( $( this ), current_container, container_id, page_id, optin_id ); 339 340 return false;
341 }); 342 343 // unlock content immediately if custom HTML form is used. 344 $body.on( 'click', '.inf_infusionsoft_locked_container .inf_infusionsoft_custom_html_form input[type="submit"], .inf_infusionsoft_locked_container .inf_infusionsoft_custom_html_form button[type="submit"]', function() { 345 var current_container = $( this ).closest( '.inf_infusionsoft_locked_container' ), 346 container_id = current_container.data( 'container_id' ), 347 page_id = current_container.data( 'page_id' ), 348 optin_id = current_container.data( 'optin_id' ); 349 350 unlock_content( current_container, container_id, page_id, optin_id ); 351 } ); 352 353 function unlock_content( current_container, container_id, locked_page_id, locked_optin_id ) { 354 set_cookie( 365, 'inf_infusionsoft_unlocked' + locked_optin_id + locked_page_id + '=true' ); 355 current_container.find( '.inf_infusionsoft_locked_form' ).replaceWith( $locked_containers[container_id] ); 356 current_container.find( '.inf_infusionsoft_locked_content' ).css( { 'display' : 'block' } ); 357 } 358 359 // Move inline forms into appropriate sections in Divi theme 360 var $radInfusionsoftBelowPost = $('.inf_infusionsoft_below_post'); 361 if( $radInfusionsoftBelowPost.length ) { 362 if ( $body.hasClass( 'inf_pb_pagebuilder_layout' ) ) { 363 var bottom_inline = $radInfusionsoftBelowPost, 364 divi_container = '<div class="inf_pb_row"><div class="inf_pb_column ra_pb_column_4_4"></div></div>'; 365 366 if ( bottom_inline.length ) { 367 $( '.inf_pb_section' ).not( '.inf_pb_fullwidth_section' ).last().append( divi_container ).find( '.inf_pb_row' ).last().find( '.inf_pb_column' ).append( bottom_inline ); 368 } 369 } 370 } 371 372 function define_popup_position( $this_popup, $just_loaded, $message_space ) { 373 var this_popup = $this_popup.find( '.inf_infusionsoft_form_container' ), 374 popup_max_height = this_popup.hasClass( 'inf_infusionsoft_popup_container' ) ? $( window ).height() - 40 : $( window ).height() - 20, 375 real_popup_height = 0, 376 flyin_percentage = this_popup.parent().hasClass( 'inf_infusionsoft_flyin' ) ? 0.03 : 0.05, 377 percentage = this_popup.hasClass( 'inf_infusionsoft_with_border' ) ? flyin_percentage + 0.03 : flyin_percentage, 378 breakout_offset = this_popup.hasClass( 'breakout_edge' ) ? 0.95 : 1, 379 dashed_offset = this_popup.hasClass( 'inf_infusionsoft_border_dashed' ) ? 4 : 0, 380 form_height = this_popup.find( 'form' ).innerHeight() + $message_space, 381 form_add = true == $just_loaded ? 5 : 0; 382 consent_height = this_popup.find( '.consent_wrapper').height(); 383 real_form_height = form_height + consent_height; 384 385 386 //this_popup.find('form').css({'height': form_height + consent_height}); 387 388 389 var header_height = undefined; 390 if ( this_popup.find( '.inf_infusionsoft_form_header' ).hasClass('split' ) ) { 391 var image_height = this_popup.find( '.inf_infusionsoft_form_header img' ).innerHeight(), 392 text_height = this_popup.find( '.inf_infusionsoft_form_header .inf_infusionsoft_form_text' ).innerHeight(); 393 header_height = image_height < text_height ? text_height + 30 : image_height + 30; 394 } else { 395 header_height = this_popup.find( '.inf_infusionsoft_form_header img' ).innerHeight() + this_popup.find( '.inf_infusionsoft_form_header .inf_infusionsoft_form_text' ).innerHeight() + 30; 396 } 397 398 this_popup.css( { 'max-height' : popup_max_height } ); 399 if ( this_popup.hasClass( 'inf_infusionsoft_popup_container' ) ) { 400 var top_position = $( window ).height() / 2 - this_popup.innerHeight() / 2; 401 this_popup.css( { 'top' : top_position + 'px' } ); 402 } 403 404 this_popup.find( '.inf_infusionsoft_form_container_wrapper' ).css( { 'max-height' : popup_max_height - 20 } ); 405 406 407 var $body2 = $('body'); 408 if ( ( 768 > $body2.outerWidth() + 15 ) || this_popup.hasClass( 'inf_infusionsoft_form_bottom' ) ) { 409 if ( this_popup.hasClass( 'inf_infusionsoft_form_right' ) || this_popup.hasClass( 'inf_infusionsoft_form_left' ) ) { 410 this_popup.find( '.inf_infusionsoft_form_header' ).css( { 'height' : 'auto' } ); 411 } 412 413 real_popup_height = this_popup.find( '.inf_infusionsoft_form_header' ).innerHeight() + this_popup.find( '.inf_infusionsoft_form_content' ).innerHeight() + 30 + form_add; 414 415 if ( this_popup.hasClass( 'inf_infusionsoft_form_right' ) || this_popup.hasClass( 'inf_infusionsoft_form_left' ) ) { 416 this_popup.find( '.inf_infusionsoft_form_container_wrapper' ).css( { 'height' : real_popup_height - 30 + dashed_offset } ); 417 } 418 } else { 419 if ( header_height < real_form_height ) { 420 //real_popup_height = this_popup.find( 'form' ).innerHeight() + 30 + $message_space; 421 real_popup_height = real_form_height; 422 $('.inf_infusionsoft .inf_infusionsoft_form_container .inf_infusionsoft_form_content').css({'padding-top':'40', 'padding-bottom': '40'}); 423 var topFix = consent_height; 424 $('.inf_infusionsoft .inf_infusionsoft_form_left .inf_infusionsoft_form_content form, .inf_infusionsoft .inf_infusionsoft_form_right .inf_infusionsoft_form_content form').css({'top': '-'+topFix+'px'}); 425 } else { 426 real_popup_height = header_height + 30; 427 } 428 429 if ( this_popup.hasClass( 'inf_infusionsoft_form_right' ) || this_popup.hasClass( 'inf_infusionsoft_form_left' ) ) { 430 this_popup.find( '.inf_infusionsoft_form_header' ).css( { 'height' : real_popup_height * breakout_offset - dashed_offset } ); 431 this_popup.find( '.inf_infusionsoft_form_content' ).css( { 'min-height' : real_popup_height - dashed_offset } ); 432 this_popup.find( '.inf_infusionsoft_form_container_wrapper' ).css( { 'height' : real_popup_height } ); 433 } 434 } 435 436 if ( real_popup_height > popup_max_height ) { 437 this_popup.find( '.inf_infusionsoft_form_container_wrapper' ).addClass( 'inf_infusionsoft_vertical_scroll' ); 438 } else { 439 this_popup.find( '.inf_infusionsoft_form_container_wrapper' ).removeClass( 'inf_infusionsoft_vertical_scroll' ); 440 } 441 442 if ( $this_popup.hasClass( 'inf_infusionsoft_popup' ) ) { 443 $body2.addClass( 'inf_infusionsoft_popup_active' ); 444 } 445 } 446 447 $body.on( 'click', '.inf_infusionsoft_submit_subscription', function() { 448 perform_subscription( $( this ), '', '', '', '' ); 449 return false;
450 }); 451 452 function perform_subscription( this_button, current_container, container_id, locked_page_id, locked_optin_id ) { 453 var this_form = this_button.parent(), 454 list_id = this_button.data( 'list_id' ), 455 account_name = this_button.data( 'account' ), 456 service = this_button.data( 'service' ), 457 name = this_form.find( '.inf_infusionsoft_subscribe_name input' ).val(), 458 last_name = undefined != this_form.find( '.inf_infusionsoft_subscribe_last input' ).val() ? this_form.find( '.inf_infusionsoft_subscribe_last input' ).val() : '', 459 email = this_form.find( '.inf_infusionsoft_subscribe_email input' ).val(), 460 page_id = this_button.data( 'page_id' ), 461 webhook_url = this_button.data( 'center_webhook_url' ), 462 463 disable_dbl_optin = this_button.data( 'disable_dbl_optin'), 464 post_name = this_button.data('post_name'), 465 cookie = this_button.data('cookie'); 466 optin_id = this_button.data( 'optin_id' ); 467 optin_type = (this_button.data('optin_type') == 'infusion' ? 'infusion' : 'standard'); 468 redirectUrl = this_button.data( 'redirect_url' ); 469 redirectTab = this_button.data( 'redirect' ); 470 redirect_delay = this_button.data( 'success_delay' ) + '000'; 471 redirect_delay = parseInt(redirect_delay); 472 this_form.find( '.inf_infusionsoft_subscribe_email input' ).removeClass( 'inf_infusionsoft_warn_field' ); 473 474 if(this_button.hasClass('cursor-not-allowed')){ 475 //find the top level parent of but button clicked to find the error message for this specific form 476 var parents = this_form.parents(); 477 parents.each(function(){ 478 if($(this).hasClass('inf_infusionsoft_optin') || $(this).hasClass('inf_infusionsoft_infusionbar')){ 479 top_parent = $(this); 480 } 481 }); 482 var error_message = top_parent.find('.consent_error'); 483 var consent_form = top_parent.find('.infusion_consent_form') ; 484 $(error_message).show(); 485 if ($(consent_form).hasClass('infusion_consent_closed')) { 486 $(consent_form).removeClass('infusion_consent_closed'); 487 $(consent_form).addClass('infusion_consent'); 488 } 489 return; 490 } 491 if ( '' == email ) { 492 this_form.find( '.inf_infusionsoft_subscribe_email input' ).addClass( 'inf_infusionsoft_warn_field' ); 493 } else { 494 $subscribe_data = JSON.stringify({ 'list_id' : list_id, 'account_name' : account_name, 'service' : service, 'name' : name, 'email' : email, 'page_id' : page_id, 'optin_id' : optin_id, 'last_name' : last_name, 'dbl_optin' : disable_dbl_optin, 'post_name' : post_name, 'cookie' : cookie }); 495 $.ajax({ 496 type: 'POST', 497 dataType: 'json', 498 url: infusionsoftSettings.ajaxurl, 499 data: { 500 action : 'infusionsoft_subscribe', 501 subscribe_data_array : $subscribe_data, 502 subscribe_nonce : infusionsoftSettings.subscribe_nonce 503 }, 504 beforeSend: function( data ) { 505 this_button.addClass( 'inf_infusionsoft_button_text_loading' ); 506 this_button.find( '.inf_infusionsoft_subscribe_loader' ).css( { 'display' : 'block' } ); 507 }, 508 success: function( data ) { 509 $('.infusion_consent_form').hide();//hide infusion consent text 510 $('.consent_wrapper').hide();//hide all other forms consent text 511 this_button.removeClass( 'inf_infusionsoft_button_text_loading' ); 512 this_button.find( '.inf_infusionsoft_subscribe_loader' ).css( { 'display' : 'none' } ); 513 if ( data ) { 514 if ( '' != current_container && ( data.success || 'Invalid email' != data.error ) ) { 515 unlock_content( current_container, container_id, locked_page_id, locked_optin_id ); 516 } else { 517 if ( data.error ) { 518 this_form.find( '.inf_infusionsoft_error_message' ).remove(); 519 this_form.prepend( '<h2 class="inf_infusionsoft_error_message">' + data.error + '</h2>' ); 520 this_form.parent().parent().find( '.inf_infusionsoft_form_header' ).addClass( 'inf_infusionsoft_with_error' ); 521 } 522 if( data.success && '' == current_container && optin_type == 'infusion'){ 523 var topLevel = this_form.parent().parent(); 524 topLevel.find( '.inf_infusionsoft_success_message' ).addClass( 'inf_infusionsoft_animate_message' ); 525 topLevel.find( '.inf_infusionsoft_success_container' ).addClass( 'inf_infusionsoft_animate_success' ); 526 topLevel.find('.inf_infusionsoft_form_text').remove(); 527 //set_cookie( 365, 'inf_infusionsoft_subscribed_to_' + optin_id + list_id + '=true' ); 528 if(typeof(center) == "function") { 529 center('associate', email); 530 } 531 //uncomment to reactivate center webhooks 532 //submit_center_webhook(email, name, last_name, webhook_url); 533 rapidbarSubmitPaddingNeeded = ( jQuery('.inf_infusionsoft_infusionbar_form_content button').data('service') == 'redirect') ? 35 : 50;//set this before the bar is removed so I know how much padding to remove on other functions 534 this_form.remove(); 535 setTimeout(function(){ 536 $('.inf_infusionsoft_infusionbar').remove(); 537 }, 3000); 538 if(redirectUrl.length > 0){ 539 setTimeout(function(){ 540 if(redirectTab == 'new_tab') { 541 window.open(redirectUrl); 542 }else if(redirectTab == 'new_window'){ 543 window.open(redirectUrl, '_blank', 'toolbar=1,location=0,menubar=1'); 544 }else{ 545 window.location.href = redirectUrl; 546 } 547 }, redirect_delay); 548 } 549 } 550 if ( data.success && '' == current_container && optin_type == 'standard') { 551 this_form.parent().find( '.inf_infusionsoft_success_message' ).addClass( 'inf_infusionsoft_animate_message' ); 552 this_form.parent().find( '.inf_infusionsoft_success_container' ).addClass( 'inf_infusionsoft_animate_success' ); 553 this_form.remove(); 554 if(typeof(center) == "function") { 555 center('associate', email); 556 } 557 //uncomment to reactivate center webhooks 558 559 //submit_center_webhook(email, name, last_name, webhook_url); 560 //set_cookie( 365, 'inf_infusionsoft_subscribed_to_' + optin_id + list_id + '=true' ); 561 if(redirectUrl.length > 0){ 562 setTimeout(function(){ 563 if(redirectTab == 'new_tab') { 564 window.open(redirectUrl); 565 }else if(redirectTab == 'new_window'){ 566 window.open(redirectUrl, '_blank', 'toolbar=1,location=0,menubar=1'); 567 }else{ 568 window.location.href = redirectUrl; 569 } 570 }, redirect_delay); 571 } 572 } 573 } 574 define_popup_position( this_form.parent().parent().parent().parent(), false, 50 ); 575 } 576 } 577 }); 578 } 579 } 580 581 function submit_center_webhook(email, name, last_name, url) { 582 var full_name; 583 var first_name = ''; 584 585 if(name == null){ 586 name = ''; 587 } 588 589 //check if last name is blank if so 590 //name is probably the full name 591 //although they could have just left first name blank so this is not full proof 592 593 if(last_name == '') 594 { 595 full_name = name; 596 }else{ 597 first_name = name; 598 } 599 600 var data = 601 { 602 'email': email, 603 'first_name': first_name, 604 'last_name': last_name, 605 'full_name': full_name, 606 } 607 608 var submit_data = { 609 url: url, 610 data: data 611 } 612 613 console.log(submit_data); 614 $.ajax({ 615 type: 'POST', 616 dataType: 'json', 617 url: infusionsoftSettings.ajaxurl, 618 data: { 619 action : 'infusionsoft_center_webhooks', 620 data: submit_data, 621 center_nonce: infusionsoftSettings.center_nonce 622 }, 623 beforeSend: function (data) { 624 625 }, 626 success: function(response) { 627 console.log(response); 628 } 629 630 }); 631 632 } 633 634 $body.on( 'click', '.inf_infusionsoft_custom_html_form input[type="submit"], .inf_infusionsoft_custom_html_form button[type="submit"]', function() { 635 var this_button = $( this ), 636 form_container = this_button.closest( '.inf_infusionsoft_custom_html_form' ); 637 638 update_stats_table( 'con', form_container ); 639 } ); 640 641 $body.on( 'click','.inf_infusionsoft_redirect_page',function(e){ 642 e.preventDefault(); 643 var this_button = $( this ); 644 //list_id = this_button.data( 'list_id' ); 645 optin_id = this_button.data( 'optin_id' ); 646 type = this_button.data( 'optin_type' ); 647 var popup_id = $(this).data('popup_id'); 648 var redirectUrl = $(this).data('redirect_url'); 649 redirectTab = this_button.data( 'redirect' );
650 redirect_delay = this_button.data( 'success_delay' ) + '000'; 651 redirect_delay = parseInt(redirect_delay); 652 var container = $(this).parent().parent().parent().parent().parent(); 653 container.addClass( 'inf_infusionsoft_exit_animation' ); 654 update_stats_table( 'con', this_button ); 655 rapidbarSubmitPaddingNeeded = ( jQuery('.inf_infusionsoft_infusionbar_form_content button').data('service') == 'redirect') ? 35 : 50;//set this before the bar is removed so I know how much padding to remove on other functions 656 657 658 //set_cookie( 365, 'inf_infusionsoft_subscribed_to_' + optin_id + list_id + '=true' ); 659 if(popup_id) { 660 var optin = $('.inf_infusionsoft_' + popup_id); 661 make_popup_visible(optin, 0, '', ''); 662 }else { 663 if(redirectTab == 'new_tab') { 664 window.open(redirectUrl); 665 }else if(redirectTab == 'new_window'){ 666 window.open(redirectUrl, '_blank', 'toolbar=1,location=0,menubar=1'); 667 }else{ 668 window.location.href = redirectUrl; 669 } 670 } 671 }); 672 673 $body.on('click', '.accept_consent', function(){ 674 var parent = $(this).parent().parent().parent().get( 0 ).tagName; 675 var button = $(parent + ' .inf_infusionsoft_submit_subscription'); 676 if($('.accept_consent').prop('checked')){ 677 button.removeClass('cursor-not-allowed'); 678 }else{ 679 button.addClass('cursor-not-allowed'); 680 } 681 }); 682 683 $body.on('click', '.consent_wrapper .accept_consent', function(){ 684 var parent = $(this).parent().parent().parent().get( 0 ).tagName; 685 var button = $(parent + ' .inf_infusionsoft_submit_subscription'); 686 if($(this).prop('checked')){ 687 button.removeClass('cursor-not-allowed'); 688 }else{ 689 button.addClass('cursor-not-allowed'); 690 } 691 }); 692 693 $( window ).resize( function(){ 694 var $radInfusionsoftResize = $('.inf_infusionsoft_resize'); 695 if ( $radInfusionsoftResize.length ) { 696 $radInfusionsoftResize.each( function() { 697 define_popup_position( $( this ), false, 0 ); 698 }); 699 } 700 }); 701 }); 702 703})(jQuery); 704 705 706//once the window is loaded make sure that the body tag has the required class for infusionsoft to work 707(function($){ 708 $(window).load(function(){ 709 if(!$('body').hasClass('inf_infusionsoft')){ 710 $('body').addClass('inf_infusionsoft'); 711 } 712 }); 713}(jQuery));
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.