1$ = jQuery; 2 3Drupal.behaviors.tabMenu = {}; 4Drupal.behaviors.tabMenu.attach = function (context, settings) { 5 if ($('#cudl_content_container').length && $('#cudl_content_container > .letter').length) { 6 var letter_container = $('#cudl_content_container').closest('.cudl_single'); 7 if (!letter_container.length) { 8 letter_container = $('body'); 9 } 10 11 // add behaviour any unattached tab menu 12 var tab_menu = letter_container.find('ul.tab-menu:not(.attached)'); 13 if (!tab_menu.length) { 14 tab_menu = $('#block-cudl-cudl ul.tab-menu:not(.attached)'); 15 } 16 if (tab_menu.length) { 17 tab_menu.addClass('attached'); 18 tab_menu.prependTo(letter_container.closest('.region-content')); 19 20 // todo: remove this when Mike updates 21 tab_menu.find('li').each(function (i, e) { 22 // expect an <A> tag, not just LI 23 var elt = $(e); 24 if (elt.children('a').length == 0) { 25 var t = elt.text(); 26 elt.html(''); 27 elt.append($('<a href="#"></a>').text(t)); 28 } 29 }); 30 31 /** 32 * @CR2017-02-08 - insert "Around this date" link if not found 33 */ 34 if (tab_menu.find('li#tableLink').length == 0) { 35 var elt = $('<li id="tableLink"><a href="#">Around this date</a></li>'); 36 tab_menu.append(elt); 37 } 38 39 /** 40 * @CR2017-04-24 - insert "With this correspondent" link if not found 41 */ 42 if (tab_menu.find('li#correspondentLink').length == 0) { 43 var elt = $('<li id="correspondentLink"><a href="#">With this correspondent</a></li>'); 44 tab_menu.append(elt); 45 } 46 47 /** 48 * @CR2017-02-08 - if "original" scan exists, add note to secondary content 49 */ 50 if (tab_menu.find('li#scanLink').length == 1) { 51 // after secondary content has been filled 52 setTimeout(function(){ 53 $('.views-field-field-side-text .field-content:last').append('<div class="">Images of original letters from the Cambridge University Library collections are courtesy of Cambridge University Digital Library (<a href="http://cudl.lib.cam.ac.uk">cudl.lib.cam.ac.uk</a>).</div>'); 54 }, 250); 55 56 57 58 } 59 60if($("#tableLink").length>0){ 61 $("<div id='readanother'>Find the next letter</div>").insertAfter($("#letter .body-content")); 62 $("#readanother").hide(); 63 64 setTimeout(function(){ 65 $("#readanother:hidden").fadeIn("slow"); 66 },1500); 67 68 69 $("#readanother").on("click",function(){ 70 71 if($("#correspondentLink").length>0){ 72 $("#correspondentLink > a").trigger("click"); 73 } else { 74 $("#tableLink > a").trigger("click"); 75 } 76 $('html, body').animate({ 77 scrollTop: $("#tableLink").offset().top 78 }, 1000); 79 }); 80 } 81 // add "click" to each 82 tab_menu.find('li a').click(function () { 83 // close any footnote popups 84 $("#footnotepopup").remove(); 85 $("sup[id^='back-mark']").removeClass("selectedFootnote"); 86 87 if ($(this).hasClass('active')) { 88 return false; 89 } 90 tab_menu.find('li a').removeClass('active'); 91 var id = $(this).parent().attr('id'); 92 $(this).addClass('active'); 93 // hide others, show this item 94 switch (id) { 95 case 'transcriptLink': 96 $('#cudl_content_container > .letter').show(); 97 $('#cudl_content_container > .translation').hide(); 98 $('#cudl_content_container > #seadragoncontainer').hide(); 99 $('.darwin-timeline-container #darwin_timeline_letter_table').hide(); 100 $('.darwin-timeline-container-correspondent #darwin_timeline_letter_table').hide(); 101 break; 102 case 'translationLink': 103 $('#cudl_content_container > .letter').hide(); 104 $('#cudl_content_container > .translation').show(); 105 $('#cudl_content_container > #seadragoncontainer').hide(); 106 $('.darwin-timeline-container #darwin_timeline_letter_table').hide(); 107 $('.darwin-timeline-container-correspondent #darwin_timeline_letter_table').hide(); 108 break; 109 case 'scanLink': 110 $('#cudl_content_container > .letter').hide(); 111 $('#cudl_content_container > .translation').hide(); 112 $('#cudl_content_container > #seadragoncontainer').show(); 113 $('.darwin-timeline-container #darwin_timeline_letter_table').hide(); 114 $('.darwin-timeline-container-correspondent #darwin_timeline_letter_table').hide(); 115 break; 116 case 'tableLink': 117 $('#cudl_content_container > .letter').hide(); 118 $('#cudl_content_container > .translation').hide(); 119 $('#cudl_content_container > #seadragoncontainer').hide(); 120 $('.darwin-timeline-container #darwin_timeline_letter_table').show(); 121 $('.darwin-timeline-container #darwin_timeline_letter_table').trigger('show'); 122 $('.darwin-timeline-container-correspondent #darwin_timeline_letter_table').hide(); 123 break; 124 case 'correspondentLink': 125 $('#cudl_content_container > .letter').hide(); 126 $('#cudl_content_container > .translation').hide(); 127 $('#cudl_content_container > #seadragoncontainer').hide(); 128 $('.darwin-timeline-container #darwin_timeline_letter_table').hide(); 129 $('.darwin-timeline-container-correspondent #darwin_timeline_letter_table').show(); 130 $('.darwin-timeline-container-correspondent #darwin_timeline_letter_table').trigger('show'); 131 break; 132 } 133 134 // reconfigure secondary content size 135 $('.campl-secondary-content').trigger('reconfigure'); 136 137 return false; 138 }); 139 140 tab_menu.find('li a:first').click(); 141 } 142 } 143}; 144 145/* 146 Surface Impression custom script 147 */ 148 149/** 150 * @moved search results fixer to darwin_search module 151 */ 152$(document).on('closing', '.remodal', function (e) { 153 154 155 var vimeoframe = $("#vimeo")[0]; 156 var player = $f(vimeoframe); 157 player.api("pause"); 158 159 160}); 161 162 163$(function () {
164 $("#block-system-main div:contains('letter')").each(function () { 165 if ($.trim($(this).text()) == 'letter') { 166 $(this).remove(); 167 } 168 }); 169 $("#iframe1").attr("src","https://www.darwinproject.ac.uk/darwin/editor/index.html"); 170 $("#iframe2").attr("src","https://www.darwinproject.ac.uk/darwin/editor/garden.html"); 171 if ($(window).width() < 767) { 172 $(".block-darwin-search .form-text").attr("placeholder", "Search..."); 173 } 174 175 var dateregex = /(From|To)\s(.*)\s\s([0-9].*$)/; 176 var titleString = $(".opener h1").text(); 177 //titleString = titleString.replace(dateregex,"<span>$1</span> $2 <time>$3</time>"); 178 //$(".opener h1").html(titleString); 179 180 $(".campl-global-header:first").css("z-index", "199"); 181 var counter = 0; 182 $(".box.promo").each(function () { 183 $(this).find(".file-image a").attr("href", $(this).find("a:first").attr("href")); 184 $(this).on("click", function () { 185 window.location.href = $(this).find("a:first").attr("href"); 186 }); 187 if ($(window).width() > 600) { 188 189 if (counter % 2 == 0) { 190 $(this).addClass("leftpromo"); 191 } else { 192 $(this).addClass("rightpromo"); 193 } 194 counter++; 195 } 196 }); 197 198 $("#block-block-37 .file-image a").attr("href", $("#block-block-37 a:last").attr("href")); 199 200 $(".meet-people .file-image").each(function () { 201 $(this).find(".content").height($(this).find(".content").width()); 202 $(this).find("a").attr("href", $(this).parents("td").find(".views-field-title a").attr("href")); 203 }); 204 205 if ($('.node-type-page').length) { 206 $('#block-system-main .field-type-image img').each(function () { 207 208 // Get on screen image 209 var screenImage = $(this); 210 211 // Create new offscreen image to test 212 var theImage = new Image(); 213 theImage.src = screenImage.attr("src"); 214 215 // Get accurate measurements from that. 216 var $w = theImage.width; 217 var $h = theImage.height; 218 219 if ($w < 600) { 220 $(this).parent().addClass('small-image'); 221 } else if ($h >= $w) { 222 $(this).parent().addClass('portrait-image'); 223 } 224 if (window.console) { 225 console.log("width is = " + $w) 226 } 227 ; 228 229 }); 230 } 231 232 233 $(".campl-local-navigation-container li.first:contains('overview')").remove(); 234 235 // Crop for portrait images > 600px 236 $(function () { 237 var imageHeight, wrapperHeight, overlap, container = $('.portrait-image'); 238 239 function centerImage() { 240 imageHeight = container.find('img').height(); 241 wrapperHeight = container.height(); 242 overlap = (wrapperHeight - imageHeight) / 2; 243 container.find('img').css('margin-top', overlap); 244 } 245 246 $(window).on("load resize", centerImage); 247 var el = $('.portrait-image'); 248 }); 249 250// fix included images 251 252$("#cudl_content_container .figure img").each(function(){ 253 $(this).attr("src",$(this).attr("src").split("data/images/").join("/sites/default/files/")); 254}); 255 256 257 /// load schools content 258 259 if ($(".page-node-198").size() > 0) { 260 261 $(".campl-main-content").prepend("<div id='schools-inclusion' />") 262 $("#schools-inclusion").load("/sites/all/static/The%20Offer%20of%20a%20Liftetime_.html"); 263 264 265 } 266 267 if ($(".SI-7-11").size() > 0) { 268 //$(".campl-content-container .field-name-body .field-item").
268children().hide(); 269 $(".campl-content-container .field-name-body .field-item h3").wrapInner("<a data-remodal-target='intromodal' />").addClass("button").show(); 270 $(".campl-content-container .field-name-body").prepend($(".campl-content-container .field-name-body h3.button")); 271 $(".campl-content-container .field-name-body .field-item .intro").wrap("<div data-remodal-id='intromodal' id='intromodal' />"); 272 $('[data-remodal-id=intromodal]').remodal(); 273 274 } 275 276 // deal with schools content video 277 var iframeCount = 0; 278 $(".SI-7-11 .block-block iframe").each(function () { 279 iframeCount++; 280 $(this).parent().append("<p><a data-remodal-target='videomodal" + iframeCount + "'>Watch video</a></p>"); 281 $(this).wrap("<div data-remodal-id='videomodal" + iframeCount + "' id='videomodal" + iframeCount + "' />"); 282 283 $('[data-remodal-id=videomodal' + iframeCount + ']').remodal(); 284 }); 285 286 $(".SI-7-11 .region-content .block-block").each(function () { 287 if ($(this).find("a:last").size() > 0) { 288 if ($(this).find("a:last").attr("href") && $(this).find("a:last").attr("href").indexOf("ppt") != -1) { 289 $(this).find("a:last").attr("download", "presentation.pptx"); 290 $(this).find(".file-image a").attr("download", "presentation"); 291 } 292 } 293 294 if ($(this).is(":first")) { 295 $(this).find("h2:first").css("background-color", "#dc8a14"); 296 } 297 298 if ($(this).is(":last-child")) { 299 if ($(this).find(".campl-heading-container h2").text().indexOf("Discussion") != -1) { 300 $(this).append("<p><a data-remodal-target='questionmodal'>View</a></p>"); 301 $(this).find(".collapse").wrapAll("<div data-remodal-id='questionmodal' />"); 302 $("[data-remodal-id=questionmodal] .collapse p").hide(); 303 $("[data-remodal-id=questionmodal] .collapse .suggested p").show(); 304 $("[data-remodal-id=questionmodal] .collapse h4,[data-remodal-id=questionmodal] .collapse .suggested").on("click", function () { 305 $(this).parent().find("p").slideDown(); 306 }); 307 $('[data-remodal-id=questionmodal]').remodal(); 308 } 309 } 310 $(this).find(".file-image a").attr("href", $(this).find("a:last").attr("href")); 311 }); 312 313 314 // handle references 315 316 $(".node-type-page .field-name-field-file-reference").each(function () { 317 var URL = $(this).text(); 318 if (URL.indexOf("http") != -1) { 319 $(this).parent().find("a:first").attr("href", URL); 320 $(this).parent().find(".field-name-field-credit .field-item").wrap("<a href='" + URL + "' />"); 321 $(this).hide(); 322 } 323 324 }); 325 326 $(".campl-teaser").each(function () { 327 $(this).find(".file-image a").attr("href", $(this).find(".campl-teaser-title a").attr("href")); 328 }); 329 $(".view-topics li").each(function () { 330 $(this).find(".views-field-field-tag-image a").attr("href", $(this).find(".views-field-name a").attr("href")); 331 }); 332 333 $(".field-name-field-credit .field-items a").each(function () { 334 $(this).append($(this).parent().parent().parent().find(".field-name-field-file-copyright")); 335 }); 336 337 338 var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "
338November", "December"]; 339 340 $(".facetSubGroup .col2 a[href*='date']").not(".facetSubGroup .facetSubGroup a").each(function () { 341 var monthIndex = parseInt($(this).text()) - 1; 342 $(this).text(months[monthIndex]); 343 }); 344 345 346 // Letter page layout fixer 347 // var letter_container = $('.cudl_single .letter'); 348 // if ($('.cudl_single .letter').size()==0) { 349 // letter_container = $("body[class^='page-letter-']"); 350 // } 351 if ($('#cudl_content_container').length && $('#cudl_content_container > .letter').length) { 352 var letter_container = $('#cudl_content_container').closest('.cudl_single'); 353 if (!letter_container.length) { 354 letter_container = $('body'); 355 } 356 357 // $(".opener h1").wrap("<div class='opener' />"); 358 // //$(".region-content").prepend($(".opener > .opener")); 359 // $("h1.campl-sub-title").html($(".opener > .opener:first")); 360 361 // Adds basic sidebar markup 362 var $sidebar = '<div id="page-secondary" class="campl-column3 campl-secondary-content"> \ 363 <div class="region region-sidebar"> \ 364 </div> \ 365 </div>'; 366 367 // Tweaks page layout, then adds content to sidebar 368 //$('#page-content').removeClass('campl-column12').addClass('campl-column9'); 369 if ($('.campl-secondary-content').size() == 0) { 370 $($sidebar).insertAfter('.campl-main-content'); 371 $(".campl-main-content").removeClass('campl-column12').addClass('campl-column9'); 372 $(".campl-secondary-content").show(); 373 } 374 $('body').addClass('page-letter'); 375 $('.campl-secondary-content').attr('id', 'page-secondary'); 376 377 //@CR2017-04-08 378 var regionSidebar = $('.campl-secondary-content div.region-sidebar'); 379 if (regionSidebar.find('div.view-my-sidebar').length == 0) { 380 var mySidebar = '<div class="view view-my-sidebar view-id-my_sidebar view-display-id-block"> \ 381 <div class="view-content"> \ 382 <div class="views-row views-row-1 views-row-odd views-row-first views-row-last"> \ 383 <div class="views-field views-field-field-side-text"> \ 384 <div class="field-content"> \ 385 </div> \ 386 </div> \ 387 </div> \ 388 </div> \ 389 </div>'; 390 regionSidebar.append(mySidebar); 391 } 392 393 // // create letter-extras after CUDL block 394 // $('<div id="letter-extras"></div>').insertAfter('#block-cudl-cudl'); 395 396 // move Summary to page-secondary 397 $('#summary').appendTo('#page-secondary .field-content'); 398 // move letter details, terms and citations to page-secondary (RHS) 399 $('#letter_details').appendTo('#page-secondary .field-content'); 400 $('#terms').appendTo('#page-secondary .field-content'); 401 $('.cite').appendTo('#page-secondary .field-content'); 402 403 // Makes the wrapper class the same as regular pages 404 $('#page-content').addClass('content'); 405 406 /** 407 * @CR2017-04-24 - hide "terms" links altogether 408 * after advanced search, the letter details content contains nicer version of this 409 * and the links in here appear to be no use, so will hide for now 410 */ 411 $("#terms").hide(); 412 413 // todo: check needed 414 // Formats the Terms section 415 $("#terms h3").each(function () { 416 // Changes the title of "Other" 417 if ($(this).text() == "Other") { 418 $(this).text('General'); 419 } 420 // Turns each title into a nice value to use as a class 421 var $id = $(this).text().toLowerCase().split(' ').join('-'); 422 // Wraps each chunk in a div with the class 423 $(this).next('ul').andSelf().wrapAll("<div class='" + $id + "' />"); 424 }); 425 // Change the Terms main title 426 $('#terms h2').filter(function () { 427 return $(this).text() == "Subjects"; 428 }).text('Terms'); 429 430 431 // // Bibliography 432 // $('.bibl').addClass('box').appendTo('#letter-extras').find('.provenance').prepend('<div class="label"><i class="material-icons">account_balance</i> <span class="title">Provenance</span></div> '); 433 434 // // Enclosures 435 // $('.enclosure h2').filter(function(){ 436 // return $(this).text() == "[Enclosure]"; 437 // }).text('Enclosure'); 438 // $('.enclosures').addClass('box').appendTo('#letter-extras'); 439 440 // // More boxes 441 // $('.annotations').addClass('box').appendTo('#letter-extras'); 442 // $('.footnotes').addClass('box').appendTo('#letter-extras'); 443 444 // $(".call-url").appendTo('#letter-extras'); 445 446 // Letter details 447 $('#letter_details dt').each(function () { 448 if ($(this).text() == "Souce of text") { 449 $(this).text('Source of text'); 450 } 451 if ($(this).text() == "Physcial description") { 452 $(this).text('Physical description'); 453 } 454 var $id = $(this).text().toLowerCase().split(' ').join('-'); 455 $(this).next('dd').andSelf().wrapAll("<span class='" + $id + "' />"); 456 });
457 458 // $('#letter_details .from').prepend('<i class="material-icons">account_circle</i>'); 459 // $('#letter_details .to').prepend('<i class="material-icons">account_circle</i>'); 460 // $('#letter_details .sent-from').prepend('<i class="material-icons">language</i>'); 461 // $("#letter_details .source-of-text,#letter_details dl span:first").prepend('<i class="material-icons">library_books</i>'); 462 // $('#letter_details .physical-description').prepend('<i class="material-icons">remove_red_eye</i>'); 463 464 465 // Makes footnotes into links 466 $('sup[data-target]').each(function () { 467 var $i = $(this).attr('data-target').split(".").join("_"); 468 $(this).wrap('<a href="' + $i + '" class="footnotelink"></a>'); 469 }); 470 471 $(".footnote").each(function () { 472 $(this).attr("id", $(this).attr("id").split(".").join("_")); 473 }); 474 475 // sort out sort options 476 if ($("select[name='sort']").size() > 0 && urlParam('sort') != undefined) { 477 var sortParam = urlParam('sort'); 478 479 $("select[name='sort'] option").removeAttr("selected"); 480 $("select[name='sort'] option").each(function () { 481 if ($(this).val() == sortParam) { 482 $(this).attr("selected", "selected"); 483 } 484 485 }); 486 } 487 488 // // Bibliography pages 489 // var $str = $('h1.campl-sub-title').text(); 490 // if ($str.indexOf("bibliographies") >= 0){ 491 // $('body').addClass('bibliography-page'); 492 // 493 // $('#block-cudl-cudl h3').each(function(){ 494 // var $id2 = $(this).text().toLowerCase().split(' ').join('-'); 495 // $(this).addClass('capitalize'); 496 // $(this).next('p, ul').andSelf().wrapAll("<div class='"+$id2+"' />"); 497 // }); 498 // 499 // $('.location').appendTo('#page-secondary .field-content'); 500 // $('.volumes').appendTo('#page-secondary .field-content'); 501 // } 502 503 504 // move letter title above it all 505 // var h1 = letter_container.find('#letter div.opener h1'); 506 // if (h1.length) { 507 // h1.prependTo(letter_container.closest('.region-content')) 508 // .addClass('letter-title'); 509 // } 510 511// h1.addClass('campl-sub-title').addClass('campl-content-container'); 512 513 514 // footnotes popup 515 //$("a.footnotelink").on("click", openFootnoteModal); 516 517 openFootnoteModal = function(e, larger) { 518 e.preventDefault(); 519 let element = $(e.target).closest("a"); 520 $("#footnotepopup").remove(); 521 $("sup[id^='back-mark']").removeClass("selectedFootnote"); 522 element.find("sup:first").addClass("selectedFootnote"); 523 var id = element.attr("href"); 524 525 $("body").append("<div id='footnotepopup' />"); 526 527 528 $("#footnotepopup").append($(id).html()); 529 $("#footnotepopup").css({ 530 width: Math.max(150, $(window).width() * 0.33) + 'px', 531 padding: '15px', 532 border: '4px solid #DDD', 533 'box-shadow': '0 0 5px #000', 534 position: 'absolute', 535 background: '#FFF', 536 left: Math.min(e.pageX, $(window).width() - Math.max(200, $(window).width() * 0.33)) + 'px', 537 top: e.pageY + 'px', 538 'font-size': larger ? '1rem' : '0.8rem', 539 'line-height': 1.4, 540 'z-index': 10000001 541 }); 542 $("#footnotepopup").append("<div id='footnoteclose' ><i class='material-icons'>close</i></div>"); 543 $("#footnoteclose").on("click", function () { 544 $("sup[id^='back-mark']").removeClass("selectedFootnote"); 545 $(this).parent().remove(); 546 }); 547 return false; 548 } 549 550 $("a.footnotelink").on("click", function(e){ return openFootnoteModal(e, false); }); 551 $(".footnote .note_number").on("click", function () { 552 $("#footnotepopup").remove(); 553 $("sup[id^='back-mark']").removeClass("selectedFootnote"); 554 var id = $(this).parent().attr("id"); 555 if ($("#back-mark-" + id).size() > 0) { 556 $('html, body').animate({ 557 scrollTop: $("#back-mark-" + id).offset().top - 100 558 }, 1000, "swing", function () { 559 $("#back-mark-" + id).addClass("selectedFootnote"); 560 }); 561 } 562 }); 563 } 564 565 566 //* @PC -- why commented out I wonder... 567 568 if ($('.campl-secondary-content').on) { 569 $('.campl-secondary-content').on('reconfigure', {}, function () { 570 571 setTimeout(function () { 572 573 var primary = $(".campl-main-content"); 574 primary.css('min-height', ''); 575 // reconfigure content heights 576 var secondary = $('.campl-secondary-content'); 577 secondary.css('min-height', ''); 578 579 // sidebar inner 580 var sidebar = $('.region-sidebar'); 581 582 if (primary.length == 0 || secondary.length == 0) { 583 return; 584 } 585 586 // force layout reflow 587 primary[0].offsetHeight; 588 secondary[0].offsetHeight; 589 590 var defaultHeight = secondary.height(); 591 592 // console.log(secondary, defaultHeight, primary.height()); 593 594 var maxColumnHeight = Math.max(defaultHeight, primary.height()); 595 maxColumnHeight = Math.max(sidebar.height() - 60 /* it's got a top margin of -8.5em*/, maxColumnHeight); 596 597 if ($('.campl-tertiary-navigation').length > 0) { 598 $('.campl-tertiary-navigation, .campl-secondary-content, .campl-main-content').css({'min-height': maxColumnHeight + 50 + 'px'}) 599 //uneven height distribution on nav and sec columns 600 } 601 else { 602 $('.campl-main-content').css({'min-height': maxColumnHeight + 'px'}) 603 secondary.css({'min-height': maxColumnHeight + 50}) 604 } 605 }, 250); 606 607 });
608 } 609 //*/ 610 611 $(".physical-description dd").append("<span class='codes-explanation'><a href='/letters/symbols-and-abbreviations'>See symbols & abbreviations</a></span>"); 612 613 614 $(".field-name-body td").has(".file-image").addClass("imagecell").css({"width": "33%", "text-align": "center"}); 615 616 // ah ha 617 // @CR2017-02-11 618 // this was only being picked up on production 619 // the titles need to stay within letter content now 620 if ($(".SI-letter h1.campl-sub-title").text() == "Letter") { 621 // $(".SI-letter h1.campl-sub-title").html($(".SI-letter .block-cudl h2:first").text()); 622 // $(".SI-letter .block-cudl h2:first").remove(); 623 $(".SI-letter h1.campl-sub-title").remove(); 624 } 625 626}); 627 628function adjustImageCrop() { 629 630 $(".campl-horizontal-teaser-img .content img,.campl-vertical-teaser-img .content img").each(function () { 631 if ($(this).height() > $(this).width()) { 632 $(this).css({ 633 position: "relative", 634 top: "-" + ($(this).height() / 7) + "px" 635 }); 636 } 637 }); 638 639 640} 641 642 643$(window).on("resize", function () { 644 $(".meet-people .file-image").each(function () { 645 $(this).find(".content").height($(this).find(".content").width()); 646 }); 647 adjustImageCrop(); 648 adjustColumns(); 649}); 650 651function adjustColumns() { 652 setTimeout(function () { 653 if ($(window).width() > 767) { 654 655 if ($(".campl-secondary-content .region-sidebar").height() > $(".campl-main-content").height()) { 656 657 $(".campl-main-content").height($(".campl-secondary-content .region-sidebar").height() + 50); 658 659 } 660 661 } 662 }, 100); 663} 664 665 666$(window).on("load", function () { 667 668 adjustImageCrop(); 669 670 var jsonData; 671 672 $("#block-block-36 .file-image .content").prepend($("#block-block-36 .file-image .content img")); 673 674 675 adjustColumns(); 676 677 678 /*$(".search-result-item td b:contains('Classmark')").each(function(){ 679 var classmark = ( $(this).parent().next().text()); 680 681 $.getJSON( "/sites/all/modules/cudl/DAR-gateway.php?classmark="+escape(classmark), function( data) { 682 if(data.error=="OK"){ 683 $(".search-result-item td:contains('"+data.classmark+"')").parent().parent().parent().parent().find(".summary").addClass("hasImage").prepend("<div class='letter-thumbmnail'><img src='"+data.images[0]+"' alt='thumbnail image of letter' /></div>"); 684 } 685 }); 686 }); 687 688 if($("#letter_details").size()>0 && $(".source-of-text dd").size()>0){ 689 var classmark = $(".source-of-text dd").text(); 690 if(classmark.indexOf("DAR")!=-1){ 691 $.getJSON( "/sites/all/modules/cudl/DAR-gateway.php?classmark="+escape(classmark), function( data) { 692 if(data.error=="OK"){ 693 // 694 jsonData = data; 695 /// load openseadragon 696 $('#letter-extras').append("<div id='seadragoncontainer' style='width:100%;height:700px;background-color:black'/>"); 697 $.getScript( "/sites/all/modules/cudl/openseadragon.min.js" , function(){ 698 var viewer = OpenSeadragon({ 699 id:'seadragoncontainer', 700 prefixUrl :'/sites/all/modules/cudl/images/', 701 tileSources: jsonData.dzi, 702 sequenceMode: true, 703 preserveViewport: true 704 }); 705 }); 706 $(".region-content:first").prepend("<ul id='transcript-original-menu' class='tab-menu'><li id='transcriptLink' class='active'>Transcript</li><li id='scanLink'>Original</li></ul>"); 707 $("#seadragoncontainer").hide(); 708 $("#transcriptLink").on("click",function(){ 709 $("#seadragoncontainer").hide(); 710 $("#block-cudl-cudl").show(); 711 $("#letter-extras .box").show(); 712 $("#scanLink").removeClass("active"); 713 $(this).addClass("active"); 714 }); 715 $("#scanLink").on("click",function(){ 716 $("#seadragoncontainer").show(); 717 $("#block-cudl-cudl").hide(); 718 $("#letter-extras .box").hide(); 719 $("#transcriptLink").removeClass("active"); 720 $(this).addClass("active"); 721 }); 722 } 723 }); 724 } 725 726 }*/ 727 728// images 729 $("body").append("<div id='imagemodal' class='remodal' data-remodal-id='imagemodal' ><div class='contentholder'></div></div>"); 730 $(".file-image .content a").each(function () { 731 if ($(this).attr("href").toLowerCase().indexOf(".jpg") != -1 || $(this).attr("href").toLowerCase().indexOf(".png") != -1 || $(this).attr("href").toLowerCase().indexOf(".gif") != -1) { 732 $(this).on("click", function () { 733 $("#imagemodal .contentholder").html($(this).find("img").clone());
734 var inst = $('#imagemodal').remodal(); 735 inst.open(); 736 return false; 737 }); 738 } 739 }); 740 $('#imagemodal').on('contextmenu', 'img', function (e) { 741 return false; 742 }); 743 744 745 var observer = new MutationObserver(function(mutations) { 746 console.log("mutation") 747 let letter = $("#cudl_content_container .letter"); 748 if (letter.length > 0) { 749 console.log("element found!"); 750 letter.addClass("test"); 751 $("#cudl_content_container .letter .opener h1").css("max-width", "75%"); 752 letter.find(".opener").css("position", "relative"); 753 let button = $('<a href="#content_warning" class="footnotelink" style="position:absolute; top:1rem; right:0.2rem;font-size:1.25rem;"><sup id="back-mark-Lfoot_content_warning" class="footnote" data-target="" style="border:0.3rem solid black; padding: 2px 1em 4px;">Content warning</sup></a>'); 754 letter.find(".opener").append(button); 755 $("body").append("<div id='content_warning' style='display:none;'>The letters contained on the Darwin Correspondence Project website may include content and language that is upsetting or offensive. This reflects the attitudes of the historical period in which they were written. This can include language that is racist, sexist, ableist, homophobic, and otherwise discriminatory and unacceptable today. <br/>
755See this page for a commentary on <a href='/darwin-race-and-gender'>Charles Darwinâs views on race and gender</a>. <br/><a href='/about/contact'>Contact us here</a>.</div>"); 756 757 //letter.find(".opener").css("max-width", "calc(100%-6rem)"); 758 observer.disconnect(); 759 760 button.on("click", function(e) { 761 openFootnoteModal(e,true); 762 if ($("#footnotepopup").length == 0) { 763 $("#footnotepopup").removeClass("click_open"); 764 } else { 765 $("#footnotepopup").addClass("click_open"); 766 } 767 }); 768 button.on("mouseenter", function(e){ 769 if ($("#footnotepopup").length == 0 && !$("#footnotepopup").hasClass("click_open")) setTimeout(function(){return openFootnoteModal(e, true);},10); 770 }); 771 button.on("mouseleave", function(e){ 772 if ($("#footnotepopup").length > 0 && !$("#footnotepopup").hasClass("click_open") && !$("#footnotepopup").is(":hover")) { 773 $("#footnotepopup").remove(); 774 $("sup[id^='back-mark']").removeClass("selectedFootnote"); 775 } 776 }); 777 } 778 }); 779 780 observer.observe(document, {attributes: false, childList: true, characterData: false, subtree:true}); 781 782}); 783 784var urlParam = function (name, url) { 785 if (!url) { 786 url = window.location.href; 787 } 788 var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(url); 789 if (!results) { 790 return undefined; 791 } 792 return results[1] || undefined; 793} 794 795
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.