1var sub_navigation = { 2 3 init: function() { 4 window.galleries.sub_navigation.inject_sub_nav(); 5 window.galleries.sub_navigation.page_header_setup(); 6 window.galleries.sub_navigation.disable_page_header(); 7 this.set_panel_anchor_links(); 8 }, 9 10 inject_sub_nav: function() { 11 12 if ($('.scroll_sub_nav_enabled').length && $('.scroll_section_container').length && $('.page-param-type-artist_id #sub_nav.navigation, .page-param-type-exhibition_id #sub_nav.navigation').length) { 13 $('.page-param-type-artist_id #sub_nav.navigation, .page-param-type-exhibition_id #sub_nav.navigation').each(function() { 14 $('#header .inner').after('<div class="page-header-container record-page-content-combined" aria-hidden="true"><div id="page_header"><span class="page-header-inner"></span></div>'); 15 16 var original_html = $(this).parent().clone(); 17 original_html.find('.has_subtitle').removeAttr('hidden'); 18 original_html.find('#h1_wrapper').removeClass('hidden'); 19 original_html.find('.h1_wrapper').removeClass('hidden'); 20 // We don't want to add the share button to the header 21 original_html.find('#sub-item-share').remove(); 22 23 // Accessibillity changes to remove duplicate ids and change cloned h1 tags to h2 24 original_html.find('h1, h1.has_subtitle, h1.has_subnav').replaceWith(function() { 25 return $('<h2>', { 26 'class': this.className, 27 html: $(this).html() 28 },'</h2>') 29 }) 30 original_html.find("#sub_nav").prop("id", "sticky_sub_nav"); 31 original_html.find('#sticky_sub_nav ul li, #exhibition-status-current').each(function() { 32 $(this).attr("id", $(this).attr("id") + "-page_header"); 33 }) 34 35 $('.page-header-inner').append(original_html.html()); 36 }); 37 } 38 }, 39 40 page_header_setup: function() { 41 42 if ($('.scroll_sub_nav_enabled').length && $('.scroll_section_container').length && $('.page-param-type-artist_id #sub_nav.navigation, .page-param-type-exhibition_id #sub_nav.navigation').length) { 43 if (!$('.layout-hero-header').length) { 44 if ($('.scroll_section_container').length && $('.page-param-type-artist_id #sub_nav.navigation, .page-param-type-exhibition_id #sub_nav.navigation').length) { 45 $(window).resize(function() { 46 $('.header-fixed-wrapper').height($('.header_fixed').height()); 47 }).trigger('resize'); 48 } 49 } 50 } 51 }, 52 53 enable_page_header: function(window_scroll_top, scroll_direction) { 54 55 if ($('.scroll_sub_nav_enabled').length && $('.scroll_section_container').length && $('.page-param-type-artist_id #sub_nav.navigation, .page-param-type-exhibition_id #sub_nav.navigation').length) { 56 if (!$('.layout-hero-header').length) { 57 $('#container').addClass('page_header_enable'); 58 } else { 59 60 var sub_nav_top = $('#sub_nav').offset().top; 61 var sub_nav_height = $('#sub_nav').outerHeight(true); 62 var sub_nav_offset = sub_nav_top + sub_nav_height; 63 var sub_nav_offset_scroll_down = sub_nav_offset + 300; 64 var sub_nav_offset_scroll_up = sub_nav_offset - 200; 65 66 if ($('.page-top').length) { 67 $('#container').removeClass('page_header_enable'); 68 } else if (window_scroll_top > sub_nav_offset_scroll_down && scroll_direction =='down') { 69 $('#container').addClass('page_header_enable'); 70 } else if (window_scroll_top < sub_nav_offset_scroll_up && scroll_direction =='up') { 71 $('#container').removeClass('page_header_enable'); 72 } 73 } 74 } 75 }, 76 77 disable_page_header: function() { 78 if (!$('.scroll_section_container').length || !$('.page-param-type-artist_id, .page-param-type-exhibition_id').length) { 79 $('#container').removeClass('page_header_enable'); 80 } 81 }, 82 83 set_panel_anchor_links: function() { 84 var container = $('#main_content'); 85 var links_html = '<div id="sub_nav" class="feature-panel-nav navigation noprint clearafter clearwithin" role="navigation" aria-label="Subnavigation"><ul>'; 86 var anchor_panels = $('[data-anchor-label].panel'); 87 if ($('#sub_nav').length) { 88 return; 89 } 90 91 anchor_panels.each(function(i) { 92 var id = $(this).attr('data-panel-unique-id'); 93 var text = $(this).attr('data-anchor-label'); 94 95 // create anchor links 96 links_html += ''+ 97 '<li id="sub-item-overview" class="'+(!i ? 'first' : '')+'">'+ 98 '<a href="#" role="button">'+text+'</a>'+ 99 '</li>'; 100 }); 101 links_html += '</ul></div>'; 102 103 if (container.length && anchor_panels.length) { 104 var heading_wrapper = container.find('.heading_wrapper:not(.hidden)'); 105 var home_slideshow = container.find('#content #slideshow'); 106 if (heading_wrapper.length) { 107 heading_wrapper.append(links_html); 108 } else if (home_slideshow.length) { 109 home_slideshow.after(links_html); 110 } else { 111 container.prepend(links_html); 112 } 113 114 container.find('a').click(function(event) { 115 event.preventDefault(); 116 var label = $(this).text();
117 var section_el = $('[data-anchor-label="'+label+'"]'); 118 119 if (section_el.length) { 120 var offset = section_el.offset().top - 60; 121 $('html,body').animate( 122 { scrollTop: offset }, 123 800, 124 'easeInOutQuad', 125 function () { 126 $('body').delay(100).queue(function () { 127 $(this).removeClass('window-forced-scroll-up'); 128 $(this).dequeue(); 129 }); 130 // window.galleries.scroll_sections.subnav_active_change(); 131 // Accessibility - set focus on new section 132 $(section_el).get(0).focus({ preventScroll: true }); 133 } 134 ); 135 } 136 }) 137 } 138 } 139 140} 141 142window.galleries = window.galleries || {}; 143window.galleries.sub_navigation = sub_navigation; 144export default sub_navigation;
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.