1/* info-graficos */ 2 3/* 4* debouncedresize: special jQuery event that happens once after a window resize 5* 6* latest version and complete README available on Github: 7* https://github.com/louisremi/jquery-smartresize/blob/master/jquery.debouncedresize.js 8* 9* Copyright 2011 @louis_remi 10* Licensed under the MIT license. 11*/ 12var $event = $.event, 13$special, 14resizeTimeout; 15 16$special = $event.special.debouncedresize = { 17 setup: function() { 18 $( this ).on( "resize", $special.handler ); 19 }, 20 teardown: function() { 21 $( this ).off( "resize", $special.handler ); 22 }, 23 handler: function( event, execAsap ) { 24 // Save the context 25 var context = this, 26 args = arguments, 27 dispatch = function() { 28 // set correct event type 29 event.type = "debouncedresize"; 30 $event.dispatch.apply( context, args ); 31 }; 32 33 if ( resizeTimeout ) { 34 clearTimeout( resizeTimeout ); 35 } 36 37 execAsap ? 38 dispatch() : 39 resizeTimeout = setTimeout( dispatch, $special.threshold ); 40 }, 41 threshold: 250 42}; 43 44// ======================= imagesLoaded Plugin =============================== 45// https://github.com/desandro/imagesloaded 46 47// $('#my-container').imagesLoaded(myFunction) 48// execute a callback when all images have loaded. 49// needed because .load() doesn't work on cached images 50 51// callback function gets image collection as argument 52// this is the container 53 54// original: MIT license. Paul Irish. 2010. 55// contributors: Oren Solomianik, David DeSandro, Yiannis Chatzikonstantinou 56 57// blank image data-uri bypasses webkit log warning (thx doug jones) 58var BLANK = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=='; 59 60$.fn.imagesLoaded = function( callback ) { 61 var $this = this, 62 deferred = $.isFunction($.Deferred) ? $.Deferred() : 0, 63 hasNotify = $.isFunction(deferred.notify), 64 $images = $this.find('img').add( $this.filter('img') ), 65 loaded = [], 66 proper = [], 67 broken = []; 68 69 // Register deferred callbacks 70 if ($.isPlainObject(callback)) { 71 $.each(callback, function (key, value) { 72 if (key === 'callback') { 73 callback = value; 74 } else if (deferred) { 75 deferred[key](value); 76 } 77 }); 78 } 79 80 function doneLoading() { 81 var $proper = $(proper), 82 $broken = $(broken); 83 84 if ( deferred ) { 85 if ( broken.length ) { 86 deferred.reject( $images, $proper, $broken ); 87 } else { 88 deferred.resolve( $images ); 89 } 90 } 91 92 if ( $.isFunction( callback ) ) { 93 callback.call( $this, $images, $proper, $broken ); 94 } 95 } 96 97 function imgLoaded( img, isBroken ) { 98 // don't proceed if BLANK image, or image is already loaded 99 if ( img.src === BLANK || $.inArray( img, loaded ) !== -1 ) { 100 return; 101 } 102 103 // store element in loaded images array 104 loaded.push( img ); 105 106 // keep track of broken and properly loaded images 107 if ( isBroken ) { 108 broken.push( img ); 109 } else { 110 proper.push( img ); 111 } 112 113 // cache image and its state for future calls 114 $.data( img, 'imagesLoaded', { isBroken: isBroken, src: img.src } ); 115 116 // trigger deferred progress method if present 117 if ( hasNotify ) { 118 deferred.notifyWith( $(img), [ isBroken, $images, $(proper), $(broken) ] ); 119 } 120 121 // call doneLoading and clean listeners if all images are loaded 122 if ( $images.length === loaded.length ){ 123 setTimeout( doneLoading ); 124 $images.unbind( '.imagesLoaded' ); 125 } 126 } 127 128 // if no images, trigger immediately 129 if ( !$images.length ) { 130 doneLoading(); 131 } else { 132 $images.bind( 'load.imagesLoaded error.imagesLoaded', function( event ){ 133 // trigger imgLoaded 134 imgLoaded( event.target, event.type === 'error' ); 135 }).each( function( i, el ) { 136 var src = el.src; 137 138 // find out if this image has been already checked for status 139 // if it was, and src has not changed, call imgLoaded on it 140 var cached = $.data( el, 'imagesLoaded' ); 141 if ( cached && cached.src === src ) { 142 imgLoaded( el, cached.isBroken ); 143 return; 144 } 145 146 // if complete is true and browser supports natural sizes, try 147 // to check for image status manually
148 if ( el.complete && el.naturalWidth !== undefined ) { 149 imgLoaded( el, el.naturalWidth === 0 || el.naturalHeight === 0 ); 150 return; 151 } 152 153 // cached images don't fire load sometimes, so we reset src, but only when 154 // dealing with IE, or image is complete (loaded) and failed manual check 155 // webkit hack from http://groups.google.com/group/jquery-dev/browse_thread/thread/eee6ab7b2da50e1f 156 if ( el.readyState || el.complete ) { 157 el.src = BLANK; 158 el.src = src; 159 } 160 }); 161 } 162 163 return deferred ? deferred.promise( $this ) : $this; 164}; 165 166var Grid = (function() { 167 168 // list of items 169 var $grid = $( '#og-grid' ), 170 // the items 171 $items = $grid.children( 'li' ), 172 // current expanded item's index 173 current = -1, 174 // position (top) of the expanded item 175 // used to know if the preview will expand in a different row 176 previewPos = -1, 177 // extra amount of pixels to scroll the window 178 scrollExtra = 0, 179 // extra margin when expanded (between preview overlay and the next items) 180 marginExpanded = 10, 181 $window = $( window ), winsize, 182 $body = $( 'html, body' ), 183 // transitionend events 184 transEndEventNames = { 185 'WebkitTransition' : 'webkitTransitionEnd', 186 'MozTransition' : 'transitionend', 187 'OTransition' : 'oTransitionEnd', 188 'msTransition' : 'MSTransitionEnd', 189 'transition' : 'transitionend' 190 }, 191 transEndEventName = transEndEventNames[ Modernizr.prefixed( 'transition' ) ], 192 // support for csstransitions 193 support = Modernizr.csstransitions, 194 // default settings 195 settings = { 196 minHeight : 600, 197 speed : 350, 198 easing : 'ease' 199 }; 200 201 function init( config ) { 202 203 // the settings.. 204 settings = $.extend( true, {}, settings, config ); 205 206 // preload all images 207 $grid.imagesLoaded( function() { 208 209 // save itemôs size and offset 210 saveItemInfo( true ); 211 // get windowôs size 212 getWinSize(); 213 // initialize some events 214 initEvents(); 215 216 } ); 217 218 } 219 220 // add more items to the grid. 221 // the new items need to appended to the grid. 222 // after that call Grid.addItems(theItems); 223 function addItems( $newitems ) { 224 225 $items = $items.add( $newitems ); 226 227 $newitems.each( function() { 228 var $item = $( this ); 229 $item.data( { 230 offsetTop : $item.offset().top, 231 height : $item.height() 232 } ); 233 } ); 234 235 initItemsEvents( $newitems ); 236 237 } 238 239 // saves the itemôs offset top and height (if saveheight is true) 240 function saveItemInfo( saveheight ) { 241 $items.each( function() { 242 var $item = $( this ); 243 $item.data( 'offsetTop', $item.offset().top ); 244 if( saveheight ) { 245 $item.data( 'height', $item.height() ); 246 } 247 } ); 248 } 249 250 function initEvents() { 251 252 // when clicking an item, show the preview with the itemôs info and large image. 253 // close the item if already expanded. 254 // also close if clicking on the itemôs cross 255 initItemsEvents( $items ); 256 257 // on window resize get the windowôs size again 258 // reset some values.. 259 $window.on( 'debouncedresize', function() { 260 261 scrollExtra = 0; 262 previewPos = -1; 263 // save itemôs offset 264 saveItemInfo(); 265 getWinSize(); 266 var preview = $.data( this, 'preview' ); 267 if( typeof preview != 'undefined' ) { 268 hidePreview(); 269 } 270 271 } ); 272 273 } 274 275 function initItemsEvents( $items ) { 276 $items.on( 'click', 'span.og-close', function() { 277 hidePreview(); 278 return false; 279 } ).children( 'a' ).on( 'click', function(e) { 280 281 var $item = $( this ).parent(); 282 // check if item already opened 283 current === $item.index() ? hidePreview() : showPreview( $item ); 284 return false; 285 286 } ); 287 } 288 289 function getWinSize() { 290 winsize = { width : $window.width(), height : $window.height() }; 291 } 292 293 function showPreview( $item ) { 294 295 var preview = $.data( this, 'preview' ), 296 // itemôs offset top 297 position = $item.data( 'offsetTop' ); 298 299 scrollExtra = 0; 300 301 // if a preview exists and previewPos is different (different row) from itemôs top then close it 302 if( typeof preview != 'undefined' ) { 303 304 // not in the same row 305 if( previewPos !== position ) { 306 // if position > previewPos then we need to take te current previewôs height in consideration when scrolling the window 307 if( position > previewPos ) { 308 scrollExtra = preview.height; 309 } 310 hidePreview(); 311 } 312 // same row 313 else { 314 preview.update( $item ); 315 return false; 316 } 317 318 } 319 320 // update previewPos 321 previewPos = position; 322 // initialize new preview for the clicked item 323 preview = $.data( this, 'preview', new Preview( $item ) ); 324 // expand preview overlay 325 preview.open(); 326 327 } 328 329 function hidePreview() { 330 current = -1; 331 var preview = $.data( this, 'preview' ); 332 preview.close(); 333 $.removeData( this, 'preview' ); 334 } 335 336 // the preview obj / overlay 337 function Preview( $item ) { 338 this.$item = $item; 339 this.expandedIdx = this.$item.index(); 340 this.create(); 341 this.update(); 342 } 343 344 Preview.prototype = { 345 create : function() { 346 // create Preview structure: 347 this.$title = $( '<h3></h3>' ); 348 this.$description = $( '<p></p>' ); 349 this.$href = $( '<div></div>' ); 350 this.$details = $( '<div class="og-details"></div>' ).append( this.$description, this.$href ); 351 this.$loading = $( '<div class="og-loading"></div>' ); 352 this.$fullimage = $( '<div class="og-fullimg"></div>' ).append( this.$loading ); 353 this.$closePreview = $( '<span class="og-close"></span>' ); 354 this.$previewInner = $( '<div class="og-expander-inner"></div>' ).append( this.$closePreview, this.$fullimage, this.$details ); 355 this.$previewEl = $( '<div class="og-expander"></div>' ).append( this.$previewInner ); 356 // append preview element to the item 357 this.$item.append( this.getEl() ); 358 // set the transitions for the preview and the item 359 if( support ) { 360 this.setTransition(); 361 } 362 }, 363 update : function( $item ) { 364 365 if( $item ) { 366 this.$item = $item; 367 } 368 369 // if already expanded remove class "og-expanded" from current item and add it to new item 370 if( current !== -1 ) { 371 var $currentItem = $items.eq( current ); 372 $currentItem.removeClass( 'og-expanded' ); 373 this.$item.addClass( 'og-expanded' ); 374 // position the preview correctly 375 this.positionPreview(); 376 } 377 378 // update current value 379 current = this.$item.index(); 380 381 // update previewôs content 382 var $itemEl = this.$item.children( 'a' ), 383 eldata = { 384 href : $itemEl.attr( 'href' ), 385 largesrc : $itemEl.data( 'largesrc' ), 386 title : $itemEl.data( 'title' ), 387 description : $itemEl.data( 'description' ) 388 }; 389 390 this.$title.html( eldata.title ); 391 this.$description.html( eldata.description ); 392 this.$href.html( eldata.href ); 393 394 var self = this; 395 396 // remove the current image in the preview 397 if( typeof self.$largeImg != 'undefined' ) { 398 self.$largeImg.remove(); 399 } 400 401 // preload large image and add it to the preview
402 // for smaller screens we donôt display the large image (the media query will hide the fullimage wrapper) 403 if( self.$fullimage.is( ':visible' ) ) { 404 this.$loading.show(); 405 $( '<img/>' ).load( function() { 406 var $img = $( this ); 407 if( $img.attr( 'src' ) === self.$item.children('a').data( 'largesrc' ) ) { 408 self.$loading.hide(); 409 self.$fullimage.find( 'img' ).remove(); 410 self.$largeImg = $img.fadeIn( 350 ); 411 self.$fullimage.append( self.$largeImg ); 412 } 413 } ).attr( 'src', eldata.largesrc ); 414 } 415 416 }, 417 open : function() { 418 419 setTimeout( $.proxy( function() { 420 // set the height for the preview and the item 421 this.setHeights(); 422 // scroll to position the preview in the right place 423 this.positionPreview(); 424 }, this ), 25 ); 425 426 }, 427 close : function() { 428 429 var self = this, 430 onEndFn = function() { 431 if( support ) { 432 $( this ).off( transEndEventName ); 433 } 434 self.$item.removeClass( 'og-expanded' ); 435 self.$previewEl.remove(); 436 changeHeightLess(); 437 }; 438 439 setTimeout( $.proxy( function() { 440 441 if( typeof this.$largeImg !== 'undefined' ) { 442 this.$largeImg.fadeOut( 'fast' ); 443 } 444 this.$previewEl.css( 'height', 0 ); 445 // the current expanded item (might be different from this.$item) 446 var $expandedItem = $items.eq( this.expandedIdx ); 447 $expandedItem.css( 'height', $expandedItem.data( 'height' ) ).on( transEndEventName, onEndFn ); 448 449 if( !support ) { 450 onEndFn.call(); 451 } 452 453 }, this ), 25 ); 454 455 return false; 456 457 }, 458 calcHeight : function() { 459 460 var heightPreview = winsize.height - this.$item.data( 'height' ), 461 itemHeight = winsize.height; 462 463 if( heightPreview < settings.minHeight ) { 464 heightPreview = settings.minHeight; 465 itemHeight = settings.minHeight + this.$item.data( 'height' ) + marginExpanded; 466 } 467 468 this.height = heightPreview; 469 this.itemHeight = itemHeight; 470 471 }, 472 setHeights : function() { 473 474 var self = this, 475 onEndFn = function() { 476 if( support ) { 477 self.$item.off( transEndEventName ); 478 } 479 self.$item.addClass( 'og-expanded' ); 480 changeHeightMore(); 481 }; 482 483 this.calcHeight(); 484 this.$previewEl.css( 'height', this.height ); 485 this.$item.css( 'height', this.itemHeight ).on( transEndEventName, onEndFn ); 486 487 if( !support ) { 488 onEndFn.call(); 489 } 490 491 }, 492 positionPreview : function() { 493 494 // scroll page 495 // case 1 : preview height + item height fits in windowôs height 496 // case 2 : preview height + item height does not fit in windowôs height and preview height is smaller than windowôs height 497 // case 3 : preview height + item height does not fit in windowôs height and preview height is bigger than windowôs height 498 var position = this.$item.data( 'offsetTop' ), 499 previewOffsetT = this.$previewEl.offset().top - scrollExtra, 500 scrollVal = this.height + this.$item.data( 'height' ) + marginExpanded <= winsize.height ? position : this.height < winsize.height ? previewOffsetT - ( winsize.height - this.height ) : previewOffsetT; 501 502 //$body.animate( { scrollTop : scrollVal }, settings.speed ); 503 504 }, 505 setTransition : function() { 506 this.$previewEl.css( 'transition', 'height ' + settings.speed + 'ms ' + settings.easing ); 507 this.$item.css( 'transition', 'height ' + settings.speed + 'ms ' + settings.easing ); 508 }, 509 getEl : function() { 510 return this.$previewEl; 511 } 512 } 513 514 515 516 return { 517 init : init, 518 addItems : addItems 519 }; 520 521})(); 522 523$(".og-grid").on('mouseup',function(){ 524 var id = $(this).attr('class'); 525 //alert(id); 526 console.log($(window).width()); 527 //if($(window).width() > 500){ 528 $('html, body').animate({ 529 scrollTop: $('.'+id).offset().top +($(window).width()/2.5) 530 }, 500); 531 //} 532 });
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.