1(function($){ 2 $( function () { 3 var all_networks_opened = 0; 4 5 // fix the "on media" wrapper inside the Divi Gallery grid 6 et_pb_fix_gallery_wrapper(); 7 8 $( 'body' ).on( 'click', '.et_social_share', function() { 9 var $this_el = $(this), 10 social_type = $this_el.data( 'social_type' ), 11 social_network = $this_el.data( 'social_name' ), 12 share_link = 'media' == social_type ? $this_el.data( 'social_link' ) : $this_el.prop( 'href' ); 13 14 update_stats_table( social_network, $this_el ); 15 16 if ( 'like' === social_network ) { 17 return false; 18 } 19 20 var left = ( $( window ).width()/2 ) - ( 550/2 ); 21 var top = ( $( window ).height()/2 ) - ( 450/2 ); 22 var new_window = window.open( share_link, '', 'scrollbars=1, height=450, width=550, left=' + left + ', top=' + top ); 23 24 if ( window.focus ) { 25 new_window.focus(); 26 } 27 28 return false; 29 }); 30 31 $( '.et_social_follow' ).on('click', function() { 32 var $this_el = $(this), 33 social_network = $this_el.data( 'social_name' ); 34 35 update_stats_table( social_network, $this_el ); 36 37 if ( 'like' === social_network ) { 38 return false; 39 } 40 }); 41 42 $( 'body' ).on( 'click', '.et_social_share_pinterest', function() { 43 if ( $( this ).hasClass( 'et_social_pin_all' ) ) { 44 var left = ( $( window ).width()/2 ) - ( 550/2 ), 45 top = ( $( window ).height()/2 ) - ( 450/2 ), 46 share_link = $( this ).attr( 'href' ), 47 new_window = window.open( share_link, '', 'scrollbars=1, height=450, width=550, left=' + left + ', top=' + top ); 48 49 if ( window.focus ) { 50 new_window.focus(); 51 } 52 } else { 53 $( '.et_social_pin_images_outer' ).fadeToggle( 400 ); 54 } 55 56 return false; 57 }); 58 59 function get_url_parameter( param_name ) { 60 var page_url = window.location.search.substring(1); 61 var url_variables = page_url.split('&'); 62 for ( var i = 0; i < url_variables.length; i++ ) { 63 var curr_param_name = url_variables[i].split( '=' ); 64 if ( curr_param_name[0] == param_name ) { 65 return curr_param_name[1]; 66 } 67 } 68 } 69 70 function update_stats_table( $social_network, $this_el ) { 71 var action = $this_el.data( 'social_type' ), 72 media_url = 'media' == action ? $this_el.closest( '.et_social_media_wrapper' ).find( 'img' ).attr( 'src' ) : '', 73 post_id = $this_el.data( 'post_id' ), 74 location = $this_el.data( 'location' ), 75 stats_data = ''; 76 77 stats_data = JSON.stringify({ 78 'action' : action, 79 'network' : $social_network, 80 'media_url' : media_url, 81 'post_id' : post_id, 82 'location' : location 83 }); 84 85 $.ajax({ 86 type: 'POST', 87 url: monarchSettings.ajaxurl, 88 data: { 89 action : 'add_stats_record_db', 90 stats_data_array : stats_data, 91 add_stats_nonce : monarchSettings.stats_nonce 92 }, 93 success: function( data ) { 94 if ( true == data ){ 95 if ( 'like' === action ){ 96 update_single_shares( $this_el, '', post_id, $social_network, 'like' ); 97 } 98 if ( 'media' === action ){ 99 update_total_media_shares( $this_el.closest( '.et_social_media_wrapper' ) ); 100 update_single_shares( $this_el, media_url, post_id, $social_network, 'media' ); 101 } 102 } 103 } 104 }); 105 } 106 107 function append_share_counts( $current_network ) { 108 var network = $current_network.data( 'social_name' ), 109 min_count = $current_network.data( 'min_count' ), 110 post_id = $current_network.data( 'post_id' ), 111 url = monarchSettings.pageurl !== '' ? monarchSettings.pageurl : window.location.href, 112 label_div = $current_network.find( '.et_social_network_label' ),
113 append_to = ( 0 != ( label_div.length ) ) ? label_div : $current_network; 114 115 $share_count_data = JSON.stringify({ 'network' : network, 'min_count' : min_count, 'post_id' : post_id, 'url' : url }); 116 117 $.ajax({ 118 type: 'POST', 119 url: monarchSettings.ajaxurl, 120 data: { 121 action : 'get_shares_count', 122 share_count_array : $share_count_data, 123 get_share_counts_nonce : monarchSettings.share_counts 124 }, 125 beforeSend: function( data ){ 126 append_to.append( '<span class="et_social_placeholder"></span>' ); 127 }, 128 success: function( data ){ 129 $current_network.find( 'span.et_social_placeholder' ).remove(); 130 append_to.append( data ); 131 } 132 }); 133 } 134 135 function append_total_shares( $current_area ) { 136 var post_id = $current_area.data( 'post_id' ), 137 url = monarchSettings.pageurl !== '' ? monarchSettings.pageurl : window.location.href, 138 append_to = $current_area; 139 140 $share_total_count_data = JSON.stringify({ 'post_id' : post_id, 'url' : url }); 141 142 $.ajax({ 143 type: 'POST', 144 url: monarchSettings.ajaxurl, 145 data: { 146 action : 'get_total_shares', 147 share_total_count_array : $share_total_count_data, 148 get_total_counts_nonce : monarchSettings.total_counts 149 }, 150 beforeSend: function( data ){ 151 append_to.append( '<span class="et_social_placeholder"></span>' ); 152 }, 153 success: function( data ){ 154 append_to.find( 'span.et_social_placeholder' ).remove(); 155 append_to.append( data ); 156 } 157 }); 158 } 159 160 function append_follow_counts( $current_area ) { 161 var network = $current_area.data( 'network' ), 162 min_count = $current_area.data( 'min_count' ), 163 index = $current_area.data( 'index' ),
164 append_to = $current_area; 165 166 $follow_count_data = JSON.stringify({ 'network' : network, 'min_count' : min_count, 'index' : index }); 167 $.ajax({ 168 type: 'POST', 169 url: monarchSettings.ajaxurl, 170 data: { 171 action : 'get_follow_counts', 172 follow_count_array : $follow_count_data, 173 get_follow_counts_nonce : monarchSettings.follow_counts 174 }, 175 beforeSend: function( data ){ 176 append_to.append( '<span class="et_social_placeholder"></span>' ); 177 }, 178 success: function( data ){ 179 $current_area.find( 'span.et_social_placeholder' ).remove(); 180 append_to.append( data ); 181 } 182 }); 183 } 184 185 function append_total_follows( $current_area ) { 186 var append_to = $current_area; 187 $.ajax({ 188 type: 'POST', 189 url: monarchSettings.ajaxurl, 190 data: { 191 action : 'get_follow_total', 192 get_total_counts_nonce : monarchSettings.total_counts 193 }, 194 beforeSend: function( data ){ 195 append_to.append( '<span class="et_social_placeholder"></span>' ); 196 }, 197 success: function( data ){ 198 append_to.find( 'span.et_social_placeholder' ).remove(); 199 append_to.append( data ); 200 } 201 }); 202 } 203 204 if ( $( '.et_social_display_follow_counts' ).length ) { 205 $( '.et_social_display_follow_counts' ).each( function(){ 206 append_follow_counts( $( this) ); 207 }); 208 } 209 210 if ( $( '.et_social_follow_total' ).length ) { 211 $( '.et_social_follow_total' ).each( function(){ 212 append_total_follows( $( this) ); 213 }); 214 } 215 216 217 if ( $( '.et_social_total_share' ).length ) { 218 $( '.et_social_total_share' ).each( function(){ 219 append_total_shares( $( this) ); 220 }); 221 } 222 223 if ( $( '.et_social_display_count' ).length ) { 224 $( '.et_social_display_count' ).each( function(){ 225 append_share_counts( $( this) ); 226 }); 227 } 228 229 if ( $( '.et_social_media_wrapper' ).length && $( '.et_social_media_wrapper .et_social_totalcount' ).length ) { 230 231 $( '.et_social_media_wrapper' ).each( function() { 232 update_total_media_shares( $( this ) ); 233 }); 234 } 235 236 if ( $( '.et_social_media_wrapper' ).length && $( '.et_social_media_wrapper .et_social_withcounts' ).length ) { 237 238 $( '.et_social_media_wrapper .et_social_share' ).each( function() { 239 var this_el = $( this ), 240 media_url = this_el.closest( '.et_social_media_wrapper' ).find('img').attr('src'), 241 post_id = this_el.data( 'post_id' ), 242 social_network = this_el.data( 'social_name' ); 243 244 update_single_shares( this_el, media_url, post_id, social_network, 'media' ); 245 246 }); 247 } 248 249 function update_total_media_shares( $element ) { 250 if ( $( '.et_social_totalcount' ).length ) { 251 var this_el = $element, 252 media_url = this_el.find( 'img' ).attr( 'src' ), 253 post_id = this_el.find( '.et_social_share' ).first().data( 'post_id' ), 254 media_data = JSON.stringify({ 'media_url' : media_url, 'post_id' : post_id }); 255 256 $.ajax({ 257 type: 'POST', 258 url: monarchSettings.ajaxurl, 259 data: { 260 action : 'get_media_shares_total', 261 media_total : media_data, 262 get_media_shares_total_nonce : monarchSettings.media_total 263 }, 264 success: function( data ){ 265 this_el.find( '.et_social_totalcount_count' ).empty().append( data ); 266 } 267 }); 268 } 269 } 270 271 function update_single_shares( $this_el, $media_url, $post_id, $network, $action ) { 272 if( $( '.et_social_withcounts' ).length ) { 273 var media_data = JSON.stringify({ 'media_url' : $media_url, 'post_id' : $post_id, 'network' : $network, 'action' : $action }); 274 $.ajax({ 275 type: 'POST', 276 url: monarchSettings.ajaxurl, 277 data: { 278 action : 'get_shares_single', 279 media_single : media_data, 280 get_media_shares_nonce : monarchSettings.media_single 281 }, 282 success: function( data ){ 283 $this_el.find( '.et_social_count span' ).not('.et_social_count_label').empty().append( data ); 284 } 285 }); 286 } 287 } 288 289 function setCookieExpire(days) { 290 291 var ms = days*24*60*60*1000; 292 293 var date = new Date(); 294 date.setTime(date.getTime() + ms); 295 296 return "; expires=" + date.toUTCString(); 297 } 298 299 function checkCookieValue(cookieName, value) { 300 return parseCookies()[cookieName] === value; 301 } 302 303 function parseCookies() { 304 var cookies = document.cookie.split('; '); 305 306 var ret = {};
307 for (var i = cookies.length - 1; i >= 0; i--) { 308 var el = cookies[i].split('='); 309 ret[el[0]] = el[1]; 310 } 311 return ret; 312 } 313 314 function set_cookie( $expire ) { 315 cookieExpire = setCookieExpire( $expire ); 316 document.cookie = 'etSocialCookie=true' + cookieExpire; 317 } 318 319 //separate function for the setTimeout to make it work properly within the loop. 320 function make_popup_visible( $popup, $delay ){ 321 setTimeout( function() { 322 $popup.addClass( 'et_social_visible et_social_animated' ); 323 if ( $( '.et_social_resize' ).length ) { 324 $( '.et_social_resize' ).each( function() { 325 define_popup_position( $( this ) ); 326 }); 327 } 328 }, $delay ); 329 } 330 331 function auto_popup( this_el, delay ) { 332 var $current_popup_auto = this_el; 333 if ( ! $current_popup_auto.hasClass( 'et_social_animated' ) ) { 334 var $cookies_expire_auto = $current_popup_auto.data( 'cookie_duration' ) ? $current_popup_auto.data( 'cookie_duration' ) : false, 335 $delay = delay; 336 337 if ( ( false !== $cookies_expire_auto && ! checkCookieValue( 'etSocialCookie', 'true' ) ) || false == $cookies_expire_auto ) { 338 339 make_popup_visible ( $current_popup_auto, $delay ); 340 341 if ( false !== $cookies_expire_auto ) { 342 set_cookie( $cookies_expire_auto ); 343 } 344 } 345 } 346 } 347 348 if ( 'true' == get_url_parameter( 'et_monarch_popup' ) ) { 349 $( '.et_social_after_comment' ).each( function() { 350 var $current_popup = $( this ); 351 auto_popup( $current_popup, 0 ); 352 }); 353 } 354 355 if( $( '.et_social_auto_popup' ).length ) { 356 $( '.et_social_auto_popup' ).each( function() { 357 var $current_popup_auto = $( this ); 358 auto_popup( $current_popup_auto, '' !== $current_popup_auto.data( 'delay' ) ? $current_popup_auto.data( 'delay' ) * 1000 : 0 ); 359 }); 360 } 361 362 $( '.et_social_pinterest_window .et_social_close' ).on( 'click', function(){ 363 $( '.et_social_pin_images_outer' ).fadeToggle( 400 ); 364 }); 365 366 $ ( 'body' ).on( 'click', '.et_social_icon_cancel', function(){ 367 var this_el = $( this ); 368 if ( this_el.parent().hasClass( 'et_social_flyin' ) ) { 369 $popup = this_el.parent(); 370 } else { 371 $popup = this_el.parent().parent(); 372 373 if ( $popup.hasClass( 'et_social_all_networks_popup' ) ) { 374 all_networks_opened = 0; 375 } 376 } 377 378 $popup.addClass( 'et_social_fadeout' ); 379 380 setTimeout( function() { 381 $popup.remove(); 382 }, 800 ); 383 return false; 384 }); 385 386 if ( $( '.et_monarch_after_order' ).length ) { 387 $( '.et_social_after_purchase' ).each( function() { 388 var $current_popup = $( this ); 389 if ( ! $current_popup.hasClass( 'et_social_animated' ) ) { 390 var $cookies_expire = $current_popup.data( 'cookie_duration' ) ? $current_popup.data( 'cookie_duration' ) : false, 391 $delay = 0; 392 393 if ( ( false !== $cookies_expire && ! checkCookieValue( 'etSocialCookie', 'true' ) ) || false == $cookies_expire ) { 394 395 make_popup_visible ( $current_popup, $delay ); 396 397 if ( false !== $cookies_expire ) { 398 set_cookie( $cookies_expire ); 399 } 400 } 401 } 402 } ); 403 } 404 405 if( $( '.et_social_trigger_bottom' ).length ) { 406 407 $( '.et_social_trigger_bottom' ).each(function(){ 408 scroll_trigger( $( this ), true ); 409 }); 410 411 } 412 413 if( $( '.et_social_scroll' ).length ) { 414 415 $( '.et_social_scroll' ).each(function(){ 416 scroll_trigger( $( this ), false ); 417 }); 418 419 } 420 421 function scroll_trigger( this_el, is_bottom_trigger ) { 422 var current_popup_bottom = this_el; 423 if ( ! current_popup_bottom.hasClass( 'et_social_animated' ) ) { 424 var cookies_expire_bottom = current_popup_bottom.data( 'cookie_duration' ) ? current_popup_bottom.data( 'cookie_duration' ) : false; 425 426 if ( true == is_bottom_trigger ) { 427 var scroll_trigger = $( '.et_social_bottom_trigger' ).length ? $( '.et_social_bottom_trigger' ).offset().top : $( document ).height() - 500; 428 } else { 429 var scroll_pos = this_el.data( 'scroll_pos' ) > 100 ? 100 : this_el.data( 'scroll_pos' ), 430 scroll_trigger = 100 == scroll_pos ? $( document ).height() - 10 : $( document ).height() * scroll_pos / 100; 431 } 432 433 $( window ).on('scroll', function(){ 434 if ( ( false !== cookies_expire_bottom && ! checkCookieValue( 'etSocialCookie', 'true' ) ) || false == cookies_expire_bottom ) { 435 if( $( window ).scrollTop() + $( window ).height() > scroll_trigger ) { 436 current_popup_bottom.addClass( 'et_social_visible et_social_animated' ); 437 if ( $( '.et_social_resize' ).length ) { 438 $( '.et_social_resize' ).each( function() { 439 define_popup_position( $( this ) ); 440 }); 441 } 442 if ( false !== cookies_expire_bottom ) { 443 set_cookie( cookies_expire_bottom ); 444 } 445 } 446 } 447 }); 448 } 449 } 450 451 if( $( '.et_social_trigger_idle' ).length ) { 452 $( '.et_social_trigger_idle' ).each( function() { 453 var this_el = $( this ); 454 455 if ( ! this_el.hasClass( 'et_social_animated' ) ) { 456 var $cookies_expire_idle = this_el.data( 'cookie_duration' ) ? this_el.data( 'cookie_duration' ) : false, 457 $idle_timeout = '' !== this_el.data( 'idle_timeout' ) ? this_el.data( 'idle_timeout' ) * 1000 : 30000; 458 459 if ( ( false !== $cookies_expire_idle && ! checkCookieValue( 'etSocialCookie', 'true' ) ) || false == $cookies_expire_idle ) { 460 $( document ).idleTimer( $idle_timeout ); 461 462 $( document ).on( "idle.idleTimer", function(){ 463 make_popup_visible ( this_el, 0 ); 464 }); 465 466 if ( false !== $cookies_expire_idle ) { 467 set_cookie( $cookies_expire_idle ); 468 } 469 } 470 } 471 }); 472 } 473 474 // open close the mobile sideabr on header click 475 $( '.et_social_heading, .et_social_mobile_button' ).on('click', function(){ 476 $this_mobile_div = $( '.et_social_mobile' ); 477 478 $this_mobile_div.css( {'display' : 'block' } ); 479 $( '.et_social_mobile_button').removeClass( 'et_social_active_button' ); 480 481 if ( $this_mobile_div.hasClass( 'et_social_opened' ) ) { 482 $this_mobile_div.find( '.et_social_networks' ).slideToggle( 600 ); 483 $this_mobile_div.removeClass( 'et_social_opened' ).addClass( 'et_social_closed' ); 484 $( '.et_social_mobile_overlay' ).removeClass( 'et_social_visible_overlay' ); 485 $( '.et_social_mobile_overlay' ).fadeToggle( 600 ); 486 } else { 487 $this_mobile_div.removeClass( 'et_social_closed' ).addClass( 'et_social_opened' ); 488 $this_mobile_div.find( '.et_social_networks' ).slideToggle( 600 ); 489 $( '.et_social_mobile_overlay' ).addClass( 'et_social_visible_overlay' ).css({ 'display' : 'block' }); 490 } 491 }); 492 493 //if close button clicked - hide the mobile sidebar from screen 494 $( '.et_social_mobile .et_social_close' ).on('click', function(){ 495 $mobile_div = $( '.et_social_mobile' ); 496 $mobile_div.fadeToggle( 600 ); 497 $( '.et_social_mobile_button' ).addClass( 'et_social_active_button' ); 498 499 if ( $mobile_div.hasClass( 'et_social_opened' ) ) { 500 $( '.et_social_mobile_overlay' ).fadeToggle( 600 ); 501 $mobile_div.removeClass( 'et_social_opened' ); 502 $mobile_div.find( '.et_social_networks' ).fadeToggle( 600 ); 503 } 504 505 }); 506 507 // Move inline icons into appropriate sections in Divi theme 508 if( $( '.et_social_inline' ).length ) { 509 if ( $( 'body' ).hasClass( 'et_pb_pagebuilder_layout' ) ) { 510 var top_inline = $( '.et_social_inline_top' ), 511 bottom_inline = $( '.et_social_inline_bottom' ), 512 divi_container = '<div class="et_pb_row"><div class="et_pb_column et_pb_column_4_4"></div></div>'; 513 514 if ($('.et-l--post').first().length > 0) { 515 var $sections = $('.et-l--post .et_pb_section').not('.et_pb_fullwidth_section'); 516 } else { 517 // Backwards compatibility before .et-l was introduced. 518 var $sections = $('.et_pb_section:not(.et-l .et_pb_section)').not('.et_pb_fullwidth_section'); 519 } 520 521 if ($sections.length > 0 && top_inline.length) { 522 $sections.first().prepend(divi_container).find('.et_pb_row').first().find('.et_pb_column').append(top_inline); 523 } 524 525 if ($sections.length > 0 && bottom_inline.length) { 526 $sections.last().append(divi_container).find('.et_pb_row').last().find('.et_pb_column').append(bottom_inline); 527 } 528 } 529 } 530 531 function define_popup_position( $this_popup ) { 532 setTimeout( function() { // make sure all css transitions are finished to calculate the heights correctly 533 var this_popup = $this_popup, 534 networks_div = this_popup.find( '.et_social_networks' ), 535 header_height = this_popup.find( '.et_social_header' ).outerHeight() || 0, 536 total_count_height = this_popup.find( '.et_social_totalcount' ).height(), 537 extra_height = 0 < total_count_height ? 20 : 0; 538 539 this_popup.height( this_popup.find( '.et_social_icons_container' ).innerHeight() + header_height + total_count_height + 20 + extra_height ); 540 541 var popup_max_height = this_popup.hasClass( 'et_social_popup_content' ) ? $( window ).height() : $( window ).height() - 60; 542 543 if ( this_popup.hasClass( 'et_social_popup_content' ) && 768 < $( window ).width() ) { 544 popup_max_height = popup_max_height - 50; 545 } 546 547 this_popup.css( { 'max-height' : popup_max_height + 'px' } ); 548 549 if( this_popup.hasClass( 'et_social_popup_content' ) ) { 550 var top_position = $( window ).height() / 2 - this_popup.innerHeight() / 2; 551 this_popup.css( { 'top' : top_position + 'px' } ); 552 } 553 554 var networks_div_height = this_popup.height() - header_height + total_count_height - extra_height; 555 networks_div.height( networks_div_height ); 556 }, 400 ); 557 } 558 559 function set_mobile_sidebar_height() { 560 setTimeout( function() { // make sure all css transitions are finished to calculate the heights correctly 561 var mobile_div = $( '.et_social_mobile' ); 562 563 if ( !mobile_div.hasClass( 'et_social_opened' ) ){ 564 $('.et_social_mobile .et_social_networks').css({'display' : 'block'}); 565 } 566 if( $('.et_social_active_button').length ) { 567 mobile_div.css({'display' : 'block'}); 568 } 569 570 var inner_contatiner_height = mobile_div.find( '.et_social_icons_container' ).innerHeight() + 45; 571 572 if ( !mobile_div.hasClass( 'et_social_opened' ) ){ 573 $('.et_social_mobile .et_social_networks').css({'display' : 'none'}); 574 } 575 if( $('.et_social_active_button').length ) { 576 mobile_div.css({'display' : 'none'}); 577 } 578 579 mobile_div.find( '.et_social_networks' ).css( { 'max-height' : inner_contatiner_height + 'px', 'height' : inner_contatiner_height + 'px' } ); 580 if ( $( window ).height() < inner_contatiner_height ) { 581 var inner_height = $( window ).height() - mobile_div.find( '.et_social_heading' ).innerHeight() + 10; 582 mobile_div.find( '.et_social_networks' ).css({ 'height' : inner_height + 'px' }); 583 } 584 }, 400 ); 585 } 586 587 function set_sidebar_position(){ 588 if( $( '.et_social_sidebar_networks' ).length ){ 589 var this_sidebar = $( '.et_social_sidebar_networks' ), 590 top_position = $( window ).height() / 2 - this_sidebar.innerHe
590ight() / 2; 591 top_position = 0 > top_position ? 0 : top_position; 592 this_sidebar.css( { 'top' : top_position + 'px' } ); 593 } 594 } 595 596 function set_media_wrapper_size() { 597 if ( $( '.et_social_media_wrapper' ).length ) { 598 $( '.et_social_media_wrapper' ).each( function(){ 599 var this_wrapper = $( this ), 600 this_wrapper_media = this_wrapper.find( '.et_social_media' ), 601 this_image = this_wrapper.find( 'img' ), 602 image_position = this_image.position(), 603 image_left_offset = typeof image_position !== 'undefined' ? image_position.left : 0, 604 this_image_height = this_image.height(), 605 this_image_width = this_image.width(), 606 this_wrapper_networks_height = this_wrapper.find( '.et_social_networks' ).innerHeight(); 607 608 this_wrapper.addClass( this_image.attr( 'class' ) ); 609 this_wrapper_media.css( { 'max-height' : this_image_height + 'px' } ); 610 this_wrapper_media.css( { 'height' : ( this_wrapper_networks_height + 50 ) + 'px' } ); 611 this_wrapper_media.width( this_image_width - 80 ); 612 613 // adjust the icons position based on image alignement 614 if ( 0 !== image_left_offset ) { 615 this_wrapper_media.css( { 'left' : ( image_left_offset + 20 ) + 'px' } ); 616 } 617 }); 618 619 // fix the media wrapper sizes in Divi Gallery Slider if needed 620 et_pb_fix_gallery_slider_icons_size(); 621 } 622 } 623 624 function et_pb_fix_gallery_wrapper() { 625 var $media_wrappers_inside_gallery = $( '.et_pb_gallery_grid .et_social_media_wrapper' ); 626 627 if ( 0 > $media_wrappers_inside_gallery.length ) { 628 return; 629 } 630 631 $media_wrappers_inside_gallery.each( function() { 632 var $this_wrapper = $( this ); 633 var $gallery_item = $this_wrapper.closest( '.et_pb_gallery_image' );
634 var $gallery_overlay = $gallery_item.find( '.et_overlay' ); 635 636 if ( 0 < $gallery_overlay.length ) { 637 // move the gallery overlay inside media icons wrapper so it won't break the sharing functionality 638 $this_wrapper.append( $gallery_overlay ); 639 } 640 }); 641 } 642 643 function et_pb_fix_gallery_slider_icons_size() { 644 var $gallery_slider_icons = $( '.et_pb_gallery_fullwidth .et_social_media_wrapper' ); 645 646 if ( 0 > $gallery_slider_icons.length ) { 647 return; 648 } 649 650 var $all_galleries = $( '.et_pb_gallery_fullwidth' ); 651 652 $all_galleries.each( function() { 653 var $this_gallery = $( this ); 654 var $this_gallery_media = $this_gallery.find( '.et_social_media_wrapper .et_social_media' ); 655 656 if ( 0 > $this_gallery_media.length ) { 657 return; 658 } 659 660 var $first_icon_wrapper = $this_gallery_media.first(); 661 var icons_width = $first_icon_wrapper.width(); 662 var icons_height = $first_icon_wrapper.css( 'height' ); 663 var icons_max_height = $first_icon_wrapper.css( 'max-height' ); 664 665 // use the dimensions from first slide and apply it to all the media icons in the slider 666 $this_gallery_media.width( icons_width - 80 ); 667 $this_gallery_media.height( icons_height ); 668 $this_gallery_media.css( { 'max-height' : icons_max_height + 'px' } ); 669 }); 670 } 671 672 $ ( 'body' ).on( 'click', '.et_social_open_all', function() { 673 all_networks_opened++; 674 if ( 1 == all_networks_opened ) { 675 var this_button = $( this ), 676 page_id = this_button.data( 'page_id' ), 677 permalink = this_button.data( 'permalink' ), 678 title = this_button.data( 'title' ), 679 media = typeof this_button.data( 'media' ) !== 'undefined' ? this_button.data( 'media' ) : '', 680 is_popup = 'popup' == this_button.data( 'location' ) ? 'true' : 'false'; 681 682 $.ajax({ 683 type: 'POST', 684 url: monarchSettings.ajaxurl, 685 data: { 686 action : 'generate_all_networks_popup', 687 all_networks_page_id : page_id, 688 all_networks_link : permalink, 689 all_networks_title : title, 690 all_networks_media : media, 691 is_popup : is_popup, 692 generate_all_window_nonce : monarchSettings.generate_all_window_nonce 693 }, 694 success: function( data ) { 695 if ( 'false' == is_popup ) { 696 $( 'body' ).append( data ); 697 make_popup_visible( $( '.et_social_all_networks_popup' ), 1 ); 698 } else { 699 var popup_container = this_button.parent().closest( '.et_social_popup_content' ); 700 701 this_button.parent().replaceWith( data ); 702 define_popup_position( popup_container ); 703 all_networks_opened = 0; 704 } 705 } 706 }); 707 } 708 709 return false; 710 }); 711 712 set_mobile_sidebar_height(); 713 714 set_sidebar_position(); 715 716 $( window ).on( 'resize', () => { 717 if ( $( '.et_social_resize' ).length ) { 718 $( '.et_social_resize' ).each( function() { 719 define_popup_position( $( this ) ); 720 }); 721 } 722 if ( $('.et_social_mobile') ) { 723 set_mobile_sidebar_height(); 724 } 725 if( $( '.et_social_sidebar_networks' ).length ){ 726 set_sidebar_position(); 727 } 728 729 set_media_wrapper_size(); 730 }); 731 732 $( '.et_social_hide_sidebar' ).on('click', function(){ 733 $( '.et_social_hide_sidebar' ).toggleClass( 'et_social_hidden_sidebar' ); 734 $( '.et_social_sidebar_networks' ).toggleClass( 'et_social_hidden_sidebar et_social_visible_sidebar' ); 735 }); 736 737 $( window ).on('load', function(){ 738 set_media_wrapper_size(); 739 740 if ( $( '.et_social_pin_images' ).length && ( $( '.et_social_all_button' ).length || $( '.et_social_pinterest' ).length ) ) { 741 var pin_container = $( '.et_social_pin_images' ), 742 permalink = pin_container.data( 'permalink' ), 743 title = pin_container.data( 'title' ), 744 post_id = pin_container.data( 'post_id' ), 745 $i = 0; 746 747 $( 'img' ).each( function(){ 748 //do not include comment avatars into the Modal 749 if ( ! $( this ).hasClass( 'avatar' ) ) { 750 var this_img = $( this ).attr( 'src' ), 751 this_alt = $( this ).attr( 'alt' ); 752 753 if ( '' != this_img ) { 754 var pin_link = 'http://www.pinterest.com/pin/create/button/?url=' + permalink + '&media=' + this_img + '&description=' + title, 755 this_img_container = '<div class="et_social_pin_image"><a href="' + pin_link + '" rel="nofollow" class="et_social_icon et_social_share" data-social_name="pinterest" data-post_id="' + post_id + '" data-social_type="share"><img src="' + this_img + '" alt="' + this_alt + '"/><span class="et_social_pin_overlay et_social_icon"></span></a></div>'; 756 $( '.et_social_pin_images' ).append( this_img_container ); 757 $i++; 758 } 759 } 760 }); 761 762 //Append error message if no images found on page 763 if ( 0 == $i ) {
764 $( '.et_social_pin_images' ).append( monarchSettings.no_img_message ); 765 } 766 } 767 }); 768 }); 769})(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.