1// Core frontend JS for Archimedes modules // 2// ----------------------------------------- // 3 4 5(function($) { 6 7 window.modules = { 8 9 init_all: function() { 10 this.shared.init(); 11 this.attachments.init(); 12 this.comments.init(); 13 this.messages.init(); 14 this.reviews.init(); 15 this.picture_gallery.init(); 16 this.media_gallery.init(); 17 this.faq.init(); 18 19 if($(".social_sharing_wrap").length > 1){ 20 //console.log("assign multi id"); 21 $(".social_sharing_wrap").each(function(index){ 22 $(this).attr("id","social_sharing_wrap-"+index); 23 $(this).find(".share_link").attr("id","share_link_btn-"+index); 24 $(this).find("#social_sharing").attr("id","social_sharing-"+index); 25 $(this).find("#relative_social_sharing").attr("id","relative_social_sharing-"+index); 26 $(this).find("#social_sharing_links").attr("id","social_sharing_links-"+index); 27 }); 28 } 29 30 31 32 this.sharing.init(); // applies to Share and Add to calendar menus 33 }, 34 35 shared: { 36 37 init: function() { 38 $('.module a.void').attr('href', 'javascript:void(0)'); 39 $('.module a.submit-btn') 40 .attr('href', 'javascript:void(0)') 41 .click(function() { 42 var data = modules.shared.parse_el_data(this) 43 //console.log('submit ' + data.form_selector); 44 $(data.form_selector)[0].submit(); 45 }); 46 $('.module div.toggle-editable').click(function() { 47 $('.module div.toggle-editable').removeClass('active'); 48 $(this).addClass('active'); 49 }); 50 }, 51 52 reveal_rows_speed: function(no_of_rows) { 53 // the speed at which the extra rows open is 54 // governed by the number of invisible rows... 55 var ms_per_row = 170; 56 var max_time = 1000; 57 var speed = (200 * no_of_rows); 58 if (speed > max_time) { 59 speed = max_time; 60 } 61 return speed; 62 }, 63 64 get_el_id: function(el) { 65 return $(el).closest('.module').attr('id'); 66 }, 67 68 parse_el_data: function(el) { 69 var el_id = this.get_el_id(el); 70 var el_selector = '#' + el_id; 71 var container_id = el_id + '_container'; 72 var container_selector = '#' + container_id; 73 var rows_id = el_id + '_rows'; 74 var rows_selector = '#' + rows_id; 75 var form_id = el_id + '_form'; 76 var form_selector = '#' + form_id; 77 var rows_data = [null, null, null]; 78 if ($(el_selector).attr('data-role')) { 79 rows_data = $(el_selector).attr('data-role').split(' '); 80 } 81 var data = { 82 el_id: el_id, 83 el_selector: el_selector, 84 container_id: container_id, 85 container_selector: container_selector, 86 rows_id: rows_id, 87 rows_selector: rows_selector, 88 form_id: form_id, 89 form_selector: form_selector, 90 no_of_rows: rows_data[0], 91 show_rows: rows_data[1], 92 max_rows: rows_data[2] 93 }; 94 return data; 95 } 96 97 }, 98 99 attachments: { 100 101 init: function() { 102 $('.module-attachments').each(function() { 103 var data = modules.shared.parse_el_data(this); 104 $(data.el_selector) 105 .wrap('<div id="' + data.container_id + '"></div>'); 106 $(data.el_selector + ' a.attach-link') 107 .click(function() { 108 modules.attachments.on_btn_click(this); 109 }); 110 }); 111 $('.module-attachments a.submit-btn') 112 .click(function() { 113 var data = modules.shared.parse_el_data(this); 114 var form_id = data.el_id + '_form'; 115 $('#' + form_id)[0].submit(); 116 }); 117 // 'browse' button is called different things on 118 // different browsers... 119 if ($.browser.safari) { 120 $('.module-attachments .browse-text').html('Choose File'); 121 } else if ($.browser.opera) { 122 $('.module-attachments .browse-text').html('Choose'); 123 } else if ($.browser.chrome) { 124 $('.module-attachments .browse-text').html('Choose File'); 125 } 126 $('.module-attachments a.row-save-btn') 127 .click(function() { 128 var form_el = $(this).closest('form'); 129 form_el.submit(); 130 }); 131 $('.module-attachments a.row-remove-btn') 132 .click(function() { 133 var form_el = $(this).closest('form'); 134 var filename = $(form_el)[0].filename.value; 135 $.prompt("Are you sure you want to remove this file? This action cannot " + 136 "be undone.", { 137 buttons: { 138 'Cancel': false, 139 'Permanently remove file': true 140 }, 141 callback: function(bool) { 142 if (bool) { 143 $(form_el)[0]._remove.value = filename; 144 form_el.submit(); 145 } 146 } 147 }); 148 }); 149 }, 150 151 on_btn_click: function(el) { 152 data = modules.shared.parse_el_data(el); 153 $(data.el_selector + ' .add_btn_container').hide(); 154 $(data.el_selector + ' .single-uploader').slideDown(600); 155 }, 156 157 show_content: function(el_id) { 158 var html = $('#' + el_id).html(); 159 h.alert(html); 160 } 161 162 }, 163 164 comments: { 165 166 init: function() { 167 $('.module-comments .module-comments-reveal-rows-button a') 168 .attr('href', 'javascript:void(0)') 169 .click(function() { 170 $(this).closest('.module-comments-reveal-rows-button').hide(); 171 $(this).closest('.module-comments').find('.module-comments-rows-container').slideDown(); 172 }) 173 ; 174 $('.module-comments .more-link a') 175 .attr('href', 'javascript:void(0)') 176 .each(function() {modules.comments.show_more(this);}); 177 $('.module-comments .less-link a') 178 .attr('href', 'javascript:void(0)') 179 .each(function() {modules.comments.show_less(this);}); 180 if ($('.module-comments .rows div.featured').length == 0) { 181 // if there are no featured comments, hide the 182 // 'Sort by Editor pick' option 183 $('.module-comments a.link-sort-featured').remove(); 184 $('.module-comments a.link-sort-latest').closest('li').addClass('active'); 185 } 186 $('.module-comments a.link-sort-featured') 187 .attr('href', 'javascript:void(0)') 188 .click(function() {modules.comments.resort(this, 'featured');}); 189 $('.module-comments a.link-sort-rating') 190 .attr('href', 'javascript:void(0)') 191 .click(function() {modules.comments.resort(this, 'rating');}); 192 $('.module-comments a.link-sort-latest') 193 .attr('href', 'javascript:void(0)') 194 .click(function() {modules.comments.resort(this, 'latest');}); 195 if (h.element_exists('.module-comment-submitted')) { 196 var html = $('.module-comment-submitted').html(); 197 $('.module-comment-submitted').html(''); // clear it 198 h.alert(html); 199 } 200 }, 201 202 get_el_id: function(el) { 203 return $(el).closest('.module-comments').attr('id'); 204 }, 205 206 resort: function(el, sort_value) { 207 var data = modules.shared.parse_el_data(el); 208 $(data.el_selector + ' .less-link').hide(); 209 $(data.el_selector + ' .more-link').show(); 210 $(data.el_selector + ' li').removeClass('active'); 211 $(el).closest('li').addClass('active'); 212 var url = $(data.el_selector + ' #module-get-path').val();
213 $(data.rows_selector).load(url, { 214 'order_by': sort_value, 215 'reload': 1 216 }); 217 }, 218 219 show_more: function(el) { 220 var data = modules.shared.parse_el_data(el); 221 var speed = modules.shared.reveal_rows_speed(data.no_of_rows - data.show_rows); 222 $(el).click(function() { 223 $(data.el_selector + ' .more-link').hide(); 224 $(data.el_selector + ' .less-link').show(); 225 $(data.el_selector + ' .more-items').slideDown(speed); 226 }); 227 }, 228 229 show_less: function(el) { 230 var data = modules.shared.parse_el_data(el); 231 var speed = modules.shared.reveal_rows_speed(data.no_of_rows - data.show_rows); 232 $(el).click(function() { 233 $(data.el_selector + ' .less-link').hide(); 234 $(data.el_selector + ' .more-link').show(); 235 $(data.el_selector + ' .more-items').slideUp(speed); 236 }); 237 } 238 239 }, 240 241 picture_gallery: { 242 init: function() { 243 if (h.element_exists('#picture_gallery')) { 244 $('#picture_gallery .slideshow') 245 .cycle({ 246 fx: 'fade', 247 speed: 1200, 248 timeout: 5000, 249 pause: 0, 250 before: function(currSlideElement, nextSlideElement, options) { 251 $('#slideshow_caption').html($(this).attr('rel')); 252 $('#picture_gallery #slideshow_thumbnails li a').removeClass('active'); 253 $('#picture_gallery #slideshow_thumbnails li a span').stop().hide(0).fadeTo(0, 0); 254 255 next_slide_id = $(nextSlideElement).attr('id').split('pg_slide_')[1]; 256 next_slide_thumb_id = '#pg_thumb_' + next_slide_id; 257 $(next_slide_thumb_id + ' a', '#picture_gallery #slideshow_thumbnails').addClass('active'); 258 $(next_slide_thumb_id + ' a span', '#picture_gallery #slideshow_thumbnails').show(0).fadeTo(200, 0.92); 259 260 next_slide_thumb_container = $(next_slide_thumb_id + ' a span').closest('ul').attr('rel'); 261 if (next_slide_thumb_container) { 262 $('#picture_gallery #slideshow_thumbnails').cycle(parseInt(next_slide_thumb_container)); 263 } 264 } 265 }); 266 267 $('#picture_gallery #slideshow_thumbnails a') 268 .click(function () { 269 $(this).fadeTo(0, 1); 270 $('#picture_gallery .slideshow').cycle('pause'); 271 if ($(this).attr('rel')) { 272 $('#picture_gallery .slideshow').cycle(parseInt($(this).attr('rel'))); 273 } 274 return false; 275 }) 276 .mouseover(function () { 277 if ($(this).hasClass('active')) { 278 $(this).fadeTo(0, 1); 279 } else { 280 $(this).fadeTo(100, 0.7); 281 } 282 }) 283 .mouseout(function () { 284 $(this).fadeTo(250, 1); 285 }) 286 ; 287 288 $('#picture_gallery #slideshow_thumbnails').cycle({ 289 fx: 'scrollHorz', 290 speed: 500, 291 timeout: 1000 292 }); 293 $('#picture_gallery #slideshow_thumbnails').cycle('pause'); 294 $('#picture_gallery #slideshow_thumbnails_prev a').click(function () { 295 $('#picture_gallery .slideshow').cycle('pause'); 296 $('#picture_gallery #slideshow_thumbnails').cycle('prev'); 297 return false;
298 }); 299 $('#picture_gallery #slideshow_thumbnails_next a').click(function () { 300 $('#picture_gallery .slideshow').cycle('pause'); 301 $('#picture_gallery #slideshow_thumbnails').cycle('next'); 302 return false; 303 }); 304 } 305 } 306 }, 307 308 media_gallery: { 309 init: function() { 310 if (h.element_exists('#media_gallery')) { 311 $('#media_gallery .slideshow') 312 .cycle({ 313 fx: 'fade', 314 speed: 1200, 315 timeout: 5000, 316 pause: 0, 317 before: function(currSlideElement, nextSlideElement, options) { 318 $('#slideshow_caption').html($(this).attr('rel')); 319 $('#media_gallery #slideshow_thumbnails li a').removeClass('active'); 320 $('#media_gallery #slideshow_thumbnails li a span').stop().hide(0).fadeTo(0, 0); 321 322 next_slide_id = $(nextSlideElement).attr('id').split('pg_slide_')[1]; 323 next_slide_thumb_id = '#pg_thumb_' + next_slide_id; 324 $(next_slide_thumb_id + ' a', '#media_gallery #slideshow_thumbnails').addClass('active'); 325 $(next_slide_thumb_id + ' a span', '#media_gallery #slideshow_thumbnails').show(0).fadeTo(200, 0.92); 326 327 next_slide_thumb_container = $(next_slide_thumb_id + ' a span').closest('ul').attr('rel'); 328 if (next_slide_thumb_container) { 329 $('#media_gallery #slideshow_thumbnails').cycle(parseInt(next_slide_thumb_container)); 330 } 331 } 332 }); 333 334 $('#media_gallery #slideshow_thumbnails a') 335 .click(function () { 336 $(this).fadeTo(0, 1); 337 $('#media_gallery .slideshow').cycle('pause'); 338 if ($(this).attr('rel')) { 339 $('#media_gallery .slideshow').cycle(parseInt($(this).attr('rel'))); 340 } 341 return false; 342 }) 343 .mouseover(function () { 344 if ($(this).hasClass('active')) { 345 $(this).fadeTo(0, 1); 346 } else { 347 $(this).fadeTo(100, 0.7); 348 } 349 }) 350 .mouseout(function () { 351 $(this).fadeTo(250, 1); 352 }) 353 ; 354 355 $('#media_gallery #slideshow_thumbnails').cycle({ 356 fx: 'scrollHorz', 357 speed: 500, 358 timeout: 1000 359 }); 360 $('#media_gallery #slideshow_thumbnails').cycle('pause'); 361 $('#media_gallery #slideshow_thumbnails_prev a').click(function () { 362 $('#media_gallery .slideshow').cycle('pause'); 363 $('#media_gallery #slideshow_thumbnails').cycle('prev'); 364 return false; 365 }); 366 $('#media_gallery #slideshow_thumbnails_next a').click(function () { 367 $('#media_gallery .slideshow').cycle('pause'); 368 $('#media_gallery #slideshow_thumbnails').cycle('next'); 369 return false;
370 }); 371 } 372 } 373 }, 374 375 messages: { 376 377 init: function() { 378 $('.module-messages .more-link a') 379 .attr('href', 'javascript:void(0)') 380 .each(function() {modules.messages.show_more(this);}); 381 $('.module-messages .less-link a') 382 .attr('href', 'javascript:void(0)') 383 .each(function() {modules.messages.show_less(this);}); 384 if ($('.module-messages .rows div.featured').length == 0) { 385 // if there are no featured comments, hide the 386 // 'Sort by Editor pick' option 387 $('.module-messages a.link-sort-featured').remove(); 388 $('.module-messages a.link-sort-latest').closest('li').addClass('active'); 389 } 390 $('.module-messages a.link-sort-featured') 391 .attr('href', 'javascript:void(0)') 392 .click(function() {modules.messages.resort(this, 'featured');}); 393 $('.module-messages a.link-sort-rating') 394 .attr('href', 'javascript:void(0)') 395 .click(function() {modules.messages.resort(this, 'rating');}); 396 $('.module-messages a.link-sort-latest') 397 .attr('href', 'javascript:void(0)') 398 .click(function() {modules.messages.resort(this, 'latest');}); 399 if (h.element_exists('.module-message-submitted')) { 400 var html = $('.module-message-submitted').html(); 401 $('.module-message-submitted').html(''); // clear it 402 h.alert(html); 403 } 404 }, 405 406 get_el_id: function(el) { 407 return $(el).closest('.module-messages').attr('id'); 408 }, 409 410 resort: function(el, sort_value) { 411 var data = modules.shared.parse_el_data(el); 412 $(data.el_selector + ' .less-link').hide(); 413 $(data.el_selector + ' .more-link').show(); 414 $(data.el_selector + ' li').removeClass('active'); 415 $(el).closest('li').addClass('active'); 416 var url = $(data.el_selector + ' #module-get-path').val(); 417 $(data.rows_selector).load(url, { 418 'order_by': sort_value, 419 'reload': 1 420 }); 421 }, 422 423 show_more: function(el) { 424 var data = modules.shared.parse_el_data(el); 425 var speed = modules.shared.reveal_rows_speed(data.no_of_rows - data.show_rows); 426 $(el).click(function() { 427 $(data.el_selector + ' .more-link').hide(); 428 $(data.el_selector + ' .less-link').show(); 429 $(data.el_selector + ' .more-items').slideDown(speed); 430 }); 431 }, 432 433 show_less: function(el) { 434 var data = modules.shared.parse_el_data(el); 435 var speed = modules.shared.reveal_rows_speed(data.no_of_rows - data.show_rows); 436 $(el).click(function() { 437 $(data.el_selector + ' .less-link').hide(); 438 $(data.el_selector + ' .more-link').show(); 439 $(data.el_selector + ' .more-items').slideUp(speed); 440 }); 441 } 442 443 }, 444 445 reviews: { 446 447 init: function() { 448 $('.module-reviews .module-reviews-reveal-rows-button a') 449 .attr('href', 'javascript:void(0)') 450 .click(function() { 451 $(this).closest('.module-reviews-reveal-rows-button').hide(); 452 $(this).closest('.module-reviews').find('.module-reviews-rows-container').slideDown(); 453 }) 454 ; 455 $('.module-reviews .more-link a') 456 .attr('href', 'javascript:void(0)') 457 .each(function() {modules.reviews.show_more(this);}); 458 $('.module-reviews .less-link a') 459 .attr('href', 'javascript:void(0)') 460 .each(function() {modules.reviews.show_less(this);}); 461 if ($('.module-reviews .rows div.featured').length == 0) { 462 // if there are no featured reviews, hide the 463 // 'Sort by Editor pick' option 464 $('.module-reviews a.link-sort-featured').remove(); 465 $('.module-reviews a.link-sort-latest').closest('li').addClass('active'); 466 } 467 $('.module-reviews a.link-sort-featured') 468 .attr('href', 'javascript:void(0)') 469 .click(function() {modules.reviews.resort(this, 'featured');}); 470 $('.module-reviews a.link-sort-rating') 471 .attr('href', 'javascript:void(0)') 472 .click(function() {modules.reviews.resort(this, 'rating');}); 473 $('.module-reviews a.link-sort-latest') 474 .attr('href', 'javascript:void(0)') 475 .click(function() {modules.reviews.resort(this, 'latest');}); 476 if (h.element_exists('.module-review-submitted')) { 477 var html = $('.module-review-submitted').html(); 478 $('.module-review-submitted').html(''); // clear it 479 h.alert(html); 480 } 481 }, 482 483 get_el_id: function(el) { 484 return $(el).closest('.module-reviews').attr('id'); 485 }, 486 487 resort: function(el, sort_value) { 488 var data = modules.shared.parse_el_data($(el)); 489 $(data.el_selector + ' .less-link').hide(); 490 $(data.el_selector + ' .more-link').show(); 491 $(data.el_selector + ' li').removeClass('active'); 492 $(el).closest('li').addClass('active'); 493 var url = $(data.el_selector + ' #module-get-path').val();
494 $(data.rows_selector).load( 495 url, 496 { 497 'order_by': sort_value, 498 'reload': 1, 499 'exclude_ids': $('.module-reviews').find('#reviews-exclude-ids').val() 500 }, 501 function() { 502 window.modules.reviews.after_resort(); 503 } 504 ); 505 }, 506 507 after_resort: function() { 508 509 }, 510 511 show_more: function(el) { 512 var data = modules.shared.parse_el_data(el); 513 var speed = modules.shared.reveal_rows_speed(data.no_of_rows - data.show_rows); 514 $(el).click(function() { 515 $(data.el_selector + ' .more-link').hide(); 516 $(data.el_selector + ' .less-link').show(); 517 $(data.el_selector + ' .more-items').slideDown(speed); 518 }); 519 }, 520 521 show_less: function(el) { 522 var data = modules.shared.parse_el_data(el); 523 var speed = modules.shared.reveal_rows_speed(data.no_of_rows - data.show_rows); 524 $(el).click(function() { 525 $(data.el_selector + ' .less-link').hide(); 526 $(data.el_selector + ' .more-link').show(); 527 $(data.el_selector + ' .more-items').slideUp(speed); 528 }); 529 } 530 531 }, 532 533 faq: { 534 init: function() { 535 $('.module-faq .faq_question a').click(function() { 536 var faq_id = $(this).closest('.module-faq .faq_question').attr('id'); 537 //note the hyphenated "faq-answer-" this is because i wanted to avoid faq_answer-[id] scenario!! 538 $(".module-faq #faq-answer-" + faq_id).slideToggle(500); 539 $(this).closest('.module-faq .faq_item').toggleClass('active'); 540 }); 541 } 542 }, 543 544 sharing: { 545 546 547 init: function(popup_init) { 548 549 if ($('.popup_links').length) { 550 551 $('.popup_links').each(function(index) { 552 553 var popup_links_id = '#' + $(this).attr('id'); 554 var popup_links = $('#' + $(this).attr('id')); // $('#social_sharing_links') 555 var popup_links_parent = '#' + $(this).parents('.popup_links_parent').attr('id'); // #social_sharing 556 //var popup_links_nav_link = $(this).parents('.popup_vertical_link').attr('class'); //.share_link 557 if (typeof $(this).parents('.popup_vertical_link').attr('id') !== 'undefined' && $(this).parents('.popup_vertical_link').attr('id') !== false ){ 558 //for normal case 559 var popup_links_nav_link = "#share_link_btn-"+index; 560 }else{ 561 //for bespoke or TP if it is still using class name 562 var popup_links_nav_link = $(this).parents('.popup_vertical_link').attr('class'); 563 if (popup_links_nav_link) { 564 popup_links_nav_link = String("." + $(this).parents('.popup_vertical_link').attr('class').split(' ')[1]); //.share_link 565 } 566 } 567 568 //console.log(popup_links_nav_link); 569 if(!popup_links.hasClass('inline') && (popup_links_nav_link == '.share_link' || popup_links_nav_link == '.add_to_calendar_link' || popup_links_nav_link == '#share_link_btn-'+index )) { 570 571 if (!popup_init){ 572 if ($('div' + popup_links_parent +':eq(0)').length > 0 && $('body >' + popup_links_parent).length) { 573 $('body >' + popup_links_parent).remove(); 574 } 575 if ($(popup_links_nav_link + ':eq(0)').length && !$(popup_links_nav_link + ':eq(0)').hasClass('retain_dropdown_dom_position')) { 576 $('div' + popup_links_parent +':eq(0)').detach().appendTo('body'); 577 } 578 } else { 579 if ($('div' + popup_links_parent +':eq(0)').length > 0 && $('body >' + popup_links_parent).length > 0) { 580 $('body >' + popup_links_parent).remove(); 581 } 582 if ($(popup_links_nav_link + ':eq(0)').length && !$(popup_links_nav_link + ':eq(0)').hasClass('retain_dropdown_dom_position')) { 583 $('div' + popup_links_parent +':eq(0)').detach().appendTo('body'); 584 } 585 popup_links.find('a').each(function() { 586 if ($(this).attr('href').indexOf('http') == 0) { 587 $(this).attr('target', '_blank'); 588 } 589 }); 590 } 591 $(popup_links_nav_link + ' > a').unbind().click(function(e) { 592 e.preventDefault(); 593 //console.log("click to " + popup_links_nav_link); 594 //console.log("this.parent" + popup_links_parent); 595 $(this).addClass('active'); 596 var div_buttom = $(this).parent(); 597 var $popup_links_parent = $(popup_links_parent) 598 599 var close_class = 'close'; 600 if (div_buttom.hasClass('retain_dropdown_dom_position')) { 601 close_class = 'dropdown_closed' 602 603 var popup_links_buttom = $(popup_links_id, div_buttom); 604 var popup_links_parent_buttom = $(popup_links_parent, div_buttom); 605 } 606 607 if(popup_links_buttom.hasClass(close_class)){ 608 609 $(this).attr('aria-expanded', true) 610 $('body').addClass('share-dropdown-active'); 611 var windowHeight = $('body').outerHeight(); 612 var scrollTop = $(window).scrollTop(); 613 var top = 0; 614 var left = 0; 615 616 // HIGHTS FOR ABOVE-BELOW 617 var bodyBorder = $('body').outerHeight() - $('body').height(); 618 if ($('#cms-frontend-toolbar').length) { 619 bodyBorder = bodyBorder - $('.cms-frontend-toolbar-active #cms-frontend-toolbar-container').height(); 620 } 621 622 var topValueButtonShare = div_buttom.offset().top; 623 var heighValueShareButton = div_buttom.outerHeight(); 624 var bottonDistanceShareButton= scrollTop + windowHeight - topValueButtonShare - he
624ighValueShareButton - bodyBorder; 625 var heightItem = popup_links_buttom.outerHeight(); 626 627 // WIDTHS FOR LEFT-RIGHT 628 var windowWidth = $(window).width(); 629 var offsetLeftShareButton = div_buttom.offset().left; 630 var widthShareButton = div_buttom.outerWidth(); 631 var sharing_element_width = popup_links_buttom.outerWidth(); 632 633 // POPUP VERTICAL 634 if( popup_links_buttom.hasClass('popup_vertical')){ 635 // Calculating whether pop-up should appear above or below 636 if(bottonDistanceShareButton < heightItem){ 637 // ABOVE THE BOTTOM 638 if (div_buttom.hasClass('retain_dropdown_dom_position')) { 639 top = 0 - heightItem; 640 } else { 641 top = topValueButtonShare + bodyBorder - heightItem; 642 } 643 popup_links_buttom.css('bottom', '0px'); 644 popup_links_parent_buttom.css({'width': sharing_element_width + 29 + 'px', 'top': top, 'height': heightItem + 'px'}); 645 }else{ 646 // BELOW THE BOTTOM 647 if (div_buttom.hasClass('retain_dropdown_dom_position')) { 648 top = heighValueShareButton; 649 } else { 650 top = topValueButtonShare + bodyBorder + heighValueShareButton; 651 } 652 popup_links_buttom.css("bottom", "auto"); 653 popup_links_parent_buttom.css({'width': sharing_element_width + 29 + 'px', 'top': top , 'height': heightItem + 'px'}); 654 } 655 656 if (!div_buttom.hasClass('left_aligned')) { 657 // Calculating whether pop-up should appear left or right 658 popup_links_parent_buttom.removeClass('right_aligned'); 659 if(windowWidth - offsetLeftShareButton - widthShareButton < sharing_element_width){ 660 // |+SHARE| 661 // ############### 662 // ############### 663 if (div_buttom.hasClass('retain_dropdown_dom_position')) { 664 popup_links_parent_buttom.css({"left": "auto", "right": "0"}).addClass('right_aligned'); 665 } else { 666 left = offsetLeftShareButton - sharing_element_width + widthShareButton; 667 popup_links_parent_buttom.css({"left": left + "px"}); 668 } 669 670 }else{ 671 // |+SHARE| 672 // ############### 673 // ############### 674 if (div_buttom.hasClass('retain_dropdown_dom_position')) { 675 popup_links_parent_buttom.css({"left": "0", "right": "auto"}); 676 } else { 677 popup_links_parent_buttom.css({"left": offsetLeftShareButton + "px"}); 678 } 679 } 680 } 681 682 popup_links_buttom.slideToggle(300); 683 popup_links_parent_buttom.css('opacity','0'); 684 popup_links_parent_buttom.animate({opacity:'1'},400); 685 686 } 687 688 // INLINE POPUP 689 else if( popup_links_buttom.hasClass('inline_popup')){ 690 691 if(bottonDistanceShareButton - heighValueShareButton < heightItem){ 692 693 // ABOVE THE BOTTOM 694 top = topValueButtonShare + bodyBorder - heightItem; 695 popup_links_buttom.css({"top": top + "px"}) 696 }else{ 697 // BELOW THE BOTTOM 698 top = topValueButtonShare + heighValueShareButton + bodyBorder; 699 popup_links_buttom.css({"top": top + "px"}); 700 } 701 if(windowWidth - offsetLeftShareButton - widthShareButton < sharing_element_width){ 702 // |+SHARE| 703 // ############### 704 // ############### 705 if(windowWidth < 500){ 706 popup_links_buttom.css({"left": offsetLeftShareButton + "px"}); 707 }else{ 708 left = offsetLeftShareButton - sharing_element_width + widthShareButton; 709 popup_links_buttom.css({"left": left + "px"}) 710 } 711 }else{ 712 // |+SHARE| 713 // ############### 714 // ############### 715 popup_links_buttom.css({"left": offsetLeftShareButton + "px"}) 716 } 717 popup_links_buttom.fadeToggle(200); 718 } 719 720 popup_links_buttom.find('a').attr("tabindex", 0) 721 popup_links_buttom.find('a:first').focus(); 722 723 // triggers close of share dropdown 724 function trigger_close(e) { 725 e.preventDefault(); 726 $(popup_links_nav_link + '> a.active').focus() 727 $(popup_links_id + ' ul').trigger("mouseup"); 728 } 729 // triggers close if you tab backwards from first item in dropdown 730 popup_links_buttom.find('ul a:first').on('keydown', function (e) { 731 var keyCode = e.which; 732 if ( keyCode == 9 && e.shiftKey ) { 733 trigger_close(e); 734 } 735 }); 736 // triggers close if you tab forwards from last item in dropdown 737 popup_links_buttom.find('ul a:last').on('keydown', function (e) { 738 var keyCode = e.which; 739 if ( keyCode == 9 && !e.shiftKey ) { 740 trigger_close(e) 741 } 742 }); 743 // triggers close if escape key pressed whilst on any of the dropdown links 744 popup_links_buttom.find('ul a').on('keydown', function (e) { 745 var keyCode = e.which; 746 if ( keyCode == 27 ) { 747 trigger_close(e) 748 } 749 }); 750 751 popup_links_buttom.removeClass(close_class); 752 753 754 // CLOSE SHARINGPOP-UP WHEN YOU CLICK IN OTHER
754SITE OF THE BROWSER 755 $(document).mouseup(function (e){ 756 if (!popup_links_buttom.is(e.target) && !$(popup_links_nav_link + '> a').is(e.target) && !popup_links_buttom.hasClass(close_class)){ 757 if(popup_links_buttom.hasClass('inline_popup')){ 758 popup_links_buttom.fadeToggle(200); 759 }else if( popup_links_buttom.hasClass('popup_vertical')){ 760 popup_links_buttom.slideToggle(300, function(){ 761 $(popup_links_parent).css({"height": "0px"}) 762 }); 763 764 $(popup_links_parent).css('opacity','1'); 765 $(popup_links_parent).animate({opacity:'0'},400); 766 } 767 $(popup_links_buttom).addClass(close_class); 768 769 $(popup_links_nav_link + ' > a.active') 770 .removeClass('active') 771 .attr('aria-expanded', false); 772 773 setTimeout(function(){ 774 $('body').removeClass('share-dropdown-active'); 775 }, 500); 776 } 777 }); 778 779 }else{ 780 // ACTION DEPEND OF GALLERY_SETTING: inline_popup,popup_vertical 781 if(popup_links_buttom.hasClass('inline_popup')){ 782 popup_links_buttom.fadeToggle(200); 783 }else if( popup_links_buttom.hasClass('popup_vertical')){ 784 popup_links_buttom.slideToggle(300, function(){ 785 $(popup_links_parent).css({"height": "0px"}) 786 }); 787 $(popup_links_parent).css('opacity','1'); 788 $(popup_links_parent).animate({opacity:'0'},400); 789 } 790 popup_links_buttom.addClass(close_class); 791 $(popup_links_nav_link + '> a.active') 792 .removeClass('active') 793 .attr('aria-expanded', false); 794 795 setTimeout(function(){ 796 $('body').removeClass('share-dropdown-active'); 797 }, 500); 798 } 799 800 }) 801 802 } 803 804 }) 805 806 } 807 808 } 809 810 }, 811 }; 812 813 814 $(document).ready(function() { 815 816 modules.init_all(); 817 818 }); 819 820 821})(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.