1(function($){ 2 $(document).ready(function() { 3 var $locked_containers = []; 4 5 $( '.et_bloom_custom_html_form input[type="radio"], .et_bloom_custom_html_form input[type="checkbox"]' ).uniform(); 6 7 $( 'body' ).on( 'click', 'span.et_bloom_close_button', function(){ 8 var container = $( this ).parent().parent(); 9 10 container.addClass( 'et_bloom_exit_animation' ); 11 12 setTimeout( function() { 13 if ( container.hasClass( 'et_bloom_trigger_click' ) ) { 14 container.removeClass( 'et_bloom_visible et_bloom_animated' ); 15 } else { 16 container.remove(); 17 } 18 }, 400 ); 19 20 $( 'body' ).removeClass( 'et_bloom_popup_active' ); 21 22 return false; 23 }); 24 25 function update_stats_table( $type, $this_button ) { 26 var $optin_id = $this_button.data( 'optin_id' ), 27 $page_id = $this_button.data( 'page_id' ), 28 $list_id = $this_button.data( 'list_id' ); 29 30 $stats_data = JSON.stringify({ 'type' : $type, 'optin_id' : $optin_id, 'page_id' : $page_id, 'list_id' : $list_id }); 31 $.ajax({ 32 type: 'POST', 33 url: bloomSettings.ajaxurl, 34 data: { 35 action : 'bloom_handle_stats_adding', 36 stats_data_array : $stats_data, 37 update_stats_nonce : bloomSettings.stats_nonce 38 } 39 }); 40 } 41 42 function setCookieExpire( days ) { 43 var ms = days*24*60*60*1000; 44 45 var date = new Date(); 46 date.setTime( date.getTime() + ms ); 47 48 return "; expires=" + date.toUTCString(); 49 } 50 51 function checkCookieValue( cookieName, value ) { 52 return parseCookies()[cookieName] == value; 53 } 54 55 function parseCookies() { 56 var cookies = document.cookie.split( '; ' ); 57 58 var ret = {}; 59 for ( var i = cookies.length - 1; i >= 0; i-- ) { 60 var el = cookies[i].split( '=' ); 61 ret[el[0]] = el[1]; 62 } 63 return ret; 64 } 65 66 function set_cookie( $expire, $cookie_content ) { 67 var $cookie_content = '' == $cookie_content ? 'etBloomCookie=true' : $cookie_content; 68 cookieExpire = setCookieExpire( $expire ); 69 document.cookie = $cookie_content + cookieExpire + "; path=/"; 70 } 71 72 function get_url_parameter( param_name ) { 73 var page_url = window.location.search.substring(1); 74 var url_variables = page_url.split('&'); 75 for ( var i = 0; i < url_variables.length; i++ ) { 76 var curr_param_name = url_variables[i].split( '=' ); 77 if ( curr_param_name[0] == param_name ) { 78 return curr_param_name[1]; 79 } 80 } 81 } 82 83 //separate function for the setTimeout to make it work properly within the loop. 84 function make_popup_visible( $popup, $delay, $cookie_exp, $cookie_content ){ 85 if ( ! $popup.hasClass( 'et_bloom_visible' ) ) { 86 setTimeout( function() { 87 $popup.addClass( 'et_bloom_visible et_bloom_animated' ); 88 $stats_data_container = 0 != $popup.find( '.et_bloom_custom_html_form' ).length ? $popup.find( '.et_bloom_custom_html_form' ) : $popup.find( '.et_bloom_submit_subscription' ); 89 update_stats_table( 'imp', $stats_data_container ); 90 91 if ( '' != $cookie_exp ) { 92 set_cookie( $cookie_exp, $cookie_content ); 93 } 94 95 if ( $( '.et_bloom_resize' ).length ) { 96 $( '.et_bloom_resize.et_bloom_visible' ).each( function() { 97 define_popup_position( $( this ), true, 0 ); 98 }); 99 } 100 101 display_image( $popup ); 102 103 }, $delay ); 104 } 105 } 106 107 function display_image( $popup ) { 108 setTimeout( function() { 109 $popup.find( '.et_bloom_image' ).addClass( 'et_bloom_visible_image' ); 110 }, 500 ); 111 } 112 113 function auto_popup( $current_popup_auto, $delay ) { 114 var page_id = $current_popup_auto.find( '.et_bloom_submit_subscription' ).data( 'page_id' ), 115 optin_id = $current_popup_auto.find( '.et_bloom_submit_subscription' ).data( 'optin_id' ), 116 list_id = $current_popup_auto.find( '.et_bloom_submit_subscription' ).data( 'list_id' ); 117 118 if ( ! $current_popup_auto.hasClass( 'et_bloom_animated' ) ) { 119 var $cookies_expire_auto = $current_popup_auto.data( 'cookie_duration' ) ? $current_popup_auto.data( 'cookie_duration' ) : false, 120 $already_subscribed = checkCookieValue( 'et_bloom_subscribed_to_' + optin_id + list_id, 'true' ); 121 122 if ( ( ( false !== $cookies_expire_auto && ! checkCookieValue( 'etBloomCookie_' + optin_id, 'true' ) ) || false == $cookies_expire_auto ) && ! $already_subscribed ) { 123 if ( false !== $cookies_expire_auto ) {
124 make_popup_visible ( $current_popup_auto, $delay, $cookies_expire_auto, 'etBloomCookie_' + optin_id + '=true' ); 125 } else { 126 make_popup_visible ( $current_popup_auto, $delay, '', '' ); 127 } 128 } 129 } 130 } 131 132 function scroll_trigger( current_popup_bottom, is_bottom_trigger ) { 133 var triggered = 0, 134 page_id = current_popup_bottom.find( '.et_bloom_submit_subscription' ).data( 'page_id' ), 135 optin_id = current_popup_bottom.find( '.et_bloom_submit_subscription' ).data( 'optin_id' ); 136 list_id = current_popup_bottom.find( '.et_bloom_submit_subscription' ).data( 'list_id' ); 137 138 if ( ! current_popup_bottom.hasClass( 'et_bloom_animated' ) ) { 139 var cookies_expire_bottom = current_popup_bottom.data( 'cookie_duration' ) ? current_popup_bottom.data( 'cookie_duration' ) : false, 140 $already_subscribed = checkCookieValue( 'et_bloom_subscribed_to_' + optin_id + list_id, 'true' ); 141 142 if ( true == is_bottom_trigger ) { 143 var scroll_trigger = $( '.et_bloom_bottom_trigger' ).length ? $( '.et_bloom_bottom_trigger' ).offset().top : $( document ).height() - 500; 144 } else { 145 var scroll_pos = current_popup_bottom.data( 'scroll_pos' ) > 100 ? 100 : current_popup_bottom.data( 'scroll_pos' ), 146 scroll_trigger = 100 == scroll_pos ? $( document ).height() - 50 : $( document ).height() * scroll_pos / 100; 147 } 148 149 $( window ).scroll( function(){ 150 if ( ( ( false !== cookies_expire_bottom && ! checkCookieValue( 'etBloomCookie_' + optin_id, 'true' ) ) || false == cookies_expire_bottom ) && ! $already_subscribed ) { 151 if( $( window ).scrollTop() + $( window ).height() > scroll_trigger ) { 152 if ( 0 == triggered ) { 153 if ( false !== cookies_expire_bottom ) { 154 make_popup_visible ( current_popup_bottom, 0, cookies_expire_bottom, 'etBloomCookie_' + optin_id + '=true' ); 155 } else { 156 make_popup_visible ( current_popup_bottom, 0, '', '' ); 157 } 158 159 triggered++; 160 } 161 } 162 } 163 }); 164 } 165 } 166 167 if( $( '.et_bloom_auto_popup' ).length ) { 168 $( '.et_bloom_auto_popup:not(.et_bloom_visible)' ).each( function() { 169 var this_el = $( this ),
170 delay = '' !== this_el.data( 'delay' ) ? this_el.data( 'delay' ) * 1000 : 0; 171 auto_popup( this_el, delay ); 172 }); 173 } 174 175 if( $( '.et_bloom_trigger_bottom' ).length ) { 176 177 $( '.et_bloom_trigger_bottom:not(.et_bloom_visible)' ).each( function(){ 178 scroll_trigger( $( this ), true ); 179 }); 180 181 } 182 183 if( $( '.et_bloom_scroll' ).length ) { 184 185 $( '.et_bloom_scroll:not(.et_bloom_visible)' ).each( function(){ 186 scroll_trigger( $( this ), false ); 187 }); 188 } 189 190 if ( $( '.et_bloom_trigger_click' ).length ) { 191 $( '.et_bloom_trigger_click:not(.et_bloom_visible)' ).each( function() { 192 var $this_el = $( this ), 193 selector = $this_el.attr( 'data-trigger_click' ); 194 195 if ( typeof selector !== 'undefined' ) { 196 $( 'body' ).on( 'click', selector, function() { 197 make_popup_visible ( $this_el, 0, '', '' ); 198 }); 199 } 200 }); 201 } 202 203 if( $( '.et_bloom_trigger_idle' ).length ) { 204 $( '.et_bloom_trigger_idle:not(.et_bloom_visible)' ).each( function() { 205 var this_el = $( this ), 206 page_id = this_el.find( '.et_bloom_submit_subscription' ).data( 'page_id' ), 207 optin_id = this_el.find( '.et_bloom_submit_subscription' ).data( 'optin_id' ), 208 list_id = this_el.find( '.et_bloom_submit_subscription' ).data( 'list_id' ); 209 210 if ( ! this_el.hasClass( 'et_bloom_animated' ) ) { 211 var $cookies_expire_idle = this_el.data( 'cookie_duration' ) ? this_el.data( 'cookie_duration' ) : false, 212 $already_subscribed = checkCookieValue( 'et_bloom_subscribed_to_' + optin_id + list_id, 'true' ); 213 $idle_timeout = '' !== this_el.data( 'idle_timeout' ) ? this_el.data( 'idle_timeout' ) * 1000 : 30000, 214 $delay = 0; 215 216 if ( ( ( false !== $cookies_expire_idle && ! checkCookieValue( 'etBloomCookie_' + optin_id, 'true' ) ) || false == $cookies_expire_idle ) && ! $already_subscribed ) { 217 $( document ).idleTimer( $idle_timeout ); 218 219 $( document ).on( 'idle.idleTimer', function() { 220 if ( false !== $cookies_expire_idle ) { 221 make_popup_visible ( this_el, $delay, $cookies_expire_idle, 'etBloomCookie_' + optin_id + '=true' ); 222 } else { 223 make_popup_visible ( this_el, $delay, '', '' ); 224 } 225 }); 226 } 227 } 228 }); 229 } 230 231 if ( 'true' == get_url_parameter( 'et_bloom_popup' ) ) { 232 $( '.et_bloom_after_comment' ).each( function() { 233 auto_popup( $( this ), 0 ); 234 }); 235 } 236 237 if ( $( '.et_bloom_after_order' ).length ) { 238 $( '.et_bloom_after_purchase' ).each( function() { 239 auto_popup( $( this ), 0 ); 240 }); 241 } 242 243 if( $( '.et_bloom_locked_container' ).length ) { 244 var $i = 0; 245 246 $( '.et_bloom_locked_container' ).each( function() { 247 var $this_el = $( this ), 248 content = $this_el.find( '.et_bloom_locked_content' ), 249 form = $this_el.find( '.et_bloom_locked_form' ), 250 page_id = $this_el.data( 'page_id' ), 251 optin_id = $this_el.data( 'optin_id' ); 252 253 $this_el.data( 'container_id', $i ); 254 $locked_containers.push( content ); 255 256 if ( checkCookieValue( 'et_bloom_unlocked' + optin_id + page_id, 'true' ) ) { 257 content.css( {'display' : 'block'} ); 258 form.remove(); 259 } else { 260 content.remove(); 261 update_stats_table( 'imp', $this_el ); 262 } 263 264 $i++; 265 }); 266 } 267 268 $( 'body' ).on( 'click', '.et_bloom_locked_container .et_bloom_submit_subscription', function(){ 269 var current_container = $( this ).closest( '.et_bloom_locked_container' ), 270 container_id = current_container.data( 'container_id' ), 271 page_id = current_container.data( 'page_id' ), 272 optin_id = current_container.data( 'optin_id' ); 273 274 perform_subscription( $( this ), current_container, container_id, page_id, optin_id ); 275 276 return false; 277 }); 278 279 // unlock content immediately if custom HTML form is used. 280 $( 'body' ).on( 'click', '.et_bloom_locked_container .et_bloom_custom_html_form input[type="submit"], .et_bloom_locked_container .et_bloom_custom_html_form button[type="submit"]', function() { 281 var current_container = $( this ).closest( '.et_bloom_locked_container' ), 282 container_id = current_container.data( 'container_id' ), 283 page_id = current_container.data( 'page_id' ), 284 optin_id = current_container.data( 'optin_id' ); 285 286 unlock_content( current_container, container_id, page_id, optin_id ); 287 } ); 288 289 function unlock_content( current_container, container_id, locked_page_id, locked_optin_id ) { 290 set_cookie( 365, 'et_bloom_unlocked' + locked_optin_id + locked_page_id + '=true' ); 291 current_container.find( '.et_bloom_locked_form' ).replaceWith( $locked_containers[container_id] ); 292 current_container.find( '.et_bloom_locked_content' ).css( { 'display' : 'block' } ); 293 } 294 295 // Move inline forms into appropriate sections in Divi theme 296 if( $( '.et_bloom_below_post' ).length ) { 297 if ( $( 'body' ).hasClass( 'et_pb_pagebuilder_layout' ) ) { 298 var bottom_inline = $( '.et_bloom_below_post' ), 299 divi_container = '<div class="et_pb_row"><div class="et_pb_column et_pb_column_4_4"></div></div>'; 300 301 if ( bottom_inline.length ) { 302 $( '.et_pb_section' ).not( '.et_pb_fullwidth_section' ).last().append( divi_container ).find( '.et_pb_row' ).last().find( '.et_pb_column' ).append( bottom_inline ); 303 } 304 } 305 } 306 307 function define_popup_position( $this_popup, $just_loaded, $message_space ) { 308 var this_popup = $this_popup.find( '.et_bloom_form_container' ), 309 popup_max_height = this_popup.hasClass( 'et_bloom_popup_container' ) ? $( window ).height() - 40 : $( window ).height() - 20, 310 real_popup_height = 0, 311 percentage = this_popup.parent().hasClass( 'et_bloom_flyin' ) ? 0.03 : 0.05, 312 percentage = this_popup.hasClass( 'et_bloom_with_border' ) ? percentage + 0.03 : percentage, 313 breakout_offset = this_popup.hasClass( 'breakout_edge' ) ? 0.95
313: 1, 314 dashed_offset = this_popup.hasClass( 'et_bloom_border_dashed' ) ? 4 : 0, 315 form_height = this_popup.find( 'form' ).innerHeight() + $message_space, 316 form_add = true == $just_loaded ? 5 : 0; 317 318 if ( this_popup.find( '.et_bloom_form_header' ).hasClass('split' ) ) { 319 var image_height = this_popup.find( '.et_bloom_form_header img' ).innerHeight(), 320 text_height = this_popup.find( '.et_bloom_form_header .et_bloom_form_text' ).innerHeight(), 321 header_height = image_height < text_height ? text_height + 30 : image_height + 30; 322 } else { 323 var header_height = this_popup.find( '.et_bloom_form_header img' ).innerHeight() + this_popup.find( '.et_bloom_form_header .et_bloom_form_text' ).innerHeight() + 30; 324 } 325 326 this_popup.css( { 'max-height' : popup_max_height } ); 327 328 if ( this_popup.hasClass( 'et_bloom_popup_container' ) ) { 329 var top_position = $( window ).height() / 2 - this_popup.innerHeight() / 2; 330 this_popup.css( { 'top' : top_position + 'px' } ); 331 } 332 333 this_popup.find( '.et_bloom_form_container_wrapper' ).css( { 'max-height' : popup_max_height - 20 } ); 334 335 336 if ( ( 768 > $( 'body' ).outerWidth() + 15 ) || this_popup.hasClass( 'et_bloom_form_bottom' ) ) { 337 if ( this_popup.hasClass( 'et_bloom_form_right' ) || this_popup.hasClass( 'et_bloom_form_left' ) ) { 338 this_popup.find( '.et_bloom_form_header' ).css( { 'height' : 'auto' } ); 339 } 340 341 real_popup_height = this_popup.find( '.et_bloom_form_header' ).innerHeight() + this_popup.find( '.et_bloom_form_content' ).innerHeight() + 30 + form_add; 342 343 if ( this_popup.hasClass( 'et_bloom_form_right' ) || this_popup.hasClass( 'et_bloom_form_left' ) ) { 344 this_popup.find( '.et_bloom_form_container_wrapper' ).css( { 'height' : real_popup_height - 30 + dashed_offset } ); 345 } 346 } else { 347 if ( header_height < form_height ) { 348 real_popup_height = this_popup.find( 'form' ).innerHeight() + 30 + $message_space; 349 } else { 350 real_popup_height = header_height + 30; 351 } 352 353 if ( this_popup.hasClass( 'et_bloom_form_right' ) || this_popup.hasClass( 'et_bloom_form_left' ) ) { 354 this_popup.find( '.et_bloom_form_header' ).css( { 'height' : real_popup_height * breakout_offset - dashed_offset } ); 355 this_popup.find( '.et_bloom_form_content' ).css( { 'min-height' : real_popup_height - dashed_offset } ); 356 this_popup.find( '.et_bloom_form_container_wrapper' ).css( { 'height' : real_popup_height } ); 357 } 358 } 359 360 if ( real_popup_height > popup_max_height ) { 361 this_popup.find( '.et_bloom_form_container_wrapper' ).addClass( 'et_bloom_vertical_scroll' ); 362 } else { 363 this_popup.find( '.et_bloom_form_container_wrapper' ).removeClass( 'et_bloom_vertical_scroll' ); 364 } 365 366 if ( $this_popup.hasClass( 'et_bloom_popup' ) ) { 367 $( 'body' ).addClass( 'et_bloom_popup_active' ); 368 } 369 } 370 371 $( 'body' ).on( 'click', '.et_bloom_submit_subscription:not(.et_bloom_submit_subscription_locked)', function() { 372 perform_subscription( $( this ), '', '', '', '' ); 373 return false; 374 }); 375 376 function perform_subscription( this_button, current_container, container_id, locked_page_id, locked_optin_id ) { 377 var this_form = this_button.parent(), 378 list_id = this_button.data( 'list_id' ), 379 account_name = this_button.data( 'account' ), 380 service = this_button.data( 'service' ), 381 name = this_form.find( '.et_bloom_subscribe_name input' ).val(), 382 last_name = undefined != this_form.find( '.et_bloom_subscribe_last input' ).val() ? this_form.find( '.et_bloom_subscribe_last input' ).val() : '', 383 email = this_form.find( '.et_bloom_subscribe_email input' ).val(), 384 page_id = this_button.data( 'page_id' ), 385 optin_id = this_button.data( 'optin_id' ), 386 disable_dbl_optin = this_button.data( 'disable_dbl_optin' ); 387 388 this_form.find( '.et_bloom_subscribe_email input' ).removeClass( 'et_bloom_warn_field' ); 389 390 if ( '' == email ) { 391 this_form.find( '.et_bloom_subscribe_email input' ).addClass( 'et_bloom_warn_field' ); 392 } else { 393 $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 }); 394 $.ajax({
395 type: 'POST', 396 dataType: 'json', 397 url: bloomSettings.ajaxurl, 398 data: { 399 action : 'bloom_subscribe', 400 subscribe_data_array : $subscribe_data, 401 subscribe_nonce : bloomSettings.subscribe_nonce 402 }, 403 beforeSend: function( data ) { 404 this_button.addClass( 'et_bloom_button_text_loading' ); 405 this_button.find( '.et_bloom_subscribe_loader' ).css( { 'display' : 'block' } ); 406 }, 407 success: function( data ) { 408 this_button.removeClass( 'et_bloom_button_text_loading' ); 409 this_button.find( '.et_bloom_subscribe_loader' ).css( { 'display' : 'none' } ); 410 if ( data ) { 411 if ( '' != current_container && ( data.success || 'Invalid email' != data.error ) ) { 412 unlock_content( current_container, container_id, locked_page_id, locked_optin_id ); 413 } else { 414 if ( data.error ) { 415 this_form.find( '.et_bloom_error_message' ).remove(); 416 this_form.prepend( '<h2 class="et_bloom_error_message">' + data.error + '</h2>' ); 417 this_form.parent().parent().find( '.et_bloom_form_header' ).addClass( 'et_bloom_with_error' ); 418 } 419 if ( data.success && '' == current_container ) { 420 this_form.parent().find( '.et_bloom_success_message' ).addClass( 'et_bloom_animate_message' ); 421 this_form.parent().find( '.et_bloom_success_container' ).addClass( 'et_bloom_animate_success' ); 422 this_form.remove(); 423 set_cookie( 365, 'et_bloom_subscribed_to_' + optin_id + list_id + '=true' ); 424 } 425 } 426 427 define_popup_position( this_form.parent().parent().parent().parent(), false, 50 ); 428 } 429 } 430 }); 431 } 432 } 433 434 $( 'body' ).on( 'click', '.et_bloom_custom_html_form input[type="submit"], .et_bloom_custom_html_form button[type="submit"]', function() { 435 var this_button = $( this ), 436 form_container = this_button.closest( '.et_bloom_custom_html_form' ); 437 438 update_stats_table( 'con', form_container ); 439 } ); 440 441 $( window ).resize( function(){ 442 if ( $( '.et_bloom_resize' ).length ) { 443 $( '.et_bloom_resize' ).each( function() { 444 define_popup_position( $( this ), false, 0 ); 445 }); 446 } 447 }); 448 }); 449})(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.