1(function($) { 2 3 $(function() { 4 $('.site-title a .logo-2x, .site-title a .logo-3x').each(function() { 5 var $logo = $(this); 6 $('img', $logo).each(function() { 7 var $img = $(this); 8 if($img.get(0).complete) { 9 $img.width(parseInt($img.width()/($logo.hasClass('logo-2x') ? 2 : 3))); 10 $img.css({ visibility : 'visible' }); 11 setMargin($img.parent().find('img.default')); 12 } else { 13 $img.load(function() { 14 $img.width(parseInt($img.width()/2)); 15 $img.css({ visibility : 'visible' }); 16 setMargin($img.parent().find('img.default')); 17 }); 18 } 19 }); 20 }); 21 22 $('.site-title h1 .logo:visible img').load(function() { 23 $('.site-title a .logo:visible img.small').show(); 24 $(this).closest('.site-title .logo:visible').width(Math.max($('.site-title a .logo:visible img.default').width(), $('.site-title a .logo:visible img.small').width())); 25 }); 26 }); 27 28 function setMargin(img) { 29 var w = $(img).width(); 30 $(img).siblings('img.small').show(); 31 if($(img).closest('.header-main.logo-position-right').length) { 32 w = $(img).siblings('img.small').width(); 33 } 34 if($(img).closest('.header-main.logo-position-center').length) { 35 w = $(img).siblings('img.small').width() + ($(img).width() - $(img).siblings('img.small').width()) / 2; 36 $(img).siblings('img.small').css('margin-right', ($(img).width() - $(img).siblings('img.small').width()) / 2 + 'px'); 37 } 38 $(img).siblings('img.small').css('margin-left', '-' + w + 'px'); 39 } 40 41 function HeaderAnimation(el, options) { 42 this.el = el; 43 this.$el = $(el); 44 this.options = { 45 startTop: 100 46 }; 47 $.extend(this.options, options); 48 this.initialize(); 49 } 50 51 HeaderAnimation.prototype = { 52 initialize: function() { 53 var self = this; 54 this.hasAnimation = false; 55 this.originalMenuLinkPaddingTop = ''; 56 this.originalMenuLinkPaddingBottom = ''; 57 this.supportTransition = Modernizr.csstransitions; 58 this.$el.wrap('<div id="site-header-wrapper"></div>'); 59 this.$wrapper = $('#site-header-wrapper'); 60 this.initializeHeight(); 61 if(this.$el.hasClass('header-on-slideshow') && $('#main-content > *').first().is('.sc-slideshow, .block-slideshow')) { 62 this.$wrapper.addClass('header-on-slideshow'); 63 } else { 64 this.$el.removeClass('header-on-slideshow'); 65 } 66 if($('.page-title-block .sc-video-background').length && $('.page-title-block .sc-video-background').data('headerup')) { 67 this.$el.addClass('header-on-slideshow'); 68 this.$wrapper.addClass('header-on-slideshow'); 69 } 70 //this.$el.addClass('init'); 71 this.initializeStyles(); 72 this.updateTopOffset(); 73 if ($('#top-area').size() > 0) 74 this.options.startTop = $('#top-area').outerHeight(); 75 $(window).scroll(function() { 76 self.scrollHandler(); 77 }); 78 $(window).resize(function() { 79 self.scrollHandler(); 80 setTimeout(function() { 81 self.initializeHeight(); 82 }, 350); 83 }); 84 $(document).ready(function() { 85 self.scrollHandler(); 86 }); 87 88 }, 89 90 initializeStyles: function() { 91 var self = this; 92 if ($('.site-title a .logo:visible img.default', this.$el).size() > 0 && $('.site-title a .logo:visible img.default', this.$el)[0].complete) { 93 setMargin($('.site-title a .logo:visible img.default', this.$el)); 94 self.initializeHeight(); 95 } else { 96 $('.site-title a .logo:visible img.default', this.$el).on('load error', function() { 97 setMargin(this); 98 self.initializeHeight(); 99 }); 100 } 101 102 }, 103 104 initializeHeight: function() { 105 var shrink = this.$el.hasClass('shrink'); 106 var fixed = this.$el.hasClass('fixed'); 107 this.$el.removeClass('shrink fixed'); 108 this.updateTopOffset(); 109 if($('.page-title-block .sc-video-background').length && $('.page-title-block .sc-video-background').data('headerup')) { 110 $('.page-title-block').css('paddingTop', ''); 111 $('.page-title-block').css({ 112 paddingTop: parseInt($('.page-title-block').css('paddingTop')) + this.$el.outerHeight() + 'px' 113 }); 114 } 115 if($('#primary-navigation .menu-toggle').is(':visible')) 116 return false; 117 this.$wrapper.height(this.$el.outerHeight()); 118 if(shrink) { 119 this.$el.addClass('shrink'); 120 } 121 if(fixed) { 122 this.$el.addClass('fixed'); 123 } 124 }, 125 126 updateTopOffset: function() { 127 var offset = parseInt($('html').css('margin-top')); 128 if (this.$wrapper.hasClass('header-on-slideshow') && !this.$el.hasClass('fixed')) 129 offset = 0; 130 var scroll = getScrollY(); 131 if ($('#top-area').size() > 0 && $('#top-area').is(':visible')) { 132 var top_area_height = $('#top-area').outerHeight(); 133 if (scroll < top_area_height)
134 offset += top_area_height - scroll; 135 } 136 this.$el.css('top', offset + 'px'); 137 }, 138 139 firstShrink: function() { 140 this.$el.parent().css({ 141 position: 'static' 142 }); 143 if(this.$el.hasClass('header-on-slideshow') && $('#main-content > *').first().is('.sc-slideshow, .block-slideshow')) { 144 this.$wrapper.css({position: 'absolute'}); 145 } 146 this.$el.addClass('fixed'); 147 }, 148 149 scrollHandler: function() { 150 if (this.hasAnimation) 151 return false; 152 if($('#primary-navigation .menu-toggle').is(':visible')) 153 return false; 154 this.updateTopOffset(); 155 var scroll = getScrollY(); 156 if (scroll >= this.options.startTop) { 157 //this.$el.removeClass('init'); 158 if (!this.$el.hasClass('shrink')) { 159 this.firstShrink(); 160 this.shrink(); 161 } 162 } else { 163 if (this.$el.hasClass('shrink')) { 164 this.expand(); 165 } 166 } 167 }, 168 169 expand: function() { 170 var self = this; 171 this.hasAnimation = true; 172 this.$el.removeClass('shrink') 173 if (!this.supportTransition) { 174 if (this.originalMenuLinkPaddingTop || this.originalMenuLinkPaddingBottom) 175 $('#primary-menu > li > a').animate({ 176 paddingTop: this.originalMenuLinkPaddingTop, 177 paddingBottom: this.originalMenuLinkPaddingBottom 178 }, 300, function() { 179 self.hasAnimation = false; 180 }); 181 } else { 182 this.hasAnimation = false; 183 } 184 }, 185 186 shrink: function() { 187 var self = this; 188 this.hasAnimation = true; 189 this.$el.addClass('shrink'); 190 if (!this.supportTransition) { 191 this.originalMenuLinkPaddingTop = $('#primary-menu > li > a:first').css('padding-top'); 192 this.originalMenuLinkPaddingBottom = $('#primary-menu > li > a:first').css('padding-top'); 193 $('#primary-menu > li > a').animate({ 194 paddingTop: '28px', 195 paddingBottom: '28px' 196 }, 300, function () { 197 self.hasAnimation = false; 198 }); 199 } else { 200 this.hasAnimation = false; 201 } 202 } 203 }; 204 205 function getScrollY(elem){ 206 return window.pageYOffset || document.documentElement.scrollTop; 207 }; 208 209 $.fn.headerAnimation = function(options) { 210 options = options || {}; 211 return new HeaderAnimation(this.get(0), options); 212 } 213})(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.