1/* 2* debouncedresize: special jQuery event that happens once after a window resize 3* 4* latest version and complete README available on Github: 5* https://github.com/louisremi/jquery-smartresize/blob/master/jquery.debouncedresize.js 6* 7* Copyright 2011 @louis_remi 8* Licensed under the MIT license. 9*/ 10var $event = $.event, 11$special, 12resizeTimeout; 13 14$special = $event.special.debouncedresize = { 15 setup: function() { 16 $( this ).on( "resize", $special.handler ); 17 }, 18 teardown: function() { 19 $( this ).off( "resize", $special.handler ); 20 }, 21 handler: function( event, execAsap ) { 22 // Save the context 23 var context = this, 24 args = arguments, 25 dispatch = function() { 26 // set correct event type 27 event.type = "debouncedresize"; 28 $event.dispatch.apply( context, args ); 29 }; 30 31 if ( resizeTimeout ) { 32 clearTimeout( resizeTimeout ); 33 } 34 35 execAsap ? 36 dispatch() : 37 resizeTimeout = setTimeout( dispatch, $special.threshold ); 38 }, 39 threshold: 250 40 }; 41 42// ======================= imagesLoaded Plugin =============================== 43// https://github.com/desandro/imagesloaded 44 45// $('#my-container').imagesLoaded(myFunction) 46// execute a callback when all images have loaded. 47// needed because .load() doesn't work on cached images 48 49// callback function gets image collection as argument 50// this is the container 51 52// original: MIT license. Paul Irish. 2010. 53// contributors: Oren Solomianik, David DeSandro, Yiannis Chatzikonstantinou 54 55// blank image data-uri bypasses webkit log warning (thx doug jones) 56var BLANK = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=='; 57 58$.fn.imagesLoaded = function( callback ) { 59 var $this = this, 60 deferred = $.isFunction($.Deferred) ? $.Deferred() : 0, 61 hasNotify = $.isFunction(deferred.notify), 62 $images = $this.find('img').add( $this.filter('img') ), 63 loaded = [], 64 proper = [], 65 broken = []; 66 67 // Register deferred callbacks 68 if ($.isPlainObject(callback)) { 69 $.each(callback, function (key, value) { 70 if (key === 'callback') { 71 callback = value; 72 } else if (deferred) { 73 deferred[key](value); 74 } 75 }); 76 } 77 78 function doneLoading() { 79 var $proper = $(proper), 80 $broken = $(broken); 81 82 if ( deferred ) { 83 if ( broken.length ) { 84 deferred.reject( $images, $proper, $broken ); 85 } else { 86 deferred.resolve( $images ); 87 } 88 } 89 90 if ( $.isFunction( callback ) ) { 91 callback.call( $this, $images, $proper, $broken ); 92 } 93 } 94 95 function imgLoaded( img, isBroken ) { 96 // don't proceed if BLANK image, or image is already loaded 97 if ( img.src === BLANK || $.inArray( img, loaded ) !== -1 ) { 98 return; 99 } 100 101 // store element in loaded images array 102 loaded.push( img ); 103 104 // keep track of broken and properly loaded images 105 if ( isBroken ) { 106 broken.push( img ); 107 } else { 108 proper.push( img ); 109 } 110 111 // cache image and its state for future calls 112 $.data( img, 'imagesLoaded', { isBroken: isBroken, src: img.src } ); 113 114 // trigger deferred progress method if present 115 if ( hasNotify ) { 116 deferred.notifyWith( $(img), [ isBroken, $images, $(proper), $(broken) ] ); 117 } 118 119 // call doneLoading and clean listeners if all images are loaded 120 if ( $images.length === loaded.length ){ 121 setTimeout( doneLoading ); 122 $images.unbind( '.imagesLoaded' ); 123 } 124 } 125 126 // if no images, trigger immediately 127 if ( !$images.length ) { 128 doneLoading(); 129 } else { 130 $images.bind( 'load.imagesLoaded error.imagesLoaded', function( event ){ 131 // trigger imgLoaded 132 imgLoaded( event.target, event.type === 'error' ); 133 }).each( function( i, el ) { 134 var src = el.src; 135 136 // find out if this image has been already checked for status 137 // if it was, and src has not changed, call imgLoaded on it 138 var cached = $.data( el, 'imagesLoaded' ); 139 if ( cached && cached.src === src ) { 140 imgLoaded( el, cached.isBroken ); 141 return; 142 } 143 144 // if complete is true and browser supports natural sizes, try 145 // to check for image status manually 146 if ( el.complete && el.naturalWidth !== undefined ) { 147 imgLoaded( el, el.naturalWidth === 0 || el.naturalHeight === 0 ); 148 return; 149 } 150 151 // cached images don't fire load sometimes, so we reset src, but only when 152 // dealing with IE, or image is complete (loaded) and failed manual check 153 // webkit hack from http://groups.google.com/group/jquery-dev/browse_thread/thread/eee6ab7b2da50e1f 154 if ( el.readyState || el.complete ) { 155 el.src = BLANK; 156 el.src = src; 157 } 158 }); 159 } 160 161 return deferred ? deferred.promise( $this ) : $this; 162}; 163 164 165var PureGrid = (function() { 166 167 var $grid = $( '#og-grid' ),
168 // the items 169 $items = $grid.children( 'li' ), 170 current = -1, 171 expanderPosition = 0, 172 transEndEventNames = { 173 'WebkitTransition' : 'webkitTransitionEnd', 174 'MozTransition' : 'transitionend', 175 'OTransition' : 'oTransitionEnd', 176 'msTransition' : 'MSTransitionEnd', 177 'transition' : 'transitionend' 178 }, 179 transEndEventName = transEndEventNames[ Modernizr.prefixed( 'transition' ) ], 180 // support for csstransitions 181 support = Modernizr.csstransitions, 182 $body = $( 'html, body' ), 183 settings = { 184 minHeight : 500, 185 speed : 350, 186 marginBottom : 20, 187 easing : 'ease' 188 }; 189 190 function init( config ) { 191 192 // the settings.. 193 settings = $.extend( true, {}, settings, config ); 194 195 // preload all images 196 $grid.imagesLoaded( function() { 197 $('.flexslider').flexslider({ 198 animation: "fade", 199 slideshow: false, 200 animationLoop: true, 201 animationSpeed: "3000", 202 slideshowSpeed: "8000", 203 controlNav: false, 204 205 }); 206 saveItemInfo( true ); 207 initEvents(); 208 } ); 209 210 } 211 212 function initEvents() { 213 214 // when clicking an item, show the preview with the item´s info and large image. 215 // close the item if already expanded. 216 // also close if clicking on the item´s cross 217 initItemsEvents( $items ); 218 219 // on window resize get the window´s size again 220 // reset some values.. 221 $( window ).on( 'debouncedresize', function() { 222 saveItemInfo( true ); 223 scrollExtra = 0; 224 previewPos = -1; 225 // save item´s offset 226 $newheight = $('#og-grid li:first-child .dynamic-portfolio-holder').height(); 227 $items.each( function() { 228 var $item = $( this ); 229 230 $item.stop().animate({ 'height': $newheight}); 231 232 }); 233 $expanded = $('#og-grid li.expanded'); 234 $expanded.removeClass('expanded').find('.og-expander').animate({ opacity: '0' },500,function(){ 235 $expanded.find('.og-expander').css({ height: 0 }); 236 //$expanded.stop().animate({ 'height' :$expanded.data( 'height' ) },200); 237 }); 238 /*var preview = $.data( this, 'preview' ); 239 if( typeof preview != 'undefined' ) { 240 hidePreview(); 241 }*/ 242 243 } ); 244 245 } 246 247 // saves the item´s offset top and height (if saveheight is true) 248 function saveItemInfo( saveheight ) { 249 $items.each( function() { 250 var $item = $( this ); 251 var $expanded = $item.find('.og-expander'); 252 $item.data( 'offsetTop', $item.offset().top ); 253 if( saveheight ) { 254 $item.data( 'height', $item.height() ); 255 $expanded.css({ 'height': 'auto' }).data( 'height', $expanded.height() ).css({ 'height': 0 }); 256 } 257 }); 258 } 259 260 function initItemsEvents( $items ) { 261 262 $items.on( 'click', 'span.og-close', function() { 263 hidePreview(); 264 return false; 265 } ).children( 'a.grid-item-image' ).on( 'click', function(e) { 266 e.preventDefault(); 267 var $item = $( this ).parent(); 268 // check if item already opened 269 //current === $item.index() ? hidePreview() : showPreview( $item ); 270 if($item.hasClass('clickable')){ 271 if($item.hasClass('expanded')) { } else { 272 showPreview( $item ) 273 } 274 } 275 return false; 276 } ); 277 } 278 279 function showPreview( $item ) { 280 var $expanded = $item.find('.og-expander'), 281 $image = $item.find('a.grid-item-image .dynamic-portfolio-holder'), 282 $icon = $item.find('.hover-icon'); 283 offsetTop = $item.offset().top; 284 current = $item.index(); 285 286 $item.addClass('loading'); 287 $icon.addClass('loading'); 288 289 totalheight = $expanded.data( 'height' ) + $image.height() + settings.marginBottom; 290 291 if(offsetTop!==expanderPosition && expanderPosition !==0) { 292 //not the same row 293 var $expandedItem = $('#og-grid li.expanded'); 294 $expandedItem.removeClass('expanded').find('.og-expander').animate({ height: 0, opacity: '0' },500,function(){ 295 $expandedItem.animate({ 'height' :$expandedItem.data( 'height' ) },200); 296 }); 297 $item.addClass('expanded').animate({ height: totalheight },500, function(){ 298 $expanded.css({height: $expanded.data( 'height' )}).animate({ opacity: '1' },500, function(){ 299 expanderPosition = $('#og-grid li.expanded').offset().top; 300 $body.animate( { scrollTop : expanderPosition }, settings.speed ); 301 $item.removeClass('loading').delay( 800 ).find('.hover-icon').removeClass('loading'); 302 303 }) 304 }) 305 } else { 306 // same row 307 var $expandedItem = $('#og-grid li.expanded'); 308 $item.addClass('expanded').animate({ height: totalheight },500, function(){ 309 $expanded.css({height: $expanded.data( 'height' )}).animate({ opacity: '1' } ,200, function(){ 310 }) 311 // 312 $expandedItem
313 .animate({ 'height' :$expandedItem.data( 'height' ) }) 314 .removeClass('expanded').find('.og-expander') 315 .css({ height: 0 }) 316 .css({ opacity: '0' }) 317 expanderPosition = $('#og-grid li.expanded').offset().top; 318 $body.animate( { scrollTop : expanderPosition }, settings.speed ); 319 $item.removeClass('loading').delay( 800 ).find('.hover-icon').removeClass('loading'); 320 321 322 }) 323 } 324 325 } 326 327 function setTransition($item) { 328 $item.find('.og-expander').css( 'transition', 'height ' + settings.speed + 'ms ' + settings.easing ); 329 $item.css( 'transition', 'height ' + settings.speed + 'ms ' + settings.easing ); 330 } 331 332 function hidePreview() { 333 334 var $expandedItem = $items.eq( current ); 335 current = -1; 336 $items.removeClass('expanded').find('.og-expander').animate({ opacity: '0' },500,function(){ 337 $items.find('.og-expander').css({ height: 0 }); 338 $items.animate({ 'height' :$items.data( 'height' ) },200); 339 }); 340 341 } 342 343 return { 344 init : init 345 }; 346 347})(); 348
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.