1(function($){ 2 $(document).ready(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' ).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 ).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' ).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' ).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 ( top_inline.length ) { 515 $( '.et_pb_section' ).not( '.et_pb_fullwidth_section' ).first().prepend( divi_container ).find( '.et_pb_row' ).first().find( '.et_pb_column' ).append( top_inline ); 516 } 517 518 if ( bottom_inline.length ) { 519 $( '.et_pb_section' ).not( '.et_pb_fullwidth_section' ).last().append( divi_container ).find( '.et_pb_row' ).last().find( '.et_pb_column' ).append( bottom_inline ); 520 } 521 } 522 } 523 524 function define_popup_position( $this_popup ) { 525 setTimeout( function() { // make sure all css transitions are finished to calculate the heights correctly 526 var this_popup = $this_popup, 527 networks_div = this_popup.find( '.et_social_networks' ), 528 header_height = this_popup.find( '.et_social_header' ).outerHeight(), 529 total_count_height = this_popup.find( '.et_social_totalcount' ).height(), 530 extra_height = 0 < total_count_height ? 20 : 0; 531 532 this_popup.height( this_popup.find( '.et_social_icons_container' ).innerHeight() + header_height + total_count_height + 20 + extra_height ); 533 534 var popup_max_height = this_popup.hasClass( 'et_social_popup_content' ) ? $( window ).height() : $( window ).height() - 60; 535 536 if ( this_popup.hasClass( 'et_social_popup_content' ) && 768 < $( window ).width() ) { 537 popup_max_height = popup_max_height - 50; 538 } 539 540 this_popup.css( { 'max-height' : popup_max_height } ); 541 542 if( this_popup.hasClass( 'et_social_popup_content' ) ) { 543 var top_position = $( window ).height() / 2 - this_popup.innerHeight() / 2; 544 this_popup.css( { 'top' : top_position + 'px' } ); 545 } 546 547 var networks_div_height = this_popup.height() - header_height + total_count_height - extra_height; 548 networks_div.height( networks_div_height ); 549 }, 400 ); 550 } 551 552 function set_mobile_sidebar_height() { 553 setTimeout( function() { // make sure all css transitions are finished to calculate the heights correctly 554 var mobile_div = $( '.et_social_mobile' ); 555 556 if ( !mobile_div.hasClass( 'et_social_opened' ) ){ 557 $('.et_social_mobile .et_social_networks').css({'display' : 'block'}); 558 } 559 if( $('.et_social_active_button').length ) { 560 mobile_div.css({'display' : 'block'}); 561 } 562 563 var inner_contatiner_height = mobile_div.find( '.et_social_icons_container' ).innerHeight() + 45; 564 565 if ( !mobile_div.hasClass( 'et_social_opened' ) ){ 566 $('.et_social_mobile .et_social_networks').css({'display' : 'none'}); 567 } 568 if( $('.et_social_active_button').length ) { 569 mobile_div.css({'display' : 'none'}); 570 } 571 572 mobile_div.find( '.et_social_networks' ).css( { 'max-height' : inner_contatiner_height, 'height' : inner_contatiner_height } ); 573 if ( $( window ).height() < inner_contatiner_height ) { 574 var inner_height = $( window ).height() - mobile_div.find( '.et_social_heading' ).innerHeight() + 10; 575 mobile_div.find( '.et_social_networks' ).css({ 'height' : inner_height }); 576 } 577 }, 400 ); 578 } 579 580 function set_sidebar_position(){ 581 if( $( '.et_social_sidebar_networks' ).length ){ 582 var this_sidebar = $( '.et_social_sidebar_networks' ), 583 top_position = $( window ).height() / 2 - this_sidebar.innerHe
583ight() / 2; 584 top_position = 0 > top_position ? 0 : top_position; 585 this_sidebar.css( { 'top' : top_position + 'px' } ); 586 } 587 } 588 589 function set_media_wrapper_size() { 590 if ( $( '.et_social_media_wrapper' ).length ) { 591 $( '.et_social_media_wrapper' ).each( function(){ 592 var this_wrapper = $( this ), 593 this_wrapper_media = this_wrapper.find( '.et_social_media' ), 594 this_image = this_wrapper.find( 'img' ), 595 image_position = this_image.position(), 596 image_left_offset = typeof image_position !== 'undefined' ? image_position.left : 0, 597 this_image_height = this_image.height(), 598 this_image_width = this_image.width(), 599 this_wrapper_networks_height = this_wrapper.find( '.et_social_networks' ).innerHeight(); 600 601 this_wrapper.addClass( this_image.attr( 'class' ) ); 602 this_wrapper_media.css( { 'max-height' : this_image_height } ); 603 this_wrapper_media.css( { 'height' : this_wrapper_networks_height + 50 } ); 604 this_wrapper_media.width( this_image_width - 80 ); 605 606 // adjust the icons position based on image alignement 607 if ( 0 !== image_left_offset ) { 608 this_wrapper_media.css( { 'left' : image_left_offset + 20 } ); 609 } 610 }); 611 612 // fix the media wrapper sizes in Divi Gallery Slider if needed 613 et_pb_fix_gallery_slider_icons_size(); 614 } 615 } 616 617 function et_pb_fix_gallery_wrapper() { 618 var $media_wrappers_inside_gallery = $( '.et_pb_gallery_grid .et_social_media_wrapper' ); 619 620 if ( 0 > $media_wrappers_inside_gallery.length ) { 621 return; 622 } 623 624 $media_wrappers_inside_gallery.each( function() { 625 var $this_wrapper = $( this ); 626 var $gallery_item = $this_wrapper.closest( '.et_pb_gallery_image' );
627 var $gallery_overlay = $gallery_item.find( '.et_overlay' ); 628 629 if ( 0 < $gallery_overlay.length ) { 630 // move the gallery overlay inside media icons wrapper so it won't break the sharing functionality 631 $this_wrapper.append( $gallery_overlay ); 632 } 633 }); 634 } 635 636 function et_pb_fix_gallery_slider_icons_size() { 637 var $gallery_slider_icons = $( '.et_pb_gallery_fullwidth .et_social_media_wrapper' ); 638 639 if ( 0 > $gallery_slider_icons.length ) { 640 return; 641 } 642 643 var $all_galleries = $( '.et_pb_gallery_fullwidth' ); 644 645 $all_galleries.each( function() { 646 var $this_gallery = $( this ); 647 var $this_gallery_media = $this_gallery.find( '.et_social_media_wrapper .et_social_media' ); 648 649 if ( 0 > $this_gallery_media.length ) { 650 return; 651 } 652 653 var $first_icon_wrapper = $this_gallery_media.first(); 654 var icons_width = $first_icon_wrapper.width(); 655 var icons_height = $first_icon_wrapper.css( 'height' ); 656 var icons_max_height = $first_icon_wrapper.css( 'max-height' ); 657 658 // use the dimensions from first slide and apply it to all the media icons in the slider 659 $this_gallery_media.width( icons_width - 80 ); 660 $this_gallery_media.height( icons_height ); 661 $this_gallery_media.css( { 'max-height' : icons_max_height } ); 662 }); 663 } 664 665 $ ( 'body' ).on( 'click', '.et_social_open_all', function() { 666 all_networks_opened++; 667 if ( 1 == all_networks_opened ) { 668 var this_button = $( this ), 669 page_id = this_button.data( 'page_id' ), 670 permalink = this_button.data( 'permalink' ), 671 title = this_button.data( 'title' ), 672 media = typeof this_button.data( 'media' ) !== 'undefined' ? this_button.data( 'media' ) : '', 673 is_popup = 'popup' == this_button.data( 'location' ) ? 'true' : 'false'; 674 675 $.ajax({ 676 type: 'POST', 677 url: monarchSettings.ajaxurl, 678 data: { 679 action : 'generate_all_networks_popup', 680 all_networks_page_id : page_id, 681 all_networks_link : permalink, 682 all_networks_title : title, 683 all_networks_media : media, 684 is_popup : is_popup, 685 generate_all_window_nonce : monarchSettings.generate_all_window_nonce 686 }, 687 success: function( data ) { 688 if ( 'false' == is_popup ) { 689 $( 'body' ).append( data ); 690 make_popup_visible( $( '.et_social_all_networks_popup' ), 1 ); 691 } else { 692 var popup_container = this_button.parent().closest( '.et_social_popup_content' ); 693 694 this_button.parent().replaceWith( data ); 695 define_popup_position( popup_container ); 696 all_networks_opened = 0; 697 } 698 } 699 }); 700 } 701 702 return false; 703 }); 704 705 set_mobile_sidebar_height(); 706 707 set_sidebar_position(); 708 709 $( window ).resize( function(){ 710 if ( $( '.et_social_resize' ).length ) { 711 $( '.et_social_resize' ).each( function() { 712 define_popup_position( $( this ) ); 713 }); 714 } 715 if ( $('.et_social_mobile') ) { 716 set_mobile_sidebar_height(); 717 } 718 if( $( '.et_social_sidebar_networks' ).length ){ 719 set_sidebar_position(); 720 } 721 722 set_media_wrapper_size(); 723 }); 724 725 $( '.et_social_hide_sidebar' ).click( function(){ 726 $( '.et_social_hide_sidebar' ).toggleClass( 'et_social_hidden_sidebar' ); 727 $( '.et_social_sidebar_networks' ).toggleClass( 'et_social_hidden_sidebar et_social_visible_sidebar' ); 728 }); 729 730 $( window ).load( function(){ 731 set_media_wrapper_size(); 732 733 if ( $( '.et_social_pin_images' ).length && ( $( '.et_social_all_button' ).length || $( '.et_social_pinterest' ).length ) ) { 734 var pin_container = $( '.et_social_pin_images' ), 735 permalink = pin_container.data( 'permalink' ), 736 title = pin_container.data( 'title' ), 737 post_id = pin_container.data( 'post_id' ), 738 $i = 0; 739 740 $( 'img' ).each( function(){ 741 //do not include comment avatars into the Modal 742 if ( ! $( this ).hasClass( 'avatar' ) ) { 743 var this_img = $( this ).attr( 'src' ), 744 this_alt = $( this ).attr( 'alt' ); 745 746 if ( '' != this_img ) { 747 var pin_link = 'http://www.pinterest.com/pin/create/button/?url=' + permalink + '&media=' + this_img + '&description=' + title, 748 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>'; 749 $( '.et_social_pin_images' ).append( this_img_container ); 750 $i++; 751 } 752 } 753 }); 754 755 //Append error message if no images found on page 756 if ( 0 == $i ) {
757 $( '.et_social_pin_images' ).append( monarchSettings.no_img_message ); 758 } 759 } 760 }); 761 }); 762})(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.