1/* 2 * University of Houston 3 * Scripts for the 2016 landing/gateway pages 4 * 5 * Table of Contents: 6 * ------------------ 7 * lazyYT (lazy load YouTube videos) 8 * Magic 9 * Page Header Image Margin 10 * Match Breadcrumb theme 11 * Page Contents Nav 12 * Initiate Owl Carousel 13 * 14 */ 15 16 17/*! 18* lazyYT (lazy load YouTube videos) 19* v1.3.0 - 2016-03-06 20* https://github.com/Daugilas/lazyYT 21* (CC) This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 22* http://creativecommons.org/licenses/by-sa/4.0/ 23* Contributors: https://github.com/tylerpearson/lazyYT/graphs/contributors || https://github.com/daugilas/lazyYT/graphs/contributors 24* 25* Usage: <div class="lazyYT" data-youtube-id="laknj093n" data-parameters="rel=0">loading...</div> 26*/ 27 28!function(t){"use strict";function e(e,a){var i,l,n=e.data("width"),r=e.data("height"),o=e.attr("title")||e.data("title"),c=e.data("display-title"),d=e.data("ratio")?e.data("ratio"):a.default_ratio,u=e.data("display-duration"),y=e.data("youtube-id"),h=[],v=e.text()?e.text():a.loading_text,f=["https://www.googleapis.com/youtube/v3/videos?id=",y,"&key=",a.yt_api_key,"&part=snippet"].join(""),g=e.data("parameters")||"";d=d.split(":"),g+="&"+a.youtube_parameters,"boolean"!=typeof c&&(c=a.display_title),"boolean"!=typeof u&&(u=a.display_duration),"number"==typeof n&&"number"==typeof r?(e.width(n),i=r+"px"):"number"==typeof n?(e.width(n),i=n*d[1]/d[0]+"px"):(n=e.width(),0==n&&(n=e.parent().width()),i=d[1]/d[0]*100+"%"),h.push('<div class="ytp-thumbnail">'),h.push('<button class="ytp-large-play-button ytp-button" tabindex="0" aria-label="Play"'),320>=n?h.push(' style="transform: scale(0.61);"'):640>=n&&h.push(' style="transform: scale(0.85);"'),c&&o&&h.push(' aria-label="',o,'"'),h.push(">"),h.push('<svg height="100%" version="1.1" viewBox="0 0 68 48" width="100%">'),h.push('<path class="ytp-large-play-button-bg" d="m .66,37.62 c 0,0 .66,4.70 2.70,6.77 2.58,2.71 5.98,2.63 7.49,2.91 5.43,.52 23.10,.68 23.12,.68 .00,-1.3e-5 14.29,-0.02 23.81,-0.71 1.32,-0.15 4.22,-0.17 6.81,-2.89 2.03,-2.07 2.70,-6.77 2.70,-6.77 0,0 .67,-5.52 .67,-11.04 l 0,-5.17 c 0,-5.52 -0.67,-11.04 -0.67,-11.04 0,0 -0.66,-4.70 -2.70,-6.77 C 62.03,.86 59.13,.84 57.80,.69 48.28,0 34.00,0 34.00,0 33.97,0 19.69,0 10.18,.69 8.85,.84 5.95,.86 3.36,3.58 1.32,5.65 .66,10.35 .66,10.35 c 0,0 -0.55,4.50 -0.66,9.45 l 0,8.36 c .10,4.94 .66,9.45 .66,9.45 z" fill="#1f1f1e" fill-opacity="0.9"></path>'),h.push('<path d="m 26.96,13.67 18.37,9.62 -18.37,9.55 -0.00,-19.17 z" fill="#fff"></path>'),h.push('<path d="M 45.02,23.46 45.32,23.28 26.96,13.67 43.32,24.34 45.02,23.46 z" fill="#ccc"></path>'),h.push("</svg>"),h.push("</button>"),h.push('<div class="ytp-spinner" data-layer="4">'),h.push('<span class="ytp-spinner-svg">'),h.push('<svg height="100%" version="1.1" viewBox="0 0 22 22" width="100%">'),h.push('<svg x="7" y="1"><circle class="ytp-spinner-dot ytp-spinner-dot-0" cx="4" cy="4" r="2"></circle></svg>'),h.push('<svg x="11" y="3"><circle class="ytp-spinner-dot ytp-spinner-dot-1" cx="4" cy="4" r="2"></circle></svg>'),h.push('<svg x="13" y="7"><circle class="ytp-spinner-dot ytp-spinner-dot-2" cx="4" cy="4" r="2"></circle></svg>'),h.push('<svg x="11" y="11"><circle class="ytp-spinner-dot ytp-spinner-dot-3" cx="4" cy="4" r="2"></circle></svg>'),h.push('<svg x="7" y="13"><circle class="ytp-spinner-dot ytp-spinner-dot-4" cx="4" cy="4" r="2"></circle></svg>'),h.push('<svg x="3" y="11"><circle class="ytp-spinner-dot ytp-spinner-dot-5" cx="4" cy="4" r="2"></circle></svg>'),h.push('<svg x="1" y="7"><circle class="ytp-spinner-dot ytp-spinner-dot-6" cx="4" cy="4" r="2"></circle></svg>'),h.push('<svg x="3" y="3"><circle class="ytp-spinner-dot ytp-spinner-dot-7" cx="4" cy="4" r="2"></circle></svg>'),h.push("</svg>"),h.push("</span>"),h.push('<div class="ytp-spinner-message" style="display: none;">If playback doesn\'t begin shortly, try restarting your device.</div>'),h.push("</div>"),u&&h.push('<span class="video-time" style="display:none;"></span>'),h.push("</div>"),c&&(h.push('<div class="ytp-gradient-top"></div>'),h.push('<div class="ytp-chrome-top">'),h.push('<div class="ytp-title">'),h.push('<div class="ytp-title-text">'),h.push('<a id="lazyYT-title-',y,'" class="ytp-title-link" tabindex="13" target="_blank" data-se
28ssionlink="feature=player-title" href="https://www.youtube.com/watch?v=',y,'">'),h.push(o?o:v),h.push("</a>"),h.push("</div>"),h.push("</div>"),h.push("</div>")),e.css({"padding-bottom":i}).html(h.join("")),l=e.find(".ytp-thumbnail").on("click",function(t){t.preventDefault(),e.hasClass(a.video_loaded_class)||(e.html('<iframe src="//www.youtube.com/embed/'+y+"?"+g+'&autoplay=1" frameborder="0" allowfullscreen></iframe>').addClass(a.video_loaded_class),"function"==typeof a.callback&&a.callback.call(e))}),s(y,n,l,f),(!o&&c||u)&&(u&&(f+=",contentDetails"),t.getJSON(f,function(t){var s=t.items[0];e.find("#lazyYT-title-"+y).text(s.snippet.title),u&&e.find(".video-time").text(p(s.contentDetails.duration,a)).show()}))}function s(e,s,p,l){var n,r,o=new Image;0==s&&(s=p.width()),n=s>640?"maxresdefault.jpg":s>480?"sddefault.jpg":s>320?"hqdefault.jpg":s>120?"mqdefault.jpg":0==s?"hqdefault.jpg":"default.jpg",r=["https://img.youtube.com/vi/",e,"/",n].join(""),o.onload=function(e){var n=i(e,"naturalWidth");s>n?t.getJSON(l,function(t){var e=t.items[0],i=e.snippet.thumbnails;0==s&&(s=p.width()),r=s>640&&"object"==typeof i.maxres?i.maxres.url:s>480&&"object"==typeof i.standard?i.standard.url:s>320&&"object"==typeof i.high?i.high.url:s>120&&"object"==typeof i.medium?i.medium.url:i["default"].url,a(p,r)}):a(p,this.src)},o.src=r}function a(t,e){t.css({"background-image":["url(",e,")"].join("")}).addClass("lazyYT-image-loaded")}function i(t,e){var s;return s="object"==typeof t.path?t.path[0]:"object"==typeof t.target?t.target:t.originalTarget,s.naturalWidth}function p(t,e){for(var s=[],a=0,i=t.match(/P(?:(\d*)Y)?(?:(\d*)M)?(?:(\d*)W)?(?:(\d*)D)?T(?:(\d*)H)?(?:(\d*)M)?(?:(\d*)S)?/i),p=[{pos:1,multiplier:31536e3},{pos:2,multiplier:2592e3},{pos:3,multiplier:604800},{pos:4,multiplier:86400},{pos:5,multiplier:3600},{pos:6,multiplier:60},{pos:7,multiplier:1}],l=0;l<p.length;l++)"undefined"!=typeof i[p[l].pos]&&(a+=parseInt(i[p[l].pos])*p[l].multiplier);return a>3599&&(s.push(parseInt(a/3600)),a%=3600),s.push(("0"+parseInt(a/60)).slice(-2)),s.push(("0"+a%60).slice(-2)),s.join(":")}t.fn.lazyYT=function(s,a){var i={yt_api_key:s,youtube_parameters:"rel=0",loading_text:"Loading...",display_title:!0,default_ratio:"16:9",display_duration:!1,callback:null,video_loaded_class:"lazyYT-video-loaded",container_class:"lazyYT-container"},p=t.extend(i,a);
28return this.each(function(){var s=t(this).addClass(p.container_class);e(s,p)})}}(jQuery); 29 30/* 31 * Magic 32 */ 33 34$(document).ready(function(){ 35 // gives page-header container the same background image as it's child image 36 var imgUrl = $('.page-header.cover-photo > img, .powerhouse-header > img').attr('src'); 37 if (typeof imgUrl !== 'undefined') { 38 $('.page-header, .powerhouse-header').css('background-image', 'url(' + imgUrl + ')'); 39 }; 40 41 // initiates lazyYT plugin 42 $('.lazyYT').lazyYT('AIzaSyAT7q0IEqaQKU79OSQ-auESoldDwdSB8PI', { 43 display_duration: false, 44 youtube_parameters: 'rel=0&showinfo=0', 45 default_ratio: '16:9', 46 display_title: false 47 }); 48 // hides caption and plays video on caption link click 49 $('.video-container .cta-link').click(function(e) { 50 e.preventDefault(); 51 $(this).closest('.caption-wrapper').addClass('disabled'); 52 $(this).closest('.video-container').find('.lazyYT-image-loaded').trigger('click'); 53 }); 54 // hides caption on video player click 55 $('.video-container .embed-responsive').click(function() { 56 $(this).closest('.video-container').find('.caption-wrapper').addClass('disabled'); 57 }); 58}); 59 60/* 61 * Page Header Image Margin 62 */ 63 64$(document).ready(function() { 65 var headerImageMargin = function() { 66 if(Modernizr.mq('(min-width: 1200px)')){ 67 var offset = $('.page-header').offset(); 68 if ( typeof offset !== 'undefined') { 69 $('.page-header:not(.page-header-scroll) > img').css('margin-top', offset.top * -1 - 1); 70 } 71 } else { 72 $('.page-header > img').css('margin-top', 0); 73 }; 74 }; 75 headerImageMargin(); 76 $(window).bind('resize', function() { 77 headerImageMargin(); 78 }); 79}); 80 81 82 83 84 85// Match Breadcrumb Theme 86 87 88$(document).ready(function() { 89 var $breadcrumb = $('nav.nav-breadcrumb'); 90 91 if (!$breadcrumb.length) { 92 console.warn('[Breadcrumb Script] No <nav class="nav-breadcrumb"> found.'); 93 return; 94 } 95 96 // Finds the first <section> that appears AFTER the breadcrumb in document order 97 // (Works even if <nav> is nested inside a <header> or wrapper) 98 var $firstSection = $('section').filter(function() { 99 return (this.compareDocumentPosition($breadcrumb[0]) & Node.DOCUMENT_POSITION_PRECEDING); 100 }).first(); 101 102 // Fallback: If document position filter fails, try standard sibling search 103 if (!$firstSection.length) { 104 $firstSection = $breadcrumb.nextAll('section').first(); 105 } 106 107 if (!$firstSection.length) { 108 console.warn('[Breadcrumb Script] No <section> found anywhere after <nav.nav-breadcrumb>.'); 109 return; 110 } 111 112 console.log('[Breadcrumb Script] Targeted section:', $firstSection[0]); 113 console.log('[Breadcrumb Script] Section classes:', $firstSection.attr('class')); 114 115 // Check for bg-image 116 if ($firstSection.hasClass('bg-image')) { 117 console.info('[Breadcrumb Script] Section has "bg-image". Skipping theme sync.'); 118 return; 119 } 120 121 var themes = ['theme-light-gray', 'theme-cream', 'theme-brick', 'theme-slate', 'bg-white', 'bg-dark', 'bg-light', 'bg-black', 'bg-secondary', 'text-white', 'text-black', 'text-light', 'text-dark']; 122 123 $breadcrumb.removeClass(themes.join(' ')); 124 125 var matched = themes.some(function(theme) { 126 if ($firstSection.hasClass(theme)) { 127 $breadcrumb.addClass(theme); 128 console.log('[Breadcrumb Script] Applied theme:', theme); 129 return true; 130 } 131 return false; 132 }); 133 134 if (!matched) { 135 console.info('[Breadcrumb Script] No matching theme class found on target section.'); 136 } 137}); 138 139 140 141/* 142 * Page Contents Nav 143 */ 144 145// fixes the scroll offset when navigating sections 146$(window).bind("load resize", function(){ 147 if(Modernizr.mq("(max-width: 767px)")){ 148 $('.page-contents a').bind('click',function(event){ 149 var $anchor = $(this); 150 $('html, body').stop().animate({ 151 scrollTop: $($anchor.attr('href')).offset().top-0 152 }, 400); 153 event.preventDefault(); 154 }); 155 } else { 156 $('.page-contents a').bind('click',function(event){ 157 var $anchor = $(this); 158 $('html, body').stop().animate({ 159 scrollTop: $($anchor.attr('href')).offset().top-46 160 }, 400); 161 event.preventDefault(); 162 }); 163 }; 164}); 165 166 167// data-spy="scroll" and data-spy="affix" were removed in Bootstrap 5 168 169$(function() { 170// $('body').attr('data-spy', 'scroll'); 171 $('body').attr('data-target', '.page-contents'); 172 $('body').attr('id', 'top'); 173 $('.page-contents').attr('data-offset-top', '160'); 174// $('.page-contents').attr('data-spy', 'affix'); 175});
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.