1/* 2 * agility.js 3 * 4 * The main javascript for Agility - Responsive HTML5/CSS3 Template by SevenSpark 5 * 6 * Copyright 2011 Chris Mavricos, SevenSpark 7 * http://sevenspark.com 8 * 9 */ 10 11jQuery(document).ready(function($){ 12 13 /* Style for JS-enabled */ 14 $('body').addClass('js-enabled'); 15 16 /* Keep track of the width for use in mobile browser displays */ 17 var currentWindowWidth = $(window).width(); 18 $(window).resize(function(){ 19 currentWindowWidth = $(window).width(); 20 }); 21 22 /* FLEX SLIDER */ 23 var $flexSlider = $('.flexslider'); 24 $flexSlider.flexslider({ 25 animation: "fade", 26 controlsContainer: ".flex-container", 27 prevText: "â", 28 nextText: "â", 29 pausePlay:true, 30 pauseOnHover:true, 31 controlNav: true, 32 manualControls: ".gallery-thumbs img", 33 before: function($slider){ 34 $slider.find('.flex-caption').fadeOut('fast'); 35 }, 36 after: function($slider){ 37 $slider.find('.flex-caption').fadeIn(); 38 } 39 }); 40 $('.height-expand').each(function(){ 41 $(this).height($(this).prev().height()); 42 }); 43 44 /* DROP PANEL */ 45 $('#drop-panel-expando').click(function(e){ 46 e.preventDefault(); 47 $('.drop-panel').slideToggle(); 48 }); 49 50 /* PRETTY PHOTO */ 51 $("a[data-rel^='prettyPhoto']").prettyPhoto({ 52 social_tools: '', 53 overlay_gallery: false 54 }); 55 56 /* MOBILE MENU */ 57 $('.mobile-menu-button').click(function(e){ 58 e.preventDefault(); 59 var $menu = $($(this).attr('href')); 60 $menu.toggleClass('menu-open'); //toggle() 61 62 if(typeof $navClose !== 'undefined' && !$menu.hasClass('menu-open') ){ 63 console.log('hide'); 64 $navClose.hide(); 65 } 66 }); 67 68 /* Expander for featured images */ 69 $('.single-post-feature-expander').click(function(){ 70 $('.featured-image').toggleClass('full-width'); 71 }); 72 73 //Size images in IE 74 imgSizer.collate(); 75 76 77 //IPHONE, IPAD, IPOD 78 var deviceAgent = navigator.userAgent.toLowerCase(); 79 var is_iOS = deviceAgent.match(/(iphone|ipod|ipad)/); 80 81 if (is_iOS) { 82 83 $('#main-nav').prepend('<a href="#" class="nav-close">Ã</a>'); // Close Submenu 84 85 var $navClose = $('.nav-close'); 86 $navClose.hide().click(function(e){ 87 e.preventDefault(); 88 if(currentWindowWidth >= 767){ 89 $(this).hide(); 90 } 91 }); 92 93 $('#main-nav > ul > li').hover(function(e){ 94 e.preventDefault(); 95 if(currentWindowWidth < 767){ 96 $navClose.css({ 97 top : $(this).position().top + 33, 98 left : '', 99 right : 0 100 }).show(); 101 } 102 else{ 103 $navClose.css({ 104 left : $(this).position().left + parseInt($(this).css('marginLeft')), 105 top : '', 106 right : 'auto' 107 }).show(); 108 } 109 }); 110 111 } 112 113 114 //NON-IOS 115 if(!is_iOS){ 116 //iOS doesn't like CSS3 transitioning preloader, so don't use it 117 $('.preload').preloadImages({ 118 showSpeed: 200 // length of fade-in animation, should be .2 in CSS transition 119 }); 120 $('.video-container').addClass('video-flex'); 121 } 122 123 124 //ANDROID 125 var is_Android = deviceAgent.match(/(android)/); 126 if(is_Android){ 127 //Do something special with Android 128 } 129 130 131 //IE automatic grid clears 132 if($.browser.msie){ 133 $('.portfolio.col-4 article:nth-child(4n+1)').addClass('clear-grid'); 134 $('.portfolio.col-3 article:nth-child(3n+1)').addClass('clear-grid'); 135 $('.portfolio.col-2 article:nth-child(2n+1)').addClass('clear-grid'); 136 } 137 138 139 //HTML5 Fallbacks 140 if(!Modernizr.input.placeholder){ 141 $('.fallback').show(); 142 } 143 144 //Google Maps 145 if(typeof google.maps.LatLng !== 'undefined'){ 146 $('.map_canvas').each(function(){ 147 148 var $canvas = $(this); 149 var dataZoom = $canvas.attr('data-zoom') ? parseInt($canvas.attr('data-zoom')) : 8; 150 151 var latlng = $canvas.attr('data-lat') ? 152 new google.maps.LatLng($canvas.attr('data-lat'), $canvas.attr('data-lng')) : 153 new google.maps.LatLng(40.7143528, -74.0059731); 154 155 var myOptions = { 156 zoom: dataZoom, 157 mapTypeId: google.maps.MapTypeId.ROADMAP, 158 center: latlng 159 }; 160 161 var map = new google.maps.Map(this, myOptions); 162 163 if($canvas.attr('data-address')){ 164 var geocoder = new google.maps.Geocoder(); 165 geocoder.geocode({ 166 'address' : $canvas.attr('data-address') 167 }, 168 function(results, status) { 169 if (status == google.maps.GeocoderStatus.OK) { 170 map.setCenter(results[0].geometry.location); 171 var marker = new google.maps.Marker({ 172 map: map, 173 position: results[0].geometry.location, 174 title: $canvas.attr('data-mapTitle') 175 }); 176 } 177 }); 178 } 179 }); 180 } 181 182 //Twitter
183 if($('#tweet').size() > 0){ 184 getTwitters('tweet', { 185 id: 'Chesterman_BnB', 186 count: 3, 187 enableLinks: true, 188 ignoreReplies: true, 189 clearContents: true, 190 template: '%text% <a href="http://twitter.com/%user_screen_name%/statuses/%id_str%/" class="tweet-time" target="_blank">%time%</a>'+ 191 '<a href="http://twitter.com/%user_screen_name%" class="twitter-account" title="Follow %user_screen_name% on Twitter" target="_blank" ><img src="../js/%user_profile_image_url%" /></a>' 192 }); 193 } 194 195}); 196 197 198 199//Image Preloader 200jQuery.fn.preloadImages = function(options){ 201 202 var defaults = { 203 showSpeed: 200 204 }; 205 206 var options = jQuery.extend(defaults, options); 207 208 return this.each(function(){ 209 var $container = jQuery(this); 210 var $image = $container.find('img'); 211 212 $image.addClass('loading'); //hide image while loading 213 214 $image.bind('load error', function(){ 215 $image.removeClass('loading'); //allow image to display (will fade in with CSS3 trans) 216 217 setTimeout(function(){ 218 $container.removeClass('preload'); //remove the preloading class to swap the bkg 219 }, options.showSpeed); 220 221 }); 222 223 if($image[0].complete || (jQuery.browser.msie )) { 224 $image.trigger('load'); //IE has glitchy load triggers, so trigger it automatically 225 } 226 }); 227} 228 229 230/* IE Image Resizing - by Ethan Marcotte - http://unstoppablerobotninja.com/entry/fluid-images/ */ 231var imgSizer = { 232 Config : { 233 imgCache : [] 234 ,spacer : "../images/spacer.gif" 235 } 236 237 ,collate : function(aScope) { 238 var isOldIE = (document.all && !window.opera && !window.XDomainRequest) ? 1 : 0; 239 if (isOldIE && document.getElementsByTagName) { 240 var c = imgSizer; 241 var imgCache = c.Config.imgCache; 242 243 var images = (aScope && aScope.length) ? aScope : document.getElementsByTagName("img"); 244 for (var i = 0; i < images.length; i++) { 245 images[i].origWidth = images[i].offsetWidth; 246 images[i].origHeight = images[i].offsetHeight; 247 248 imgCache.push(images[i]); 249 c.ieAlpha(images[i]); 250 images[i].style.width = "100%"; 251 } 252 253 if (imgCache.length) { 254 c.resize(function() { 255 for (var i = 0; i < imgCache.length; i++) { 256 var ratio = (imgCache[i].offsetWidth / imgCache[i].origWidth); 257 imgCache[i].style.height = (imgCache[i].origHeight * ratio) + "px"; 258 } 259 }); 260 } 261 } 262 } 263 264 ,ieAlpha : function(img) { 265 var c = imgSizer; 266 if (img.oldSrc) { 267 img.src = img.oldSrc; 268 } 269 var src = img.src; 270 img.style.width = img.offsetWidth + "px"; 271 img.style.height = img.offsetHeight + "px"; 272 img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')" 273 img.oldSrc = src; 274 img.src = c.Config.spacer; 275 } 276 277 // Ghettomodified version of Simon Willison's addLoadEvent() -- http://simonwillison.net/2004/May/26/addLoadEvent/ 278 ,resize : function(func) { 279 var oldonresize = window.onresize; 280 if (typeof window.onresize != 'function') { 281 window.onresize = func; 282 } else { 283 window.onresize = function() { 284 if (oldonresize) { 285 oldonresize(); 286 } 287 func(); 288 } 289 } 290 } 291} 292 293
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.